mirror of
https://github.com/Karaka-Management/Resources.git
synced 2026-01-10 21:08:41 +00:00
code style fixes + const check fix
This commit is contained in:
parent
cfc0d32a10
commit
3011a504cd
|
|
@ -76,7 +76,7 @@ class ConfigVariables
|
|||
// Uses Adobe CJK fonts for CJK languages
|
||||
// default TRUE, only set false if you have defined some available fonts that support CJK
|
||||
// If true this will not stop use of other CJK fonts if specified by font-family:
|
||||
// and vice versa i.e. only dictates behaviour when specified by lang="" incl. AutoFont()
|
||||
// and vice versa i.e. only dictates behavior when specified by lang="" incl. AutoFont()
|
||||
'useAdobeCJK' => false,
|
||||
|
||||
// When embedding full TTF font files, remakes the font file using only core tables
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -7,7 +7,7 @@ use PclZip;
|
|||
class PclZipAdapter implements ZipInterface
|
||||
{
|
||||
/**
|
||||
* @var PclZip
|
||||
* @var \PclZip
|
||||
*/
|
||||
protected $oPclZip;
|
||||
|
||||
|
|
@ -18,8 +18,8 @@ class PclZipAdapter implements ZipInterface
|
|||
|
||||
public function open($filename)
|
||||
{
|
||||
$this->oPclZip = new PclZip($filename);
|
||||
$this->tmpDir = sys_get_temp_dir();
|
||||
$this->oPclZip = new \PclZip($filename);
|
||||
$this->tmpDir = \sys_get_temp_dir();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -31,17 +31,17 @@ class PclZipAdapter implements ZipInterface
|
|||
|
||||
public function addFromString($localname, $contents)
|
||||
{
|
||||
$pathData = pathinfo($localname);
|
||||
$pathData = \pathinfo($localname);
|
||||
|
||||
$hFile = fopen($this->tmpDir . '/' . $pathData['basename'], 'wb');
|
||||
fwrite($hFile, $contents);
|
||||
fclose($hFile);
|
||||
$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']);
|
||||
\unlink($this->tmpDir . '/' . $pathData['basename']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use ZipArchive;
|
|||
class ZipArchiveAdapter implements ZipInterface
|
||||
{
|
||||
/**
|
||||
* @var ZipArchive
|
||||
* @var \ZipArchive
|
||||
*/
|
||||
protected $oZipArchive;
|
||||
|
||||
|
|
@ -19,12 +19,12 @@ class ZipArchiveAdapter implements ZipInterface
|
|||
public function open($filename)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
$this->oZipArchive = new ZipArchive();
|
||||
$this->oZipArchive = new \ZipArchive();
|
||||
|
||||
if ($this->oZipArchive->open($this->filename, ZipArchive::OVERWRITE) === true) {
|
||||
if ($this->oZipArchive->open($this->filename, \ZipArchive::OVERWRITE) === true) {
|
||||
return $this;
|
||||
}
|
||||
if ($this->oZipArchive->open($this->filename, ZipArchive::CREATE) === true) {
|
||||
if ($this->oZipArchive->open($this->filename, \ZipArchive::CREATE) === true) {
|
||||
return $this;
|
||||
}
|
||||
throw new \Exception("Could not open $this->filename for writing.");
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Autoloader
|
|||
*/
|
||||
public static function register(): void
|
||||
{
|
||||
spl_autoload_register([new self(), 'autoload']);
|
||||
\spl_autoload_register([new self(), 'autoload']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -42,11 +42,11 @@ class Autoloader
|
|||
*/
|
||||
public static function autoload(string $class): void
|
||||
{
|
||||
$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)) {
|
||||
$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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Drawing
|
|||
*/
|
||||
public static function pixelsToEmu(float $pValue = 0): float
|
||||
{
|
||||
return round($pValue * 9525);
|
||||
return \round($pValue * 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -46,7 +46,7 @@ class Drawing
|
|||
return 0;
|
||||
}
|
||||
|
||||
return (int) round($pValue / 9525);
|
||||
return (int) \round($pValue / 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -135,7 +135,7 @@ class Drawing
|
|||
return 0;
|
||||
}
|
||||
|
||||
return (int) round((($pValue / 2.54) * self::DPI_96));
|
||||
return (int) \round((($pValue / 2.54) * self::DPI_96));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -147,7 +147,7 @@ class Drawing
|
|||
*/
|
||||
public static function degreesToAngle(int $pValue = 0): int
|
||||
{
|
||||
return (int) round($pValue * 60000);
|
||||
return (int) \round($pValue * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,7 +163,7 @@ class Drawing
|
|||
return 0;
|
||||
}
|
||||
|
||||
return round($pValue / 60000);
|
||||
return \round($pValue / 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -243,7 +243,7 @@ class Drawing
|
|||
return 0;
|
||||
}
|
||||
|
||||
return round($pValue / 15);
|
||||
return \round($pValue / 15);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -259,7 +259,7 @@ class Drawing
|
|||
return 0;
|
||||
}
|
||||
|
||||
return (int) round(($pValue / 0.75) / 9525);
|
||||
return (int) \round(($pValue / 0.75) / 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -272,20 +272,20 @@ class Drawing
|
|||
public static function htmlToRGB(string $pValue): ?array
|
||||
{
|
||||
if ($pValue[0] == '#') {
|
||||
$pValue = substr($pValue, 1);
|
||||
$pValue = \substr($pValue, 1);
|
||||
}
|
||||
|
||||
if (strlen($pValue) == 6) {
|
||||
if (\strlen($pValue) == 6) {
|
||||
list($colorR, $colorG, $colorB) = [$pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]];
|
||||
} elseif (strlen($pValue) == 3) {
|
||||
} elseif (\strlen($pValue) == 3) {
|
||||
list($colorR, $colorG, $colorB) = [$pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
$colorR = hexdec($colorR);
|
||||
$colorG = hexdec($colorG);
|
||||
$colorB = hexdec($colorB);
|
||||
$colorR = \hexdec($colorR);
|
||||
$colorG = \hexdec($colorG);
|
||||
$colorB = \hexdec($colorB);
|
||||
|
||||
return [$colorR, $colorG, $colorB];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,12 +33,12 @@ class File
|
|||
// 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') {
|
||||
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);
|
||||
$zipFile = \substr($pFilename, 6, \strpos($pFilename, '#') - 6);
|
||||
$archiveFile = \substr($pFilename, \strpos($pFilename, '#') + 1);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip = new \ZipArchive();
|
||||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = ($zip->getFromName($archiveFile) !== false);
|
||||
$zip->close();
|
||||
|
|
@ -50,7 +50,7 @@ class File
|
|||
}
|
||||
|
||||
// Regular file_exists
|
||||
return file_exists($pFilename);
|
||||
return \file_exists($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,12 +65,12 @@ class File
|
|||
if (!self::fileExists($pFilename)) {
|
||||
return null;
|
||||
}
|
||||
if (strtolower(substr($pFilename, 0, 3)) == 'zip') {
|
||||
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);
|
||||
$zipFile = \substr($pFilename, 6, \strpos($pFilename, '#') - 6);
|
||||
$archiveFile = \substr($pFilename, \strpos($pFilename, '#') + 1);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip = new \ZipArchive();
|
||||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = $zip->getFromName($archiveFile);
|
||||
$zip->close();
|
||||
|
|
@ -81,7 +81,7 @@ class File
|
|||
return null;
|
||||
}
|
||||
// Regular file contents
|
||||
return file_get_contents($pFilename);
|
||||
return \file_get_contents($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,13 +94,13 @@ class File
|
|||
public static function realpath(string $pFilename): string
|
||||
{
|
||||
// Try using realpath()
|
||||
$returnValue = realpath($pFilename);
|
||||
$returnValue = \realpath($pFilename);
|
||||
|
||||
// Found something?
|
||||
if (empty($returnValue)) {
|
||||
$pathArray = explode('/', $pFilename);
|
||||
while (in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
$numPathArray = count($pathArray);
|
||||
$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]);
|
||||
|
|
@ -109,7 +109,7 @@ class File
|
|||
}
|
||||
}
|
||||
}
|
||||
$returnValue = implode('/', $pathArray);
|
||||
$returnValue = \implode('/', $pathArray);
|
||||
}
|
||||
|
||||
// Return
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@
|
|||
|
||||
namespace PhpOffice\Common\Microsoft;
|
||||
|
||||
/*
|
||||
if (!defined('IDENTIFIER_OLE')) {
|
||||
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1));
|
||||
}
|
||||
*/
|
||||
|
||||
class OLERead
|
||||
{
|
||||
|
|
@ -29,7 +31,7 @@ class OLERead
|
|||
private $data = '';
|
||||
|
||||
// OLE identifier
|
||||
public const IDENTIFIER_OLE = IDENTIFIER_OLE;
|
||||
public const IDENTIFIER_OLE = "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1";
|
||||
|
||||
// Size of a sector = 512 bytes
|
||||
public const BIG_BLOCK_SIZE = 0x200;
|
||||
|
|
@ -105,24 +107,26 @@ class OLERead
|
|||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function read(string $sFileName): void
|
||||
public function read(string $sFileName): bool
|
||||
{
|
||||
// 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.');
|
||||
if (!\is_readable($sFileName)) {
|
||||
return false;
|
||||
//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);
|
||||
$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');
|
||||
return false;
|
||||
//throw new \Exception('The filename ' . $sFileName . ' is not recognized as an OLE file');
|
||||
}
|
||||
|
||||
// Get the file data
|
||||
$this->data = file_get_contents($sFileName);
|
||||
$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);
|
||||
|
|
@ -155,7 +159,7 @@ class OLERead
|
|||
|
||||
for ($j = 0; $j < $numExtensionBlocks; ++$j) {
|
||||
$pos = ($extensionBlock + 1) * self::BIG_BLOCK_SIZE;
|
||||
$blocksToRead = min($numBigBlkDepotBlks - $bbdBlocks, self::BIG_BLOCK_SIZE / 4 - 1);
|
||||
$blocksToRead = \min($numBigBlkDepotBlks - $bbdBlocks, self::BIG_BLOCK_SIZE / 4 - 1);
|
||||
|
||||
for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; ++$i) {
|
||||
$bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos);
|
||||
|
|
@ -173,7 +177,7 @@ class OLERead
|
|||
for ($i = 0; $i < $numBigBlkDepotBlks; ++$i) {
|
||||
$pos = ($bigBlockDepotBlocks[$i] + 1) * self::BIG_BLOCK_SIZE;
|
||||
|
||||
$this->bigBlockChain .= substr($this->data, $pos, 4 * $bbs);
|
||||
$this->bigBlockChain .= \substr($this->data, $pos, 4 * $bbs);
|
||||
$pos += 4 * $bbs;
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +186,7 @@ class OLERead
|
|||
while ($sbdBlock != -2) {
|
||||
$pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE;
|
||||
|
||||
$this->smallBlockChain .= substr($this->data, $pos, 4 * $bbs);
|
||||
$this->smallBlockChain .= \substr($this->data, $pos, 4 * $bbs);
|
||||
$pos += 4 * $bbs;
|
||||
|
||||
$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock * 4);
|
||||
|
|
@ -193,6 +197,8 @@ class OLERead
|
|||
$this->entry = $this->readData($block);
|
||||
|
||||
$this->readPropertySets();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -211,7 +217,7 @@ class OLERead
|
|||
|
||||
while ($block != -2) {
|
||||
$pos = $block * self::SMALL_BLOCK_SIZE;
|
||||
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
|
||||
$streamData .= \substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
|
||||
|
||||
$block = self::getInt4d($this->smallBlockChain, $block * 4);
|
||||
}
|
||||
|
|
@ -232,7 +238,7 @@ class OLERead
|
|||
|
||||
while ($block != -2) {
|
||||
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
|
||||
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$streamData .= \substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block * 4);
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +259,7 @@ class OLERead
|
|||
|
||||
while ($block != -2) {
|
||||
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
|
||||
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$data .= \substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block * 4);
|
||||
}
|
||||
|
||||
|
|
@ -268,16 +274,16 @@ class OLERead
|
|||
$offset = 0;
|
||||
|
||||
// loop through entires, each entry is 128 bytes
|
||||
$entryLen = strlen($this->entry);
|
||||
$entryLen = \strlen($this->entry);
|
||||
while ($offset < $entryLen) {
|
||||
// entry data (128 bytes)
|
||||
$data = substr($this->entry, $offset, self::PROPERTY_STORAGE_BLOCK_SIZE);
|
||||
$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);
|
||||
$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]);
|
||||
$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
|
||||
|
|
@ -285,7 +291,7 @@ class OLERead
|
|||
|
||||
$size = self::getInt4d($data, self::SIZE_POS);
|
||||
|
||||
$name = str_replace("\x00", '', substr($data, 0, $nameSize));
|
||||
$name = \str_replace("\x00", '', \substr($data, 0, $nameSize));
|
||||
if ($size > 0) {
|
||||
$this->props[] = [
|
||||
'name' => $name,
|
||||
|
|
@ -295,34 +301,35 @@ class OLERead
|
|||
];
|
||||
|
||||
// tmp helper to simplify checks
|
||||
$upName = strtoupper($name);
|
||||
$upName = \strtoupper($name);
|
||||
|
||||
switch ($upName) {
|
||||
case 'ROOT ENTRY':
|
||||
case 'R':
|
||||
$this->rootEntry = count($this->props) - 1;
|
||||
$this->rootEntry = \count($this->props) - 1;
|
||||
break;
|
||||
case chr(1) . 'COMPOBJ':
|
||||
case \chr(1) . 'COMPOBJ':
|
||||
break;
|
||||
case chr(1) . 'OLE':
|
||||
case \chr(1) . 'OLE':
|
||||
break;
|
||||
case chr(5) . 'SUMMARYINFORMATION':
|
||||
$this->summaryInformation = count($this->props) - 1;
|
||||
case \chr(5) . 'SUMMARYINFORMATION':
|
||||
$this->summaryInformation = \count($this->props) - 1;
|
||||
break;
|
||||
case chr(5) . 'DOCUMENTSUMMARYINFORMATION':
|
||||
$this->docSummaryInfos = count($this->props) - 1;
|
||||
case \chr(5) . 'DOCUMENTSUMMARYINFORMATION':
|
||||
$this->docSummaryInfos = \count($this->props) - 1;
|
||||
break;
|
||||
case 'CURRENT USER':
|
||||
$this->currentUser = count($this->props) - 1;
|
||||
$this->currentUser = \count($this->props) - 1;
|
||||
break;
|
||||
case 'PICTURES':
|
||||
$this->pictures = count($this->props) - 1;
|
||||
$this->pictures = \count($this->props) - 1;
|
||||
break;
|
||||
case 'POWERPOINT DOCUMENT':
|
||||
$this->powerpointDocument = count($this->props) - 1;
|
||||
$this->powerpointDocument = \count($this->props) - 1;
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('OLE Block Not defined: $upName : ' . $upName . ' - $name : "' . $name . '"');
|
||||
return;
|
||||
//throw new \Exception('OLE Block Not defined: $upName : ' . $upName . ' - $name : "' . $name . '"');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -343,14 +350,14 @@ class OLERead
|
|||
// 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]);
|
||||
$or24 = \ord($data[$pos + 3]);
|
||||
if ($or24 >= 128) {
|
||||
// negative number
|
||||
$ord24 = -abs((256 - $or24) << 24);
|
||||
$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;
|
||||
return \ord($data[$pos]) | (\ord($data[$pos + 1]) << 8) | (\ord($data[$pos + 2]) << 16) | $ord24;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,44 +116,44 @@ class PasswordEncoder
|
|||
*/
|
||||
public static function hashPassword(string $password, string $algorithmName = self::ALGORITHM_SHA_1, string $salt = null, int $spinCount = 10000)
|
||||
{
|
||||
$origEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('UTF-8');
|
||||
$origEncoding = \mb_internal_encoding();
|
||||
\mb_internal_encoding('UTF-8');
|
||||
|
||||
$password = mb_substr($password, 0, min(self::$passwordMaxLength, mb_strlen($password)));
|
||||
$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');
|
||||
$passUtf8 = \mb_convert_encoding($password, 'UCS-2LE', 'UTF-8');
|
||||
$byteChars = [];
|
||||
|
||||
for ($i = 0; $i < mb_strlen($password); ++$i) {
|
||||
$byteChars[$i] = ord(substr($passUtf8, $i * 2, 1));
|
||||
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));
|
||||
$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);
|
||||
$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');
|
||||
$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);
|
||||
$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 = \hash($algorithm, $generatedKey . \pack('CCCC', $i, $i >> 8, $i >> 16, $i >> 24), true);
|
||||
}
|
||||
$generatedKey = base64_encode($generatedKey);
|
||||
$generatedKey = \base64_encode($generatedKey);
|
||||
|
||||
mb_internal_encoding($origEncoding);
|
||||
\mb_internal_encoding($origEncoding);
|
||||
|
||||
return $generatedKey;
|
||||
}
|
||||
|
|
@ -196,7 +196,7 @@ class PasswordEncoder
|
|||
*/
|
||||
private static function buildCombinedKey(array $byteChars): int
|
||||
{
|
||||
$byteCharsLength = count($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];
|
||||
|
|
@ -231,7 +231,7 @@ class PasswordEncoder
|
|||
}
|
||||
|
||||
/**
|
||||
* Simulate behaviour of (signed) int32
|
||||
* Simulate behavior of (signed) int32
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ class Text
|
|||
{
|
||||
for ($i = 0; $i <= 19; ++$i) {
|
||||
if ($i != 9 && $i != 10 && $i != 13) {
|
||||
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
|
||||
$replace = chr($i);
|
||||
$find = '_x' . \sprintf('%04s', \strtoupper(\dechex($i))) . '_';
|
||||
$replace = \chr($i);
|
||||
self::$controlCharacters[$find] = $replace;
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ class Text
|
|||
self::buildControlCharacters();
|
||||
}
|
||||
|
||||
return str_replace(array_values(self::$controlCharacters), array_keys(self::$controlCharacters), $value);
|
||||
return \str_replace(\array_values(self::$controlCharacters), \array_keys(self::$controlCharacters), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -77,7 +77,7 @@ class Text
|
|||
*/
|
||||
public static function numberFormat(float $number, int $decimals): string
|
||||
{
|
||||
return number_format($number, $decimals, '.', '');
|
||||
return \number_format($number, $decimals, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,16 +92,16 @@ class Text
|
|||
public static function chr(int $dec): string
|
||||
{
|
||||
if ($dec <= 0x7F) {
|
||||
return chr($dec);
|
||||
return \chr($dec);
|
||||
}
|
||||
if ($dec <= 0x7FF) {
|
||||
return chr(($dec >> 6) + 192) . chr(($dec & 63) + 128);
|
||||
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);
|
||||
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 \chr(($dec >> 18) + 240) . \chr((($dec >> 12) & 63) + 128) . \chr((($dec >> 6) & 63) + 128) . \chr(($dec & 63) + 128);
|
||||
}
|
||||
|
||||
return '';
|
||||
|
|
@ -120,7 +120,7 @@ class Text
|
|||
self::buildControlCharacters();
|
||||
}
|
||||
|
||||
return str_replace(array_keys(self::$controlCharacters), array_values(self::$controlCharacters), $value);
|
||||
return \str_replace(\array_keys(self::$controlCharacters), \array_values(self::$controlCharacters), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -132,7 +132,7 @@ class Text
|
|||
*/
|
||||
public static function isUTF8(string $value = ''): bool
|
||||
{
|
||||
return is_string($value) && ($value === '' || preg_match('/^./su', $value) == 1);
|
||||
return \is_string($value) && ($value === '' || \preg_match('/^./su', $value) == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -144,8 +144,8 @@ class Text
|
|||
*/
|
||||
public static function toUTF8(?string $value = ''): ?string
|
||||
{
|
||||
if (!is_null($value) && !self::isUTF8($value)) {
|
||||
$value = utf8_encode($value);
|
||||
if (!\is_null($value) && !self::isUTF8($value)) {
|
||||
$value = \utf8_encode($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
|
@ -184,16 +184,16 @@ class Text
|
|||
$lookingFor = 1;
|
||||
|
||||
// Gets unicode for each character
|
||||
for ($i = 0; $i < strlen($text); ++$i) {
|
||||
$thisValue = ord($text[$i]);
|
||||
for ($i = 0; $i < \strlen($text); ++$i) {
|
||||
$thisValue = \ord($text[$i]);
|
||||
if ($thisValue < 128) {
|
||||
$unicode[] = $thisValue;
|
||||
} else {
|
||||
if (count($values) == 0) {
|
||||
if (\count($values) == 0) {
|
||||
$lookingFor = $thisValue < 224 ? 2 : 3;
|
||||
}
|
||||
$values[] = $thisValue;
|
||||
if (count($values) == $lookingFor) {
|
||||
if (\count($values) == $lookingFor) {
|
||||
if ($lookingFor == 3) {
|
||||
$number = (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64);
|
||||
} else {
|
||||
|
|
@ -225,7 +225,7 @@ class Text
|
|||
|
||||
foreach ($unicode as $value) {
|
||||
if ($value != 65279) {
|
||||
$entities .= $value > 127 ? '\uc0{\u' . $value . '}' : chr($value);
|
||||
$entities .= $value > 127 ? '\uc0{\u' . $value . '}' : \chr($value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -241,9 +241,9 @@ class Text
|
|||
*/
|
||||
public static function removeUnderscorePrefix(?string $value): string
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (substr($value, 0, 1) == '_') {
|
||||
$value = substr($value, 1);
|
||||
if (!\is_null($value)) {
|
||||
if (\substr($value, 0, 1) == '_') {
|
||||
$value = \substr($value, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ class XMLReader
|
|||
/**
|
||||
* DOMDocument object
|
||||
*
|
||||
* @var DOMDocument
|
||||
* @var \DOMDocument
|
||||
*/
|
||||
private $dom = null;
|
||||
|
||||
/**
|
||||
* DOMXpath object
|
||||
*
|
||||
* @var DOMXpath
|
||||
* @var \DOMXpath
|
||||
*/
|
||||
private $xpath = null;
|
||||
|
||||
|
|
@ -50,17 +50,17 @@ class XMLReader
|
|||
* @param string $zipFile
|
||||
* @param string $xmlFile
|
||||
*
|
||||
* @return DOMDocument|false
|
||||
* @return \DOMDocument|false
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getDomFromZip(string $zipFile, string $xmlFile)
|
||||
{
|
||||
if (file_exists($zipFile) === false) {
|
||||
if (\file_exists($zipFile) === false) {
|
||||
throw new \Exception('Cannot find archive file.');
|
||||
}
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip = new \ZipArchive();
|
||||
$zip->open($zipFile);
|
||||
$content = $zip->getFromName($xmlFile);
|
||||
$zip->close();
|
||||
|
|
@ -77,20 +77,20 @@ class XMLReader
|
|||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return DOMDocument
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function getDomFromString(string $content)
|
||||
{
|
||||
$originalLibXMLEntityValue = false;
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
$originalLibXMLEntityValue = libxml_disable_entity_loader(true);
|
||||
$originalLibXMLEntityValue = \libxml_disable_entity_loader(true);
|
||||
}
|
||||
|
||||
$this->dom = new DOMDocument();
|
||||
$this->dom = new \DOMDocument();
|
||||
$this->dom->loadXML($content);
|
||||
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
libxml_disable_entity_loader($originalLibXMLEntityValue);
|
||||
\libxml_disable_entity_loader($originalLibXMLEntityValue);
|
||||
}
|
||||
|
||||
return $this->dom;
|
||||
|
|
@ -100,20 +100,20 @@ class XMLReader
|
|||
* Get elements
|
||||
*
|
||||
* @param string $path
|
||||
* @param DOMElement $contextNode
|
||||
* @param \DOMElement $contextNode
|
||||
*
|
||||
* @return DOMNodeList<DOMElement>
|
||||
* @return \DOMNodeList<\DOMElement>
|
||||
*/
|
||||
public function getElements(string $path, DOMElement $contextNode = null)
|
||||
public function getElements(string $path, \DOMElement $contextNode = null)
|
||||
{
|
||||
if ($this->dom === null) {
|
||||
return new DOMNodeList();
|
||||
return new \DOMNodeList();
|
||||
}
|
||||
if ($this->xpath === null) {
|
||||
$this->xpath = new DOMXpath($this->dom);
|
||||
$this->xpath = new \DOMXpath($this->dom);
|
||||
}
|
||||
|
||||
if (is_null($contextNode)) {
|
||||
if (\is_null($contextNode)) {
|
||||
return $this->xpath->query($path);
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ class XMLReader
|
|||
throw new \InvalidArgumentException('Dom needs to be loaded before registering a namespace');
|
||||
}
|
||||
if ($this->xpath === null) {
|
||||
$this->xpath = new DOMXpath($this->dom);
|
||||
$this->xpath = new \DOMXpath($this->dom);
|
||||
}
|
||||
|
||||
return $this->xpath->registerNamespace($prefix, $namespaceURI);
|
||||
|
|
@ -146,15 +146,15 @@ class XMLReader
|
|||
* Get element
|
||||
*
|
||||
* @param string $path
|
||||
* @param DOMElement $contextNode
|
||||
* @param \DOMElement $contextNode
|
||||
*
|
||||
* @return DOMElement|null
|
||||
* @return \DOMElement|null
|
||||
*/
|
||||
public function getElement($path, DOMElement $contextNode = null): ?DOMElement
|
||||
public function getElement($path, \DOMElement $contextNode = null): ?\DOMElement
|
||||
{
|
||||
$elements = $this->getElements($path, $contextNode);
|
||||
if ($elements->length > 0) {
|
||||
return $elements->item(0) instanceof DOMElement ? $elements->item(0) : null;
|
||||
return $elements->item(0) instanceof \DOMElement ? $elements->item(0) : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -164,18 +164,18 @@ class XMLReader
|
|||
* Get element attribute
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param DOMElement $contextNode
|
||||
* @param \DOMElement $contextNode
|
||||
* @param string $path
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAttribute($attribute, DOMElement $contextNode = null, $path = 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 */
|
||||
/** @var \DOMElement $node Type hint */
|
||||
$node = $elements->item(0);
|
||||
$return = $node->getAttribute($attribute);
|
||||
}
|
||||
|
|
@ -192,11 +192,11 @@ class XMLReader
|
|||
* Get element value
|
||||
*
|
||||
* @param string $path
|
||||
* @param DOMElement $contextNode
|
||||
* @param \DOMElement $contextNode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getValue($path, DOMElement $contextNode = null)
|
||||
public function getValue($path, \DOMElement $contextNode = null)
|
||||
{
|
||||
$elements = $this->getElements($path, $contextNode);
|
||||
if ($elements->length > 0) {
|
||||
|
|
@ -210,11 +210,11 @@ class XMLReader
|
|||
* Count elements
|
||||
*
|
||||
* @param string $path
|
||||
* @param DOMElement $contextNode
|
||||
* @param \DOMElement $contextNode
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countElements($path, DOMElement $contextNode = null)
|
||||
public function countElements($path, \DOMElement $contextNode = null)
|
||||
{
|
||||
$elements = $this->getElements($path, $contextNode);
|
||||
|
||||
|
|
@ -225,11 +225,11 @@ class XMLReader
|
|||
* Element exists
|
||||
*
|
||||
* @param string $path
|
||||
* @param DOMElement $contextNode
|
||||
* @param \DOMElement $contextNode
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function elementExists($path, DOMElement $contextNode = null)
|
||||
public function elementExists($path, \DOMElement $contextNode = null)
|
||||
{
|
||||
return $this->getElements($path, $contextNode)->length > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ class XMLWriter extends \XMLWriter
|
|||
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
||||
$this->openMemory();
|
||||
} else {
|
||||
if ($pTemporaryStorageDir && !is_dir($pTemporaryStorageDir)) {
|
||||
$pTemporaryStorageDir = sys_get_temp_dir();
|
||||
if ($pTemporaryStorageDir && !\is_dir($pTemporaryStorageDir)) {
|
||||
$pTemporaryStorageDir = \sys_get_temp_dir();
|
||||
}
|
||||
// Create temporary filename
|
||||
$this->tempFileName = @tempnam($pTemporaryStorageDir, 'xml');
|
||||
$this->tempFileName = @\tempnam($pTemporaryStorageDir, 'xml');
|
||||
|
||||
// Open storage
|
||||
$this->openUri($this->tempFileName);
|
||||
|
|
@ -87,7 +87,7 @@ class XMLWriter extends \XMLWriter
|
|||
if (empty($this->tempFileName)) {
|
||||
return;
|
||||
}
|
||||
if (PHP_OS != 'WINNT' && @unlink($this->tempFileName) === false) {
|
||||
if (PHP_OS != 'WINNT' && @\unlink($this->tempFileName) === false) {
|
||||
throw new \Exception('The file ' . $this->tempFileName . ' could not be deleted.');
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ class XMLWriter extends \XMLWriter
|
|||
|
||||
$this->flush();
|
||||
|
||||
return file_get_contents($this->tempFileName);
|
||||
return \file_get_contents($this->tempFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -124,7 +124,7 @@ class XMLWriter extends \XMLWriter
|
|||
public function writeElementBlock(string $element, $attributes, string $value = null)
|
||||
{
|
||||
$this->startElement($element);
|
||||
if (!is_array($attributes)) {
|
||||
if (!\is_array($attributes)) {
|
||||
$attributes = [$attributes => $value];
|
||||
}
|
||||
foreach ($attributes as $attribute => $value) {
|
||||
|
|
@ -146,7 +146,7 @@ class XMLWriter extends \XMLWriter
|
|||
public function writeElementIf(bool $condition, string $element, ?string $attribute = null, $value = null)
|
||||
{
|
||||
if ($condition) {
|
||||
if (is_null($attribute)) {
|
||||
if (\is_null($attribute)) {
|
||||
$this->writeElement($element, $value);
|
||||
} else {
|
||||
$this->startElement($element);
|
||||
|
|
@ -180,8 +180,8 @@ class XMLWriter extends \XMLWriter
|
|||
*/
|
||||
public function writeAttribute($name, $value): bool
|
||||
{
|
||||
if (is_float($value)) {
|
||||
$value = json_encode($value);
|
||||
if (\is_float($value)) {
|
||||
$value = \json_encode($value);
|
||||
}
|
||||
|
||||
return parent::writeAttribute($name, $value ?? '');
|
||||
|
|
|
|||
|
|
@ -153,10 +153,10 @@ abstract class AbstractShape implements ComparableInterface
|
|||
*/
|
||||
public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideOld = false)
|
||||
{
|
||||
if (is_null($this->container)) {
|
||||
if (\is_null($this->container)) {
|
||||
// Add drawing to ShapeContainerInterface
|
||||
$this->container = $pValue;
|
||||
if (!is_null($this->container)) {
|
||||
if (!\is_null($this->container)) {
|
||||
$this->container->getShapeCollection()->append($this);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -345,7 +345,7 @@ abstract class AbstractShape implements ComparableInterface
|
|||
*/
|
||||
public function hasHyperlink()
|
||||
{
|
||||
return !is_null($this->hyperlink);
|
||||
return !\is_null($this->hyperlink);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -353,7 +353,7 @@ abstract class AbstractShape implements ComparableInterface
|
|||
*/
|
||||
public function getHyperlink(): Hyperlink
|
||||
{
|
||||
if (is_null($this->hyperlink)) {
|
||||
if (\is_null($this->hyperlink)) {
|
||||
$this->hyperlink = new Hyperlink();
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ abstract class AbstractShape implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
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__);
|
||||
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__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -412,7 +412,7 @@ abstract class AbstractShape implements ComparableInterface
|
|||
|
||||
public function isPlaceholder(): bool
|
||||
{
|
||||
return !is_null($this->placeholder);
|
||||
return !\is_null($this->placeholder);
|
||||
}
|
||||
|
||||
public function getPlaceholder(): ?Placeholder
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Autoloader
|
|||
*/
|
||||
public static function register(): void
|
||||
{
|
||||
spl_autoload_register([new self(), 'autoload']);
|
||||
\spl_autoload_register([new self(), 'autoload']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -41,14 +41,14 @@ class Autoloader
|
|||
*/
|
||||
public static function autoload(string $class): void
|
||||
{
|
||||
$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');
|
||||
$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) {
|
||||
return;
|
||||
}
|
||||
if (file_exists($file)) {
|
||||
if (\file_exists($file)) {
|
||||
/** @noinspection PhpIncludeInspection Dynamic includes */
|
||||
require_once $file;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,8 +117,8 @@ class DocumentProperties
|
|||
// Initialise values
|
||||
$this->creator = 'Unknown Creator';
|
||||
$this->lastModifiedBy = $this->creator;
|
||||
$this->created = time();
|
||||
$this->modified = time();
|
||||
$this->created = \time();
|
||||
$this->modified = \time();
|
||||
$this->title = 'Untitled Presentation';
|
||||
$this->subject = '';
|
||||
$this->description = '';
|
||||
|
|
@ -194,8 +194,8 @@ class DocumentProperties
|
|||
*/
|
||||
public function setCreated($pValue = null)
|
||||
{
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
if (\is_null($pValue)) {
|
||||
$pValue = \time();
|
||||
}
|
||||
$this->created = $pValue;
|
||||
|
||||
|
|
@ -221,8 +221,8 @@ class DocumentProperties
|
|||
*/
|
||||
public function setModified($pValue = null)
|
||||
{
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
if (\is_null($pValue)) {
|
||||
$pValue = \time();
|
||||
}
|
||||
$this->modified = $pValue;
|
||||
|
||||
|
|
@ -380,7 +380,7 @@ class DocumentProperties
|
|||
*/
|
||||
public function getCustomProperties(): array
|
||||
{
|
||||
return array_keys($this->customProperties);
|
||||
return \array_keys($this->customProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -443,18 +443,18 @@ class DocumentProperties
|
|||
*/
|
||||
public function setCustomProperty(string $propertyName, $propertyValue = '', ?string $propertyType = null): self
|
||||
{
|
||||
if (!in_array($propertyType, [
|
||||
if (!\in_array($propertyType, [
|
||||
self::PROPERTY_TYPE_INTEGER,
|
||||
self::PROPERTY_TYPE_FLOAT,
|
||||
self::PROPERTY_TYPE_STRING,
|
||||
self::PROPERTY_TYPE_DATE,
|
||||
self::PROPERTY_TYPE_BOOLEAN,
|
||||
])) {
|
||||
if (is_float($propertyValue)) {
|
||||
if (\is_float($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_FLOAT;
|
||||
} elseif (is_int($propertyValue)) {
|
||||
} elseif (\is_int($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_INTEGER;
|
||||
} elseif (is_bool($propertyValue)) {
|
||||
} elseif (\is_bool($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
|
||||
} else {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class DirectoryNotFoundException extends PhpPresentationException
|
|||
{
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The directory %s doesn\'t exist',
|
||||
$path
|
||||
));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class FileCopyException extends PhpPresentationException
|
|||
{
|
||||
public function __construct(string $source, string $destination)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The file %s can\'t be copied to %s',
|
||||
$source,
|
||||
$destination
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class FileNotFoundException extends PhpPresentationException
|
|||
{
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The file "%s" doesn\'t exist',
|
||||
$path
|
||||
));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class FileRemoveException extends PhpPresentationException
|
|||
{
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The file %s can\'t be removed',
|
||||
$path
|
||||
));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class InvalidClassException extends PhpPresentationException
|
|||
{
|
||||
public function __construct(string $class, string $error)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The class %s is invalid (%s)',
|
||||
$class,
|
||||
$error
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class InvalidFileFormatException extends PhpPresentationException
|
|||
$error = '(' . $error . ')';
|
||||
}
|
||||
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The file %s is not in the format supported by %s%s%s',
|
||||
$path,
|
||||
$class,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class InvalidParameterException extends PhpPresentationException
|
|||
{
|
||||
public function __construct(string $parameter, string $value)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The parameter %s can\'t have the value "%s"',
|
||||
$parameter,
|
||||
$value
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class OutOfBoundsException extends PhpPresentationException
|
|||
{
|
||||
public function __construct(int $minBounds, ?int $maxBounds, int $expectedBounds)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The expected value (%d) is out of bounds (%d, %s)',
|
||||
$expectedBounds,
|
||||
$minBounds,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@ namespace PhpOffice\PhpPresentation\Exception;
|
|||
|
||||
use Exception;
|
||||
|
||||
class PhpPresentationException extends Exception
|
||||
class PhpPresentationException extends \Exception
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ShapeContainerAlreadyAssignedException extends PhpPresentationException
|
|||
{
|
||||
public function __construct(string $class)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The shape %s has already a container assigned',
|
||||
$class
|
||||
));
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ class UnauthorizedMimetypeException extends PhpPresentationException
|
|||
*/
|
||||
public function __construct(string $expectedMimetype, array $authorizedMimetypes)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
parent::__construct(\sprintf(
|
||||
'The mime type %s is not found in autorized values (%s)',
|
||||
$expectedMimetype,
|
||||
implode(', ', $authorizedMimetypes)
|
||||
\implode(', ', $authorizedMimetypes)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class GeometryCalculator
|
|||
{
|
||||
$offsets = [self::X => 0, self::Y => 0];
|
||||
|
||||
if (null !== $container && 0 != count($container->getShapeCollection())) {
|
||||
if (null !== $container && 0 != \count($container->getShapeCollection())) {
|
||||
$shapes = $container->getShapeCollection();
|
||||
if (null !== $shapes[0]) {
|
||||
$offsets[self::X] = $shapes[0]->getOffsetX();
|
||||
|
|
@ -70,7 +70,7 @@ class GeometryCalculator
|
|||
/** @var array<string, int> $extents */
|
||||
$extents = [self::X => 0, self::Y => 0];
|
||||
|
||||
if (null !== $container && 0 != count($container->getShapeCollection())) {
|
||||
if (null !== $container && 0 != \count($container->getShapeCollection())) {
|
||||
$shapes = $container->getShapeCollection();
|
||||
if (null !== $shapes[0]) {
|
||||
$extents[self::X] = (int) ($shapes[0]->getOffsetX() + $shapes[0]->getWidth());
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class HashTable
|
|||
// Add value
|
||||
if (!isset($this->items[$hashCode])) {
|
||||
$this->items[$hashCode] = $pSource;
|
||||
$index = count($this->items) - 1;
|
||||
$index = \count($this->items) - 1;
|
||||
$this->keyMap[$index] = $hashCode;
|
||||
$pSource->setHashIndex($index);
|
||||
} else {
|
||||
|
|
@ -106,7 +106,7 @@ class HashTable
|
|||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->keyMap[count($this->keyMap) - 1]);
|
||||
unset($this->keyMap[\count($this->keyMap) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ class HashTable
|
|||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->items);
|
||||
return \count($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -134,7 +134,7 @@ class HashTable
|
|||
*/
|
||||
public function getIndexForHashCode(string $pHashCode = ''): int
|
||||
{
|
||||
$index = array_search($pHashCode, $this->keyMap);
|
||||
$index = \array_search($pHashCode, $this->keyMap);
|
||||
|
||||
return false === $index ? -1 : $index;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,13 +94,13 @@ class IOFactory
|
|||
*/
|
||||
private static function loadClass(string $class, string $type, PhpPresentation $phpPresentation = null)
|
||||
{
|
||||
if (!class_exists($class)) {
|
||||
if (!\class_exists($class)) {
|
||||
throw new InvalidClassException($class, $type . ': The class doesn\'t exist');
|
||||
}
|
||||
if (!self::isConcreteClass($class)) {
|
||||
throw new InvalidClassException($class, $type . ': The class is an abstract class or an interface');
|
||||
}
|
||||
if (is_null($phpPresentation)) {
|
||||
if (\is_null($phpPresentation)) {
|
||||
return new $class();
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ class IOFactory
|
|||
*/
|
||||
private static function isConcreteClass(string $class): bool
|
||||
{
|
||||
$reflection = new ReflectionClass($class);
|
||||
$reflection = new \ReflectionClass($class);
|
||||
|
||||
return !$reflection->isAbstract() && !$reflection->isInterface();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class PhpPresentation
|
|||
/**
|
||||
* Collection of Master Slides.
|
||||
*
|
||||
* @var array<int, SlideMaster>|ArrayObject<int, SlideMaster>
|
||||
* @var array<int, SlideMaster>|\ArrayObject<int, SlideMaster>
|
||||
*/
|
||||
protected $slideMasters;
|
||||
|
||||
|
|
@ -184,10 +184,10 @@ class PhpPresentation
|
|||
*/
|
||||
public function removeSlideByIndex(int $index = 0): self
|
||||
{
|
||||
if ($index > count($this->slideCollection) - 1) {
|
||||
throw new OutOfBoundsException(0, count($this->slideCollection) - 1, $index);
|
||||
if ($index > \count($this->slideCollection) - 1) {
|
||||
throw new OutOfBoundsException(0, \count($this->slideCollection) - 1, $index);
|
||||
}
|
||||
array_splice($this->slideCollection, $index, 1);
|
||||
\array_splice($this->slideCollection, $index, 1);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -201,8 +201,8 @@ class PhpPresentation
|
|||
*/
|
||||
public function getSlide(int $index = 0): Slide
|
||||
{
|
||||
if ($index > count($this->slideCollection) - 1) {
|
||||
throw new OutOfBoundsException(0, count($this->slideCollection) - 1, $index);
|
||||
if ($index > \count($this->slideCollection) - 1) {
|
||||
throw new OutOfBoundsException(0, \count($this->slideCollection) - 1, $index);
|
||||
}
|
||||
|
||||
return $this->slideCollection[$index];
|
||||
|
|
@ -240,7 +240,7 @@ class PhpPresentation
|
|||
*/
|
||||
public function getSlideCount(): int
|
||||
{
|
||||
return count($this->slideCollection);
|
||||
return \count($this->slideCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -262,8 +262,8 @@ class PhpPresentation
|
|||
*/
|
||||
public function setActiveSlideIndex(int $index = 0): Slide
|
||||
{
|
||||
if ($index > count($this->slideCollection) - 1) {
|
||||
throw new OutOfBoundsException(0, count($this->slideCollection) - 1, $index);
|
||||
if ($index > \count($this->slideCollection) - 1) {
|
||||
throw new OutOfBoundsException(0, \count($this->slideCollection) - 1, $index);
|
||||
}
|
||||
$this->activeSlideIndex = $index;
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ class PhpPresentation
|
|||
{
|
||||
$copied = clone $this;
|
||||
|
||||
$slideCount = count($this->slideCollection);
|
||||
$slideCount = \count($this->slideCollection);
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
$this->slideCollection[$i] = $this->slideCollection[$i]->copy();
|
||||
$this->slideCollection[$i]->rebindParent($this);
|
||||
|
|
@ -330,7 +330,7 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array<int, Slide\SlideMaster>|ArrayObject<int, Slide\SlideMaster>
|
||||
* @return array<int, Slide\SlideMaster>|\ArrayObject<int, Slide\SlideMaster>
|
||||
*/
|
||||
public function getAllMasterSlides()
|
||||
{
|
||||
|
|
@ -338,11 +338,11 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array<int, Slide\SlideMaster>|ArrayObject<int, Slide\SlideMaster> $slideMasters
|
||||
* @param array<int, Slide\SlideMaster>|\ArrayObject<int, Slide\SlideMaster> $slideMasters
|
||||
*/
|
||||
public function setAllMasterSlides($slideMasters = []): self
|
||||
{
|
||||
if ($slideMasters instanceof ArrayObject || is_array($slideMasters)) {
|
||||
if ($slideMasters instanceof \ArrayObject || \is_array($slideMasters)) {
|
||||
$this->slideMasters = $slideMasters;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class PresentationProperties
|
|||
*/
|
||||
public function setThumbnailPath(string $path = ''): self
|
||||
{
|
||||
if (file_exists($path)) {
|
||||
if (\file_exists($path)) {
|
||||
$this->thumbnail = $path;
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ class PresentationProperties
|
|||
*/
|
||||
public function setLastView(string $value = self::VIEW_SLIDE): self
|
||||
{
|
||||
if (in_array($value, $this->arrayView)) {
|
||||
if (\in_array($value, $this->arrayView)) {
|
||||
$this->lastView = $value;
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ class PresentationProperties
|
|||
*/
|
||||
public function setSlideshowType(string $value = self::SLIDESHOW_TYPE_PRESENT): self
|
||||
{
|
||||
if (in_array($value, $this->arraySlideshowTypes)) {
|
||||
if (\in_array($value, $this->arraySlideshowTypes)) {
|
||||
$this->slideshowType = $value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,16 +92,16 @@ class ODPresentation implements ReaderInterface
|
|||
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
if (!\file_exists($pFilename)) {
|
||||
throw new FileNotFoundException($pFilename);
|
||||
}
|
||||
|
||||
$oZip = new ZipArchive();
|
||||
$oZip = new \ZipArchive();
|
||||
// Is it a zip ?
|
||||
if (true === $oZip->open($pFilename)) {
|
||||
// Is it an OpenXML Document ?
|
||||
// Is it a Presentation ?
|
||||
if (is_array($oZip->statName('META-INF/manifest.xml')) && is_array($oZip->statName('mimetype')) && 'application/vnd.oasis.opendocument.presentation' == $oZip->getFromName('mimetype')) {
|
||||
if (\is_array($oZip->statName('META-INF/manifest.xml')) && \is_array($oZip->statName('mimetype')) && 'application/vnd.oasis.opendocument.presentation' == $oZip->getFromName('mimetype')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ class ODPresentation implements ReaderInterface
|
|||
$this->oPhpPresentation = new PhpPresentation();
|
||||
$this->oPhpPresentation->removeSlideByIndex();
|
||||
|
||||
$this->oZip = new ZipArchive();
|
||||
$this->oZip = new \ZipArchive();
|
||||
$this->oZip->open($pFilename);
|
||||
|
||||
$this->oXMLReader = new XMLReader();
|
||||
|
|
@ -174,12 +174,12 @@ class ODPresentation implements ReaderInterface
|
|||
$properties = $this->oPhpPresentation->getDocumentProperties();
|
||||
foreach ($arrayProperties as $path => $property) {
|
||||
$oElement = $this->oXMLReader->getElement($path);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
$value = $oElement->nodeValue;
|
||||
if (in_array($property, ['setCreated', 'setModified'])) {
|
||||
$dateTime = DateTime::createFromFormat(DateTime::W3C, $value);
|
||||
if (\in_array($property, ['setCreated', 'setModified'])) {
|
||||
$dateTime = \DateTime::createFromFormat(\DateTime::W3C, $value);
|
||||
if (!$dateTime) {
|
||||
$dateTime = new DateTime();
|
||||
$dateTime = new \DateTime();
|
||||
}
|
||||
$value = $dateTime->getTimestamp();
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
|
||||
foreach ($this->oXMLReader->getElements('/office:document-meta/office:meta/meta:user-defined') as $element) {
|
||||
if (!($element instanceof DOMElement)
|
||||
if (!($element instanceof \DOMElement)
|
||||
|| !$element->hasAttribute('meta:name')) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ class ODPresentation implements ReaderInterface
|
|||
$propertyType = DocumentProperties::PROPERTY_TYPE_BOOLEAN;
|
||||
break;
|
||||
case 'float':
|
||||
$propertyType = filter_var($propertyValue, FILTER_VALIDATE_INT) === false
|
||||
$propertyType = \filter_var($propertyValue, FILTER_VALIDATE_INT) === false
|
||||
? DocumentProperties::PROPERTY_TYPE_FLOAT
|
||||
: DocumentProperties::PROPERTY_TYPE_INTEGER;
|
||||
break;
|
||||
|
|
@ -222,12 +222,12 @@ class ODPresentation implements ReaderInterface
|
|||
protected function loadSlides(): void
|
||||
{
|
||||
foreach ($this->oXMLReader->getElements('/office:document-content/office:automatic-styles/*') as $oElement) {
|
||||
if ($oElement instanceof DOMElement && $oElement->hasAttribute('style:name')) {
|
||||
if ($oElement instanceof \DOMElement && $oElement->hasAttribute('style:name')) {
|
||||
$this->loadStyle($oElement);
|
||||
}
|
||||
}
|
||||
foreach ($this->oXMLReader->getElements('/office:document-content/office:body/office:presentation/draw:page') as $oElement) {
|
||||
if ($oElement instanceof DOMElement && 'draw:page' == $oElement->nodeName) {
|
||||
if ($oElement instanceof \DOMElement && 'draw:page' == $oElement->nodeName) {
|
||||
$this->loadSlide($oElement);
|
||||
}
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ class ODPresentation implements ReaderInterface
|
|||
protected function loadPresentationProperties(): void
|
||||
{
|
||||
$element = $this->oXMLReader->getElement('/office:document-content/office:body/office:presentation/presentation:settings');
|
||||
if ($element instanceof DOMElement) {
|
||||
if ($element instanceof \DOMElement) {
|
||||
if ($element->getAttribute('presentation:full-screen') === 'false') {
|
||||
$this->oPhpPresentation->getPresentationProperties()->setSlideshowType(PresentationProperties::SLIDESHOW_TYPE_BROWSE);
|
||||
}
|
||||
|
|
@ -246,26 +246,26 @@ class ODPresentation implements ReaderInterface
|
|||
/**
|
||||
* Extract style
|
||||
*/
|
||||
protected function loadStyle(DOMElement $nodeStyle): bool
|
||||
protected function loadStyle(\DOMElement $nodeStyle): bool
|
||||
{
|
||||
$keyStyle = $nodeStyle->getAttribute('style:name');
|
||||
|
||||
$nodeDrawingPageProps = $this->oXMLReader->getElement('style:drawing-page-properties', $nodeStyle);
|
||||
if ($nodeDrawingPageProps instanceof DOMElement) {
|
||||
if ($nodeDrawingPageProps instanceof \DOMElement) {
|
||||
// Read Background Color
|
||||
if ($nodeDrawingPageProps->hasAttribute('draw:fill-color') && 'solid' == $nodeDrawingPageProps->getAttribute('draw:fill')) {
|
||||
$oBackground = new \PhpOffice\PhpPresentation\Slide\Background\Color();
|
||||
$oColor = new Color();
|
||||
$oColor->setRGB(substr($nodeDrawingPageProps->getAttribute('draw:fill-color'), -6));
|
||||
$oColor->setRGB(\substr($nodeDrawingPageProps->getAttribute('draw:fill-color'), -6));
|
||||
$oBackground->setColor($oColor);
|
||||
}
|
||||
// Read Background Image
|
||||
if ('bitmap' == $nodeDrawingPageProps->getAttribute('draw:fill') && $nodeDrawingPageProps->hasAttribute('draw:fill-image-name')) {
|
||||
$nameStyle = $nodeDrawingPageProps->getAttribute('draw:fill-image-name');
|
||||
if (!empty($this->arrayCommonStyles[$nameStyle]) && 'image' == $this->arrayCommonStyles[$nameStyle]['type'] && !empty($this->arrayCommonStyles[$nameStyle]['path'])) {
|
||||
$tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderODPBkg');
|
||||
$tmpBkgImg = \tempnam(\sys_get_temp_dir(), 'PhpPresentationReaderODPBkg');
|
||||
$contentImg = $this->oZip->getFromName($this->arrayCommonStyles[$nameStyle]['path']);
|
||||
file_put_contents($tmpBkgImg, $contentImg);
|
||||
\file_put_contents($tmpBkgImg, $contentImg);
|
||||
|
||||
$oBackground = new Image();
|
||||
$oBackground->setPath($tmpBkgImg);
|
||||
|
|
@ -274,27 +274,27 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
|
||||
$nodeGraphicProps = $this->oXMLReader->getElement('style:graphic-properties', $nodeStyle);
|
||||
if ($nodeGraphicProps instanceof DOMElement) {
|
||||
if ($nodeGraphicProps instanceof \DOMElement) {
|
||||
// Read Shadow
|
||||
if ($nodeGraphicProps->hasAttribute('draw:shadow') && 'visible' == $nodeGraphicProps->getAttribute('draw:shadow')) {
|
||||
$oShadow = new Shadow();
|
||||
$oShadow->setVisible(true);
|
||||
if ($nodeGraphicProps->hasAttribute('draw:shadow-color')) {
|
||||
$oShadow->getColor()->setRGB(substr($nodeGraphicProps->getAttribute('draw:shadow-color'), -6));
|
||||
$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));
|
||||
$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 = (float) substr($nodeGraphicProps->getAttribute('draw:shadow-offset-x'), 0, -2);
|
||||
$offsetY = (float) substr($nodeGraphicProps->getAttribute('draw:shadow-offset-y'), 0, -2);
|
||||
$offsetX = (float) \substr($nodeGraphicProps->getAttribute('draw:shadow-offset-x'), 0, -2);
|
||||
$offsetY = (float) \substr($nodeGraphicProps->getAttribute('draw:shadow-offset-y'), 0, -2);
|
||||
$distance = 0;
|
||||
if (0 != $offsetX) {
|
||||
$distance = ($offsetX < 0 ? $offsetX * -1 : $offsetX);
|
||||
} elseif (0 != $offsetY) {
|
||||
$distance = ($offsetY < 0 ? $offsetY * -1 : $offsetY);
|
||||
}
|
||||
$oShadow->setDirection((int) rad2deg(atan2($offsetY, $offsetX)));
|
||||
$oShadow->setDirection((int) \rad2deg(\atan2($offsetY, $offsetX)));
|
||||
$oShadow->setDistance(CommonDrawing::centimetersToPixels($distance));
|
||||
}
|
||||
}
|
||||
|
|
@ -312,7 +312,7 @@ class ODPresentation implements ReaderInterface
|
|||
$oFill->setFillType(Fill::FILL_SOLID);
|
||||
if ($nodeGraphicProps->hasAttribute('draw:fill-color')) {
|
||||
$oColor = new Color();
|
||||
$oColor->setRGB(substr($nodeGraphicProps->getAttribute('draw:fill-color'), 1));
|
||||
$oColor->setRGB(\substr($nodeGraphicProps->getAttribute('draw:fill-color'), 1));
|
||||
$oFill->setStartColor($oColor);
|
||||
}
|
||||
break;
|
||||
|
|
@ -321,10 +321,10 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
|
||||
$nodeTextProperties = $this->oXMLReader->getElement('style:text-properties', $nodeStyle);
|
||||
if ($nodeTextProperties instanceof DOMElement) {
|
||||
if ($nodeTextProperties instanceof \DOMElement) {
|
||||
$oFont = new Font();
|
||||
if ($nodeTextProperties->hasAttribute('fo:color')) {
|
||||
$oFont->getColor()->setRGB(substr($nodeTextProperties->getAttribute('fo:color'), -6));
|
||||
$oFont->getColor()->setRGB(\substr($nodeTextProperties->getAttribute('fo:color'), -6));
|
||||
}
|
||||
// Font Latin
|
||||
if ($nodeTextProperties->hasAttribute('fo:font-family')) {
|
||||
|
|
@ -339,7 +339,7 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
if ($nodeTextProperties->hasAttribute('fo:font-size')) {
|
||||
$oFont
|
||||
->setSize((int) substr($nodeTextProperties->getAttribute('fo:font-size'), 0, -2))
|
||||
->setSize((int) \substr($nodeTextProperties->getAttribute('fo:font-size'), 0, -2))
|
||||
->setFormat(Font::FORMAT_LATIN);
|
||||
}
|
||||
// Font East Asian
|
||||
|
|
@ -355,7 +355,7 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
if ($nodeTextProperties->hasAttribute('style:font-size-asian')) {
|
||||
$oFont
|
||||
->setSize((int) substr($nodeTextProperties->getAttribute('style:font-size-asian'), 0, -2))
|
||||
->setSize((int) \substr($nodeTextProperties->getAttribute('style:font-size-asian'), 0, -2))
|
||||
->setFormat(Font::FORMAT_EAST_ASIAN);
|
||||
}
|
||||
// Font Complex Script
|
||||
|
|
@ -371,7 +371,7 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
if ($nodeTextProperties->hasAttribute('style:font-size-complex')) {
|
||||
$oFont
|
||||
->setSize((int) substr($nodeTextProperties->getAttribute('style:font-size-complex'), 0, -2))
|
||||
->setSize((int) \substr($nodeTextProperties->getAttribute('style:font-size-complex'), 0, -2))
|
||||
->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('style:script-type')) {
|
||||
|
|
@ -390,18 +390,18 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
|
||||
$nodeParagraphProps = $this->oXMLReader->getElement('style:paragraph-properties', $nodeStyle);
|
||||
if ($nodeParagraphProps instanceof DOMElement) {
|
||||
if ($nodeParagraphProps instanceof \DOMElement) {
|
||||
if ($nodeParagraphProps->hasAttribute('fo:line-height')) {
|
||||
$lineHeightUnit = $this->getExpressionUnit($nodeParagraphProps->getAttribute('fo:margin-bottom'));
|
||||
$lineSpacingMode = $lineHeightUnit == '%' ? Paragraph::LINE_SPACING_MODE_PERCENT : Paragraph::LINE_SPACING_MODE_POINT;
|
||||
$lineSpacing = $this->getExpressionValue($nodeParagraphProps->getAttribute('fo:margin-bottom'));
|
||||
}
|
||||
if ($nodeParagraphProps->hasAttribute('fo:margin-bottom')) {
|
||||
$spacingAfter = (float) substr($nodeParagraphProps->getAttribute('fo:margin-bottom'), 0, -2);
|
||||
$spacingAfter = (float) \substr($nodeParagraphProps->getAttribute('fo:margin-bottom'), 0, -2);
|
||||
$spacingAfter = CommonDrawing::centimetersToPoints($spacingAfter);
|
||||
}
|
||||
if ($nodeParagraphProps->hasAttribute('fo:margin-top')) {
|
||||
$spacingBefore = (float) substr($nodeParagraphProps->getAttribute('fo:margin-top'), 0, -2);
|
||||
$spacingBefore = (float) \substr($nodeParagraphProps->getAttribute('fo:margin-top'), 0, -2);
|
||||
$spacingBefore = CommonDrawing::centimetersToPoints($spacingBefore);
|
||||
}
|
||||
$oAlignment = new Alignment();
|
||||
|
|
@ -434,7 +434,7 @@ class ODPresentation implements ReaderInterface
|
|||
$oAlignment = new Alignment();
|
||||
$oBullet = new Bullet();
|
||||
$oBullet->setBulletType(Bullet::TYPE_NONE);
|
||||
if ($oNodeListLevel instanceof DOMElement) {
|
||||
if ($oNodeListLevel instanceof \DOMElement) {
|
||||
if ($oNodeListLevel->hasAttribute('text:level')) {
|
||||
$oAlignment->setLevel((int) $oNodeListLevel->getAttribute('text:level') - 1);
|
||||
}
|
||||
|
|
@ -444,19 +444,19 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
|
||||
$oNodeListProperties = $this->oXMLReader->getElement('style:list-level-properties', $oNodeListLevel);
|
||||
if ($oNodeListProperties instanceof DOMElement) {
|
||||
if ($oNodeListProperties instanceof \DOMElement) {
|
||||
if ($oNodeListProperties->hasAttribute('text:min-label-width')) {
|
||||
$oAlignment->setIndent(CommonDrawing::centimetersToPixels((float) substr($oNodeListProperties->getAttribute('text:min-label-width'), 0, -2)));
|
||||
$oAlignment->setIndent(CommonDrawing::centimetersToPixels((float) \substr($oNodeListProperties->getAttribute('text:min-label-width'), 0, -2)));
|
||||
}
|
||||
if ($oNodeListProperties->hasAttribute('text:space-before')) {
|
||||
$iSpaceBefore = CommonDrawing::centimetersToPixels((float) substr($oNodeListProperties->getAttribute('text:space-before'), 0, -2));
|
||||
$iSpaceBefore = CommonDrawing::centimetersToPixels((float) \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 instanceof \DOMElement) {
|
||||
if ($oNodeTextProperties->hasAttribute('fo:font-family')) {
|
||||
$oBullet->setBulletFont($oNodeTextProperties->getAttribute('fo:font-family'));
|
||||
}
|
||||
|
|
@ -489,7 +489,7 @@ class ODPresentation implements ReaderInterface
|
|||
/**
|
||||
* Read Slide
|
||||
*/
|
||||
protected function loadSlide(DOMElement $nodeSlide): bool
|
||||
protected function loadSlide(\DOMElement $nodeSlide): bool
|
||||
{
|
||||
// Core
|
||||
$this->oPhpPresentation->createSlide();
|
||||
|
|
@ -504,7 +504,7 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
}
|
||||
foreach ($this->oXMLReader->getElements('draw:frame', $nodeSlide) as $oNodeFrame) {
|
||||
if ($oNodeFrame instanceof DOMElement) {
|
||||
if ($oNodeFrame instanceof \DOMElement) {
|
||||
if ($this->oXMLReader->getElement('draw:image', $oNodeFrame)) {
|
||||
$this->loadShapeDrawing($oNodeFrame);
|
||||
continue;
|
||||
|
|
@ -522,20 +522,20 @@ class ODPresentation implements ReaderInterface
|
|||
/**
|
||||
* Read Shape Drawing
|
||||
*/
|
||||
protected function loadShapeDrawing(DOMElement $oNodeFrame): void
|
||||
protected function loadShapeDrawing(\DOMElement $oNodeFrame): void
|
||||
{
|
||||
// Core
|
||||
$mimetype = '';
|
||||
|
||||
$oNodeImage = $this->oXMLReader->getElement('draw:image', $oNodeFrame);
|
||||
if ($oNodeImage instanceof DOMElement) {
|
||||
if ($oNodeImage instanceof \DOMElement) {
|
||||
if ($oNodeImage->hasAttribute('loext:mime-type')) {
|
||||
$mimetype = $oNodeImage->getAttribute('loext:mime-type');
|
||||
}
|
||||
if ($oNodeImage->hasAttribute('xlink:href')) {
|
||||
$sFilename = $oNodeImage->getAttribute('xlink:href');
|
||||
// svm = StarView Metafile
|
||||
if ('svm' == pathinfo($sFilename, PATHINFO_EXTENSION)) {
|
||||
if ('svm' == \pathinfo($sFilename, PATHINFO_EXTENSION)) {
|
||||
return;
|
||||
}
|
||||
$imageFile = $this->oZip->getFromName($sFilename);
|
||||
|
|
@ -549,21 +549,21 @@ class ODPresentation implements ReaderInterface
|
|||
// Contents of file
|
||||
if (empty($mimetype)) {
|
||||
$shape = new Gd();
|
||||
$shape->setImageResource(imagecreatefromstring($imageFile));
|
||||
$shape->setImageResource(\imagecreatefromstring($imageFile));
|
||||
} else {
|
||||
$shape = new Base64();
|
||||
$shape->setData('data:' . $mimetype . ';base64,' . base64_encode($imageFile));
|
||||
$shape->setData('data:' . $mimetype . ';base64,' . \base64_encode($imageFile));
|
||||
}
|
||||
|
||||
$shape->getShadow()->setVisible(false);
|
||||
$shape->setName($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
|
||||
$shape->setDescription($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
|
||||
$shape->setResizeProportional(false);
|
||||
$shape->setWidth($oNodeFrame->hasAttribute('svg:width') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:width'), 0, -2)) : 0);
|
||||
$shape->setHeight($oNodeFrame->hasAttribute('svg:height') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:height'), 0, -2)) : 0);
|
||||
$shape->setWidth($oNodeFrame->hasAttribute('svg:width') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:width'), 0, -2)) : 0);
|
||||
$shape->setHeight($oNodeFrame->hasAttribute('svg:height') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:height'), 0, -2)) : 0);
|
||||
$shape->setResizeProportional(true);
|
||||
$shape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:x'), 0, -2)) : 0);
|
||||
$shape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:y'), 0, -2)) : 0);
|
||||
$shape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:x'), 0, -2)) : 0);
|
||||
$shape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:y'), 0, -2)) : 0);
|
||||
|
||||
if ($oNodeFrame->hasAttribute('draw:style-name')) {
|
||||
$keyStyle = $oNodeFrame->getAttribute('draw:style-name');
|
||||
|
|
@ -579,20 +579,20 @@ class ODPresentation implements ReaderInterface
|
|||
/**
|
||||
* Read Shape RichText
|
||||
*/
|
||||
protected function loadShapeRichText(DOMElement $oNodeFrame): void
|
||||
protected function loadShapeRichText(\DOMElement $oNodeFrame): void
|
||||
{
|
||||
// Core
|
||||
$oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
|
||||
$oShape->setParagraphs([]);
|
||||
|
||||
$oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:width'), 0, -2)) : 0);
|
||||
$oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:height'), 0, -2)) : 0);
|
||||
$oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:x'), 0, -2)) : 0);
|
||||
$oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:y'), 0, -2)) : 0);
|
||||
$oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:width'), 0, -2)) : 0);
|
||||
$oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:height'), 0, -2)) : 0);
|
||||
$oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:x'), 0, -2)) : 0);
|
||||
$oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:y'), 0, -2)) : 0);
|
||||
|
||||
foreach ($this->oXMLReader->getElements('draw:text-box/*', $oNodeFrame) as $oNodeParagraph) {
|
||||
$this->levelParagraph = 0;
|
||||
if ($oNodeParagraph instanceof DOMElement) {
|
||||
if ($oNodeParagraph instanceof \DOMElement) {
|
||||
if ('text:p' == $oNodeParagraph->nodeName) {
|
||||
$this->readParagraph($oShape, $oNodeParagraph);
|
||||
}
|
||||
|
|
@ -602,7 +602,7 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
}
|
||||
|
||||
if (count($oShape->getParagraphs()) > 0) {
|
||||
if (\count($oShape->getParagraphs()) > 0) {
|
||||
$oShape->setActiveParagraph(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -610,7 +610,7 @@ class ODPresentation implements ReaderInterface
|
|||
/**
|
||||
* Read Paragraph
|
||||
*/
|
||||
protected function readParagraph(RichText $oShape, DOMElement $oNodeParent): void
|
||||
protected function readParagraph(RichText $oShape, \DOMElement $oNodeParent): void
|
||||
{
|
||||
$oParagraph = $oShape->createParagraph();
|
||||
if ($oNodeParent->hasAttribute('text:style-name')) {
|
||||
|
|
@ -633,13 +633,13 @@ class ODPresentation implements ReaderInterface
|
|||
$oDomList = $this->oXMLReader->getElements('text:span', $oNodeParent);
|
||||
$oDomTextNodes = $this->oXMLReader->getElements('text()', $oNodeParent);
|
||||
foreach ($oDomTextNodes as $oDomTextNode) {
|
||||
if ('' != trim($oDomTextNode->nodeValue)) {
|
||||
if ('' != \trim($oDomTextNode->nodeValue)) {
|
||||
$oTextRun = $oParagraph->createTextRun();
|
||||
$oTextRun->setText(trim($oDomTextNode->nodeValue));
|
||||
$oTextRun->setText(\trim($oDomTextNode->nodeValue));
|
||||
}
|
||||
}
|
||||
foreach ($oDomList as $oNodeRichTextElement) {
|
||||
if ($oNodeRichTextElement instanceof DOMElement) {
|
||||
if ($oNodeRichTextElement instanceof \DOMElement) {
|
||||
$this->readParagraphItem($oParagraph, $oNodeRichTextElement);
|
||||
}
|
||||
}
|
||||
|
|
@ -648,7 +648,7 @@ class ODPresentation implements ReaderInterface
|
|||
/**
|
||||
* Read Paragraph Item
|
||||
*/
|
||||
protected function readParagraphItem(Paragraph $oParagraph, DOMElement $oNodeParent): void
|
||||
protected function readParagraphItem(Paragraph $oParagraph, \DOMElement $oNodeParent): void
|
||||
{
|
||||
if ($this->oXMLReader->elementExists('text:line-break', $oNodeParent)) {
|
||||
$oParagraph->createBreak();
|
||||
|
|
@ -661,7 +661,7 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
}
|
||||
$oTextRunLink = $this->oXMLReader->getElement('text:a', $oNodeParent);
|
||||
if ($oTextRunLink instanceof DOMElement) {
|
||||
if ($oTextRunLink instanceof \DOMElement) {
|
||||
$oTextRun->setText($oTextRunLink->nodeValue);
|
||||
if ($oTextRunLink->hasAttribute('xlink:href')) {
|
||||
$oTextRun->getHyperlink()->setUrl($oTextRunLink->getAttribute('xlink:href'));
|
||||
|
|
@ -675,10 +675,10 @@ class ODPresentation implements ReaderInterface
|
|||
/**
|
||||
* Read List
|
||||
*/
|
||||
protected function readList(RichText $oShape, DOMElement $oNodeParent): void
|
||||
protected function readList(RichText $oShape, \DOMElement $oNodeParent): void
|
||||
{
|
||||
foreach ($this->oXMLReader->getElements('text:list-item/*', $oNodeParent) as $oNodeListItem) {
|
||||
if ($oNodeListItem instanceof DOMElement) {
|
||||
if ($oNodeListItem instanceof \DOMElement) {
|
||||
if ('text:p' == $oNodeListItem->nodeName) {
|
||||
$this->readListItem($oShape, $oNodeListItem, $oNodeParent);
|
||||
}
|
||||
|
|
@ -694,7 +694,7 @@ class ODPresentation implements ReaderInterface
|
|||
/**
|
||||
* Read List Item
|
||||
*/
|
||||
protected function readListItem(RichText $oShape, DOMElement $oNodeParent, DOMElement $oNodeParagraph): void
|
||||
protected function readListItem(RichText $oShape, \DOMElement $oNodeParent, \DOMElement $oNodeParagraph): void
|
||||
{
|
||||
$oParagraph = $oShape->createParagraph();
|
||||
if ($oNodeParagraph->hasAttribute('text:style-name')) {
|
||||
|
|
@ -705,7 +705,7 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
}
|
||||
foreach ($this->oXMLReader->getElements('text:span', $oNodeParent) as $oNodeRichTextElement) {
|
||||
if ($oNodeRichTextElement instanceof DOMElement) {
|
||||
if ($oNodeRichTextElement instanceof \DOMElement) {
|
||||
$this->readParagraphItem($oParagraph, $oNodeRichTextElement);
|
||||
}
|
||||
}
|
||||
|
|
@ -717,7 +717,7 @@ class ODPresentation implements ReaderInterface
|
|||
protected function loadStylesFile(): void
|
||||
{
|
||||
foreach ($this->oXMLReader->getElements('/office:document-styles/office:styles/*') as $oElement) {
|
||||
if ($oElement instanceof DOMElement && 'draw:fill-image' == $oElement->nodeName) {
|
||||
if ($oElement instanceof \DOMElement && 'draw:fill-image' == $oElement->nodeName) {
|
||||
$this->arrayCommonStyles[$oElement->getAttribute('draw:name')] = [
|
||||
'type' => 'image',
|
||||
'path' => $oElement->hasAttribute('xlink:href') ? $oElement->getAttribute('xlink:href') : null,
|
||||
|
|
@ -733,11 +733,11 @@ class ODPresentation implements ReaderInterface
|
|||
*/
|
||||
private function getExpressionUnit(string $expr): string
|
||||
{
|
||||
if (substr($expr, -1) == '%') {
|
||||
if (\substr($expr, -1) == '%') {
|
||||
return '%';
|
||||
}
|
||||
|
||||
return substr($expr, -2);
|
||||
return \substr($expr, -2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -747,10 +747,10 @@ class ODPresentation implements ReaderInterface
|
|||
*/
|
||||
private function getExpressionValue(string $expr): string
|
||||
{
|
||||
if (substr($expr, -1) == '%') {
|
||||
return substr($expr, 0, -1);
|
||||
if (\substr($expr, -1) == '%') {
|
||||
return \substr($expr, 0, -1);
|
||||
}
|
||||
|
||||
return substr($expr, 0, -2);
|
||||
return \substr($expr, 0, -2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,16 +105,16 @@ class PowerPoint2007 implements ReaderInterface
|
|||
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
if (!\file_exists($pFilename)) {
|
||||
throw new FileNotFoundException($pFilename);
|
||||
}
|
||||
|
||||
$oZip = new ZipArchive();
|
||||
$oZip = new \ZipArchive();
|
||||
// Is it a zip ?
|
||||
if (true === $oZip->open($pFilename)) {
|
||||
// Is it an OpenXML Document ?
|
||||
// Is it a Presentation ?
|
||||
if (is_array($oZip->statName('[Content_Types].xml')) && is_array($oZip->statName('ppt/presentation.xml'))) {
|
||||
if (\is_array($oZip->statName('[Content_Types].xml')) && \is_array($oZip->statName('ppt/presentation.xml'))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$this->oPhpPresentation->setAllMasterSlides([]);
|
||||
$this->filename = $pFilename;
|
||||
|
||||
$this->oZip = new ZipArchive();
|
||||
$this->oZip = new \ZipArchive();
|
||||
$this->oZip->open($this->filename);
|
||||
$docPropsCore = $this->oZip->getFromName('docProps/core.xml');
|
||||
if (false !== $docPropsCore) {
|
||||
|
|
@ -187,7 +187,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
/* @phpstan-ignore-next-line */
|
||||
if ($xmlReader->getDomFromString($sPart)) {
|
||||
foreach ($xmlReader->getElements('/p:presentation/p:sldSz') as $oElement) {
|
||||
if (!($oElement instanceof DOMElement)) {
|
||||
if (!($oElement instanceof \DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
$type = $oElement->getAttribute('type');
|
||||
|
|
@ -227,9 +227,9 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$oProperties = $this->oPhpPresentation->getDocumentProperties();
|
||||
foreach ($arrayProperties as $path => $property) {
|
||||
$oElement = $xmlReader->getElement($path);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('xsi:type') && 'dcterms:W3CDTF' == $oElement->getAttribute('xsi:type')) {
|
||||
$dateTime = DateTime::createFromFormat(DateTime::W3C, $oElement->nodeValue);
|
||||
$dateTime = \DateTime::createFromFormat(\DateTime::W3C, $oElement->nodeValue);
|
||||
$oProperties->{$property}($dateTime->getTimestamp());
|
||||
} else {
|
||||
$oProperties->{$property}($oElement->nodeValue);
|
||||
|
|
@ -245,7 +245,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
protected function loadCustomProperties(string $sPart): void
|
||||
{
|
||||
$xmlReader = new XMLReader();
|
||||
$sPart = str_replace(' xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"', '', $sPart);
|
||||
$sPart = \str_replace(' xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"', '', $sPart);
|
||||
/* @phpstan-ignore-next-line */
|
||||
if ($xmlReader->getDomFromString($sPart)) {
|
||||
foreach ($xmlReader->getElements('/Properties/property[@fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"]') as $element) {
|
||||
|
|
@ -276,7 +276,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$propertyValue = $attributeTypeBoolean->nodeValue == 'true' ? true : false;
|
||||
} elseif ($attributeTypeDate) {
|
||||
$propertyType = DocumentProperties::PROPERTY_TYPE_DATE;
|
||||
$propertyValue = strtotime($attributeTypeDate->nodeValue);
|
||||
$propertyValue = \strtotime($attributeTypeDate->nodeValue);
|
||||
} else {
|
||||
$propertyType = DocumentProperties::PROPERTY_TYPE_STRING;
|
||||
$propertyValue = $attributeTypeString->nodeValue;
|
||||
|
|
@ -297,7 +297,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
/* @phpstan-ignore-next-line */
|
||||
if ($xmlReader->getDomFromString($sPart)) {
|
||||
$element = $xmlReader->getElement('/p:presentationPr/p:showPr');
|
||||
if ($element instanceof DOMElement) {
|
||||
if ($element instanceof \DOMElement) {
|
||||
if ($element->hasAttribute('loop')) {
|
||||
$this->oPhpPresentation->getPresentationProperties()->setLoopContinuouslyUntilEsc(
|
||||
(bool) $element->getAttribute('loop')
|
||||
|
|
@ -332,7 +332,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
if ($xmlReader->getDomFromString($sPart)) {
|
||||
$pathZoom = '/p:viewPr/p:slideViewPr/p:cSldViewPr/p:cViewPr/p:scale/a:sx';
|
||||
$oElement = $xmlReader->getElement($pathZoom);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('d') && $oElement->hasAttribute('n')) {
|
||||
$this->oPhpPresentation->getPresentationProperties()->setZoom($oElement->getAttribute('n') / $oElement->getAttribute('d'));
|
||||
}
|
||||
|
|
@ -354,7 +354,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$this->loadMasterSlides($xmlReader, $fileRels);
|
||||
// Continue with loading the slides
|
||||
foreach ($xmlReader->getElements('/p:presentation/p:sldIdLst/p:sldId') as $oElement) {
|
||||
if (!($oElement instanceof DOMElement)) {
|
||||
if (!($oElement instanceof \DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
$rId = $oElement->getAttribute('r:id');
|
||||
|
|
@ -362,12 +362,12 @@ class PowerPoint2007 implements ReaderInterface
|
|||
if (!empty($pathSlide)) {
|
||||
$pptSlide = $this->oZip->getFromName('ppt/' . $pathSlide);
|
||||
if (false !== $pptSlide) {
|
||||
$slideRels = 'ppt/slides/_rels/' . basename($pathSlide) . '.rels';
|
||||
$slideRels = 'ppt/slides/_rels/' . \basename($pathSlide) . '.rels';
|
||||
$this->loadRels($slideRels);
|
||||
$this->loadSlide($pptSlide, basename($pathSlide));
|
||||
$this->loadSlide($pptSlide, \basename($pathSlide));
|
||||
foreach ($this->arrayRels[$slideRels] as $rel) {
|
||||
if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide' == $rel['Type']) {
|
||||
$this->loadSlideNote(basename($rel['Target']), $this->oPhpPresentation->getActiveSlide());
|
||||
$this->loadSlideNote(\basename($rel['Target']), $this->oPhpPresentation->getActiveSlide());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -383,7 +383,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
{
|
||||
// Get all the MasterSlide Id's from the presentation.xml file
|
||||
foreach ($xmlReader->getElements('/p:presentation/p:sldMasterIdLst/p:sldMasterId') as $oElement) {
|
||||
if (!($oElement instanceof DOMElement)) {
|
||||
if (!($oElement instanceof \DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
$rId = $oElement->getAttribute('r:id');
|
||||
|
|
@ -393,8 +393,8 @@ class PowerPoint2007 implements ReaderInterface
|
|||
if (!empty($pathMasterSlide)) {
|
||||
$pptMasterSlide = $this->oZip->getFromName('ppt/' . $pathMasterSlide);
|
||||
if (false !== $pptMasterSlide) {
|
||||
$this->loadRels('ppt/slideMasters/_rels/' . basename($pathMasterSlide) . '.rels');
|
||||
$this->loadMasterSlide($pptMasterSlide, basename($pathMasterSlide));
|
||||
$this->loadRels('ppt/slideMasters/_rels/' . \basename($pathMasterSlide) . '.rels');
|
||||
$this->loadMasterSlide($pptMasterSlide, \basename($pathMasterSlide));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -415,9 +415,9 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
// Background
|
||||
$oElement = $xmlReader->getElement('/p:sld/p:cSld/p:bg/p:bgPr');
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
$oElementColor = $xmlReader->getElement('a:solidFill/a:srgbClr', $oElement);
|
||||
if ($oElementColor instanceof DOMElement) {
|
||||
if ($oElementColor instanceof \DOMElement) {
|
||||
// Color
|
||||
$oColor = new Color();
|
||||
$oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
|
||||
|
|
@ -429,7 +429,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$oSlide->setBackground($oBackground);
|
||||
}
|
||||
$oElementColor = $xmlReader->getElement('a:solidFill/a:schemeClr', $oElement);
|
||||
if ($oElementColor instanceof DOMElement) {
|
||||
if ($oElementColor instanceof \DOMElement) {
|
||||
// Color
|
||||
$oColor = new SchemeColor();
|
||||
$oColor->setValue($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
|
||||
|
|
@ -441,23 +441,23 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$oSlide->setBackground($oBackground);
|
||||
}
|
||||
$oElementImage = $xmlReader->getElement('a:blipFill/a:blip', $oElement);
|
||||
if ($oElementImage instanceof DOMElement) {
|
||||
if ($oElementImage instanceof \DOMElement) {
|
||||
$relImg = $this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'][$oElementImage->getAttribute('r:embed')];
|
||||
if (is_array($relImg)) {
|
||||
if (\is_array($relImg)) {
|
||||
// File
|
||||
$pathImage = 'ppt/slides/' . $relImg['Target'];
|
||||
$pathImage = explode('/', $pathImage);
|
||||
$pathImage = \explode('/', $pathImage);
|
||||
foreach ($pathImage as $key => $partPath) {
|
||||
if ('..' == $partPath) {
|
||||
unset($pathImage[$key - 1]);
|
||||
unset($pathImage[$key]);
|
||||
}
|
||||
}
|
||||
$pathImage = implode('/', $pathImage);
|
||||
$pathImage = \implode('/', $pathImage);
|
||||
$contentImg = $this->oZip->getFromName($pathImage);
|
||||
|
||||
$tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg');
|
||||
file_put_contents($tmpBkgImg, $contentImg);
|
||||
$tmpBkgImg = \tempnam(\sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg');
|
||||
\file_put_contents($tmpBkgImg, $contentImg);
|
||||
// Background
|
||||
$oBackground = new Slide\Background\Image();
|
||||
$oBackground->setPath($tmpBkgImg);
|
||||
|
|
@ -476,8 +476,8 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$oSlide = $this->oPhpPresentation->getActiveSlide();
|
||||
foreach ($this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'] as $valueRel) {
|
||||
if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout' == $valueRel['Type']) {
|
||||
$layoutBasename = basename($valueRel['Target']);
|
||||
if (array_key_exists($layoutBasename, $this->arraySlideLayouts)) {
|
||||
$layoutBasename = \basename($valueRel['Target']);
|
||||
if (\array_key_exists($layoutBasename, $this->arraySlideLayouts)) {
|
||||
$oSlide->setSlideLayout($this->arraySlideLayouts[$layoutBasename]);
|
||||
}
|
||||
break;
|
||||
|
|
@ -498,7 +498,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
// Background
|
||||
$oElement = $xmlReader->getElement('/p:sldMaster/p:cSld/p:bg');
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
$this->loadSlideBackground($xmlReader, $oElement, $oSlideMaster);
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
foreach ($arrayElementTxStyles as $oElementTxStyle) {
|
||||
$arrayElementsLvl = $xmlReader->getElements('/p:sldMaster/p:txStyles/' . $oElementTxStyle->nodeName . '/*');
|
||||
foreach ($arrayElementsLvl as $oElementLvl) {
|
||||
if (!($oElementLvl instanceof DOMElement) || 'a:extLst' == $oElementLvl->nodeName) {
|
||||
if (!($oElementLvl instanceof \DOMElement) || 'a:extLst' == $oElementLvl->nodeName) {
|
||||
continue;
|
||||
}
|
||||
$oRTParagraph = new Paragraph();
|
||||
|
|
@ -531,9 +531,9 @@ class PowerPoint2007 implements ReaderInterface
|
|||
if ('a:defPPr' == $oElementLvl->nodeName) {
|
||||
$level = 0;
|
||||
} else {
|
||||
$level = str_replace('a:lvl', '', $oElementLvl->nodeName);
|
||||
$level = str_replace('pPr', '', $level);
|
||||
$level = intval($level);
|
||||
$level = \str_replace('a:lvl', '', $oElementLvl->nodeName);
|
||||
$level = \str_replace('pPr', '', $level);
|
||||
$level = \intval($level);
|
||||
}
|
||||
|
||||
if ($oElementLvl->hasAttribute('algn')) {
|
||||
|
|
@ -555,7 +555,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$oRTParagraph->getAlignment()->setIndent($val);
|
||||
}
|
||||
$oElementLvlDefRPR = $xmlReader->getElement('a:defRPr', $oElementLvl);
|
||||
if ($oElementLvlDefRPR instanceof DOMElement) {
|
||||
if ($oElementLvlDefRPR instanceof \DOMElement) {
|
||||
if ($oElementLvlDefRPR->hasAttribute('sz')) {
|
||||
$oRTParagraph->getFont()->setSize($oElementLvlDefRPR->getAttribute('sz') / 100);
|
||||
}
|
||||
|
|
@ -567,7 +567,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
}
|
||||
$oElementSchemeColor = $xmlReader->getElement('a:defRPr/a:solidFill/a:schemeClr', $oElementLvl);
|
||||
if ($oElementSchemeColor instanceof DOMElement) {
|
||||
if ($oElementSchemeColor instanceof \DOMElement) {
|
||||
if ($oElementSchemeColor->hasAttribute('val')) {
|
||||
$oSchemeColor = new SchemeColor();
|
||||
$oSchemeColor->setValue($oElementSchemeColor->getAttribute('val'));
|
||||
|
|
@ -592,7 +592,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
// Load the theme
|
||||
foreach ($this->arrayRels[$oSlideMaster->getRelsIndex()] as $arrayRel) {
|
||||
if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme' == $arrayRel['Type']) {
|
||||
$pptTheme = $this->oZip->getFromName('ppt/' . substr($arrayRel['Target'], strrpos($arrayRel['Target'], '../') + 3));
|
||||
$pptTheme = $this->oZip->getFromName('ppt/' . \substr($arrayRel['Target'], \strrpos($arrayRel['Target'], '../') + 3));
|
||||
if (false !== $pptTheme) {
|
||||
$this->loadTheme($pptTheme, $oSlideMaster);
|
||||
}
|
||||
|
|
@ -602,7 +602,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
// Load the Layoutslide
|
||||
foreach ($xmlReader->getElements('/p:sldMaster/p:sldLayoutIdLst/p:sldLayoutId') as $oElement) {
|
||||
if (!($oElement instanceof DOMElement)) {
|
||||
if (!($oElement instanceof \DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
$rId = $oElement->getAttribute('r:id');
|
||||
|
|
@ -610,11 +610,11 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$pathLayoutSlide = isset($this->arrayRels[$oSlideMaster->getRelsIndex()][$rId]) ?
|
||||
$this->arrayRels[$oSlideMaster->getRelsIndex()][$rId]['Target'] : '';
|
||||
if (!empty($pathLayoutSlide)) {
|
||||
$pptLayoutSlide = $this->oZip->getFromName('ppt/' . substr($pathLayoutSlide, strrpos($pathLayoutSlide, '../') + 3));
|
||||
$pptLayoutSlide = $this->oZip->getFromName('ppt/' . \substr($pathLayoutSlide, \strrpos($pathLayoutSlide, '../') + 3));
|
||||
if (false !== $pptLayoutSlide) {
|
||||
$this->loadRels('ppt/slideLayouts/_rels/' . basename($pathLayoutSlide) . '.rels');
|
||||
$this->loadRels('ppt/slideLayouts/_rels/' . \basename($pathLayoutSlide) . '.rels');
|
||||
$oSlideMaster->addSlideLayout(
|
||||
$this->loadLayoutSlide($pptLayoutSlide, basename($pathLayoutSlide), $oSlideMaster)
|
||||
$this->loadLayoutSlide($pptLayoutSlide, \basename($pathLayoutSlide), $oSlideMaster)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -633,19 +633,19 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
// Name
|
||||
$oElement = $xmlReader->getElement('/p:sldLayout/p:cSld');
|
||||
if ($oElement instanceof DOMElement && $oElement->hasAttribute('name')) {
|
||||
if ($oElement instanceof \DOMElement && $oElement->hasAttribute('name')) {
|
||||
$oSlideLayout->setLayoutName($oElement->getAttribute('name'));
|
||||
}
|
||||
|
||||
// Background
|
||||
$oElement = $xmlReader->getElement('/p:sldLayout/p:cSld/p:bg');
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
$this->loadSlideBackground($xmlReader, $oElement, $oSlideLayout);
|
||||
}
|
||||
|
||||
// ColorMapping
|
||||
$oElement = $xmlReader->getElement('/p:sldLayout/p:clrMapOvr/a:overrideClrMapping');
|
||||
if ($oElement instanceof DOMElement && $oElement->hasAttributes()) {
|
||||
if ($oElement instanceof \DOMElement && $oElement->hasAttributes()) {
|
||||
$colorMap = [];
|
||||
foreach ($oElement->attributes as $attr) {
|
||||
$colorMap[$attr->nodeName] = $attr->nodeValue;
|
||||
|
|
@ -671,11 +671,11 @@ class PowerPoint2007 implements ReaderInterface
|
|||
if ($xmlReader->getDomFromString($sPart)) {
|
||||
$oElements = $xmlReader->getElements('/a:theme/a:themeElements/a:clrScheme/*');
|
||||
foreach ($oElements as $oElement) {
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
$oSchemeColor = new SchemeColor();
|
||||
$oSchemeColor->setValue(str_replace('a:', '', $oElement->tagName));
|
||||
$oSchemeColor->setValue(\str_replace('a:', '', $oElement->tagName));
|
||||
$colorElement = $xmlReader->getElement('*', $oElement);
|
||||
if ($colorElement instanceof DOMElement) {
|
||||
if ($colorElement instanceof \DOMElement) {
|
||||
if ($colorElement->hasAttribute('lastClr')) {
|
||||
$oSchemeColor->setRGB($colorElement->getAttribute('lastClr'));
|
||||
} elseif ($colorElement->hasAttribute('val')) {
|
||||
|
|
@ -688,11 +688,11 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
}
|
||||
|
||||
protected function loadSlideBackground(XMLReader $xmlReader, DOMElement $oElement, AbstractSlide $oSlide): void
|
||||
protected function loadSlideBackground(XMLReader $xmlReader, \DOMElement $oElement, AbstractSlide $oSlide): void
|
||||
{
|
||||
// Background color
|
||||
$oElementColor = $xmlReader->getElement('p:bgPr/a:solidFill/a:srgbClr', $oElement);
|
||||
if ($oElementColor instanceof DOMElement) {
|
||||
if ($oElementColor instanceof \DOMElement) {
|
||||
// Color
|
||||
$oColor = new Color();
|
||||
$oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
|
||||
|
|
@ -705,7 +705,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
// Background scheme color
|
||||
$oElementSchemeColor = $xmlReader->getElement('p:bgRef/a:schemeClr', $oElement);
|
||||
if ($oElementSchemeColor instanceof DOMElement) {
|
||||
if ($oElementSchemeColor instanceof \DOMElement) {
|
||||
// Color
|
||||
$oColor = new SchemeColor();
|
||||
$oColor->setValue($oElementSchemeColor->hasAttribute('val') ? $oElementSchemeColor->getAttribute('val') : null);
|
||||
|
|
@ -718,23 +718,23 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
// Background image
|
||||
$oElementImage = $xmlReader->getElement('p:bgPr/a:blipFill/a:blip', $oElement);
|
||||
if ($oElementImage instanceof DOMElement) {
|
||||
if ($oElementImage instanceof \DOMElement) {
|
||||
$relImg = $this->arrayRels[$oSlide->getRelsIndex()][$oElementImage->getAttribute('r:embed')];
|
||||
if (is_array($relImg)) {
|
||||
if (\is_array($relImg)) {
|
||||
// File
|
||||
$pathImage = 'ppt/slides/' . $relImg['Target'];
|
||||
$pathImage = explode('/', $pathImage);
|
||||
$pathImage = \explode('/', $pathImage);
|
||||
foreach ($pathImage as $key => $partPath) {
|
||||
if ('..' == $partPath) {
|
||||
unset($pathImage[$key - 1]);
|
||||
unset($pathImage[$key]);
|
||||
}
|
||||
}
|
||||
$pathImage = implode('/', $pathImage);
|
||||
$pathImage = \implode('/', $pathImage);
|
||||
$contentImg = $this->oZip->getFromName($pathImage);
|
||||
|
||||
$tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg');
|
||||
file_put_contents($tmpBkgImg, $contentImg);
|
||||
$tmpBkgImg = \tempnam(\sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg');
|
||||
\file_put_contents($tmpBkgImg, $contentImg);
|
||||
// Background
|
||||
$oBackground = new Slide\Background\Image();
|
||||
$oBackground->setPath($tmpBkgImg);
|
||||
|
|
@ -757,7 +757,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
}
|
||||
|
||||
protected function loadShapeDrawing(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void
|
||||
protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide): void
|
||||
{
|
||||
// Core
|
||||
$document->registerNamespace('asvg', 'http://schemas.microsoft.com/office/drawing/2016/SVG/main');
|
||||
|
|
@ -771,13 +771,13 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$fileRels = $oSlide->getRelsIndex();
|
||||
|
||||
$oElement = $document->getElement('p:nvPicPr/p:cNvPr', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
$oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : '');
|
||||
$oShape->setDescription($oElement->hasAttribute('descr') ? $oElement->getAttribute('descr') : '');
|
||||
|
||||
// Hyperlink
|
||||
$oElementHlinkClick = $document->getElement('a:hlinkClick', $oElement);
|
||||
if (is_object($oElementHlinkClick)) {
|
||||
if (\is_object($oElementHlinkClick)) {
|
||||
$oShape->setHyperlink(
|
||||
$this->loadHyperlink($document, $oElementHlinkClick, $oShape->getHyperlink())
|
||||
);
|
||||
|
|
@ -785,46 +785,46 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElement = $document->getElement('p:blipFill/a:blip', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('r:embed') && isset($this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target'])) {
|
||||
$pathImage = 'ppt/slides/' . $this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target'];
|
||||
$pathImage = explode('/', $pathImage);
|
||||
$pathImage = \explode('/', $pathImage);
|
||||
foreach ($pathImage as $key => $partPath) {
|
||||
if ('..' == $partPath) {
|
||||
unset($pathImage[$key - 1]);
|
||||
unset($pathImage[$key]);
|
||||
}
|
||||
}
|
||||
$pathImage = implode('/', $pathImage);
|
||||
$pathImage = \implode('/', $pathImage);
|
||||
$imageFile = $this->oZip->getFromName($pathImage);
|
||||
if (!empty($imageFile)) {
|
||||
if ($oShape instanceof Gd) {
|
||||
$info = getimagesizefromstring($imageFile);
|
||||
$info = \getimagesizefromstring($imageFile);
|
||||
$oShape->setMimeType($info['mime']);
|
||||
$oShape->setRenderingFunction(str_replace('/', '', $info['mime']));
|
||||
$oShape->setImageResource(imagecreatefromstring($imageFile));
|
||||
$oShape->setRenderingFunction(\str_replace('/', '', $info['mime']));
|
||||
$oShape->setImageResource(\imagecreatefromstring($imageFile));
|
||||
} elseif ($oShape instanceof Base64) {
|
||||
$oShape->setData('data:image/svg+xml;base64,' . base64_encode($imageFile));
|
||||
$oShape->setData('data:image/svg+xml;base64,' . \base64_encode($imageFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oElement = $document->getElement('p:spPr', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
$oFill = $this->loadStyleFill($document, $oElement);
|
||||
$oShape->setFill($oFill);
|
||||
}
|
||||
|
||||
$oElement = $document->getElement('p:spPr/a:xfrm', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('rot')) {
|
||||
$oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot')));
|
||||
}
|
||||
}
|
||||
|
||||
$oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('x')) {
|
||||
$oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x')));
|
||||
}
|
||||
|
|
@ -834,7 +834,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('cx')) {
|
||||
$oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx')));
|
||||
}
|
||||
|
|
@ -844,11 +844,11 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElement = $document->getElement('p:spPr/a:effectLst', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
$oShape->getShadow()->setVisible(true);
|
||||
|
||||
$oSubElement = $document->getElement('a:outerShdw', $oElement);
|
||||
if ($oSubElement instanceof DOMElement) {
|
||||
if ($oSubElement instanceof \DOMElement) {
|
||||
if ($oSubElement->hasAttribute('blurRad')) {
|
||||
$oShape->getShadow()->setBlurRadius(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('blurRad')));
|
||||
}
|
||||
|
|
@ -864,7 +864,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oSubElement = $document->getElement('a:outerShdw/a:srgbClr', $oElement);
|
||||
if ($oSubElement instanceof DOMElement) {
|
||||
if ($oSubElement instanceof \DOMElement) {
|
||||
if ($oSubElement->hasAttribute('val')) {
|
||||
$oColor = new Color();
|
||||
$oColor->setRGB($oSubElement->getAttribute('val'));
|
||||
|
|
@ -873,7 +873,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oSubElement = $document->getElement('a:outerShdw/a:srgbClr/a:alpha', $oElement);
|
||||
if ($oSubElement instanceof DOMElement) {
|
||||
if ($oSubElement instanceof \DOMElement) {
|
||||
if ($oSubElement->hasAttribute('val')) {
|
||||
$oShape->getShadow()->setAlpha((int) $oSubElement->getAttribute('val') / 1000);
|
||||
}
|
||||
|
|
@ -883,7 +883,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$oSlide->addShape($oShape);
|
||||
}
|
||||
|
||||
protected function loadShapeRichText(XMLReader $document, DOMElement $node, $oSlide): void
|
||||
protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $oSlide): void
|
||||
{
|
||||
if (!$document->elementExists('p:txBody/a:p/a:r', $node) || !$oSlide instanceof AbstractSlide) {
|
||||
return;
|
||||
|
|
@ -897,12 +897,12 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElement = $document->getElement('p:spPr/a:xfrm', $node);
|
||||
if ($oElement instanceof DOMElement && $oElement->hasAttribute('rot')) {
|
||||
if ($oElement instanceof \DOMElement && $oElement->hasAttribute('rot')) {
|
||||
$oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot')));
|
||||
}
|
||||
|
||||
$oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('x')) {
|
||||
$oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x')));
|
||||
}
|
||||
|
|
@ -912,7 +912,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('cx')) {
|
||||
$oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx')));
|
||||
}
|
||||
|
|
@ -922,7 +922,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElement = $document->getElement('p:nvSpPr/p:nvPr/p:ph', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('type')) {
|
||||
$placeholder = new Placeholder($oElement->getAttribute('type'));
|
||||
$oShape->setPlaceHolder($placeholder);
|
||||
|
|
@ -931,24 +931,24 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
$arrayElements = $document->getElements('p:txBody/a:p', $node);
|
||||
foreach ($arrayElements as $oElement) {
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
$this->loadParagraph($document, $oElement, $oShape);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($oShape->getParagraphs()) > 0) {
|
||||
if (\count($oShape->getParagraphs()) > 0) {
|
||||
$oShape->setActiveParagraph(0);
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadShapeTable(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void
|
||||
protected function loadShapeTable(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide): void
|
||||
{
|
||||
$this->fileRels = $oSlide->getRelsIndex();
|
||||
|
||||
$oShape = $oSlide->createTableShape();
|
||||
|
||||
$oElement = $document->getElement('p:cNvPr', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('name')) {
|
||||
$oShape->setName($oElement->getAttribute('name'));
|
||||
}
|
||||
|
|
@ -958,7 +958,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElement = $document->getElement('p:xfrm/a:off', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('x')) {
|
||||
$oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x')));
|
||||
}
|
||||
|
|
@ -968,7 +968,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElement = $document->getElement('p:xfrm/a:ext', $node);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if ($oElement->hasAttribute('cx')) {
|
||||
$oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx')));
|
||||
}
|
||||
|
|
@ -981,14 +981,14 @@ class PowerPoint2007 implements ReaderInterface
|
|||
$oShape->setNumColumns($arrayElements->length);
|
||||
$oShape->createRow();
|
||||
foreach ($arrayElements as $key => $oElement) {
|
||||
if ($oElement instanceof DOMElement && $oElement->getAttribute('w')) {
|
||||
if ($oElement instanceof \DOMElement && $oElement->getAttribute('w')) {
|
||||
$oShape->getRow(0)->getCell($key)->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('w')));
|
||||
}
|
||||
}
|
||||
|
||||
$arrayElements = $document->getElements('a:graphic/a:graphicData/a:tbl/a:tr', $node);
|
||||
foreach ($arrayElements as $keyRow => $oElementRow) {
|
||||
if (!($oElementRow instanceof DOMElement)) {
|
||||
if (!($oElementRow instanceof \DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
if ($oShape->hasRow($keyRow)) {
|
||||
|
|
@ -1001,7 +1001,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
$arrayElementsCell = $document->getElements('a:tc', $oElementRow);
|
||||
foreach ($arrayElementsCell as $keyCell => $oElementCell) {
|
||||
if (!($oElementCell instanceof DOMElement)) {
|
||||
if (!($oElementCell instanceof \DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
$oCell = $oRow->getCell($keyCell);
|
||||
|
|
@ -1014,14 +1014,14 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
foreach ($document->getElements('a:txBody/a:p', $oElementCell) as $oElementPara) {
|
||||
if ($oElementPara instanceof DOMElement) {
|
||||
if ($oElementPara instanceof \DOMElement) {
|
||||
$this->loadParagraph($document, $oElementPara, $oCell);
|
||||
}
|
||||
}
|
||||
|
||||
$oElementTcPr = $document->getElement('a:tcPr', $oElementCell);
|
||||
if ($oElementTcPr instanceof DOMElement) {
|
||||
$numParagraphs = count($oCell->getParagraphs());
|
||||
if ($oElementTcPr instanceof \DOMElement) {
|
||||
$numParagraphs = \count($oCell->getParagraphs());
|
||||
if ($numParagraphs > 0) {
|
||||
if ($oElementTcPr->hasAttribute('vert')) {
|
||||
$oCell->getParagraph(0)->getAlignment()->setTextDirection($oElementTcPr->getAttribute('vert'));
|
||||
|
|
@ -1050,27 +1050,27 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
$oBorders = new Borders();
|
||||
$oElementBorderL = $document->getElement('a:lnL', $oElementTcPr);
|
||||
if ($oElementBorderL instanceof DOMElement) {
|
||||
if ($oElementBorderL instanceof \DOMElement) {
|
||||
$this->loadStyleBorder($document, $oElementBorderL, $oBorders->getLeft());
|
||||
}
|
||||
$oElementBorderR = $document->getElement('a:lnR', $oElementTcPr);
|
||||
if ($oElementBorderR instanceof DOMElement) {
|
||||
if ($oElementBorderR instanceof \DOMElement) {
|
||||
$this->loadStyleBorder($document, $oElementBorderR, $oBorders->getRight());
|
||||
}
|
||||
$oElementBorderT = $document->getElement('a:lnT', $oElementTcPr);
|
||||
if ($oElementBorderT instanceof DOMElement) {
|
||||
if ($oElementBorderT instanceof \DOMElement) {
|
||||
$this->loadStyleBorder($document, $oElementBorderT, $oBorders->getTop());
|
||||
}
|
||||
$oElementBorderB = $document->getElement('a:lnB', $oElementTcPr);
|
||||
if ($oElementBorderB instanceof DOMElement) {
|
||||
if ($oElementBorderB instanceof \DOMElement) {
|
||||
$this->loadStyleBorder($document, $oElementBorderB, $oBorders->getBottom());
|
||||
}
|
||||
$oElementBorderDiagDown = $document->getElement('a:lnTlToBr', $oElementTcPr);
|
||||
if ($oElementBorderDiagDown instanceof DOMElement) {
|
||||
if ($oElementBorderDiagDown instanceof \DOMElement) {
|
||||
$this->loadStyleBorder($document, $oElementBorderDiagDown, $oBorders->getDiagonalDown());
|
||||
}
|
||||
$oElementBorderDiagUp = $document->getElement('a:lnBlToTr', $oElementTcPr);
|
||||
if ($oElementBorderDiagUp instanceof DOMElement) {
|
||||
if ($oElementBorderDiagUp instanceof \DOMElement) {
|
||||
$this->loadStyleBorder($document, $oElementBorderDiagUp, $oBorders->getDiagonalUp());
|
||||
}
|
||||
$oCell->setBorders($oBorders);
|
||||
|
|
@ -1082,14 +1082,14 @@ class PowerPoint2007 implements ReaderInterface
|
|||
/**
|
||||
* @param Cell|RichText $oShape
|
||||
*/
|
||||
protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oShape): void
|
||||
protected function loadParagraph(XMLReader $document, \DOMElement $oElement, $oShape): void
|
||||
{
|
||||
// Core
|
||||
$oParagraph = $oShape->createParagraph();
|
||||
$oParagraph->setRichTextElements([]);
|
||||
|
||||
$oSubElement = $document->getElement('a:pPr', $oElement);
|
||||
if ($oSubElement instanceof DOMElement) {
|
||||
if ($oSubElement instanceof \DOMElement) {
|
||||
if ($oSubElement->hasAttribute('algn')) {
|
||||
$oParagraph->getAlignment()->setHorizontal($oSubElement->getAttribute('algn'));
|
||||
}
|
||||
|
|
@ -1113,41 +1113,41 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElementLineSpacingPoints = $document->getElement('a:lnSpc/a:spcPts', $oSubElement);
|
||||
if ($oElementLineSpacingPoints instanceof DOMElement) {
|
||||
if ($oElementLineSpacingPoints instanceof \DOMElement) {
|
||||
$oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT);
|
||||
$oParagraph->setLineSpacing($oElementLineSpacingPoints->getAttribute('val') / 100);
|
||||
}
|
||||
$oElementLineSpacingPercent = $document->getElement('a:lnSpc/a:spcPct', $oSubElement);
|
||||
if ($oElementLineSpacingPercent instanceof DOMElement) {
|
||||
if ($oElementLineSpacingPercent instanceof \DOMElement) {
|
||||
$oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_PERCENT);
|
||||
$oParagraph->setLineSpacing($oElementLineSpacingPercent->getAttribute('val') / 1000);
|
||||
}
|
||||
$oElementSpacingBefore = $document->getElement('a:spcBef/a:spcPts', $oSubElement);
|
||||
if ($oElementSpacingBefore instanceof DOMElement) {
|
||||
if ($oElementSpacingBefore instanceof \DOMElement) {
|
||||
$oParagraph->setSpacingBefore($oElementSpacingBefore->getAttribute('val') / 100);
|
||||
}
|
||||
$oElementSpacingAfter = $document->getElement('a:spcAft/a:spcPts', $oSubElement);
|
||||
if ($oElementSpacingAfter instanceof DOMElement) {
|
||||
if ($oElementSpacingAfter instanceof \DOMElement) {
|
||||
$oParagraph->setSpacingAfter($oElementSpacingAfter->getAttribute('val') / 100);
|
||||
}
|
||||
|
||||
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE);
|
||||
|
||||
$oElementBuFont = $document->getElement('a:buFont', $oSubElement);
|
||||
if ($oElementBuFont instanceof DOMElement) {
|
||||
if ($oElementBuFont instanceof \DOMElement) {
|
||||
if ($oElementBuFont->hasAttribute('typeface')) {
|
||||
$oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface'));
|
||||
}
|
||||
}
|
||||
$oElementBuChar = $document->getElement('a:buChar', $oSubElement);
|
||||
if ($oElementBuChar instanceof DOMElement) {
|
||||
if ($oElementBuChar instanceof \DOMElement) {
|
||||
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
|
||||
if ($oElementBuChar->hasAttribute('char')) {
|
||||
$oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char'));
|
||||
}
|
||||
}
|
||||
$oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement);
|
||||
if ($oElementBuAutoNum instanceof DOMElement) {
|
||||
if ($oElementBuAutoNum instanceof \DOMElement) {
|
||||
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC);
|
||||
if ($oElementBuAutoNum->hasAttribute('type')) {
|
||||
$oParagraph->getBulletStyle()->setBulletNumericStyle($oElementBuAutoNum->getAttribute('type'));
|
||||
|
|
@ -1157,13 +1157,13 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
}
|
||||
$oElementBuClr = $document->getElement('a:buClr', $oSubElement);
|
||||
if ($oElementBuClr instanceof DOMElement) {
|
||||
if ($oElementBuClr instanceof \DOMElement) {
|
||||
$oColor = new Color();
|
||||
/**
|
||||
* @todo Create protected for reading Color
|
||||
*/
|
||||
$oElementColor = $document->getElement('a:srgbClr', $oElementBuClr);
|
||||
if ($oElementColor instanceof DOMElement) {
|
||||
if ($oElementColor instanceof \DOMElement) {
|
||||
$oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
|
||||
}
|
||||
$oParagraph->getBulletStyle()->setBulletColor($oColor);
|
||||
|
|
@ -1171,7 +1171,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
$arraySubElements = $document->getElements('(a:r|a:br)', $oElement);
|
||||
foreach ($arraySubElements as $oSubElement) {
|
||||
if (!($oSubElement instanceof DOMElement)) {
|
||||
if (!($oSubElement instanceof \DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
if ('a:br' == $oSubElement->tagName) {
|
||||
|
|
@ -1179,7 +1179,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
if ('a:r' == $oSubElement->tagName) {
|
||||
$oElementrPr = $document->getElement('a:rPr', $oSubElement);
|
||||
if (is_object($oElementrPr)) {
|
||||
if (\is_object($oElementrPr)) {
|
||||
$oText = $oParagraph->createTextRun();
|
||||
|
||||
if ($oElementrPr->hasAttribute('b')) {
|
||||
|
|
@ -1201,14 +1201,14 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
// Color
|
||||
$oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr);
|
||||
if (is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) {
|
||||
if (\is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) {
|
||||
$oColor = new Color();
|
||||
$oColor->setRGB($oElementSrgbClr->getAttribute('val'));
|
||||
$oText->getFont()->setColor($oColor);
|
||||
}
|
||||
// Hyperlink
|
||||
$oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr);
|
||||
if (is_object($oElementHlinkClick)) {
|
||||
if (\is_object($oElementHlinkClick)) {
|
||||
$oText->setHyperlink(
|
||||
$this->loadHyperlink($document, $oElementHlinkClick, $oText->getHyperlink())
|
||||
);
|
||||
|
|
@ -1216,21 +1216,21 @@ class PowerPoint2007 implements ReaderInterface
|
|||
// Font
|
||||
$oElementFontFormat = null;
|
||||
$oElementFontFormatLatin = $document->getElement('a:latin', $oElementrPr);
|
||||
if (is_object($oElementFontFormatLatin)) {
|
||||
if (\is_object($oElementFontFormatLatin)) {
|
||||
$oText->getFont()->setFormat(Font::FORMAT_LATIN);
|
||||
$oElementFontFormat = $oElementFontFormatLatin;
|
||||
}
|
||||
$oElementFontFormatEastAsian = $document->getElement('a:ea', $oElementrPr);
|
||||
if (is_object($oElementFontFormatEastAsian)) {
|
||||
if (\is_object($oElementFontFormatEastAsian)) {
|
||||
$oText->getFont()->setFormat(Font::FORMAT_EAST_ASIAN);
|
||||
$oElementFontFormat = $oElementFontFormatEastAsian;
|
||||
}
|
||||
$oElementFontFormatComplexScript = $document->getElement('a:cs', $oElementrPr);
|
||||
if (is_object($oElementFontFormatComplexScript)) {
|
||||
if (\is_object($oElementFontFormatComplexScript)) {
|
||||
$oText->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
|
||||
$oElementFontFormat = $oElementFontFormatComplexScript;
|
||||
}
|
||||
if (is_object($oElementFontFormat) && $oElementFontFormat->hasAttribute('typeface')) {
|
||||
if (\is_object($oElementFontFormat) && $oElementFontFormat->hasAttribute('typeface')) {
|
||||
$oText->getFont()->setName($oElementFontFormat->getAttribute('typeface'));
|
||||
}
|
||||
|
||||
|
|
@ -1244,7 +1244,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
}
|
||||
|
||||
protected function loadHyperlink(XMLReader $xmlReader, DOMElement $element, Hyperlink $hyperlink): Hyperlink
|
||||
protected function loadHyperlink(XMLReader $xmlReader, \DOMElement $element, Hyperlink $hyperlink): Hyperlink
|
||||
{
|
||||
if ($element->hasAttribute('tooltip')) {
|
||||
$hyperlink->setTooltip($element->getAttribute('tooltip'));
|
||||
|
|
@ -1261,7 +1261,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
return $hyperlink;
|
||||
}
|
||||
|
||||
protected function loadStyleBorder(XMLReader $xmlReader, DOMElement $oElement, Border $oBorder): void
|
||||
protected function loadStyleBorder(XMLReader $xmlReader, \DOMElement $oElement, Border $oBorder): void
|
||||
{
|
||||
if ($oElement->hasAttribute('w')) {
|
||||
$oBorder->setLineWidth($oElement->getAttribute('w') / 12700);
|
||||
|
|
@ -1271,54 +1271,54 @@ class PowerPoint2007 implements ReaderInterface
|
|||
}
|
||||
|
||||
$oElementNoFill = $xmlReader->getElement('a:noFill', $oElement);
|
||||
if ($oElementNoFill instanceof DOMElement && Border::LINE_SINGLE == $oBorder->getLineStyle()) {
|
||||
if ($oElementNoFill instanceof \DOMElement && Border::LINE_SINGLE == $oBorder->getLineStyle()) {
|
||||
$oBorder->setLineStyle(Border::LINE_NONE);
|
||||
}
|
||||
|
||||
$oElementColor = $xmlReader->getElement('a:solidFill/a:srgbClr', $oElement);
|
||||
if ($oElementColor instanceof DOMElement) {
|
||||
if ($oElementColor instanceof \DOMElement) {
|
||||
$oBorder->setColor($this->loadStyleColor($xmlReader, $oElementColor));
|
||||
}
|
||||
|
||||
$oElementDashStyle = $xmlReader->getElement('a:prstDash', $oElement);
|
||||
if ($oElementDashStyle instanceof DOMElement && $oElementDashStyle->hasAttribute('val')) {
|
||||
if ($oElementDashStyle instanceof \DOMElement && $oElementDashStyle->hasAttribute('val')) {
|
||||
$oBorder->setDashStyle($oElementDashStyle->getAttribute('val'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadStyleColor(XMLReader $xmlReader, DOMElement $oElement): Color
|
||||
protected function loadStyleColor(XMLReader $xmlReader, \DOMElement $oElement): Color
|
||||
{
|
||||
$oColor = new Color();
|
||||
$oColor->setRGB($oElement->getAttribute('val'));
|
||||
$oElementAlpha = $xmlReader->getElement('a:alpha', $oElement);
|
||||
if ($oElementAlpha instanceof DOMElement && $oElementAlpha->hasAttribute('val')) {
|
||||
$alpha = strtoupper(dechex((($oElementAlpha->getAttribute('val') / 1000) / 100) * 255));
|
||||
if ($oElementAlpha instanceof \DOMElement && $oElementAlpha->hasAttribute('val')) {
|
||||
$alpha = \strtoupper(\dechex((($oElementAlpha->getAttribute('val') / 1000) / 100) * 255));
|
||||
$oColor->setRGB($oElement->getAttribute('val'), $alpha);
|
||||
}
|
||||
|
||||
return $oColor;
|
||||
}
|
||||
|
||||
protected function loadStyleFill(XMLReader $xmlReader, DOMElement $oElement): ?Fill
|
||||
protected function loadStyleFill(XMLReader $xmlReader, \DOMElement $oElement): ?Fill
|
||||
{
|
||||
// Gradient fill
|
||||
$oElementFill = $xmlReader->getElement('a:gradFill', $oElement);
|
||||
if ($oElementFill instanceof DOMElement) {
|
||||
if ($oElementFill instanceof \DOMElement) {
|
||||
$oFill = new Fill();
|
||||
$oFill->setFillType(Fill::FILL_GRADIENT_LINEAR);
|
||||
|
||||
$oElementColor = $xmlReader->getElement('a:gsLst/a:gs[@pos="0"]/a:srgbClr', $oElementFill);
|
||||
if ($oElementColor instanceof DOMElement && $oElementColor->hasAttribute('val')) {
|
||||
if ($oElementColor instanceof \DOMElement && $oElementColor->hasAttribute('val')) {
|
||||
$oFill->setStartColor($this->loadStyleColor($xmlReader, $oElementColor));
|
||||
}
|
||||
|
||||
$oElementColor = $xmlReader->getElement('a:gsLst/a:gs[@pos="100000"]/a:srgbClr', $oElementFill);
|
||||
if ($oElementColor instanceof DOMElement && $oElementColor->hasAttribute('val')) {
|
||||
if ($oElementColor instanceof \DOMElement && $oElementColor->hasAttribute('val')) {
|
||||
$oFill->setEndColor($this->loadStyleColor($xmlReader, $oElementColor));
|
||||
}
|
||||
|
||||
$oRotation = $xmlReader->getElement('a:lin', $oElementFill);
|
||||
if ($oRotation instanceof DOMElement && $oRotation->hasAttribute('ang')) {
|
||||
if ($oRotation instanceof \DOMElement && $oRotation->hasAttribute('ang')) {
|
||||
$oFill->setRotation(CommonDrawing::angleToDegrees((int) $oRotation->getAttribute('ang')));
|
||||
}
|
||||
|
||||
|
|
@ -1327,12 +1327,12 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
// Solid fill
|
||||
$oElementFill = $xmlReader->getElement('a:solidFill', $oElement);
|
||||
if ($oElementFill instanceof DOMElement) {
|
||||
if ($oElementFill instanceof \DOMElement) {
|
||||
$oFill = new Fill();
|
||||
$oFill->setFillType(Fill::FILL_SOLID);
|
||||
|
||||
$oElementColor = $xmlReader->getElement('a:srgbClr', $oElementFill);
|
||||
if ($oElementColor instanceof DOMElement) {
|
||||
if ($oElementColor instanceof \DOMElement) {
|
||||
$oFill->setStartColor($this->loadStyleColor($xmlReader, $oElementColor));
|
||||
}
|
||||
|
||||
|
|
@ -1350,7 +1350,7 @@ class PowerPoint2007 implements ReaderInterface
|
|||
/* @phpstan-ignore-next-line */
|
||||
if ($xmlReader->getDomFromString($sPart)) {
|
||||
foreach ($xmlReader->getElements('*') as $oNode) {
|
||||
if (!($oNode instanceof DOMElement)) {
|
||||
if (!($oNode instanceof \DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
$this->arrayRels[$fileRels][$oNode->getAttribute('Id')] = [
|
||||
|
|
@ -1364,16 +1364,16 @@ class PowerPoint2007 implements ReaderInterface
|
|||
|
||||
/**
|
||||
* @param AbstractSlide|Note $oSlide
|
||||
* @param DOMNodeList<DOMNode> $oElements
|
||||
* @param \DOMNodeList<\DOMNode> $oElements
|
||||
*
|
||||
* @throws FeatureNotImplementedException
|
||||
*
|
||||
* @internal param $baseFile
|
||||
*/
|
||||
protected function loadSlideShapes($oSlide, DOMNodeList $oElements, XMLReader $xmlReader): void
|
||||
protected function loadSlideShapes($oSlide, \DOMNodeList $oElements, XMLReader $xmlReader): void
|
||||
{
|
||||
foreach ($oElements as $oNode) {
|
||||
if (!($oNode instanceof DOMElement)) {
|
||||
if (!($oNode instanceof \DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
switch ($oNode->tagName) {
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
if (!\file_exists($pFilename)) {
|
||||
throw new FileNotFoundException($pFilename);
|
||||
}
|
||||
|
||||
|
|
@ -408,7 +408,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
$ole->read($pFilename);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -652,8 +652,8 @@ class PowerPoint97 implements ReaderInterface
|
|||
$recLen = self::getInt4d($stream, $pos + 4);
|
||||
|
||||
return [
|
||||
'recVer' => ($rec >> 0) & bindec('1111'),
|
||||
'recInstance' => ($rec >> 4) & bindec('111111111111'),
|
||||
'recVer' => ($rec >> 0) & \bindec('1111'),
|
||||
'recInstance' => ($rec >> 4) & \bindec('111111111111'),
|
||||
'recType' => $recType,
|
||||
'recLen' => $recLen,
|
||||
];
|
||||
|
|
@ -664,7 +664,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
*/
|
||||
public static function getInt1d(string $data, int $pos): int
|
||||
{
|
||||
return ord($data[$pos]);
|
||||
return \ord($data[$pos]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -672,7 +672,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
*/
|
||||
public static function getInt2d(string $data, int $pos): int
|
||||
{
|
||||
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8);
|
||||
return \ord($data[$pos]) | (\ord($data[$pos + 1]) << 8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -683,15 +683,15 @@ class PowerPoint97 implements ReaderInterface
|
|||
// 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]);
|
||||
$or24 = \ord($data[$pos + 3]);
|
||||
|
||||
$ord24 = ($or24 & 127) << 24;
|
||||
if ($or24 >= 128) {
|
||||
// negative number
|
||||
$ord24 = -abs((256 - $or24) << 24);
|
||||
$ord24 = -\abs((256 - $or24) << 24);
|
||||
}
|
||||
|
||||
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24;
|
||||
return \ord($data[$pos]) | (\ord($data[$pos + 1]) << 8) | (\ord($data[$pos + 2]) << 16) | $ord24;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -781,7 +781,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
$char = self::getInt2d($stream, $pos);
|
||||
$pos += 2;
|
||||
$exObjList['recLen'] -= 2;
|
||||
$this->arrayHyperlinks[$exHyperlinkId]['text'] .= chr($char);
|
||||
$this->arrayHyperlinks[$exHyperlinkId]['text'] .= \chr($char);
|
||||
}
|
||||
}
|
||||
// targetAtom
|
||||
|
|
@ -794,7 +794,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
$char = self::getInt2d($stream, $pos);
|
||||
$pos += 2;
|
||||
$exObjList['recLen'] -= 2;
|
||||
$this->arrayHyperlinks[$exHyperlinkId]['url'] .= chr($char);
|
||||
$this->arrayHyperlinks[$exHyperlinkId]['url'] .= \chr($char);
|
||||
}
|
||||
}
|
||||
// locationAtom
|
||||
|
|
@ -807,7 +807,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
$char = self::getInt2d($stream, $pos);
|
||||
$pos += 2;
|
||||
$exObjList['recLen'] -= 2;
|
||||
$string .= chr($char);
|
||||
$string .= \chr($char);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -845,7 +845,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
$char = self::getInt2d($stream, $pos);
|
||||
$pos += 2;
|
||||
$fontCollection['recLen'] -= 2;
|
||||
$string .= chr($char);
|
||||
$string .= \chr($char);
|
||||
}
|
||||
$this->arrayFonts[] = $string;
|
||||
|
||||
|
|
@ -1238,7 +1238,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
++$arrayReturn['length'];
|
||||
--$data['recLen'];
|
||||
// BLIPFileData
|
||||
$arrayReturn['picture'] = substr($this->streamPictures, $pos + $arrayReturn['length'], $data['recLen']);
|
||||
$arrayReturn['picture'] = \substr($this->streamPictures, $pos + $arrayReturn['length'], $data['recLen']);
|
||||
$arrayReturn['length'] += $data['recLen'];
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1431,10 +1431,10 @@ class PowerPoint97 implements ReaderInterface
|
|||
//@link : http://msdn.microsoft.com/en-us/library/dd947973(v=office.12).aspx
|
||||
if (0x0000 == $rhChild['recInstance']) {
|
||||
//@todo : MouseClickTextInteractiveInfoAtom
|
||||
$arrayReturn['hyperlink'][count($arrayReturn['hyperlink']) - 1]['start'] = self::getInt4d($stream, $pos + +$arrayReturn['length']);
|
||||
$arrayReturn['hyperlink'][\count($arrayReturn['hyperlink']) - 1]['start'] = self::getInt4d($stream, $pos + +$arrayReturn['length']);
|
||||
$arrayReturn['length'] += 4;
|
||||
|
||||
$arrayReturn['hyperlink'][count($arrayReturn['hyperlink']) - 1]['end'] = self::getInt4d($stream, $pos + +$arrayReturn['length']);
|
||||
$arrayReturn['hyperlink'][\count($arrayReturn['hyperlink']) - 1]['end'] = self::getInt4d($stream, $pos + +$arrayReturn['length']);
|
||||
$arrayReturn['length'] += 4;
|
||||
}
|
||||
if (0x0001 == $rhChild['recInstance']) {
|
||||
|
|
@ -1552,7 +1552,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
// Informations about group are not defined
|
||||
$arrayDimensions = [];
|
||||
$bIsGroup = false;
|
||||
if (is_object($this->oCurrentGroup)) {
|
||||
if (\is_object($this->oCurrentGroup)) {
|
||||
if (!$this->bFirstShapeGroup) {
|
||||
if ($clientAnchor['length'] > 0) {
|
||||
// $this->oCurrentGroup->setOffsetX($clientAnchor['left']);
|
||||
|
|
@ -1578,7 +1578,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
// isDrawing
|
||||
$drawingPib = $shpPrimaryOptions['pib'];
|
||||
if (isset($this->arrayPictures[$drawingPib - 1])) {
|
||||
$gdImage = imagecreatefromstring($this->arrayPictures[$drawingPib - 1]);
|
||||
$gdImage = \imagecreatefromstring($this->arrayPictures[$drawingPib - 1]);
|
||||
$arrayReturn['shape'] = new Drawing\Gd();
|
||||
$arrayReturn['shape']->setImageResource($gdImage);
|
||||
}
|
||||
|
|
@ -1621,7 +1621,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
}
|
||||
}
|
||||
// Texte
|
||||
$sText = substr(isset($clientTextbox['text']) ? $clientTextbox['text'] : '', $start, $clientTextbox['part' . $inc]['partLength']);
|
||||
$sText = \substr(isset($clientTextbox['text']) ? $clientTextbox['text'] : '', $start, $clientTextbox['part' . $inc]['partLength']);
|
||||
$sHyperlinkURL = '';
|
||||
if (empty($sText)) {
|
||||
// Is there a hyperlink ?
|
||||
|
|
@ -1637,9 +1637,9 @@ class PowerPoint97 implements ReaderInterface
|
|||
}
|
||||
// New paragraph
|
||||
$bCreateParagraph = false;
|
||||
if (false !== strpos($sText, "\r")) {
|
||||
if (false !== \strpos($sText, "\r")) {
|
||||
$bCreateParagraph = true;
|
||||
$sText = str_replace("\r", '', $sText);
|
||||
$sText = \str_replace("\r", '', $sText);
|
||||
}
|
||||
// TextRun
|
||||
$txtRun = $arrayReturn['shape']->createTextRun($sText);
|
||||
|
|
@ -1787,10 +1787,10 @@ class PowerPoint97 implements ReaderInterface
|
|||
$data['recLen'] -= $fileBlock['length'];
|
||||
// Core
|
||||
//@todo
|
||||
if (!is_null($fileBlock['shape'])) {
|
||||
if (!\is_null($fileBlock['shape'])) {
|
||||
switch ($this->inMainType) {
|
||||
case self::RT_NOTES:
|
||||
$arrayIdxSlide = array_flip($this->arrayNotes);
|
||||
$arrayIdxSlide = \array_flip($this->arrayNotes);
|
||||
if ($this->currentNote > 0 && isset($arrayIdxSlide[$this->currentNote])) {
|
||||
$oSlide = $this->oPhpPresentation->getSlide($arrayIdxSlide[$this->currentNote]);
|
||||
if (0 == $oSlide->getNote()->getShapeCollection()->count()) {
|
||||
|
|
@ -1843,9 +1843,9 @@ class PowerPoint97 implements ReaderInterface
|
|||
$optOp = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
|
||||
$arrayReturn['length'] += 4;
|
||||
$officeArtFOPTE[] = [
|
||||
'opid' => ($opid >> 0) & bindec('11111111111111'),
|
||||
'fBid' => ($opid >> 14) & bindec('1'),
|
||||
'fComplex' => ($opid >> 15) & bindec('1'),
|
||||
'opid' => ($opid >> 0) & \bindec('11111111111111'),
|
||||
'fBid' => ($opid >> 14) & \bindec('1'),
|
||||
'fComplex' => ($opid >> 15) & \bindec('1'),
|
||||
'op' => $optOp,
|
||||
];
|
||||
}
|
||||
|
|
@ -1975,9 +1975,9 @@ class PowerPoint97 implements ReaderInterface
|
|||
$arrayReturn['length'] += 4;
|
||||
$data['recLen'] -= 4;
|
||||
$officeArtFOPTE[] = [
|
||||
'opid' => ($opid >> 0) & bindec('11111111111111'),
|
||||
'fBid' => ($opid >> 14) & bindec('1'),
|
||||
'fComplex' => ($opid >> 15) & bindec('1'),
|
||||
'opid' => ($opid >> 0) & \bindec('11111111111111'),
|
||||
'fBid' => ($opid >> 14) & \bindec('1'),
|
||||
'fComplex' => ($opid >> 15) & \bindec('1'),
|
||||
'op' => $optOp,
|
||||
];
|
||||
}
|
||||
|
|
@ -2120,17 +2120,17 @@ class PowerPoint97 implements ReaderInterface
|
|||
case 0x0181:
|
||||
// Fill : fillColor
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd921332(v=office.12).aspx
|
||||
$strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor = \str_pad(\dechex(($opt['op'] >> 0) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= \str_pad(\dechex(($opt['op'] >> 8) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= \str_pad(\dechex(($opt['op'] >> 16) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
// echo 'fillColor : '.$strColor.EOL;
|
||||
break;
|
||||
case 0x0183:
|
||||
// Fill : fillBackColor
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd950634(v=office.12).aspx
|
||||
$strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor = \str_pad(\dechex(($opt['op'] >> 0) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= \str_pad(\dechex(($opt['op'] >> 8) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= \str_pad(\dechex(($opt['op'] >> 16) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
// echo 'fillBackColor : '.$strColor.EOL;
|
||||
break;
|
||||
case 0x0193:
|
||||
|
|
@ -2150,9 +2150,9 @@ class PowerPoint97 implements ReaderInterface
|
|||
case 0x01C0:
|
||||
// Line Style : lineColor
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd920397(v=office.12).aspx
|
||||
$strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor = \str_pad(\dechex(($opt['op'] >> 0) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= \str_pad(\dechex(($opt['op'] >> 8) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= \str_pad(\dechex(($opt['op'] >> 16) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
|
||||
$arrayReturn['lineColor'] = $strColor;
|
||||
break;
|
||||
case 0x01C1:
|
||||
|
|
@ -2277,10 +2277,10 @@ class PowerPoint97 implements ReaderInterface
|
|||
// data
|
||||
$data = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
|
||||
$arrayReturn['length'] += 4;
|
||||
$arrayReturn['fGroup'] = ($data >> 0) & bindec('1');
|
||||
$arrayReturn['fChild'] = ($data >> 1) & bindec('1');
|
||||
$arrayReturn['fPatriarch'] = ($data >> 2) & bindec('1');
|
||||
$arrayReturn['fDeleted'] = ($data >> 3) & bindec('1');
|
||||
$arrayReturn['fGroup'] = ($data >> 0) & \bindec('1');
|
||||
$arrayReturn['fChild'] = ($data >> 1) & \bindec('1');
|
||||
$arrayReturn['fPatriarch'] = ($data >> 2) & \bindec('1');
|
||||
$arrayReturn['fDeleted'] = ($data >> 3) & \bindec('1');
|
||||
}
|
||||
|
||||
return $arrayReturn;
|
||||
|
|
@ -2399,7 +2399,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
];
|
||||
do {
|
||||
$dataHeaderRG = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']);
|
||||
if (in_array($dataHeaderRG['recType'], $array)) {
|
||||
if (\in_array($dataHeaderRG['recType'], $array)) {
|
||||
switch ($dataHeaderRG['recType']) {
|
||||
case self::RT_PROGTAGS:
|
||||
$dataRG = $this->readRecordShapeProgTagsContainer($stream, $pos + $arrayReturn['length']);
|
||||
|
|
@ -2418,7 +2418,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
throw new FeatureNotImplementedException();
|
||||
}
|
||||
}
|
||||
} while (in_array($dataHeaderRG['recType'], $array));
|
||||
} while (\in_array($dataHeaderRG['recType'], $array));
|
||||
}
|
||||
|
||||
return $arrayReturn;
|
||||
|
|
@ -2445,7 +2445,7 @@ class PowerPoint97 implements ReaderInterface
|
|||
$pos += 4;
|
||||
$rHeader['recLen'] -= 4;
|
||||
//$persistId = ($data >> 0) & bindec('11111111111111111111');
|
||||
$cPersist = ($data >> 20) & bindec('111111111111');
|
||||
$cPersist = ($data >> 20) & \bindec('111111111111');
|
||||
|
||||
$rgPersistOffset = [];
|
||||
for ($inc = 0; $inc < $cPersist; ++$inc) {
|
||||
|
|
@ -3023,46 +3023,46 @@ class PowerPoint97 implements ReaderInterface
|
|||
$arrayReturn['length'] += 4;
|
||||
|
||||
$masksData = [];
|
||||
$masksData['bold'] = ($masks >> 0) & bindec('1');
|
||||
$masksData['italic'] = ($masks >> 1) & bindec('1');
|
||||
$masksData['underline'] = ($masks >> 2) & bindec('1');
|
||||
$masksData['unused1'] = ($masks >> 3) & bindec('1');
|
||||
$masksData['shadow'] = ($masks >> 4) & bindec('1');
|
||||
$masksData['fehint'] = ($masks >> 5) & bindec('1');
|
||||
$masksData['unused2'] = ($masks >> 6) & bindec('1');
|
||||
$masksData['kumi'] = ($masks >> 7) & bindec('1');
|
||||
$masksData['unused3'] = ($masks >> 8) & bindec('1');
|
||||
$masksData['emboss'] = ($masks >> 9) & bindec('1');
|
||||
$masksData['fHasStyle'] = ($masks >> 10) & bindec('1111');
|
||||
$masksData['unused4'] = ($masks >> 14) & bindec('11');
|
||||
$masksData['typeface'] = ($masks >> 16) & bindec('1');
|
||||
$masksData['size'] = ($masks >> 17) & bindec('1');
|
||||
$masksData['color'] = ($masks >> 18) & bindec('1');
|
||||
$masksData['position'] = ($masks >> 19) & bindec('1');
|
||||
$masksData['pp10ext'] = ($masks >> 20) & bindec('1');
|
||||
$masksData['oldEATypeface'] = ($masks >> 21) & bindec('1');
|
||||
$masksData['ansiTypeface'] = ($masks >> 22) & bindec('1');
|
||||
$masksData['symbolTypeface'] = ($masks >> 23) & bindec('1');
|
||||
$masksData['newEATypeface'] = ($masks >> 24) & bindec('1');
|
||||
$masksData['csTypeface'] = ($masks >> 25) & bindec('1');
|
||||
$masksData['pp11ext'] = ($masks >> 26) & bindec('1');
|
||||
$masksData['bold'] = ($masks >> 0) & \bindec('1');
|
||||
$masksData['italic'] = ($masks >> 1) & \bindec('1');
|
||||
$masksData['underline'] = ($masks >> 2) & \bindec('1');
|
||||
$masksData['unused1'] = ($masks >> 3) & \bindec('1');
|
||||
$masksData['shadow'] = ($masks >> 4) & \bindec('1');
|
||||
$masksData['fehint'] = ($masks >> 5) & \bindec('1');
|
||||
$masksData['unused2'] = ($masks >> 6) & \bindec('1');
|
||||
$masksData['kumi'] = ($masks >> 7) & \bindec('1');
|
||||
$masksData['unused3'] = ($masks >> 8) & \bindec('1');
|
||||
$masksData['emboss'] = ($masks >> 9) & \bindec('1');
|
||||
$masksData['fHasStyle'] = ($masks >> 10) & \bindec('1111');
|
||||
$masksData['unused4'] = ($masks >> 14) & \bindec('11');
|
||||
$masksData['typeface'] = ($masks >> 16) & \bindec('1');
|
||||
$masksData['size'] = ($masks >> 17) & \bindec('1');
|
||||
$masksData['color'] = ($masks >> 18) & \bindec('1');
|
||||
$masksData['position'] = ($masks >> 19) & \bindec('1');
|
||||
$masksData['pp10ext'] = ($masks >> 20) & \bindec('1');
|
||||
$masksData['oldEATypeface'] = ($masks >> 21) & \bindec('1');
|
||||
$masksData['ansiTypeface'] = ($masks >> 22) & \bindec('1');
|
||||
$masksData['symbolTypeface'] = ($masks >> 23) & \bindec('1');
|
||||
$masksData['newEATypeface'] = ($masks >> 24) & \bindec('1');
|
||||
$masksData['csTypeface'] = ($masks >> 25) & \bindec('1');
|
||||
$masksData['pp11ext'] = ($masks >> 26) & \bindec('1');
|
||||
if (1 == $masksData['bold'] || 1 == $masksData['italic'] || 1 == $masksData['underline'] || 1 == $masksData['shadow'] || 1 == $masksData['fehint'] || 1 == $masksData['kumi'] || 1 == $masksData['emboss'] || 1 == $masksData['fHasStyle']) {
|
||||
$data = self::getInt2d($stream, $pos + $arrayReturn['length']);
|
||||
$arrayReturn['length'] += 2;
|
||||
|
||||
$fontStyleFlags = [];
|
||||
$fontStyleFlags['bold'] = ($data >> 0) & bindec('1');
|
||||
$fontStyleFlags['italic'] = ($data >> 1) & bindec('1');
|
||||
$fontStyleFlags['underline'] = ($data >> 2) & bindec('1');
|
||||
$fontStyleFlags['unused1'] = ($data >> 3) & bindec('1');
|
||||
$fontStyleFlags['shadow'] = ($data >> 4) & bindec('1');
|
||||
$fontStyleFlags['fehint'] = ($data >> 5) & bindec('1');
|
||||
$fontStyleFlags['unused2'] = ($data >> 6) & bindec('1');
|
||||
$fontStyleFlags['kumi'] = ($data >> 7) & bindec('1');
|
||||
$fontStyleFlags['unused3'] = ($data >> 8) & bindec('1');
|
||||
$fontStyleFlags['emboss'] = ($data >> 9) & bindec('1');
|
||||
$fontStyleFlags['pp9rt'] = ($data >> 10) & bindec('1111');
|
||||
$fontStyleFlags['unused4'] = ($data >> 14) & bindec('11');
|
||||
$fontStyleFlags['bold'] = ($data >> 0) & \bindec('1');
|
||||
$fontStyleFlags['italic'] = ($data >> 1) & \bindec('1');
|
||||
$fontStyleFlags['underline'] = ($data >> 2) & \bindec('1');
|
||||
$fontStyleFlags['unused1'] = ($data >> 3) & \bindec('1');
|
||||
$fontStyleFlags['shadow'] = ($data >> 4) & \bindec('1');
|
||||
$fontStyleFlags['fehint'] = ($data >> 5) & \bindec('1');
|
||||
$fontStyleFlags['unused2'] = ($data >> 6) & \bindec('1');
|
||||
$fontStyleFlags['kumi'] = ($data >> 7) & \bindec('1');
|
||||
$fontStyleFlags['unused3'] = ($data >> 8) & \bindec('1');
|
||||
$fontStyleFlags['emboss'] = ($data >> 9) & \bindec('1');
|
||||
$fontStyleFlags['pp9rt'] = ($data >> 10) & \bindec('1111');
|
||||
$fontStyleFlags['unused4'] = ($data >> 14) & \bindec('11');
|
||||
|
||||
$arrayReturn['bold'] = (1 == $fontStyleFlags['bold']) ? true : false;
|
||||
$arrayReturn['italic'] = (1 == $fontStyleFlags['italic']) ? true : false;
|
||||
|
|
@ -3100,9 +3100,9 @@ class PowerPoint97 implements ReaderInterface
|
|||
++$arrayReturn['length'];
|
||||
|
||||
if (0xFE == $index) {
|
||||
$strColor = str_pad(dechex($red), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= str_pad(dechex($green), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= str_pad(dechex($blue), 2, '0', STR_PAD_LEFT);
|
||||
$strColor = \str_pad(\dechex($red), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= \str_pad(\dechex($green), 2, '0', STR_PAD_LEFT);
|
||||
$strColor .= \str_pad(\dechex($blue), 2, '0', STR_PAD_LEFT);
|
||||
|
||||
$arrayReturn['color'] = new Color('FF' . $strColor);
|
||||
}
|
||||
|
|
@ -3142,47 +3142,47 @@ class PowerPoint97 implements ReaderInterface
|
|||
$arrayReturn['length'] += 4;
|
||||
|
||||
$masksData = [];
|
||||
$masksData['hasBullet'] = ($masks >> 0) & bindec('1');
|
||||
$masksData['bulletHasFont'] = ($masks >> 1) & bindec('1');
|
||||
$masksData['bulletHasColor'] = ($masks >> 2) & bindec('1');
|
||||
$masksData['bulletHasSize'] = ($masks >> 3) & bindec('1');
|
||||
$masksData['bulletFont'] = ($masks >> 4) & bindec('1');
|
||||
$masksData['bulletColor'] = ($masks >> 5) & bindec('1');
|
||||
$masksData['bulletSize'] = ($masks >> 6) & bindec('1');
|
||||
$masksData['bulletChar'] = ($masks >> 7) & bindec('1');
|
||||
$masksData['leftMargin'] = ($masks >> 8) & bindec('1');
|
||||
$masksData['unused'] = ($masks >> 9) & bindec('1');
|
||||
$masksData['indent'] = ($masks >> 10) & bindec('1');
|
||||
$masksData['align'] = ($masks >> 11) & bindec('1');
|
||||
$masksData['lineSpacing'] = ($masks >> 12) & bindec('1');
|
||||
$masksData['spaceBefore'] = ($masks >> 13) & bindec('1');
|
||||
$masksData['spaceAfter'] = ($masks >> 14) & bindec('1');
|
||||
$masksData['defaultTabSize'] = ($masks >> 15) & bindec('1');
|
||||
$masksData['fontAlign'] = ($masks >> 16) & bindec('1');
|
||||
$masksData['charWrap'] = ($masks >> 17) & bindec('1');
|
||||
$masksData['wordWrap'] = ($masks >> 18) & bindec('1');
|
||||
$masksData['overflow'] = ($masks >> 19) & bindec('1');
|
||||
$masksData['tabStops'] = ($masks >> 20) & bindec('1');
|
||||
$masksData['textDirection'] = ($masks >> 21) & bindec('1');
|
||||
$masksData['reserved1'] = ($masks >> 22) & bindec('1');
|
||||
$masksData['bulletBlip'] = ($masks >> 23) & bindec('1');
|
||||
$masksData['bulletScheme'] = ($masks >> 24) & bindec('1');
|
||||
$masksData['bulletHasScheme'] = ($masks >> 25) & bindec('1');
|
||||
$masksData['hasBullet'] = ($masks >> 0) & \bindec('1');
|
||||
$masksData['bulletHasFont'] = ($masks >> 1) & \bindec('1');
|
||||
$masksData['bulletHasColor'] = ($masks >> 2) & \bindec('1');
|
||||
$masksData['bulletHasSize'] = ($masks >> 3) & \bindec('1');
|
||||
$masksData['bulletFont'] = ($masks >> 4) & \bindec('1');
|
||||
$masksData['bulletColor'] = ($masks >> 5) & \bindec('1');
|
||||
$masksData['bulletSize'] = ($masks >> 6) & \bindec('1');
|
||||
$masksData['bulletChar'] = ($masks >> 7) & \bindec('1');
|
||||
$masksData['leftMargin'] = ($masks >> 8) & \bindec('1');
|
||||
$masksData['unused'] = ($masks >> 9) & \bindec('1');
|
||||
$masksData['indent'] = ($masks >> 10) & \bindec('1');
|
||||
$masksData['align'] = ($masks >> 11) & \bindec('1');
|
||||
$masksData['lineSpacing'] = ($masks >> 12) & \bindec('1');
|
||||
$masksData['spaceBefore'] = ($masks >> 13) & \bindec('1');
|
||||
$masksData['spaceAfter'] = ($masks >> 14) & \bindec('1');
|
||||
$masksData['defaultTabSize'] = ($masks >> 15) & \bindec('1');
|
||||
$masksData['fontAlign'] = ($masks >> 16) & \bindec('1');
|
||||
$masksData['charWrap'] = ($masks >> 17) & \bindec('1');
|
||||
$masksData['wordWrap'] = ($masks >> 18) & \bindec('1');
|
||||
$masksData['overflow'] = ($masks >> 19) & \bindec('1');
|
||||
$masksData['tabStops'] = ($masks >> 20) & \bindec('1');
|
||||
$masksData['textDirection'] = ($masks >> 21) & \bindec('1');
|
||||
$masksData['reserved1'] = ($masks >> 22) & \bindec('1');
|
||||
$masksData['bulletBlip'] = ($masks >> 23) & \bindec('1');
|
||||
$masksData['bulletScheme'] = ($masks >> 24) & \bindec('1');
|
||||
$masksData['bulletHasScheme'] = ($masks >> 25) & \bindec('1');
|
||||
|
||||
$bulletFlags = [];
|
||||
if (1 == $masksData['hasBullet'] || 1 == $masksData['bulletHasFont'] || 1 == $masksData['bulletHasColor'] || 1 == $masksData['bulletHasSize']) {
|
||||
$data = self::getInt2d($stream, $pos + $arrayReturn['length']);
|
||||
$arrayReturn['length'] += 2;
|
||||
|
||||
$bulletFlags['fHasBullet'] = ($data >> 0) & bindec('1');
|
||||
$bulletFlags['fBulletHasFont'] = ($data >> 1) & bindec('1');
|
||||
$bulletFlags['fBulletHasColor'] = ($data >> 2) & bindec('1');
|
||||
$bulletFlags['fBulletHasSize'] = ($data >> 3) & bindec('1');
|
||||
$bulletFlags['fHasBullet'] = ($data >> 0) & \bindec('1');
|
||||
$bulletFlags['fBulletHasFont'] = ($data >> 1) & \bindec('1');
|
||||
$bulletFlags['fBulletHasColor'] = ($data >> 2) & \bindec('1');
|
||||
$bulletFlags['fBulletHasSize'] = ($data >> 3) & \bindec('1');
|
||||
}
|
||||
if (1 == $masksData['bulletChar']) {
|
||||
$data = self::getInt2d($stream, $pos + $arrayReturn['length']);
|
||||
$arrayReturn['length'] += 2;
|
||||
$arrayReturn['bulletChar'] = chr($data);
|
||||
$arrayReturn['bulletChar'] = \chr($data);
|
||||
}
|
||||
if (1 == $masksData['bulletFont']) {
|
||||
// $data = self::getInt2d($stream, $pos);
|
||||
|
|
@ -3252,12 +3252,12 @@ class PowerPoint97 implements ReaderInterface
|
|||
if (1 == $masksData['leftMargin']) {
|
||||
$data = self::getInt2d($stream, $pos + $arrayReturn['length']);
|
||||
$arrayReturn['length'] += 2;
|
||||
$arrayReturn['leftMargin'] = (int) round($data / 6);
|
||||
$arrayReturn['leftMargin'] = (int) \round($data / 6);
|
||||
}
|
||||
if (1 == $masksData['indent']) {
|
||||
$data = self::getInt2d($stream, $pos + $arrayReturn['length']);
|
||||
$arrayReturn['length'] += 2;
|
||||
$arrayReturn['indent'] = (int) round($data / 6);
|
||||
$arrayReturn['indent'] = (int) \round($data / 6);
|
||||
}
|
||||
if (1 == $masksData['defaultTabSize']) {
|
||||
// $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
|
||||
|
|
@ -3303,24 +3303,24 @@ class PowerPoint97 implements ReaderInterface
|
|||
$data = self::getInt4d($stream, $pos + $arrayReturn['length']);
|
||||
$arrayReturn['length'] += 4;
|
||||
$masksData = [];
|
||||
$masksData['spell'] = ($data >> 0) & bindec('1');
|
||||
$masksData['lang'] = ($data >> 1) & bindec('1');
|
||||
$masksData['altLang'] = ($data >> 2) & bindec('1');
|
||||
$masksData['unused1'] = ($data >> 3) & bindec('1');
|
||||
$masksData['unused2'] = ($data >> 4) & bindec('1');
|
||||
$masksData['fPp10ext'] = ($data >> 5) & bindec('1');
|
||||
$masksData['fBidi'] = ($data >> 6) & bindec('1');
|
||||
$masksData['unused3'] = ($data >> 7) & bindec('1');
|
||||
$masksData['reserved1'] = ($data >> 8) & bindec('1');
|
||||
$masksData['smartTag'] = ($data >> 9) & bindec('1');
|
||||
$masksData['spell'] = ($data >> 0) & \bindec('1');
|
||||
$masksData['lang'] = ($data >> 1) & \bindec('1');
|
||||
$masksData['altLang'] = ($data >> 2) & \bindec('1');
|
||||
$masksData['unused1'] = ($data >> 3) & \bindec('1');
|
||||
$masksData['unused2'] = ($data >> 4) & \bindec('1');
|
||||
$masksData['fPp10ext'] = ($data >> 5) & \bindec('1');
|
||||
$masksData['fBidi'] = ($data >> 6) & \bindec('1');
|
||||
$masksData['unused3'] = ($data >> 7) & \bindec('1');
|
||||
$masksData['reserved1'] = ($data >> 8) & \bindec('1');
|
||||
$masksData['smartTag'] = ($data >> 9) & \bindec('1');
|
||||
|
||||
if (1 == $masksData['spell']) {
|
||||
$data = self::getInt2d($stream, $pos + $arrayReturn['length']);
|
||||
$arrayReturn['length'] += 2;
|
||||
$masksSpell = [];
|
||||
$masksSpell['error'] = ($data >> 0) & bindec('1');
|
||||
$masksSpell['clean'] = ($data >> 1) & bindec('1');
|
||||
$masksSpell['grammar'] = ($data >> 2) & bindec('1');
|
||||
$masksSpell['error'] = ($data >> 0) & \bindec('1');
|
||||
$masksSpell['clean'] = ($data >> 1) & \bindec('1');
|
||||
$masksSpell['grammar'] = ($data >> 2) & \bindec('1');
|
||||
}
|
||||
if (1 == $masksData['lang']) {
|
||||
// $data = self::getInt2d($stream, $pos);
|
||||
|
|
@ -3362,19 +3362,19 @@ class PowerPoint97 implements ReaderInterface
|
|||
$arrayReturn['length'] += 4;
|
||||
|
||||
$masksData = [];
|
||||
$masksData['fDefaultTabSize'] = ($data >> 0) & bindec('1');
|
||||
$masksData['fCLevels'] = ($data >> 1) & bindec('1');
|
||||
$masksData['fTabStops'] = ($data >> 2) & bindec('1');
|
||||
$masksData['fLeftMargin1'] = ($data >> 3) & bindec('1');
|
||||
$masksData['fLeftMargin2'] = ($data >> 4) & bindec('1');
|
||||
$masksData['fLeftMargin3'] = ($data >> 5) & bindec('1');
|
||||
$masksData['fLeftMargin4'] = ($data >> 6) & bindec('1');
|
||||
$masksData['fLeftMargin5'] = ($data >> 7) & bindec('1');
|
||||
$masksData['fIndent1'] = ($data >> 8) & bindec('1');
|
||||
$masksData['fIndent2'] = ($data >> 9) & bindec('1');
|
||||
$masksData['fIndent3'] = ($data >> 10) & bindec('1');
|
||||
$masksData['fIndent4'] = ($data >> 11) & bindec('1');
|
||||
$masksData['fIndent5'] = ($data >> 12) & bindec('1');
|
||||
$masksData['fDefaultTabSize'] = ($data >> 0) & \bindec('1');
|
||||
$masksData['fCLevels'] = ($data >> 1) & \bindec('1');
|
||||
$masksData['fTabStops'] = ($data >> 2) & \bindec('1');
|
||||
$masksData['fLeftMargin1'] = ($data >> 3) & \bindec('1');
|
||||
$masksData['fLeftMargin2'] = ($data >> 4) & \bindec('1');
|
||||
$masksData['fLeftMargin3'] = ($data >> 5) & \bindec('1');
|
||||
$masksData['fLeftMargin4'] = ($data >> 6) & \bindec('1');
|
||||
$masksData['fLeftMargin5'] = ($data >> 7) & \bindec('1');
|
||||
$masksData['fIndent1'] = ($data >> 8) & \bindec('1');
|
||||
$masksData['fIndent2'] = ($data >> 9) & \bindec('1');
|
||||
$masksData['fIndent3'] = ($data >> 10) & \bindec('1');
|
||||
$masksData['fIndent4'] = ($data >> 11) & \bindec('1');
|
||||
$masksData['fIndent5'] = ($data >> 12) & \bindec('1');
|
||||
|
||||
if (1 == $masksData['fCLevels']) {
|
||||
throw new FeatureNotImplementedException();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class Serialized implements ReaderInterface
|
|||
public function fileSupportsUnserializePhpPresentation(string $pFilename): bool
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
if (!\file_exists($pFilename)) {
|
||||
throw new FileNotFoundException($pFilename);
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ class Serialized implements ReaderInterface
|
|||
public function load(string $pFilename): PhpPresentation
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
if (!\file_exists($pFilename)) {
|
||||
throw new FileNotFoundException($pFilename);
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class Serialized implements ReaderInterface
|
|||
*/
|
||||
private function loadSerialized(string $pFilename): PhpPresentation
|
||||
{
|
||||
$oArchive = new ZipArchive();
|
||||
$oArchive = new \ZipArchive();
|
||||
if (true !== $oArchive->open($pFilename)) {
|
||||
throw new InvalidFileFormatException($pFilename, Serialized::class);
|
||||
}
|
||||
|
|
@ -95,15 +95,15 @@ class Serialized implements ReaderInterface
|
|||
throw new InvalidFileFormatException($pFilename, Serialized::class, 'The file PhpPresentation.xml is malformed');
|
||||
}
|
||||
|
||||
$xmlData = simplexml_load_string($xmlContent);
|
||||
$file = unserialize(base64_decode((string) $xmlData->data));
|
||||
$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);
|
||||
$imgPath = 'zip://' . $pFilename . '#media/' . $imgTemp->getImageIndex() . '/' . pathinfo($imgTemp->getPath(), PATHINFO_BASENAME);
|
||||
$imgPath = 'zip://' . $pFilename . '#media/' . $imgTemp->getImageIndex() . '/' . \pathinfo($imgTemp->getPath(), PATHINFO_BASENAME);
|
||||
if ($imgTemp instanceof DrawingFile) {
|
||||
$imgTemp->setPath($imgPath, false);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
// Resize proportional?
|
||||
if ($this->resizeProportional && 0 != $pValue && 0 != $this->width) {
|
||||
$ratio = $this->height / $this->width;
|
||||
$this->height = (int) round($ratio * $pValue);
|
||||
$this->height = (int) \round($ratio * $pValue);
|
||||
}
|
||||
|
||||
// Set width
|
||||
|
|
@ -183,7 +183,7 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
// Resize proportional?
|
||||
if ($this->resizeProportional && 0 != $pValue && 0 != $this->height) {
|
||||
$ratio = $this->width / $this->height;
|
||||
$this->width = (int) round($ratio * $pValue);
|
||||
$this->width = (int) \round($ratio * $pValue);
|
||||
}
|
||||
|
||||
// Set height
|
||||
|
|
@ -205,10 +205,10 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
$yratio = $height / $this->height;
|
||||
if ($this->resizeProportional && !(0 == $width || 0 == $height)) {
|
||||
if (($xratio * $this->height) < $height) {
|
||||
$this->height = (int) ceil($xratio * $this->height);
|
||||
$this->height = (int) \ceil($xratio * $this->height);
|
||||
$this->width = $width;
|
||||
} else {
|
||||
$this->width = (int) ceil($yratio * $this->width);
|
||||
$this->width = (int) \ceil($yratio * $this->width);
|
||||
$this->height = $height;
|
||||
}
|
||||
}
|
||||
|
|
@ -245,6 +245,6 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->name . $this->description . parent::getHashCode() . __CLASS__);
|
||||
return \md5($this->name . $this->description . parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ class Chart extends AbstractGraphic implements ComparableInterface
|
|||
*/
|
||||
public function setDisplayBlankAs(string $value): self
|
||||
{
|
||||
if (in_array($value, [self::BLANKAS_GAP, self::BLANKAS_SPAN, self::BLANKAS_ZERO])) {
|
||||
if (\in_array($value, [self::BLANKAS_GAP, self::BLANKAS_SPAN, self::BLANKAS_ZERO])) {
|
||||
$this->displayBlankAs = $value;
|
||||
}
|
||||
|
||||
|
|
@ -209,6 +209,6 @@ class Chart extends AbstractGraphic implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . $this->title->getHashCode() . $this->legend->getHashCode() . $this->plotArea->getHashCode() . $this->view3D->getHashCode() . ($this->includeSpreadsheet ? 1 : 0) . __CLASS__);
|
||||
return \md5(parent::getHashCode() . $this->title->getHashCode() . $this->legend->getHashCode() . $this->plotArea->getHashCode() . $this->view3D->getHashCode() . ($this->includeSpreadsheet ? 1 : 0) . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ class Axis implements ComparableInterface
|
|||
*/
|
||||
public function setMinBounds(int $minBounds = null): self
|
||||
{
|
||||
$this->minBounds = is_null($minBounds) ? null : $minBounds;
|
||||
$this->minBounds = \is_null($minBounds) ? null : $minBounds;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -252,7 +252,7 @@ class Axis implements ComparableInterface
|
|||
*/
|
||||
public function setMaxBounds(int $maxBounds = null): self
|
||||
{
|
||||
$this->maxBounds = is_null($maxBounds) ? null : $maxBounds;
|
||||
$this->maxBounds = \is_null($maxBounds) ? null : $maxBounds;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -454,7 +454,7 @@ class Axis implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->title . $this->formatCode . __CLASS__);
|
||||
return \md5($this->title . $this->formatCode . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -533,7 +533,7 @@ class Axis implements ComparableInterface
|
|||
*/
|
||||
public function setTickLabelPosition(string $value = self::TICK_LABEL_POSITION_NEXT_TO): self
|
||||
{
|
||||
if (in_array($value, [
|
||||
if (\in_array($value, [
|
||||
self::TICK_LABEL_POSITION_HIGH,
|
||||
self::TICK_LABEL_POSITION_LOW,
|
||||
self::TICK_LABEL_POSITION_NEXT_TO,
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ class Legend implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
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__);
|
||||
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__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class PlotArea implements ComparableInterface
|
|||
*/
|
||||
public function getType(): AbstractType
|
||||
{
|
||||
if (is_null($this->type)) {
|
||||
if (\is_null($this->type)) {
|
||||
throw new UndefinedChartTypeException();
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ class PlotArea implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
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__);
|
||||
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__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ class Series implements ComparableInterface
|
|||
|
||||
public function hasShowSeparator(): bool
|
||||
{
|
||||
return !is_null($this->separator);
|
||||
return !\is_null($this->separator);
|
||||
}
|
||||
|
||||
public function setSeparator(?string $pValue): self
|
||||
|
|
@ -477,7 +477,7 @@ class Series implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
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__);
|
||||
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__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -515,7 +515,7 @@ class Series implements ComparableInterface
|
|||
{
|
||||
$this->font = clone $this->font;
|
||||
$this->marker = clone $this->marker;
|
||||
if (is_object($this->outline)) {
|
||||
if (\is_object($this->outline)) {
|
||||
$this->outline = clone $this->outline;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ class Title implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->text . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__);
|
||||
return \md5($this->text . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -60,6 +60,6 @@ class AbstractTypeLine extends AbstractType
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->isSmooth() ? '1' : '0');
|
||||
return \md5($this->isSmooth() ? '1' : '0');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,6 @@ class Area extends AbstractType implements ComparableInterface
|
|||
$hash .= $series->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hash . __CLASS__);
|
||||
return \md5($hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ class Bar extends AbstractTypeBar implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
return \md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ class Bar3D extends AbstractTypeBar implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
return \md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,6 @@ class Doughnut extends AbstractTypePie implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
return \md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ class Line extends AbstractTypeLine implements ComparableInterface
|
|||
$hash .= $series->getHashCode();
|
||||
}
|
||||
|
||||
return md5(parent::getHashCode() . $hash . __CLASS__);
|
||||
return \md5(parent::getHashCode() . $hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ class Pie extends AbstractTypePie implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
return \md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ class Pie3D extends AbstractTypePie implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
return \md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ class Radar extends AbstractType implements ComparableInterface
|
|||
$hash .= $series->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hash . __CLASS__);
|
||||
return \md5($hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ class Scatter extends AbstractTypeLine implements ComparableInterface
|
|||
$hash .= $series->getHashCode();
|
||||
}
|
||||
|
||||
return md5(parent::getHashCode() . $hash . __CLASS__);
|
||||
return \md5(parent::getHashCode() . $hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ class View3D implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->rotationX . $this->rotationY . ($this->rightAngleAxes ? 't' : 'f') . $this->perspective . $this->heightPercent . $this->depthPercent . __CLASS__);
|
||||
return \md5($this->rotationX . $this->rotationY . ($this->rightAngleAxes ? 't' : 'f') . $this->perspective . $this->heightPercent . $this->depthPercent . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Comment extends AbstractShape implements ComparableInterface
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setDate(time());
|
||||
$this->setDate(\time());
|
||||
}
|
||||
|
||||
public function getAuthor(): ?Author
|
||||
|
|
|
|||
|
|
@ -104,6 +104,6 @@ class Author
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->getInitials() . $this->getName() . __CLASS__);
|
||||
return \md5($this->getInitials() . $this->getName() . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Base64 extends AbstractDrawingAdapter
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999));
|
||||
$this->uniqueName = \md5(\rand(0, 9999) . \time() . \rand(0, 9999));
|
||||
$this->data = '';
|
||||
}
|
||||
|
||||
|
|
@ -75,10 +75,10 @@ class Base64 extends AbstractDrawingAdapter
|
|||
|
||||
public function getContents(): string
|
||||
{
|
||||
list(, $imageContents) = explode(';', $this->getData());
|
||||
list(, $imageContents) = explode(',', $imageContents);
|
||||
list(, $imageContents) = \explode(';', $this->getData());
|
||||
list(, $imageContents) = \explode(',', $imageContents);
|
||||
|
||||
return base64_decode($imageContents);
|
||||
return \base64_decode($imageContents);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -86,10 +86,10 @@ class Base64 extends AbstractDrawingAdapter
|
|||
*/
|
||||
public function getExtension(): string
|
||||
{
|
||||
list($data) = explode(';', $this->getData());
|
||||
list(, $mime) = explode(':', $data);
|
||||
list($data) = \explode(';', $this->getData());
|
||||
list(, $mime) = \explode(':', $data);
|
||||
|
||||
if (!array_key_exists($mime, $this->arrayMimeExtension)) {
|
||||
if (!\array_key_exists($mime, $this->arrayMimeExtension)) {
|
||||
throw new UnauthorizedMimetypeException($mime, $this->arrayMimeExtension);
|
||||
}
|
||||
|
||||
|
|
@ -103,22 +103,22 @@ class Base64 extends AbstractDrawingAdapter
|
|||
|
||||
public function getMimeType(): string
|
||||
{
|
||||
list($data) = explode(';', $this->getData());
|
||||
list(, $mime) = explode(':', $data);
|
||||
list($data) = \explode(';', $this->getData());
|
||||
list(, $mime) = \explode(':', $data);
|
||||
|
||||
if (!empty($mime)) {
|
||||
return $mime;
|
||||
}
|
||||
|
||||
$sImage = $this->getContents();
|
||||
if (!function_exists('getimagesizefromstring')) {
|
||||
$uri = 'data://application/octet-stream;base64,' . base64_encode($sImage);
|
||||
$image = getimagesize($uri);
|
||||
if (!\function_exists('getimagesizefromstring')) {
|
||||
$uri = 'data://application/octet-stream;base64,' . \base64_encode($sImage);
|
||||
$image = \getimagesize($uri);
|
||||
} else {
|
||||
$image = getimagesizefromstring($sImage);
|
||||
$image = \getimagesizefromstring($sImage);
|
||||
}
|
||||
|
||||
return image_type_to_mime_type($image[2]);
|
||||
return \image_type_to_mime_type($image[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class File extends AbstractDrawingAdapter
|
|||
public function setPath(string $pValue = '', bool $pVerifyFile = true): self
|
||||
{
|
||||
if ($pVerifyFile) {
|
||||
if (!file_exists($pValue)) {
|
||||
if (!\file_exists($pValue)) {
|
||||
throw new FileNotFoundException($pValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ class File extends AbstractDrawingAdapter
|
|||
|
||||
if ($pVerifyFile) {
|
||||
if (0 == $this->width && 0 == $this->height) {
|
||||
list($this->width, $this->height) = getimagesize($this->getPath());
|
||||
list($this->width, $this->height) = \getimagesize($this->getPath());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ class File extends AbstractDrawingAdapter
|
|||
|
||||
public function getExtension(): string
|
||||
{
|
||||
return pathinfo($this->getPath(), PATHINFO_EXTENSION);
|
||||
return \pathinfo($this->getPath(), PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,21 +84,21 @@ class File extends AbstractDrawingAdapter
|
|||
if (!CommonFile::fileExists($this->getPath())) {
|
||||
throw new FileNotFoundException($this->getPath());
|
||||
}
|
||||
$image = getimagesizefromstring(CommonFile::fileGetContents($this->getPath()));
|
||||
$image = \getimagesizefromstring(CommonFile::fileGetContents($this->getPath()));
|
||||
|
||||
if (is_array($image)) {
|
||||
return image_type_to_mime_type($image[2]);
|
||||
if (\is_array($image)) {
|
||||
return \image_type_to_mime_type($image[2]);
|
||||
}
|
||||
|
||||
return mime_content_type($this->getPath());
|
||||
return \mime_content_type($this->getPath());
|
||||
}
|
||||
|
||||
public function getIndexedFilename(): string
|
||||
{
|
||||
$output = str_replace('.' . $this->getExtension(), '', pathinfo($this->getPath(), PATHINFO_FILENAME));
|
||||
$output = \str_replace('.' . $this->getExtension(), '', \pathinfo($this->getPath(), PATHINFO_FILENAME));
|
||||
$output .= $this->getImageIndex();
|
||||
$output .= '.' . $this->getExtension();
|
||||
$output = str_replace(' ', '_', $output);
|
||||
$output = \str_replace(' ', '_', $output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class Gd extends AbstractDrawingAdapter
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999));
|
||||
$this->uniqueName = \md5(\rand(0, 9999) . \time() . \rand(0, 9999));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,10 +92,10 @@ class Gd extends AbstractDrawingAdapter
|
|||
{
|
||||
$this->imageResource = $value;
|
||||
|
||||
if (!is_null($this->imageResource)) {
|
||||
if (!\is_null($this->imageResource)) {
|
||||
// Get width/height
|
||||
$this->width = imagesx($this->imageResource);
|
||||
$this->height = imagesy($this->imageResource);
|
||||
$this->width = \imagesx($this->imageResource);
|
||||
$this->height = \imagesy($this->imageResource);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -149,22 +149,22 @@ class Gd extends AbstractDrawingAdapter
|
|||
|
||||
public function getContents(): string
|
||||
{
|
||||
ob_start();
|
||||
\ob_start();
|
||||
if (self::MIMETYPE_DEFAULT === $this->getMimeType()) {
|
||||
imagealphablending($this->getImageResource(), false);
|
||||
imagesavealpha($this->getImageResource(), true);
|
||||
\imagealphablending($this->getImageResource(), false);
|
||||
\imagesavealpha($this->getImageResource(), true);
|
||||
}
|
||||
call_user_func($this->getRenderingFunction(), $this->getImageResource());
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
\call_user_func($this->getRenderingFunction(), $this->getImageResource());
|
||||
$imageContents = \ob_get_contents();
|
||||
\ob_end_clean();
|
||||
|
||||
return $imageContents;
|
||||
}
|
||||
|
||||
public function getExtension(): string
|
||||
{
|
||||
$extension = strtolower($this->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = \strtolower($this->getMimeType());
|
||||
$extension = \explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
||||
return $extension;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class ZipFile extends AbstractDrawingAdapter
|
|||
|
||||
public function getExtension(): string
|
||||
{
|
||||
return pathinfo($this->getZipFileIn(), PATHINFO_EXTENSION);
|
||||
return \pathinfo($this->getZipFileIn(), PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -85,39 +85,39 @@ class ZipFile extends AbstractDrawingAdapter
|
|||
}
|
||||
$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);
|
||||
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()));
|
||||
$image = \getimagesizefromstring($oArchive->getFromName($this->getZipFileIn()));
|
||||
}
|
||||
|
||||
return image_type_to_mime_type($image[2]);
|
||||
return \image_type_to_mime_type($image[2]);
|
||||
}
|
||||
|
||||
public function getIndexedFilename(): string
|
||||
{
|
||||
$output = pathinfo($this->getZipFileIn(), PATHINFO_FILENAME);
|
||||
$output = str_replace('.' . $this->getExtension(), '', $output);
|
||||
$output = \pathinfo($this->getZipFileIn(), PATHINFO_FILENAME);
|
||||
$output = \str_replace('.' . $this->getExtension(), '', $output);
|
||||
$output .= $this->getImageIndex();
|
||||
$output .= '.' . $this->getExtension();
|
||||
$output = str_replace(' ', '_', $output);
|
||||
$output = \str_replace(' ', '_', $output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function getZipFileOut(): string
|
||||
{
|
||||
$path = str_replace('zip://', '', $this->getPath());
|
||||
$path = explode('#', $path);
|
||||
$path = \str_replace('zip://', '', $this->getPath());
|
||||
$path = \explode('#', $path);
|
||||
|
||||
return empty($path[0]) ? '' : $path[0];
|
||||
}
|
||||
|
||||
protected function getZipFileIn(): string
|
||||
{
|
||||
$path = str_replace('zip://', '', $this->getPath());
|
||||
$path = explode('#', $path);
|
||||
$path = \str_replace('zip://', '', $this->getPath());
|
||||
$path = \explode('#', $path);
|
||||
|
||||
return empty($path[1]) ? '' : $path[1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
/**
|
||||
* Collection of shapes.
|
||||
*
|
||||
* @var array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
* @var array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
private $shapeCollection;
|
||||
|
||||
|
|
@ -53,13 +53,13 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
parent::__construct();
|
||||
|
||||
// Shape collection
|
||||
$this->shapeCollection = new ArrayObject();
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of shapes.
|
||||
*
|
||||
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
* @return array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class Hyperlink
|
|||
*/
|
||||
public function isInternal(): bool
|
||||
{
|
||||
return false !== strpos($this->url, 'ppaction://');
|
||||
return false !== \strpos($this->url, 'ppaction://');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -169,7 +169,7 @@ class Hyperlink
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->url . $this->tooltip . __CLASS__);
|
||||
return \md5($this->url . $this->tooltip . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -55,6 +55,6 @@ class Line extends AbstractShape implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->getBorder()->getLineStyle() . parent::getHashCode() . __CLASS__);
|
||||
return \md5($this->getBorder()->getLineStyle() . parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Media extends File implements ComparableInterface
|
|||
{
|
||||
public function getMimeType(): string
|
||||
{
|
||||
switch (strtolower($this->getExtension())) {
|
||||
switch (\strtolower($this->getExtension())) {
|
||||
case 'mp4':
|
||||
$mimetype = 'video/mp4';
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -207,8 +207,8 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
*/
|
||||
public function setActiveParagraph(int $index = 0): Paragraph
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index);
|
||||
if ($index >= \count($this->richTextParagraphs)) {
|
||||
throw new OutOfBoundsException(0, \count($this->richTextParagraphs), $index);
|
||||
}
|
||||
|
||||
$this->activeParagraph = $index;
|
||||
|
|
@ -223,8 +223,8 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
*/
|
||||
public function getParagraph(int $index = 0): Paragraph
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index);
|
||||
if ($index >= \count($this->richTextParagraphs)) {
|
||||
throw new OutOfBoundsException(0, \count($this->richTextParagraphs), $index);
|
||||
}
|
||||
|
||||
return $this->richTextParagraphs[$index];
|
||||
|
|
@ -235,7 +235,7 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
*/
|
||||
public function createParagraph(): Paragraph
|
||||
{
|
||||
$numParagraphs = count($this->richTextParagraphs);
|
||||
$numParagraphs = \count($this->richTextParagraphs);
|
||||
if ($numParagraphs > 0) {
|
||||
$alignment = clone $this->getActiveParagraph()->getAlignment();
|
||||
$font = clone $this->getActiveParagraph()->getFont();
|
||||
|
|
@ -243,7 +243,7 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
$this->richTextParagraphs[] = new Paragraph();
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
$this->activeParagraph = \count($this->richTextParagraphs) - 1;
|
||||
|
||||
if (isset($alignment)) {
|
||||
$this->getActiveParagraph()->setAlignment($alignment);
|
||||
|
|
@ -351,7 +351,7 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
public function setParagraphs(array $paragraphs = []): self
|
||||
{
|
||||
$this->richTextParagraphs = $paragraphs;
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
$this->activeParagraph = \count($this->richTextParagraphs) - 1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -419,11 +419,11 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
{
|
||||
$this->autoFit = $value;
|
||||
|
||||
if (!is_null($fontScale)) {
|
||||
if (!\is_null($fontScale)) {
|
||||
$this->fontScale = $fontScale;
|
||||
}
|
||||
|
||||
if (!is_null($lnSpcReduction)) {
|
||||
if (!\is_null($lnSpcReduction)) {
|
||||
$this->lnSpcReduction = $lnSpcReduction;
|
||||
}
|
||||
|
||||
|
|
@ -722,7 +722,7 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5(
|
||||
return \md5(
|
||||
$hashElements
|
||||
. $this->wrap
|
||||
. $this->autoFit
|
||||
|
|
|
|||
|
|
@ -87,6 +87,6 @@ class BreakElement implements TextElementInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(__CLASS__);
|
||||
return \md5(__CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ class Paragraph implements ComparableInterface
|
|||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . $this->font->getHashCode() . __CLASS__);
|
||||
return \md5($hashElements . $this->font->getHashCode() . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -337,7 +337,7 @@ class Paragraph implements ComparableInterface
|
|||
*/
|
||||
public function setLineSpacingMode(string $lineSpacingMode): self
|
||||
{
|
||||
if (in_array($lineSpacingMode, [
|
||||
if (\in_array($lineSpacingMode, [
|
||||
self::LINE_SPACING_MODE_PERCENT,
|
||||
self::LINE_SPACING_MODE_POINT,
|
||||
])) {
|
||||
|
|
|
|||
|
|
@ -75,6 +75,6 @@ class Run extends TextElement implements TextElementInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->getText() . $this->font->getHashCode() . __CLASS__);
|
||||
return \md5($this->getText() . $this->font->getHashCode() . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,12 +92,12 @@ class TextElement implements TextElementInterface
|
|||
|
||||
public function hasHyperlink(): bool
|
||||
{
|
||||
return !is_null($this->hyperlink);
|
||||
return !\is_null($this->hyperlink);
|
||||
}
|
||||
|
||||
public function getHyperlink(): Hyperlink
|
||||
{
|
||||
if (is_null($this->hyperlink)) {
|
||||
if (\is_null($this->hyperlink)) {
|
||||
$this->hyperlink = new Hyperlink();
|
||||
}
|
||||
|
||||
|
|
@ -147,6 +147,6 @@ class TextElement implements TextElementInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->text . (is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
|
||||
return \md5($this->text . (\is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Table extends AbstractGraphic implements ComparableInterface
|
|||
if (!isset($this->rows[$row])) {
|
||||
throw new OutOfBoundsException(
|
||||
0,
|
||||
(count($this->rows) - 1) < 0 ? 0 : count($this->rows) - 1,
|
||||
(\count($this->rows) - 1) < 0 ? 0 : \count($this->rows) - 1,
|
||||
$row
|
||||
);
|
||||
}
|
||||
|
|
@ -144,6 +144,6 @@ class Table extends AbstractGraphic implements ComparableInterface
|
|||
$hashElements .= $row->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . __CLASS__);
|
||||
return \md5($hashElements . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,8 +133,8 @@ class Cell implements ComparableInterface
|
|||
*/
|
||||
public function setActiveParagraph($index = 0): Paragraph
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index);
|
||||
if ($index >= \count($this->richTextParagraphs)) {
|
||||
throw new OutOfBoundsException(0, \count($this->richTextParagraphs), $index);
|
||||
}
|
||||
|
||||
$this->activeParagraph = $index;
|
||||
|
|
@ -151,8 +151,8 @@ class Cell implements ComparableInterface
|
|||
*/
|
||||
public function getParagraph(int $index = 0): Paragraph
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index);
|
||||
if ($index >= \count($this->richTextParagraphs)) {
|
||||
throw new OutOfBoundsException(0, \count($this->richTextParagraphs), $index);
|
||||
}
|
||||
|
||||
return $this->richTextParagraphs[$index];
|
||||
|
|
@ -164,7 +164,7 @@ class Cell implements ComparableInterface
|
|||
public function createParagraph(): Paragraph
|
||||
{
|
||||
$this->richTextParagraphs[] = new Paragraph();
|
||||
$totalRichTextParagraphs = count($this->richTextParagraphs);
|
||||
$totalRichTextParagraphs = \count($this->richTextParagraphs);
|
||||
$this->activeParagraph = $totalRichTextParagraphs - 1;
|
||||
|
||||
if ($totalRichTextParagraphs > 1) {
|
||||
|
|
@ -277,7 +277,7 @@ class Cell implements ComparableInterface
|
|||
public function setParagraphs(array $paragraphs = []): self
|
||||
{
|
||||
$this->richTextParagraphs = $paragraphs;
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
$this->activeParagraph = \count($this->richTextParagraphs) - 1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -384,7 +384,7 @@ class Cell implements ComparableInterface
|
|||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . $this->fill->getHashCode() . $this->borders->getHashCode() . $this->width . __CLASS__);
|
||||
return \md5($hashElements . $this->fill->getHashCode() . $this->borders->getHashCode() . $this->width . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class Row implements ComparableInterface
|
|||
if (!isset($this->cells[$cell])) {
|
||||
throw new OutOfBoundsException(
|
||||
0,
|
||||
(count($this->cells) - 1) < 0 ? count($this->cells) - 1 : 0,
|
||||
(\count($this->cells) - 1) < 0 ? \count($this->cells) - 1 : 0,
|
||||
$cell
|
||||
);
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ class Row implements ComparableInterface
|
|||
|
||||
throw new OutOfBoundsException(
|
||||
0,
|
||||
(count($this->cells) - 1) < 0 ? count($this->cells) - 1 : 0,
|
||||
(\count($this->cells) - 1) < 0 ? \count($this->cells) - 1 : 0,
|
||||
$this->activeCellIndex
|
||||
);
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ class Row implements ComparableInterface
|
|||
$hashElements .= $cell->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . $this->fill->getHashCode() . $this->height . __CLASS__);
|
||||
return \md5($hashElements . $this->fill->getHashCode() . $this->height . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ interface ShapeContainerInterface
|
|||
/**
|
||||
* Get collection of shapes.
|
||||
*
|
||||
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
* @return array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
public function getShapeCollection();
|
||||
|
||||
|
|
|
|||
|
|
@ -79,13 +79,13 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
|
|||
// Shape collection
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
// Set identifier
|
||||
$this->identifier = md5(rand(0, 9999) . time());
|
||||
$this->identifier = \md5(\rand(0, 9999) . \time());
|
||||
// Set Slide Layout
|
||||
if ($this->parent instanceof PhpPresentation) {
|
||||
$arrayMasterSlides = $this->parent->getAllMasterSlides();
|
||||
$oMasterSlide = reset($arrayMasterSlides);
|
||||
$oMasterSlide = \reset($arrayMasterSlides);
|
||||
$arraySlideLayouts = $oMasterSlide->getAllSlideLayouts();
|
||||
$oSlideLayout = reset($arraySlideLayouts);
|
||||
$oSlideLayout = \reset($arraySlideLayouts);
|
||||
$this->setSlideLayout($oSlideLayout);
|
||||
}
|
||||
// Set note
|
||||
|
|
@ -153,7 +153,7 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
|
|||
|
||||
public function setNote(Note $note = null): self
|
||||
{
|
||||
$this->slideNote = (is_null($note) ? new Note() : $note);
|
||||
$this->slideNote = (\is_null($note) ? new Note() : $note);
|
||||
$this->slideNote->setParent($this);
|
||||
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ abstract class AbstractSlide implements ComparableInterface, ShapeContainerInter
|
|||
/**
|
||||
* Collection of shapes.
|
||||
*
|
||||
* @var array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
* @var array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
protected $shapeCollection = [];
|
||||
/**
|
||||
|
|
@ -102,7 +102,7 @@ abstract class AbstractSlide implements ComparableInterface, ShapeContainerInter
|
|||
/**
|
||||
* Get collection of shapes.
|
||||
*
|
||||
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
* @return array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
|
|
@ -112,7 +112,7 @@ abstract class AbstractSlide implements ComparableInterface, ShapeContainerInter
|
|||
/**
|
||||
* Get collection of shapes.
|
||||
*
|
||||
* @param array<int, AbstractShape>|ArrayObject<int, AbstractShape> $shapeCollection
|
||||
* @param array<int, AbstractShape>|\ArrayObject<int, AbstractShape> $shapeCollection
|
||||
*
|
||||
* @return AbstractSlide
|
||||
*/
|
||||
|
|
@ -198,7 +198,7 @@ abstract class AbstractSlide implements ComparableInterface, ShapeContainerInter
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->identifier . __CLASS__);
|
||||
return \md5($this->identifier . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -70,13 +70,13 @@ class Image extends AbstractBackground
|
|||
public function setPath(string $pValue = '', bool $pVerifyFile = true)
|
||||
{
|
||||
if ($pVerifyFile) {
|
||||
if (!file_exists($pValue)) {
|
||||
if (!\file_exists($pValue)) {
|
||||
throw new FileNotFoundException($pValue);
|
||||
}
|
||||
|
||||
if (0 == $this->width && 0 == $this->height) {
|
||||
// Get width/height
|
||||
list($this->width, $this->height) = getimagesize($pValue);
|
||||
list($this->width, $this->height) = \getimagesize($pValue);
|
||||
}
|
||||
}
|
||||
$this->path = $pValue;
|
||||
|
|
@ -91,7 +91,7 @@ class Image extends AbstractBackground
|
|||
*/
|
||||
public function getFilename(): string
|
||||
{
|
||||
return $this->path ? basename($this->path) : '';
|
||||
return $this->path ? \basename($this->path) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,9 +101,9 @@ class Image extends AbstractBackground
|
|||
*/
|
||||
public function getExtension(): string
|
||||
{
|
||||
$exploded = explode('.', $this->getFilename());
|
||||
$exploded = \explode('.', $this->getFilename());
|
||||
|
||||
return $exploded[count($exploded) - 1];
|
||||
return $exploded[\count($exploded) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use IteratorIterator;
|
|||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
class Iterator extends IteratorIterator
|
||||
class Iterator extends \IteratorIterator
|
||||
{
|
||||
/**
|
||||
* Presentation to iterate.
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Note implements ComparableInterface, ShapeContainerInterface
|
|||
/**
|
||||
* Collection of shapes.
|
||||
*
|
||||
* @var array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
* @var array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
private $shapeCollection;
|
||||
|
||||
|
|
@ -97,16 +97,16 @@ class Note implements ComparableInterface, ShapeContainerInterface
|
|||
$this->parent = $pParent;
|
||||
|
||||
// Shape collection
|
||||
$this->shapeCollection = new ArrayObject();
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
|
||||
// Set identifier
|
||||
$this->identifier = md5(rand(0, 9999) . time());
|
||||
$this->identifier = \md5(\rand(0, 9999) . \time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of shapes.
|
||||
*
|
||||
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
* @return array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
|
|
@ -221,7 +221,7 @@ class Note implements ComparableInterface, ShapeContainerInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->identifier . __CLASS__);
|
||||
return \md5($this->identifier . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class SlideLayout extends AbstractSlide implements ComparableInterface, ShapeCon
|
|||
// Shape collection
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
// Set identifier
|
||||
$this->identifier = md5(rand(0, 9999) . time());
|
||||
$this->identifier = \md5(\rand(0, 9999) . \time());
|
||||
// Set a basic colorMap
|
||||
$this->colorMap = new ColorMap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class SlideMaster extends AbstractSlide implements ComparableInterface, ShapeCon
|
|||
// Shape collection
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
// Set identifier
|
||||
$this->identifier = md5(rand(0, 9999) . time());
|
||||
$this->identifier = \md5(\rand(0, 9999) . \time());
|
||||
// Set a basic colorMap
|
||||
$this->colorMap = new ColorMap();
|
||||
// Set a white background
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class Transition
|
|||
|
||||
public function setSpeed(?string $speed = self::SPEED_MEDIUM): self
|
||||
{
|
||||
if (in_array($speed, [self::SPEED_FAST, self::SPEED_MEDIUM, self::SPEED_SLOW])) {
|
||||
if (\in_array($speed, [self::SPEED_FAST, self::SPEED_MEDIUM, self::SPEED_SLOW])) {
|
||||
$this->speed = $speed;
|
||||
} else {
|
||||
$this->speed = null;
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class Alignment implements ComparableInterface
|
|||
*/
|
||||
public function setIndent(float $pValue = 0): self
|
||||
{
|
||||
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) {
|
||||
if ($pValue > 0 && !\in_array($this->getHorizontal(), $this->supportedStyles)) {
|
||||
$pValue = 0; // indent not supported
|
||||
}
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ class Alignment implements ComparableInterface
|
|||
*/
|
||||
public function setMarginLeft(float $pValue = 0): self
|
||||
{
|
||||
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) {
|
||||
if ($pValue > 0 && !\in_array($this->getHorizontal(), $this->supportedStyles)) {
|
||||
$pValue = 0; // margin left not supported
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ class Alignment implements ComparableInterface
|
|||
*/
|
||||
public function setMarginRight(float $pValue = 0): self
|
||||
{
|
||||
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) {
|
||||
if ($pValue > 0 && !\in_array($this->getHorizontal(), $this->supportedStyles)) {
|
||||
$pValue = 0; // margin right not supported
|
||||
}
|
||||
|
||||
|
|
@ -343,7 +343,7 @@ class Alignment implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(
|
||||
return \md5(
|
||||
$this->horizontal
|
||||
. $this->vertical
|
||||
. $this->level
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ class Border implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(
|
||||
return \md5(
|
||||
$this->lineStyle
|
||||
. $this->lineWidth
|
||||
. $this->dashStyle
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class Borders implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(
|
||||
return \md5(
|
||||
$this->getLeft()->getHashCode()
|
||||
. $this->getRight()->getHashCode()
|
||||
. $this->getTop()->getHashCode()
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ class Bullet implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(
|
||||
return \md5(
|
||||
$this->bulletType
|
||||
. $this->bulletFont
|
||||
. $this->bulletChar
|
||||
|
|
|
|||
|
|
@ -100,9 +100,9 @@ class Color implements ComparableInterface
|
|||
public function getAlpha(): int
|
||||
{
|
||||
$alpha = 100;
|
||||
if (strlen($this->argb) >= 6) {
|
||||
$dec = hexdec(substr($this->argb, 0, 2));
|
||||
$alpha = (int) number_format(($dec / 255) * 100, 0);
|
||||
if (\strlen($this->argb) >= 6) {
|
||||
$dec = \hexdec(\substr($this->argb, 0, 2));
|
||||
$alpha = (int) \number_format(($dec / 255) * 100, 0);
|
||||
}
|
||||
|
||||
return $alpha;
|
||||
|
|
@ -123,10 +123,10 @@ class Color implements ComparableInterface
|
|||
if ($alpha > 100) {
|
||||
$alpha = 100;
|
||||
}
|
||||
$alpha = round(($alpha / 100) * 255);
|
||||
$alpha = dechex((int) $alpha);
|
||||
$alpha = str_pad($alpha, 2, '0', STR_PAD_LEFT);
|
||||
$this->argb = $alpha . substr($this->argb, 2);
|
||||
$alpha = \round(($alpha / 100) * 255);
|
||||
$alpha = \dechex((int) $alpha);
|
||||
$alpha = \str_pad($alpha, 2, '0', STR_PAD_LEFT);
|
||||
$this->argb = $alpha . \substr($this->argb, 2);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -138,10 +138,10 @@ class Color implements ComparableInterface
|
|||
*/
|
||||
public function getRGB()
|
||||
{
|
||||
if (6 == strlen($this->argb)) {
|
||||
if (6 == \strlen($this->argb)) {
|
||||
return $this->argb;
|
||||
} else {
|
||||
return substr($this->argb, 2);
|
||||
return \substr($this->argb, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ class Color implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(
|
||||
return \md5(
|
||||
$this->argb
|
||||
. __CLASS__
|
||||
);
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ class Fill implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(
|
||||
return \md5(
|
||||
$this->getFillType()
|
||||
. $this->getRotation()
|
||||
. $this->getStartColor()->getHashCode()
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ class Font implements ComparableInterface
|
|||
*/
|
||||
public function setFormat(string $value = self::FORMAT_LATIN): self
|
||||
{
|
||||
if (in_array($value, [
|
||||
if (\in_array($value, [
|
||||
self::FORMAT_COMPLEX_SCRIPT,
|
||||
self::FORMAT_EAST_ASIAN,
|
||||
self::FORMAT_LATIN,
|
||||
|
|
@ -394,7 +394,7 @@ class Font implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(
|
||||
return \md5(
|
||||
$this->name
|
||||
. $this->size
|
||||
. ($this->bold ? 't' : 'f')
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ class Shadow implements ComparableInterface
|
|||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(($this->visible ? 't' : 'f') . $this->blurRadius . $this->distance . $this->direction . $this->alignment . $this->color->getHashCode() . $this->alpha . __CLASS__);
|
||||
return \md5(($this->visible ? 't' : 'f') . $this->blurRadius . $this->distance . $this->direction . $this->alignment . $this->color->getHashCode() . $this->alpha . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class TextStyle
|
|||
|
||||
private function checkLvl(?int $lvl): bool
|
||||
{
|
||||
if (is_null($lvl) || $lvl > 9) {
|
||||
if (\is_null($lvl) || $lvl > 9) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,31 +105,31 @@ abstract class AbstractWriter
|
|||
// Get an array of all master slides
|
||||
$aSlideMasters = $this->getPhpPresentation()->getAllMasterSlides();
|
||||
|
||||
$aSlideMasterLayouts = array_map(function ($oSlideMaster) {
|
||||
$aSlideMasterLayouts = \array_map(function ($oSlideMaster) {
|
||||
return $oSlideMaster->getAllSlideLayouts();
|
||||
}, $aSlideMasters);
|
||||
|
||||
// Get an array of all slide layouts
|
||||
$aSlideLayouts = [];
|
||||
array_walk_recursive($aSlideMasterLayouts, function ($oSlideLayout) use (&$aSlideLayouts) {
|
||||
\array_walk_recursive($aSlideMasterLayouts, function ($oSlideLayout) use (&$aSlideLayouts) {
|
||||
$aSlideLayouts[] = $oSlideLayout;
|
||||
});
|
||||
|
||||
// Loop through PhpPresentation
|
||||
foreach (array_merge($this->getPhpPresentation()->getAllSlides(), $aSlideMasters, $aSlideLayouts) as $oSlide) {
|
||||
foreach (\array_merge($this->getPhpPresentation()->getAllSlides(), $aSlideMasters, $aSlideLayouts) as $oSlide) {
|
||||
$arrayReturn = $this->iterateCollection($oSlide->getShapeCollection()->getIterator());
|
||||
$aDrawings = array_merge($aDrawings, $arrayReturn);
|
||||
$aDrawings = \array_merge($aDrawings, $arrayReturn);
|
||||
}
|
||||
|
||||
return $aDrawings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayIterator<int, AbstractShape> $oIterator
|
||||
* @param \ArrayIterator<int, AbstractShape> $oIterator
|
||||
*
|
||||
* @return array<int, AbstractShape>
|
||||
*/
|
||||
private function iterateCollection(ArrayIterator $oIterator): array
|
||||
private function iterateCollection(\ArrayIterator $oIterator): array
|
||||
{
|
||||
$arrayReturn = [];
|
||||
if ($oIterator->count() <= 0) {
|
||||
|
|
@ -144,7 +144,7 @@ abstract class AbstractWriter
|
|||
$arrayReturn[] = $oShape;
|
||||
} elseif ($oShape instanceof Group) {
|
||||
$arrayGroup = $this->iterateCollection($oShape->getShapeCollection()->getIterator());
|
||||
$arrayReturn = array_merge($arrayReturn, $arrayGroup);
|
||||
$arrayReturn = \array_merge($arrayReturn, $arrayGroup);
|
||||
}
|
||||
$oIterator->next();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ class ODPresentation extends AbstractWriter implements WriterInterface
|
|||
}
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if ('php://output' == strtolower($pFilename) || 'php://stdout' == strtolower($pFilename)) {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ('php://output' == \strtolower($pFilename) || 'php://stdout' == \strtolower($pFilename)) {
|
||||
$pFilename = @\tempnam('./', 'phppttmp');
|
||||
if ('' == $pFilename) {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ class ODPresentation extends AbstractWriter implements WriterInterface
|
|||
$arrayChart = [];
|
||||
|
||||
$arrayFiles = [];
|
||||
$oDir = new DirectoryIterator(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ODPresentation');
|
||||
$oDir = new \DirectoryIterator(\dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ODPresentation');
|
||||
foreach ($oDir as $oFile) {
|
||||
if (!$oFile->isFile()) {
|
||||
continue;
|
||||
|
|
@ -120,7 +120,7 @@ class ODPresentation extends AbstractWriter implements WriterInterface
|
|||
$arrayFiles[$oFile->getBasename('.php')] = $class;
|
||||
}
|
||||
|
||||
ksort($arrayFiles);
|
||||
\ksort($arrayFiles);
|
||||
|
||||
foreach ($arrayFiles as $o) {
|
||||
$oService = $o->newInstance();
|
||||
|
|
@ -138,10 +138,10 @@ class ODPresentation extends AbstractWriter implements WriterInterface
|
|||
|
||||
// If a temporary file was used, copy it to the correct file stream
|
||||
if ($originalFilename != $pFilename) {
|
||||
if (false === copy($pFilename, $originalFilename)) {
|
||||
if (false === \copy($pFilename, $originalFilename)) {
|
||||
throw new FileCopyException($pFilename, $originalFilename);
|
||||
}
|
||||
if (false === @unlink($pFilename)) {
|
||||
if (false === @\unlink($pFilename)) {
|
||||
throw new FileRemoveException($pFilename);
|
||||
}
|
||||
}
|
||||
|
|
@ -171,8 +171,8 @@ class ODPresentation extends AbstractWriter implements WriterInterface
|
|||
{
|
||||
$this->useDiskCaching = $pValue;
|
||||
|
||||
if (!is_null($directory)) {
|
||||
if (!is_dir($directory)) {
|
||||
if (!\is_null($directory)) {
|
||||
if (!\is_dir($directory)) {
|
||||
throw new DirectoryNotFoundException($directory);
|
||||
}
|
||||
$this->diskCachingDirectory = $directory;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class Content extends AbstractDecoratorWriter
|
|||
if (!empty($this->arrStyleBullet)) {
|
||||
foreach ($this->arrStyleBullet as $key => $item) {
|
||||
$oStyle = $item['oStyle'];
|
||||
$arrLevel = explode(';', $item['level']);
|
||||
$arrLevel = \explode(';', $item['level']);
|
||||
// style:style
|
||||
$objWriter->startElement('text:list-style');
|
||||
$objWriter->writeAttribute('style:name', 'L_' . $key);
|
||||
|
|
@ -179,7 +179,7 @@ class Content extends AbstractDecoratorWriter
|
|||
$oAlign = $item['oAlign_' . $level];
|
||||
// text:list-level-style-bullet
|
||||
$objWriter->startElement('text:list-level-style-bullet');
|
||||
$objWriter->writeAttribute('text:level', intval($level) + 1);
|
||||
$objWriter->writeAttribute('text:level', \intval($level) + 1);
|
||||
$objWriter->writeAttribute('text:bullet-char', $oStyle->getBulletChar());
|
||||
// style:list-level-properties
|
||||
$objWriter->startElement('style:list-level-properties');
|
||||
|
|
@ -318,7 +318,7 @@ class Content extends AbstractDecoratorWriter
|
|||
$pSlide = $this->getPresentation()->getSlide($i);
|
||||
$objWriter->startElement('draw:page');
|
||||
$name = $pSlide->getName();
|
||||
if (!is_null($name)) {
|
||||
if (!\is_null($name)) {
|
||||
$objWriter->writeAttribute('draw:name', $name);
|
||||
}
|
||||
$objWriter->writeAttribute('draw:master-page-name', 'Standard');
|
||||
|
|
@ -638,13 +638,13 @@ class Content extends AbstractDecoratorWriter
|
|||
*/
|
||||
// officeooo:annotation
|
||||
$objWriter->startElement('officeooo:annotation');
|
||||
$objWriter->writeAttribute('svg:x', number_format(CommonDrawing::pixelsToCentimeters((int) $oShape->getOffsetX()), 2, '.', '') . 'cm');
|
||||
$objWriter->writeAttribute('svg:y', number_format(CommonDrawing::pixelsToCentimeters((int) $oShape->getOffsetY()), 2, '.', '') . 'cm');
|
||||
$objWriter->writeAttribute('svg:x', \number_format(CommonDrawing::pixelsToCentimeters((int) $oShape->getOffsetX()), 2, '.', '') . 'cm');
|
||||
$objWriter->writeAttribute('svg:y', \number_format(CommonDrawing::pixelsToCentimeters((int) $oShape->getOffsetY()), 2, '.', '') . 'cm');
|
||||
|
||||
if ($oShape->getAuthor() instanceof Comment\Author) {
|
||||
$objWriter->writeElement('dc:creator', $oShape->getAuthor()->getName());
|
||||
}
|
||||
$objWriter->writeElement('dc:date', date('Y-m-d\TH:i:s', $oShape->getDate()));
|
||||
$objWriter->writeElement('dc:date', \date('Y-m-d\TH:i:s', $oShape->getDate()));
|
||||
$objWriter->writeElement('text:p', $oShape->getText());
|
||||
|
||||
// ## officeooo:annotation
|
||||
|
|
@ -681,7 +681,7 @@ class Content extends AbstractDecoratorWriter
|
|||
|
||||
$arrayRows = $shape->getRows();
|
||||
if (!empty($arrayRows)) {
|
||||
$firstRow = reset($arrayRows);
|
||||
$firstRow = \reset($arrayRows);
|
||||
$arrayCells = $firstRow->getCells();
|
||||
// table:table
|
||||
$objWriter->startElement('table:table');
|
||||
|
|
@ -862,11 +862,11 @@ class Content extends AbstractDecoratorWriter
|
|||
$objWriter->startElement('style:graphic-properties');
|
||||
$objWriter->writeAttribute('style:mirror', 'none');
|
||||
$this->writeStylePartShadow($objWriter, $shape->getShadow());
|
||||
if (is_bool($shape->hasAutoShrinkVertical())) {
|
||||
$objWriter->writeAttribute('draw:auto-grow-height', var_export($shape->hasAutoShrinkVertical(), true));
|
||||
if (\is_bool($shape->hasAutoShrinkVertical())) {
|
||||
$objWriter->writeAttribute('draw:auto-grow-height', \var_export($shape->hasAutoShrinkVertical(), true));
|
||||
}
|
||||
if (is_bool($shape->hasAutoShrinkHorizontal())) {
|
||||
$objWriter->writeAttribute('draw:auto-grow-width', var_export($shape->hasAutoShrinkHorizontal(), true));
|
||||
if (\is_bool($shape->hasAutoShrinkHorizontal())) {
|
||||
$objWriter->writeAttribute('draw:auto-grow-width', \var_export($shape->hasAutoShrinkHorizontal(), true));
|
||||
}
|
||||
// Fill
|
||||
switch ($shape->getFill()->getFillType()) {
|
||||
|
|
@ -890,7 +890,7 @@ class Content extends AbstractDecoratorWriter
|
|||
$objWriter->writeAttribute('draw:stroke', 'none');
|
||||
} else {
|
||||
$objWriter->writeAttribute('svg:stroke-color', '#' . $shape->getBorder()->getColor()->getRGB());
|
||||
$objWriter->writeAttribute('svg:stroke-width', number_format(CommonDrawing::pointsToCentimeters($shape->getBorder()->getLineWidth()), 3, '.', '') . 'cm');
|
||||
$objWriter->writeAttribute('svg:stroke-width', \number_format(CommonDrawing::pointsToCentimeters($shape->getBorder()->getLineWidth()), 3, '.', '') . 'cm');
|
||||
switch ($shape->getBorder()->getDashStyle()) {
|
||||
case Border::DASH_SOLID:
|
||||
$objWriter->writeAttribute('draw:stroke', 'solid');
|
||||
|
|
@ -936,7 +936,7 @@ class Content extends AbstractDecoratorWriter
|
|||
$this->arrStyleBullet[$bulletStyleHashCode]['oStyle'] = $paragraph->getBulletStyle();
|
||||
$this->arrStyleBullet[$bulletStyleHashCode]['level'] = '';
|
||||
}
|
||||
if (false === strpos($this->arrStyleBullet[$bulletStyleHashCode]['level'], ';' . $paragraph->getAlignment()->getLevel())) {
|
||||
if (false === \strpos($this->arrStyleBullet[$bulletStyleHashCode]['level'], ';' . $paragraph->getAlignment()->getLevel())) {
|
||||
$this->arrStyleBullet[$bulletStyleHashCode]['level'] .= ';' . $paragraph->getAlignment()->getLevel();
|
||||
$this->arrStyleBullet[$bulletStyleHashCode]['oAlign_' . $paragraph->getAlignment()->getLevel()] = $paragraph->getAlignment();
|
||||
}
|
||||
|
|
@ -1129,7 +1129,7 @@ class Content extends AbstractDecoratorWriter
|
|||
protected function writeSlideNote(XMLWriter $objWriter, Note $note): void
|
||||
{
|
||||
$shapesNote = $note->getShapeCollection();
|
||||
if (count($shapesNote) > 0) {
|
||||
if (\count($shapesNote) > 0) {
|
||||
$objWriter->startElement('presentation:notes');
|
||||
|
||||
foreach ($shapesNote as $shape) {
|
||||
|
|
@ -1157,8 +1157,8 @@ class Content extends AbstractDecoratorWriter
|
|||
// style:style/style:drawing-page-properties
|
||||
$objWriter->startElement('style:drawing-page-properties');
|
||||
$objWriter->writeAttributeIf(!$slide->isVisible(), 'presentation:visibility', 'hidden');
|
||||
if (!is_null($oTransition = $slide->getTransition())) {
|
||||
$objWriter->writeAttribute('presentation:duration', 'PT' . number_format($oTransition->getAdvanceTimeTrigger() / 1000, 6, '.', '') . 'S');
|
||||
if (!\is_null($oTransition = $slide->getTransition())) {
|
||||
$objWriter->writeAttribute('presentation:duration', 'PT' . \number_format($oTransition->getAdvanceTimeTrigger() / 1000, 6, '.', '') . 'S');
|
||||
$objWriter->writeAttributeIf($oTransition->hasManualTrigger(), 'presentation:transition-type', 'manual');
|
||||
$objWriter->writeAttributeIf($oTransition->hasTimeTrigger(), 'presentation:transition-type', 'automatic');
|
||||
switch ($oTransition->getSpeed()) {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class Meta extends AbstractDecoratorWriter
|
|||
// dc:creator
|
||||
$objWriter->writeElement('dc:creator', $this->getPresentation()->getDocumentProperties()->getLastModifiedBy());
|
||||
// dc:date
|
||||
$objWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $this->getPresentation()->getDocumentProperties()->getModified()));
|
||||
$objWriter->writeElement('dc:date', \gmdate('Y-m-d\TH:i:s.000', $this->getPresentation()->getDocumentProperties()->getModified()));
|
||||
// dc:description
|
||||
$objWriter->writeElement('dc:description', $this->getPresentation()->getDocumentProperties()->getDescription());
|
||||
// dc:subject
|
||||
|
|
@ -64,7 +64,7 @@ class Meta extends AbstractDecoratorWriter
|
|||
// dc:title
|
||||
$objWriter->writeElement('dc:title', $this->getPresentation()->getDocumentProperties()->getTitle());
|
||||
// meta:creation-date
|
||||
$objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $this->getPresentation()->getDocumentProperties()->getCreated()));
|
||||
$objWriter->writeElement('meta:creation-date', \gmdate('Y-m-d\TH:i:s.000', $this->getPresentation()->getDocumentProperties()->getCreated()));
|
||||
// meta:initial-creator
|
||||
$objWriter->writeElement('meta:initial-creator', $this->getPresentation()->getDocumentProperties()->getCreator());
|
||||
// meta:keyword
|
||||
|
|
@ -90,7 +90,7 @@ class Meta extends AbstractDecoratorWriter
|
|||
break;
|
||||
case DocumentProperties::PROPERTY_TYPE_DATE:
|
||||
$objWriter->writeAttribute('meta:value-type', 'date');
|
||||
$objWriter->writeRaw(date(DATE_W3C, (int) $propertyValue));
|
||||
$objWriter->writeRaw(\date(DATE_W3C, (int) $propertyValue));
|
||||
break;
|
||||
case DocumentProperties::PROPERTY_TYPE_STRING:
|
||||
case DocumentProperties::PROPERTY_TYPE_UNKNOWN:
|
||||
|
|
|
|||
|
|
@ -93,12 +93,12 @@ class MetaInfManifest extends AbstractDecoratorWriter
|
|||
foreach ($this->getPresentation()->getAllSlides() as $numSlide => $oSlide) {
|
||||
$oBkgImage = $oSlide->getBackground();
|
||||
if ($oBkgImage instanceof Image) {
|
||||
$arrayImage = getimagesize($oBkgImage->getPath());
|
||||
$mimeType = image_type_to_mime_type($arrayImage[2]);
|
||||
$arrayImage = \getimagesize($oBkgImage->getPath());
|
||||
$mimeType = \image_type_to_mime_type($arrayImage[2]);
|
||||
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', $mimeType);
|
||||
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $oBkgImage->getIndexedFilename((string) $numSlide)));
|
||||
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . \str_replace(' ', '_', $oBkgImage->getIndexedFilename((string) $numSlide)));
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
|
@ -107,9 +107,9 @@ class MetaInfManifest extends AbstractDecoratorWriter
|
|||
$pathThumbnail = $this->getPresentation()->getPresentationProperties()->getThumbnailPath();
|
||||
// Size : 128x128 pixel
|
||||
// PNG : 8bit, non-interlaced with full alpha transparency
|
||||
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail));
|
||||
$gdImage = \imagecreatefromstring(\file_get_contents($pathThumbnail));
|
||||
if ($gdImage) {
|
||||
imagedestroy($gdImage);
|
||||
\imagedestroy($gdImage);
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', 'image/png');
|
||||
$objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png');
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ class ObjectsChart extends AbstractDecoratorWriter
|
|||
// style:graphic-properties
|
||||
$this->xmlContent->startElement('style:graphic-properties');
|
||||
$this->xmlContent->writeAttribute('draw:stroke', $axis->getOutline()->getFill()->getFillType());
|
||||
$this->xmlContent->writeAttribute('svg:stroke-width', number_format(CommonDrawing::pointsToCentimeters($axis->getOutline()->getWidth()), 3, '.', '') . 'cm');
|
||||
$this->xmlContent->writeAttribute('svg:stroke-width', \number_format(CommonDrawing::pointsToCentimeters($axis->getOutline()->getWidth()), 3, '.', '') . 'cm');
|
||||
$this->xmlContent->writeAttribute('svg:stroke-color', '#' . $axis->getOutline()->getFill()->getStartColor()->getRGB());
|
||||
$this->xmlContent->endElement();
|
||||
// style:style > style:text-properties
|
||||
|
|
@ -391,7 +391,7 @@ class ObjectsChart extends AbstractDecoratorWriter
|
|||
$this->xmlContent->writeAttribute('style:family', 'chart');
|
||||
// style:style > style:graphic-properties
|
||||
$this->xmlContent->startElement('style:graphic-properties');
|
||||
$this->xmlContent->writeAttribute('svg:stroke-width', number_format(CommonDrawing::pointsToCentimeters($oGridlines->getOutline()->getWidth()), 2, '.', '') . 'cm');
|
||||
$this->xmlContent->writeAttribute('svg:stroke-width', \number_format(CommonDrawing::pointsToCentimeters($oGridlines->getOutline()->getWidth()), 2, '.', '') . 'cm');
|
||||
$this->xmlContent->writeAttribute('svg:stroke-color', '#' . $oGridlines->getOutline()->getFill()->getStartColor()->getRGB());
|
||||
$this->xmlContent->endElement();
|
||||
// ##style:style
|
||||
|
|
@ -617,7 +617,7 @@ class ObjectsChart extends AbstractDecoratorWriter
|
|||
{
|
||||
$chartType = $chart->getPlotArea()->getType();
|
||||
|
||||
$numRange = count($series->getValues());
|
||||
$numRange = \count($series->getValues());
|
||||
// chart:series
|
||||
$this->xmlContent->startElement('chart:series');
|
||||
$this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$' . $this->rangeCol . '$2:.$' . $this->rangeCol . '$' . ($numRange + 1));
|
||||
|
|
@ -662,7 +662,7 @@ class ObjectsChart extends AbstractDecoratorWriter
|
|||
// > chart:data-point
|
||||
$this->xmlContent->endElement();
|
||||
} elseif ($chartType instanceof AbstractTypePie) {
|
||||
$count = count($series->getDataPointFills());
|
||||
$count = \count($series->getDataPointFills());
|
||||
for ($inc = 0; $inc < $count; ++$inc) {
|
||||
// chart:data-point
|
||||
$this->xmlContent->startElement('chart:data-point');
|
||||
|
|
@ -730,7 +730,7 @@ class ObjectsChart extends AbstractDecoratorWriter
|
|||
break;
|
||||
}
|
||||
$this->xmlContent->writeAttribute('chart:symbol-name', $symbolName);
|
||||
$symbolSize = number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', '');
|
||||
$symbolSize = \number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', '');
|
||||
$this->xmlContent->writeAttribute('chart:symbol-width', $symbolSize . 'cm');
|
||||
$this->xmlContent->writeAttribute('chart:symbol-height', $symbolSize . 'cm');
|
||||
}
|
||||
|
|
@ -760,7 +760,7 @@ class ObjectsChart extends AbstractDecoratorWriter
|
|||
if ($oOutline instanceof Outline) {
|
||||
$outlineWidth = $oOutline->getWidth();
|
||||
if (!empty($outlineWidth)) {
|
||||
$outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', '');
|
||||
$outlineWidth = \number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', '');
|
||||
}
|
||||
$outlineColor = $oOutline->getFill()->getStartColor()->getRGB();
|
||||
}
|
||||
|
|
@ -819,8 +819,8 @@ class ObjectsChart extends AbstractDecoratorWriter
|
|||
// table:table-column
|
||||
$this->xmlContent->startElement('table:table-column');
|
||||
if (!empty($this->arrayData)) {
|
||||
$rowFirst = reset($this->arrayData);
|
||||
$this->xmlContent->writeAttribute('table:number-columns-repeated', count($rowFirst) - 1);
|
||||
$rowFirst = \reset($this->arrayData);
|
||||
$this->xmlContent->writeAttribute('table:number-columns-repeated', \count($rowFirst) - 1);
|
||||
}
|
||||
// > table:table-column
|
||||
$this->xmlContent->endElement();
|
||||
|
|
@ -842,7 +842,7 @@ class ObjectsChart extends AbstractDecoratorWriter
|
|||
$this->xmlContent->startElement('table:table-cell');
|
||||
$this->xmlContent->endElement();
|
||||
} else {
|
||||
$rowFirst = reset($this->arrayData);
|
||||
$rowFirst = \reset($this->arrayData);
|
||||
foreach ($rowFirst as $key => $cell) {
|
||||
// table:table-cell
|
||||
$this->xmlContent->startElement('table:table-cell');
|
||||
|
|
@ -880,13 +880,13 @@ class ObjectsChart extends AbstractDecoratorWriter
|
|||
// table:table-cell
|
||||
$this->xmlContent->startElement('table:table-cell');
|
||||
|
||||
$cellValueTypeFloat = is_null($cell) ? true : is_numeric($cell);
|
||||
$cellValueTypeFloat = \is_null($cell) ? true : \is_numeric($cell);
|
||||
$this->xmlContent->writeAttributeIf(!$cellValueTypeFloat, 'office:value-type', 'string');
|
||||
$this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value-type', 'float');
|
||||
$this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value', is_null($cell) ? 'NaN' : $cell);
|
||||
$this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value', \is_null($cell) ? 'NaN' : $cell);
|
||||
// text:p
|
||||
$this->xmlContent->startElement('text:p');
|
||||
$this->xmlContent->text(is_null($cell) ? 'NaN' : (string) $cell);
|
||||
$this->xmlContent->text(\is_null($cell) ? 'NaN' : (string) $cell);
|
||||
$this->xmlContent->endElement();
|
||||
// > table:table-cell
|
||||
$this->xmlContent->endElement();
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class Pictures extends AbstractDecoratorWriter
|
|||
// Add background image slide
|
||||
$oBkgImage = $oSlide->getBackground();
|
||||
if ($oBkgImage instanceof Image) {
|
||||
$this->getZip()->addFromString('Pictures/' . $oBkgImage->getIndexedFilename((string) $keySlide), file_get_contents($oBkgImage->getPath()));
|
||||
$this->getZip()->addFromString('Pictures/' . $oBkgImage->getIndexedFilename((string) $keySlide), \file_get_contents($oBkgImage->getPath()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,13 +184,13 @@ class Styles extends AbstractDecoratorWriter
|
|||
{
|
||||
$oFill = $shape->getFill();
|
||||
if (Fill::FILL_GRADIENT_LINEAR == $oFill->getFillType() || Fill::FILL_GRADIENT_PATH == $oFill->getFillType()) {
|
||||
if (!in_array($oFill->getHashCode(), $this->arrayGradient)) {
|
||||
if (!\in_array($oFill->getHashCode(), $this->arrayGradient)) {
|
||||
$this->writeGradientFill($objWriter, $oFill);
|
||||
}
|
||||
}
|
||||
$oBorder = $shape->getBorder();
|
||||
if (Border::DASH_SOLID != $oBorder->getDashStyle()) {
|
||||
if (!in_array($oBorder->getDashStyle(), $this->arrayStrokeDash)) {
|
||||
if (!\in_array($oBorder->getDashStyle(), $this->arrayStrokeDash)) {
|
||||
$objWriter->startElement('draw:stroke-dash');
|
||||
$objWriter->writeAttribute('draw:name', 'strokeDash_' . $oBorder->getDashStyle());
|
||||
$objWriter->writeAttribute('draw:style', 'rect');
|
||||
|
|
@ -270,7 +270,7 @@ class Styles extends AbstractDecoratorWriter
|
|||
foreach ($shape->getRows() as $row) {
|
||||
foreach ($row->getCells() as $cell) {
|
||||
if (Fill::FILL_GRADIENT_LINEAR == $cell->getFill()->getFillType()) {
|
||||
if (!in_array($cell->getFill()->getHashCode(), $this->arrayGradient)) {
|
||||
if (!\in_array($cell->getFill()->getHashCode(), $this->arrayGradient)) {
|
||||
$this->writeGradientFill($objWriter, $cell->getFill());
|
||||
}
|
||||
}
|
||||
|
|
@ -319,7 +319,7 @@ class Styles extends AbstractDecoratorWriter
|
|||
{
|
||||
$objWriter->startElement('draw:fill-image');
|
||||
$objWriter->writeAttribute('draw:name', 'background_' . (string) $numSlide);
|
||||
$objWriter->writeAttribute('xlink:href', 'Pictures/' . str_replace(' ', '_', $oBkgImage->getIndexedFilename((string) $numSlide)));
|
||||
$objWriter->writeAttribute('xlink:href', 'Pictures/' . \str_replace(' ', '_', $oBkgImage->getIndexedFilename((string) $numSlide)));
|
||||
$objWriter->writeAttribute('xlink:type', 'simple');
|
||||
$objWriter->writeAttribute('xlink:show', 'embed');
|
||||
$objWriter->writeAttribute('xlink:actuate', 'onLoad');
|
||||
|
|
|
|||
|
|
@ -30,25 +30,25 @@ class ThumbnailsThumbnail extends AbstractDecoratorWriter
|
|||
if ($pathThumbnail) {
|
||||
// Size : 128x128 pixel
|
||||
// PNG : 8bit, non-interlaced with full alpha transparency
|
||||
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail));
|
||||
$gdImage = \imagecreatefromstring(\file_get_contents($pathThumbnail));
|
||||
if ($gdImage) {
|
||||
list($width, $height) = getimagesize($pathThumbnail);
|
||||
list($width, $height) = \getimagesize($pathThumbnail);
|
||||
|
||||
$gdRender = imagecreatetruecolor(128, 128);
|
||||
$colorBgAlpha = imagecolorallocatealpha($gdRender, 0, 0, 0, 127);
|
||||
imagecolortransparent($gdRender, $colorBgAlpha);
|
||||
imagefill($gdRender, 0, 0, $colorBgAlpha);
|
||||
imagecopyresampled($gdRender, $gdImage, 0, 0, 0, 0, 128, 128, $width, $height);
|
||||
imagetruecolortopalette($gdRender, false, 255);
|
||||
imagesavealpha($gdRender, true);
|
||||
$gdRender = \imagecreatetruecolor(128, 128);
|
||||
$colorBgAlpha = \imagecolorallocatealpha($gdRender, 0, 0, 0, 127);
|
||||
\imagecolortransparent($gdRender, $colorBgAlpha);
|
||||
\imagefill($gdRender, 0, 0, $colorBgAlpha);
|
||||
\imagecopyresampled($gdRender, $gdImage, 0, 0, 0, 0, 128, 128, $width, $height);
|
||||
\imagetruecolortopalette($gdRender, false, 255);
|
||||
\imagesavealpha($gdRender, true);
|
||||
|
||||
ob_start();
|
||||
imagepng($gdRender);
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
\ob_start();
|
||||
\imagepng($gdRender);
|
||||
$imageContents = \ob_get_contents();
|
||||
\ob_end_clean();
|
||||
|
||||
imagedestroy($gdRender);
|
||||
imagedestroy($gdImage);
|
||||
\imagedestroy($gdRender);
|
||||
\imagedestroy($gdImage);
|
||||
|
||||
$this->getZip()->addFromString('Thumbnails/thumbnail.png', $imageContents);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
|
|||
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if ('php://output' == strtolower($pFilename) || 'php://stdout' == strtolower($pFilename)) {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ('php://output' == \strtolower($pFilename) || 'php://stdout' == \strtolower($pFilename)) {
|
||||
$pFilename = @\tempnam('./', 'phppttmp');
|
||||
if ('' == $pFilename) {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
|
|||
$oZip = $this->getZipAdapter();
|
||||
$oZip->open($pFilename);
|
||||
|
||||
$oDir = new DirectoryIterator(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'PowerPoint2007');
|
||||
$oDir = new \DirectoryIterator(\dirname(__FILE__) . DIRECTORY_SEPARATOR . 'PowerPoint2007');
|
||||
$arrayFiles = [];
|
||||
foreach ($oDir as $oFile) {
|
||||
if (!$oFile->isFile()) {
|
||||
|
|
@ -106,7 +106,7 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
|
|||
}
|
||||
|
||||
$class = __NAMESPACE__ . '\\PowerPoint2007\\' . $oFile->getBasename('.php');
|
||||
$class = new ReflectionClass($class);
|
||||
$class = new \ReflectionClass($class);
|
||||
|
||||
if ($class->isAbstract() || !$class->isSubclassOf(AbstractDecoratorWriter::class)) {
|
||||
continue;
|
||||
|
|
@ -114,7 +114,7 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
|
|||
$arrayFiles[$oFile->getBasename('.php')] = $class;
|
||||
}
|
||||
|
||||
ksort($arrayFiles);
|
||||
\ksort($arrayFiles);
|
||||
|
||||
foreach ($arrayFiles as $o) {
|
||||
$oService = $o->newInstance();
|
||||
|
|
@ -130,10 +130,10 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
|
|||
|
||||
// If a temporary file was used, copy it to the correct file stream
|
||||
if ($originalFilename != $pFilename) {
|
||||
if (false === copy($pFilename, $originalFilename)) {
|
||||
if (false === \copy($pFilename, $originalFilename)) {
|
||||
throw new FileCopyException($pFilename, $originalFilename);
|
||||
}
|
||||
if (false === @unlink($pFilename)) {
|
||||
if (false === @\unlink($pFilename)) {
|
||||
throw new FileRemoveException($pFilename);
|
||||
}
|
||||
}
|
||||
|
|
@ -163,8 +163,8 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
|
|||
{
|
||||
$this->useDiskCaching = $useDiskCaching;
|
||||
|
||||
if (!is_null($directory)) {
|
||||
if (!is_dir($directory)) {
|
||||
if (!\is_null($directory)) {
|
||||
if (!\is_dir($directory)) {
|
||||
throw new DirectoryNotFoundException($directory);
|
||||
}
|
||||
$this->diskCachingDir = $directory;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ abstract class AbstractDecoratorWriter extends \PhpOffice\PhpPresentation\Writer
|
|||
|
||||
protected function writeColor(XMLWriter $objWriter, Color $color, ?int $alpha = null): void
|
||||
{
|
||||
if (is_null($alpha)) {
|
||||
if (\is_null($alpha)) {
|
||||
$alpha = $color->getAlpha();
|
||||
}
|
||||
|
||||
|
|
@ -283,12 +283,12 @@ abstract class AbstractDecoratorWriter extends \PhpOffice\PhpPresentation\Writer
|
|||
*/
|
||||
protected function absoluteZipPath(string $path): string
|
||||
{
|
||||
$path = str_replace([
|
||||
$path = \str_replace([
|
||||
'/',
|
||||
'\\',
|
||||
], DIRECTORY_SEPARATOR, $path);
|
||||
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), function (string $var) {
|
||||
return (bool) strlen($var);
|
||||
$parts = \array_filter(\explode(DIRECTORY_SEPARATOR, $path), function (string $var) {
|
||||
return (bool) \strlen($var);
|
||||
});
|
||||
$absolutes = [];
|
||||
foreach ($parts as $part) {
|
||||
|
|
@ -296,12 +296,12 @@ abstract class AbstractDecoratorWriter extends \PhpOffice\PhpPresentation\Writer
|
|||
continue;
|
||||
}
|
||||
if ('..' == $part) {
|
||||
array_pop($absolutes);
|
||||
\array_pop($absolutes);
|
||||
} else {
|
||||
$absolutes[] = $part;
|
||||
}
|
||||
}
|
||||
|
||||
return implode('/', $absolutes);
|
||||
return \implode('/', $absolutes);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user