mirror of
https://github.com/Karaka-Management/Resources.git
synced 2026-01-11 13:28:40 +00:00
add more phpoffice libs
This commit is contained in:
parent
b652dacd5b
commit
dca863d888
45
PhpOffice/Common/Adapter/Zip/PclZipAdapter.php
Normal file
45
PhpOffice/Common/Adapter/Zip/PclZipAdapter.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace PhpOffice\Common\Adapter\Zip;
|
||||
|
||||
use PclZip;
|
||||
|
||||
class PclZipAdapter implements ZipInterface
|
||||
{
|
||||
/**
|
||||
* @var PclZip
|
||||
*/
|
||||
protected $oPclZip;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tmpDir;
|
||||
|
||||
public function open($filename)
|
||||
{
|
||||
$this->oPclZip = new PclZip($filename);
|
||||
$this->tmpDir = sys_get_temp_dir();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addFromString($localname, $contents)
|
||||
{
|
||||
$pathData = pathinfo($localname);
|
||||
|
||||
$hFile = fopen($this->tmpDir.'/'.$pathData['basename'], "wb");
|
||||
fwrite($hFile, $contents);
|
||||
fclose($hFile);
|
||||
|
||||
$res = $this->oPclZip->add($this->tmpDir.'/'.$pathData['basename'], PCLZIP_OPT_REMOVE_PATH, $this->tmpDir, PCLZIP_OPT_ADD_PATH, $pathData['dirname']);
|
||||
if ($res == 0) {
|
||||
throw new \Exception("Error zipping files : " . $this->oPclZip->errorInfo(true));
|
||||
}
|
||||
unlink($this->tmpDir.'/'.$pathData['basename']);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
49
PhpOffice/Common/Adapter/Zip/ZipArchiveAdapter.php
Normal file
49
PhpOffice/Common/Adapter/Zip/ZipArchiveAdapter.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\Common\Adapter\Zip;
|
||||
|
||||
use ZipArchive;
|
||||
|
||||
class ZipArchiveAdapter implements ZipInterface
|
||||
{
|
||||
/**
|
||||
* @var ZipArchive
|
||||
*/
|
||||
protected $oZipArchive;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $filename;
|
||||
|
||||
public function open($filename)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
$this->oZipArchive = new ZipArchive();
|
||||
|
||||
if ($this->oZipArchive->open($this->filename, ZipArchive::OVERWRITE) === true) {
|
||||
return $this;
|
||||
}
|
||||
if ($this->oZipArchive->open($this->filename, ZipArchive::CREATE) === true) {
|
||||
return $this;
|
||||
}
|
||||
throw new \Exception("Could not open $this->filename for writing.");
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
if ($this->oZipArchive->close() === false) {
|
||||
throw new \Exception("Could not close zip file $this->filename.");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addFromString($localname, $contents)
|
||||
{
|
||||
if ($this->oZipArchive->addFromString($localname, $contents) === false) {
|
||||
throw new \Exception("Error zipping files : " . $localname);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
30
PhpOffice/Common/Adapter/Zip/ZipInterface.php
Normal file
30
PhpOffice/Common/Adapter/Zip/ZipInterface.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\Common\Adapter\Zip;
|
||||
|
||||
interface ZipInterface
|
||||
{
|
||||
/**
|
||||
* Open a ZIP file archive
|
||||
* @param string $filename
|
||||
* @return $this
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function open($filename);
|
||||
|
||||
/**
|
||||
* Close the active archive (opened or newly created)
|
||||
* @return $this
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function close();
|
||||
|
||||
/**
|
||||
* Add a file to a ZIP archive using its contents
|
||||
* @param string $localname The name of the entry to create.
|
||||
* @param string $contents The contents to use to create the entry. It is used in a binary safe mode.
|
||||
* @return $this
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addFromString($localname, $contents);
|
||||
}
|
||||
54
PhpOffice/Common/Autoloader.php
Normal file
54
PhpOffice/Common/Autoloader.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPOffice Common
|
||||
*
|
||||
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
/**
|
||||
* Autoloader
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
/** @const string */
|
||||
const NAMESPACE_PREFIX = 'PhpOffice\\Common\\';
|
||||
|
||||
/**
|
||||
* Register
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register()
|
||||
{
|
||||
spl_autoload_register(array(new self, 'autoload'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload
|
||||
*
|
||||
* @param string $class
|
||||
*/
|
||||
public static function autoload($class)
|
||||
{
|
||||
$prefixLength = strlen(self::NAMESPACE_PREFIX);
|
||||
if (0 === strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) {
|
||||
$file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
|
||||
$file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
|
||||
if (file_exists($file)) {
|
||||
/** @noinspection PhpIncludeInspection Dynamic includes */
|
||||
require_once $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
237
PhpOffice/Common/Drawing.php
Normal file
237
PhpOffice/Common/Drawing.php
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPOffice Common
|
||||
*
|
||||
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
/**
|
||||
* \PhpOffice\Common\Drawing
|
||||
*/
|
||||
class Drawing
|
||||
{
|
||||
const DPI_96 = 96;
|
||||
|
||||
/**
|
||||
* Convert pixels to EMU
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int
|
||||
*/
|
||||
public static function pixelsToEmu($pValue = 0)
|
||||
{
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EMU to pixels
|
||||
*
|
||||
* @param int $pValue Value in EMU
|
||||
* @return int
|
||||
*/
|
||||
public static function emuToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return round($pValue / 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return float
|
||||
*/
|
||||
public static function pixelsToPoints($pValue = 0)
|
||||
{
|
||||
return $pValue * 0.67777777;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points width to centimeters
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @return float
|
||||
*/
|
||||
public static function pointsToCentimeters($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return ((($pValue * 1.333333333) / self::DPI_96) * 2.54);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points width to pixels
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @return float
|
||||
*/
|
||||
public static function pointsToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $pValue * 1.333333333;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to centimeters
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return float
|
||||
*/
|
||||
public static function pixelsToCentimeters($pValue = 0)
|
||||
{
|
||||
//return $pValue * 0.028;
|
||||
return (($pValue / self::DPI_96) * 2.54);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert centimeters width to pixels
|
||||
*
|
||||
* @param int $pValue Value in centimeters
|
||||
* @return float
|
||||
*/
|
||||
public static function centimetersToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return ($pValue / 2.54) * self::DPI_96;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert degrees to angle
|
||||
*
|
||||
* @param int $pValue Degrees
|
||||
* @return int
|
||||
*/
|
||||
public static function degreesToAngle($pValue = 0)
|
||||
{
|
||||
return (int) round($pValue * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert angle to degrees
|
||||
*
|
||||
* @param int $pValue Angle
|
||||
* @return int
|
||||
*/
|
||||
public static function angleToDegrees($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return round($pValue / 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert centimeters width to twips
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @return float
|
||||
*/
|
||||
public static function centimetersToTwips($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $pValue * 566.928;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert twips width to centimeters
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @return float
|
||||
*/
|
||||
public static function twipsToCentimeters($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $pValue / 566.928;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert inches width to twips
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @return float
|
||||
*/
|
||||
public static function inchesToTwips($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $pValue * 1440;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert twips width to inches
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @return float
|
||||
*/
|
||||
public static function twipsToInches($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $pValue / 1440;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert twips width to pixels
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @return float
|
||||
*/
|
||||
public static function twipsToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return round($pValue / 15.873984);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert HTML hexadecimal to RGB
|
||||
*
|
||||
* @param string $pValue HTML Color in hexadecimal
|
||||
* @return array|false Value in RGB
|
||||
*/
|
||||
public static function htmlToRGB($pValue)
|
||||
{
|
||||
if ($pValue[0] == '#') {
|
||||
$pValue = substr($pValue, 1);
|
||||
}
|
||||
|
||||
if (strlen($pValue) == 6) {
|
||||
list($colorR, $colorG, $colorB) = array($pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]);
|
||||
} elseif (strlen($pValue) == 3) {
|
||||
list($colorR, $colorG, $colorB) = array($pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$colorR = hexdec($colorR);
|
||||
$colorG = hexdec($colorG);
|
||||
$colorB = hexdec($colorB);
|
||||
|
||||
return array($colorR, $colorG, $colorB);
|
||||
}
|
||||
}
|
||||
112
PhpOffice/Common/File.php
Normal file
112
PhpOffice/Common/File.php
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPOffice Common
|
||||
*
|
||||
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
/**
|
||||
* Drawing
|
||||
*/
|
||||
class File
|
||||
{
|
||||
/**
|
||||
* Verify if a file exists
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @return bool
|
||||
*/
|
||||
public static function fileExists($pFilename)
|
||||
{
|
||||
// Sick construction, but it seems that
|
||||
// file_exists returns strange values when
|
||||
// doing the original file_exists on ZIP archives...
|
||||
if (strtolower(substr($pFilename, 0, 3)) == 'zip') {
|
||||
// Open ZIP file and verify if the file exists
|
||||
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
|
||||
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = ($zip->getFromName($archiveFile) !== false);
|
||||
$zip->close();
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Regular file_exists
|
||||
return file_exists($pFilename);
|
||||
}
|
||||
/**
|
||||
* Returns the content of a file
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @return string
|
||||
*/
|
||||
public static function fileGetContents($pFilename)
|
||||
{
|
||||
if (!self::fileExists($pFilename)) {
|
||||
return false;
|
||||
}
|
||||
if (strtolower(substr($pFilename, 0, 3)) == 'zip') {
|
||||
// Open ZIP file and verify if the file exists
|
||||
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
|
||||
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = $zip->getFromName($archiveFile);
|
||||
$zip->close();
|
||||
return $returnValue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Regular file contents
|
||||
return file_get_contents($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns canonicalized absolute pathname, also for ZIP archives
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return string
|
||||
*/
|
||||
public static function realpath($pFilename)
|
||||
{
|
||||
// Try using realpath()
|
||||
$returnValue = realpath($pFilename);
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
$pathArray = explode('/', $pFilename);
|
||||
while (in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
$numPathArray = count($pathArray);
|
||||
for ($i = 0; $i < $numPathArray; ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
unset($pathArray[$i]);
|
||||
unset($pathArray[$i - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$returnValue = implode('/', $pathArray);
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
}
|
||||
100
PhpOffice/Common/Font.php
Normal file
100
PhpOffice/Common/Font.php
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPOffice Common
|
||||
*
|
||||
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
/**
|
||||
* Font
|
||||
*/
|
||||
class Font
|
||||
{
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on a font points size
|
||||
*
|
||||
* @param int $fontSizeInPoints Font size (in points)
|
||||
* @return int Font size (in pixels)
|
||||
*/
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12)
|
||||
{
|
||||
return ((16 / 12) * $fontSizeInPoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on inch size
|
||||
*
|
||||
* @param int $sizeInInch Font size (in inch)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function inchSizeToPixels($sizeInInch = 1)
|
||||
{
|
||||
return ($sizeInInch * 96);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on centimeter size
|
||||
*
|
||||
* @param int $sizeInCm Font size (in centimeters)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1)
|
||||
{
|
||||
return ($sizeInCm * 37.795275591);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert centimeter to twip
|
||||
*
|
||||
* @param int $sizeInCm
|
||||
* @return double
|
||||
*/
|
||||
public static function centimeterSizeToTwips($sizeInCm = 1)
|
||||
{
|
||||
return $sizeInCm / 2.54 * 1440;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert inch to twip
|
||||
*
|
||||
* @param int $sizeInInch
|
||||
* @return double
|
||||
*/
|
||||
public static function inchSizeToTwips($sizeInInch = 1)
|
||||
{
|
||||
return $sizeInInch * 1440;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixel to twip
|
||||
*
|
||||
* @param int $sizeInPixel
|
||||
* @return double
|
||||
*/
|
||||
public static function pixelSizeToTwips($sizeInPixel = 1)
|
||||
{
|
||||
return $sizeInPixel / 96 * 1440;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate twip based on point size, used mainly for paragraph spacing
|
||||
*
|
||||
* @param integer $sizeInPoint Size in point
|
||||
* @return integer Size (in twips)
|
||||
*/
|
||||
public static function pointSizeToTwips($sizeInPoint = 1)
|
||||
{
|
||||
return $sizeInPoint / 72 * 1440;
|
||||
}
|
||||
}
|
||||
320
PhpOffice/Common/Microsoft/OLERead.php
Normal file
320
PhpOffice/Common/Microsoft/OLERead.php
Normal file
|
|
@ -0,0 +1,320 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPOffice Common
|
||||
*
|
||||
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common\Microsoft;
|
||||
|
||||
if (!defined('IDENTIFIER_OLE')) {
|
||||
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1));
|
||||
}
|
||||
|
||||
class OLERead
|
||||
{
|
||||
private $data = '';
|
||||
|
||||
// OLE identifier
|
||||
const IDENTIFIER_OLE = IDENTIFIER_OLE;
|
||||
|
||||
// Size of a sector = 512 bytes
|
||||
const BIG_BLOCK_SIZE = 0x200;
|
||||
|
||||
// Size of a short sector = 64 bytes
|
||||
const SMALL_BLOCK_SIZE = 0x40;
|
||||
|
||||
// Size of a directory entry always = 128 bytes
|
||||
const PROPERTY_STORAGE_BLOCK_SIZE = 0x80;
|
||||
|
||||
// Minimum size of a standard stream = 4096 bytes, streams smaller than this are stored as short streams
|
||||
const SMALL_BLOCK_THRESHOLD = 0x1000;
|
||||
|
||||
// header offsets
|
||||
const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c;
|
||||
const ROOT_START_BLOCK_POS = 0x30;
|
||||
const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c;
|
||||
const EXTENSION_BLOCK_POS = 0x44;
|
||||
const NUM_EXTENSION_BLOCK_POS = 0x48;
|
||||
const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c;
|
||||
|
||||
// property storage offsets (directory offsets)
|
||||
const SIZE_OF_NAME_POS = 0x40;
|
||||
const TYPE_POS = 0x42;
|
||||
const START_BLOCK_POS = 0x74;
|
||||
const SIZE_POS = 0x78;
|
||||
|
||||
public $summaryInformation = null;
|
||||
public $docSummaryInfos = null;
|
||||
public $powerpointDocument = null;
|
||||
public $currentUser = null;
|
||||
public $pictures = null;
|
||||
public $rootEntry = null;
|
||||
public $props = array();
|
||||
public $smallBlockChain = null;
|
||||
public $bigBlockChain = null;
|
||||
public $entry = null;
|
||||
|
||||
/**
|
||||
* Read the file
|
||||
*
|
||||
* @param $sFileName string Filename
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function read($sFileName)
|
||||
{
|
||||
// Check if file exists and is readable
|
||||
if (!is_readable($sFileName)) {
|
||||
throw new \Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable.");
|
||||
}
|
||||
|
||||
// Get the file identifier
|
||||
// Don't bother reading the whole file until we know it's a valid OLE file
|
||||
$this->data = file_get_contents($sFileName, false, null, 0, 8);
|
||||
|
||||
// Check OLE identifier
|
||||
if ($this->data != self::IDENTIFIER_OLE) {
|
||||
throw new \Exception('The filename ' . $sFileName . ' is not recognised as an OLE file');
|
||||
}
|
||||
|
||||
// Get the file data
|
||||
$this->data = file_get_contents($sFileName);
|
||||
|
||||
// Total number of sectors used for the SAT
|
||||
$numBigBlkDepotBlks = self::getInt4d($this->data, self::NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
|
||||
|
||||
// SecID of the first sector of the directory stream
|
||||
$rootStartBlock = self::getInt4d($this->data, self::ROOT_START_BLOCK_POS);
|
||||
|
||||
// SecID of the first sector of the SSAT (or -2 if not extant)
|
||||
$sbdStartBlock = self::getInt4d($this->data, self::SMALL_BLOCK_DEPOT_BLOCK_POS);
|
||||
|
||||
// SecID of the first sector of the MSAT (or -2 if no additional sectors are used)
|
||||
$extensionBlock = self::getInt4d($this->data, self::EXTENSION_BLOCK_POS);
|
||||
|
||||
// Total number of sectors used by MSAT
|
||||
$numExtensionBlocks = self::getInt4d($this->data, self::NUM_EXTENSION_BLOCK_POS);
|
||||
|
||||
$bigBlockDepotBlocks = array();
|
||||
$pos = self::BIG_BLOCK_DEPOT_BLOCKS_POS;
|
||||
|
||||
$bbdBlocks = $numBigBlkDepotBlks;
|
||||
|
||||
if ($numExtensionBlocks != 0) {
|
||||
$bbdBlocks = (self::BIG_BLOCK_SIZE - self::BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $bbdBlocks; ++$i) {
|
||||
$bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos);
|
||||
$pos += 4;
|
||||
}
|
||||
|
||||
for ($j = 0; $j < $numExtensionBlocks; ++$j) {
|
||||
$pos = ($extensionBlock + 1) * self::BIG_BLOCK_SIZE;
|
||||
$blocksToRead = min($numBigBlkDepotBlks - $bbdBlocks, self::BIG_BLOCK_SIZE / 4 - 1);
|
||||
|
||||
for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; ++$i) {
|
||||
$bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos);
|
||||
$pos += 4;
|
||||
}
|
||||
|
||||
$bbdBlocks += $blocksToRead;
|
||||
if ($bbdBlocks < $numBigBlkDepotBlks) {
|
||||
$extensionBlock = self::getInt4d($this->data, $pos);
|
||||
}
|
||||
}
|
||||
|
||||
$this->bigBlockChain = '';
|
||||
$bbs = self::BIG_BLOCK_SIZE / 4;
|
||||
for ($i = 0; $i < $numBigBlkDepotBlks; ++$i) {
|
||||
$pos = ($bigBlockDepotBlocks[$i] + 1) * self::BIG_BLOCK_SIZE;
|
||||
|
||||
$this->bigBlockChain .= substr($this->data, $pos, 4*$bbs);
|
||||
$pos += 4*$bbs;
|
||||
}
|
||||
|
||||
$sbdBlock = $sbdStartBlock;
|
||||
$this->smallBlockChain = '';
|
||||
while ($sbdBlock != -2) {
|
||||
$pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE;
|
||||
|
||||
$this->smallBlockChain .= substr($this->data, $pos, 4*$bbs);
|
||||
$pos += 4*$bbs;
|
||||
|
||||
$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock*4);
|
||||
}
|
||||
|
||||
// read the directory stream
|
||||
$block = $rootStartBlock;
|
||||
$this->entry = $this->readData($block);
|
||||
|
||||
$this->readPropertySets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract binary stream data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStream($stream)
|
||||
{
|
||||
if ($stream === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$streamData = '';
|
||||
|
||||
if ($this->props[$stream]['size'] < self::SMALL_BLOCK_THRESHOLD) {
|
||||
$rootdata = $this->readData($this->props[$this->rootEntry]['startBlock']);
|
||||
|
||||
$block = $this->props[$stream]['startBlock'];
|
||||
|
||||
while ($block != -2) {
|
||||
$pos = $block * self::SMALL_BLOCK_SIZE;
|
||||
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
|
||||
|
||||
$block = self::getInt4d($this->smallBlockChain, $block*4);
|
||||
}
|
||||
|
||||
return $streamData;
|
||||
}
|
||||
|
||||
$numBlocks = $this->props[$stream]['size'] / self::BIG_BLOCK_SIZE;
|
||||
if ($this->props[$stream]['size'] % self::BIG_BLOCK_SIZE != 0) {
|
||||
++$numBlocks;
|
||||
}
|
||||
|
||||
if ($numBlocks == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$block = $this->props[$stream]['startBlock'];
|
||||
|
||||
while ($block != -2) {
|
||||
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
|
||||
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block*4);
|
||||
}
|
||||
|
||||
return $streamData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a standard stream (by joining sectors using information from SAT)
|
||||
*
|
||||
* @param int $blID Sector ID where the stream starts
|
||||
* @return string Data for standard stream
|
||||
*/
|
||||
private function readData($blID)
|
||||
{
|
||||
$block = $blID;
|
||||
$data = '';
|
||||
|
||||
while ($block != -2) {
|
||||
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
|
||||
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block*4);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read entries in the directory stream.
|
||||
*/
|
||||
private function readPropertySets()
|
||||
{
|
||||
$offset = 0;
|
||||
|
||||
// loop through entires, each entry is 128 bytes
|
||||
$entryLen = strlen($this->entry);
|
||||
while ($offset < $entryLen) {
|
||||
// entry data (128 bytes)
|
||||
$data = substr($this->entry, $offset, self::PROPERTY_STORAGE_BLOCK_SIZE);
|
||||
|
||||
// size in bytes of name
|
||||
$nameSize = ord($data[self::SIZE_OF_NAME_POS]) | (ord($data[self::SIZE_OF_NAME_POS+1]) << 8);
|
||||
|
||||
// type of entry
|
||||
$type = ord($data[self::TYPE_POS]);
|
||||
|
||||
// sectorID of first sector or short sector, if this entry refers to a stream (the case with workbook)
|
||||
// sectorID of first sector of the short-stream container stream, if this entry is root entry
|
||||
$startBlock = self::getInt4d($data, self::START_BLOCK_POS);
|
||||
|
||||
$size = self::getInt4d($data, self::SIZE_POS);
|
||||
|
||||
$name = str_replace("\x00", "", substr($data, 0, $nameSize));
|
||||
if ($size > 0) {
|
||||
$this->props[] = array (
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'startBlock' => $startBlock,
|
||||
'size' => $size);
|
||||
|
||||
// tmp helper to simplify checks
|
||||
$upName = strtoupper($name);
|
||||
|
||||
switch ($upName) {
|
||||
case 'ROOT ENTRY':
|
||||
case 'R':
|
||||
$this->rootEntry = count($this->props) - 1;
|
||||
break;
|
||||
case chr(1).'COMPOBJ':
|
||||
break;
|
||||
case chr(1).'OLE':
|
||||
break;
|
||||
case chr(5).'SUMMARYINFORMATION':
|
||||
$this->summaryInformation = count($this->props) - 1;
|
||||
break;
|
||||
case chr(5).'DOCUMENTSUMMARYINFORMATION':
|
||||
$this->docSummaryInfos = count($this->props) - 1;
|
||||
break;
|
||||
case 'CURRENT USER':
|
||||
$this->currentUser = count($this->props) - 1;
|
||||
break;
|
||||
case 'PICTURES':
|
||||
$this->pictures = count($this->props) - 1;
|
||||
break;
|
||||
case 'POWERPOINT DOCUMENT':
|
||||
$this->powerpointDocument = count($this->props) - 1;
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('OLE Block Not defined: $upName : '.$upName. ' - $name : "'.$name.'"');
|
||||
}
|
||||
}
|
||||
|
||||
$offset += self::PROPERTY_STORAGE_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read 4 bytes of data at specified position
|
||||
*
|
||||
* @param string $data
|
||||
* @param int $pos
|
||||
* @return int
|
||||
*/
|
||||
private static function getInt4d($data, $pos)
|
||||
{
|
||||
// FIX: represent numbers correctly on 64-bit system
|
||||
// http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334
|
||||
// Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems
|
||||
$or24 = ord($data[$pos + 3]);
|
||||
if ($or24 >= 128) {
|
||||
// negative number
|
||||
$ord24 = -abs((256 - $or24) << 24);
|
||||
} else {
|
||||
$ord24 = ($or24 & 127) << 24;
|
||||
}
|
||||
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24;
|
||||
}
|
||||
}
|
||||
234
PhpOffice/Common/Microsoft/PasswordEncoder.php
Normal file
234
PhpOffice/Common/Microsoft/PasswordEncoder.php
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPOffice Common
|
||||
*
|
||||
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common\Microsoft;
|
||||
|
||||
/**
|
||||
* Password encoder for microsoft office applications
|
||||
*/
|
||||
class PasswordEncoder
|
||||
{
|
||||
const ALGORITHM_MD2 = 'MD2';
|
||||
const ALGORITHM_MD4 = 'MD4';
|
||||
const ALGORITHM_MD5 = 'MD5';
|
||||
const ALGORITHM_SHA_1 = 'SHA-1';
|
||||
const ALGORITHM_SHA_256 = 'SHA-256';
|
||||
const ALGORITHM_SHA_384 = 'SHA-384';
|
||||
const ALGORITHM_SHA_512 = 'SHA-512';
|
||||
const ALGORITHM_RIPEMD = 'RIPEMD';
|
||||
const ALGORITHM_RIPEMD_160 = 'RIPEMD-160';
|
||||
const ALGORITHM_MAC = 'MAC';
|
||||
const ALGORITHM_HMAC = 'HMAC';
|
||||
|
||||
/**
|
||||
* Mapping between algorithm name and algorithm ID
|
||||
*
|
||||
* @var array
|
||||
* @see https://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.writeprotection.cryptographicalgorithmsid(v=office.14).aspx
|
||||
*/
|
||||
private static $algorithmMapping = array(
|
||||
self::ALGORITHM_MD2 => array(1, 'md2'),
|
||||
self::ALGORITHM_MD4 => array(2, 'md4'),
|
||||
self::ALGORITHM_MD5 => array(3, 'md5'),
|
||||
self::ALGORITHM_SHA_1 => array(4, 'sha1'),
|
||||
self::ALGORITHM_MAC => array(5, ''), // 'mac' -> not possible with hash()
|
||||
self::ALGORITHM_RIPEMD => array(6, 'ripemd'),
|
||||
self::ALGORITHM_RIPEMD_160 => array(7, 'ripemd160'),
|
||||
self::ALGORITHM_HMAC => array(9, ''), //'hmac' -> not possible with hash()
|
||||
self::ALGORITHM_SHA_256 => array(12, 'sha256'),
|
||||
self::ALGORITHM_SHA_384 => array(13, 'sha384'),
|
||||
self::ALGORITHM_SHA_512 => array(14, 'sha512'),
|
||||
);
|
||||
|
||||
private static $initialCodeArray = array(
|
||||
0xE1F0,
|
||||
0x1D0F,
|
||||
0xCC9C,
|
||||
0x84C0,
|
||||
0x110C,
|
||||
0x0E10,
|
||||
0xF1CE,
|
||||
0x313E,
|
||||
0x1872,
|
||||
0xE139,
|
||||
0xD40F,
|
||||
0x84F9,
|
||||
0x280C,
|
||||
0xA96A,
|
||||
0x4EC3,
|
||||
);
|
||||
|
||||
private static $encryptionMatrix = array(
|
||||
array(0xAEFC, 0x4DD9, 0x9BB2, 0x2745, 0x4E8A, 0x9D14, 0x2A09),
|
||||
array(0x7B61, 0xF6C2, 0xFDA5, 0xEB6B, 0xC6F7, 0x9DCF, 0x2BBF),
|
||||
array(0x4563, 0x8AC6, 0x05AD, 0x0B5A, 0x16B4, 0x2D68, 0x5AD0),
|
||||
array(0x0375, 0x06EA, 0x0DD4, 0x1BA8, 0x3750, 0x6EA0, 0xDD40),
|
||||
array(0xD849, 0xA0B3, 0x5147, 0xA28E, 0x553D, 0xAA7A, 0x44D5),
|
||||
array(0x6F45, 0xDE8A, 0xAD35, 0x4A4B, 0x9496, 0x390D, 0x721A),
|
||||
array(0xEB23, 0xC667, 0x9CEF, 0x29FF, 0x53FE, 0xA7FC, 0x5FD9),
|
||||
array(0x47D3, 0x8FA6, 0x0F6D, 0x1EDA, 0x3DB4, 0x7B68, 0xF6D0),
|
||||
array(0xB861, 0x60E3, 0xC1C6, 0x93AD, 0x377B, 0x6EF6, 0xDDEC),
|
||||
array(0x45A0, 0x8B40, 0x06A1, 0x0D42, 0x1A84, 0x3508, 0x6A10),
|
||||
array(0xAA51, 0x4483, 0x8906, 0x022D, 0x045A, 0x08B4, 0x1168),
|
||||
array(0x76B4, 0xED68, 0xCAF1, 0x85C3, 0x1BA7, 0x374E, 0x6E9C),
|
||||
array(0x3730, 0x6E60, 0xDCC0, 0xA9A1, 0x4363, 0x86C6, 0x1DAD),
|
||||
array(0x3331, 0x6662, 0xCCC4, 0x89A9, 0x0373, 0x06E6, 0x0DCC),
|
||||
array(0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48C4),
|
||||
);
|
||||
|
||||
private static $passwordMaxLength = 15;
|
||||
|
||||
/**
|
||||
* Create a hashed password that MS Word will be able to work with
|
||||
* @see https://blogs.msdn.microsoft.com/vsod/2010/04/05/how-to-set-the-editing-restrictions-in-word-using-open-xml-sdk-2-0/
|
||||
*
|
||||
* @param string $password
|
||||
* @param string $algorithmName
|
||||
* @param string $salt
|
||||
* @param int $spinCount
|
||||
* @return string
|
||||
*/
|
||||
public static function hashPassword($password, $algorithmName = self::ALGORITHM_SHA_1, $salt = null, $spinCount = 10000)
|
||||
{
|
||||
$origEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('UTF-8');
|
||||
|
||||
$password = mb_substr($password, 0, min(self::$passwordMaxLength, mb_strlen($password)));
|
||||
|
||||
// Get the single-byte values by iterating through the Unicode characters of the truncated password.
|
||||
// For each character, if the low byte is not equal to 0, take it. Otherwise, take the high byte.
|
||||
$passUtf8 = mb_convert_encoding($password, 'UCS-2LE', 'UTF-8');
|
||||
$byteChars = array();
|
||||
|
||||
for ($i = 0; $i < mb_strlen($password); $i++) {
|
||||
$byteChars[$i] = ord(substr($passUtf8, $i * 2, 1));
|
||||
|
||||
if ($byteChars[$i] == 0) {
|
||||
$byteChars[$i] = ord(substr($passUtf8, $i * 2 + 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
// build low-order word and hig-order word and combine them
|
||||
$combinedKey = self::buildCombinedKey($byteChars);
|
||||
// build reversed hexadecimal string
|
||||
$hex = str_pad(strtoupper(dechex($combinedKey & 0xFFFFFFFF)), 8, '0', \STR_PAD_LEFT);
|
||||
$reversedHex = $hex[6] . $hex[7] . $hex[4] . $hex[5] . $hex[2] . $hex[3] . $hex[0] . $hex[1];
|
||||
|
||||
$generatedKey = mb_convert_encoding($reversedHex, 'UCS-2LE', 'UTF-8');
|
||||
|
||||
// Implementation Notes List:
|
||||
// Word requires that the initial hash of the password with the salt not be considered in the count.
|
||||
// The initial hash of salt + key is not included in the iteration count.
|
||||
$algorithm = self::getAlgorithm($algorithmName);
|
||||
$generatedKey = hash($algorithm, $salt . $generatedKey, true);
|
||||
|
||||
for ($i = 0; $i < $spinCount; $i++) {
|
||||
$generatedKey = hash($algorithm, $generatedKey . pack('CCCC', $i, $i >> 8, $i >> 16, $i >> 24), true);
|
||||
}
|
||||
$generatedKey = base64_encode($generatedKey);
|
||||
|
||||
mb_internal_encoding($origEncoding);
|
||||
|
||||
return $generatedKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get algorithm from self::$algorithmMapping
|
||||
*
|
||||
* @param string $algorithmName
|
||||
* @return string
|
||||
*/
|
||||
private static function getAlgorithm($algorithmName)
|
||||
{
|
||||
$algorithm = self::$algorithmMapping[$algorithmName][1];
|
||||
if ($algorithm == '') {
|
||||
$algorithm = 'sha1';
|
||||
}
|
||||
|
||||
return $algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the algorithm ID
|
||||
*
|
||||
* @param string $algorithmName
|
||||
* @return int
|
||||
*/
|
||||
public static function getAlgorithmId($algorithmName)
|
||||
{
|
||||
return self::$algorithmMapping[$algorithmName][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build combined key from low-order word and high-order word
|
||||
*
|
||||
* @param array $byteChars byte array representation of password
|
||||
* @return int
|
||||
*/
|
||||
private static function buildCombinedKey($byteChars)
|
||||
{
|
||||
$byteCharsLength = count($byteChars);
|
||||
// Compute the high-order word
|
||||
// Initialize from the initial code array (see above), depending on the passwords length.
|
||||
$highOrderWord = self::$initialCodeArray[$byteCharsLength - 1];
|
||||
|
||||
// For each character in the password:
|
||||
// For every bit in the character, starting with the least significant and progressing to (but excluding)
|
||||
// the most significant, if the bit is set, XOR the key’s high-order word with the corresponding word from
|
||||
// the Encryption Matrix
|
||||
for ($i = 0; $i < $byteCharsLength; $i++) {
|
||||
$tmp = self::$passwordMaxLength - $byteCharsLength + $i;
|
||||
$matrixRow = self::$encryptionMatrix[$tmp];
|
||||
for ($intBit = 0; $intBit < 7; $intBit++) {
|
||||
if (($byteChars[$i] & (0x0001 << $intBit)) != 0) {
|
||||
$highOrderWord = ($highOrderWord ^ $matrixRow[$intBit]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute low-order word
|
||||
// Initialize with 0
|
||||
$lowOrderWord = 0;
|
||||
// For each character in the password, going backwards
|
||||
for ($i = $byteCharsLength - 1; $i >= 0; $i--) {
|
||||
// low-order word = (((low-order word SHR 14) AND 0x0001) OR (low-order word SHL 1) AND 0x7FFF)) XOR character
|
||||
$lowOrderWord = (((($lowOrderWord >> 14) & 0x0001) | (($lowOrderWord << 1) & 0x7FFF)) ^ $byteChars[$i]);
|
||||
}
|
||||
// Lastly, low-order word = (((low-order word SHR 14) AND 0x0001) OR (low-order word SHL 1) AND 0x7FFF)) XOR strPassword length XOR 0xCE4B.
|
||||
$lowOrderWord = (((($lowOrderWord >> 14) & 0x0001) | (($lowOrderWord << 1) & 0x7FFF)) ^ $byteCharsLength ^ 0xCE4B);
|
||||
|
||||
// Combine the Low and High Order Word
|
||||
return self::int32(($highOrderWord << 16) + $lowOrderWord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate behaviour of (signed) int32
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @param int $value
|
||||
* @return int
|
||||
*/
|
||||
private static function int32($value)
|
||||
{
|
||||
$value = ($value & 0xFFFFFFFF);
|
||||
|
||||
if ($value & 0x80000000) {
|
||||
$value = -((~$value & 0xFFFFFFFF) + 1);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
234
PhpOffice/Common/Text.php
Normal file
234
PhpOffice/Common/Text.php
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPOffice Common
|
||||
*
|
||||
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
/**
|
||||
* Text
|
||||
*/
|
||||
class Text
|
||||
{
|
||||
/**
|
||||
* Control characters array
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $controlCharacters = array();
|
||||
|
||||
/**
|
||||
* Build control characters array
|
||||
*/
|
||||
private static function buildControlCharacters()
|
||||
{
|
||||
for ($i = 0; $i <= 19; ++$i) {
|
||||
if ($i != 9 && $i != 10 && $i != 13) {
|
||||
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
|
||||
$replace = chr($i);
|
||||
self::$controlCharacters[$find] = $replace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from PHP control character to OpenXML escaped control character
|
||||
*
|
||||
* Excel 2007 team:
|
||||
* ----------------
|
||||
* That's correct, control characters are stored directly in the shared-strings table.
|
||||
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
||||
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
||||
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to escape
|
||||
* @return string
|
||||
*/
|
||||
public static function controlCharacterPHP2OOXML($value = '')
|
||||
{
|
||||
if (empty(self::$controlCharacters)) {
|
||||
self::buildControlCharacters();
|
||||
}
|
||||
|
||||
return str_replace(array_values(self::$controlCharacters), array_keys(self::$controlCharacters), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a number formatted for being integrated in xml files
|
||||
* @param float $number
|
||||
* @param integer $decimals
|
||||
* @return string
|
||||
*/
|
||||
public static function numberFormat($number, $decimals)
|
||||
{
|
||||
return number_format($number, $decimals, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $dec
|
||||
* @link http://stackoverflow.com/a/7153133/2235790
|
||||
* @author velcrow
|
||||
* @return string
|
||||
*/
|
||||
public static function chr($dec)
|
||||
{
|
||||
if ($dec<=0x7F) {
|
||||
return chr($dec);
|
||||
}
|
||||
if ($dec<=0x7FF) {
|
||||
return chr(($dec>>6)+192).chr(($dec&63)+128);
|
||||
}
|
||||
if ($dec<=0xFFFF) {
|
||||
return chr(($dec>>12)+224).chr((($dec>>6)&63)+128).chr(($dec&63)+128);
|
||||
}
|
||||
if ($dec<=0x1FFFFF) {
|
||||
return chr(($dec>>18)+240).chr((($dec>>12)&63)+128).chr((($dec>>6)&63)+128).chr(($dec&63)+128);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from OpenXML escaped control character to PHP control character
|
||||
*
|
||||
* @param string $value Value to unescape
|
||||
* @return string
|
||||
*/
|
||||
public static function controlCharacterOOXML2PHP($value = '')
|
||||
{
|
||||
if (empty(self::$controlCharacters)) {
|
||||
self::buildControlCharacters();
|
||||
}
|
||||
|
||||
return str_replace(array_keys(self::$controlCharacters), array_values(self::$controlCharacters), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string contains UTF-8 data
|
||||
*
|
||||
* @param string $value
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isUTF8($value = '')
|
||||
{
|
||||
return is_string($value) && ($value === '' || preg_match('/^./su', $value) == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return UTF8 encoded value
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public static function toUTF8($value = '')
|
||||
{
|
||||
if (!is_null($value) && !self::isUTF8($value)) {
|
||||
$value = utf8_encode($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns unicode from UTF8 text
|
||||
*
|
||||
* The function is splitted to reduce cyclomatic complexity
|
||||
*
|
||||
* @param string $text UTF8 text
|
||||
* @return string Unicode text
|
||||
* @since 0.11.0
|
||||
*/
|
||||
public static function toUnicode($text)
|
||||
{
|
||||
return self::unicodeToEntities(self::utf8ToUnicode($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns unicode array from UTF8 text
|
||||
*
|
||||
* @param string $text UTF8 text
|
||||
* @return array
|
||||
* @since 0.11.0
|
||||
* @link http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||
*/
|
||||
public static function utf8ToUnicode($text)
|
||||
{
|
||||
$unicode = array();
|
||||
$values = array();
|
||||
$lookingFor = 1;
|
||||
|
||||
// Gets unicode for each character
|
||||
for ($i = 0; $i < strlen($text); $i++) {
|
||||
$thisValue = ord($text[$i]);
|
||||
if ($thisValue < 128) {
|
||||
$unicode[] = $thisValue;
|
||||
} else {
|
||||
if (count($values) == 0) {
|
||||
$lookingFor = $thisValue < 224 ? 2 : 3;
|
||||
}
|
||||
$values[] = $thisValue;
|
||||
if (count($values) == $lookingFor) {
|
||||
if ($lookingFor == 3) {
|
||||
$number = (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64);
|
||||
} else {
|
||||
$number = (($values[0] % 32) * 64) + ($values[1] % 64);
|
||||
}
|
||||
$unicode[] = $number;
|
||||
$values = array();
|
||||
$lookingFor = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $unicode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns entites from unicode array
|
||||
*
|
||||
* @param array $unicode
|
||||
* @return string
|
||||
* @since 0.11.0
|
||||
* @link http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||
*/
|
||||
private static function unicodeToEntities($unicode)
|
||||
{
|
||||
$entities = '';
|
||||
|
||||
foreach ($unicode as $value) {
|
||||
if ($value != 65279) {
|
||||
$entities .= $value > 127 ? '\uc0{\u' . $value . '}' : chr($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name without underscore for < 0.10.0 variable name compatibility
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public static function removeUnderscorePrefix($value)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (substr($value, 0, 1) == '_') {
|
||||
$value = substr($value, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
210
PhpOffice/Common/XMLReader.php
Normal file
210
PhpOffice/Common/XMLReader.php
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPOffice Common
|
||||
*
|
||||
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
/**
|
||||
* XML Reader wrapper
|
||||
*
|
||||
* @since 0.2.1
|
||||
*/
|
||||
class XMLReader
|
||||
{
|
||||
/**
|
||||
* DOMDocument object
|
||||
*
|
||||
* @var \DOMDocument
|
||||
*/
|
||||
private $dom = null;
|
||||
|
||||
/**
|
||||
* DOMXpath object
|
||||
*
|
||||
* @var \DOMXpath
|
||||
*/
|
||||
private $xpath = null;
|
||||
|
||||
/**
|
||||
* Get DOMDocument from ZipArchive
|
||||
*
|
||||
* @param string $zipFile
|
||||
* @param string $xmlFile
|
||||
* @return \DOMDocument|false
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getDomFromZip($zipFile, $xmlFile)
|
||||
{
|
||||
if (file_exists($zipFile) === false) {
|
||||
throw new \Exception('Cannot find archive file.');
|
||||
}
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
$zip->open($zipFile);
|
||||
$content = $zip->getFromName($xmlFile);
|
||||
$zip->close();
|
||||
|
||||
if ($content === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getDomFromString($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DOMDocument from content string
|
||||
*
|
||||
* @param string $content
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function getDomFromString($content)
|
||||
{
|
||||
$originalLibXMLEntityValue = libxml_disable_entity_loader(true);
|
||||
$this->dom = new \DOMDocument();
|
||||
$this->dom->loadXML($content);
|
||||
libxml_disable_entity_loader($originalLibXMLEntityValue);
|
||||
|
||||
return $this->dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get elements
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return \DOMNodeList
|
||||
*/
|
||||
public function getElements($path, \DOMElement $contextNode = null)
|
||||
{
|
||||
if ($this->dom === null) {
|
||||
return array();
|
||||
}
|
||||
if ($this->xpath === null) {
|
||||
$this->xpath = new \DOMXpath($this->dom);
|
||||
}
|
||||
|
||||
if (is_null($contextNode)) {
|
||||
return $this->xpath->query($path);
|
||||
}
|
||||
|
||||
return $this->xpath->query($path, $contextNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the namespace with the DOMXPath object
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string $namespaceURI The URI of the namespace
|
||||
* @return bool true on success or false on failure
|
||||
* @throws \InvalidArgumentException If called before having loaded the DOM document
|
||||
*/
|
||||
public function registerNamespace($prefix, $namespaceURI)
|
||||
{
|
||||
if ($this->dom === null) {
|
||||
throw new \InvalidArgumentException('Dom needs to be loaded before registering a namespace');
|
||||
}
|
||||
if ($this->xpath === null) {
|
||||
$this->xpath = new \DOMXpath($this->dom);
|
||||
}
|
||||
return $this->xpath->registerNamespace($prefix, $namespaceURI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return \DOMElement|null
|
||||
*/
|
||||
public function getElement($path, \DOMElement $contextNode = null)
|
||||
{
|
||||
$elements = $this->getElements($path, $contextNode);
|
||||
if ($elements->length > 0) {
|
||||
return $elements->item(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element attribute
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param \DOMElement $contextNode
|
||||
* @param string $path
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAttribute($attribute, \DOMElement $contextNode = null, $path = null)
|
||||
{
|
||||
$return = null;
|
||||
if ($path !== null) {
|
||||
$elements = $this->getElements($path, $contextNode);
|
||||
if ($elements->length > 0) {
|
||||
/** @var \DOMElement $node Type hint */
|
||||
$node = $elements->item(0);
|
||||
$return = $node->getAttribute($attribute);
|
||||
}
|
||||
} else {
|
||||
if ($contextNode !== null) {
|
||||
$return = $contextNode->getAttribute($attribute);
|
||||
}
|
||||
}
|
||||
|
||||
return ($return == '') ? null : $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element value
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return string|null
|
||||
*/
|
||||
public function getValue($path, \DOMElement $contextNode = null)
|
||||
{
|
||||
$elements = $this->getElements($path, $contextNode);
|
||||
if ($elements->length > 0) {
|
||||
return $elements->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count elements
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return integer
|
||||
*/
|
||||
public function countElements($path, \DOMElement $contextNode = null)
|
||||
{
|
||||
$elements = $this->getElements($path, $contextNode);
|
||||
|
||||
return $elements->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element exists
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return boolean
|
||||
*/
|
||||
public function elementExists($path, \DOMElement $contextNode = null)
|
||||
{
|
||||
return $this->getElements($path, $contextNode)->length > 0;
|
||||
}
|
||||
}
|
||||
183
PhpOffice/Common/XMLWriter.php
Normal file
183
PhpOffice/Common/XMLWriter.php
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPOffice Common
|
||||
*
|
||||
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
/**
|
||||
* XMLWriter
|
||||
*
|
||||
* @method bool endElement()
|
||||
* @method mixed flush(bool $empty = null)
|
||||
* @method bool openMemory()
|
||||
* @method string outputMemory(bool $flush = null)
|
||||
* @method bool setIndent(bool $indent)
|
||||
* @method bool startDocument(string $version = 1.0, string $encoding = null, string $standalone = null)
|
||||
* @method bool startElement(string $name)
|
||||
* @method bool text(string $content)
|
||||
* @method bool writeCData(string $content)
|
||||
* @method bool writeComment(string $content)
|
||||
* @method bool writeElement(string $name, string $content = null)
|
||||
* @method bool writeRaw(string $content)
|
||||
*/
|
||||
class XMLWriter extends \XMLWriter
|
||||
{
|
||||
/** Temporary storage method */
|
||||
const STORAGE_MEMORY = 1;
|
||||
const STORAGE_DISK = 2;
|
||||
|
||||
/**
|
||||
* Temporary filename
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tempFileName = '';
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPowerpoint\Shared\XMLWriter instance
|
||||
*
|
||||
* @param int $pTemporaryStorage Temporary storage location
|
||||
* @param string $pTemporaryStorageDir Temporary storage folder
|
||||
* @param bool $compatibility
|
||||
*/
|
||||
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageDir = null, $compatibility = false)
|
||||
{
|
||||
// Open temporary storage
|
||||
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
||||
$this->openMemory();
|
||||
} else {
|
||||
if (!is_dir($pTemporaryStorageDir)) {
|
||||
$pTemporaryStorageDir = sys_get_temp_dir();
|
||||
}
|
||||
// Create temporary filename
|
||||
$this->tempFileName = @tempnam($pTemporaryStorageDir, 'xml');
|
||||
|
||||
// Open storage
|
||||
$this->openUri($this->tempFileName);
|
||||
}
|
||||
|
||||
if ($compatibility) {
|
||||
$this->setIndent(false);
|
||||
$this->setIndentString('');
|
||||
} else {
|
||||
$this->setIndent(true);
|
||||
$this->setIndentString(' ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
// Unlink temporary files
|
||||
if (empty($this->tempFileName)) {
|
||||
return;
|
||||
}
|
||||
if (PHP_OS != 'WINNT' && @unlink($this->tempFileName) === false) {
|
||||
throw new \Exception('The file '.$this->tempFileName.' could not be deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get written data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
if ($this->tempFileName == '') {
|
||||
return $this->outputMemory(true);
|
||||
}
|
||||
|
||||
$this->flush();
|
||||
return file_get_contents($this->tempFileName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write simple element and attribute(s) block
|
||||
*
|
||||
* There are two options:
|
||||
* 1. If the `$attributes` is an array, then it's an associative array of attributes
|
||||
* 2. If not, then it's a simple attribute-value pair
|
||||
*
|
||||
* @param string $element
|
||||
* @param string|array $attributes
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function writeElementBlock($element, $attributes, $value = null)
|
||||
{
|
||||
$this->startElement($element);
|
||||
if (!is_array($attributes)) {
|
||||
$attributes = array($attributes => $value);
|
||||
}
|
||||
foreach ($attributes as $attribute => $value) {
|
||||
$this->writeAttribute($attribute, $value);
|
||||
}
|
||||
$this->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write element if ...
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $element
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function writeElementIf($condition, $element, $attribute = null, $value = null)
|
||||
{
|
||||
if ($condition == true) {
|
||||
if (is_null($attribute)) {
|
||||
$this->writeElement($element, $value);
|
||||
} else {
|
||||
$this->startElement($element);
|
||||
$this->writeAttribute($attribute, $value);
|
||||
$this->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write attribute if ...
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function writeAttributeIf($condition, $attribute, $value)
|
||||
{
|
||||
if ($condition == true) {
|
||||
$this->writeAttribute($attribute, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function writeAttribute($name, $value)
|
||||
{
|
||||
if (is_float($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
return parent::writeAttribute($name, $value);
|
||||
}
|
||||
}
|
||||
469
PhpOffice/PhpPresentation/AbstractShape.php
Normal file
469
PhpOffice/PhpPresentation/AbstractShape.php
Normal file
|
|
@ -0,0 +1,469 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\Hyperlink;
|
||||
use PhpOffice\PhpPresentation\Shape\Placeholder;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
use PhpOffice\PhpPresentation\Style\Shadow;
|
||||
|
||||
/**
|
||||
* Abstract shape
|
||||
*/
|
||||
abstract class AbstractShape implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Container
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Offset X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offsetX;
|
||||
|
||||
/**
|
||||
* Offset Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offsetY;
|
||||
|
||||
/**
|
||||
* Width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $width;
|
||||
|
||||
/**
|
||||
* Height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $height;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
private $fill;
|
||||
|
||||
/**
|
||||
* Border
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
private $border;
|
||||
|
||||
/**
|
||||
* Rotation
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $rotation;
|
||||
|
||||
/**
|
||||
* Shadow
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Shadow
|
||||
*/
|
||||
protected $shadow;
|
||||
|
||||
/**
|
||||
* Hyperlink
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
*/
|
||||
protected $hyperlink;
|
||||
|
||||
/**
|
||||
* PlaceHolder
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Placeholder
|
||||
*/
|
||||
protected $placeholder;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new self
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->container = null;
|
||||
$this->offsetX = 0;
|
||||
$this->offsetY = 0;
|
||||
$this->width = 0;
|
||||
$this->height = 0;
|
||||
$this->rotation = 0;
|
||||
$this->fill = new Style\Fill();
|
||||
$this->border = new Style\Border();
|
||||
$this->shadow = new Style\Shadow();
|
||||
|
||||
$this->border->setLineStyle(Style\Border::LINE_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic Method : clone
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->container = null;
|
||||
$this->fill = clone $this->fill;
|
||||
$this->border = clone $this->border;
|
||||
$this->shadow = clone $this->shadow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Container, Slide or Group
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
*/
|
||||
public function getContainer()
|
||||
{
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Container, Slide or Group
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ShapeContainerInterface $pValue
|
||||
* @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide?
|
||||
* @throws \Exception
|
||||
* @return $this
|
||||
*/
|
||||
public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideOld = false)
|
||||
{
|
||||
if (is_null($this->container)) {
|
||||
// Add drawing to \PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
$this->container = $pValue;
|
||||
if (!is_null($this->container)) {
|
||||
$this->container->getShapeCollection()->append($this);
|
||||
}
|
||||
} else {
|
||||
if ($pOverrideOld) {
|
||||
// Remove drawing from old \PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
$iterator = $this->container->getShapeCollection()->getIterator();
|
||||
|
||||
while ($iterator->valid()) {
|
||||
if ($iterator->current()->getHashCode() == $this->getHashCode()) {
|
||||
$this->container->getShapeCollection()->offsetUnset($iterator->key());
|
||||
$this->container = null;
|
||||
break;
|
||||
}
|
||||
$iterator->next();
|
||||
}
|
||||
|
||||
// Set new \PhpOffice\PhpPresentation\Slide
|
||||
$this->setContainer($pValue);
|
||||
} else {
|
||||
throw new \Exception("A \PhpOffice\PhpPresentation\ShapeContainerInterface has already been assigned. Shapes can only exist on one \PhpOffice\PhpPresentation\ShapeContainerInterface.");
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetX()
|
||||
{
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetX($pValue = 0)
|
||||
{
|
||||
$this->offsetX = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetY()
|
||||
{
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetY($pValue = 0)
|
||||
{
|
||||
$this->offsetY = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setWidth($pValue = 0)
|
||||
{
|
||||
$this->width = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeight($pValue = 0)
|
||||
{
|
||||
$this->height = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set width and height with proportional resize
|
||||
*
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @example $objDrawing->setWidthAndHeight(160,120);
|
||||
* @return $this
|
||||
*/
|
||||
public function setWidthAndHeight($width = 0, $height = 0)
|
||||
{
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRotation()
|
||||
{
|
||||
return $this->rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rotation
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setRotation($pValue = 0)
|
||||
{
|
||||
$this->rotation = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function getFill()
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $pValue
|
||||
* @return \PhpOffice\PhpPresentation\AbstractShape
|
||||
*/
|
||||
public function setFill(Fill $pValue = null)
|
||||
{
|
||||
$this->fill = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Border
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function getBorder()
|
||||
{
|
||||
return $this->border;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Shadow
|
||||
*/
|
||||
public function getShadow()
|
||||
{
|
||||
return $this->shadow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Shadow $pValue
|
||||
* @throws \Exception
|
||||
* @return $this
|
||||
*/
|
||||
public function setShadow(Shadow $pValue = null)
|
||||
{
|
||||
$this->shadow = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has Hyperlink?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasHyperlink()
|
||||
{
|
||||
return !is_null($this->hyperlink);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Hyperlink
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getHyperlink()
|
||||
{
|
||||
if (is_null($this->hyperlink)) {
|
||||
$this->hyperlink = new Hyperlink();
|
||||
}
|
||||
return $this->hyperlink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Hyperlink
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Hyperlink $pHyperlink
|
||||
* @throws \Exception
|
||||
* @return $this
|
||||
*/
|
||||
public function setHyperlink(Hyperlink $pHyperlink = null)
|
||||
{
|
||||
$this->hyperlink = $pHyperlink;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5((is_object($this->container) ? $this->container->getHashCode() : '') . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->rotation . (is_null($this->getFill()) ? '' : $this->getFill()->getHashCode()) . (is_null($this->shadow) ? '' : $this->shadow->getHashCode()) . (is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
|
||||
public function isPlaceholder()
|
||||
{
|
||||
return !is_null($this->placeholder);
|
||||
}
|
||||
|
||||
public function getPlaceholder()
|
||||
{
|
||||
if (!$this->isPlaceholder()) {
|
||||
return null;
|
||||
}
|
||||
return $this->placeholder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Placeholder $placeholder
|
||||
* @return $this
|
||||
*/
|
||||
public function setPlaceHolder(Placeholder $placeholder)
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
55
PhpOffice/PhpPresentation/Autoloader.php
Normal file
55
PhpOffice/PhpPresentation/Autoloader.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* Autoloader
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
/** @const string */
|
||||
const NAMESPACE_PREFIX = 'PhpOffice\\PhpPresentation\\';
|
||||
|
||||
/**
|
||||
* Register
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register()
|
||||
{
|
||||
spl_autoload_register(array(new self, 'autoload'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload
|
||||
*
|
||||
* @param string $class
|
||||
*/
|
||||
public static function autoload($class)
|
||||
{
|
||||
$prefixLength = strlen(self::NAMESPACE_PREFIX);
|
||||
if (0 === strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) {
|
||||
$file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
|
||||
$file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
|
||||
if (file_exists($file)) {
|
||||
/** @noinspection PhpIncludeInspection Dynamic includes */
|
||||
require_once $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
PhpOffice/PhpPresentation/ComparableInterface.php
Normal file
51
PhpOffice/PhpPresentation/ComparableInterface.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* PhpOffice\PhpPresentation\ComparableInterface
|
||||
*/
|
||||
interface ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex();
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value);
|
||||
}
|
||||
252
PhpOffice/PhpPresentation/DocumentLayout.php
Normal file
252
PhpOffice/PhpPresentation/DocumentLayout.php
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use PhpOffice\Common\Drawing;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\DocumentLayout
|
||||
*/
|
||||
class DocumentLayout
|
||||
{
|
||||
const LAYOUT_CUSTOM = '';
|
||||
const LAYOUT_SCREEN_4X3 = 'screen4x3';
|
||||
const LAYOUT_SCREEN_16X10 = 'screen16x10';
|
||||
const LAYOUT_SCREEN_16X9 = 'screen16x9';
|
||||
const LAYOUT_35MM = '35mm';
|
||||
const LAYOUT_A3 = 'A3';
|
||||
const LAYOUT_A4 = 'A4';
|
||||
const LAYOUT_B4ISO = 'B4ISO';
|
||||
const LAYOUT_B5ISO = 'B5ISO';
|
||||
const LAYOUT_BANNER = 'banner';
|
||||
const LAYOUT_LETTER = 'letter';
|
||||
const LAYOUT_OVERHEAD = 'overhead';
|
||||
|
||||
const UNIT_EMU = 'emu';
|
||||
const UNIT_CENTIMETER = 'cm';
|
||||
const UNIT_INCH = 'in';
|
||||
const UNIT_MILLIMETER = 'mm';
|
||||
const UNIT_PIXEL = 'px';
|
||||
const UNIT_POINT = 'pt';
|
||||
|
||||
/**
|
||||
* Dimension types
|
||||
*
|
||||
* 1 px = 9525 EMU @ 96dpi (which is seems to be the default)
|
||||
* Absolute distances are specified in English Metric Units (EMUs),
|
||||
* occasionally referred to as A units; there are 360000 EMUs per
|
||||
* centimeter, 914400 EMUs per inch, 12700 EMUs per point.
|
||||
*/
|
||||
private $dimension = array(
|
||||
self::LAYOUT_SCREEN_4X3 => array('cx' => 9144000, 'cy' => 6858000),
|
||||
self::LAYOUT_SCREEN_16X10 => array('cx' => 9144000, 'cy' => 5715000),
|
||||
self::LAYOUT_SCREEN_16X9 => array('cx' => 9144000, 'cy' => 5143500),
|
||||
self::LAYOUT_35MM => array('cx' => 10287000, 'cy' => 6858000),
|
||||
self::LAYOUT_A3 => array('cx' => 15120000, 'cy' => 10692000),
|
||||
self::LAYOUT_A4 => array('cx' => 10692000, 'cy' => 7560000),
|
||||
self::LAYOUT_B4ISO => array('cx' => 10826750, 'cy' => 8120063),
|
||||
self::LAYOUT_B5ISO => array('cx' => 7169150, 'cy' => 5376863),
|
||||
self::LAYOUT_BANNER => array('cx' => 7315200, 'cy' => 914400),
|
||||
self::LAYOUT_LETTER => array('cx' => 9144000, 'cy' => 6858000),
|
||||
self::LAYOUT_OVERHEAD => array('cx' => 9144000, 'cy' => 6858000),
|
||||
);
|
||||
|
||||
/**
|
||||
* Layout name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $layout;
|
||||
|
||||
/**
|
||||
* Layout X dimension
|
||||
* @var float
|
||||
*/
|
||||
private $dimensionX;
|
||||
|
||||
/**
|
||||
* Layout Y dimension
|
||||
* @var float
|
||||
*/
|
||||
private $dimensionY;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\DocumentLayout
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setDocumentLayout(self::LAYOUT_SCREEN_4X3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDocumentLayout()
|
||||
{
|
||||
return $this->layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Document Layout
|
||||
*
|
||||
* @param array|string $pValue
|
||||
* @param boolean $isLandscape
|
||||
* @return \PhpOffice\PhpPresentation\DocumentLayout
|
||||
*/
|
||||
public function setDocumentLayout($pValue = self::LAYOUT_SCREEN_4X3, $isLandscape = true)
|
||||
{
|
||||
switch ($pValue) {
|
||||
case self::LAYOUT_SCREEN_4X3:
|
||||
case self::LAYOUT_SCREEN_16X10:
|
||||
case self::LAYOUT_SCREEN_16X9:
|
||||
case self::LAYOUT_35MM:
|
||||
case self::LAYOUT_A3:
|
||||
case self::LAYOUT_A4:
|
||||
case self::LAYOUT_B4ISO:
|
||||
case self::LAYOUT_B5ISO:
|
||||
case self::LAYOUT_BANNER:
|
||||
case self::LAYOUT_LETTER:
|
||||
case self::LAYOUT_OVERHEAD:
|
||||
$this->layout = $pValue;
|
||||
$this->dimensionX = $this->dimension[$this->layout]['cx'];
|
||||
$this->dimensionY = $this->dimension[$this->layout]['cy'];
|
||||
break;
|
||||
case self::LAYOUT_CUSTOM:
|
||||
default:
|
||||
$this->layout = self::LAYOUT_CUSTOM;
|
||||
$this->dimensionX = $pValue['cx'];
|
||||
$this->dimensionY = $pValue['cy'];
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$isLandscape) {
|
||||
$tmp = $this->dimensionX;
|
||||
$this->dimensionX = $this->dimensionY;
|
||||
$this->dimensionY = $tmp;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout cx
|
||||
*
|
||||
* @param string $unit
|
||||
* @return integer
|
||||
*/
|
||||
public function getCX($unit = self::UNIT_EMU)
|
||||
{
|
||||
return $this->convertUnit($this->dimensionX, self::UNIT_EMU, $unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout cy
|
||||
*
|
||||
* @param string $unit
|
||||
* @return integer
|
||||
*/
|
||||
public function getCY($unit = self::UNIT_EMU)
|
||||
{
|
||||
return $this->convertUnit($this->dimensionY, self::UNIT_EMU, $unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout cx
|
||||
*
|
||||
* @param float $value
|
||||
* @param string $unit
|
||||
* @return DocumentLayout
|
||||
*/
|
||||
public function setCX($value, $unit = self::UNIT_EMU)
|
||||
{
|
||||
$this->layout = self::LAYOUT_CUSTOM;
|
||||
$this->dimensionX = $this->convertUnit($value, $unit, self::UNIT_EMU);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout cy
|
||||
*
|
||||
* @param float $value
|
||||
* @param string $unit
|
||||
* @return DocumentLayout
|
||||
*/
|
||||
public function setCY($value, $unit = self::UNIT_EMU)
|
||||
{
|
||||
$this->layout = self::LAYOUT_CUSTOM;
|
||||
$this->dimensionY = $this->convertUnit($value, $unit, self::UNIT_EMU);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EMUs to differents units
|
||||
* @param float $value
|
||||
* @param string $fromUnit
|
||||
* @param string $toUnit
|
||||
* @return float
|
||||
*/
|
||||
protected function convertUnit($value, $fromUnit, $toUnit)
|
||||
{
|
||||
// Convert from $fromUnit to EMU
|
||||
switch ($fromUnit) {
|
||||
case self::UNIT_MILLIMETER:
|
||||
$value *= 36000;
|
||||
break;
|
||||
case self::UNIT_CENTIMETER:
|
||||
$value *= 360000;
|
||||
break;
|
||||
case self::UNIT_INCH:
|
||||
$value *= 914400;
|
||||
break;
|
||||
case self::UNIT_PIXEL:
|
||||
$value = Drawing::pixelsToEmu($value);
|
||||
break;
|
||||
case self::UNIT_POINT:
|
||||
$value *= 12700;
|
||||
break;
|
||||
case self::UNIT_EMU:
|
||||
default:
|
||||
// no changes
|
||||
}
|
||||
|
||||
// Convert from EMU to $toUnit
|
||||
switch ($toUnit) {
|
||||
case self::UNIT_MILLIMETER:
|
||||
$value /= 36000;
|
||||
break;
|
||||
case self::UNIT_CENTIMETER:
|
||||
$value /= 360000;
|
||||
break;
|
||||
case self::UNIT_INCH:
|
||||
$value /= 914400;
|
||||
break;
|
||||
case self::UNIT_PIXEL:
|
||||
$value = Drawing::emuToPixels($value);
|
||||
break;
|
||||
case self::UNIT_POINT:
|
||||
$value /= 12700;
|
||||
break;
|
||||
case self::UNIT_EMU:
|
||||
default:
|
||||
// no changes
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
348
PhpOffice/PhpPresentation/DocumentProperties.php
Normal file
348
PhpOffice/PhpPresentation/DocumentProperties.php
Normal file
|
|
@ -0,0 +1,348 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
class DocumentProperties
|
||||
{
|
||||
/**
|
||||
* Creator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $creator;
|
||||
|
||||
/**
|
||||
* LastModifiedBy
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $lastModifiedBy;
|
||||
|
||||
/**
|
||||
* Created
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $created;
|
||||
|
||||
/**
|
||||
* Modified
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $modified;
|
||||
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* Subject
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $subject;
|
||||
|
||||
/**
|
||||
* Keywords
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $keywords;
|
||||
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $category;
|
||||
|
||||
/**
|
||||
* Company
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $company;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->creator = 'Unknown Creator';
|
||||
$this->lastModifiedBy = $this->creator;
|
||||
$this->created = time();
|
||||
$this->modified = time();
|
||||
$this->title = "Untitled Presentation";
|
||||
$this->subject = '';
|
||||
$this->description = '';
|
||||
$this->keywords = '';
|
||||
$this->category = '';
|
||||
$this->company = 'Microsoft Corporation';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Creator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreator()
|
||||
{
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Creator
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setCreator($pValue = '')
|
||||
{
|
||||
$this->creator = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Modified By
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModifiedBy()
|
||||
{
|
||||
return $this->lastModifiedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Last Modified By
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setLastModifiedBy($pValue = '')
|
||||
{
|
||||
$this->lastModifiedBy = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Created
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCreated()
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Created
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setCreated($pValue = null)
|
||||
{
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->created = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Modified
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getModified()
|
||||
{
|
||||
return $this->modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Modified
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setModified($pValue = null)
|
||||
{
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->modified = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setTitle($pValue = '')
|
||||
{
|
||||
$this->title = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setDescription($pValue = '')
|
||||
{
|
||||
$this->description = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Subject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Subject
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setSubject($pValue = '')
|
||||
{
|
||||
$this->subject = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords()
|
||||
{
|
||||
return $this->keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Keywords
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setKeywords($pValue = '')
|
||||
{
|
||||
$this->keywords = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setCategory($pValue = '')
|
||||
{
|
||||
$this->category = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Company
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Company
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setCompany($pValue = '')
|
||||
{
|
||||
$this->company = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
96
PhpOffice/PhpPresentation/GeometryCalculator.php
Normal file
96
PhpOffice/PhpPresentation/GeometryCalculator.php
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* PhpOffice\PhpPresentation\GeometryCalculator
|
||||
*/
|
||||
class GeometryCalculator
|
||||
{
|
||||
const X = 'X';
|
||||
const Y = 'Y';
|
||||
|
||||
/**
|
||||
* Calculate X and Y offsets for a set of shapes within a container such as a slide or group.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ShapeContainerInterface $container
|
||||
* @return array
|
||||
*/
|
||||
public static function calculateOffsets(ShapeContainerInterface $container)
|
||||
{
|
||||
$offsets = array(self::X => 0, self::Y => 0);
|
||||
|
||||
if ($container !== null && count($container->getShapeCollection()) != 0) {
|
||||
$shapes = $container->getShapeCollection();
|
||||
if ($shapes[0] !== null) {
|
||||
$offsets[self::X] = $shapes[0]->getOffsetX();
|
||||
$offsets[self::Y] = $shapes[0]->getOffsetY();
|
||||
}
|
||||
|
||||
foreach ($shapes as $shape) {
|
||||
if ($shape !== null) {
|
||||
if ($shape->getOffsetX() < $offsets[self::X]) {
|
||||
$offsets[self::X] = $shape->getOffsetX();
|
||||
}
|
||||
|
||||
if ($shape->getOffsetY() < $offsets[self::Y]) {
|
||||
$offsets[self::Y] = $shape->getOffsetY();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $offsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate X and Y extents for a set of shapes within a container such as a slide or group.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ShapeContainerInterface $container
|
||||
* @return array
|
||||
*/
|
||||
public static function calculateExtents(ShapeContainerInterface $container)
|
||||
{
|
||||
$extents = array(self::X => 0, self::Y => 0);
|
||||
|
||||
if ($container !== null && count($container->getShapeCollection()) != 0) {
|
||||
$shapes = $container->getShapeCollection();
|
||||
if ($shapes[0] !== null) {
|
||||
$extents[self::X] = $shapes[0]->getOffsetX() + $shapes[0]->getWidth();
|
||||
$extents[self::Y] = $shapes[0]->getOffsetY() + $shapes[0]->getHeight();
|
||||
}
|
||||
|
||||
foreach ($shapes as $shape) {
|
||||
if ($shape !== null) {
|
||||
$extentX = $shape->getOffsetX() + $shape->getWidth();
|
||||
$extentY = $shape->getOffsetY() + $shape->getHeight();
|
||||
|
||||
if ($extentX > $extents[self::X]) {
|
||||
$extents[self::X] = $extentX;
|
||||
}
|
||||
|
||||
if ($extentY > $extents[self::Y]) {
|
||||
$extents[self::Y] = $extentY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $extents;
|
||||
}
|
||||
}
|
||||
198
PhpOffice/PhpPresentation/HashTable.php
Normal file
198
PhpOffice/PhpPresentation/HashTable.php
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\HashTable
|
||||
*/
|
||||
class HashTable
|
||||
{
|
||||
/**
|
||||
* HashTable elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $items = array();
|
||||
|
||||
/**
|
||||
* HashTable key map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $keyMap = array();
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\HashTable
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ComparableInterface[] $pSource Optional source array to create HashTable from
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(array $pSource = null)
|
||||
{
|
||||
if (!is_null($pSource)) {
|
||||
// Create HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable items from source
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ComparableInterface[] $pSource Source array to create HashTable from
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addFromSource($pSource = null)
|
||||
{
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
} elseif (!is_array($pSource)) {
|
||||
throw new \Exception('Invalid array parameter passed.');
|
||||
}
|
||||
|
||||
foreach ($pSource as $item) {
|
||||
$this->add($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable item
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ComparableInterface $pSource Item to add
|
||||
*/
|
||||
public function add(ComparableInterface $pSource)
|
||||
{
|
||||
// Determine hashcode
|
||||
$hashIndex = $pSource->getHashIndex();
|
||||
$hashCode = $pSource->getHashCode();
|
||||
|
||||
if (is_null($hashIndex)) {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
} elseif (isset($this->keyMap[$hashIndex])) {
|
||||
$hashCode = $this->keyMap[$hashIndex];
|
||||
}
|
||||
|
||||
// Add value
|
||||
if (!isset($this->items[$hashCode])) {
|
||||
$this->items[$hashCode] = $pSource;
|
||||
$index = count($this->items) - 1;
|
||||
$this->keyMap[$index] = $hashCode;
|
||||
$pSource->setHashIndex($index);
|
||||
} else {
|
||||
$pSource->setHashIndex($this->items[$hashCode]->getHashIndex());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove HashTable item
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ComparableInterface $pSource Item to remove
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function remove(ComparableInterface $pSource)
|
||||
{
|
||||
if (isset($this->items[$pSource->getHashCode()])) {
|
||||
unset($this->items[$pSource->getHashCode()]);
|
||||
|
||||
$deleteKey = -1;
|
||||
foreach ($this->keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->keyMap[$key - 1] = $value;
|
||||
}
|
||||
|
||||
if ($value == $pSource->getHashCode()) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->keyMap[count($this->keyMap) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->items = array();
|
||||
$this->keyMap = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for hash code
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '')
|
||||
{
|
||||
return array_search($pHashCode, $this->keyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return \PhpOffice\PhpPresentation\ComparableInterface
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0)
|
||||
{
|
||||
if (isset($this->keyMap[$pIndex])) {
|
||||
return $this->getByHashCode($this->keyMap[$pIndex]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by hashcode
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return \PhpOffice\PhpPresentation\ComparableInterface
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '')
|
||||
{
|
||||
if (isset($this->items[$pHashCode])) {
|
||||
return $this->items[$pHashCode];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* HashTable to array
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\ComparableInterface[]
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
}
|
||||
115
PhpOffice/PhpPresentation/IOFactory.php
Normal file
115
PhpOffice/PhpPresentation/IOFactory.php
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* IOFactory
|
||||
*/
|
||||
class IOFactory
|
||||
{
|
||||
/**
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $autoResolveClasses = array('Serialized', 'ODPresentation', 'PowerPoint97', 'PowerPoint2007');
|
||||
|
||||
/**
|
||||
* Create writer
|
||||
*
|
||||
* @param PhpPresentation $phpPresentation
|
||||
* @param string $name
|
||||
* @return \PhpOffice\PhpPresentation\Writer\WriterInterface
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function createWriter(PhpPresentation $phpPresentation, $name = 'PowerPoint2007')
|
||||
{
|
||||
$class = 'PhpOffice\\PhpPresentation\\Writer\\' . $name;
|
||||
return self::loadClass($class, $name, 'writer', $phpPresentation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create reader
|
||||
*
|
||||
* @param string $name
|
||||
* @return \PhpOffice\PhpPresentation\Reader\ReaderInterface
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function createReader($name = '')
|
||||
{
|
||||
$class = 'PhpOffice\\PhpPresentation\\Reader\\' . $name;
|
||||
return self::loadClass($class, $name, 'reader');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PhpPresentation from file using automatic \PhpOffice\PhpPresentation\Reader\ReaderInterface resolution
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PhpPresentation
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function load($pFilename)
|
||||
{
|
||||
// Try loading using self::$autoResolveClasses
|
||||
foreach (self::$autoResolveClasses as $autoResolveClass) {
|
||||
$reader = self::createReader($autoResolveClass);
|
||||
if ($reader->canRead($pFilename)) {
|
||||
return $reader->load($pFilename);
|
||||
}
|
||||
}
|
||||
|
||||
throw new \Exception("Could not automatically determine \PhpOffice\PhpPresentation\Reader\ReaderInterface for file.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Load class
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @param \PhpOffice\PhpPresentation\PhpPresentation $phpPresentation
|
||||
* @return mixed
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
private static function loadClass($class, $name, $type, PhpPresentation $phpPresentation = null)
|
||||
{
|
||||
if (class_exists($class) && self::isConcreteClass($class)) {
|
||||
if (is_null($phpPresentation)) {
|
||||
return new $class();
|
||||
} else {
|
||||
return new $class($phpPresentation);
|
||||
}
|
||||
} else {
|
||||
throw new \Exception('"'.$name.'" is not a valid '.$type.'.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is it a concrete class?
|
||||
*
|
||||
* @param string $class
|
||||
* @return bool
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
private static function isConcreteClass($class)
|
||||
{
|
||||
$reflection = new \ReflectionClass($class);
|
||||
|
||||
return !$reflection->isAbstract() && !$reflection->isInterface();
|
||||
}
|
||||
}
|
||||
447
PhpOffice/PhpPresentation/PhpPresentation.php
Normal file
447
PhpOffice/PhpPresentation/PhpPresentation.php
Normal file
|
|
@ -0,0 +1,447 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use PhpOffice\PhpPresentation\Slide;
|
||||
use PhpOffice\PhpPresentation\Slide\Iterator;
|
||||
use PhpOffice\PhpPresentation\Slide\SlideMaster;
|
||||
|
||||
/**
|
||||
* PhpPresentation
|
||||
*/
|
||||
class PhpPresentation
|
||||
{
|
||||
/**
|
||||
* Document properties
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
protected $documentProperties;
|
||||
|
||||
/**
|
||||
* Presentation properties
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\PresentationProperties
|
||||
*/
|
||||
protected $presentationProps;
|
||||
|
||||
/**
|
||||
* Document layout
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\DocumentLayout
|
||||
*/
|
||||
protected $layout;
|
||||
|
||||
/**
|
||||
* Collection of Slide objects
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Slide[]
|
||||
*/
|
||||
protected $slideCollection = array();
|
||||
|
||||
/**
|
||||
* Active slide index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $activeSlideIndex = 0;
|
||||
|
||||
/**
|
||||
* Collection of Master Slides
|
||||
* @var \ArrayObject|\PhpOffice\PhpPresentation\Slide\SlideMaster[]
|
||||
*/
|
||||
protected $slideMasters;
|
||||
|
||||
/**
|
||||
* Create a new PhpPresentation with one Slide
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Set empty Master & SlideLayout
|
||||
$this->createMasterSlide()->createSlideLayout();
|
||||
|
||||
// Initialise slide collection and add one slide
|
||||
$this->createSlide();
|
||||
$this->setActiveSlideIndex();
|
||||
|
||||
// Set initial document properties & layout
|
||||
$this->setDocumentProperties(new DocumentProperties());
|
||||
$this->setPresentationProperties(new PresentationProperties());
|
||||
$this->setLayout(new DocumentLayout());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
* @deprecated for getDocumentProperties
|
||||
*/
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->getDocumentProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set properties
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\DocumentProperties $value
|
||||
* @deprecated for setDocumentProperties
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
public function setProperties(DocumentProperties $value)
|
||||
{
|
||||
return $this->setDocumentProperties($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function getDocumentProperties()
|
||||
{
|
||||
return $this->documentProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set properties
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\DocumentProperties $value
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
public function setDocumentProperties(DocumentProperties $value)
|
||||
{
|
||||
$this->documentProperties = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get presentation properties
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\PresentationProperties
|
||||
*/
|
||||
public function getPresentationProperties()
|
||||
{
|
||||
return $this->presentationProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set presentation properties
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\PresentationProperties $value
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
public function setPresentationProperties(PresentationProperties $value)
|
||||
{
|
||||
$this->presentationProps = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get layout
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\DocumentLayout
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
return $this->layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set layout
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\DocumentLayout $value
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
public function setLayout(DocumentLayout $value)
|
||||
{
|
||||
$this->layout = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active slide
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function getActiveSlide()
|
||||
{
|
||||
return $this->slideCollection[$this->activeSlideIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create slide and add it to this presentation
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createSlide()
|
||||
{
|
||||
$newSlide = new Slide($this);
|
||||
$this->addSlide($newSlide);
|
||||
return $newSlide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide $slide
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function addSlide(Slide $slide = null)
|
||||
{
|
||||
$this->slideCollection[] = $slide;
|
||||
|
||||
return $slide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove slide by index
|
||||
*
|
||||
* @param int $index Slide index
|
||||
* @throws \Exception
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
public function removeSlideByIndex($index = 0)
|
||||
{
|
||||
if ($index > count($this->slideCollection) - 1) {
|
||||
throw new \Exception("Slide index is out of bounds.");
|
||||
}
|
||||
array_splice($this->slideCollection, $index, 1);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide by index
|
||||
*
|
||||
* @param int $index Slide index
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getSlide($index = 0)
|
||||
{
|
||||
if ($index > count($this->slideCollection) - 1) {
|
||||
throw new \Exception("Slide index is out of bounds.");
|
||||
}
|
||||
return $this->slideCollection[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all slides
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide[]
|
||||
*/
|
||||
public function getAllSlides()
|
||||
{
|
||||
return $this->slideCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\AbstractSlide $slide
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getIndex(Slide\AbstractSlide $slide)
|
||||
{
|
||||
$index = null;
|
||||
foreach ($this->slideCollection as $key => $value) {
|
||||
if ($value->getHashCode() == $slide->getHashCode()) {
|
||||
$index = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSlideCount()
|
||||
{
|
||||
return count($this->slideCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active slide index
|
||||
*
|
||||
* @return int Active slide index
|
||||
*/
|
||||
public function getActiveSlideIndex()
|
||||
{
|
||||
return $this->activeSlideIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active slide index
|
||||
*
|
||||
* @param int $index Active slide index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function setActiveSlideIndex($index = 0)
|
||||
{
|
||||
if ($index > count($this->slideCollection) - 1) {
|
||||
throw new \Exception("Active slide index is out of bounds.");
|
||||
}
|
||||
$this->activeSlideIndex = $index;
|
||||
|
||||
return $this->getActiveSlide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add external slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide $slide External slide to add
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function addExternalSlide(Slide $slide)
|
||||
{
|
||||
$slide->rebindParent($this);
|
||||
|
||||
$this->addMasterSlide($slide->getSlideLayout()->getSlideMaster());
|
||||
|
||||
return $this->addSlide($slide);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide iterator
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\Iterator
|
||||
*/
|
||||
public function getSlideIterator()
|
||||
{
|
||||
return new Iterator($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a masterslide and add it to this presentation
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\SlideMaster
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createMasterSlide()
|
||||
{
|
||||
$newMasterSlide = new SlideMaster($this);
|
||||
$this->addMasterSlide($newMasterSlide);
|
||||
return $newMasterSlide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add masterslide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\SlideMaster $slide
|
||||
* @return \PhpOffice\PhpPresentation\Slide\SlideMaster
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addMasterSlide(SlideMaster $slide = null)
|
||||
{
|
||||
$this->slideMasters[] = $slide;
|
||||
|
||||
return $slide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy presentation (!= clone!)
|
||||
*
|
||||
* @return PhpPresentation
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function copy()
|
||||
{
|
||||
$copied = clone $this;
|
||||
|
||||
$slideCount = count($this->slideCollection);
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
$this->slideCollection[$i] = $this->slideCollection[$i]->copy();
|
||||
$this->slideCollection[$i]->rebindParent($this);
|
||||
}
|
||||
|
||||
return $copied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a document as final
|
||||
* @param bool $state
|
||||
* @return PresentationProperties
|
||||
* @deprecated for getPresentationProperties()->markAsFinal()
|
||||
*/
|
||||
public function markAsFinal($state = true)
|
||||
{
|
||||
return $this->getPresentationProperties()->markAsFinal($state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if this document is marked as final
|
||||
* @return bool
|
||||
* @deprecated for getPresentationProperties()->isMarkedAsFinal()
|
||||
*/
|
||||
public function isMarkedAsFinal()
|
||||
{
|
||||
return $this->getPresentationProperties()->isMarkedAsFinal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zoom of the document (in percentage)
|
||||
* @param float $zoom
|
||||
* @return PresentationProperties
|
||||
* @deprecated for getPresentationProperties()->setZoom()
|
||||
*/
|
||||
public function setZoom($zoom = 1.0)
|
||||
{
|
||||
return $this->getPresentationProperties()->setZoom($zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the zoom (in percentage)
|
||||
* @return float
|
||||
* @deprecated for getPresentationProperties()->getZoom()
|
||||
*/
|
||||
public function getZoom()
|
||||
{
|
||||
return $this->getPresentationProperties()->getZoom();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ArrayObject|Slide\SlideMaster[]
|
||||
*/
|
||||
public function getAllMasterSlides()
|
||||
{
|
||||
return $this->slideMasters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ArrayObject|Slide\SlideMaster[] $slideMasters
|
||||
* @return $this
|
||||
*/
|
||||
public function setAllMasterSlides($slideMasters = array())
|
||||
{
|
||||
if ($slideMasters instanceof \ArrayObject || is_array($slideMasters)) {
|
||||
$this->slideMasters = $slideMasters;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
201
PhpOffice/PhpPresentation/PresentationProperties.php
Normal file
201
PhpOffice/PhpPresentation/PresentationProperties.php
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\PresentationProperties
|
||||
*/
|
||||
class PresentationProperties
|
||||
{
|
||||
const VIEW_HANDOUT = 'handoutView';
|
||||
const VIEW_NOTES = 'notesView';
|
||||
const VIEW_NOTES_MASTER = 'notesMasterView';
|
||||
const VIEW_OUTLINE = 'outlineView';
|
||||
const VIEW_SLIDE = 'sldView';
|
||||
const VIEW_SLIDE_MASTER = 'sldMasterView';
|
||||
const VIEW_SLIDE_SORTER = 'sldSorterView';
|
||||
const VIEW_SLIDE_THUMBNAIL = 'sldThumbnailView';
|
||||
|
||||
protected $arrayView = array(
|
||||
self::VIEW_HANDOUT,
|
||||
self::VIEW_NOTES,
|
||||
self::VIEW_NOTES_MASTER,
|
||||
self::VIEW_OUTLINE,
|
||||
self::VIEW_SLIDE,
|
||||
self::VIEW_SLIDE_MASTER,
|
||||
self::VIEW_SLIDE_SORTER,
|
||||
self::VIEW_SLIDE_THUMBNAIL,
|
||||
);
|
||||
|
||||
/*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $isLoopUntilEsc = false;
|
||||
|
||||
/**
|
||||
* Mark as final
|
||||
* @var bool
|
||||
*/
|
||||
protected $markAsFinal = false;
|
||||
|
||||
/*
|
||||
* @var string
|
||||
*/
|
||||
protected $thumbnail;
|
||||
|
||||
/**
|
||||
* Zoom
|
||||
* @var float
|
||||
*/
|
||||
protected $zoom = 1;
|
||||
|
||||
/*
|
||||
* @var string
|
||||
*/
|
||||
protected $lastView = self::VIEW_SLIDE;
|
||||
|
||||
/*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $isCommentVisible = false;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLoopContinuouslyUntilEsc()
|
||||
{
|
||||
return $this->isLoopUntilEsc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
* @return \PhpOffice\PhpPresentation\PresentationProperties
|
||||
*/
|
||||
public function setLoopContinuouslyUntilEsc($value = false)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->isLoopUntilEsc = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the thumbnail file path
|
||||
* @return string
|
||||
*/
|
||||
public function getThumbnailPath()
|
||||
{
|
||||
return $this->thumbnail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the path for the thumbnail file / preview picture
|
||||
* @param string $path
|
||||
* @return \PhpOffice\PhpPresentation\PresentationProperties
|
||||
*/
|
||||
public function setThumbnailPath($path = '')
|
||||
{
|
||||
if (file_exists($path)) {
|
||||
$this->thumbnail = $path;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a document as final
|
||||
* @param bool $state
|
||||
* @return PresentationProperties
|
||||
*/
|
||||
public function markAsFinal($state = true)
|
||||
{
|
||||
if (is_bool($state)) {
|
||||
$this->markAsFinal = $state;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if this document is marked as final
|
||||
* @return bool
|
||||
*/
|
||||
public function isMarkedAsFinal()
|
||||
{
|
||||
return $this->markAsFinal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zoom of the document (in percentage)
|
||||
* @param float $zoom
|
||||
* @return PresentationProperties
|
||||
*/
|
||||
public function setZoom($zoom = 1.0)
|
||||
{
|
||||
if (is_numeric($zoom)) {
|
||||
$this->zoom = (float)$zoom;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the zoom (in percentage)
|
||||
* @return float
|
||||
*/
|
||||
public function getZoom()
|
||||
{
|
||||
return $this->zoom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setLastView($value = self::VIEW_SLIDE)
|
||||
{
|
||||
if (in_array($value, $this->arrayView)) {
|
||||
$this->lastView = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastView()
|
||||
{
|
||||
return $this->lastView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setCommentVisible($value = false)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->isCommentVisible = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function isCommentVisible()
|
||||
{
|
||||
return $this->isCommentVisible;
|
||||
}
|
||||
}
|
||||
576
PhpOffice/PhpPresentation/Reader/ODPresentation.php
Normal file
576
PhpOffice/PhpPresentation/Reader/ODPresentation.php
Normal file
|
|
@ -0,0 +1,576 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Reader;
|
||||
|
||||
use ZipArchive;
|
||||
use PhpOffice\Common\XMLReader;
|
||||
use PhpOffice\Common\Drawing as CommonDrawing;
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\Gd;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
|
||||
use PhpOffice\PhpPresentation\Slide\Background\Image;
|
||||
use PhpOffice\PhpPresentation\Style\Bullet;
|
||||
use PhpOffice\PhpPresentation\Style\Color;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
use PhpOffice\PhpPresentation\Style\Shadow;
|
||||
use PhpOffice\PhpPresentation\Style\Alignment;
|
||||
|
||||
/**
|
||||
* Serialized format reader
|
||||
*/
|
||||
class ODPresentation implements ReaderInterface
|
||||
{
|
||||
/**
|
||||
* Output Object
|
||||
* @var PhpPresentation
|
||||
*/
|
||||
protected $oPhpPresentation;
|
||||
/**
|
||||
* Output Object
|
||||
* @var \ZipArchive
|
||||
*/
|
||||
protected $oZip;
|
||||
/**
|
||||
* @var array[]
|
||||
*/
|
||||
protected $arrayStyles = array();
|
||||
/**
|
||||
* @var array[]
|
||||
*/
|
||||
protected $arrayCommonStyles = array();
|
||||
/**
|
||||
* @var \PhpOffice\Common\XMLReader
|
||||
*/
|
||||
protected $oXMLReader;
|
||||
|
||||
/**
|
||||
* Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws \Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
return $this->fileSupportsUnserializePhpPresentation($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a file support UnserializePhpPresentation ?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws \Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function fileSupportsUnserializePhpPresentation($pFilename = '')
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new \Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$oZip = new ZipArchive();
|
||||
// Is it a zip ?
|
||||
if ($oZip->open($pFilename) === true) {
|
||||
// Is it an OpenXML Document ?
|
||||
// Is it a Presentation ?
|
||||
if (is_array($oZip->statName('META-INF/manifest.xml')) && is_array($oZip->statName('mimetype')) && $oZip->getFromName('mimetype') == 'application/vnd.oasis.opendocument.presentation') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PhpPresentation Serialized file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Unserialize... First make sure the file supports it!
|
||||
if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
|
||||
throw new \Exception("Invalid file format for PhpOffice\PhpPresentation\Reader\ODPresentation: " . $pFilename . ".");
|
||||
}
|
||||
|
||||
return $this->loadFile($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load PhpPresentation Serialized file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadFile($pFilename)
|
||||
{
|
||||
$this->oPhpPresentation = new PhpPresentation();
|
||||
$this->oPhpPresentation->removeSlideByIndex();
|
||||
|
||||
$this->oZip = new ZipArchive();
|
||||
$this->oZip->open($pFilename);
|
||||
|
||||
$this->oXMLReader = new XMLReader();
|
||||
if ($this->oXMLReader->getDomFromZip($pFilename, 'meta.xml') !== false) {
|
||||
$this->loadDocumentProperties();
|
||||
}
|
||||
$this->oXMLReader = new XMLReader();
|
||||
if ($this->oXMLReader->getDomFromZip($pFilename, 'styles.xml') !== false) {
|
||||
$this->loadStylesFile();
|
||||
}
|
||||
$this->oXMLReader = new XMLReader();
|
||||
if ($this->oXMLReader->getDomFromZip($pFilename, 'content.xml') !== false) {
|
||||
$this->loadSlides();
|
||||
}
|
||||
|
||||
return $this->oPhpPresentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Document Properties
|
||||
*/
|
||||
protected function loadDocumentProperties()
|
||||
{
|
||||
$arrayProperties = array(
|
||||
'/office:document-meta/office:meta/meta:initial-creator' => 'setCreator',
|
||||
'/office:document-meta/office:meta/dc:creator' => 'setLastModifiedBy',
|
||||
'/office:document-meta/office:meta/dc:title' => 'setTitle',
|
||||
'/office:document-meta/office:meta/dc:description' => 'setDescription',
|
||||
'/office:document-meta/office:meta/dc:subject' => 'setSubject',
|
||||
'/office:document-meta/office:meta/meta:keyword' => 'setKeywords',
|
||||
'/office:document-meta/office:meta/meta:creation-date' => 'setCreated',
|
||||
'/office:document-meta/office:meta/dc:date' => 'setModified',
|
||||
);
|
||||
$oProperties = $this->oPhpPresentation->getDocumentProperties();
|
||||
foreach ($arrayProperties as $path => $property) {
|
||||
$oElement = $this->oXMLReader->getElement($path);
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if (in_array($property, array('setCreated', 'setModified'))) {
|
||||
$oDateTime = new \DateTime();
|
||||
$oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
|
||||
$oProperties->{$property}($oDateTime->getTimestamp());
|
||||
} else {
|
||||
$oProperties->{$property}($oElement->nodeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract all slides
|
||||
*/
|
||||
protected function loadSlides()
|
||||
{
|
||||
foreach ($this->oXMLReader->getElements('/office:document-content/office:automatic-styles/*') as $oElement) {
|
||||
if ($oElement->hasAttribute('style:name')) {
|
||||
$this->loadStyle($oElement);
|
||||
}
|
||||
}
|
||||
foreach ($this->oXMLReader->getElements('/office:document-content/office:body/office:presentation/draw:page') as $oElement) {
|
||||
if ($oElement->nodeName == 'draw:page') {
|
||||
$this->loadSlide($oElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract style
|
||||
* @param \DOMElement $nodeStyle
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadStyle(\DOMElement $nodeStyle)
|
||||
{
|
||||
$keyStyle = $nodeStyle->getAttribute('style:name');
|
||||
|
||||
$nodeDrawingPageProps = $this->oXMLReader->getElement('style:drawing-page-properties', $nodeStyle);
|
||||
if ($nodeDrawingPageProps instanceof \DOMElement) {
|
||||
// Read Background Color
|
||||
if ($nodeDrawingPageProps->hasAttribute('draw:fill-color') && $nodeDrawingPageProps->getAttribute('draw:fill') == 'solid') {
|
||||
$oBackground = new \PhpOffice\PhpPresentation\Slide\Background\Color();
|
||||
$oColor = new Color();
|
||||
$oColor->setRGB(substr($nodeDrawingPageProps->getAttribute('draw:fill-color'), -6));
|
||||
$oBackground->setColor($oColor);
|
||||
}
|
||||
// Read Background Image
|
||||
if ($nodeDrawingPageProps->getAttribute('draw:fill') == 'bitmap' && $nodeDrawingPageProps->hasAttribute('draw:fill-image-name')) {
|
||||
$nameStyle = $nodeDrawingPageProps->getAttribute('draw:fill-image-name');
|
||||
if (!empty($this->arrayCommonStyles[$nameStyle]) && $this->arrayCommonStyles[$nameStyle]['type'] == 'image' && !empty($this->arrayCommonStyles[$nameStyle]['path'])) {
|
||||
$tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderODPBkg');
|
||||
$contentImg = $this->oZip->getFromName($this->arrayCommonStyles[$nameStyle]['path']);
|
||||
file_put_contents($tmpBkgImg, $contentImg);
|
||||
|
||||
$oBackground = new Image();
|
||||
$oBackground->setPath($tmpBkgImg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nodeGraphicProps = $this->oXMLReader->getElement('style:graphic-properties', $nodeStyle);
|
||||
if ($nodeGraphicProps instanceof \DOMElement) {
|
||||
// Read Shadow
|
||||
if ($nodeGraphicProps->hasAttribute('draw:shadow') && $nodeGraphicProps->getAttribute('draw:shadow') == 'visible') {
|
||||
$oShadow = new Shadow();
|
||||
$oShadow->setVisible(true);
|
||||
if ($nodeGraphicProps->hasAttribute('draw:shadow-color')) {
|
||||
$oShadow->getColor()->setRGB(substr($nodeGraphicProps->getAttribute('draw:shadow-color'), -6));
|
||||
}
|
||||
if ($nodeGraphicProps->hasAttribute('draw:shadow-opacity')) {
|
||||
$oShadow->setAlpha(100 - (int)substr($nodeGraphicProps->getAttribute('draw:shadow-opacity'), 0, -1));
|
||||
}
|
||||
if ($nodeGraphicProps->hasAttribute('draw:shadow-offset-x') && $nodeGraphicProps->hasAttribute('draw:shadow-offset-y')) {
|
||||
$offsetX = substr($nodeGraphicProps->getAttribute('draw:shadow-offset-x'), 0, -2);
|
||||
$offsetY = substr($nodeGraphicProps->getAttribute('draw:shadow-offset-y'), 0, -2);
|
||||
$distance = 0;
|
||||
if ($offsetX != 0) {
|
||||
$distance = ($offsetX < 0 ? $offsetX * -1 : $offsetX);
|
||||
} elseif ($offsetY != 0) {
|
||||
$distance = ($offsetY < 0 ? $offsetY * -1 : $offsetY);
|
||||
}
|
||||
$oShadow->setDirection(rad2deg(atan2($offsetY, $offsetX)));
|
||||
$oShadow->setDistance(CommonDrawing::centimetersToPixels($distance));
|
||||
}
|
||||
}
|
||||
// Read Fill
|
||||
if ($nodeGraphicProps->hasAttribute('draw:fill')) {
|
||||
$value = $nodeGraphicProps->getAttribute('draw:fill');
|
||||
|
||||
switch ($value) {
|
||||
case 'none':
|
||||
$oFill = new Fill();
|
||||
$oFill->setFillType(Fill::FILL_NONE);
|
||||
break;
|
||||
case 'solid':
|
||||
$oFill = new Fill();
|
||||
$oFill->setFillType(Fill::FILL_SOLID);
|
||||
if ($nodeGraphicProps->hasAttribute('draw:fill-color')) {
|
||||
$oColor = new Color();
|
||||
$oColor->setRGB(substr($nodeGraphicProps->getAttribute('draw:fill-color'), 1));
|
||||
$oFill->setStartColor($oColor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nodeTextProperties = $this->oXMLReader->getElement('style:text-properties', $nodeStyle);
|
||||
if ($nodeTextProperties instanceof \DOMElement) {
|
||||
$oFont = new Font();
|
||||
if ($nodeTextProperties->hasAttribute('fo:color')) {
|
||||
$oFont->getColor()->setRGB(substr($nodeTextProperties->getAttribute('fo:color'), -6));
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('fo:font-family')) {
|
||||
$oFont->setName($nodeTextProperties->getAttribute('fo:font-family'));
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('fo:font-weight') && $nodeTextProperties->getAttribute('fo:font-weight') == 'bold') {
|
||||
$oFont->setBold(true);
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('fo:font-size')) {
|
||||
$oFont->setSize(substr($nodeTextProperties->getAttribute('fo:font-size'), 0, -2));
|
||||
}
|
||||
}
|
||||
|
||||
$nodeParagraphProps = $this->oXMLReader->getElement('style:paragraph-properties', $nodeStyle);
|
||||
if ($nodeParagraphProps instanceof \DOMElement) {
|
||||
$oAlignment = new Alignment();
|
||||
if ($nodeParagraphProps->hasAttribute('fo:text-align')) {
|
||||
$oAlignment->setHorizontal($nodeParagraphProps->getAttribute('fo:text-align'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($nodeStyle->nodeName == 'text:list-style') {
|
||||
$arrayListStyle = array();
|
||||
foreach ($this->oXMLReader->getElements('text:list-level-style-bullet', $nodeStyle) as $oNodeListLevel) {
|
||||
$oAlignment = new Alignment();
|
||||
$oBullet = new Bullet();
|
||||
$oBullet->setBulletType(Bullet::TYPE_NONE);
|
||||
if ($oNodeListLevel->hasAttribute('text:level')) {
|
||||
$oAlignment->setLevel((int) $oNodeListLevel->getAttribute('text:level') - 1);
|
||||
}
|
||||
if ($oNodeListLevel->hasAttribute('text:bullet-char')) {
|
||||
$oBullet->setBulletChar($oNodeListLevel->getAttribute('text:bullet-char'));
|
||||
$oBullet->setBulletType(Bullet::TYPE_BULLET);
|
||||
}
|
||||
|
||||
$oNodeListProperties = $this->oXMLReader->getElement('style:list-level-properties', $oNodeListLevel);
|
||||
if ($oNodeListProperties instanceof \DOMElement) {
|
||||
if ($oNodeListProperties->hasAttribute('text:min-label-width')) {
|
||||
$oAlignment->setIndent((int)round(CommonDrawing::centimetersToPixels(substr($oNodeListProperties->getAttribute('text:min-label-width'), 0, -2))));
|
||||
}
|
||||
if ($oNodeListProperties->hasAttribute('text:space-before')) {
|
||||
$iSpaceBefore = CommonDrawing::centimetersToPixels(substr($oNodeListProperties->getAttribute('text:space-before'), 0, -2));
|
||||
$iMarginLeft = $iSpaceBefore + $oAlignment->getIndent();
|
||||
$oAlignment->setMarginLeft($iMarginLeft);
|
||||
}
|
||||
}
|
||||
$oNodeTextProperties = $this->oXMLReader->getElement('style:text-properties', $oNodeListLevel);
|
||||
if ($oNodeTextProperties instanceof \DOMElement) {
|
||||
if ($oNodeTextProperties->hasAttribute('fo:font-family')) {
|
||||
$oBullet->setBulletFont($oNodeTextProperties->getAttribute('fo:font-family'));
|
||||
}
|
||||
}
|
||||
|
||||
$arrayListStyle[$oAlignment->getLevel()] = array(
|
||||
'alignment' => $oAlignment,
|
||||
'bullet' => $oBullet,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->arrayStyles[$keyStyle] = array(
|
||||
'alignment' => isset($oAlignment) ? $oAlignment : null,
|
||||
'background' => isset($oBackground) ? $oBackground : null,
|
||||
'fill' => isset($oFill) ? $oFill : null,
|
||||
'font' => isset($oFont) ? $oFont : null,
|
||||
'shadow' => isset($oShadow) ? $oShadow : null,
|
||||
'listStyle' => isset($arrayListStyle) ? $arrayListStyle : null,
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Slide
|
||||
*
|
||||
* @param \DOMElement $nodeSlide
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadSlide(\DOMElement $nodeSlide)
|
||||
{
|
||||
// Core
|
||||
$this->oPhpPresentation->createSlide();
|
||||
$this->oPhpPresentation->setActiveSlideIndex($this->oPhpPresentation->getSlideCount() - 1);
|
||||
if ($nodeSlide->hasAttribute('draw:name')) {
|
||||
$this->oPhpPresentation->getActiveSlide()->setName($nodeSlide->getAttribute('draw:name'));
|
||||
}
|
||||
if ($nodeSlide->hasAttribute('draw:style-name')) {
|
||||
$keyStyle = $nodeSlide->getAttribute('draw:style-name');
|
||||
if (isset($this->arrayStyles[$keyStyle])) {
|
||||
$this->oPhpPresentation->getActiveSlide()->setBackground($this->arrayStyles[$keyStyle]['background']);
|
||||
}
|
||||
}
|
||||
foreach ($this->oXMLReader->getElements('draw:frame', $nodeSlide) as $oNodeFrame) {
|
||||
if ($this->oXMLReader->getElement('draw:image', $oNodeFrame)) {
|
||||
$this->loadShapeDrawing($oNodeFrame);
|
||||
continue;
|
||||
}
|
||||
if ($this->oXMLReader->getElement('draw:text-box', $oNodeFrame)) {
|
||||
$this->loadShapeRichText($oNodeFrame);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Shape Drawing
|
||||
*
|
||||
* @param \DOMElement $oNodeFrame
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadShapeDrawing(\DOMElement $oNodeFrame)
|
||||
{
|
||||
// Core
|
||||
$oShape = new Gd();
|
||||
$oShape->getShadow()->setVisible(false);
|
||||
|
||||
$oNodeImage = $this->oXMLReader->getElement('draw:image', $oNodeFrame);
|
||||
if ($oNodeImage instanceof \DOMElement) {
|
||||
if ($oNodeImage->hasAttribute('xlink:href')) {
|
||||
$sFilename = $oNodeImage->getAttribute('xlink:href');
|
||||
// svm = StarView Metafile
|
||||
if (pathinfo($sFilename, PATHINFO_EXTENSION) == 'svm') {
|
||||
return;
|
||||
}
|
||||
$imageFile = $this->oZip->getFromName($sFilename);
|
||||
if (!empty($imageFile)) {
|
||||
$oShape->setImageResource(imagecreatefromstring($imageFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oShape->setName($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
|
||||
$oShape->setDescription($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
|
||||
$oShape->setResizeProportional(false);
|
||||
$oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:width'), 0, -2))) : '');
|
||||
$oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:height'), 0, -2))) : '');
|
||||
$oShape->setResizeProportional(true);
|
||||
$oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:x'), 0, -2))) : '');
|
||||
$oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:y'), 0, -2))) : '');
|
||||
|
||||
if ($oNodeFrame->hasAttribute('draw:style-name')) {
|
||||
$keyStyle = $oNodeFrame->getAttribute('draw:style-name');
|
||||
if (isset($this->arrayStyles[$keyStyle])) {
|
||||
$oShape->setShadow($this->arrayStyles[$keyStyle]['shadow']);
|
||||
$oShape->setFill($this->arrayStyles[$keyStyle]['fill']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->oPhpPresentation->getActiveSlide()->addShape($oShape);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Shape RichText
|
||||
*
|
||||
* @param \DOMElement $oNodeFrame
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadShapeRichText(\DOMElement $oNodeFrame)
|
||||
{
|
||||
// Core
|
||||
$oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
|
||||
$oShape->setParagraphs(array());
|
||||
|
||||
$oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:width'), 0, -2))) : '');
|
||||
$oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:height'), 0, -2))) : '');
|
||||
$oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:x'), 0, -2))) : '');
|
||||
$oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:y'), 0, -2))) : '');
|
||||
|
||||
foreach ($this->oXMLReader->getElements('draw:text-box/*', $oNodeFrame) as $oNodeParagraph) {
|
||||
$this->levelParagraph = 0;
|
||||
if ($oNodeParagraph->nodeName == 'text:p') {
|
||||
$this->readParagraph($oShape, $oNodeParagraph);
|
||||
}
|
||||
if ($oNodeParagraph->nodeName == 'text:list') {
|
||||
$this->readList($oShape, $oNodeParagraph);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($oShape->getParagraphs()) > 0) {
|
||||
$oShape->setActiveParagraph(0);
|
||||
}
|
||||
}
|
||||
|
||||
protected $levelParagraph = 0;
|
||||
|
||||
/**
|
||||
* Read Paragraph
|
||||
* @param RichText $oShape
|
||||
* @param \DOMElement $oNodeParent
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function readParagraph(RichText $oShape, \DOMElement $oNodeParent)
|
||||
{
|
||||
$oParagraph = $oShape->createParagraph();
|
||||
$oDomList = $this->oXMLReader->getElements('text:span', $oNodeParent);
|
||||
$oDomTextNodes = $this->oXMLReader->getElements('text()', $oNodeParent);
|
||||
foreach ($oDomTextNodes as $oDomTextNode) {
|
||||
if (trim($oDomTextNode->nodeValue) != '') {
|
||||
$oTextRun = $oParagraph->createTextRun();
|
||||
$oTextRun->setText(trim($oDomTextNode->nodeValue));
|
||||
}
|
||||
}
|
||||
foreach ($oDomList as $oNodeRichTextElement) {
|
||||
$this->readParagraphItem($oParagraph, $oNodeRichTextElement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Paragraph Item
|
||||
* @param Paragraph $oParagraph
|
||||
* @param \DOMElement $oNodeParent
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function readParagraphItem(Paragraph $oParagraph, \DOMElement $oNodeParent)
|
||||
{
|
||||
if ($this->oXMLReader->elementExists('text:line-break', $oNodeParent)) {
|
||||
$oParagraph->createBreak();
|
||||
} else {
|
||||
$oTextRun = $oParagraph->createTextRun();
|
||||
if ($oNodeParent->hasAttribute('text:style-name')) {
|
||||
$keyStyle = $oNodeParent->getAttribute('text:style-name');
|
||||
if (isset($this->arrayStyles[$keyStyle])) {
|
||||
$oTextRun->setFont($this->arrayStyles[$keyStyle]['font']);
|
||||
}
|
||||
}
|
||||
$oTextRunLink = $this->oXMLReader->getElement('text:a', $oNodeParent);
|
||||
if ($oTextRunLink instanceof \DOMElement) {
|
||||
$oTextRun->setText($oTextRunLink->nodeValue);
|
||||
if ($oTextRunLink->hasAttribute('xlink:href')) {
|
||||
$oTextRun->getHyperlink()->setUrl($oTextRunLink->getAttribute('xlink:href'));
|
||||
}
|
||||
} else {
|
||||
$oTextRun->setText($oNodeParent->nodeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read List
|
||||
*
|
||||
* @param RichText $oShape
|
||||
* @param \DOMElement $oNodeParent
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function readList(RichText $oShape, \DOMElement $oNodeParent)
|
||||
{
|
||||
foreach ($this->oXMLReader->getElements('text:list-item/*', $oNodeParent) as $oNodeListItem) {
|
||||
if ($oNodeListItem->nodeName == 'text:p') {
|
||||
$this->readListItem($oShape, $oNodeListItem, $oNodeParent);
|
||||
}
|
||||
if ($oNodeListItem->nodeName == 'text:list') {
|
||||
$this->levelParagraph++;
|
||||
$this->readList($oShape, $oNodeListItem);
|
||||
$this->levelParagraph--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read List Item
|
||||
* @param RichText $oShape
|
||||
* @param \DOMElement $oNodeParent
|
||||
* @param \DOMElement $oNodeParagraph
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function readListItem(RichText $oShape, \DOMElement $oNodeParent, \DOMElement $oNodeParagraph)
|
||||
{
|
||||
$oParagraph = $oShape->createParagraph();
|
||||
if ($oNodeParagraph->hasAttribute('text:style-name')) {
|
||||
$keyStyle = $oNodeParagraph->getAttribute('text:style-name');
|
||||
if (isset($this->arrayStyles[$keyStyle]) && !empty($this->arrayStyles[$keyStyle]['listStyle'])) {
|
||||
$oParagraph->setAlignment($this->arrayStyles[$keyStyle]['listStyle'][$this->levelParagraph]['alignment']);
|
||||
$oParagraph->setBulletStyle($this->arrayStyles[$keyStyle]['listStyle'][$this->levelParagraph]['bullet']);
|
||||
}
|
||||
}
|
||||
foreach ($this->oXMLReader->getElements('text:span', $oNodeParent) as $oNodeRichTextElement) {
|
||||
$this->readParagraphItem($oParagraph, $oNodeRichTextElement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load file 'styles.xml'
|
||||
*/
|
||||
protected function loadStylesFile()
|
||||
{
|
||||
foreach ($this->oXMLReader->getElements('/office:document-styles/office:styles/*') as $oElement) {
|
||||
if ($oElement->nodeName == 'draw:fill-image') {
|
||||
$this->arrayCommonStyles[$oElement->getAttribute('draw:name')] = array(
|
||||
'type' => 'image',
|
||||
'path' => $oElement->hasAttribute('xlink:href') ? $oElement->getAttribute('xlink:href') : null
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1314
PhpOffice/PhpPresentation/Reader/PowerPoint2007.php
Normal file
1314
PhpOffice/PhpPresentation/Reader/PowerPoint2007.php
Normal file
File diff suppressed because it is too large
Load Diff
3472
PhpOffice/PhpPresentation/Reader/PowerPoint97.php
Normal file
3472
PhpOffice/PhpPresentation/Reader/PowerPoint97.php
Normal file
File diff suppressed because it is too large
Load Diff
41
PhpOffice/PhpPresentation/Reader/ReaderInterface.php
Normal file
41
PhpOffice/PhpPresentation/Reader/ReaderInterface.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Reader;
|
||||
|
||||
/**
|
||||
* Reader interface
|
||||
*/
|
||||
interface ReaderInterface
|
||||
{
|
||||
/**
|
||||
* Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename);
|
||||
|
||||
/**
|
||||
* Loads PhpPresentation from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function load($pFilename);
|
||||
}
|
||||
113
PhpOffice/PhpPresentation/Reader/Serialized.php
Normal file
113
PhpOffice/PhpPresentation/Reader/Serialized.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Reader;
|
||||
|
||||
use PhpOffice\Common\File;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\AbstractDrawingAdapter;
|
||||
|
||||
/**
|
||||
* Serialized format reader
|
||||
*/
|
||||
class Serialized implements ReaderInterface
|
||||
{
|
||||
/**
|
||||
* Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws \Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
return $this->fileSupportsUnserializePhpPresentation($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a file support UnserializePhpPresentation ?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws \Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function fileSupportsUnserializePhpPresentation($pFilename = '')
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new \Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// File exists, does it contain PhpPresentation.xml?
|
||||
return File::fileExists("zip://$pFilename#PhpPresentation.xml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PhpPresentation Serialized file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new \Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Unserialize... First make sure the file supports it!
|
||||
if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
|
||||
throw new \Exception("Invalid file format for PhpOffice\PhpPresentation\Reader\Serialized: " . $pFilename . ".");
|
||||
}
|
||||
|
||||
return $this->loadSerialized($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load PhpPresentation Serialized file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
*/
|
||||
private function loadSerialized($pFilename)
|
||||
{
|
||||
$oArchive = new \ZipArchive();
|
||||
if ($oArchive->open($pFilename) === true) {
|
||||
$xmlContent = $oArchive->getFromName('PhpPresentation.xml');
|
||||
|
||||
if (!empty($xmlContent)) {
|
||||
$xmlData = simplexml_load_string($xmlContent);
|
||||
$file = unserialize(base64_decode((string) $xmlData->data));
|
||||
|
||||
// Update media links
|
||||
for ($i = 0; $i < $file->getSlideCount(); ++$i) {
|
||||
for ($j = 0; $j < $file->getSlide($i)->getShapeCollection()->count(); ++$j) {
|
||||
if ($file->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawingAdapter) {
|
||||
$imgTemp = $file->getSlide($i)->getShapeCollection()->offsetGet($j);
|
||||
$imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getImageIndex() . '/' . pathinfo($imgTemp->getPath(), PATHINFO_BASENAME), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oArchive->close();
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
247
PhpOffice/PhpPresentation/Shape/AbstractGraphic.php
Normal file
247
PhpOffice/PhpPresentation/Shape/AbstractGraphic.php
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* Abstract drawing
|
||||
*/
|
||||
abstract class AbstractGraphic extends AbstractShape implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Image counter
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $imageCounter = 0;
|
||||
|
||||
/**
|
||||
* Image index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $imageIndex = 0;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* Proportional resize
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $resizeProportional;
|
||||
|
||||
/**
|
||||
* Slide relation ID (should not be used by user code!)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $relationId = null;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Slide\AbstractDrawing
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->name = '';
|
||||
$this->description = '';
|
||||
$this->resizeProportional = true;
|
||||
|
||||
// Set image index
|
||||
self::$imageCounter++;
|
||||
$this->imageIndex = self::$imageCounter;
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
parent::__clone();
|
||||
|
||||
self::$imageCounter++;
|
||||
$this->imageIndex = self::$imageCounter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getImageIndex()
|
||||
{
|
||||
return $this->imageIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Name
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($pValue = '')
|
||||
{
|
||||
$this->name = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($pValue = '')
|
||||
{
|
||||
$this->description = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic
|
||||
*/
|
||||
public function setWidth($pValue = 0)
|
||||
{
|
||||
// Resize proportional?
|
||||
if ($this->resizeProportional && $pValue != 0 && $this->width != 0) {
|
||||
$ratio = $this->height / $this->width;
|
||||
$this->height = (int) round($ratio * $pValue);
|
||||
}
|
||||
|
||||
// Set width
|
||||
$this->width = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic
|
||||
*/
|
||||
public function setHeight($pValue = 0)
|
||||
{
|
||||
// Resize proportional?
|
||||
if ($this->resizeProportional && $pValue != 0 && $this->height != 0) {
|
||||
$ratio = $this->width / $this->height;
|
||||
$this->width = (int) round($ratio * $pValue);
|
||||
}
|
||||
|
||||
// Set height
|
||||
$this->height = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set width and height with proportional resize
|
||||
* @author Vincent@luo MSN:kele_100@hotmail.com
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic
|
||||
*/
|
||||
public function setWidthAndHeight($width = 0, $height = 0)
|
||||
{
|
||||
$xratio = $width / $this->width;
|
||||
$yratio = $height / $this->height;
|
||||
if ($this->resizeProportional && !($width == 0 || $height == 0)) {
|
||||
if (($xratio * $this->height) < $height) {
|
||||
$this->height = (int) ceil($xratio * $this->height);
|
||||
$this->width = $width;
|
||||
} else {
|
||||
$this->width = (int) ceil($yratio * $this->width);
|
||||
$this->height = $height;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ResizeProportional
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isResizeProportional()
|
||||
{
|
||||
return $this->resizeProportional;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ResizeProportional
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic
|
||||
*/
|
||||
public function setResizeProportional($pValue = true)
|
||||
{
|
||||
$this->resizeProportional = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->name . $this->description . parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
172
PhpOffice/PhpPresentation/Shape/Chart.php
Normal file
172
PhpOffice/PhpPresentation/Shape/Chart.php
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart\Legend;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart\PlotArea;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart\Title;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart\View3D;
|
||||
|
||||
/**
|
||||
* Chart element
|
||||
*/
|
||||
class Chart extends AbstractGraphic implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* Legend
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
private $legend;
|
||||
|
||||
/**
|
||||
* Plot area
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
private $plotArea;
|
||||
|
||||
/**
|
||||
* View 3D
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
private $view3D;
|
||||
|
||||
/**
|
||||
* Include spreadsheet for editing data? Requires PHPExcel in the same folder as PhpPresentation
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $includeSpreadsheet = false;
|
||||
|
||||
/**
|
||||
* Create a new Chart
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialize
|
||||
$this->title = new Title();
|
||||
$this->legend = new Legend();
|
||||
$this->plotArea = new PlotArea();
|
||||
$this->view3D = new View3D();
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
parent::__clone();
|
||||
|
||||
$this->title = clone $this->title;
|
||||
$this->legend = clone $this->legend;
|
||||
$this->plotArea = clone $this->plotArea;
|
||||
$this->view3D = clone $this->view3D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Legend
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function getLegend()
|
||||
{
|
||||
return $this->legend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PlotArea
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
public function getPlotArea()
|
||||
{
|
||||
return $this->plotArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View3D
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
public function getView3D()
|
||||
{
|
||||
return $this->view3D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include spreadsheet for editing data? Requires PHPExcel in the same folder as PhpPresentation
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasIncludedSpreadsheet()
|
||||
{
|
||||
return $this->includeSpreadsheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include spreadsheet for editing data? Requires PHPExcel in the same folder as PhpPresentation
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart
|
||||
*/
|
||||
public function setIncludeSpreadsheet($value = false)
|
||||
{
|
||||
$this->includeSpreadsheet = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indexed filename (using image index)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
{
|
||||
return 'chart' . $this->getImageIndex() . '.xml';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(parent::getHashCode() . $this->title->getHashCode() . $this->legend->getHashCode() . $this->plotArea->getHashCode() . $this->view3D->getHashCode() . ($this->includeSpreadsheet ? 1 : 0) . __CLASS__);
|
||||
}
|
||||
}
|
||||
416
PhpOffice/PhpPresentation/Shape/Chart/Axis.php
Normal file
416
PhpOffice/PhpPresentation/Shape/Chart/Axis.php
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
use PhpOffice\PhpPresentation\Style\Outline;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
class Axis implements ComparableInterface
|
||||
{
|
||||
const AXIS_X = 'x';
|
||||
const AXIS_Y = 'y';
|
||||
|
||||
const TICK_MARK_NONE = 'none';
|
||||
const TICK_MARK_CROSS = 'cross';
|
||||
const TICK_MARK_INSIDE = 'in';
|
||||
const TICK_MARK_OUTSIDE = 'out';
|
||||
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $title = 'Axis Title';
|
||||
|
||||
/**
|
||||
* Format code
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $formatCode = '';
|
||||
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* @var Gridlines
|
||||
*/
|
||||
protected $majorGridlines;
|
||||
|
||||
/**
|
||||
* @var Gridlines
|
||||
*/
|
||||
protected $minorGridlines;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $minBounds;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $maxBounds;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $minorTickMark = self::TICK_MARK_NONE;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $majorTickMark = self::TICK_MARK_NONE;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
protected $minorUnit;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
protected $majorUnit;
|
||||
|
||||
/**
|
||||
* @var Outline
|
||||
*/
|
||||
protected $outline;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
protected $isVisible = true;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
|
||||
*
|
||||
* @param string $title Title
|
||||
*/
|
||||
public function __construct($title = 'Axis Title')
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->outline = new Outline();
|
||||
$this->font = new Font();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
public function setTitle($value = 'Axis Title')
|
||||
{
|
||||
$this->title = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
{
|
||||
$this->font = $pFont;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Format Code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormatCode()
|
||||
{
|
||||
return $this->formatCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Format Code
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
public function setFormatCode($value = '')
|
||||
{
|
||||
$this->formatCode = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMinBounds()
|
||||
{
|
||||
return $this->minBounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $minBounds
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMinBounds($minBounds = null)
|
||||
{
|
||||
$this->minBounds = is_null($minBounds) ? null : (int)$minBounds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMaxBounds()
|
||||
{
|
||||
return $this->maxBounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $maxBounds
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMaxBounds($maxBounds = null)
|
||||
{
|
||||
$this->maxBounds = is_null($maxBounds) ? null : (int)$maxBounds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gridlines
|
||||
*/
|
||||
public function getMajorGridlines()
|
||||
{
|
||||
return $this->majorGridlines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gridlines $majorGridlines
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMajorGridlines(Gridlines $majorGridlines)
|
||||
{
|
||||
$this->majorGridlines = $majorGridlines;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gridlines
|
||||
*/
|
||||
public function getMinorGridlines()
|
||||
{
|
||||
return $this->minorGridlines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gridlines $minorGridlines
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMinorGridlines(Gridlines $minorGridlines)
|
||||
{
|
||||
$this->minorGridlines = $minorGridlines;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMinorTickMark()
|
||||
{
|
||||
return $this->minorTickMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pTickMark
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMinorTickMark($pTickMark = self::TICK_MARK_NONE)
|
||||
{
|
||||
$this->minorTickMark = $pTickMark;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMajorTickMark()
|
||||
{
|
||||
return $this->majorTickMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pTickMark
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMajorTickMark($pTickMark = self::TICK_MARK_NONE)
|
||||
{
|
||||
$this->majorTickMark = $pTickMark;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getMinorUnit()
|
||||
{
|
||||
return $this->minorUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $pUnit
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMinorUnit($pUnit = null)
|
||||
{
|
||||
$this->minorUnit = $pUnit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getMajorUnit()
|
||||
{
|
||||
return $this->majorUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $pUnit
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMajorUnit($pUnit = null)
|
||||
{
|
||||
$this->majorUnit = $pUnit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Outline
|
||||
*/
|
||||
public function getOutline()
|
||||
{
|
||||
return $this->outline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Outline $outline
|
||||
* @return Axis
|
||||
*/
|
||||
public function setOutline(Outline $outline)
|
||||
{
|
||||
$this->outline = $outline;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->title . $this->formatCode . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @return $this
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Axis is hidden ?
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->isVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide an axis
|
||||
*
|
||||
* @param boolean $value delete
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsVisible($value)
|
||||
{
|
||||
$this->isVisible = (bool)$value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
36
PhpOffice/PhpPresentation/Shape/Chart/Gridlines.php
Normal file
36
PhpOffice/PhpPresentation/Shape/Chart/Gridlines.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\Style\Outline;
|
||||
|
||||
class Gridlines
|
||||
{
|
||||
/**
|
||||
* @var Outline
|
||||
*/
|
||||
protected $outline;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->outline = new Outline();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Outline
|
||||
*/
|
||||
public function getOutline()
|
||||
{
|
||||
return $this->outline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Outline $outline
|
||||
* @return Gridlines
|
||||
*/
|
||||
public function setOutline(Outline $outline)
|
||||
{
|
||||
$this->outline = $outline;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
384
PhpOffice/PhpPresentation/Shape/Chart/Legend.php
Normal file
384
PhpOffice/PhpPresentation/Shape/Chart/Legend.php
Normal file
|
|
@ -0,0 +1,384 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Alignment;
|
||||
use PhpOffice\PhpPresentation\Style\Border;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
class Legend implements ComparableInterface
|
||||
{
|
||||
/** Legend positions */
|
||||
const POSITION_BOTTOM = 'b';
|
||||
const POSITION_LEFT = 'l';
|
||||
const POSITION_RIGHT = 'r';
|
||||
const POSITION_TOP = 't';
|
||||
const POSITION_TOPRIGHT = 'tr';
|
||||
|
||||
/**
|
||||
* Visible
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $visible = true;
|
||||
|
||||
/**
|
||||
* Position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $position = self::POSITION_RIGHT;
|
||||
|
||||
/**
|
||||
* OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetX = 0;
|
||||
|
||||
/**
|
||||
* OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetY = 0;
|
||||
|
||||
/**
|
||||
* Width (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $width = 0;
|
||||
|
||||
/**
|
||||
* Height (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $height = 0;
|
||||
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* Border
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
private $border;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
private $fill;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
private $alignment;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Legend instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->font = new Font();
|
||||
$this->border = new Border();
|
||||
$this->fill = new Fill();
|
||||
$this->alignment = new Alignment();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Visible
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setVisible($value = true)
|
||||
{
|
||||
$this->visible = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Position
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Position
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setPosition($value = self::POSITION_RIGHT)
|
||||
{
|
||||
$this->position = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getOffsetX()
|
||||
{
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setOffsetX($value = 0)
|
||||
{
|
||||
$this->offsetX = (double)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getOffsetY()
|
||||
{
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setOffsetY($value = 0)
|
||||
{
|
||||
$this->offsetY = (double)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setWidth($value = 0)
|
||||
{
|
||||
$this->width = (double)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setHeight($value = 0)
|
||||
{
|
||||
$this->height = (double)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
{
|
||||
$this->font = $pFont;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Border
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function getBorder()
|
||||
{
|
||||
return $this->border;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Border
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Border $border
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setBorder(Border $border)
|
||||
{
|
||||
$this->border = $border;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function getFill()
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $fill
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setFill(Fill $fill)
|
||||
{
|
||||
$this->fill = $fill;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Alignment $alignment
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setAlignment(Alignment $alignment)
|
||||
{
|
||||
$this->alignment = $alignment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->position . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->border->getHashCode() . $this->fill->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @return Legend
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
94
PhpOffice/PhpPresentation/Shape/Chart/Marker.php
Normal file
94
PhpOffice/PhpPresentation/Shape/Chart/Marker.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
class Marker
|
||||
{
|
||||
const SYMBOL_CIRCLE = 'circle';
|
||||
const SYMBOL_DASH = 'dash';
|
||||
const SYMBOL_DIAMOND = 'diamond';
|
||||
const SYMBOL_DOT = 'dot';
|
||||
const SYMBOL_NONE = 'none';
|
||||
const SYMBOL_PLUS = 'plus';
|
||||
const SYMBOL_SQUARE = 'square';
|
||||
const SYMBOL_STAR = 'star';
|
||||
const SYMBOL_TRIANGLE = 'triangle';
|
||||
const SYMBOL_X = 'x';
|
||||
|
||||
public static $arraySymbol = array(
|
||||
self::SYMBOL_CIRCLE,
|
||||
self::SYMBOL_DASH,
|
||||
self::SYMBOL_DIAMOND,
|
||||
self::SYMBOL_DOT,
|
||||
self::SYMBOL_NONE,
|
||||
self::SYMBOL_PLUS,
|
||||
self::SYMBOL_SQUARE,
|
||||
self::SYMBOL_STAR,
|
||||
self::SYMBOL_TRIANGLE,
|
||||
self::SYMBOL_X
|
||||
);
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $symbol = self::SYMBOL_NONE;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $size = 5;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return $this->symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $symbol
|
||||
* @return $this
|
||||
*/
|
||||
public function setSymbol($symbol = self::SYMBOL_NONE)
|
||||
{
|
||||
$this->symbol = $symbol;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $size
|
||||
* @return $this
|
||||
*/
|
||||
public function setSize($size = 5)
|
||||
{
|
||||
$this->size = $size;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
277
PhpOffice/PhpPresentation/Shape/Chart/PlotArea.php
Normal file
277
PhpOffice/PhpPresentation/Shape/Chart/PlotArea.php
Normal file
|
|
@ -0,0 +1,277 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractType;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
class PlotArea implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Type
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractType
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* Axis X
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
private $axisX;
|
||||
|
||||
/**
|
||||
* Axis Y
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
private $axisY;
|
||||
|
||||
/**
|
||||
* OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetX = 0;
|
||||
|
||||
/**
|
||||
* OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetY = 0;
|
||||
|
||||
/**
|
||||
* Width (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $width = 0;
|
||||
|
||||
/**
|
||||
* Height (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $height = 0;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\PlotArea instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = null;
|
||||
$this->axisX = new Axis();
|
||||
$this->axisY = new Axis();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->axisX = clone $this->axisX;
|
||||
$this->axisY = clone $this->axisY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
*
|
||||
* @return AbstractType
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
if (is_null($this->type)) {
|
||||
throw new \Exception('Chart type has not been set.');
|
||||
}
|
||||
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractType $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
public function setType(Type\AbstractType $value)
|
||||
{
|
||||
$this->type = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Axis X
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
public function getAxisX()
|
||||
{
|
||||
return $this->axisX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Axis Y
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
public function getAxisY()
|
||||
{
|
||||
return $this->axisY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getOffsetX()
|
||||
{
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
public function setOffsetX($value = 0)
|
||||
{
|
||||
$this->offsetX = (double)$value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getOffsetY()
|
||||
{
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
public function setOffsetY($value = 0)
|
||||
{
|
||||
$this->offsetY = (double)$value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
public function setWidth($value = 0)
|
||||
{
|
||||
$this->width = (double)$value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
public function setHeight($value = 0)
|
||||
{
|
||||
$this->height = (double)$value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5((is_null($this->type) ? 'null' : $this->type->getHashCode()) . $this->axisX->getHashCode() . $this->axisY->getHashCode() . $this->offsetX . $this->offsetY . $this->width . $this->height . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @return PlotArea
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
598
PhpOffice/PhpPresentation/Shape/Chart/Series.php
Normal file
598
PhpOffice/PhpPresentation/Shape/Chart/Series.php
Normal file
|
|
@ -0,0 +1,598 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
use PhpOffice\PhpPresentation\Style\Outline;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
class Series implements ComparableInterface
|
||||
{
|
||||
/* Label positions */
|
||||
const LABEL_BESTFIT = 'bestFit';
|
||||
const LABEL_BOTTOM = 'b';
|
||||
const LABEL_CENTER = 'ctr';
|
||||
const LABEL_INSIDEBASE = 'inBase';
|
||||
const LABEL_INSIDEEND = 'inEnd';
|
||||
const LABEL_LEFT = 'i';
|
||||
const LABEL_OUTSIDEEND = 'outEnd';
|
||||
const LABEL_RIGHT = 'r';
|
||||
const LABEL_TOP = 't';
|
||||
|
||||
/**
|
||||
* DataPointFills (key/value)
|
||||
* @var array
|
||||
*/
|
||||
protected $dataPointFills = array();
|
||||
|
||||
/**
|
||||
* Data Label Number Format
|
||||
* @var string
|
||||
*/
|
||||
protected $DlblNumFormat = '';
|
||||
|
||||
/**
|
||||
* Separator
|
||||
* @var string
|
||||
*/
|
||||
protected $separator = null;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
protected $fill;
|
||||
|
||||
/**
|
||||
* Font
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
protected $font;
|
||||
|
||||
/**
|
||||
* Label position
|
||||
* @var string
|
||||
*/
|
||||
protected $labelPosition = 'ctr';
|
||||
|
||||
/**
|
||||
* @var Marker
|
||||
*/
|
||||
protected $marker;
|
||||
|
||||
/**
|
||||
* @var Outline
|
||||
*/
|
||||
protected $outline;
|
||||
|
||||
/**
|
||||
* Show Category Name
|
||||
* @var boolean
|
||||
*/
|
||||
private $showCategoryName = false;
|
||||
|
||||
/**
|
||||
* Show Leader Lines
|
||||
* @var boolean
|
||||
*/
|
||||
private $showLeaderLines = true;
|
||||
|
||||
/**
|
||||
* Show Legend Key
|
||||
* @var boolean
|
||||
*/
|
||||
private $showLegendKey = false;
|
||||
|
||||
/**
|
||||
* ShowPercentage
|
||||
* @var boolean
|
||||
*/
|
||||
private $showPercentage = false;
|
||||
|
||||
/**
|
||||
* ShowSeriesName
|
||||
* @var boolean
|
||||
*/
|
||||
private $showSeriesName = false;
|
||||
|
||||
/**
|
||||
* ShowValue
|
||||
* @var boolean
|
||||
*/
|
||||
private $showValue = true;
|
||||
|
||||
/**
|
||||
* Title
|
||||
* @var string
|
||||
*/
|
||||
private $title = 'Series Title';
|
||||
|
||||
/**
|
||||
* Values (key/value)
|
||||
* @var array
|
||||
*/
|
||||
private $values = array();
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Series instance
|
||||
*
|
||||
* @param string $title Title
|
||||
* @param array $values Values
|
||||
*/
|
||||
public function __construct($title = 'Series Title', $values = array())
|
||||
{
|
||||
$this->fill = new Fill();
|
||||
$this->font = new Font();
|
||||
$this->font->setName('Calibri');
|
||||
$this->font->setSize(9);
|
||||
$this->title = $title;
|
||||
$this->values = $values;
|
||||
$this->marker = new Marker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setTitle($value = 'Series Title')
|
||||
{
|
||||
$this->title = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Data Label NumFormat
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDlblNumFormat()
|
||||
{
|
||||
return $this->DlblNumFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has Data Label NumFormat
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function hasDlblNumFormat()
|
||||
{
|
||||
return !empty($this->DlblNumFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Data Label NumFormat
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setDlblNumFormat($value = '')
|
||||
{
|
||||
$this->DlblNumFormat = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function getFill()
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $fill
|
||||
* @return Series
|
||||
*/
|
||||
public function setFill(Fill $fill = null)
|
||||
{
|
||||
$this->fill = $fill;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DataPointFill
|
||||
*
|
||||
* @param int $dataPointIndex Data point index.
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function getDataPointFill($dataPointIndex)
|
||||
{
|
||||
if (!isset($this->dataPointFills[$dataPointIndex])) {
|
||||
$this->dataPointFills[$dataPointIndex] = new Fill();
|
||||
}
|
||||
|
||||
return $this->dataPointFills[$dataPointIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DataPointFills
|
||||
*
|
||||
* @return Fill[]
|
||||
*/
|
||||
public function getDataPointFills()
|
||||
{
|
||||
return $this->dataPointFills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Values
|
||||
*
|
||||
* @param array $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setValues($value = array())
|
||||
{
|
||||
$this->values = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Value
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function addValue($key, $value)
|
||||
{
|
||||
$this->values[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowSeriesName
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasShowSeriesName()
|
||||
{
|
||||
return $this->showSeriesName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowSeriesName
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setShowSeriesName($value)
|
||||
{
|
||||
$this->showSeriesName = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowCategoryName
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasShowCategoryName()
|
||||
{
|
||||
return $this->showCategoryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowCategoryName
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setShowCategoryName($value)
|
||||
{
|
||||
$this->showCategoryName = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowValue
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasShowLegendKey()
|
||||
{
|
||||
return $this->showLegendKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowValue
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setShowLegendKey($value)
|
||||
{
|
||||
$this->showLegendKey = (bool)$value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowValue
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasShowValue()
|
||||
{
|
||||
return $this->showValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowValue
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setShowValue($value)
|
||||
{
|
||||
$this->showValue = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowPercentage
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasShowPercentage()
|
||||
{
|
||||
return $this->showPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowPercentage
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setShowPercentage($value)
|
||||
{
|
||||
$this->showPercentage = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowLeaderLines
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasShowSeparator()
|
||||
{
|
||||
return !is_null($this->separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Separator
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setSeparator($pValue)
|
||||
{
|
||||
$this->separator = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Separator
|
||||
* @return string
|
||||
*/
|
||||
public function getSeparator()
|
||||
{
|
||||
return $this->separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowLeaderLines
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasShowLeaderLines()
|
||||
{
|
||||
return $this->showLeaderLines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowLeaderLines
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setShowLeaderLines($value)
|
||||
{
|
||||
$this->showLeaderLines = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
{
|
||||
$this->font = $pFont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get label position
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabelPosition()
|
||||
{
|
||||
return $this->labelPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set label position
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setLabelPosition($value)
|
||||
{
|
||||
$this->labelPosition = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Marker
|
||||
*/
|
||||
public function getMarker()
|
||||
{
|
||||
return $this->marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Marker $marker
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setMarker(Marker $marker)
|
||||
{
|
||||
$this->marker = $marker;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Outline
|
||||
*/
|
||||
public function getOutline()
|
||||
{
|
||||
return $this->outline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Outline $outline
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setOutline(Outline $outline)
|
||||
{
|
||||
$this->outline = $outline;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5((is_null($this->fill) ? 'null' : $this->fill->getHashCode()) . (is_null($this->font) ? 'null' : $this->font->getHashCode()) . var_export($this->values, true) . var_export($this, true) . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @link http://php.net/manual/en/language.oop5.cloning.php
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->font = clone $this->font;
|
||||
$this->marker = clone $this->marker;
|
||||
if (is_object($this->outline)) {
|
||||
$this->outline = clone $this->outline;
|
||||
}
|
||||
}
|
||||
}
|
||||
325
PhpOffice/PhpPresentation/Shape/Chart/Title.php
Normal file
325
PhpOffice/PhpPresentation/Shape/Chart/Title.php
Normal file
|
|
@ -0,0 +1,325 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Alignment;
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
class Title implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Visible
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $visible = true;
|
||||
|
||||
/**
|
||||
* Text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $text = 'Chart Title';
|
||||
|
||||
/**
|
||||
* OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetX = 0.01;
|
||||
|
||||
/**
|
||||
* OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetY = 0.01;
|
||||
|
||||
/**
|
||||
* Width (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $width = 0;
|
||||
|
||||
/**
|
||||
* Height (as a fraction of the chart)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $height = 0;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
private $alignment;
|
||||
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Title instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->alignment = new Alignment();
|
||||
$this->font = new Font();
|
||||
$this->font->setName('Calibri');
|
||||
$this->font->setSize(18);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Visible
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setVisible($value = true)
|
||||
{
|
||||
$this->visible = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Text
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setText($value = null)
|
||||
{
|
||||
$this->text = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getOffsetX()
|
||||
{
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @param float $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setOffsetX($value = 0.01)
|
||||
{
|
||||
$this->offsetX = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getOffsetY()
|
||||
{
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @param float $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setOffsetY($value = 0.01)
|
||||
{
|
||||
$this->offsetY = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setWidth($value = 0)
|
||||
{
|
||||
$this->width = (double)$value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setHeight($value = 0)
|
||||
{
|
||||
$this->height = (double)$value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
{
|
||||
$this->font = $pFont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Alignment $alignment
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setAlignment(Alignment $alignment)
|
||||
{
|
||||
$this->alignment = $alignment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->text . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @return Title
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
171
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractType.php
Normal file
171
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractType.php
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart\Series;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type
|
||||
*/
|
||||
abstract class AbstractType implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Has Axis X?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $hasAxisX = true;
|
||||
|
||||
/**
|
||||
* Has Axis Y?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $hasAxisY = true;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $data = array();
|
||||
|
||||
/**
|
||||
* Has Axis X?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasAxisX()
|
||||
{
|
||||
return $this->hasAxisX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has Axis Y?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasAxisY()
|
||||
{
|
||||
return $this->hasAxisY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @return AbstractType
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Series
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Chart\Series $value
|
||||
* @return $this
|
||||
*/
|
||||
public function addSeries(Series $value)
|
||||
{
|
||||
$this->data[] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series[]
|
||||
*/
|
||||
public function getSeries()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series
|
||||
*
|
||||
* @param array $value Array of \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* @return $this
|
||||
*/
|
||||
public function setSeries($value = array())
|
||||
{
|
||||
$this->data = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Data
|
||||
*
|
||||
* @deprecated getSeries
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->getSeries();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Data
|
||||
*
|
||||
* @deprecated setSeries
|
||||
* @param array $value
|
||||
* @return AbstractType
|
||||
*/
|
||||
public function setData($value = array())
|
||||
{
|
||||
return $this->setSeries($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @link http://php.net/manual/en/language.oop5.cloning.php
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$arrayClone = array();
|
||||
foreach ($this->data as $itemSeries) {
|
||||
$arrayClone[] = clone $itemSeries;
|
||||
}
|
||||
$this->data = $arrayClone;
|
||||
}
|
||||
}
|
||||
140
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php
Normal file
140
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar
|
||||
*/
|
||||
class AbstractTypeBar extends AbstractType
|
||||
{
|
||||
/** Orientation of bars */
|
||||
const DIRECTION_VERTICAL = 'col';
|
||||
const DIRECTION_HORIZONTAL = 'bar';
|
||||
|
||||
/** Grouping of bars */
|
||||
const GROUPING_CLUSTERED = 'clustered'; //Chart series are drawn next to each other along the category axis.
|
||||
const GROUPING_STACKED = 'stacked'; //Chart series are drawn next to each other on the value axis.
|
||||
const GROUPING_PERCENTSTACKED = 'percentStacked'; //Chart series are drawn next to each other along the value axis and scaled to total 100%
|
||||
|
||||
|
||||
/**
|
||||
* Orientation of bars
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $barDirection = self::DIRECTION_VERTICAL;
|
||||
|
||||
|
||||
/**
|
||||
* Grouping of bars
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $barGrouping = self::GROUPING_CLUSTERED;
|
||||
|
||||
|
||||
/**
|
||||
* Space between bar or columns clusters
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $gapWidthPercent = 150;
|
||||
|
||||
|
||||
/**
|
||||
* Set bar orientation
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypeBar
|
||||
*/
|
||||
public function setBarDirection($value = self::DIRECTION_VERTICAL)
|
||||
{
|
||||
$this->barDirection = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get orientation
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBarDirection()
|
||||
{
|
||||
return $this->barDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bar grouping (stack or expanded style bar)
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypeBar
|
||||
*/
|
||||
public function setBarGrouping($value = self::GROUPING_CLUSTERED)
|
||||
{
|
||||
$this->barGrouping = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get grouping (stack or expanded style bar)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBarGrouping()
|
||||
{
|
||||
return $this->barGrouping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getGapWidthPercent()
|
||||
{
|
||||
return $this->gapWidthPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $gapWidthPercent
|
||||
* @return $this
|
||||
*/
|
||||
public function setGapWidthPercent($gapWidthPercent)
|
||||
{
|
||||
if ($gapWidthPercent < 0) {
|
||||
$gapWidthPercent = 0;
|
||||
}
|
||||
if ($gapWidthPercent > 500) {
|
||||
$gapWidthPercent = 500;
|
||||
}
|
||||
$this->gapWidthPercent = $gapWidthPercent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar
|
||||
*/
|
||||
class AbstractTypePie extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Create a new self instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->hasAxisX = false;
|
||||
$this->hasAxisY = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explosion of the Pie
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $explosion = 0;
|
||||
|
||||
/**
|
||||
* Set explosion
|
||||
*
|
||||
* @param integer $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypePie
|
||||
*/
|
||||
public function setExplosion($value = 0)
|
||||
{
|
||||
$this->explosion = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get orientation
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExplosion()
|
||||
{
|
||||
return $this->explosion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
40
PhpOffice/PhpPresentation/Shape/Chart/Type/Area.php
Normal file
40
PhpOffice/PhpPresentation/Shape/Chart/Type/Area.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Area
|
||||
*/
|
||||
class Area extends AbstractType implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
return md5($hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
36
PhpOffice/PhpPresentation/Shape/Chart/Type/Bar.php
Normal file
36
PhpOffice/PhpPresentation/Shape/Chart/Type/Bar.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar
|
||||
*/
|
||||
class Bar extends AbstractTypeBar implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
36
PhpOffice/PhpPresentation/Shape/Chart/Type/Bar3D.php
Normal file
36
PhpOffice/PhpPresentation/Shape/Chart/Type/Bar3D.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D
|
||||
*/
|
||||
class Bar3D extends AbstractTypeBar implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
67
PhpOffice/PhpPresentation/Shape/Chart/Type/Doughnut.php
Normal file
67
PhpOffice/PhpPresentation/Shape/Chart/Type/Doughnut.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* self
|
||||
*/
|
||||
class Doughnut extends AbstractTypePie implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Hole Size
|
||||
* @var int
|
||||
*/
|
||||
protected $holeSize = 50;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getHoleSize()
|
||||
{
|
||||
return $this->holeSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $holeSize
|
||||
* @return Doughnut
|
||||
* @link https://msdn.microsoft.com/en-us/library/documentformat.openxml.drawing.charts.holesize(v=office.14).aspx
|
||||
*/
|
||||
public function setHoleSize($holeSize = 50)
|
||||
{
|
||||
if ($holeSize < 10) {
|
||||
$holeSize = 10;
|
||||
}
|
||||
if ($holeSize > 90) {
|
||||
$holeSize = 90;
|
||||
}
|
||||
$this->holeSize = $holeSize;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
40
PhpOffice/PhpPresentation/Shape/Chart/Type/Line.php
Normal file
40
PhpOffice/PhpPresentation/Shape/Chart/Type/Line.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Line
|
||||
*/
|
||||
class Line extends AbstractType implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
return md5($hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
36
PhpOffice/PhpPresentation/Shape/Chart/Type/Pie.php
Normal file
36
PhpOffice/PhpPresentation/Shape/Chart/Type/Pie.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* self
|
||||
*/
|
||||
class Pie extends AbstractTypePie implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
36
PhpOffice/PhpPresentation/Shape/Chart/Type/Pie3D.php
Normal file
36
PhpOffice/PhpPresentation/Shape/Chart/Type/Pie3D.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* self
|
||||
*/
|
||||
class Pie3D extends AbstractTypePie implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
40
PhpOffice/PhpPresentation/Shape/Chart/Type/Scatter.php
Normal file
40
PhpOffice/PhpPresentation/Shape/Chart/Type/Scatter.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Scatter
|
||||
*/
|
||||
class Scatter extends AbstractType implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
return md5($hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
258
PhpOffice/PhpPresentation/Shape/Chart/View3D.php
Normal file
258
PhpOffice/PhpPresentation/Shape/Chart/View3D.php
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
class View3D implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Rotation X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $rotationX = 0;
|
||||
|
||||
/**
|
||||
* Rotation Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $rotationY = 0;
|
||||
|
||||
/**
|
||||
* Right Angle Axes
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $rightAngleAxes = true;
|
||||
|
||||
/**
|
||||
* Perspective
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $perspective = 30;
|
||||
|
||||
/**
|
||||
* Height Percent
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $heightPercent = 100;
|
||||
|
||||
/**
|
||||
* Depth Percent
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $depthPercent = 100;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\View3D instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation X
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRotationX()
|
||||
{
|
||||
return $this->rotationX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rotation X (-90 to 90)
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
public function setRotationX($pValue = 0)
|
||||
{
|
||||
$this->rotationX = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation Y
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRotationY()
|
||||
{
|
||||
return $this->rotationY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rotation Y (-90 to 90)
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
public function setRotationY($pValue = 0)
|
||||
{
|
||||
$this->rotationY = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get RightAngleAxes
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasRightAngleAxes()
|
||||
{
|
||||
return $this->rightAngleAxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set RightAngleAxes
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
public function setRightAngleAxes($value = true)
|
||||
{
|
||||
$this->rightAngleAxes = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Perspective
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPerspective()
|
||||
{
|
||||
return $this->perspective;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Perspective (0 to 100)
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
public function setPerspective($value = 30)
|
||||
{
|
||||
$this->perspective = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HeightPercent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeightPercent()
|
||||
{
|
||||
return $this->heightPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set HeightPercent (5 to 500)
|
||||
*
|
||||
* @param int $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeightPercent($value = 100)
|
||||
{
|
||||
$this->heightPercent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DepthPercent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDepthPercent()
|
||||
{
|
||||
return $this->depthPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set DepthPercent (20 to 2000)
|
||||
*
|
||||
* @param int $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setDepthPercent($value = 100)
|
||||
{
|
||||
$this->depthPercent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->rotationX . $this->rotationY . ($this->rightAngleAxes ? 't' : 'f') . $this->perspective . $this->heightPercent . $this->depthPercent . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @return View3D
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
145
PhpOffice/PhpPresentation/Shape/Comment.php
Normal file
145
PhpOffice/PhpPresentation/Shape/Comment.php
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Comment\Author;
|
||||
|
||||
/**
|
||||
* Comment shape
|
||||
*/
|
||||
class Comment extends AbstractShape implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* @var Author
|
||||
*/
|
||||
protected $author;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $dtComment;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $text;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setDate(time());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Author
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Author $author
|
||||
* @return Comment
|
||||
*/
|
||||
public function setAuthor(Author $author)
|
||||
{
|
||||
$this->author = $author;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->dtComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $dtComment timestamp of the comment
|
||||
* @return Comment
|
||||
*/
|
||||
public function setDate($dtComment)
|
||||
{
|
||||
$this->dtComment = (int)$dtComment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
* @return Comment
|
||||
*/
|
||||
public function setText($text = '')
|
||||
{
|
||||
$this->text = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment has not height
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeight($pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment has not width
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setWidth($pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
85
PhpOffice/PhpPresentation/Shape/Comment/Author.php
Normal file
85
PhpOffice/PhpPresentation/Shape/Comment/Author.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Comment;
|
||||
|
||||
class Author
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $idxAuthor;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $initials;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
return $this->idxAuthor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $idxAuthor
|
||||
* @return Author
|
||||
*/
|
||||
public function setIndex($idxAuthor)
|
||||
{
|
||||
$this->idxAuthor = (int) $idxAuthor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getInitials()
|
||||
{
|
||||
return $this->initials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $initials
|
||||
* @return Author
|
||||
*/
|
||||
public function setInitials($initials)
|
||||
{
|
||||
$this->initials = $initials;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Author
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->getInitials() . $this->getName() . __CLASS__);
|
||||
}
|
||||
}
|
||||
28
PhpOffice/PhpPresentation/Shape/Drawing.php
Normal file
28
PhpOffice/PhpPresentation/Shape/Drawing.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\File;
|
||||
|
||||
/**
|
||||
* Drawing element
|
||||
* @deprecated Drawing\File
|
||||
*/
|
||||
class Drawing extends File
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\AbstractGraphic;
|
||||
|
||||
abstract class AbstractDrawingAdapter extends AbstractGraphic
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getContents();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getExtension();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getIndexedFilename();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getMimeType();
|
||||
}
|
||||
103
PhpOffice/PhpPresentation/Shape/Drawing/Base64.php
Normal file
103
PhpOffice/PhpPresentation/Shape/Drawing/Base64.php
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
class Base64 extends AbstractDrawingAdapter
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Unique name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $uniqueName;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $arrayMimeExtension = array(
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/png' => 'png',
|
||||
'image/gif' => 'gif',
|
||||
);
|
||||
|
||||
/**
|
||||
* Base64 constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
* @return Base64
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
list(, $imageContents) = explode(';', $this->getData());
|
||||
list(, $imageContents) = explode(',', $imageContents);
|
||||
return base64_decode($imageContents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
list($data, ) = explode(';', $this->getData());
|
||||
list(, $mime) = explode(':', $data);
|
||||
|
||||
if (!array_key_exists($mime, $this->arrayMimeExtension)) {
|
||||
throw new \Exception('Type Mime not found : "'.$mime.'"');
|
||||
}
|
||||
return $this->arrayMimeExtension[$mime];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
{
|
||||
return $this->uniqueName . $this->getImageIndex() . '.' . $this->getExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
$sImage = $this->getContents();
|
||||
if (!function_exists('getimagesizefromstring')) {
|
||||
$uri = 'data://application/octet-stream;base64,' . base64_encode($sImage);
|
||||
$image = getimagesize($uri);
|
||||
} else {
|
||||
$image = getimagesizefromstring($sImage);
|
||||
}
|
||||
return image_type_to_mime_type($image[2]);
|
||||
}
|
||||
}
|
||||
91
PhpOffice/PhpPresentation/Shape/Drawing/File.php
Normal file
91
PhpOffice/PhpPresentation/Shape/Drawing/File.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
use PhpOffice\Common\File as CommonFile;
|
||||
|
||||
class File extends AbstractDrawingAdapter
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Get Path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Path
|
||||
*
|
||||
* @param string $pValue File path
|
||||
* @param boolean $pVerifyFile Verify file
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Drawing\File
|
||||
*/
|
||||
public function setPath($pValue = '', $pVerifyFile = true)
|
||||
{
|
||||
if ($pVerifyFile) {
|
||||
if (!file_exists($pValue)) {
|
||||
throw new \Exception("File $pValue not found!");
|
||||
}
|
||||
}
|
||||
$this->path = $pValue;
|
||||
|
||||
if ($pVerifyFile) {
|
||||
if ($this->width == 0 && $this->height == 0) {
|
||||
list($this->width, $this->height) = getimagesize($this->getPath());
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
return CommonFile::fileGetContents($this->getPath());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
return pathinfo($this->getPath(), PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
if (!CommonFile::fileExists($this->getPath())) {
|
||||
throw new \Exception('File '.$this->getPath().' does not exist');
|
||||
}
|
||||
$image = getimagesizefromstring(CommonFile::fileGetContents($this->getPath()));
|
||||
return image_type_to_mime_type($image[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
{
|
||||
$output = str_replace('.' . $this->getExtension(), '', pathinfo($this->getPath(), PATHINFO_FILENAME));
|
||||
$output .= $this->getImageIndex();
|
||||
$output .= '.'.$this->getExtension();
|
||||
$output = str_replace(' ', '_', $output);
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
163
PhpOffice/PhpPresentation/Shape/Drawing/Gd.php
Normal file
163
PhpOffice/PhpPresentation/Shape/Drawing/Gd.php
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
class Gd extends AbstractDrawingAdapter
|
||||
{
|
||||
/* Rendering functions */
|
||||
const RENDERING_DEFAULT = 'imagepng';
|
||||
const RENDERING_PNG = 'imagepng';
|
||||
const RENDERING_GIF = 'imagegif';
|
||||
const RENDERING_JPEG = 'imagejpeg';
|
||||
|
||||
/* MIME types */
|
||||
const MIMETYPE_DEFAULT = 'image/png';
|
||||
const MIMETYPE_PNG = 'image/png';
|
||||
const MIMETYPE_GIF = 'image/gif';
|
||||
const MIMETYPE_JPEG = 'image/jpeg';
|
||||
|
||||
/**
|
||||
* Image resource
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
protected $imageResource;
|
||||
|
||||
/**
|
||||
* Rendering function
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $renderingFunction = self::RENDERING_DEFAULT;
|
||||
|
||||
/**
|
||||
* Mime type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $mimeType = self::MIMETYPE_DEFAULT;
|
||||
|
||||
/**
|
||||
* Unique name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $uniqueName;
|
||||
|
||||
/**
|
||||
* Gd constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image resource
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getImageResource()
|
||||
{
|
||||
return $this->imageResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image resource
|
||||
*
|
||||
* @param $value resource
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageResource($value = null)
|
||||
{
|
||||
$this->imageResource = $value;
|
||||
|
||||
if (!is_null($this->imageResource)) {
|
||||
// Get width/height
|
||||
$this->width = imagesx($this->imageResource);
|
||||
$this->height = imagesy($this->imageResource);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rendering function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRenderingFunction()
|
||||
{
|
||||
return $this->renderingFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set rendering function
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setRenderingFunction($value = self::RENDERING_DEFAULT)
|
||||
{
|
||||
$this->renderingFunction = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mime type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
return $this->mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mime type
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setMimeType($value = self::MIMETYPE_DEFAULT)
|
||||
{
|
||||
$this->mimeType = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
ob_start();
|
||||
if ($this->getMimeType() === self::MIMETYPE_DEFAULT) {
|
||||
imagealphablending($this->getImageResource(), false);
|
||||
imagesavealpha($this->getImageResource(), true);
|
||||
}
|
||||
call_user_func($this->getRenderingFunction(), $this->getImageResource());
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $imageContents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
$extension = strtolower($this->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
return $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
{
|
||||
return $this->uniqueName . $this->getImageIndex() . '.' . $this->getExtension();
|
||||
}
|
||||
}
|
||||
109
PhpOffice/PhpPresentation/Shape/Drawing/ZipFile.php
Normal file
109
PhpOffice/PhpPresentation/Shape/Drawing/ZipFile.php
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
use PhpOffice\Common\File as CommonFile;
|
||||
|
||||
class ZipFile extends AbstractDrawingAdapter
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Get Path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Path
|
||||
*
|
||||
* @param string $pValue File path
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Drawing\ZipFile
|
||||
*/
|
||||
public function setPath($pValue = '')
|
||||
{
|
||||
$this->path = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
if (!CommonFile::fileExists($this->getZipFileOut())) {
|
||||
throw new \Exception('File '.$this->getZipFileOut().' does not exist');
|
||||
}
|
||||
|
||||
$imageZip = new \ZipArchive();
|
||||
$imageZip->open($this->getZipFileOut());
|
||||
$imageContents = $imageZip->getFromName($this->getZipFileIn());
|
||||
$imageZip->close();
|
||||
unset($imageZip);
|
||||
return $imageContents;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
return pathinfo($this->getZipFileIn(), PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
if (!CommonFile::fileExists($this->getZipFileOut())) {
|
||||
throw new \Exception('File '.$this->getZipFileOut().' does not exist');
|
||||
}
|
||||
$oArchive = new \ZipArchive();
|
||||
$oArchive->open($this->getZipFileOut());
|
||||
if (!function_exists('getimagesizefromstring')) {
|
||||
$uri = 'data://application/octet-stream;base64,' . base64_encode($oArchive->getFromName($this->getZipFileIn()));
|
||||
$image = getimagesize($uri);
|
||||
} else {
|
||||
$image = getimagesizefromstring($oArchive->getFromName($this->getZipFileIn()));
|
||||
}
|
||||
return image_type_to_mime_type($image[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
{
|
||||
$output = pathinfo($this->getZipFileIn(), PATHINFO_FILENAME);
|
||||
$output = str_replace('.' . $this->getExtension(), '', $output);
|
||||
$output .= $this->getImageIndex();
|
||||
$output .= '.'.$this->getExtension();
|
||||
$output = str_replace(' ', '_', $output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function getZipFileOut()
|
||||
{
|
||||
$path = str_replace('zip://', '', $this->getPath());
|
||||
$path = explode('#', $path);
|
||||
return empty($path[0]) ? '' : $path[0];
|
||||
}
|
||||
|
||||
protected function getZipFileIn()
|
||||
{
|
||||
$path = str_replace('zip://', '', $this->getPath());
|
||||
$path = explode('#', $path);
|
||||
return empty($path[1]) ? '' : $path[1];
|
||||
}
|
||||
}
|
||||
268
PhpOffice/PhpPresentation/Shape/Group.php
Normal file
268
PhpOffice/PhpPresentation/Shape/Group.php
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\GeometryCalculator;
|
||||
use PHPOffice\PhpPresentation\ShapeContainerInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText;
|
||||
use PhpOffice\PhpPresentation\Shape\Table;
|
||||
|
||||
class Group extends AbstractShape implements ShapeContainerInterface
|
||||
{
|
||||
/**
|
||||
* Collection of shapes
|
||||
*
|
||||
* @var \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[]
|
||||
*/
|
||||
private $shapeCollection = null;
|
||||
|
||||
/**
|
||||
* Extent X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $extentX;
|
||||
|
||||
/**
|
||||
* Extent Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $extentY;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// For logic purposes.
|
||||
$this->offsetX = null;
|
||||
$this->offsetY = null;
|
||||
|
||||
// Shape collection
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of shapes
|
||||
*
|
||||
* @return \ArrayObject|AbstractShape[]
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
return $this->shapeCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shape to slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\AbstractShape $shape
|
||||
* @return \PhpOffice\PhpPresentation\AbstractShape
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addShape(AbstractShape $shape)
|
||||
{
|
||||
$shape->setContainer($this);
|
||||
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetX()
|
||||
{
|
||||
if ($this->offsetX === null) {
|
||||
$offsets = GeometryCalculator::calculateOffsets($this);
|
||||
$this->offsetX = $offsets[GeometryCalculator::X];
|
||||
$this->offsetY = $offsets[GeometryCalculator::Y];
|
||||
}
|
||||
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignores setting the X Offset, preserving the default behavior.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetX($pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetY()
|
||||
{
|
||||
if ($this->offsetY === null) {
|
||||
$offsets = GeometryCalculator::calculateOffsets($this);
|
||||
$this->offsetX = $offsets[GeometryCalculator::X];
|
||||
$this->offsetY = $offsets[GeometryCalculator::Y];
|
||||
}
|
||||
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignores setting the Y Offset, preserving the default behavior.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetY($pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentX()
|
||||
{
|
||||
if ($this->extentX === null) {
|
||||
$extents = GeometryCalculator::calculateExtents($this);
|
||||
$this->extentX = $extents[GeometryCalculator::X] - $this->getOffsetX();
|
||||
$this->extentY = $extents[GeometryCalculator::Y] - $this->getOffsetY();
|
||||
}
|
||||
|
||||
return $this->extentX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentY()
|
||||
{
|
||||
if ($this->extentY === null) {
|
||||
$extents = GeometryCalculator::calculateExtents($this);
|
||||
$this->extentX = $extents[GeometryCalculator::X] - $this->getOffsetX();
|
||||
$this->extentY = $extents[GeometryCalculator::Y] - $this->getOffsetY();
|
||||
}
|
||||
|
||||
return $this->extentY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignores setting the width, preserving the default behavior.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setWidth($pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignores setting the height, preserving the default behavior.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeight($pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create rich text shape
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createRichTextShape()
|
||||
{
|
||||
$shape = new RichText();
|
||||
$this->addShape($shape);
|
||||
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create line shape
|
||||
*
|
||||
* @param int $fromX Starting point x offset
|
||||
* @param int $fromY Starting point y offset
|
||||
* @param int $toX Ending point x offset
|
||||
* @param int $toY Ending point y offset
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Line
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createLineShape($fromX, $fromY, $toX, $toY)
|
||||
{
|
||||
$shape = new Line($fromX, $fromY, $toX, $toY);
|
||||
$this->addShape($shape);
|
||||
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create chart shape
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createChartShape()
|
||||
{
|
||||
$shape = new Chart();
|
||||
$this->addShape($shape);
|
||||
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create drawing shape
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Drawing\File
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createDrawingShape()
|
||||
{
|
||||
$shape = new Drawing\File();
|
||||
$this->addShape($shape);
|
||||
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create table shape
|
||||
*
|
||||
* @param int $columns Number of columns
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createTableShape($columns = 1)
|
||||
{
|
||||
$shape = new Table($columns);
|
||||
$this->addShape($shape);
|
||||
|
||||
return $shape;
|
||||
}
|
||||
}
|
||||
189
PhpOffice/PhpPresentation/Shape/Hyperlink.php
Normal file
189
PhpOffice/PhpPresentation/Shape/Hyperlink.php
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
/**
|
||||
* Hyperlink element
|
||||
*/
|
||||
class Hyperlink
|
||||
{
|
||||
/**
|
||||
* URL to link the shape to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* Tooltip to display on the hyperlink
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tooltip;
|
||||
|
||||
/**
|
||||
* Slide number to link to
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $slideNumber = null;
|
||||
|
||||
/**
|
||||
* Slide relation ID (should not be used by user code!)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $relationId = null;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
*
|
||||
* @param string $pUrl Url to link the shape to
|
||||
* @param string $pTooltip Tooltip to display on the hyperlink
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($pUrl = '', $pTooltip = '')
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->setUrl($pUrl);
|
||||
$this->setTooltip($pTooltip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set URL
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
*/
|
||||
public function setUrl($value = '')
|
||||
{
|
||||
$this->url = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tooltip
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTooltip()
|
||||
{
|
||||
return $this->tooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tooltip
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
*/
|
||||
public function setTooltip($value = '')
|
||||
{
|
||||
$this->tooltip = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide number
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSlideNumber()
|
||||
{
|
||||
return $this->slideNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide number
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
*/
|
||||
public function setSlideNumber($value = 1)
|
||||
{
|
||||
$this->url = 'ppaction://hlinksldjump';
|
||||
$this->slideNumber = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this hyperlink internal? (to another slide)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isInternal()
|
||||
{
|
||||
return strpos($this->url, 'ppaction://') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->url . $this->tooltip . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
57
PhpOffice/PhpPresentation/Shape/Line.php
Normal file
57
PhpOffice/PhpPresentation/Shape/Line.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Border;
|
||||
|
||||
/**
|
||||
* Line shape
|
||||
*/
|
||||
class Line extends AbstractShape implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Line instance
|
||||
*
|
||||
* @param int $fromX
|
||||
* @param int $fromY
|
||||
* @param int $toX
|
||||
* @param int $toY
|
||||
*/
|
||||
public function __construct($fromX, $fromY, $toX, $toY)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->getBorder()->setLineStyle(Border::LINE_SINGLE);
|
||||
|
||||
$this->setOffsetX($fromX);
|
||||
$this->setOffsetY($fromY);
|
||||
$this->setWidth($toX - $fromX);
|
||||
$this->setHeight($toY - $fromY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->getBorder()->getLineStyle() . parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
49
PhpOffice/PhpPresentation/Shape/Media.php
Normal file
49
PhpOffice/PhpPresentation/Shape/Media.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\File;
|
||||
|
||||
/**
|
||||
* Media element
|
||||
*/
|
||||
class Media extends File implements ComparableInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
switch (strtolower($this->getExtension())) {
|
||||
case 'mp4':
|
||||
$mimetype = 'video/mp4';
|
||||
break;
|
||||
case 'ogv':
|
||||
$mimetype = 'video/ogg';
|
||||
break;
|
||||
case 'wmv':
|
||||
$mimetype = 'video/x-ms-wmv';
|
||||
break;
|
||||
default:
|
||||
$mimetype = 'application/octet-stream';
|
||||
}
|
||||
return $mimetype;
|
||||
}
|
||||
}
|
||||
28
PhpOffice/PhpPresentation/Shape/MemoryDrawing.php
Normal file
28
PhpOffice/PhpPresentation/Shape/MemoryDrawing.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\Gd;
|
||||
|
||||
/**
|
||||
* Memory drawing shape
|
||||
* @deprecated Drawing\Gd
|
||||
*/
|
||||
class MemoryDrawing extends Gd
|
||||
{
|
||||
}
|
||||
95
PhpOffice/PhpPresentation/Shape/Placeholder.php
Normal file
95
PhpOffice/PhpPresentation/Shape/Placeholder.php
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
class Placeholder
|
||||
{
|
||||
/** Placeholder Type constants */
|
||||
const PH_TYPE_BODY = 'body';
|
||||
const PH_TYPE_CHART = 'chart';
|
||||
const PH_TYPE_SUBTITLE = 'subTitle';
|
||||
const PH_TYPE_TITLE = 'title';
|
||||
const PH_TYPE_FOOTER = 'ftr';
|
||||
const PH_TYPE_DATETIME = 'dt';
|
||||
const PH_TYPE_SLIDENUM = 'sldNum';
|
||||
/**
|
||||
* hasCustomPrompt
|
||||
* Indicates whether the placeholder should have a customer prompt.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $hasCustomPrompt;
|
||||
/**
|
||||
* idx
|
||||
* Specifies the index of the placeholder. This is used when applying templates or changing layouts to
|
||||
* match a placeholder on one template or master to another.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $idx;
|
||||
/**
|
||||
* type
|
||||
* Specifies what content type the placeholder is to contains
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Placeholder constructor.
|
||||
* @param $type
|
||||
*/
|
||||
public function __construct($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $type
|
||||
* @return Placeholder
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIdx()
|
||||
{
|
||||
return $this->idx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $idx
|
||||
* @return Placeholder
|
||||
*/
|
||||
public function setIdx($idx)
|
||||
{
|
||||
$this->idx = $idx;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
710
PhpOffice/PhpPresentation/Shape/RichText.php
Normal file
710
PhpOffice/PhpPresentation/Shape/RichText.php
Normal file
|
|
@ -0,0 +1,710 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
class RichText extends AbstractShape implements ComparableInterface
|
||||
{
|
||||
/** Wrapping */
|
||||
const WRAP_NONE = 'none';
|
||||
const WRAP_SQUARE = 'square';
|
||||
|
||||
/** Autofit */
|
||||
const AUTOFIT_DEFAULT = 'spAutoFit';
|
||||
const AUTOFIT_SHAPE = 'spAutoFit';
|
||||
const AUTOFIT_NOAUTOFIT = 'noAutofit';
|
||||
const AUTOFIT_NORMAL = 'normAutofit';
|
||||
|
||||
/** Overflow */
|
||||
const OVERFLOW_CLIP = 'clip';
|
||||
const OVERFLOW_OVERFLOW = 'overflow';
|
||||
|
||||
/**
|
||||
* Rich text paragraphs
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[]
|
||||
*/
|
||||
private $richTextParagraphs;
|
||||
|
||||
/**
|
||||
* Active paragraph
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $activeParagraph = 0;
|
||||
|
||||
/**
|
||||
* Text wrapping
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $wrap = self::WRAP_SQUARE;
|
||||
|
||||
/**
|
||||
* Autofit
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $autoFit = self::AUTOFIT_DEFAULT;
|
||||
|
||||
/**
|
||||
* Horizontal overflow
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $horizontalOverflow = self::OVERFLOW_OVERFLOW;
|
||||
|
||||
/**
|
||||
* Vertical overflow
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $verticalOverflow = self::OVERFLOW_OVERFLOW;
|
||||
|
||||
/**
|
||||
* Text upright?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $upright = false;
|
||||
|
||||
/**
|
||||
* Vertical text?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $vertical = false;
|
||||
|
||||
/**
|
||||
* Number of columns (1 - 16)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $columns = 1;
|
||||
|
||||
/**
|
||||
* Bottom inset (in pixels)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $bottomInset = 4.8;
|
||||
|
||||
/**
|
||||
* Left inset (in pixels)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $leftInset = 9.6;
|
||||
|
||||
/**
|
||||
* Right inset (in pixels)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $rightInset = 9.6;
|
||||
|
||||
/**
|
||||
* Top inset (in pixels)
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $topInset = 4.8;
|
||||
|
||||
/**
|
||||
* Horizontal Auto Shrink
|
||||
* @var boolean
|
||||
*/
|
||||
private $autoShrinkHorizontal;
|
||||
|
||||
/**
|
||||
* Vertical Auto Shrink
|
||||
* @var boolean
|
||||
*/
|
||||
private $autoShrinkVertical;
|
||||
|
||||
/**
|
||||
* The percentage of the original font size to which the text is scaled
|
||||
* @var float
|
||||
*/
|
||||
private $fontScale;
|
||||
|
||||
/**
|
||||
* The percentage of the reduction of the line spacing
|
||||
* @var float
|
||||
*/
|
||||
private $lnSpcReduction;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->richTextParagraphs = array(
|
||||
new Paragraph()
|
||||
);
|
||||
$this->activeParagraph = 0;
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active paragraph index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getActiveParagraphIndex()
|
||||
{
|
||||
return $this->activeParagraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active paragraph
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function getActiveParagraph()
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active paragraph
|
||||
*
|
||||
* @param int $index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function setActiveParagraph($index = 0)
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new \Exception("Invalid paragraph count.");
|
||||
}
|
||||
|
||||
$this->activeParagraph = $index;
|
||||
|
||||
return $this->getActiveParagraph();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get paragraph
|
||||
*
|
||||
* @param int $index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function getParagraph($index = 0)
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new \Exception("Invalid paragraph count.");
|
||||
}
|
||||
|
||||
return $this->richTextParagraphs[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create paragraph
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createParagraph()
|
||||
{
|
||||
$numParagraphs = count($this->richTextParagraphs);
|
||||
if ($numParagraphs > 0) {
|
||||
$alignment = clone $this->getActiveParagraph()->getAlignment();
|
||||
$font = clone $this->getActiveParagraph()->getFont();
|
||||
$bulletStyle = clone $this->getActiveParagraph()->getBulletStyle();
|
||||
}
|
||||
|
||||
$this->richTextParagraphs[] = new Paragraph();
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
|
||||
if (isset($alignment)) {
|
||||
$this->getActiveParagraph()->setAlignment($alignment);
|
||||
}
|
||||
if (isset($font)) {
|
||||
$this->getActiveParagraph()->setFont($font);
|
||||
}
|
||||
if (isset($bulletStyle)) {
|
||||
$this->getActiveParagraph()->setBulletStyle($bulletStyle);
|
||||
}
|
||||
return $this->getActiveParagraph();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface $pText Rich text element
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function addText(TextElementInterface $pText = null)
|
||||
{
|
||||
$this->richTextParagraphs[$this->activeParagraph]->addText($pText);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text (can not be formatted !)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createText($pText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create break
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\BreakElement
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createBreak()
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createBreak();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text run (can be formatted)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Run
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createTextRun($pText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlainText()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop trough all \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
foreach ($this->richTextParagraphs as $p) {
|
||||
$returnValue .= $p->getPlainText();
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getPlainText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get paragraphs
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[]
|
||||
*/
|
||||
public function getParagraphs()
|
||||
{
|
||||
return $this->richTextParagraphs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set paragraphs
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] $paragraphs Array of paragraphs
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setParagraphs($paragraphs = null)
|
||||
{
|
||||
if (!is_array($paragraphs)) {
|
||||
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] array passed.");
|
||||
}
|
||||
|
||||
$this->richTextParagraphs = $paragraphs;
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text wrapping
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWrap()
|
||||
{
|
||||
return $this->wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text wrapping
|
||||
*
|
||||
* @param $value string
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setWrap($value = self::WRAP_SQUARE)
|
||||
{
|
||||
$this->wrap = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get autofit
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAutoFit()
|
||||
{
|
||||
return $this->autoFit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pourcentage of fontScale
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getFontScale()
|
||||
{
|
||||
return $this->fontScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pourcentage of the line space reduction
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getLineSpaceReduction()
|
||||
{
|
||||
return $this->lnSpcReduction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set autofit
|
||||
*
|
||||
* @param $value string
|
||||
* @param $fontScale float
|
||||
* @param $lnSpcReduction float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setAutoFit($value = self::AUTOFIT_DEFAULT, $fontScale = null, $lnSpcReduction = null)
|
||||
{
|
||||
$this->autoFit = $value;
|
||||
|
||||
if (!is_null($fontScale)) {
|
||||
$this->fontScale = $fontScale;
|
||||
}
|
||||
|
||||
if (!is_null($lnSpcReduction)) {
|
||||
$this->lnSpcReduction = $lnSpcReduction;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get horizontal overflow
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontalOverflow()
|
||||
{
|
||||
return $this->horizontalOverflow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set horizontal overflow
|
||||
*
|
||||
* @param $value string
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setHorizontalOverflow($value = self::OVERFLOW_OVERFLOW)
|
||||
{
|
||||
$this->horizontalOverflow = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertical overflow
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVerticalOverflow()
|
||||
{
|
||||
return $this->verticalOverflow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical overflow
|
||||
*
|
||||
* @param $value string
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setVerticalOverflow($value = self::OVERFLOW_OVERFLOW)
|
||||
{
|
||||
$this->verticalOverflow = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get upright
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isUpright()
|
||||
{
|
||||
return $this->upright;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical
|
||||
*
|
||||
* @param $value boolean
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setUpright($value = false)
|
||||
{
|
||||
$this->upright = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertical
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVertical()
|
||||
{
|
||||
return $this->vertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical
|
||||
*
|
||||
* @param $value boolean
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setVertical($value = false)
|
||||
{
|
||||
$this->vertical = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get columns
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set columns
|
||||
*
|
||||
* @param $value int
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setColumns($value = 1)
|
||||
{
|
||||
if ($value > 16 || $value < 1) {
|
||||
throw new \Exception('Number of columns should be 1-16');
|
||||
}
|
||||
|
||||
$this->columns = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bottom inset
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getInsetBottom()
|
||||
{
|
||||
return $this->bottomInset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bottom inset
|
||||
*
|
||||
* @param $value float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setInsetBottom($value = 4.8)
|
||||
{
|
||||
$this->bottomInset = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get left inset
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getInsetLeft()
|
||||
{
|
||||
return $this->leftInset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left inset
|
||||
*
|
||||
* @param $value float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setInsetLeft($value = 9.6)
|
||||
{
|
||||
$this->leftInset = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get right inset
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getInsetRight()
|
||||
{
|
||||
return $this->rightInset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left inset
|
||||
*
|
||||
* @param $value float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setInsetRight($value = 9.6)
|
||||
{
|
||||
$this->rightInset = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top inset
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getInsetTop()
|
||||
{
|
||||
return $this->topInset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top inset
|
||||
*
|
||||
* @param $value float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
*/
|
||||
public function setInsetTop($value = 4.8)
|
||||
{
|
||||
$this->topInset = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set horizontal auto shrink
|
||||
* @param bool $value
|
||||
* @return RichText
|
||||
*/
|
||||
public function setAutoShrinkHorizontal($value = null)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->autoShrinkHorizontal = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get horizontal auto shrink
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAutoShrinkHorizontal()
|
||||
{
|
||||
return $this->autoShrinkHorizontal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical auto shrink
|
||||
* @param bool $value
|
||||
* @return RichText
|
||||
*/
|
||||
public function setAutoShrinkVertical($value = null)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->autoShrinkVertical = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical auto shrink
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAutoShrinkVertical()
|
||||
{
|
||||
return $this->autoShrinkVertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->richTextParagraphs as $element) {
|
||||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . $this->wrap . $this->autoFit . $this->horizontalOverflow . $this->verticalOverflow . ($this->upright ? '1' : '0') . ($this->vertical ? '1' : '0') . $this->columns . $this->bottomInset . $this->leftInset . $this->rightInset . $this->topInset . parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
93
PhpOffice/PhpPresentation/Shape/RichText/BreakElement.php
Normal file
93
PhpOffice/PhpPresentation/Shape/RichText/BreakElement.php
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
/**
|
||||
* Rich text break
|
||||
*/
|
||||
class BreakElement implements TextElementInterface
|
||||
{
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\Break instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setText($pText = '')
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
* @param $lang
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setLanguage($lang)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
* @return string Language
|
||||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(__CLASS__);
|
||||
}
|
||||
}
|
||||
327
PhpOffice/PhpPresentation/Shape/RichText/Paragraph.php
Normal file
327
PhpOffice/PhpPresentation/Shape/RichText/Paragraph.php
Normal file
|
|
@ -0,0 +1,327 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Alignment;
|
||||
use PhpOffice\PhpPresentation\Style\Bullet;
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
class Paragraph implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Rich text elements
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface[]
|
||||
*/
|
||||
private $richTextElements;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
private $alignment;
|
||||
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* Bullet style
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Bullet
|
||||
*/
|
||||
private $bulletStyle;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $lineSpacing = 100;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\Paragraph instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->richTextElements = array();
|
||||
$this->alignment = new Alignment();
|
||||
$this->font = new Font();
|
||||
$this->bulletStyle = new Bullet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Alignment $alignment
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function setAlignment(Alignment $alignment)
|
||||
{
|
||||
$this->alignment = $alignment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
{
|
||||
$this->font = $pFont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bullet style
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Bullet
|
||||
*/
|
||||
public function getBulletStyle()
|
||||
{
|
||||
return $this->bulletStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bullet style
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Bullet $style
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function setBulletStyle(Bullet $style = null)
|
||||
{
|
||||
$this->bulletStyle = $style;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text (can not be formatted !)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
$objText = new TextElement($pText);
|
||||
$this->addText($objText);
|
||||
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface $pText Rich text element
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function addText(TextElementInterface $pText = null)
|
||||
{
|
||||
$this->richTextElements[] = $pText;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create break
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\BreakElement
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createBreak()
|
||||
{
|
||||
$objText = new BreakElement();
|
||||
$this->addText($objText);
|
||||
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text run (can be formatted)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Run
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
{
|
||||
$objText = new Run($pText);
|
||||
$objText->setFont(clone $this->font);
|
||||
$this->addText($objText);
|
||||
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getPlainText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlainText()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop trough all \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
foreach ($this->richTextElements as $text) {
|
||||
if ($text instanceof TextElementInterface) {
|
||||
$returnValue .= $text->getText();
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rich Text elements
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface[]
|
||||
*/
|
||||
public function getRichTextElements()
|
||||
{
|
||||
return $this->richTextElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich Text elements
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface[] $pElements Array of elements
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function setRichTextElements($pElements = null)
|
||||
{
|
||||
if (!is_array($pElements)) {
|
||||
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface[] array passed.");
|
||||
}
|
||||
$this->richTextElements = $pElements;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->richTextElements as $element) {
|
||||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . $this->font->getHashCode() . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLineSpacing()
|
||||
{
|
||||
return $this->lineSpacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $lineSpacing
|
||||
* @return Paragraph
|
||||
*/
|
||||
public function setLineSpacing($lineSpacing)
|
||||
{
|
||||
$this->lineSpacing = $lineSpacing;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
79
PhpOffice/PhpPresentation/Shape/RichText/Run.php
Normal file
79
PhpOffice/PhpPresentation/Shape/RichText/Run.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* Rich text run
|
||||
*/
|
||||
class Run extends TextElement implements TextElementInterface
|
||||
{
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\Run instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->setText($pText);
|
||||
$this->font = new Font();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
{
|
||||
$this->font = $pFont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->getText() . $this->font->getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
158
PhpOffice/PhpPresentation/Shape/RichText/TextElement.php
Normal file
158
PhpOffice/PhpPresentation/Shape/RichText/TextElement.php
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\Hyperlink;
|
||||
|
||||
/**
|
||||
* Rich text text element
|
||||
*/
|
||||
class TextElement implements TextElementInterface
|
||||
{
|
||||
/**
|
||||
* Text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $text;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* Hyperlink
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
*/
|
||||
protected $hyperlink;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\TextElement instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->text = $pText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setText($pText = '')
|
||||
{
|
||||
$this->text = $pText;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has Hyperlink?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasHyperlink()
|
||||
{
|
||||
return !is_null($this->hyperlink);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Hyperlink
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getHyperlink()
|
||||
{
|
||||
if (is_null($this->hyperlink)) {
|
||||
$this->hyperlink = new Hyperlink();
|
||||
}
|
||||
|
||||
return $this->hyperlink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Hyperlink
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Hyperlink $pHyperlink
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement
|
||||
*/
|
||||
public function setHyperlink(Hyperlink $pHyperlink = null)
|
||||
{
|
||||
$this->hyperlink = $pHyperlink;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
* @return string
|
||||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
* @param string $language
|
||||
* @return TextElement
|
||||
*/
|
||||
public function setLanguage($language)
|
||||
{
|
||||
$this->language = $language;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->text . (is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
/**
|
||||
* Rich text element interface
|
||||
*/
|
||||
interface TextElementInterface
|
||||
{
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText();
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setText($pText = '');
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function getFont();
|
||||
|
||||
/**
|
||||
* @return string Language
|
||||
*/
|
||||
public function getLanguage();
|
||||
|
||||
/**
|
||||
* @param string $lang
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setLanguage($lang);
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
}
|
||||
135
PhpOffice/PhpPresentation/Shape/Table.php
Normal file
135
PhpOffice/PhpPresentation/Shape/Table.php
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Table\Row;
|
||||
|
||||
/**
|
||||
* Table shape
|
||||
*/
|
||||
class Table extends AbstractGraphic implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Rows
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Table\Row[]
|
||||
*/
|
||||
private $rows;
|
||||
|
||||
/**
|
||||
* Number of columns
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $columnCount = 1;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Table instance
|
||||
*
|
||||
* @param int $columns Number of columns
|
||||
*/
|
||||
public function __construct($columns = 1)
|
||||
{
|
||||
// Initialise variables
|
||||
$this->rows = array();
|
||||
$this->columnCount = $columns;
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
|
||||
// No resize proportional
|
||||
$this->resizeProportional = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row
|
||||
*
|
||||
* @param int $row Row number
|
||||
* @param boolean $exceptionAsNull Return a null value instead of an exception?
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row
|
||||
*/
|
||||
public function getRow($row = 0, $exceptionAsNull = false)
|
||||
{
|
||||
if (!isset($this->rows[$row])) {
|
||||
if ($exceptionAsNull) {
|
||||
return null;
|
||||
}
|
||||
throw new \Exception('Row number out of bounds.');
|
||||
}
|
||||
|
||||
return $this->rows[$row];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row[]
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create row
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row
|
||||
*/
|
||||
public function createRow()
|
||||
{
|
||||
$row = new Row($this->columnCount);
|
||||
$this->rows[] = $row;
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNumColumns()
|
||||
{
|
||||
return $this->columnCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $numColumn
|
||||
* @return Table
|
||||
*/
|
||||
public function setNumColumns($numColumn)
|
||||
{
|
||||
$this->columnCount = $numColumn;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->rows as $row) {
|
||||
$hashElements .= $row->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . __CLASS__);
|
||||
}
|
||||
}
|
||||
443
PhpOffice/PhpPresentation/Shape/Table/Cell.php
Normal file
443
PhpOffice/PhpPresentation/Shape/Table/Cell.php
Normal file
|
|
@ -0,0 +1,443 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Table;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Borders;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
|
||||
/**
|
||||
* Table cell
|
||||
*/
|
||||
class Cell implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Rich text paragraphs
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[]
|
||||
*/
|
||||
private $richTextParagraphs;
|
||||
|
||||
/**
|
||||
* Active paragraph
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $activeParagraph = 0;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
private $fill;
|
||||
|
||||
/**
|
||||
* Borders
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Borders
|
||||
*/
|
||||
private $borders;
|
||||
|
||||
/**
|
||||
* Width (in pixels)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $width = 0;
|
||||
|
||||
/**
|
||||
* Colspan
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $colSpan = 0;
|
||||
|
||||
/**
|
||||
* Rowspan
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $rowSpan = 0;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->richTextParagraphs = array(
|
||||
new Paragraph()
|
||||
);
|
||||
$this->activeParagraph = 0;
|
||||
|
||||
// Set fill
|
||||
$this->fill = new Fill();
|
||||
|
||||
// Set borders
|
||||
$this->borders = new Borders();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active paragraph index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getActiveParagraphIndex()
|
||||
{
|
||||
return $this->activeParagraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active paragraph
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function getActiveParagraph()
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active paragraph
|
||||
*
|
||||
* @param int $index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function setActiveParagraph($index = 0)
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new \Exception("Invalid paragraph count.");
|
||||
}
|
||||
|
||||
$this->activeParagraph = $index;
|
||||
|
||||
return $this->getActiveParagraph();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get paragraph
|
||||
*
|
||||
* @param int $index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function getParagraph($index = 0)
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new \Exception("Invalid paragraph count.");
|
||||
}
|
||||
|
||||
return $this->richTextParagraphs[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create paragraph
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createParagraph()
|
||||
{
|
||||
$this->richTextParagraphs[] = new Paragraph();
|
||||
$totalRichTextParagraphs = count($this->richTextParagraphs);
|
||||
$this->activeParagraph = $totalRichTextParagraphs - 1;
|
||||
|
||||
if ($totalRichTextParagraphs > 1) {
|
||||
$alignment = clone $this->getActiveParagraph()->getAlignment();
|
||||
$font = clone $this->getActiveParagraph()->getFont();
|
||||
$bulletStyle = clone $this->getActiveParagraph()->getBulletStyle();
|
||||
|
||||
$this->getActiveParagraph()->setAlignment($alignment);
|
||||
$this->getActiveParagraph()->setFont($font);
|
||||
$this->getActiveParagraph()->setBulletStyle($bulletStyle);
|
||||
}
|
||||
return $this->getActiveParagraph();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface $pText Rich text element
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function addText(TextElementInterface $pText = null)
|
||||
{
|
||||
$this->richTextParagraphs[$this->activeParagraph]->addText($pText);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text (can not be formatted !)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createText($pText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create break
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\BreakElement
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createBreak()
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createBreak();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text run (can be formatted)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Run
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createTextRun($pText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlainText()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop trough all \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
foreach ($this->richTextParagraphs as $p) {
|
||||
$returnValue .= $p->getPlainText();
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getPlainText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get paragraphs
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[]
|
||||
*/
|
||||
public function getParagraphs()
|
||||
{
|
||||
return $this->richTextParagraphs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set paragraphs
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] $paragraphs Array of paragraphs
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setParagraphs($paragraphs = null)
|
||||
{
|
||||
if (!is_array($paragraphs)) {
|
||||
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] array passed.");
|
||||
}
|
||||
$this->richTextParagraphs = $paragraphs;
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fill
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function getFill()
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fill
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $fill
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setFill(Fill $fill)
|
||||
{
|
||||
$this->fill = $fill;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get borders
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Borders
|
||||
*/
|
||||
public function getBorders()
|
||||
{
|
||||
return $this->borders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set borders
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Borders $borders
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setBorders(Borders $borders)
|
||||
{
|
||||
$this->borders = $borders;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set width
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setWidth($value = 0)
|
||||
{
|
||||
$this->width = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colSpan
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColSpan()
|
||||
{
|
||||
return $this->colSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colSpan
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setColSpan($value = 0)
|
||||
{
|
||||
$this->colSpan = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rowSpan
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRowSpan()
|
||||
{
|
||||
return $this->rowSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set rowSpan
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setRowSpan($value = 0)
|
||||
{
|
||||
$this->rowSpan = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->richTextParagraphs as $element) {
|
||||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . $this->fill->getHashCode() . $this->borders->getHashCode() . $this->width . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
212
PhpOffice/PhpPresentation/Shape/Table/Row.php
Normal file
212
PhpOffice/PhpPresentation/Shape/Table/Row.php
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Table;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
|
||||
/**
|
||||
* Table row
|
||||
*/
|
||||
class Row implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Cells
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Table\Cell[]
|
||||
*/
|
||||
private $cells;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
private $fill;
|
||||
|
||||
/**
|
||||
* Height (in pixels)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $height = 38;
|
||||
|
||||
/**
|
||||
* Active cell index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $activeCellIndex = -1;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Table\Row instance
|
||||
*
|
||||
* @param int $columns Number of columns
|
||||
*/
|
||||
public function __construct($columns = 1)
|
||||
{
|
||||
// Initialise variables
|
||||
$this->cells = array();
|
||||
for ($i = 0; $i < $columns; $i++) {
|
||||
$this->cells[] = new Cell();
|
||||
}
|
||||
|
||||
// Set fill
|
||||
$this->fill = new Fill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell
|
||||
*
|
||||
* @param int $cell Cell number
|
||||
* @param boolean $exceptionAsNull Return a null value instead of an exception?
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function getCell($cell = 0, $exceptionAsNull = false)
|
||||
{
|
||||
if (!isset($this->cells[$cell])) {
|
||||
if ($exceptionAsNull) {
|
||||
return null;
|
||||
}
|
||||
throw new \Exception('Cell number out of bounds.');
|
||||
}
|
||||
|
||||
return $this->cells[$cell];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cells
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell[]
|
||||
*/
|
||||
public function getCells()
|
||||
{
|
||||
return $this->cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next cell (moves one cell to the right)
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function nextCell()
|
||||
{
|
||||
$this->activeCellIndex++;
|
||||
if (isset($this->cells[$this->activeCellIndex])) {
|
||||
$this->cells[$this->activeCellIndex]->setFill(clone $this->getFill());
|
||||
return $this->cells[$this->activeCellIndex];
|
||||
}
|
||||
throw new \Exception("Cell count out of bounds.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fill
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function getFill()
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fill
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $fill
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row
|
||||
*/
|
||||
public function setFill(Fill $fill)
|
||||
{
|
||||
$this->fill = $fill;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set height
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row
|
||||
*/
|
||||
public function setHeight($value = 0)
|
||||
{
|
||||
$this->height = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->cells as $cell) {
|
||||
$hashElements .= $cell->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . $this->fill->getHashCode() . $this->height . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
67
PhpOffice/PhpPresentation/ShapeContainerInterface.php
Normal file
67
PhpOffice/PhpPresentation/ShapeContainerInterface.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
*/
|
||||
interface ShapeContainerInterface
|
||||
{
|
||||
/**
|
||||
* Get collection of shapes
|
||||
*
|
||||
* @return \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[]
|
||||
*/
|
||||
public function getShapeCollection();
|
||||
|
||||
/**
|
||||
* Add shape to slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\AbstractShape $shape
|
||||
* @return \PhpOffice\PhpPresentation\AbstractShape
|
||||
*/
|
||||
public function addShape(AbstractShape $shape);
|
||||
|
||||
/**
|
||||
* Get X Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetX();
|
||||
|
||||
/**
|
||||
* Get Y Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetY();
|
||||
|
||||
/**
|
||||
* Get X Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentX();
|
||||
|
||||
/**
|
||||
* Get Y Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentY();
|
||||
}
|
||||
246
PhpOffice/PhpPresentation/Slide.php
Normal file
246
PhpOffice/PhpPresentation/Slide.php
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\Chart;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText;
|
||||
use PhpOffice\PhpPresentation\Shape\Table;
|
||||
use PhpOffice\PhpPresentation\Slide\AbstractSlide;
|
||||
use PhpOffice\PhpPresentation\Slide\Note;
|
||||
use PhpOffice\PhpPresentation\Slide\SlideLayout;
|
||||
|
||||
/**
|
||||
* Slide class
|
||||
*/
|
||||
class Slide extends AbstractSlide implements ComparableInterface, ShapeContainerInterface
|
||||
{
|
||||
/**
|
||||
* The slide is shown in presentation
|
||||
* @var bool
|
||||
*/
|
||||
protected $isVisible = true;
|
||||
|
||||
/**
|
||||
* Slide layout
|
||||
*
|
||||
* @var SlideLayout
|
||||
*/
|
||||
private $slideLayout;
|
||||
|
||||
/**
|
||||
* Slide master id
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $slideMasterId = 1;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Slide\Note
|
||||
*/
|
||||
private $slideNote;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Slide\Animation[]
|
||||
*/
|
||||
protected $animations = array();
|
||||
|
||||
/**
|
||||
* Name of the title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Create a new slide
|
||||
*
|
||||
* @param PhpPresentation $pParent
|
||||
*/
|
||||
public function __construct(PhpPresentation $pParent = null)
|
||||
{
|
||||
// Set parent
|
||||
$this->parent = $pParent;
|
||||
// Shape collection
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
// Set identifier
|
||||
$this->identifier = md5(rand(0, 9999) . time());
|
||||
// Set Slide Layout
|
||||
if ($this->parent instanceof PhpPresentation) {
|
||||
$arrayMasterSlides = $this->parent->getAllMasterSlides();
|
||||
$oMasterSlide = reset($arrayMasterSlides);
|
||||
$arraySlideLayouts = $oMasterSlide->getAllSlideLayouts();
|
||||
$oSlideLayout = reset($arraySlideLayouts);
|
||||
$this->setSlideLayout($oSlideLayout);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide layout
|
||||
*
|
||||
* @return SlideLayout
|
||||
*/
|
||||
public function getSlideLayout()
|
||||
{
|
||||
return $this->slideLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide layout
|
||||
*
|
||||
* @param SlideLayout $layout
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function setSlideLayout(SlideLayout $layout)
|
||||
{
|
||||
$this->slideLayout = $layout;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide master id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSlideMasterId()
|
||||
{
|
||||
return $this->slideMasterId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide master id
|
||||
*
|
||||
* @param int $masterId
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function setSlideMasterId($masterId = 1)
|
||||
{
|
||||
$this->slideMasterId = $masterId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy slide (!= clone!)
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function copy()
|
||||
{
|
||||
$copied = clone $this;
|
||||
|
||||
return $copied;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\Note
|
||||
*/
|
||||
public function getNote()
|
||||
{
|
||||
if (is_null($this->slideNote)) {
|
||||
$this->setNote();
|
||||
}
|
||||
return $this->slideNote;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\Note $note
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function setNote(Note $note = null)
|
||||
{
|
||||
$this->slideNote = (is_null($note) ? new Note() : $note);
|
||||
$this->slideNote->setParent($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the slide
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the slide
|
||||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->isVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $value
|
||||
* @return Slide
|
||||
*/
|
||||
public function setIsVisible($value = true)
|
||||
{
|
||||
$this->isVisible = (bool)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an animation to the slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\Animation
|
||||
* @return Slide
|
||||
*/
|
||||
public function addAnimation($animation)
|
||||
{
|
||||
$this->animations[] = $animation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of animations
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\Animation[]
|
||||
*/
|
||||
public function getAnimations()
|
||||
{
|
||||
return $this->animations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set collection of animations
|
||||
* @param \PhpOffice\PhpPresentation\Slide\Animation[] $array
|
||||
* @return Slide
|
||||
*/
|
||||
public function setAnimations(array $array = array())
|
||||
{
|
||||
$this->animations = $array;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
8
PhpOffice/PhpPresentation/Slide/AbstractBackground.php
Normal file
8
PhpOffice/PhpPresentation/Slide/AbstractBackground.php
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
class AbstractBackground
|
||||
{
|
||||
|
||||
}
|
||||
390
PhpOffice/PhpPresentation/Slide/AbstractSlide.php
Normal file
390
PhpOffice/PhpPresentation/Slide/AbstractSlide.php
Normal file
|
|
@ -0,0 +1,390 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
namespace PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\GeometryCalculator;
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\File;
|
||||
use PhpOffice\PhpPresentation\Shape\Group;
|
||||
use PhpOffice\PhpPresentation\Shape\Line;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText;
|
||||
use PhpOffice\PhpPresentation\Shape\Table;
|
||||
use PhpOffice\PhpPresentation\ShapeContainerInterface;
|
||||
use PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
abstract class AbstractSlide implements ComparableInterface, ShapeContainerInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $relsIndex;
|
||||
/**
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Slide\Transition
|
||||
*/
|
||||
protected $slideTransition;
|
||||
|
||||
/**
|
||||
* Collection of shapes
|
||||
*
|
||||
* @var \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[]
|
||||
*/
|
||||
protected $shapeCollection = null;
|
||||
/**
|
||||
* Extent Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $extentY;
|
||||
/**
|
||||
* Extent X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $extentX;
|
||||
/**
|
||||
* Offset X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offsetX;
|
||||
/**
|
||||
* Offset Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offsetY;
|
||||
/**
|
||||
* Slide identifier
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $identifier;
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $hashIndex;
|
||||
/**
|
||||
* Parent presentation
|
||||
*
|
||||
* @var PhpPresentation
|
||||
*/
|
||||
protected $parent;
|
||||
/**
|
||||
* Background of the slide
|
||||
*
|
||||
* @var AbstractBackground
|
||||
*/
|
||||
protected $background;
|
||||
|
||||
/**
|
||||
* Get collection of shapes
|
||||
*
|
||||
* @return \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[]
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
return $this->shapeCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of shapes
|
||||
*
|
||||
* @param array $shapeCollection
|
||||
* @return AbstractSlide
|
||||
*/
|
||||
public function setShapeCollection($shapeCollection = array())
|
||||
{
|
||||
$this->shapeCollection = $shapeCollection;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shape to slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\AbstractShape $shape
|
||||
* @return \PhpOffice\PhpPresentation\AbstractShape
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addShape(AbstractShape $shape)
|
||||
{
|
||||
$shape->setContainer($this);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetX()
|
||||
{
|
||||
if ($this->offsetX === null) {
|
||||
$offsets = GeometryCalculator::calculateOffsets($this);
|
||||
$this->offsetX = $offsets[GeometryCalculator::X];
|
||||
$this->offsetY = $offsets[GeometryCalculator::Y];
|
||||
}
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetY()
|
||||
{
|
||||
if ($this->offsetY === null) {
|
||||
$offsets = GeometryCalculator::calculateOffsets($this);
|
||||
$this->offsetX = $offsets[GeometryCalculator::X];
|
||||
$this->offsetY = $offsets[GeometryCalculator::Y];
|
||||
}
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentX()
|
||||
{
|
||||
if ($this->extentX === null) {
|
||||
$extents = GeometryCalculator::calculateExtents($this);
|
||||
$this->extentX = $extents[GeometryCalculator::X];
|
||||
$this->extentY = $extents[GeometryCalculator::Y];
|
||||
}
|
||||
return $this->extentX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentY()
|
||||
{
|
||||
if ($this->extentY === null) {
|
||||
$extents = GeometryCalculator::calculateExtents($this);
|
||||
$this->extentX = $extents[GeometryCalculator::X];
|
||||
$this->extentY = $extents[GeometryCalculator::Y];
|
||||
}
|
||||
return $this->extentY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->identifier . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create rich text shape
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createRichTextShape()
|
||||
{
|
||||
$shape = new RichText();
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create line shape
|
||||
*
|
||||
* @param int $fromX Starting point x offset
|
||||
* @param int $fromY Starting point y offset
|
||||
* @param int $toX Ending point x offset
|
||||
* @param int $toY Ending point y offset
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Line
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createLineShape($fromX, $fromY, $toX, $toY)
|
||||
{
|
||||
$shape = new Line($fromX, $fromY, $toX, $toY);
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create chart shape
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createChartShape()
|
||||
{
|
||||
$shape = new Chart();
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create drawing shape
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Drawing\File
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createDrawingShape()
|
||||
{
|
||||
$shape = new File();
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create table shape
|
||||
*
|
||||
* @param int $columns Number of columns
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createTableShape($columns = 1)
|
||||
{
|
||||
$shape = new Table($columns);
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a group within this slide
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Group
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createGroup()
|
||||
{
|
||||
$shape = new Group();
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent
|
||||
*
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-bind parent
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\PhpPresentation $parent
|
||||
* @return \PhpOffice\PhpPresentation\Slide\AbstractSlide
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function rebindParent(PhpPresentation $parent)
|
||||
{
|
||||
$this->parent->removeSlideByIndex($this->parent->getIndex($this));
|
||||
$this->parent = $parent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractBackground
|
||||
*/
|
||||
public function getBackground()
|
||||
{
|
||||
return $this->background;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractBackground $background
|
||||
* @return \PhpOffice\PhpPresentation\Slide\AbstractSlide
|
||||
*/
|
||||
public function setBackground(AbstractBackground $background = null)
|
||||
{
|
||||
$this->background = $background;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\Transition
|
||||
*/
|
||||
public function getTransition()
|
||||
{
|
||||
return $this->slideTransition;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\Transition $transition
|
||||
* @return \PhpOffice\PhpPresentation\Slide\AbstractSlide
|
||||
*/
|
||||
public function setTransition(Transition $transition = null)
|
||||
{
|
||||
$this->slideTransition = $transition;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRelsIndex()
|
||||
{
|
||||
return $this->relsIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $indexName
|
||||
*/
|
||||
public function setRelsIndex($indexName)
|
||||
{
|
||||
$this->relsIndex = $indexName;
|
||||
}
|
||||
}
|
||||
40
PhpOffice/PhpPresentation/Slide/Animation.php
Normal file
40
PhpOffice/PhpPresentation/Slide/Animation.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
namespace PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
|
||||
class Animation
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $shapeCollection = array();
|
||||
|
||||
/**
|
||||
* @param AbstractShape $shape
|
||||
* @return Animation
|
||||
*/
|
||||
public function addShape(AbstractShape $shape)
|
||||
{
|
||||
$this->shapeCollection[] = $shape;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
return $this->shapeCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @return Animation
|
||||
*/
|
||||
public function setShapeCollection(array $array = array())
|
||||
{
|
||||
$this->shapeCollection = $array;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
32
PhpOffice/PhpPresentation/Slide/Background/Color.php
Normal file
32
PhpOffice/PhpPresentation/Slide/Background/Color.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Slide\Background;
|
||||
|
||||
use PhpOffice\PhpPresentation\Slide\AbstractBackground;
|
||||
use PhpOffice\PhpPresentation\Style\Color as StyleColor;
|
||||
|
||||
class Color extends AbstractBackground
|
||||
{
|
||||
/**
|
||||
* @var StyleColor
|
||||
*/
|
||||
protected $color;
|
||||
|
||||
/**
|
||||
* @param StyleColor|null $color
|
||||
* @return $this
|
||||
*/
|
||||
public function setColor(StyleColor $color = null)
|
||||
{
|
||||
$this->color = $color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StyleColor
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
}
|
||||
97
PhpOffice/PhpPresentation/Slide/Background/Image.php
Normal file
97
PhpOffice/PhpPresentation/Slide/Background/Image.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Slide\Background;
|
||||
|
||||
use PhpOffice\PhpPresentation\Slide\AbstractBackground;
|
||||
|
||||
class Image extends AbstractBackground
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $relationId;
|
||||
|
||||
/**
|
||||
* Path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $height;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $width;
|
||||
|
||||
/**
|
||||
* Get Path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Path
|
||||
*
|
||||
* @param string $pValue File path
|
||||
* @param boolean $pVerifyFile Verify file
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Slide\Background\Image
|
||||
*/
|
||||
public function setPath($pValue = '', $pVerifyFile = true)
|
||||
{
|
||||
if ($pVerifyFile) {
|
||||
if (!file_exists($pValue)) {
|
||||
throw new \Exception("File not found : $pValue");
|
||||
}
|
||||
|
||||
if ($this->width == 0 && $this->height == 0) {
|
||||
// Get width/height
|
||||
list($this->width, $this->height) = getimagesize($pValue);
|
||||
}
|
||||
}
|
||||
$this->path = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename()
|
||||
{
|
||||
return basename($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
$exploded = explode('.', basename($this->path));
|
||||
|
||||
return $exploded[count($exploded) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indexed filename (using image index)
|
||||
*
|
||||
* @param integer $numSlide
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename($numSlide)
|
||||
{
|
||||
return 'background_' . $numSlide . '.' . $this->getExtension();
|
||||
}
|
||||
}
|
||||
32
PhpOffice/PhpPresentation/Slide/Background/SchemeColor.php
Normal file
32
PhpOffice/PhpPresentation/Slide/Background/SchemeColor.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Slide\Background;
|
||||
|
||||
use PhpOffice\PhpPresentation\Slide\AbstractBackground;
|
||||
use PhpOffice\PhpPresentation\Style\SchemeColor as StyleSchemeColor;
|
||||
|
||||
class SchemeColor extends AbstractBackground
|
||||
{
|
||||
/**
|
||||
* @var StyleSchemeColor
|
||||
*/
|
||||
protected $schemeColor;
|
||||
|
||||
/**
|
||||
* @param StyleSchemeColor|null $color
|
||||
* @return $this
|
||||
*/
|
||||
public function setSchemeColor(StyleSchemeColor $color = null)
|
||||
{
|
||||
$this->schemeColor = $color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StyleSchemeColor
|
||||
*/
|
||||
public function getSchemeColor()
|
||||
{
|
||||
return $this->schemeColor;
|
||||
}
|
||||
}
|
||||
108
PhpOffice/PhpPresentation/Slide/Iterator.php
Normal file
108
PhpOffice/PhpPresentation/Slide/Iterator.php
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Slide\Iterator
|
||||
*
|
||||
* Used to iterate slides in PhpPresentation
|
||||
*/
|
||||
class Iterator extends \IteratorIterator
|
||||
{
|
||||
/**
|
||||
* Presentation to iterate
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\PhpPresentation
|
||||
*/
|
||||
private $subject;
|
||||
|
||||
/**
|
||||
* Current iterator position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $position = 0;
|
||||
|
||||
/**
|
||||
* Create a new slide iterator
|
||||
*
|
||||
* @param PhpPresentation $subject
|
||||
*/
|
||||
public function __construct(PhpPresentation $subject = null)
|
||||
{
|
||||
// Set subject
|
||||
$this->subject = $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
unset($this->subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind iterator
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current \PhpOffice\PhpPresentation\Slide
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return $this->subject->getSlide($this->position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current key
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next value
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
++$this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* More \PhpOffice\PhpPresentation\Slide instances available?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return $this->position < $this->subject->getSlideCount();
|
||||
}
|
||||
}
|
||||
37
PhpOffice/PhpPresentation/Slide/Layout.php
Normal file
37
PhpOffice/PhpPresentation/Slide/Layout.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Slide\Layout
|
||||
*/
|
||||
class Layout
|
||||
{
|
||||
/** Layout constants */
|
||||
const TITLE_SLIDE = 'Title Slide';
|
||||
const TITLE_AND_CONTENT = 'Title and Content';
|
||||
const SECTION_HEADER = 'Section Header';
|
||||
const TWO_CONTENT = 'Two Content';
|
||||
const COMPARISON = 'Comparison';
|
||||
const TITLE_ONLY = 'Title Only';
|
||||
const BLANK = 'Blank';
|
||||
const CONTENT_WITH_CAPTION = 'Content with Caption';
|
||||
const PICTURE_WITH_CAPTION = 'Picture with Caption';
|
||||
const TITLE_AND_VERTICAL_TEXT = 'Title and Vertical Text';
|
||||
const VERTICAL_TITLE_AND_TEXT = 'Vertical Title and Text';
|
||||
}
|
||||
261
PhpOffice/PhpPresentation/Slide/Note.php
Normal file
261
PhpOffice/PhpPresentation/Slide/Note.php
Normal file
|
|
@ -0,0 +1,261 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\GeometryCalculator;
|
||||
use PhpOffice\PhpPresentation\ShapeContainerInterface;
|
||||
use PhpOffice\PhpPresentation\Slide;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
/**
|
||||
* Note class
|
||||
*/
|
||||
class Note implements ComparableInterface, ShapeContainerInterface
|
||||
{
|
||||
/**
|
||||
* Parent slide
|
||||
*
|
||||
* @var Slide
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* Collection of shapes
|
||||
*
|
||||
* @var \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[]
|
||||
*/
|
||||
private $shapeCollection = null;
|
||||
|
||||
/**
|
||||
* Note identifier
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $identifier;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Offset X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offsetX;
|
||||
|
||||
/**
|
||||
* Offset Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offsetY;
|
||||
|
||||
/**
|
||||
* Extent X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $extentX;
|
||||
|
||||
/**
|
||||
* Extent Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $extentY;
|
||||
|
||||
/**
|
||||
* Create a new note
|
||||
*
|
||||
* @param Slide $pParent
|
||||
*/
|
||||
public function __construct(Slide $pParent = null)
|
||||
{
|
||||
// Set parent
|
||||
$this->parent = $pParent;
|
||||
|
||||
// Shape collection
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
|
||||
// Set identifier
|
||||
$this->identifier = md5(rand(0, 9999) . time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of shapes
|
||||
*
|
||||
* @return \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[]
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
return $this->shapeCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shape to slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\AbstractShape $shape
|
||||
* @return \PhpOffice\PhpPresentation\AbstractShape
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addShape(AbstractShape $shape)
|
||||
{
|
||||
$shape->setContainer($this);
|
||||
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create rich text shape
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createRichTextShape()
|
||||
{
|
||||
$shape = new RichText();
|
||||
$this->addShape($shape);
|
||||
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent
|
||||
*
|
||||
* @return Slide
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent
|
||||
*
|
||||
* @param Slide $parent
|
||||
* @return Note
|
||||
*/
|
||||
public function setParent(Slide $parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get X Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetX()
|
||||
{
|
||||
if ($this->offsetX === null) {
|
||||
$offsets = GeometryCalculator::calculateOffsets($this);
|
||||
$this->offsetX = $offsets[GeometryCalculator::X];
|
||||
$this->offsetY = $offsets[GeometryCalculator::Y];
|
||||
}
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetY()
|
||||
{
|
||||
if ($this->offsetY === null) {
|
||||
$offsets = GeometryCalculator::calculateOffsets($this);
|
||||
$this->offsetX = $offsets[GeometryCalculator::X];
|
||||
$this->offsetY = $offsets[GeometryCalculator::Y];
|
||||
}
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentX()
|
||||
{
|
||||
if ($this->extentX === null) {
|
||||
$extents = GeometryCalculator::calculateExtents($this);
|
||||
$this->extentX = $extents[GeometryCalculator::X];
|
||||
$this->extentY = $extents[GeometryCalculator::Y];
|
||||
}
|
||||
return $this->extentX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentY()
|
||||
{
|
||||
if ($this->extentY === null) {
|
||||
$extents = GeometryCalculator::calculateExtents($this);
|
||||
$this->extentX = $extents[GeometryCalculator::X];
|
||||
$this->extentY = $extents[GeometryCalculator::Y];
|
||||
}
|
||||
return $this->extentY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->identifier . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
99
PhpOffice/PhpPresentation/Slide/SlideLayout.php
Normal file
99
PhpOffice/PhpPresentation/Slide/SlideLayout.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
namespace PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\ShapeContainerInterface;
|
||||
use PhpOffice\PhpPresentation\Style\ColorMap;
|
||||
|
||||
class SlideLayout extends AbstractSlide implements ComparableInterface, ShapeContainerInterface
|
||||
{
|
||||
protected $slideMaster;
|
||||
/**
|
||||
* Slide relation ID (should not be used by user code!)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $relationId;
|
||||
/**
|
||||
* Slide layout NR (should not be used by user code!)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $layoutNr;
|
||||
/**
|
||||
* Slide layout ID (should not be used by user code!)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $layoutId;
|
||||
/**
|
||||
* Slide layout ID (should not be used by user code!)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $layoutName;
|
||||
/**
|
||||
* Mapping of colors to the theme
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\ColorMap
|
||||
*/
|
||||
public $colorMap;
|
||||
|
||||
/**
|
||||
* Create a new slideLayout
|
||||
*
|
||||
* @param SlideMaster $pSlideMaster
|
||||
*/
|
||||
public function __construct(SlideMaster $pSlideMaster)
|
||||
{
|
||||
// Set parent
|
||||
$this->slideMaster = $pSlideMaster;
|
||||
// Shape collection
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
// Set identifier
|
||||
$this->identifier = md5(rand(0, 9999) . time());
|
||||
// Set a basic colorMap
|
||||
$this->colorMap = new ColorMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLayoutName()
|
||||
{
|
||||
return $this->layoutName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $layoutName
|
||||
* @return SlideLayout
|
||||
*/
|
||||
public function setLayoutName($layoutName)
|
||||
{
|
||||
$this->layoutName = $layoutName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SlideMaster
|
||||
*/
|
||||
public function getSlideMaster()
|
||||
{
|
||||
return $this->slideMaster;
|
||||
}
|
||||
}
|
||||
170
PhpOffice/PhpPresentation/Slide/SlideMaster.php
Normal file
170
PhpOffice/PhpPresentation/Slide/SlideMaster.php
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
namespace PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
use PhpOffice\PhpPresentation\ShapeContainerInterface;
|
||||
use PhpOffice\PhpPresentation\Slide\Background\Color as BackgroundColor;
|
||||
use PhpOffice\PhpPresentation\Style\Color;
|
||||
use PhpOffice\PhpPresentation\Style\ColorMap;
|
||||
use PhpOffice\PhpPresentation\Style\SchemeColor;
|
||||
use PhpOffice\PhpPresentation\Style\TextStyle;
|
||||
|
||||
/**
|
||||
* Class SlideMaster
|
||||
*/
|
||||
class SlideMaster extends AbstractSlide implements ComparableInterface, ShapeContainerInterface
|
||||
{
|
||||
/**
|
||||
* Collection of Slide objects
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Slide\SlideLayout[]
|
||||
*/
|
||||
protected $slideLayouts = array();
|
||||
/**
|
||||
* Mapping of colors to the theme
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\ColorMap
|
||||
*/
|
||||
public $colorMap;
|
||||
/**
|
||||
* @var \PhpOffice\PhpPresentation\Style\TextStyle
|
||||
*/
|
||||
protected $textStyles;
|
||||
/**
|
||||
* @var \PhpOffice\PhpPresentation\Style\SchemeColor[]
|
||||
*/
|
||||
protected $arraySchemeColor = array();
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultSchemeColor = array(
|
||||
'dk1' => '000000',
|
||||
'lt1' => 'FFFFFF',
|
||||
'dk2' => '1F497D',
|
||||
'lt2' => 'EEECE1',
|
||||
'accent1' => '4F81BD',
|
||||
'accent2' => 'C0504D',
|
||||
'accent3' => '9BBB59',
|
||||
'accent4' => '8064A2',
|
||||
'accent5' => '4BACC6',
|
||||
'accent6' => 'F79646',
|
||||
'hlink' => '0000FF',
|
||||
'folHlink' => '800080',
|
||||
);
|
||||
|
||||
/**
|
||||
* Create a new slideMaster
|
||||
*
|
||||
* @param PhpPresentation $pParent
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(PhpPresentation $pParent = null)
|
||||
{
|
||||
// Set parent
|
||||
$this->parent = $pParent;
|
||||
// Shape collection
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
// Set identifier
|
||||
$this->identifier = md5(rand(0, 9999) . time());
|
||||
// Set a basic colorMap
|
||||
$this->colorMap = new ColorMap();
|
||||
// Set a white background
|
||||
$this->background = new BackgroundColor();
|
||||
$this->background->setColor(new Color(Color::COLOR_WHITE));
|
||||
// Set basic textStyles
|
||||
$this->textStyles = new TextStyle(true);
|
||||
// Set basic scheme colors
|
||||
foreach ($this->defaultSchemeColor as $key => $value) {
|
||||
$oSchemeColor = new SchemeColor();
|
||||
$oSchemeColor->setValue($key);
|
||||
$oSchemeColor->setRGB($value);
|
||||
$this->addSchemeColor($oSchemeColor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a slideLayout and add it to this presentation
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\SlideLayout
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createSlideLayout()
|
||||
{
|
||||
$newSlideLayout = new SlideLayout($this);
|
||||
$this->addSlideLayout($newSlideLayout);
|
||||
return $newSlideLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add slideLayout
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\SlideLayout $slideLayout
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Slide\SlideLayout
|
||||
*/
|
||||
public function addSlideLayout(SlideLayout $slideLayout = null)
|
||||
{
|
||||
$this->slideLayouts[] = $slideLayout;
|
||||
return $slideLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SlideLayout[]
|
||||
*/
|
||||
public function getAllSlideLayouts()
|
||||
{
|
||||
return $this->slideLayouts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TextStyle
|
||||
*/
|
||||
public function getTextStyles()
|
||||
{
|
||||
return $this->textStyles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TextStyle $textStyle
|
||||
* @return $this
|
||||
*/
|
||||
public function setTextStyles(TextStyle $textStyle)
|
||||
{
|
||||
$this->textStyles = $textStyle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SchemeColor $schemeColor
|
||||
* @return $this
|
||||
*/
|
||||
public function addSchemeColor(SchemeColor $schemeColor)
|
||||
{
|
||||
$this->arraySchemeColor[$schemeColor->getValue()] = $schemeColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PhpOffice\PhpPresentation\Style\SchemeColor[]
|
||||
*/
|
||||
public function getAllSchemeColors()
|
||||
{
|
||||
return $this->arraySchemeColor;
|
||||
}
|
||||
}
|
||||
166
PhpOffice/PhpPresentation/Slide/Transition.php
Normal file
166
PhpOffice/PhpPresentation/Slide/Transition.php
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Slide;
|
||||
|
||||
use PhpOffice\PhpPresentation\Slide;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
/**
|
||||
* Transition class
|
||||
*/
|
||||
class Transition
|
||||
{
|
||||
const SPEED_FAST = 'fast';
|
||||
const SPEED_MEDIUM = 'med';
|
||||
const SPEED_SLOW = 'slow';
|
||||
|
||||
const TRANSITION_BLINDS_HORIZONTAL = 'blinds_horz';
|
||||
const TRANSITION_BLINDS_VERTICAL = 'blinds_vert';
|
||||
const TRANSITION_CHECKER_HORIZONTAL = 'checker_horz';
|
||||
const TRANSITION_CHECKER_VERTICAL = 'checker_vert';
|
||||
const TRANSITION_CIRCLE = 'circle';
|
||||
const TRANSITION_COMB_HORIZONTAL = 'comb_horz';
|
||||
const TRANSITION_COMB_VERTICAL = 'comb_vert';
|
||||
const TRANSITION_COVER_DOWN = 'cover_d';
|
||||
const TRANSITION_COVER_LEFT = 'cover_l';
|
||||
const TRANSITION_COVER_LEFT_DOWN = 'cover_ld';
|
||||
const TRANSITION_COVER_LEFT_UP = 'cover_lu';
|
||||
const TRANSITION_COVER_RIGHT = 'cover_r';
|
||||
const TRANSITION_COVER_RIGHT_DOWN = 'cover_rd';
|
||||
const TRANSITION_COVER_RIGHT_UP = 'cover_ru';
|
||||
const TRANSITION_COVER_UP = 'cover_u';
|
||||
const TRANSITION_CUT = 'cut';
|
||||
const TRANSITION_DIAMOND = 'diamond';
|
||||
const TRANSITION_DISSOLVE = 'dissolve';
|
||||
const TRANSITION_FADE = 'fade';
|
||||
const TRANSITION_NEWSFLASH = 'newsflash';
|
||||
const TRANSITION_PLUS = 'plus';
|
||||
const TRANSITION_PULL_DOWN = 'pull_d';
|
||||
const TRANSITION_PULL_LEFT = 'pull_l';
|
||||
const TRANSITION_PULL_RIGHT = 'pull_r';
|
||||
const TRANSITION_PULL_UP = 'pull_u';
|
||||
const TRANSITION_PUSH_DOWN = 'push_d';
|
||||
const TRANSITION_PUSH_LEFT = 'push_l';
|
||||
const TRANSITION_PUSH_RIGHT = 'push_r';
|
||||
const TRANSITION_PUSH_UP = 'push_u';
|
||||
const TRANSITION_RANDOM = 'random';
|
||||
const TRANSITION_RANDOMBAR_HORIZONTAL = 'randomBar_horz';
|
||||
const TRANSITION_RANDOMBAR_VERTICAL = 'randomBar_vert';
|
||||
const TRANSITION_SPLIT_IN_HORIZONTAL = 'split_in_horz';
|
||||
const TRANSITION_SPLIT_OUT_HORIZONTAL = 'split_out_horz';
|
||||
const TRANSITION_SPLIT_IN_VERTICAL = 'split_in_vert';
|
||||
const TRANSITION_SPLIT_OUT_VERTICAL = 'split_out_vert';
|
||||
const TRANSITION_STRIPS_LEFT_DOWN = 'strips_ld';
|
||||
const TRANSITION_STRIPS_LEFT_UP = 'strips_lu';
|
||||
const TRANSITION_STRIPS_RIGHT_DOWN = 'strips_rd';
|
||||
const TRANSITION_STRIPS_RIGHT_UP = 'strips_ru';
|
||||
const TRANSITION_WEDGE = 'wedge';
|
||||
const TRANSITION_WIPE_DOWN = 'wipe_d';
|
||||
const TRANSITION_WIPE_LEFT = 'wipe_l';
|
||||
const TRANSITION_WIPE_RIGHT = 'wipe_r';
|
||||
const TRANSITION_WIPE_UP = 'wipe_u';
|
||||
const TRANSITION_ZOOM_IN = 'zoom_in';
|
||||
const TRANSITION_ZOOM_OUT = 'zoom_out';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $hasManualTrigger = false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $hasTimeTrigger = false;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $advanceTimeTrigger = null;
|
||||
/**
|
||||
* @var null|self::SPEED_SLOW|self::SPEED_MEDIUM|self::SPEED_FAST
|
||||
*/
|
||||
protected $speed = null;
|
||||
/**
|
||||
* @var null|self::TRANSITION_*
|
||||
*/
|
||||
protected $transitionType = null;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $transitionOptions = array();
|
||||
|
||||
public function setSpeed($speed = self::SPEED_MEDIUM)
|
||||
{
|
||||
if (in_array($speed, array(self::SPEED_FAST, self::SPEED_MEDIUM, self::SPEED_SLOW))) {
|
||||
$this->speed = $speed;
|
||||
} else {
|
||||
$this->speed = null;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSpeed()
|
||||
{
|
||||
return $this->speed;
|
||||
}
|
||||
|
||||
public function setManualTrigger($value = false)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->hasManualTrigger = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasManualTrigger()
|
||||
{
|
||||
return $this->hasManualTrigger;
|
||||
}
|
||||
|
||||
public function setTimeTrigger($value = false, $advanceTime = 1000)
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->hasTimeTrigger = $value;
|
||||
}
|
||||
$this->advanceTimeTrigger = null;
|
||||
if ($this->hasTimeTrigger === true) {
|
||||
$this->advanceTimeTrigger = (int) $advanceTime;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasTimeTrigger()
|
||||
{
|
||||
return $this->hasTimeTrigger;
|
||||
}
|
||||
|
||||
public function getAdvanceTimeTrigger()
|
||||
{
|
||||
return $this->advanceTimeTrigger;
|
||||
}
|
||||
|
||||
public function setTransitionType($type = null)
|
||||
{
|
||||
$this->transitionType = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTransitionType()
|
||||
{
|
||||
return $this->transitionType;
|
||||
}
|
||||
}
|
||||
394
PhpOffice/PhpPresentation/Style/Alignment.php
Normal file
394
PhpOffice/PhpPresentation/Style/Alignment.php
Normal file
|
|
@ -0,0 +1,394 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
class Alignment implements ComparableInterface
|
||||
{
|
||||
/* Horizontal alignment */
|
||||
const HORIZONTAL_GENERAL = 'l';
|
||||
const HORIZONTAL_LEFT = 'l';
|
||||
const HORIZONTAL_RIGHT = 'r';
|
||||
const HORIZONTAL_CENTER = 'ctr';
|
||||
const HORIZONTAL_JUSTIFY = 'just';
|
||||
const HORIZONTAL_DISTRIBUTED = 'dist';
|
||||
|
||||
/* Vertical alignment */
|
||||
const VERTICAL_BASE = 'base';
|
||||
const VERTICAL_AUTO = 'auto';
|
||||
const VERTICAL_BOTTOM = 'b';
|
||||
const VERTICAL_TOP = 't';
|
||||
const VERTICAL_CENTER = 'ctr';
|
||||
|
||||
/* Text direction */
|
||||
const TEXT_DIRECTION_HORIZONTAL = 'horz';
|
||||
const TEXT_DIRECTION_VERTICAL_90 = 'vert';
|
||||
const TEXT_DIRECTION_VERTICAL_270 = 'vert270';
|
||||
const TEXT_DIRECTION_STACKED = 'wordArtVert';
|
||||
|
||||
private $supportedStyles = array(
|
||||
self::HORIZONTAL_GENERAL,
|
||||
self::HORIZONTAL_LEFT,
|
||||
self::HORIZONTAL_RIGHT,
|
||||
);
|
||||
|
||||
/**
|
||||
* Horizontal
|
||||
* @var string
|
||||
*/
|
||||
private $horizontal;
|
||||
|
||||
/**
|
||||
* Vertical
|
||||
* @var string
|
||||
*/
|
||||
private $vertical;
|
||||
|
||||
/**
|
||||
* Text Direction
|
||||
* @var string
|
||||
*/
|
||||
private $textDirection = self::TEXT_DIRECTION_HORIZONTAL;
|
||||
|
||||
/**
|
||||
* Level
|
||||
* @var int
|
||||
*/
|
||||
private $level = 0;
|
||||
|
||||
/**
|
||||
* Indent - only possible with horizontal alignment left and right
|
||||
* @var int
|
||||
*/
|
||||
private $indent = 0;
|
||||
|
||||
/**
|
||||
* Margin left - only possible with horizontal alignment left and right
|
||||
* @var int
|
||||
*/
|
||||
private $marginLeft = 0;
|
||||
|
||||
/**
|
||||
* Margin right - only possible with horizontal alignment left and right
|
||||
* @var int
|
||||
*/
|
||||
private $marginRight = 0;
|
||||
|
||||
/**
|
||||
* Margin top
|
||||
* @var int
|
||||
*/
|
||||
private $marginTop = 0;
|
||||
|
||||
/**
|
||||
* Margin bottom
|
||||
* @var int
|
||||
*/
|
||||
private $marginBottom = 0;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->horizontal = self::HORIZONTAL_LEFT;
|
||||
$this->vertical = self::VERTICAL_BASE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Horizontal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontal()
|
||||
{
|
||||
return $this->horizontal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Horizontal
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function setHorizontal($pValue = self::HORIZONTAL_LEFT)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = self::HORIZONTAL_LEFT;
|
||||
}
|
||||
$this->horizontal = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Vertical
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVertical()
|
||||
{
|
||||
return $this->vertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Vertical
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function setVertical($pValue = self::VERTICAL_BASE)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = self::VERTICAL_BASE;
|
||||
}
|
||||
$this->vertical = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Level
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLevel()
|
||||
{
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Level
|
||||
*
|
||||
* @param int $pValue Ranging 0 - 8
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function setLevel($pValue = 0)
|
||||
{
|
||||
if ($pValue < 0) {
|
||||
throw new \Exception("Invalid value should be more than 0.");
|
||||
}
|
||||
$this->level = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent()
|
||||
{
|
||||
return $this->indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set indent
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function setIndent($pValue = 0)
|
||||
{
|
||||
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) {
|
||||
$pValue = 0; // indent not supported
|
||||
}
|
||||
|
||||
$this->indent = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get margin left
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginLeft()
|
||||
{
|
||||
return $this->marginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margin left
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function setMarginLeft($pValue = 0)
|
||||
{
|
||||
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) {
|
||||
$pValue = 0; // margin left not supported
|
||||
}
|
||||
|
||||
$this->marginLeft = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get margin right
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginRight()
|
||||
{
|
||||
return $this->marginRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margin ight
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function setMarginRight($pValue = 0)
|
||||
{
|
||||
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) {
|
||||
$pValue = 0; // margin right not supported
|
||||
}
|
||||
|
||||
$this->marginRight = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get margin top
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginTop()
|
||||
{
|
||||
return $this->marginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margin top
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function setMarginTop($pValue = 0)
|
||||
{
|
||||
$this->marginTop = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get margin bottom
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginBottom()
|
||||
{
|
||||
return $this->marginBottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margin bottom
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
public function setMarginBottom($pValue = 0)
|
||||
{
|
||||
$this->marginBottom = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTextDirection()
|
||||
{
|
||||
return $this->textDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pValue
|
||||
* @return Alignment
|
||||
*/
|
||||
public function setTextDirection($pValue = self::TEXT_DIRECTION_HORIZONTAL)
|
||||
{
|
||||
if (empty($pValue)) {
|
||||
$pValue = self::TEXT_DIRECTION_HORIZONTAL;
|
||||
}
|
||||
$this->textDirection = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(
|
||||
$this->horizontal
|
||||
. $this->vertical
|
||||
. $this->level
|
||||
. $this->indent
|
||||
. $this->marginLeft
|
||||
. $this->marginRight
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
235
PhpOffice/PhpPresentation/Style/Border.php
Normal file
235
PhpOffice/PhpPresentation/Style/Border.php
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
class Border implements ComparableInterface
|
||||
{
|
||||
/* Line style */
|
||||
const LINE_NONE = 'none';
|
||||
const LINE_SINGLE = 'sng';
|
||||
const LINE_DOUBLE = 'dbl';
|
||||
const LINE_THICKTHIN = 'thickThin';
|
||||
const LINE_THINTHICK = 'thinThick';
|
||||
const LINE_TRI = 'tri';
|
||||
|
||||
/* Dash style */
|
||||
const DASH_DASH = 'dash';
|
||||
const DASH_DASHDOT = 'dashDot';
|
||||
const DASH_DOT = 'dot';
|
||||
const DASH_LARGEDASH = 'lgDash';
|
||||
const DASH_LARGEDASHDOT = 'lgDashDot';
|
||||
const DASH_LARGEDASHDOTDOT = 'lgDashDotDot';
|
||||
const DASH_SOLID = 'solid';
|
||||
const DASH_SYSDASH = 'sysDash';
|
||||
const DASH_SYSDASHDOT = 'sysDashDot';
|
||||
const DASH_SYSDASHDOTDOT = 'sysDashDotDot';
|
||||
const DASH_SYSDOT = 'sysDot';
|
||||
|
||||
/**
|
||||
* Line width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $lineWidth = 1;
|
||||
|
||||
/**
|
||||
* Line style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $lineStyle;
|
||||
|
||||
/**
|
||||
* Dash style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $dashStyle;
|
||||
|
||||
/**
|
||||
* Border color
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
private $color;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->lineWidth = 1;
|
||||
$this->lineStyle = self::LINE_SINGLE;
|
||||
$this->dashStyle = self::DASH_SOLID;
|
||||
$this->color = new Color(Color::COLOR_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get line width (in points)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLineWidth()
|
||||
{
|
||||
return $this->lineWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line width (in points)
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function setLineWidth($pValue = 1)
|
||||
{
|
||||
$this->lineWidth = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get line style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLineStyle()
|
||||
{
|
||||
return $this->lineStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line style
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function setLineStyle($pValue = self::LINE_SINGLE)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = self::LINE_SINGLE;
|
||||
}
|
||||
$this->lineStyle = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dash style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDashStyle()
|
||||
{
|
||||
return $this->dashStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set dash style
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function setDashStyle($pValue = self::DASH_SOLID)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = self::DASH_SOLID;
|
||||
}
|
||||
$this->dashStyle = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Border Color
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Border Color
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Color $color
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function setColor(Color $color = null)
|
||||
{
|
||||
$this->color = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(
|
||||
$this->lineStyle
|
||||
. $this->lineWidth
|
||||
. $this->dashStyle
|
||||
. $this->color->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
195
PhpOffice/PhpPresentation/Style/Borders.php
Normal file
195
PhpOffice/PhpPresentation/Style/Borders.php
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Style\Borders
|
||||
*/
|
||||
class Borders implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Left
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
private $left;
|
||||
|
||||
/**
|
||||
* Right
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
private $right;
|
||||
|
||||
/**
|
||||
* Top
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
private $top;
|
||||
|
||||
/**
|
||||
* Bottom
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
private $bottom;
|
||||
|
||||
/**
|
||||
* Diagonal up
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
private $diagonalUp;
|
||||
|
||||
/**
|
||||
* Diagonal down
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
private $diagonalDown;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Style\Borders
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->left = new Border();
|
||||
$this->right = new Border();
|
||||
$this->top = new Border();
|
||||
$this->bottom = new Border();
|
||||
$this->diagonalUp = new Border();
|
||||
$this->diagonalUp->setLineStyle(Border::LINE_NONE);
|
||||
$this->diagonalDown = new Border();
|
||||
$this->diagonalDown->setLineStyle(Border::LINE_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Left
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function getLeft()
|
||||
{
|
||||
return $this->left;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Right
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function getRight()
|
||||
{
|
||||
return $this->right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Top
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function getTop()
|
||||
{
|
||||
return $this->top;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bottom
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function getBottom()
|
||||
{
|
||||
return $this->bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Diagonal Up
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function getDiagonalUp()
|
||||
{
|
||||
return $this->diagonalUp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Diagonal Down
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function getDiagonalDown()
|
||||
{
|
||||
return $this->diagonalDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(
|
||||
$this->getLeft()->getHashCode()
|
||||
. $this->getRight()->getHashCode()
|
||||
. $this->getTop()->getHashCode()
|
||||
. $this->getBottom()->getHashCode()
|
||||
. $this->getDiagonalUp()->getHashCode()
|
||||
. $this->getDiagonalDown()->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
317
PhpOffice/PhpPresentation/Style/Bullet.php
Normal file
317
PhpOffice/PhpPresentation/Style/Bullet.php
Normal file
|
|
@ -0,0 +1,317 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Style\Bullet
|
||||
*/
|
||||
class Bullet implements ComparableInterface
|
||||
{
|
||||
/* Bullet types */
|
||||
const TYPE_NONE = 'none';
|
||||
const TYPE_BULLET = 'bullet';
|
||||
const TYPE_NUMERIC = 'numeric';
|
||||
|
||||
/* Numeric bullet styles */
|
||||
const NUMERIC_DEFAULT = 'arabicPeriod';
|
||||
const NUMERIC_ALPHALCPARENBOTH = 'alphaLcParenBoth';
|
||||
const NUMERIC_ALPHAUCPARENBOTH = 'alphaUcParenBoth';
|
||||
const NUMERIC_ALPHALCPARENR = 'alphaLcParenR';
|
||||
const NUMERIC_ALPHAUCPARENR = 'alphaUcParenR';
|
||||
const NUMERIC_ALPHALCPERIOD = 'alphaLcPeriod';
|
||||
const NUMERIC_ALPHAUCPERIOD = 'alphaUcPeriod';
|
||||
const NUMERIC_ARABICPARENBOTH = 'arabicParenBoth';
|
||||
const NUMERIC_ARABICPARENR = 'arabicParenR';
|
||||
const NUMERIC_ARABICPERIOD = 'arabicPeriod';
|
||||
const NUMERIC_ARABICPLAIN = 'arabicPlain';
|
||||
const NUMERIC_ROMANLCPARENBOTH = 'romanLcParenBoth';
|
||||
const NUMERIC_ROMANUCPARENBOTH = 'romanUcParenBoth';
|
||||
const NUMERIC_ROMANLCPARENR = 'romanLcParenR';
|
||||
const NUMERIC_ROMANUCPARENR = 'romanUcParenR';
|
||||
const NUMERIC_ROMANLCPERIOD = 'romanLcPeriod';
|
||||
const NUMERIC_ROMANUCPERIOD = 'romanUcPeriod';
|
||||
const NUMERIC_CIRCLENUMDBPLAIN = 'circleNumDbPlain';
|
||||
const NUMERIC_CIRCLENUMWDBLACKPLAIN = 'circleNumWdBlackPlain';
|
||||
const NUMERIC_CIRCLENUMWDWHITEPLAIN = 'circleNumWdWhitePlain';
|
||||
const NUMERIC_ARABICDBPERIOD = 'arabicDbPeriod';
|
||||
const NUMERIC_ARABICDBPLAIN = 'arabicDbPlain';
|
||||
const NUMERIC_EA1CHSPERIOD = 'ea1ChsPeriod';
|
||||
const NUMERIC_EA1CHSPLAIN = 'ea1ChsPlain';
|
||||
const NUMERIC_EA1CHTPERIOD = 'ea1ChtPeriod';
|
||||
const NUMERIC_EA1CHTPLAIN = 'ea1ChtPlain';
|
||||
const NUMERIC_EA1JPNCHSDBPERIOD = 'ea1JpnChsDbPeriod';
|
||||
const NUMERIC_EA1JPNKORPLAIN = 'ea1JpnKorPlain';
|
||||
const NUMERIC_EA1JPNKORPERIOD = 'ea1JpnKorPeriod';
|
||||
const NUMERIC_ARABIC1MINUS = 'arabic1Minus';
|
||||
const NUMERIC_ARABIC2MINUS = 'arabic2Minus';
|
||||
const NUMERIC_HEBREW2MINUS = 'hebrew2Minus';
|
||||
const NUMERIC_THAIALPHAPERIOD = 'thaiAlphaPeriod';
|
||||
const NUMERIC_THAIALPHAPARENR = 'thaiAlphaParenR';
|
||||
const NUMERIC_THAIALPHAPARENBOTH = 'thaiAlphaParenBoth';
|
||||
const NUMERIC_THAINUMPERIOD = 'thaiNumPeriod';
|
||||
const NUMERIC_THAINUMPARENR = 'thaiNumParenR';
|
||||
const NUMERIC_THAINUMPARENBOTH = 'thaiNumParenBoth';
|
||||
const NUMERIC_HINDIALPHAPERIOD = 'hindiAlphaPeriod';
|
||||
const NUMERIC_HINDINUMPERIOD = 'hindiNumPeriod';
|
||||
const NUMERIC_HINDINUMPARENR = 'hindiNumParenR';
|
||||
const NUMERIC_HINDIALPHA1PERIOD = 'hindiAlpha1Period';
|
||||
|
||||
/**
|
||||
* Bullet type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $bulletType = self::TYPE_NONE;
|
||||
|
||||
/**
|
||||
* Bullet font
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $bulletFont;
|
||||
|
||||
/**
|
||||
* Bullet char
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $bulletChar = '-';
|
||||
|
||||
/**
|
||||
* Bullet char
|
||||
*
|
||||
* @var Color
|
||||
*/
|
||||
private $bulletColor;
|
||||
|
||||
/**
|
||||
* Bullet numeric style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $bulletNumericStyle = self::NUMERIC_DEFAULT;
|
||||
|
||||
/**
|
||||
* Bullet numeric start at
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $bulletNumericStartAt = 1;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Style\Bullet
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->bulletType = self::TYPE_NONE;
|
||||
$this->bulletFont = 'Calibri';
|
||||
$this->bulletChar = '-';
|
||||
$this->bulletColor = new Color();
|
||||
$this->bulletNumericStyle = self::NUMERIC_DEFAULT;
|
||||
$this->bulletNumericStartAt = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bullet type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBulletType()
|
||||
{
|
||||
return $this->bulletType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bullet type
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Bullet
|
||||
*/
|
||||
public function setBulletType($pValue = self::TYPE_NONE)
|
||||
{
|
||||
$this->bulletType = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bullet font
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBulletFont()
|
||||
{
|
||||
return $this->bulletFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bullet font
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Bullet
|
||||
*/
|
||||
public function setBulletFont($pValue = 'Calibri')
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = 'Calibri';
|
||||
}
|
||||
$this->bulletFont = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bullet char
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBulletChar()
|
||||
{
|
||||
return $this->bulletChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bullet char
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Bullet
|
||||
*/
|
||||
public function setBulletChar($pValue = '-')
|
||||
{
|
||||
$this->bulletChar = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bullet numeric style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBulletNumericStyle()
|
||||
{
|
||||
return $this->bulletNumericStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bullet numeric style
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Bullet
|
||||
*/
|
||||
public function setBulletNumericStyle($pValue = self::NUMERIC_DEFAULT)
|
||||
{
|
||||
$this->bulletNumericStyle = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bullet numeric start at
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBulletNumericStartAt()
|
||||
{
|
||||
return $this->bulletNumericStartAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bullet numeric start at
|
||||
*
|
||||
* @param int|string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Bullet
|
||||
*/
|
||||
public function setBulletNumericStartAt($pValue = 1)
|
||||
{
|
||||
$this->bulletNumericStartAt = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(
|
||||
$this->bulletType
|
||||
. $this->bulletFont
|
||||
. $this->bulletChar
|
||||
. $this->bulletNumericStyle
|
||||
. $this->bulletNumericStartAt
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Color
|
||||
*/
|
||||
public function getBulletColor()
|
||||
{
|
||||
return $this->bulletColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Color $bulletColor
|
||||
* @return Bullet
|
||||
*/
|
||||
public function setBulletColor(Color $bulletColor)
|
||||
{
|
||||
$this->bulletColor = $bulletColor;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
197
PhpOffice/PhpPresentation/Style/Color.php
Normal file
197
PhpOffice/PhpPresentation/Style/Color.php
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
class Color implements ComparableInterface
|
||||
{
|
||||
/* Colors */
|
||||
const COLOR_BLACK = 'FF000000';
|
||||
const COLOR_WHITE = 'FFFFFFFF';
|
||||
const COLOR_RED = 'FFFF0000';
|
||||
const COLOR_DARKRED = 'FF800000';
|
||||
const COLOR_BLUE = 'FF0000FF';
|
||||
const COLOR_DARKBLUE = 'FF000080';
|
||||
const COLOR_GREEN = 'FF00FF00';
|
||||
const COLOR_DARKGREEN = 'FF008000';
|
||||
const COLOR_YELLOW = 'FFFFFF00';
|
||||
const COLOR_DARKYELLOW = 'FF808000';
|
||||
|
||||
/**
|
||||
* ARGB - Alpha RGB
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $argb;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Style\Color
|
||||
*
|
||||
* @param string $pARGB
|
||||
*/
|
||||
public function __construct($pARGB = self::COLOR_BLACK)
|
||||
{
|
||||
// Initialise values
|
||||
$this->argb = $pARGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ARGB
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getARGB()
|
||||
{
|
||||
return $this->argb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ARGB
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
public function setARGB($pValue = self::COLOR_BLACK)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = self::COLOR_BLACK;
|
||||
}
|
||||
$this->argb = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alpha % of the ARGB
|
||||
* Will return 100 if no ARGB
|
||||
* @return integer
|
||||
*/
|
||||
public function getAlpha()
|
||||
{
|
||||
$alpha = 100;
|
||||
if (strlen($this->argb) >= 6) {
|
||||
$dec = hexdec(substr($this->argb, 0, 2));
|
||||
$alpha = number_format(($dec/255) * 100, 2);
|
||||
}
|
||||
return $alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the alpha % of the ARGB
|
||||
* @param int $alpha
|
||||
* @return $this
|
||||
*/
|
||||
public function setAlpha($alpha = 100)
|
||||
{
|
||||
if ($alpha < 0) {
|
||||
$alpha = 0;
|
||||
}
|
||||
if ($alpha > 100) {
|
||||
$alpha = 100;
|
||||
}
|
||||
$alpha = round(($alpha / 100) * 255);
|
||||
$alpha = dechex($alpha);
|
||||
$alpha = str_pad($alpha, 2, '0', STR_PAD_LEFT);
|
||||
$this->argb = $alpha . substr($this->argb, 2);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get RGB
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRGB()
|
||||
{
|
||||
if (strlen($this->argb) == 6) {
|
||||
return $this->argb;
|
||||
} else {
|
||||
return substr($this->argb, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set RGB
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param string $pAlpha
|
||||
* @return \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
public function setRGB($pValue = '000000', $pAlpha = 'FF')
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = '000000';
|
||||
}
|
||||
if ($pAlpha == '') {
|
||||
$pAlpha = 'FF';
|
||||
}
|
||||
$this->argb = $pAlpha . $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(
|
||||
$this->argb
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
103
PhpOffice/PhpPresentation/Style/ColorMap.php
Normal file
103
PhpOffice/PhpPresentation/Style/ColorMap.php
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
/**
|
||||
* PhpOffice\PhpPresentation\Style\ColorMap
|
||||
*/
|
||||
class ColorMap
|
||||
{
|
||||
const COLOR_BG1 = 'bg1';
|
||||
const COLOR_BG2 = 'bg2';
|
||||
const COLOR_TX1 = 'tx1';
|
||||
const COLOR_TX2 = 'tx2';
|
||||
const COLOR_ACCENT1 = 'accent1';
|
||||
const COLOR_ACCENT2 = 'accent2';
|
||||
const COLOR_ACCENT3 = 'accent3';
|
||||
const COLOR_ACCENT4 = 'accent4';
|
||||
const COLOR_ACCENT5 = 'accent5';
|
||||
const COLOR_ACCENT6 = 'accent6';
|
||||
const COLOR_HLINK = 'hlink';
|
||||
const COLOR_FOLHLINK = 'folHlink';
|
||||
|
||||
/**
|
||||
* Mapping - Stores the mapping betweenSlide and theme
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $mapping = array();
|
||||
|
||||
public static $mappingDefault = array(
|
||||
self::COLOR_BG1 => 'lt1',
|
||||
self::COLOR_TX1 => 'dk1',
|
||||
self::COLOR_BG2 => 'lt2',
|
||||
self::COLOR_TX2 => 'dk2',
|
||||
self::COLOR_ACCENT1 => 'accent1',
|
||||
self::COLOR_ACCENT2 => 'accent2',
|
||||
self::COLOR_ACCENT3 => 'accent3',
|
||||
self::COLOR_ACCENT4 => 'accent4',
|
||||
self::COLOR_ACCENT5 => 'accent5',
|
||||
self::COLOR_ACCENT6 => 'accent6',
|
||||
self::COLOR_HLINK => 'hlink',
|
||||
self::COLOR_FOLHLINK => 'folHlink'
|
||||
);
|
||||
|
||||
/**
|
||||
* ColorMap constructor.
|
||||
* Create a new ColorMap with standard values
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->mapping = self::$mappingDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the color of one of the elements in the map
|
||||
*
|
||||
* @param string $item
|
||||
* @param string $newThemeColor
|
||||
* @return ColorMap
|
||||
*/
|
||||
public function changeColor($item, $newThemeColor)
|
||||
{
|
||||
$this->mapping[$item] = $newThemeColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new map. For use with the reader
|
||||
*
|
||||
* @param array $arrayMapping
|
||||
* @return ColorMap
|
||||
*/
|
||||
public function setMapping(array $arrayMapping = array())
|
||||
{
|
||||
$this->mapping = $arrayMapping;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the whole mapping as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMapping()
|
||||
{
|
||||
return $this->mapping;
|
||||
}
|
||||
}
|
||||
236
PhpOffice/PhpPresentation/Style/Fill.php
Normal file
236
PhpOffice/PhpPresentation/Style/Fill.php
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
class Fill implements ComparableInterface
|
||||
{
|
||||
/* Fill types */
|
||||
const FILL_NONE = 'none';
|
||||
const FILL_SOLID = 'solid';
|
||||
const FILL_GRADIENT_LINEAR = 'linear';
|
||||
const FILL_GRADIENT_PATH = 'path';
|
||||
const FILL_PATTERN_DARKDOWN = 'darkDown';
|
||||
const FILL_PATTERN_DARKGRAY = 'darkGray';
|
||||
const FILL_PATTERN_DARKGRID = 'darkGrid';
|
||||
const FILL_PATTERN_DARKHORIZONTAL = 'darkHorizontal';
|
||||
const FILL_PATTERN_DARKTRELLIS = 'darkTrellis';
|
||||
const FILL_PATTERN_DARKUP = 'darkUp';
|
||||
const FILL_PATTERN_DARKVERTICAL = 'darkVertical';
|
||||
const FILL_PATTERN_GRAY0625 = 'gray0625';
|
||||
const FILL_PATTERN_GRAY125 = 'gray125';
|
||||
const FILL_PATTERN_LIGHTDOWN = 'lightDown';
|
||||
const FILL_PATTERN_LIGHTGRAY = 'lightGray';
|
||||
const FILL_PATTERN_LIGHTGRID = 'lightGrid';
|
||||
const FILL_PATTERN_LIGHTHORIZONTAL = 'lightHorizontal';
|
||||
const FILL_PATTERN_LIGHTTRELLIS = 'lightTrellis';
|
||||
const FILL_PATTERN_LIGHTUP = 'lightUp';
|
||||
const FILL_PATTERN_LIGHTVERTICAL = 'lightVertical';
|
||||
const FILL_PATTERN_MEDIUMGRAY = 'mediumGray';
|
||||
|
||||
/**
|
||||
* Fill type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $fillType;
|
||||
|
||||
/**
|
||||
* Rotation
|
||||
*
|
||||
* @var double
|
||||
*/
|
||||
private $rotation;
|
||||
|
||||
/**
|
||||
* Start color
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
private $startColor;
|
||||
|
||||
/**
|
||||
* End color
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
private $endColor;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->fillType = self::FILL_NONE;
|
||||
$this->rotation = (double)0;
|
||||
$this->startColor = new Color(Color::COLOR_WHITE);
|
||||
$this->endColor = new Color(Color::COLOR_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFillType()
|
||||
{
|
||||
return $this->fillType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill Type
|
||||
*
|
||||
* @param string $pValue \PhpOffice\PhpPresentation\Style\Fill fill type
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function setFillType($pValue = self::FILL_NONE)
|
||||
{
|
||||
$this->fillType = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getRotation()
|
||||
{
|
||||
return $this->rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rotation
|
||||
*
|
||||
* @param float|int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function setRotation($pValue = 0)
|
||||
{
|
||||
$this->rotation = (double)$pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Start Color
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
public function getStartColor()
|
||||
{
|
||||
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
|
||||
// So bind as an assurance.
|
||||
return $this->startColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Start Color
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Color $pValue
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function setStartColor(Color $pValue = null)
|
||||
{
|
||||
$this->startColor = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get End Color
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
public function getEndColor()
|
||||
{
|
||||
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
|
||||
// So bind as an assurance.
|
||||
return $this->endColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set End Color
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Color $pValue
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function setEndColor(Color $pValue = null)
|
||||
{
|
||||
$this->endColor = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(
|
||||
$this->getFillType()
|
||||
. $this->getRotation()
|
||||
. $this->getStartColor()->getHashCode()
|
||||
. $this->getEndColor()->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
450
PhpOffice/PhpPresentation/Style/Font.php
Normal file
450
PhpOffice/PhpPresentation/Style/Font.php
Normal file
|
|
@ -0,0 +1,450 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
class Font implements ComparableInterface
|
||||
{
|
||||
/* Underline types */
|
||||
const UNDERLINE_NONE = 'none';
|
||||
const UNDERLINE_DASH = 'dash';
|
||||
const UNDERLINE_DASHHEAVY = 'dashHeavy';
|
||||
const UNDERLINE_DASHLONG = 'dashLong';
|
||||
const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy';
|
||||
const UNDERLINE_DOUBLE = 'dbl';
|
||||
const UNDERLINE_DOTHASH = 'dotDash';
|
||||
const UNDERLINE_DOTHASHHEAVY = 'dotDashHeavy';
|
||||
const UNDERLINE_DOTDOTDASH = 'dotDotDash';
|
||||
const UNDERLINE_DOTDOTDASHHEAVY = 'dotDotDashHeavy';
|
||||
const UNDERLINE_DOTTED = 'dotted';
|
||||
const UNDERLINE_DOTTEDHEAVY = 'dottedHeavy';
|
||||
const UNDERLINE_HEAVY = 'heavy';
|
||||
const UNDERLINE_SINGLE = 'sng';
|
||||
const UNDERLINE_WAVY = 'wavy';
|
||||
const UNDERLINE_WAVYDOUBLE = 'wavyDbl';
|
||||
const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
|
||||
const UNDERLINE_WORDS = 'words';
|
||||
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Font Size
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
private $size;
|
||||
|
||||
/**
|
||||
* Bold
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $bold;
|
||||
|
||||
/**
|
||||
* Italic
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $italic;
|
||||
|
||||
/**
|
||||
* Superscript
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $superScript;
|
||||
|
||||
/**
|
||||
* Subscript
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $subScript;
|
||||
|
||||
/**
|
||||
* Underline
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $underline;
|
||||
|
||||
/**
|
||||
* Strikethrough
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $strikethrough;
|
||||
|
||||
/**
|
||||
* Foreground color
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
private $color;
|
||||
|
||||
/**
|
||||
* Character Spacing
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $characterSpacing;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->name = 'Calibri';
|
||||
$this->size = 10;
|
||||
$this->characterSpacing = 0;
|
||||
$this->bold = false;
|
||||
$this->italic = false;
|
||||
$this->superScript = false;
|
||||
$this->subScript = false;
|
||||
$this->underline = self::UNDERLINE_NONE;
|
||||
$this->strikethrough = false;
|
||||
$this->color = new Color(Color::COLOR_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Name
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setName($pValue = 'Calibri')
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = 'Calibri';
|
||||
}
|
||||
$this->name = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Character Spacing
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getCharacterSpacing()
|
||||
{
|
||||
return $this->characterSpacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Character Spacing
|
||||
* Value in pt
|
||||
* @param float|int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setCharacterSpacing($pValue = 0)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = 0;
|
||||
}
|
||||
$this->characterSpacing = $pValue * 100;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Size
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Size
|
||||
*
|
||||
* @param float|int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setSize($pValue = 10)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = 10;
|
||||
}
|
||||
$this->size = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bold
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isBold()
|
||||
{
|
||||
return $this->bold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bold
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setBold($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->bold = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Italic
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isItalic()
|
||||
{
|
||||
return $this->italic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Italic
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setItalic($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->italic = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SuperScript
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSuperScript()
|
||||
{
|
||||
return $this->superScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SuperScript
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setSuperScript($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
|
||||
$this->superScript = $pValue;
|
||||
|
||||
// Set SubScript at false only if SuperScript is true
|
||||
if ($pValue === true) {
|
||||
$this->subScript = false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SubScript
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSubScript()
|
||||
{
|
||||
return $this->subScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SubScript
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setSubScript($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
|
||||
$this->subScript = $pValue;
|
||||
|
||||
// Set SuperScript at false only if SubScript is true
|
||||
if ($pValue === true) {
|
||||
$this->superScript = false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Underline
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUnderline()
|
||||
{
|
||||
return $this->underline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Underline
|
||||
*
|
||||
* @param string $pValue \PhpOffice\PhpPresentation\Style\Font underline type
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setUnderline($pValue = self::UNDERLINE_NONE)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = self::UNDERLINE_NONE;
|
||||
}
|
||||
$this->underline = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Strikethrough
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isStrikethrough()
|
||||
{
|
||||
return $this->strikethrough;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Strikethrough
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setStrikethrough($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->strikethrough = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Color
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Color|\PhpOffice\PhpPresentation\Style\SchemeColor
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Color
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Color|\PhpOffice\PhpPresentation\Style\SchemeColor $pValue
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
public function setColor($pValue = null)
|
||||
{
|
||||
if (!$pValue instanceof Color) {
|
||||
throw new \Exception('$pValue must be an instance of \PhpOffice\PhpPresentation\Style\Color');
|
||||
}
|
||||
$this->color = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5($this->name . $this->size . ($this->bold ? 't' : 'f') . ($this->italic ? 't' : 'f') . ($this->superScript ? 't' : 'f') . ($this->subScript ? 't' : 'f') . $this->underline . ($this->strikethrough ? 't' : 'f') . $this->color->getHashCode() . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
79
PhpOffice/PhpPresentation/Style/Outline.php
Normal file
79
PhpOffice/PhpPresentation/Style/Outline.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Style\Outline
|
||||
*/
|
||||
class Outline
|
||||
{
|
||||
/**
|
||||
* @var Fill
|
||||
*/
|
||||
protected $fill;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $width;
|
||||
|
||||
|
||||
/**
|
||||
* Outline constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->fill = new Fill();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Fill
|
||||
*/
|
||||
public function getFill()
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Fill $fill
|
||||
* @return Outline
|
||||
*/
|
||||
public function setFill(Fill $fill)
|
||||
{
|
||||
$this->fill = $fill;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value in points
|
||||
* @param int $width
|
||||
* @return Outline
|
||||
*/
|
||||
public function setWidth($width)
|
||||
{
|
||||
$this->width = intval($width);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
39
PhpOffice/PhpPresentation/Style/SchemeColor.php
Normal file
39
PhpOffice/PhpPresentation/Style/SchemeColor.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
class SchemeColor extends Color
|
||||
{
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
309
PhpOffice/PhpPresentation/Style/Shadow.php
Normal file
309
PhpOffice/PhpPresentation/Style/Shadow.php
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Style\Shadow
|
||||
*/
|
||||
class Shadow implements ComparableInterface
|
||||
{
|
||||
/* Shadow alignment */
|
||||
const SHADOW_BOTTOM = 'b';
|
||||
const SHADOW_BOTTOM_LEFT = 'bl';
|
||||
const SHADOW_BOTTOM_RIGHT = 'br';
|
||||
const SHADOW_CENTER = 'ctr';
|
||||
const SHADOW_LEFT = 'l';
|
||||
const SHADOW_TOP = 't';
|
||||
const SHADOW_TOP_LEFT = 'tl';
|
||||
const SHADOW_TOP_RIGHT = 'tr';
|
||||
|
||||
/**
|
||||
* Visible
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $visible;
|
||||
|
||||
/**
|
||||
* Blur radius
|
||||
*
|
||||
* Defaults to 6
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $blurRadius;
|
||||
|
||||
/**
|
||||
* Shadow distance
|
||||
*
|
||||
* Defaults to 2
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $distance;
|
||||
|
||||
/**
|
||||
* Shadow direction (in degrees)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $direction;
|
||||
|
||||
/**
|
||||
* Shadow alignment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $alignment;
|
||||
|
||||
/**
|
||||
* Color
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
private $color;
|
||||
|
||||
/**
|
||||
* Alpha
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $alpha;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Style\Shadow
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->visible = false;
|
||||
$this->blurRadius = 6;
|
||||
$this->distance = 2;
|
||||
$this->direction = 0;
|
||||
$this->alignment = self::SHADOW_BOTTOM_RIGHT;
|
||||
$this->color = new Color(Color::COLOR_BLACK);
|
||||
$this->alpha = 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Visible
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible($pValue = false)
|
||||
{
|
||||
$this->visible = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Blur radius
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlurRadius()
|
||||
{
|
||||
return $this->blurRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Blur radius
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setBlurRadius($pValue = 6)
|
||||
{
|
||||
$this->blurRadius = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow distance
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDistance()
|
||||
{
|
||||
return $this->distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow distance
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setDistance($pValue = 2)
|
||||
{
|
||||
$this->distance = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow direction (in degrees)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDirection()
|
||||
{
|
||||
return $this->direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow direction (in degrees)
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setDirection($pValue = 0)
|
||||
{
|
||||
$this->direction = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow alignment
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow alignment
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setAlignment($pValue = self::SHADOW_BOTTOM_RIGHT)
|
||||
{
|
||||
$this->alignment = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Color
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Color
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Color
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Color $pValue
|
||||
* @throws \Exception
|
||||
* @return $this
|
||||
*/
|
||||
public function setColor(Color $pValue = null)
|
||||
{
|
||||
$this->color = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alpha
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAlpha()
|
||||
{
|
||||
return $this->alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Alpha
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setAlpha($pValue = 0)
|
||||
{
|
||||
$this->alpha = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(($this->visible ? 't' : 'f') . $this->blurRadius . $this->distance . $this->direction . $this->alignment . $this->color->getHashCode() . $this->alpha . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
}
|
||||
}
|
||||
186
PhpOffice/PhpPresentation/Style/TextStyle.php
Normal file
186
PhpOffice/PhpPresentation/Style/TextStyle.php
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Style;
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph as RichTextParagraph;
|
||||
|
||||
/**
|
||||
* Class TextStyle
|
||||
*/
|
||||
class TextStyle
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $bodyStyle = array();
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $titleStyle = array();
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $otherStyle = array();
|
||||
|
||||
/**
|
||||
* TextStyle constructor.
|
||||
* @param bool $default
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($default = true)
|
||||
{
|
||||
if ($default) {
|
||||
$oColorLT1 = new SchemeColor();
|
||||
$oColorLT1->setValue('lt1');
|
||||
$oColorTX1 = new SchemeColor();
|
||||
$oColorTX1->setValue('tx1');
|
||||
|
||||
$oRTParagraphBody = new RichTextParagraph();
|
||||
$oRTParagraphBody->getAlignment()
|
||||
->setHorizontal(Alignment::HORIZONTAL_CENTER)
|
||||
->setIndent(-324900 / 9525)
|
||||
->setMarginLeft(342900 / 9525);
|
||||
$oRTParagraphBody->getFont()->setSize(32)->setColor($oColorTX1);
|
||||
$this->bodyStyle[1] = $oRTParagraphBody;
|
||||
|
||||
$oRTParagraphOther = new RichTextParagraph();
|
||||
$oRTParagraphOther->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||
$oRTParagraphOther->getFont()->setSize(10)->setColor($oColorTX1);
|
||||
$this->otherStyle[0] = $oRTParagraphOther;
|
||||
|
||||
$oRTParagraphTitle = new RichTextParagraph();
|
||||
$oRTParagraphTitle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||
$oRTParagraphTitle->getFont()->setSize(44)->setColor($oColorLT1);
|
||||
$this->titleStyle[1] = $oRTParagraphTitle;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $lvl
|
||||
* @return bool
|
||||
*/
|
||||
private function checkLvl($lvl)
|
||||
{
|
||||
if (!is_int($lvl)) {
|
||||
return false;
|
||||
}
|
||||
if ($lvl > 9) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RichTextParagraph $style
|
||||
* @param $lvl
|
||||
* @return TextStyle
|
||||
*/
|
||||
public function setBodyStyleAtLvl(RichTextParagraph $style, $lvl)
|
||||
{
|
||||
if ($this->checkLvl($lvl)) {
|
||||
$this->bodyStyle[$lvl] = $style;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RichTextParagraph $style
|
||||
* @param $lvl
|
||||
* @return TextStyle
|
||||
*/
|
||||
public function setTitleStyleAtLvl(RichTextParagraph $style, $lvl)
|
||||
{
|
||||
if ($this->checkLvl($lvl)) {
|
||||
$this->titleStyle[$lvl] = $style;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RichTextParagraph $style
|
||||
* @param $lvl
|
||||
* @return TextStyle
|
||||
*/
|
||||
public function setOtherStyleAtLvl(RichTextParagraph $style, $lvl)
|
||||
{
|
||||
if ($this->checkLvl($lvl)) {
|
||||
$this->otherStyle[$lvl] = $style;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $lvl
|
||||
* @return mixed
|
||||
*/
|
||||
public function getBodyStyleAtLvl($lvl)
|
||||
{
|
||||
if ($this->checkLvl($lvl) && !empty($this->bodyStyle[$lvl])) {
|
||||
return $this->bodyStyle[$lvl];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $lvl
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitleStyleAtLvl($lvl)
|
||||
{
|
||||
if ($this->checkLvl($lvl) && !empty($this->titleStyle[$lvl])) {
|
||||
return $this->titleStyle[$lvl];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $lvl
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOtherStyleAtLvl($lvl)
|
||||
{
|
||||
if ($this->checkLvl($lvl) && !empty($this->otherStyle[$lvl])) {
|
||||
return $this->otherStyle[$lvl];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBodyStyle()
|
||||
{
|
||||
return $this->bodyStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getTitleStyle()
|
||||
{
|
||||
return $this->titleStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getOtherStyle()
|
||||
{
|
||||
return $this->otherStyle;
|
||||
}
|
||||
}
|
||||
84
PhpOffice/PhpPresentation/Writer/AbstractDecoratorWriter.php
Normal file
84
PhpOffice/PhpPresentation/Writer/AbstractDecoratorWriter.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Writer;
|
||||
|
||||
use PhpOffice\Common\Adapter\Zip\ZipInterface;
|
||||
use PhpOffice\PhpPresentation\HashTable;
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
|
||||
abstract class AbstractDecoratorWriter
|
||||
{
|
||||
/**
|
||||
* @return ZipInterface
|
||||
*/
|
||||
abstract public function render();
|
||||
|
||||
/**
|
||||
* @var \PhpOffice\PhpPresentation\HashTable
|
||||
*/
|
||||
protected $oHashTable;
|
||||
|
||||
/**
|
||||
* @var PhpPresentation
|
||||
*/
|
||||
protected $oPresentation;
|
||||
|
||||
/**
|
||||
* @var ZipInterface
|
||||
*/
|
||||
protected $oZip;
|
||||
|
||||
/**
|
||||
* @param HashTable $hashTable
|
||||
* @return $this
|
||||
*/
|
||||
public function setDrawingHashTable(HashTable $hashTable)
|
||||
{
|
||||
$this->oHashTable = $hashTable;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HashTable
|
||||
*/
|
||||
public function getDrawingHashTable()
|
||||
{
|
||||
return $this->oHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PhpPresentation $oPresentation
|
||||
* @return $this
|
||||
*/
|
||||
public function setPresentation(PhpPresentation $oPresentation)
|
||||
{
|
||||
$this->oPresentation = $oPresentation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
public function getPresentation()
|
||||
{
|
||||
return $this->oPresentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ZipInterface $oZip
|
||||
* @return $this
|
||||
*/
|
||||
public function setZip(ZipInterface $oZip)
|
||||
{
|
||||
$this->oZip = $oZip;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ZipInterface
|
||||
*/
|
||||
public function getZip()
|
||||
{
|
||||
return $this->oZip;
|
||||
}
|
||||
}
|
||||
142
PhpOffice/PhpPresentation/Writer/AbstractWriter.php
Normal file
142
PhpOffice/PhpPresentation/Writer/AbstractWriter.php
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Writer;
|
||||
|
||||
use PhpOffice\Common\Adapter\Zip\ZipInterface;
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\AbstractDrawingAdapter;
|
||||
use PhpOffice\PhpPresentation\Shape\Group;
|
||||
|
||||
abstract class AbstractWriter
|
||||
{
|
||||
/**
|
||||
* Private unique hash table
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\HashTable
|
||||
*/
|
||||
protected $oDrawingHashTable;
|
||||
|
||||
/**
|
||||
* Private PhpPresentation
|
||||
*
|
||||
* @var PhpPresentation
|
||||
*/
|
||||
protected $oPresentation;
|
||||
|
||||
/**
|
||||
* @var ZipInterface
|
||||
*/
|
||||
protected $oZipAdapter;
|
||||
|
||||
/**
|
||||
* Get drawing hash table
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\HashTable
|
||||
*/
|
||||
public function getDrawingHashTable()
|
||||
{
|
||||
return $this->oDrawingHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PhpPresentation object
|
||||
*
|
||||
* @return PhpPresentation
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getPhpPresentation()
|
||||
{
|
||||
if (empty($this->oPresentation)) {
|
||||
throw new \Exception("No PhpPresentation assigned.");
|
||||
}
|
||||
return $this->oPresentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PhpPresentation object
|
||||
*
|
||||
* @param PhpPresentation $pPhpPresentation PhpPresentation object
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Writer\AbstractWriter
|
||||
*/
|
||||
public function setPhpPresentation(PhpPresentation $pPhpPresentation = null)
|
||||
{
|
||||
$this->oPresentation = $pPhpPresentation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ZipInterface $oZipAdapter
|
||||
* @return $this
|
||||
*/
|
||||
public function setZipAdapter(ZipInterface $oZipAdapter)
|
||||
{
|
||||
$this->oZipAdapter = $oZipAdapter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ZipInterface
|
||||
*/
|
||||
public function getZipAdapter()
|
||||
{
|
||||
return $this->oZipAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all drawings
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\AbstractDrawing[] All drawings in PhpPresentation
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function allDrawings()
|
||||
{
|
||||
// Get an array of all drawings
|
||||
$aDrawings = array();
|
||||
|
||||
// Get an array of all master slides
|
||||
$aSlideMasters = $this->getPhpPresentation()->getAllMasterSlides();
|
||||
|
||||
$aSlideMasterLayouts = array_map(function ($oSlideMaster) {
|
||||
return $oSlideMaster->getAllSlideLayouts();
|
||||
}, $aSlideMasters);
|
||||
|
||||
// Get an array of all slide layouts
|
||||
$aSlideLayouts = array();
|
||||
array_walk_recursive($aSlideMasterLayouts, function ($oSlideLayout) use (&$aSlideLayouts) {
|
||||
$aSlideLayouts[] = $oSlideLayout;
|
||||
});
|
||||
|
||||
// Loop through PhpPresentation
|
||||
foreach (array_merge($this->getPhpPresentation()->getAllSlides(), $aSlideMasters, $aSlideLayouts) as $oSlide) {
|
||||
$arrayReturn = $this->iterateCollection($oSlide->getShapeCollection()->getIterator());
|
||||
$aDrawings = array_merge($aDrawings, $arrayReturn);
|
||||
}
|
||||
|
||||
return $aDrawings;
|
||||
}
|
||||
|
||||
private function iterateCollection(\ArrayIterator $oIterator)
|
||||
{
|
||||
$arrayReturn = array();
|
||||
if ($oIterator->count() <= 0) {
|
||||
return $arrayReturn;
|
||||
}
|
||||
|
||||
while ($oIterator->valid()) {
|
||||
$oShape = $oIterator->current();
|
||||
if ($oShape instanceof AbstractDrawingAdapter) {
|
||||
$arrayReturn[] = $oShape;
|
||||
} elseif ($oShape instanceof Chart) {
|
||||
$arrayReturn[] = $oShape;
|
||||
} elseif ($oShape instanceof Group) {
|
||||
$arrayGroup = $this->iterateCollection($oShape->getShapeCollection()->getIterator());
|
||||
$arrayReturn = array_merge($arrayReturn, $arrayGroup);
|
||||
}
|
||||
$oIterator->next();
|
||||
}
|
||||
return $arrayReturn;
|
||||
}
|
||||
}
|
||||
186
PhpOffice/PhpPresentation/Writer/ODPresentation.php
Normal file
186
PhpOffice/PhpPresentation/Writer/ODPresentation.php
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Writer;
|
||||
|
||||
use PhpOffice\Common\Adapter\Zip\ZipArchiveAdapter;
|
||||
use PhpOffice\PhpPresentation\HashTable;
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
use PhpOffice\PhpPresentation\Shape\AbstractDrawing;
|
||||
use PhpOffice\PhpPresentation\Shape\Table;
|
||||
use DirectoryIterator;
|
||||
|
||||
/**
|
||||
* ODPresentation writer
|
||||
*/
|
||||
class ODPresentation extends AbstractWriter implements WriterInterface
|
||||
{
|
||||
/**
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart[]
|
||||
*/
|
||||
public $chartArray = array();
|
||||
|
||||
/**
|
||||
* Use disk caching where possible?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $useDiskCaching = false;
|
||||
|
||||
/**
|
||||
* Disk caching directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $diskCachingDirectory;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Writer\ODPresentation
|
||||
*
|
||||
* @param PhpPresentation $pPhpPresentation
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(PhpPresentation $pPhpPresentation = null)
|
||||
{
|
||||
// Assign PhpPresentation
|
||||
$this->setPhpPresentation($pPhpPresentation);
|
||||
|
||||
// Set up disk caching location
|
||||
$this->diskCachingDirectory = './';
|
||||
|
||||
// Set HashTable variables
|
||||
$this->oDrawingHashTable = new HashTable();
|
||||
|
||||
$this->setZipAdapter(new ZipArchiveAdapter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PhpPresentation to file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function save($pFilename)
|
||||
{
|
||||
if (empty($pFilename)) {
|
||||
throw new \Exception("Filename is empty");
|
||||
}
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize HashTable
|
||||
$this->getDrawingHashTable()->addFromSource($this->allDrawings());
|
||||
|
||||
// Initialize Zip
|
||||
$oZip = $this->getZipAdapter();
|
||||
$oZip->open($pFilename);
|
||||
|
||||
// Variables
|
||||
$oPresentation = $this->getPhpPresentation();
|
||||
$arrayChart = array();
|
||||
|
||||
$arrayFiles = array();
|
||||
$oDir = new DirectoryIterator(dirname(__FILE__).DIRECTORY_SEPARATOR.'ODPresentation');
|
||||
foreach ($oDir as $oFile) {
|
||||
if (!$oFile->isFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = __NAMESPACE__ . '\\ODPresentation\\' . $oFile->getBasename('.php');
|
||||
$o = new \ReflectionClass($class);
|
||||
|
||||
if ($o->isAbstract() || !$o->isSubclassOf('PhpOffice\PhpPresentation\Writer\ODPresentation\AbstractDecoratorWriter')) {
|
||||
continue;
|
||||
}
|
||||
$arrayFiles[$oFile->getBasename('.php')] = $o;
|
||||
}
|
||||
|
||||
ksort($arrayFiles);
|
||||
|
||||
foreach ($arrayFiles as $o) {
|
||||
$oService = $o->newInstance();
|
||||
$oService->setZip($oZip);
|
||||
$oService->setPresentation($oPresentation);
|
||||
$oService->setDrawingHashTable($this->getDrawingHashTable());
|
||||
$oService->setArrayChart($arrayChart);
|
||||
$oZip = $oService->render();
|
||||
$arrayChart = $oService->getArrayChart();
|
||||
unset($oService);
|
||||
}
|
||||
|
||||
// Close file
|
||||
$oZip->close();
|
||||
|
||||
// If a temporary file was used, copy it to the correct file stream
|
||||
if ($originalFilename != $pFilename) {
|
||||
if (copy($pFilename, $originalFilename) === false) {
|
||||
throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
|
||||
}
|
||||
if (@unlink($pFilename) === false) {
|
||||
throw new \Exception('The file ' . $pFilename . ' could not be removed.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get use disk caching where possible?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasDiskCaching()
|
||||
{
|
||||
return $this->useDiskCaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set use disk caching where possible?
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory Disk caching directory
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Writer\ODPresentation
|
||||
*/
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null)
|
||||
{
|
||||
$this->useDiskCaching = $pValue;
|
||||
|
||||
if (!is_null($pDirectory)) {
|
||||
if (!is_dir($pDirectory)) {
|
||||
throw new \Exception("Directory does not exist: $pDirectory");
|
||||
}
|
||||
$this->diskCachingDirectory = $pDirectory;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disk caching directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiskCachingDirectory()
|
||||
{
|
||||
return $this->diskCachingDirectory;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user