mirror of
https://github.com/Karaka-Management/Resources.git
synced 2026-01-27 11:48:41 +00:00
update office and its dependencies
This commit is contained in:
parent
4ebf36491f
commit
47bfb47761
412
Laminas/Escaper/Escaper.php
Normal file
412
Laminas/Escaper/Escaper.php
Normal file
|
|
@ -0,0 +1,412 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laminas\Escaper;
|
||||
|
||||
use function bin2hex;
|
||||
use function ctype_digit;
|
||||
use function hexdec;
|
||||
use function htmlspecialchars;
|
||||
use function in_array;
|
||||
use function mb_convert_encoding;
|
||||
use function ord;
|
||||
use function preg_match;
|
||||
use function preg_replace_callback;
|
||||
use function rawurlencode;
|
||||
use function sprintf;
|
||||
use function strlen;
|
||||
use function strtolower;
|
||||
use function strtoupper;
|
||||
use function substr;
|
||||
|
||||
use const ENT_QUOTES;
|
||||
use const ENT_SUBSTITUTE;
|
||||
|
||||
/**
|
||||
* Context specific methods for use in secure output escaping
|
||||
*/
|
||||
class Escaper
|
||||
{
|
||||
/**
|
||||
* Entity Map mapping Unicode codepoints to any available named HTML entities.
|
||||
*
|
||||
* While HTML supports far more named entities, the lowest common denominator
|
||||
* has become HTML5's XML Serialisation which is restricted to the those named
|
||||
* entities that XML supports. Using HTML entities would result in this error:
|
||||
* XML Parsing Error: undefined entity
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected static $htmlNamedEntityMap = [
|
||||
34 => 'quot', // quotation mark
|
||||
38 => 'amp', // ampersand
|
||||
60 => 'lt', // less-than sign
|
||||
62 => 'gt', // greater-than sign
|
||||
];
|
||||
|
||||
/**
|
||||
* Current encoding for escaping. If not UTF-8, we convert strings from this encoding
|
||||
* pre-escaping and back to this encoding post-escaping.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $encoding = 'utf-8';
|
||||
|
||||
/**
|
||||
* Holds the value of the special flags passed as second parameter to
|
||||
* htmlspecialchars().
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $htmlSpecialCharsFlags;
|
||||
|
||||
/**
|
||||
* Static Matcher which escapes characters for HTML Attribute contexts
|
||||
*
|
||||
* @var callable
|
||||
* @psalm-var callable(array<array-key, string>):string
|
||||
*/
|
||||
protected $htmlAttrMatcher;
|
||||
|
||||
/**
|
||||
* Static Matcher which escapes characters for Javascript contexts
|
||||
*
|
||||
* @var callable
|
||||
* @psalm-var callable(array<array-key, string>):string
|
||||
*/
|
||||
protected $jsMatcher;
|
||||
|
||||
/**
|
||||
* Static Matcher which escapes characters for CSS Attribute contexts
|
||||
*
|
||||
* @var callable
|
||||
* @psalm-var callable(array<array-key, string>):string
|
||||
*/
|
||||
protected $cssMatcher;
|
||||
|
||||
/**
|
||||
* List of all encoding supported by this class
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $supportedEncodings = [
|
||||
'iso-8859-1',
|
||||
'iso8859-1',
|
||||
'iso-8859-5',
|
||||
'iso8859-5',
|
||||
'iso-8859-15',
|
||||
'iso8859-15',
|
||||
'utf-8',
|
||||
'cp866',
|
||||
'ibm866',
|
||||
'866',
|
||||
'cp1251',
|
||||
'windows-1251',
|
||||
'win-1251',
|
||||
'1251',
|
||||
'cp1252',
|
||||
'windows-1252',
|
||||
'1252',
|
||||
'koi8-r',
|
||||
'koi8-ru',
|
||||
'koi8r',
|
||||
'big5',
|
||||
'950',
|
||||
'gb2312',
|
||||
'936',
|
||||
'big5-hkscs',
|
||||
'shift_jis',
|
||||
'sjis',
|
||||
'sjis-win',
|
||||
'cp932',
|
||||
'932',
|
||||
'euc-jp',
|
||||
'eucjp',
|
||||
'eucjp-win',
|
||||
'macroman',
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor: Single parameter allows setting of global encoding for use by
|
||||
* the current object.
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function __construct(?string $encoding = null)
|
||||
{
|
||||
if ($encoding !== null) {
|
||||
if ($encoding === '') {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
static::class . ' constructor parameter does not allow a blank value'
|
||||
);
|
||||
}
|
||||
|
||||
$encoding = strtolower($encoding);
|
||||
if (! in_array($encoding, $this->supportedEncodings)) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Value of \'' . $encoding . '\' passed to ' . static::class
|
||||
. ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'
|
||||
);
|
||||
}
|
||||
|
||||
$this->encoding = $encoding;
|
||||
}
|
||||
|
||||
// We take advantage of ENT_SUBSTITUTE flag to correctly deal with invalid UTF-8 sequences.
|
||||
$this->htmlSpecialCharsFlags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||
|
||||
// set matcher callbacks
|
||||
$this->htmlAttrMatcher = [$this, 'htmlAttrMatcher'];
|
||||
$this->jsMatcher = [$this, 'jsMatcher'];
|
||||
$this->cssMatcher = [$this, 'cssMatcher'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the encoding that all output/input is expected to be encoded in.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
return $this->encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string for the HTML Body context where there are very few characters
|
||||
* of special meaning. Internally this will use htmlspecialchars().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeHtml(string $string)
|
||||
{
|
||||
return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string for the HTML Attribute context. We use an extended set of characters
|
||||
* to escape that are not covered by htmlspecialchars() to cover cases where an attribute
|
||||
* might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeHtmlAttr(string $string)
|
||||
{
|
||||
$string = $this->toUtf8($string);
|
||||
if ($string === '' || ctype_digit($string)) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
$result = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->htmlAttrMatcher, $string);
|
||||
return $this->fromUtf8($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string for the Javascript context. This does not use json_encode(). An extended
|
||||
* set of characters are escaped beyond ECMAScript's rules for Javascript literal string
|
||||
* escaping in order to prevent misinterpretation of Javascript as HTML leading to the
|
||||
* injection of special characters and entities. The escaping used should be tolerant
|
||||
* of cases where HTML escaping was not applied on top of Javascript escaping correctly.
|
||||
* Backslash escaping is not used as it still leaves the escaped character as-is and so
|
||||
* is not useful in a HTML context.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeJs(string $string)
|
||||
{
|
||||
$string = $this->toUtf8($string);
|
||||
if ($string === '' || ctype_digit($string)) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
$result = preg_replace_callback('/[^a-z0-9,\._]/iSu', $this->jsMatcher, $string);
|
||||
return $this->fromUtf8($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string for the URI or Parameter contexts. This should not be used to escape
|
||||
* an entire URI - only a subcomponent being inserted. The function is a simple proxy
|
||||
* to rawurlencode() which now implements RFC 3986 since PHP 5.3 completely.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeUrl(string $string)
|
||||
{
|
||||
return rawurlencode($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string for the CSS context. CSS escaping can be applied to any string being
|
||||
* inserted into CSS and escapes everything except alphanumerics.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeCss(string $string)
|
||||
{
|
||||
$string = $this->toUtf8($string);
|
||||
if ($string === '' || ctype_digit($string)) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
$result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string);
|
||||
return $this->fromUtf8($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for preg_replace_callback that applies HTML Attribute
|
||||
* escaping to all matches.
|
||||
*
|
||||
* @param array<array-key, string> $matches
|
||||
* @return string
|
||||
*/
|
||||
protected function htmlAttrMatcher($matches)
|
||||
{
|
||||
$chr = $matches[0];
|
||||
$ord = ord($chr);
|
||||
|
||||
/**
|
||||
* The following replaces characters undefined in HTML with the
|
||||
* hex entity for the Unicode replacement character.
|
||||
*/
|
||||
if (
|
||||
($ord <= 0x1f && $chr !== "\t" && $chr !== "\n" && $chr !== "\r")
|
||||
|| ($ord >= 0x7f && $ord <= 0x9f)
|
||||
) {
|
||||
return '�';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current character to escape has a name entity we should
|
||||
* replace it with while grabbing the integer value of the character.
|
||||
*/
|
||||
if (strlen($chr) > 1) {
|
||||
$chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8');
|
||||
}
|
||||
|
||||
$hex = bin2hex($chr);
|
||||
$ord = hexdec($hex);
|
||||
if (isset(static::$htmlNamedEntityMap[$ord])) {
|
||||
return '&' . static::$htmlNamedEntityMap[$ord] . ';';
|
||||
}
|
||||
|
||||
/**
|
||||
* Per OWASP recommendations, we'll use upper hex entities
|
||||
* for any other characters where a named entity does not exist.
|
||||
*/
|
||||
if ($ord > 255) {
|
||||
return sprintf('&#x%04X;', $ord);
|
||||
}
|
||||
return sprintf('&#x%02X;', $ord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for preg_replace_callback that applies Javascript
|
||||
* escaping to all matches.
|
||||
*
|
||||
* @param array<array-key, string> $matches
|
||||
* @return string
|
||||
*/
|
||||
protected function jsMatcher($matches)
|
||||
{
|
||||
$chr = $matches[0];
|
||||
if (strlen($chr) === 1) {
|
||||
return sprintf('\\x%02X', ord($chr));
|
||||
}
|
||||
$chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8');
|
||||
$hex = strtoupper(bin2hex($chr));
|
||||
if (strlen($hex) <= 4) {
|
||||
return sprintf('\\u%04s', $hex);
|
||||
}
|
||||
$highSurrogate = substr($hex, 0, 4);
|
||||
$lowSurrogate = substr($hex, 4, 4);
|
||||
return sprintf('\\u%04s\\u%04s', $highSurrogate, $lowSurrogate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for preg_replace_callback that applies CSS
|
||||
* escaping to all matches.
|
||||
*
|
||||
* @param array<array-key, string> $matches
|
||||
* @return string
|
||||
*/
|
||||
protected function cssMatcher($matches)
|
||||
{
|
||||
$chr = $matches[0];
|
||||
if (strlen($chr) === 1) {
|
||||
$ord = ord($chr);
|
||||
} else {
|
||||
$chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8');
|
||||
$ord = hexdec(bin2hex($chr));
|
||||
}
|
||||
return sprintf('\\%X ', $ord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string to UTF-8 from the base encoding. The base encoding is set via this
|
||||
*
|
||||
* @param string $string
|
||||
* @throws Exception\RuntimeException
|
||||
* @return string
|
||||
*/
|
||||
protected function toUtf8($string)
|
||||
{
|
||||
if ($this->getEncoding() === 'utf-8') {
|
||||
$result = $string;
|
||||
} else {
|
||||
$result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding());
|
||||
}
|
||||
|
||||
if (! $this->isUtf8($result)) {
|
||||
throw new Exception\RuntimeException(
|
||||
sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result)
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string from UTF-8 to the base encoding. The base encoding is set via this
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
protected function fromUtf8($string)
|
||||
{
|
||||
if ($this->getEncoding() === 'utf-8') {
|
||||
return $string;
|
||||
}
|
||||
|
||||
return $this->convertEncoding($string, $this->getEncoding(), 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given string appears to be valid UTF-8 or not.
|
||||
*
|
||||
* @param string $string
|
||||
* @return bool
|
||||
*/
|
||||
protected function isUtf8($string)
|
||||
{
|
||||
return $string === '' || preg_match('/^./su', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encoding conversion helper which wraps mb_convert_encoding
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $to
|
||||
* @param array|string $from
|
||||
* @return string
|
||||
*/
|
||||
protected function convertEncoding($string, $to, $from)
|
||||
{
|
||||
$result = mb_convert_encoding($string, $to, $from);
|
||||
|
||||
if ($result === false) {
|
||||
return ''; // return non-fatal blank string on encoding errors from users
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
11
Laminas/Escaper/Exception/ExceptionInterface.php
Normal file
11
Laminas/Escaper/Exception/ExceptionInterface.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laminas\Escaper\Exception;
|
||||
|
||||
use Throwable;
|
||||
|
||||
interface ExceptionInterface extends Throwable
|
||||
{
|
||||
}
|
||||
13
Laminas/Escaper/Exception/InvalidArgumentException.php
Normal file
13
Laminas/Escaper/Exception/InvalidArgumentException.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laminas\Escaper\Exception;
|
||||
|
||||
/**
|
||||
* Invalid argument exception
|
||||
*/
|
||||
class InvalidArgumentException extends \InvalidArgumentException implements
|
||||
ExceptionInterface
|
||||
{
|
||||
}
|
||||
13
Laminas/Escaper/Exception/RuntimeException.php
Normal file
13
Laminas/Escaper/Exception/RuntimeException.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laminas\Escaper\Exception;
|
||||
|
||||
/**
|
||||
* Invalid argument exception
|
||||
*/
|
||||
class RuntimeException extends \RuntimeException implements
|
||||
ExceptionInterface
|
||||
{
|
||||
}
|
||||
26
Laminas/Escaper/LICENSE.md
Normal file
26
Laminas/Escaper/LICENSE.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of Laminas Foundation nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
319
MyCLabs/Enum/Enum.php
Normal file
319
MyCLabs/Enum/Enum.php
Normal file
|
|
@ -0,0 +1,319 @@
|
|||
<?php
|
||||
/**
|
||||
* @link http://github.com/myclabs/php-enum
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
||||
*/
|
||||
|
||||
namespace MyCLabs\Enum;
|
||||
|
||||
/**
|
||||
* Base Enum class
|
||||
*
|
||||
* Create an enum by implementing this class and adding class constants.
|
||||
*
|
||||
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
||||
* @author Daniel Costa <danielcosta@gmail.com>
|
||||
* @author Mirosław Filip <mirfilip@gmail.com>
|
||||
*
|
||||
* @psalm-template T
|
||||
* @psalm-immutable
|
||||
* @psalm-consistent-constructor
|
||||
*/
|
||||
abstract class Enum implements \JsonSerializable, \Stringable
|
||||
{
|
||||
/**
|
||||
* Enum value
|
||||
*
|
||||
* @var mixed
|
||||
* @psalm-var T
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* Enum key, the constant name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* Store existing constants in a static cache per object.
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
* @psalm-var array<class-string, array<string, mixed>>
|
||||
*/
|
||||
protected static $cache = [];
|
||||
|
||||
/**
|
||||
* Cache of instances of the Enum class
|
||||
*
|
||||
* @var array
|
||||
* @psalm-var array<class-string, array<string, static>>
|
||||
*/
|
||||
protected static $instances = [];
|
||||
|
||||
/**
|
||||
* Creates a new value of some type
|
||||
*
|
||||
* @psalm-pure
|
||||
* @param mixed $value
|
||||
*
|
||||
* @psalm-param T $value
|
||||
* @throws \UnexpectedValueException if incompatible type is given.
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
if ($value instanceof static) {
|
||||
/** @psalm-var T */
|
||||
$value = $value->getValue();
|
||||
}
|
||||
|
||||
/** @psalm-suppress ImplicitToStringCast assertValidValueReturningKey returns always a string but psalm has currently an issue here */
|
||||
$this->key = static::assertValidValueReturningKey($value);
|
||||
|
||||
/** @psalm-var T */
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method exists only for the compatibility reason when deserializing a previously serialized version
|
||||
* that didn't had the key property
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
/** @psalm-suppress DocblockTypeContradiction key can be null when deserializing an enum without the key */
|
||||
if ($this->key === null) {
|
||||
/**
|
||||
* @psalm-suppress InaccessibleProperty key is not readonly as marked by psalm
|
||||
* @psalm-suppress PossiblyFalsePropertyAssignmentValue deserializing a case that was removed
|
||||
*/
|
||||
$this->key = static::search($this->value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return static
|
||||
*/
|
||||
public static function from($value): self
|
||||
{
|
||||
$key = static::assertValidValueReturningKey($value);
|
||||
|
||||
return self::__callStatic($key, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @return mixed
|
||||
* @psalm-return T
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enum key (i.e. the constant name).
|
||||
*
|
||||
* @psalm-pure
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-suppress InvalidCast
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string)$this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if Enum should be considered equal with the variable passed as a parameter.
|
||||
* Returns false if an argument is an object of different class or not an object.
|
||||
*
|
||||
* This method is final, for more information read https://github.com/myclabs/php-enum/issues/4
|
||||
*
|
||||
* @psalm-pure
|
||||
* @psalm-param mixed $variable
|
||||
* @return bool
|
||||
*/
|
||||
final public function equals($variable = null): bool
|
||||
{
|
||||
return $variable instanceof self
|
||||
&& $this->getValue() === $variable->getValue()
|
||||
&& static::class === \get_class($variable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names (keys) of all constants in the Enum class
|
||||
*
|
||||
* @psalm-pure
|
||||
* @psalm-return list<string>
|
||||
* @return array
|
||||
*/
|
||||
public static function keys()
|
||||
{
|
||||
return \array_keys(static::toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns instances of the Enum class of all Enum constants
|
||||
*
|
||||
* @psalm-pure
|
||||
* @psalm-return array<string, static>
|
||||
* @return static[] Constant name in key, Enum instance in value
|
||||
*/
|
||||
public static function values()
|
||||
{
|
||||
$values = array();
|
||||
|
||||
/** @psalm-var T $value */
|
||||
foreach (static::toArray() as $key => $value) {
|
||||
/** @psalm-suppress UnsafeGenericInstantiation */
|
||||
$values[$key] = new static($value);
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all possible values as an array
|
||||
*
|
||||
* @psalm-pure
|
||||
* @psalm-suppress ImpureStaticProperty
|
||||
*
|
||||
* @psalm-return array<string, mixed>
|
||||
* @return array Constant name in key, constant value in value
|
||||
*/
|
||||
public static function toArray()
|
||||
{
|
||||
$class = static::class;
|
||||
|
||||
if (!isset(static::$cache[$class])) {
|
||||
/** @psalm-suppress ImpureMethodCall this reflection API usage has no side-effects here */
|
||||
$reflection = new \ReflectionClass($class);
|
||||
/** @psalm-suppress ImpureMethodCall this reflection API usage has no side-effects here */
|
||||
static::$cache[$class] = $reflection->getConstants();
|
||||
}
|
||||
|
||||
return static::$cache[$class];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is valid enum value
|
||||
*
|
||||
* @param $value
|
||||
* @psalm-param mixed $value
|
||||
* @psalm-pure
|
||||
* @psalm-assert-if-true T $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValid($value)
|
||||
{
|
||||
return \in_array($value, static::toArray(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts valid enum value
|
||||
*
|
||||
* @psalm-pure
|
||||
* @psalm-assert T $value
|
||||
* @param mixed $value
|
||||
*/
|
||||
public static function assertValidValue($value): void
|
||||
{
|
||||
self::assertValidValueReturningKey($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts valid enum value
|
||||
*
|
||||
* @psalm-pure
|
||||
* @psalm-assert T $value
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
private static function assertValidValueReturningKey($value): string
|
||||
{
|
||||
if (false === ($key = static::search($value))) {
|
||||
throw new \UnexpectedValueException("Value '$value' is not part of the enum " . static::class);
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is valid enum key
|
||||
*
|
||||
* @param $key
|
||||
* @psalm-param string $key
|
||||
* @psalm-pure
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValidKey($key)
|
||||
{
|
||||
$array = static::toArray();
|
||||
|
||||
return isset($array[$key]) || \array_key_exists($key, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return key for value
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @psalm-param mixed $value
|
||||
* @psalm-pure
|
||||
* @return string|false
|
||||
*/
|
||||
public static function search($value)
|
||||
{
|
||||
return \array_search($value, static::toArray(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return static
|
||||
* @throws \BadMethodCallException
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
$class = static::class;
|
||||
if (!isset(self::$instances[$class][$name])) {
|
||||
$array = static::toArray();
|
||||
if (!isset($array[$name]) && !\array_key_exists($name, $array)) {
|
||||
$message = "No static method or enum constant '$name' in class " . static::class;
|
||||
throw new \BadMethodCallException($message);
|
||||
}
|
||||
/** @psalm-suppress UnsafeGenericInstantiation */
|
||||
return self::$instances[$class][$name] = new static($array[$name]);
|
||||
}
|
||||
return clone self::$instances[$class][$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON. This method returns data that can be serialized by json_encode()
|
||||
* natively.
|
||||
*
|
||||
* @return mixed
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->getValue();
|
||||
}
|
||||
}
|
||||
18
MyCLabs/LICENSE
Normal file
18
MyCLabs/LICENSE
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 My C-Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
11
PhpOffice/Common/Adapter/Zip/PclZipAdapter.php
Executable file → Normal file
11
PhpOffice/Common/Adapter/Zip/PclZipAdapter.php
Executable file → Normal file
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\Common\Adapter\Zip;
|
||||
|
||||
use PclZip;
|
||||
|
|
@ -19,6 +20,7 @@ class PclZipAdapter implements ZipInterface
|
|||
{
|
||||
$this->oPclZip = new PclZip($filename);
|
||||
$this->tmpDir = sys_get_temp_dir();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -31,15 +33,16 @@ class PclZipAdapter implements ZipInterface
|
|||
{
|
||||
$pathData = pathinfo($localname);
|
||||
|
||||
$hFile = fopen($this->tmpDir.'/'.$pathData['basename'], "wb");
|
||||
$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']);
|
||||
$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));
|
||||
throw new \Exception('Error zipping files : ' . $this->oPclZip->errorInfo(true));
|
||||
}
|
||||
unlink($this->tmpDir.'/'.$pathData['basename']);
|
||||
unlink($this->tmpDir . '/' . $pathData['basename']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3
PhpOffice/Common/Adapter/Zip/ZipArchiveAdapter.php
Executable file → Normal file
3
PhpOffice/Common/Adapter/Zip/ZipArchiveAdapter.php
Executable file → Normal file
|
|
@ -35,13 +35,14 @@ class ZipArchiveAdapter implements ZipInterface
|
|||
if ($this->oZipArchive->close() === false) {
|
||||
throw new \Exception("Could not close zip file $this->filename.");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addFromString($localname, $contents)
|
||||
{
|
||||
if ($this->oZipArchive->addFromString($localname, $contents) === false) {
|
||||
throw new \Exception("Error zipping files : " . $localname);
|
||||
throw new \Exception('Error zipping files : ' . $localname);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
|||
10
PhpOffice/Common/Adapter/Zip/ZipInterface.php
Executable file → Normal file
10
PhpOffice/Common/Adapter/Zip/ZipInterface.php
Executable file → Normal file
|
|
@ -6,24 +6,32 @@ interface ZipInterface
|
|||
{
|
||||
/**
|
||||
* Open a ZIP file archive
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function open($filename);
|
||||
|
||||
/**
|
||||
* Close the active archive (opened or newly created)
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function close();
|
||||
|
||||
/**
|
||||
* Add a file to a ZIP archive using its contents
|
||||
* @param string $localname The name of the entry to create.
|
||||
*
|
||||
* @param string $localname the name of the entry to create
|
||||
* @param string $contents The contents to use to create the entry. It is used in a binary safe mode.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addFromString($localname, $contents);
|
||||
|
|
|
|||
11
PhpOffice/Common/Autoloader.php
Executable file → Normal file
11
PhpOffice/Common/Autoloader.php
Executable file → Normal file
|
|
@ -9,7 +9,8 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @see https://github.com/PHPOffice/Common
|
||||
*
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
|
@ -22,16 +23,16 @@ namespace PhpOffice\Common;
|
|||
class Autoloader
|
||||
{
|
||||
/** @const string */
|
||||
const NAMESPACE_PREFIX = 'PhpOffice\\Common\\';
|
||||
public const NAMESPACE_PREFIX = 'PhpOffice\\Common\\';
|
||||
|
||||
/**
|
||||
* Register
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register()
|
||||
public static function register(): void
|
||||
{
|
||||
spl_autoload_register(array(new self, 'autoload'));
|
||||
spl_autoload_register([new self(), 'autoload']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -39,7 +40,7 @@ class Autoloader
|
|||
*
|
||||
* @param string $class
|
||||
*/
|
||||
public static function autoload($class)
|
||||
public static function autoload(string $class): void
|
||||
{
|
||||
$prefixLength = strlen(self::NAMESPACE_PREFIX);
|
||||
if (0 === strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) {
|
||||
|
|
|
|||
|
|
@ -1,674 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
157
PhpOffice/Common/Drawing.php
Executable file → Normal file
157
PhpOffice/Common/Drawing.php
Executable file → Normal file
|
|
@ -9,27 +9,26 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @see https://github.com/PHPOffice/Common
|
||||
*
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
/**
|
||||
* \PhpOffice\Common\Drawing
|
||||
*/
|
||||
class Drawing
|
||||
{
|
||||
const DPI_96 = 96;
|
||||
public const DPI_96 = 96;
|
||||
|
||||
/**
|
||||
* Convert pixels to EMU
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int
|
||||
* @param float $pValue Value in pixels
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function pixelsToEmu($pValue = 0)
|
||||
public static function pixelsToEmu(float $pValue = 0): float
|
||||
{
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
|
@ -37,89 +36,116 @@ class Drawing
|
|||
/**
|
||||
* Convert EMU to pixels
|
||||
*
|
||||
* @param int $pValue Value in EMU
|
||||
* @param int $pValue Value in EMU
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function emuToPixels($pValue = 0)
|
||||
public static function emuToPixels(int $pValue = 0): int
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return round($pValue / 9525);
|
||||
|
||||
return (int) round($pValue / 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @param int $pValue Value in pixels
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function pixelsToPoints($pValue = 0)
|
||||
public static function pixelsToPoints(int $pValue = 0): float
|
||||
{
|
||||
return $pValue * 0.67777777;
|
||||
return $pValue * 0.75;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points width to centimeters
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @param float $pValue Value in points
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function pointsToCentimeters($pValue = 0)
|
||||
public static function pointsToCentimeters(float $pValue = 0): float
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return ((($pValue * 1.333333333) / self::DPI_96) * 2.54);
|
||||
|
||||
return (($pValue / 0.75) / self::DPI_96) * 2.54;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert centimeters width to points
|
||||
*
|
||||
* @param float $pValue Value in centimeters
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function centimetersToPoints(float $pValue = 0): float
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($pValue / 2.54) * self::DPI_96 * 0.75;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points width to pixels
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @param float $pValue Value in points
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function pointsToPixels($pValue = 0)
|
||||
public static function pointsToPixels(float $pValue = 0): float
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $pValue * 1.333333333;
|
||||
|
||||
return $pValue / 0.75;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to centimeters
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @param int $pValue Value in pixels
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function pixelsToCentimeters($pValue = 0)
|
||||
public static function pixelsToCentimeters(int $pValue = 0): float
|
||||
{
|
||||
//return $pValue * 0.028;
|
||||
return (($pValue / self::DPI_96) * 2.54);
|
||||
return ($pValue / self::DPI_96) * 2.54;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert centimeters width to pixels
|
||||
*
|
||||
* @param int $pValue Value in centimeters
|
||||
* @return float
|
||||
* @param float $pValue Value in centimeters
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function centimetersToPixels($pValue = 0)
|
||||
public static function centimetersToPixels(float $pValue = 0): int
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return ($pValue / 2.54) * self::DPI_96;
|
||||
|
||||
return (int) round((($pValue / 2.54) * self::DPI_96));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert degrees to angle
|
||||
*
|
||||
* @param int $pValue Degrees
|
||||
* @param int $pValue Degrees
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function degreesToAngle($pValue = 0)
|
||||
public static function degreesToAngle(int $pValue = 0): int
|
||||
{
|
||||
return (int) round($pValue * 60000);
|
||||
}
|
||||
|
|
@ -127,111 +153,140 @@ class Drawing
|
|||
/**
|
||||
* Convert angle to degrees
|
||||
*
|
||||
* @param int $pValue Angle
|
||||
* @return int
|
||||
* @param int $pValue Angle
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function angleToDegrees($pValue = 0)
|
||||
public static function angleToDegrees(int $pValue = 0): float
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return round($pValue / 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert centimeters width to twips
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @param int $pValue
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function centimetersToTwips($pValue = 0)
|
||||
public static function centimetersToTwips(int $pValue = 0): float
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $pValue * 566.928;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert twips width to centimeters
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @param int $pValue
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function twipsToCentimeters($pValue = 0)
|
||||
public static function twipsToCentimeters(int $pValue = 0): float
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $pValue / 566.928;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert inches width to twips
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @return float
|
||||
* @param int $pValue
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function inchesToTwips($pValue = 0)
|
||||
public static function inchesToTwips(int $pValue = 0): int
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $pValue * 1440;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert twips width to inches
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @param int $pValue
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function twipsToInches($pValue = 0)
|
||||
public static function twipsToInches(int $pValue = 0): float
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $pValue / 1440;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert twips width to pixels
|
||||
*
|
||||
* @param integer $pValue
|
||||
* @param int $pValue
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function twipsToPixels($pValue = 0)
|
||||
public static function twipsToPixels(int $pValue = 0): float
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return round($pValue / 15.873984);
|
||||
|
||||
return round($pValue / 15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points to emu
|
||||
*
|
||||
* @param float $pValue
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function pointsToEmu(float $pValue = 0): int
|
||||
{
|
||||
if ($pValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) round(($pValue / 0.75) / 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert HTML hexadecimal to RGB
|
||||
*
|
||||
* @param string $pValue HTML Color in hexadecimal
|
||||
* @return array|false Value in RGB
|
||||
*
|
||||
* @return array<int, int>|null Value in RGB
|
||||
*/
|
||||
public static function htmlToRGB($pValue)
|
||||
public static function htmlToRGB(string $pValue): ?array
|
||||
{
|
||||
if ($pValue[0] == '#') {
|
||||
$pValue = substr($pValue, 1);
|
||||
}
|
||||
|
||||
if (strlen($pValue) == 6) {
|
||||
list($colorR, $colorG, $colorB) = array($pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]);
|
||||
list($colorR, $colorG, $colorB) = [$pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]];
|
||||
} elseif (strlen($pValue) == 3) {
|
||||
list($colorR, $colorG, $colorB) = array($pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]);
|
||||
list($colorR, $colorG, $colorB) = [$pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]];
|
||||
} else {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
$colorR = hexdec($colorR);
|
||||
$colorG = hexdec($colorG);
|
||||
$colorB = hexdec($colorB);
|
||||
|
||||
return array($colorR, $colorG, $colorB);
|
||||
return [$colorR, $colorG, $colorB];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
42
PhpOffice/Common/File.php
Executable file → Normal file
42
PhpOffice/Common/File.php
Executable file → Normal file
|
|
@ -9,35 +9,36 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @see https://github.com/PHPOffice/Common
|
||||
*
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
/**
|
||||
* Drawing
|
||||
*/
|
||||
use ZipArchive;
|
||||
|
||||
class File
|
||||
{
|
||||
/**
|
||||
* Verify if a file exists
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @param string $pFilename Filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function fileExists($pFilename)
|
||||
public static function fileExists(string $pFilename): bool
|
||||
{
|
||||
// Sick construction, but it seems that
|
||||
// file_exists returns strange values when
|
||||
// doing the original file_exists on ZIP archives...
|
||||
if (strtolower(substr($pFilename, 0, 3)) == 'zip') {
|
||||
// Open ZIP file and verify if the file exists
|
||||
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
|
||||
$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();
|
||||
|
|
@ -51,29 +52,33 @@ class File
|
|||
// Regular file_exists
|
||||
return file_exists($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content of a file
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @return string
|
||||
* @param string $pFilename Filename
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function fileGetContents($pFilename)
|
||||
public static function fileGetContents(string $pFilename): ?string
|
||||
{
|
||||
if (!self::fileExists($pFilename)) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
if (strtolower(substr($pFilename, 0, 3)) == 'zip') {
|
||||
// Open ZIP file and verify if the file exists
|
||||
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
|
||||
$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();
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
return false;
|
||||
|
||||
return null;
|
||||
}
|
||||
// Regular file contents
|
||||
return file_get_contents($pFilename);
|
||||
|
|
@ -82,16 +87,17 @@ class File
|
|||
/**
|
||||
* Returns canonicalized absolute pathname, also for ZIP archives
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $pFilename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function realpath($pFilename)
|
||||
public static function realpath(string $pFilename): string
|
||||
{
|
||||
// Try using realpath()
|
||||
$returnValue = realpath($pFilename);
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
if (empty($returnValue)) {
|
||||
$pathArray = explode('/', $pFilename);
|
||||
while (in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
$numPathArray = count($pathArray);
|
||||
|
|
|
|||
50
PhpOffice/Common/Font.php
Executable file → Normal file
50
PhpOffice/Common/Font.php
Executable file → Normal file
|
|
@ -9,7 +9,8 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @see https://github.com/PHPOffice/Common
|
||||
*
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
|
@ -24,43 +25,47 @@ class Font
|
|||
/**
|
||||
* Calculate an (approximate) pixel size, based on a font points size
|
||||
*
|
||||
* @param int $fontSizeInPoints Font size (in points)
|
||||
* @return int Font size (in pixels)
|
||||
* @param int $fontSizeInPoints Font size (in points)
|
||||
*
|
||||
* @return float Font size (in pixels)
|
||||
*/
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12)
|
||||
public static function fontSizeToPixels(int $fontSizeInPoints = 12): float
|
||||
{
|
||||
return ((16 / 12) * $fontSizeInPoints);
|
||||
return (16 / 12) * $fontSizeInPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on inch size
|
||||
*
|
||||
* @param int $sizeInInch Font size (in inch)
|
||||
* @param int $sizeInInch Font size (in inch)
|
||||
*
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function inchSizeToPixels($sizeInInch = 1)
|
||||
public static function inchSizeToPixels(int $sizeInInch = 1): int
|
||||
{
|
||||
return ($sizeInInch * 96);
|
||||
return $sizeInInch * 96;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on centimeter size
|
||||
*
|
||||
* @param int $sizeInCm Font size (in centimeters)
|
||||
* @return int Size (in pixels)
|
||||
* @param int $sizeInCm Font size (in centimeters)
|
||||
*
|
||||
* @return float Size (in pixels)
|
||||
*/
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1)
|
||||
public static function centimeterSizeToPixels(int $sizeInCm = 1): float
|
||||
{
|
||||
return ($sizeInCm * 37.795275591);
|
||||
return $sizeInCm * 37.795275591;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert centimeter to twip
|
||||
*
|
||||
* @param int $sizeInCm
|
||||
* @return double
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function centimeterSizeToTwips($sizeInCm = 1)
|
||||
public static function centimeterSizeToTwips(int $sizeInCm = 1): float
|
||||
{
|
||||
return $sizeInCm / 2.54 * 1440;
|
||||
}
|
||||
|
|
@ -69,9 +74,10 @@ class Font
|
|||
* Convert inch to twip
|
||||
*
|
||||
* @param int $sizeInInch
|
||||
* @return double
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function inchSizeToTwips($sizeInInch = 1)
|
||||
public static function inchSizeToTwips(int $sizeInInch = 1): int
|
||||
{
|
||||
return $sizeInInch * 1440;
|
||||
}
|
||||
|
|
@ -80,9 +86,10 @@ class Font
|
|||
* Convert pixel to twip
|
||||
*
|
||||
* @param int $sizeInPixel
|
||||
* @return double
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function pixelSizeToTwips($sizeInPixel = 1)
|
||||
public static function pixelSizeToTwips(int $sizeInPixel = 1): float
|
||||
{
|
||||
return $sizeInPixel / 96 * 1440;
|
||||
}
|
||||
|
|
@ -90,10 +97,11 @@ class Font
|
|||
/**
|
||||
* Calculate twip based on point size, used mainly for paragraph spacing
|
||||
*
|
||||
* @param integer $sizeInPoint Size in point
|
||||
* @return integer Size (in twips)
|
||||
* @param int $sizeInPoint Size in point
|
||||
*
|
||||
* @return float Size (in twips)
|
||||
*/
|
||||
public static function pointSizeToTwips($sizeInPoint = 1)
|
||||
public static function pointSizeToTwips(int $sizeInPoint = 1): float
|
||||
{
|
||||
return $sizeInPoint / 72 * 1440;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
PHPOffice Common, a shared PHP library for PHPOffice Libraries
|
||||
|
||||
Copyright (c) 2015-2015 PHPOffice.
|
||||
|
||||
PHPOffice Common is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 3 as published by
|
||||
the Free Software Foundation.
|
||||
|
||||
PHPOffice Common is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License version 3 for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License version 3
|
||||
along with PHPOffice Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
160
PhpOffice/Common/Microsoft/OLERead.php
Executable file → Normal file
160
PhpOffice/Common/Microsoft/OLERead.php
Executable file → Normal file
|
|
@ -9,7 +9,8 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @see https://github.com/PHPOffice/Common
|
||||
*
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
|
@ -17,64 +18,98 @@
|
|||
namespace PhpOffice\Common\Microsoft;
|
||||
|
||||
if (!defined('IDENTIFIER_OLE')) {
|
||||
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1));
|
||||
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1));
|
||||
}
|
||||
|
||||
class OLERead
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $data = '';
|
||||
|
||||
// OLE identifier
|
||||
const IDENTIFIER_OLE = IDENTIFIER_OLE;
|
||||
public const IDENTIFIER_OLE = IDENTIFIER_OLE;
|
||||
|
||||
// Size of a sector = 512 bytes
|
||||
const BIG_BLOCK_SIZE = 0x200;
|
||||
public const BIG_BLOCK_SIZE = 0x200;
|
||||
|
||||
// Size of a short sector = 64 bytes
|
||||
const SMALL_BLOCK_SIZE = 0x40;
|
||||
public const SMALL_BLOCK_SIZE = 0x40;
|
||||
|
||||
// Size of a directory entry always = 128 bytes
|
||||
const PROPERTY_STORAGE_BLOCK_SIZE = 0x80;
|
||||
public const PROPERTY_STORAGE_BLOCK_SIZE = 0x80;
|
||||
|
||||
// Minimum size of a standard stream = 4096 bytes, streams smaller than this are stored as short streams
|
||||
const SMALL_BLOCK_THRESHOLD = 0x1000;
|
||||
public const SMALL_BLOCK_THRESHOLD = 0x1000;
|
||||
|
||||
// header offsets
|
||||
const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c;
|
||||
const ROOT_START_BLOCK_POS = 0x30;
|
||||
const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c;
|
||||
const EXTENSION_BLOCK_POS = 0x44;
|
||||
const NUM_EXTENSION_BLOCK_POS = 0x48;
|
||||
const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c;
|
||||
public const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2C;
|
||||
public const ROOT_START_BLOCK_POS = 0x30;
|
||||
public const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3C;
|
||||
public const EXTENSION_BLOCK_POS = 0x44;
|
||||
public const NUM_EXTENSION_BLOCK_POS = 0x48;
|
||||
public const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4C;
|
||||
|
||||
// property storage offsets (directory offsets)
|
||||
const SIZE_OF_NAME_POS = 0x40;
|
||||
const TYPE_POS = 0x42;
|
||||
const START_BLOCK_POS = 0x74;
|
||||
const SIZE_POS = 0x78;
|
||||
public const SIZE_OF_NAME_POS = 0x40;
|
||||
public const TYPE_POS = 0x42;
|
||||
public const START_BLOCK_POS = 0x74;
|
||||
public const SIZE_POS = 0x78;
|
||||
|
||||
public $summaryInformation = null;
|
||||
public $docSummaryInfos = null;
|
||||
public $powerpointDocument = null;
|
||||
public $currentUser = null;
|
||||
public $pictures = null;
|
||||
public $rootEntry = null;
|
||||
public $props = array();
|
||||
public $smallBlockChain = null;
|
||||
public $bigBlockChain = null;
|
||||
public $entry = null;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $summaryInformation;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $docSummaryInfos;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $powerpointDocument;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $currentUser;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $pictures;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
public $rootEntry;
|
||||
/**
|
||||
* @var array<int, array<string, int|string>>
|
||||
*/
|
||||
public $props = [];
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $smallBlockChain;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $bigBlockChain;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $entry;
|
||||
|
||||
/**
|
||||
* Read the file
|
||||
*
|
||||
* @param $sFileName string Filename
|
||||
* @param string $sFileName Filename
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function read($sFileName)
|
||||
public function read(string $sFileName): void
|
||||
{
|
||||
// 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.");
|
||||
throw new \Exception('Could not open ' . $sFileName . ' for reading! File does not exist, or it is not readable.');
|
||||
}
|
||||
|
||||
// Get the file identifier
|
||||
|
|
@ -104,18 +139,18 @@ class OLERead
|
|||
// Total number of sectors used by MSAT
|
||||
$numExtensionBlocks = self::getInt4d($this->data, self::NUM_EXTENSION_BLOCK_POS);
|
||||
|
||||
$bigBlockDepotBlocks = array();
|
||||
$bigBlockDepotBlocks = [];
|
||||
$pos = self::BIG_BLOCK_DEPOT_BLOCKS_POS;
|
||||
|
||||
$bbdBlocks = $numBigBlkDepotBlks;
|
||||
|
||||
if ($numExtensionBlocks != 0) {
|
||||
$bbdBlocks = (self::BIG_BLOCK_SIZE - self::BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
|
||||
$bbdBlocks = (self::BIG_BLOCK_SIZE - self::BIG_BLOCK_DEPOT_BLOCKS_POS) / 4;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $bbdBlocks; ++$i) {
|
||||
$bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos);
|
||||
$pos += 4;
|
||||
$bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos);
|
||||
$pos += 4;
|
||||
}
|
||||
|
||||
for ($j = 0; $j < $numExtensionBlocks; ++$j) {
|
||||
|
|
@ -138,8 +173,8 @@ class OLERead
|
|||
for ($i = 0; $i < $numBigBlkDepotBlks; ++$i) {
|
||||
$pos = ($bigBlockDepotBlocks[$i] + 1) * self::BIG_BLOCK_SIZE;
|
||||
|
||||
$this->bigBlockChain .= substr($this->data, $pos, 4*$bbs);
|
||||
$pos += 4*$bbs;
|
||||
$this->bigBlockChain .= substr($this->data, $pos, 4 * $bbs);
|
||||
$pos += 4 * $bbs;
|
||||
}
|
||||
|
||||
$sbdBlock = $sbdStartBlock;
|
||||
|
|
@ -147,10 +182,10 @@ class OLERead
|
|||
while ($sbdBlock != -2) {
|
||||
$pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE;
|
||||
|
||||
$this->smallBlockChain .= substr($this->data, $pos, 4*$bbs);
|
||||
$pos += 4*$bbs;
|
||||
$this->smallBlockChain .= substr($this->data, $pos, 4 * $bbs);
|
||||
$pos += 4 * $bbs;
|
||||
|
||||
$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock*4);
|
||||
$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock * 4);
|
||||
}
|
||||
|
||||
// read the directory stream
|
||||
|
|
@ -165,12 +200,8 @@ class OLERead
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStream($stream)
|
||||
public function getStream(int $stream): ?string
|
||||
{
|
||||
if ($stream === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$streamData = '';
|
||||
|
||||
if ($this->props[$stream]['size'] < self::SMALL_BLOCK_THRESHOLD) {
|
||||
|
|
@ -179,10 +210,10 @@ class OLERead
|
|||
$block = $this->props[$stream]['startBlock'];
|
||||
|
||||
while ($block != -2) {
|
||||
$pos = $block * self::SMALL_BLOCK_SIZE;
|
||||
$pos = $block * self::SMALL_BLOCK_SIZE;
|
||||
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
|
||||
|
||||
$block = self::getInt4d($this->smallBlockChain, $block*4);
|
||||
$block = self::getInt4d($this->smallBlockChain, $block * 4);
|
||||
}
|
||||
|
||||
return $streamData;
|
||||
|
|
@ -202,7 +233,7 @@ class OLERead
|
|||
while ($block != -2) {
|
||||
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
|
||||
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block*4);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block * 4);
|
||||
}
|
||||
|
||||
return $streamData;
|
||||
|
|
@ -212,9 +243,10 @@ class OLERead
|
|||
* Read a standard stream (by joining sectors using information from SAT)
|
||||
*
|
||||
* @param int $blID Sector ID where the stream starts
|
||||
*
|
||||
* @return string Data for standard stream
|
||||
*/
|
||||
private function readData($blID)
|
||||
private function readData(int $blID): string
|
||||
{
|
||||
$block = $blID;
|
||||
$data = '';
|
||||
|
|
@ -222,15 +254,16 @@ class OLERead
|
|||
while ($block != -2) {
|
||||
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
|
||||
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block*4);
|
||||
$block = self::getInt4d($this->bigBlockChain, $block * 4);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read entries in the directory stream.
|
||||
*/
|
||||
private function readPropertySets()
|
||||
private function readPropertySets(): void
|
||||
{
|
||||
$offset = 0;
|
||||
|
||||
|
|
@ -241,7 +274,7 @@ class OLERead
|
|||
$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]);
|
||||
|
|
@ -252,13 +285,14 @@ 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[] = array (
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'startBlock' => $startBlock,
|
||||
'size' => $size);
|
||||
$this->props[] = [
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'startBlock' => $startBlock,
|
||||
'size' => $size,
|
||||
];
|
||||
|
||||
// tmp helper to simplify checks
|
||||
$upName = strtoupper($name);
|
||||
|
|
@ -268,14 +302,14 @@ class OLERead
|
|||
case 'R':
|
||||
$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':
|
||||
case chr(5) . 'SUMMARYINFORMATION':
|
||||
$this->summaryInformation = count($this->props) - 1;
|
||||
break;
|
||||
case chr(5).'DOCUMENTSUMMARYINFORMATION':
|
||||
case chr(5) . 'DOCUMENTSUMMARYINFORMATION':
|
||||
$this->docSummaryInfos = count($this->props) - 1;
|
||||
break;
|
||||
case 'CURRENT USER':
|
||||
|
|
@ -288,7 +322,7 @@ class OLERead
|
|||
$this->powerpointDocument = count($this->props) - 1;
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('OLE Block Not defined: $upName : '.$upName. ' - $name : "'.$name.'"');
|
||||
throw new \Exception('OLE Block Not defined: $upName : ' . $upName . ' - $name : "' . $name . '"');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -301,6 +335,7 @@ class OLERead
|
|||
*
|
||||
* @param string $data
|
||||
* @param int $pos
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function getInt4d($data, $pos)
|
||||
|
|
@ -315,6 +350,7 @@ class OLERead
|
|||
} else {
|
||||
$ord24 = ($or24 & 127) << 24;
|
||||
}
|
||||
|
||||
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
130
PhpOffice/Common/Microsoft/PasswordEncoder.php
Executable file → Normal file
130
PhpOffice/Common/Microsoft/PasswordEncoder.php
Executable file → Normal file
|
|
@ -9,7 +9,8 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @see https://github.com/PHPOffice/Common
|
||||
*
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
|
@ -21,39 +22,43 @@ namespace PhpOffice\Common\Microsoft;
|
|||
*/
|
||||
class PasswordEncoder
|
||||
{
|
||||
const ALGORITHM_MD2 = 'MD2';
|
||||
const ALGORITHM_MD4 = 'MD4';
|
||||
const ALGORITHM_MD5 = 'MD5';
|
||||
const ALGORITHM_SHA_1 = 'SHA-1';
|
||||
const ALGORITHM_SHA_256 = 'SHA-256';
|
||||
const ALGORITHM_SHA_384 = 'SHA-384';
|
||||
const ALGORITHM_SHA_512 = 'SHA-512';
|
||||
const ALGORITHM_RIPEMD = 'RIPEMD';
|
||||
const ALGORITHM_RIPEMD_160 = 'RIPEMD-160';
|
||||
const ALGORITHM_MAC = 'MAC';
|
||||
const ALGORITHM_HMAC = 'HMAC';
|
||||
public const ALGORITHM_MD2 = 'MD2';
|
||||
public const ALGORITHM_MD4 = 'MD4';
|
||||
public const ALGORITHM_MD5 = 'MD5';
|
||||
public const ALGORITHM_SHA_1 = 'SHA-1';
|
||||
public const ALGORITHM_SHA_256 = 'SHA-256';
|
||||
public const ALGORITHM_SHA_384 = 'SHA-384';
|
||||
public const ALGORITHM_SHA_512 = 'SHA-512';
|
||||
public const ALGORITHM_RIPEMD = 'RIPEMD';
|
||||
public const ALGORITHM_RIPEMD_160 = 'RIPEMD-160';
|
||||
public const ALGORITHM_MAC = 'MAC';
|
||||
public const ALGORITHM_HMAC = 'HMAC';
|
||||
|
||||
/**
|
||||
* Mapping between algorithm name and algorithm ID
|
||||
*
|
||||
* @var array
|
||||
* @var array<string, array<int, int|string>>
|
||||
*
|
||||
* @see https://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.writeprotection.cryptographicalgorithmsid(v=office.14).aspx
|
||||
*/
|
||||
private static $algorithmMapping = array(
|
||||
self::ALGORITHM_MD2 => array(1, 'md2'),
|
||||
self::ALGORITHM_MD4 => array(2, 'md4'),
|
||||
self::ALGORITHM_MD5 => array(3, 'md5'),
|
||||
self::ALGORITHM_SHA_1 => array(4, 'sha1'),
|
||||
self::ALGORITHM_MAC => array(5, ''), // 'mac' -> not possible with hash()
|
||||
self::ALGORITHM_RIPEMD => array(6, 'ripemd'),
|
||||
self::ALGORITHM_RIPEMD_160 => array(7, 'ripemd160'),
|
||||
self::ALGORITHM_HMAC => array(9, ''), //'hmac' -> not possible with hash()
|
||||
self::ALGORITHM_SHA_256 => array(12, 'sha256'),
|
||||
self::ALGORITHM_SHA_384 => array(13, 'sha384'),
|
||||
self::ALGORITHM_SHA_512 => array(14, 'sha512'),
|
||||
);
|
||||
private static $algorithmMapping = [
|
||||
self::ALGORITHM_MD2 => [1, 'md2'],
|
||||
self::ALGORITHM_MD4 => [2, 'md4'],
|
||||
self::ALGORITHM_MD5 => [3, 'md5'],
|
||||
self::ALGORITHM_SHA_1 => [4, 'sha1'],
|
||||
self::ALGORITHM_MAC => [5, ''], // 'mac' -> not possible with hash()
|
||||
self::ALGORITHM_RIPEMD => [6, 'ripemd'],
|
||||
self::ALGORITHM_RIPEMD_160 => [7, 'ripemd160'],
|
||||
self::ALGORITHM_HMAC => [9, ''], //'hmac' -> not possible with hash()
|
||||
self::ALGORITHM_SHA_256 => [12, 'sha256'],
|
||||
self::ALGORITHM_SHA_384 => [13, 'sha384'],
|
||||
self::ALGORITHM_SHA_512 => [14, 'sha512'],
|
||||
];
|
||||
|
||||
private static $initialCodeArray = array(
|
||||
/**
|
||||
* @var array<int>
|
||||
*/
|
||||
private static $initialCodeArray = [
|
||||
0xE1F0,
|
||||
0x1D0F,
|
||||
0xCC9C,
|
||||
|
|
@ -69,39 +74,47 @@ class PasswordEncoder
|
|||
0x280C,
|
||||
0xA96A,
|
||||
0x4EC3,
|
||||
);
|
||||
];
|
||||
|
||||
private static $encryptionMatrix = array(
|
||||
array(0xAEFC, 0x4DD9, 0x9BB2, 0x2745, 0x4E8A, 0x9D14, 0x2A09),
|
||||
array(0x7B61, 0xF6C2, 0xFDA5, 0xEB6B, 0xC6F7, 0x9DCF, 0x2BBF),
|
||||
array(0x4563, 0x8AC6, 0x05AD, 0x0B5A, 0x16B4, 0x2D68, 0x5AD0),
|
||||
array(0x0375, 0x06EA, 0x0DD4, 0x1BA8, 0x3750, 0x6EA0, 0xDD40),
|
||||
array(0xD849, 0xA0B3, 0x5147, 0xA28E, 0x553D, 0xAA7A, 0x44D5),
|
||||
array(0x6F45, 0xDE8A, 0xAD35, 0x4A4B, 0x9496, 0x390D, 0x721A),
|
||||
array(0xEB23, 0xC667, 0x9CEF, 0x29FF, 0x53FE, 0xA7FC, 0x5FD9),
|
||||
array(0x47D3, 0x8FA6, 0x0F6D, 0x1EDA, 0x3DB4, 0x7B68, 0xF6D0),
|
||||
array(0xB861, 0x60E3, 0xC1C6, 0x93AD, 0x377B, 0x6EF6, 0xDDEC),
|
||||
array(0x45A0, 0x8B40, 0x06A1, 0x0D42, 0x1A84, 0x3508, 0x6A10),
|
||||
array(0xAA51, 0x4483, 0x8906, 0x022D, 0x045A, 0x08B4, 0x1168),
|
||||
array(0x76B4, 0xED68, 0xCAF1, 0x85C3, 0x1BA7, 0x374E, 0x6E9C),
|
||||
array(0x3730, 0x6E60, 0xDCC0, 0xA9A1, 0x4363, 0x86C6, 0x1DAD),
|
||||
array(0x3331, 0x6662, 0xCCC4, 0x89A9, 0x0373, 0x06E6, 0x0DCC),
|
||||
array(0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48C4),
|
||||
);
|
||||
/**
|
||||
* @var array<int, array<int>>
|
||||
*/
|
||||
private static $encryptionMatrix = [
|
||||
[0xAEFC, 0x4DD9, 0x9BB2, 0x2745, 0x4E8A, 0x9D14, 0x2A09],
|
||||
[0x7B61, 0xF6C2, 0xFDA5, 0xEB6B, 0xC6F7, 0x9DCF, 0x2BBF],
|
||||
[0x4563, 0x8AC6, 0x05AD, 0x0B5A, 0x16B4, 0x2D68, 0x5AD0],
|
||||
[0x0375, 0x06EA, 0x0DD4, 0x1BA8, 0x3750, 0x6EA0, 0xDD40],
|
||||
[0xD849, 0xA0B3, 0x5147, 0xA28E, 0x553D, 0xAA7A, 0x44D5],
|
||||
[0x6F45, 0xDE8A, 0xAD35, 0x4A4B, 0x9496, 0x390D, 0x721A],
|
||||
[0xEB23, 0xC667, 0x9CEF, 0x29FF, 0x53FE, 0xA7FC, 0x5FD9],
|
||||
[0x47D3, 0x8FA6, 0x0F6D, 0x1EDA, 0x3DB4, 0x7B68, 0xF6D0],
|
||||
[0xB861, 0x60E3, 0xC1C6, 0x93AD, 0x377B, 0x6EF6, 0xDDEC],
|
||||
[0x45A0, 0x8B40, 0x06A1, 0x0D42, 0x1A84, 0x3508, 0x6A10],
|
||||
[0xAA51, 0x4483, 0x8906, 0x022D, 0x045A, 0x08B4, 0x1168],
|
||||
[0x76B4, 0xED68, 0xCAF1, 0x85C3, 0x1BA7, 0x374E, 0x6E9C],
|
||||
[0x3730, 0x6E60, 0xDCC0, 0xA9A1, 0x4363, 0x86C6, 0x1DAD],
|
||||
[0x3331, 0x6662, 0xCCC4, 0x89A9, 0x0373, 0x06E6, 0x0DCC],
|
||||
[0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48C4],
|
||||
];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private static $passwordMaxLength = 15;
|
||||
|
||||
/**
|
||||
* Create a hashed password that MS Word will be able to work with
|
||||
*
|
||||
* @see https://blogs.msdn.microsoft.com/vsod/2010/04/05/how-to-set-the-editing-restrictions-in-word-using-open-xml-sdk-2-0/
|
||||
*
|
||||
* @param string $password
|
||||
* @param string $algorithmName
|
||||
* @param string $salt
|
||||
* @param int $spinCount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function hashPassword($password, $algorithmName = self::ALGORITHM_SHA_1, $salt = null, $spinCount = 10000)
|
||||
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');
|
||||
|
|
@ -111,9 +124,9 @@ class PasswordEncoder
|
|||
// Get the single-byte values by iterating through the Unicode characters of the truncated password.
|
||||
// For each character, if the low byte is not equal to 0, take it. Otherwise, take the high byte.
|
||||
$passUtf8 = mb_convert_encoding($password, 'UCS-2LE', 'UTF-8');
|
||||
$byteChars = array();
|
||||
$byteChars = [];
|
||||
|
||||
for ($i = 0; $i < mb_strlen($password); $i++) {
|
||||
for ($i = 0; $i < mb_strlen($password); ++$i) {
|
||||
$byteChars[$i] = ord(substr($passUtf8, $i * 2, 1));
|
||||
|
||||
if ($byteChars[$i] == 0) {
|
||||
|
|
@ -135,7 +148,7 @@ class PasswordEncoder
|
|||
$algorithm = self::getAlgorithm($algorithmName);
|
||||
$generatedKey = hash($algorithm, $salt . $generatedKey, true);
|
||||
|
||||
for ($i = 0; $i < $spinCount; $i++) {
|
||||
for ($i = 0; $i < $spinCount; ++$i) {
|
||||
$generatedKey = hash($algorithm, $generatedKey . pack('CCCC', $i, $i >> 8, $i >> 16, $i >> 24), true);
|
||||
}
|
||||
$generatedKey = base64_encode($generatedKey);
|
||||
|
|
@ -149,9 +162,10 @@ class PasswordEncoder
|
|||
* Get algorithm from self::$algorithmMapping
|
||||
*
|
||||
* @param string $algorithmName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getAlgorithm($algorithmName)
|
||||
private static function getAlgorithm(string $algorithmName): string
|
||||
{
|
||||
$algorithm = self::$algorithmMapping[$algorithmName][1];
|
||||
if ($algorithm == '') {
|
||||
|
|
@ -165,9 +179,10 @@ class PasswordEncoder
|
|||
* Returns the algorithm ID
|
||||
*
|
||||
* @param string $algorithmName
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getAlgorithmId($algorithmName)
|
||||
public static function getAlgorithmId(string $algorithmName): int
|
||||
{
|
||||
return self::$algorithmMapping[$algorithmName][0];
|
||||
}
|
||||
|
|
@ -175,10 +190,11 @@ class PasswordEncoder
|
|||
/**
|
||||
* Build combined key from low-order word and high-order word
|
||||
*
|
||||
* @param array $byteChars byte array representation of password
|
||||
* @param array<int, int> $byteChars byte array representation of password
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function buildCombinedKey($byteChars)
|
||||
private static function buildCombinedKey(array $byteChars): int
|
||||
{
|
||||
$byteCharsLength = count($byteChars);
|
||||
// Compute the high-order word
|
||||
|
|
@ -189,10 +205,10 @@ class PasswordEncoder
|
|||
// For every bit in the character, starting with the least significant and progressing to (but excluding)
|
||||
// the most significant, if the bit is set, XOR the key’s high-order word with the corresponding word from
|
||||
// the Encryption Matrix
|
||||
for ($i = 0; $i < $byteCharsLength; $i++) {
|
||||
for ($i = 0; $i < $byteCharsLength; ++$i) {
|
||||
$tmp = self::$passwordMaxLength - $byteCharsLength + $i;
|
||||
$matrixRow = self::$encryptionMatrix[$tmp];
|
||||
for ($intBit = 0; $intBit < 7; $intBit++) {
|
||||
for ($intBit = 0; $intBit < 7; ++$intBit) {
|
||||
if (($byteChars[$i] & (0x0001 << $intBit)) != 0) {
|
||||
$highOrderWord = ($highOrderWord ^ $matrixRow[$intBit]);
|
||||
}
|
||||
|
|
@ -203,7 +219,7 @@ class PasswordEncoder
|
|||
// Initialize with 0
|
||||
$lowOrderWord = 0;
|
||||
// For each character in the password, going backwards
|
||||
for ($i = $byteCharsLength - 1; $i >= 0; $i--) {
|
||||
for ($i = $byteCharsLength - 1; $i >= 0; --$i) {
|
||||
// low-order word = (((low-order word SHR 14) AND 0x0001) OR (low-order word SHL 1) AND 0x7FFF)) XOR character
|
||||
$lowOrderWord = (((($lowOrderWord >> 14) & 0x0001) | (($lowOrderWord << 1) & 0x7FFF)) ^ $byteChars[$i]);
|
||||
}
|
||||
|
|
@ -218,7 +234,9 @@ class PasswordEncoder
|
|||
* Simulate behaviour of (signed) int32
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function int32($value)
|
||||
|
|
|
|||
92
PhpOffice/Common/Text.php
Executable file → Normal file
92
PhpOffice/Common/Text.php
Executable file → Normal file
|
|
@ -9,7 +9,8 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @see https://github.com/PHPOffice/Common
|
||||
*
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
|
@ -26,17 +27,17 @@ class Text
|
|||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $controlCharacters = array();
|
||||
private static $controlCharacters = [];
|
||||
|
||||
/**
|
||||
* Build control characters array
|
||||
*/
|
||||
private static function buildControlCharacters()
|
||||
private static function buildControlCharacters(): void
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -53,10 +54,11 @@ class Text
|
|||
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to escape
|
||||
* @param string $value Value to escape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function controlCharacterPHP2OOXML($value = '')
|
||||
public static function controlCharacterPHP2OOXML(string $value = ''): string
|
||||
{
|
||||
if (empty(self::$controlCharacters)) {
|
||||
self::buildControlCharacters();
|
||||
|
|
@ -67,35 +69,41 @@ class Text
|
|||
|
||||
/**
|
||||
* Return a number formatted for being integrated in xml files
|
||||
*
|
||||
* @param float $number
|
||||
* @param integer $decimals
|
||||
* @param int $decimals
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function numberFormat($number, $decimals)
|
||||
public static function numberFormat(float $number, int $decimals): string
|
||||
{
|
||||
return number_format($number, $decimals, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $dec
|
||||
* @link http://stackoverflow.com/a/7153133/2235790
|
||||
*
|
||||
* @see http://stackoverflow.com/a/7153133/2235790
|
||||
*
|
||||
* @author velcrow
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function chr($dec)
|
||||
public static function chr(int $dec): string
|
||||
{
|
||||
if ($dec<=0x7F) {
|
||||
if ($dec <= 0x7F) {
|
||||
return chr($dec);
|
||||
}
|
||||
if ($dec<=0x7FF) {
|
||||
return chr(($dec>>6)+192).chr(($dec&63)+128);
|
||||
if ($dec <= 0x7FF) {
|
||||
return chr(($dec >> 6) + 192) . chr(($dec & 63) + 128);
|
||||
}
|
||||
if ($dec<=0xFFFF) {
|
||||
return chr(($dec>>12)+224).chr((($dec>>6)&63)+128).chr(($dec&63)+128);
|
||||
if ($dec <= 0xFFFF) {
|
||||
return chr(($dec >> 12) + 224) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
|
||||
}
|
||||
if ($dec<=0x1FFFFF) {
|
||||
return chr(($dec>>18)+240).chr((($dec>>12)&63)+128).chr((($dec>>6)&63)+128).chr(($dec&63)+128);
|
||||
if ($dec <= 0x1FFFFF) {
|
||||
return chr(($dec >> 18) + 240) . chr((($dec >> 12) & 63) + 128) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
@ -103,9 +111,10 @@ class Text
|
|||
* Convert from OpenXML escaped control character to PHP control character
|
||||
*
|
||||
* @param string $value Value to unescape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function controlCharacterOOXML2PHP($value = '')
|
||||
public static function controlCharacterOOXML2PHP(string $value = ''): string
|
||||
{
|
||||
if (empty(self::$controlCharacters)) {
|
||||
self::buildControlCharacters();
|
||||
|
|
@ -118,9 +127,10 @@ class Text
|
|||
* Check if a string contains UTF-8 data
|
||||
*
|
||||
* @param string $value
|
||||
* @return boolean
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isUTF8($value = '')
|
||||
public static function isUTF8(string $value = ''): bool
|
||||
{
|
||||
return is_string($value) && ($value === '' || preg_match('/^./su', $value) == 1);
|
||||
}
|
||||
|
|
@ -128,10 +138,11 @@ class Text
|
|||
/**
|
||||
* Return UTF8 encoded value
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function toUTF8($value = '')
|
||||
public static function toUTF8(?string $value = ''): ?string
|
||||
{
|
||||
if (!is_null($value) && !self::isUTF8($value)) {
|
||||
$value = utf8_encode($value);
|
||||
|
|
@ -146,10 +157,12 @@ class Text
|
|||
* The function is splitted to reduce cyclomatic complexity
|
||||
*
|
||||
* @param string $text UTF8 text
|
||||
*
|
||||
* @return string Unicode text
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
public static function toUnicode($text)
|
||||
public static function toUnicode(string $text): string
|
||||
{
|
||||
return self::unicodeToEntities(self::utf8ToUnicode($text));
|
||||
}
|
||||
|
|
@ -158,18 +171,20 @@ class Text
|
|||
* Returns unicode array from UTF8 text
|
||||
*
|
||||
* @param string $text UTF8 text
|
||||
* @return array
|
||||
*
|
||||
* @return array<int, int>
|
||||
*
|
||||
* @since 0.11.0
|
||||
* @link http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||
*/
|
||||
public static function utf8ToUnicode($text)
|
||||
public static function utf8ToUnicode(string $text): array
|
||||
{
|
||||
$unicode = array();
|
||||
$values = array();
|
||||
$unicode = [];
|
||||
$values = [];
|
||||
$lookingFor = 1;
|
||||
|
||||
// Gets unicode for each character
|
||||
for ($i = 0; $i < strlen($text); $i++) {
|
||||
for ($i = 0; $i < strlen($text); ++$i) {
|
||||
$thisValue = ord($text[$i]);
|
||||
if ($thisValue < 128) {
|
||||
$unicode[] = $thisValue;
|
||||
|
|
@ -185,7 +200,7 @@ class Text
|
|||
$number = (($values[0] % 32) * 64) + ($values[1] % 64);
|
||||
}
|
||||
$unicode[] = $number;
|
||||
$values = array();
|
||||
$values = [];
|
||||
$lookingFor = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -197,12 +212,14 @@ class Text
|
|||
/**
|
||||
* Returns entites from unicode array
|
||||
*
|
||||
* @param array $unicode
|
||||
* @param array<int, int> $unicode
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 0.11.0
|
||||
* @link http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||
*/
|
||||
private static function unicodeToEntities($unicode)
|
||||
private static function unicodeToEntities(array $unicode): string
|
||||
{
|
||||
$entities = '';
|
||||
|
||||
|
|
@ -218,10 +235,11 @@ class Text
|
|||
/**
|
||||
* Return name without underscore for < 0.10.0 variable name compatibility
|
||||
*
|
||||
* @param string $value
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function removeUnderscorePrefix($value)
|
||||
public static function removeUnderscorePrefix(?string $value): string
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
if (substr($value, 0, 1) == '_') {
|
||||
|
|
|
|||
90
PhpOffice/Common/XMLReader.php
Executable file → Normal file
90
PhpOffice/Common/XMLReader.php
Executable file → Normal file
|
|
@ -9,13 +9,20 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @see https://github.com/PHPOffice/Common
|
||||
*
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\Common;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use DOMNodeList;
|
||||
use DOMXpath;
|
||||
use ZipArchive;
|
||||
|
||||
/**
|
||||
* XML Reader wrapper
|
||||
*
|
||||
|
|
@ -26,14 +33,14 @@ class XMLReader
|
|||
/**
|
||||
* DOMDocument object
|
||||
*
|
||||
* @var \DOMDocument
|
||||
* @var DOMDocument
|
||||
*/
|
||||
private $dom = null;
|
||||
|
||||
/**
|
||||
* DOMXpath object
|
||||
*
|
||||
* @var \DOMXpath
|
||||
* @var DOMXpath
|
||||
*/
|
||||
private $xpath = null;
|
||||
|
||||
|
|
@ -42,16 +49,18 @@ class XMLReader
|
|||
*
|
||||
* @param string $zipFile
|
||||
* @param string $xmlFile
|
||||
* @return \DOMDocument|false
|
||||
*
|
||||
* @return DOMDocument|false
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getDomFromZip($zipFile, $xmlFile)
|
||||
public function getDomFromZip(string $zipFile, string $xmlFile)
|
||||
{
|
||||
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();
|
||||
|
|
@ -67,14 +76,22 @@ class XMLReader
|
|||
* Get DOMDocument from content string
|
||||
*
|
||||
* @param string $content
|
||||
* @return \DOMDocument
|
||||
*
|
||||
* @return DOMDocument
|
||||
*/
|
||||
public function getDomFromString($content)
|
||||
public function getDomFromString(string $content)
|
||||
{
|
||||
//$originalLibXMLEntityValue = libxml_disable_entity_loader(true);
|
||||
$this->dom = new \DOMDocument();
|
||||
$originalLibXMLEntityValue = false;
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
$originalLibXMLEntityValue = libxml_disable_entity_loader(true);
|
||||
}
|
||||
|
||||
$this->dom = new DOMDocument();
|
||||
$this->dom->loadXML($content);
|
||||
//libxml_disable_entity_loader($originalLibXMLEntityValue);
|
||||
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
libxml_disable_entity_loader($originalLibXMLEntityValue);
|
||||
}
|
||||
|
||||
return $this->dom;
|
||||
}
|
||||
|
|
@ -83,16 +100,17 @@ class XMLReader
|
|||
* Get elements
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return \DOMNodeList
|
||||
* @param DOMElement $contextNode
|
||||
*
|
||||
* @return DOMNodeList<DOMElement>
|
||||
*/
|
||||
public function getElements($path, \DOMElement $contextNode = null)
|
||||
public function getElements(string $path, DOMElement $contextNode = null)
|
||||
{
|
||||
if ($this->dom === null) {
|
||||
return array();
|
||||
return new DOMNodeList();
|
||||
}
|
||||
if ($this->xpath === null) {
|
||||
$this->xpath = new \DOMXpath($this->dom);
|
||||
$this->xpath = new DOMXpath($this->dom);
|
||||
}
|
||||
|
||||
if (is_null($contextNode)) {
|
||||
|
|
@ -107,7 +125,9 @@ class XMLReader
|
|||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string $namespaceURI The URI of the namespace
|
||||
*
|
||||
* @return bool true on success or false on failure
|
||||
*
|
||||
* @throws \InvalidArgumentException If called before having loaded the DOM document
|
||||
*/
|
||||
public function registerNamespace($prefix, $namespaceURI)
|
||||
|
|
@ -116,8 +136,9 @@ 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);
|
||||
}
|
||||
|
||||
|
|
@ -125,14 +146,15 @@ class XMLReader
|
|||
* Get element
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return \DOMElement|null
|
||||
* @param DOMElement $contextNode
|
||||
*
|
||||
* @return DOMElement|null
|
||||
*/
|
||||
public function getElement($path, \DOMElement $contextNode = null)
|
||||
public function getElement($path, DOMElement $contextNode = null): ?DOMElement
|
||||
{
|
||||
$elements = $this->getElements($path, $contextNode);
|
||||
if ($elements->length > 0) {
|
||||
return $elements->item(0);
|
||||
return $elements->item(0) instanceof DOMElement ? $elements->item(0) : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -142,17 +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);
|
||||
}
|
||||
|
|
@ -169,10 +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) {
|
||||
|
|
@ -186,10 +210,11 @@ class XMLReader
|
|||
* Count elements
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return integer
|
||||
* @param DOMElement $contextNode
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countElements($path, \DOMElement $contextNode = null)
|
||||
public function countElements($path, DOMElement $contextNode = null)
|
||||
{
|
||||
$elements = $this->getElements($path, $contextNode);
|
||||
|
||||
|
|
@ -200,10 +225,11 @@ class XMLReader
|
|||
* Element exists
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return boolean
|
||||
* @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;
|
||||
}
|
||||
|
|
|
|||
38
PhpOffice/Common/XMLWriter.php
Executable file → Normal file
38
PhpOffice/Common/XMLWriter.php
Executable file → Normal file
|
|
@ -9,7 +9,8 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/Common/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/Common
|
||||
* @see https://github.com/PHPOffice/Common
|
||||
*
|
||||
* @copyright 2009-2016 PHPOffice Common contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
|
@ -35,8 +36,8 @@ namespace PhpOffice\Common;
|
|||
class XMLWriter extends \XMLWriter
|
||||
{
|
||||
/** Temporary storage method */
|
||||
const STORAGE_MEMORY = 1;
|
||||
const STORAGE_DISK = 2;
|
||||
public const STORAGE_MEMORY = 1;
|
||||
public const STORAGE_DISK = 2;
|
||||
|
||||
/**
|
||||
* Temporary filename
|
||||
|
|
@ -58,7 +59,7 @@ class XMLWriter extends \XMLWriter
|
|||
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
||||
$this->openMemory();
|
||||
} else {
|
||||
if (!is_dir($pTemporaryStorageDir)) {
|
||||
if ($pTemporaryStorageDir && !is_dir($pTemporaryStorageDir)) {
|
||||
$pTemporaryStorageDir = sys_get_temp_dir();
|
||||
}
|
||||
// Create temporary filename
|
||||
|
|
@ -87,7 +88,7 @@ class XMLWriter extends \XMLWriter
|
|||
return;
|
||||
}
|
||||
if (PHP_OS != 'WINNT' && @unlink($this->tempFileName) === false) {
|
||||
throw new \Exception('The file '.$this->tempFileName.' could not be deleted.');
|
||||
throw new \Exception('The file ' . $this->tempFileName . ' could not be deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,10 +104,10 @@ class XMLWriter extends \XMLWriter
|
|||
}
|
||||
|
||||
$this->flush();
|
||||
|
||||
return file_get_contents($this->tempFileName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write simple element and attribute(s) block
|
||||
*
|
||||
|
|
@ -115,15 +116,16 @@ class XMLWriter extends \XMLWriter
|
|||
* 2. If not, then it's a simple attribute-value pair
|
||||
*
|
||||
* @param string $element
|
||||
* @param string|array $attributes
|
||||
* @param string|array<string, string> $attributes
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function writeElementBlock($element, $attributes, $value = null)
|
||||
public function writeElementBlock(string $element, $attributes, string $value = null)
|
||||
{
|
||||
$this->startElement($element);
|
||||
if (!is_array($attributes)) {
|
||||
$attributes = array($attributes => $value);
|
||||
$attributes = [$attributes => $value];
|
||||
}
|
||||
foreach ($attributes as $attribute => $value) {
|
||||
$this->writeAttribute($attribute, $value);
|
||||
|
|
@ -136,13 +138,14 @@ class XMLWriter extends \XMLWriter
|
|||
*
|
||||
* @param bool $condition
|
||||
* @param string $element
|
||||
* @param string $attribute
|
||||
* @param string|null $attribute
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function writeElementIf($condition, $element, $attribute = null, $value = null)
|
||||
public function writeElementIf(bool $condition, string $element, ?string $attribute = null, $value = null)
|
||||
{
|
||||
if ($condition == true) {
|
||||
if ($condition) {
|
||||
if (is_null($attribute)) {
|
||||
$this->writeElement($element, $value);
|
||||
} else {
|
||||
|
|
@ -159,11 +162,12 @@ class XMLWriter extends \XMLWriter
|
|||
* @param bool $condition
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function writeAttributeIf($condition, $attribute, $value)
|
||||
public function writeAttributeIf(bool $condition, string $attribute, $value)
|
||||
{
|
||||
if ($condition == true) {
|
||||
if ($condition) {
|
||||
$this->writeAttribute($attribute, $value);
|
||||
}
|
||||
}
|
||||
|
|
@ -171,13 +175,15 @@ class XMLWriter extends \XMLWriter
|
|||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function writeAttribute($name, $value)
|
||||
public function writeAttribute($name, $value): bool
|
||||
{
|
||||
if (is_float($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
return parent::writeAttribute($name, $value);
|
||||
|
||||
return parent::writeAttribute($name, $value ?? '');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
220
PhpOffice/PhpPresentation/AbstractShape.php
Executable file → Normal file
220
PhpOffice/PhpPresentation/AbstractShape.php
Executable file → Normal file
|
|
@ -10,127 +10,120 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use PhpOffice\PhpPresentation\Exception\ShapeContainerAlreadyAssignedException;
|
||||
use PhpOffice\PhpPresentation\Shape\Hyperlink;
|
||||
use PhpOffice\PhpPresentation\Shape\Placeholder;
|
||||
use PhpOffice\PhpPresentation\Style\Border;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
use PhpOffice\PhpPresentation\Style\Shadow;
|
||||
|
||||
/**
|
||||
* Abstract shape
|
||||
* Abstract shape.
|
||||
*/
|
||||
abstract class AbstractShape implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Container
|
||||
* Container.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
* @var ShapeContainerInterface|null
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Offset X
|
||||
* Offset X.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offsetX;
|
||||
|
||||
/**
|
||||
* Offset Y
|
||||
* Offset Y.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offsetY;
|
||||
|
||||
/**
|
||||
* Width
|
||||
* Width.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $width;
|
||||
|
||||
/**
|
||||
* Height
|
||||
* Height.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $height;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
* @var Fill|null
|
||||
*/
|
||||
private $fill;
|
||||
|
||||
/**
|
||||
* Border
|
||||
* Border.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
* @var Border
|
||||
*/
|
||||
private $border;
|
||||
|
||||
/**
|
||||
* Rotation
|
||||
* Rotation.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $rotation;
|
||||
|
||||
/**
|
||||
* Shadow
|
||||
* Shadow.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Shadow
|
||||
* @var Shadow|null
|
||||
*/
|
||||
protected $shadow;
|
||||
|
||||
/**
|
||||
* Hyperlink
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* @var Hyperlink|null
|
||||
*/
|
||||
protected $hyperlink;
|
||||
|
||||
/**
|
||||
* PlaceHolder
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Placeholder
|
||||
* @var Placeholder|null
|
||||
*/
|
||||
protected $placeholder;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new self
|
||||
* Create a new self.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->container = null;
|
||||
$this->offsetX = 0;
|
||||
$this->offsetY = 0;
|
||||
$this->width = 0;
|
||||
$this->height = 0;
|
||||
$this->rotation = 0;
|
||||
$this->fill = new Style\Fill();
|
||||
$this->border = new Style\Border();
|
||||
$this->shadow = new Style\Shadow();
|
||||
|
||||
$this->offsetX = $this->offsetY = $this->width = $this->height = $this->rotation = 0;
|
||||
$this->fill = new Fill();
|
||||
$this->shadow = new Shadow();
|
||||
$this->border = new Border();
|
||||
$this->border->setLineStyle(Style\Border::LINE_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic Method : clone
|
||||
* Magic Method : clone.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
|
|
@ -141,34 +134,34 @@ abstract class AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Container, Slide or Group
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
* Get Container, Slide or Group.
|
||||
*/
|
||||
public function getContainer()
|
||||
public function getContainer(): ?ShapeContainerInterface
|
||||
{
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Container, Slide or Group
|
||||
* Set Container, Slide or Group.
|
||||
*
|
||||
* @param ShapeContainerInterface $pValue
|
||||
* @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide?
|
||||
*
|
||||
* @throws ShapeContainerAlreadyAssignedException
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ShapeContainerInterface $pValue
|
||||
* @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide?
|
||||
* @throws \Exception
|
||||
* @return $this
|
||||
*/
|
||||
public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideOld = false)
|
||||
{
|
||||
if (is_null($this->container)) {
|
||||
// Add drawing to \PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
// Add drawing to ShapeContainerInterface
|
||||
$this->container = $pValue;
|
||||
if (!is_null($this->container)) {
|
||||
$this->container->getShapeCollection()->append($this);
|
||||
}
|
||||
} else {
|
||||
if ($pOverrideOld) {
|
||||
// Remove drawing from old \PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
// Remove drawing from old ShapeContainerInterface
|
||||
$iterator = $this->container->getShapeCollection()->getIterator();
|
||||
|
||||
while ($iterator->valid()) {
|
||||
|
|
@ -183,7 +176,7 @@ abstract class AbstractShape implements ComparableInterface
|
|||
// Set new \PhpOffice\PhpPresentation\Slide
|
||||
$this->setContainer($pValue);
|
||||
} else {
|
||||
throw new \Exception("A \PhpOffice\PhpPresentation\ShapeContainerInterface has already been assigned. Shapes can only exist on one \PhpOffice\PhpPresentation\ShapeContainerInterface.");
|
||||
throw new ShapeContainerAlreadyAssignedException(self::class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -191,22 +184,19 @@ abstract class AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX
|
||||
*
|
||||
* @return int
|
||||
* Get OffsetX.
|
||||
*/
|
||||
public function getOffsetX()
|
||||
public function getOffsetX(): int
|
||||
{
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX
|
||||
* Set OffsetX.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetX($pValue = 0)
|
||||
public function setOffsetX(int $pValue = 0)
|
||||
{
|
||||
$this->offsetX = $pValue;
|
||||
|
||||
|
|
@ -214,7 +204,7 @@ abstract class AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY
|
||||
* Get OffsetY.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -224,12 +214,11 @@ abstract class AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY
|
||||
* Set OffsetY.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetY($pValue = 0)
|
||||
public function setOffsetY(int $pValue = 0)
|
||||
{
|
||||
$this->offsetY = $pValue;
|
||||
|
||||
|
|
@ -237,7 +226,7 @@ abstract class AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Width
|
||||
* Get Width.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -247,19 +236,19 @@ abstract class AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
* Set Width.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setWidth($pValue = 0)
|
||||
public function setWidth(int $pValue = 0)
|
||||
{
|
||||
$this->width = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height
|
||||
* Get Height.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -269,34 +258,32 @@ abstract class AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
* Set Height.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeight($pValue = 0)
|
||||
public function setHeight(int $pValue = 0)
|
||||
{
|
||||
$this->height = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set width and height with proportional resize
|
||||
* Set width and height with proportional resize.
|
||||
*
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @example $objDrawing->setWidthAndHeight(160,120);
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setWidthAndHeight($width = 0, $height = 0)
|
||||
public function setWidthAndHeight(int $width = 0, int $height = 0)
|
||||
{
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation
|
||||
* Get Rotation.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -306,75 +293,55 @@ abstract class AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Rotation
|
||||
* Set Rotation.
|
||||
*
|
||||
* @param int $pValue
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setRotation($pValue = 0)
|
||||
{
|
||||
$this->rotation = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
public function getFill()
|
||||
public function getFill(): ?Fill
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $pValue
|
||||
* @return \PhpOffice\PhpPresentation\AbstractShape
|
||||
*/
|
||||
public function setFill(Fill $pValue = null)
|
||||
public function setFill(Fill $pValue = null): self
|
||||
{
|
||||
$this->fill = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Border
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
public function getBorder()
|
||||
public function getBorder(): Border
|
||||
{
|
||||
return $this->border;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Shadow
|
||||
*/
|
||||
public function getShadow()
|
||||
public function getShadow(): ?Shadow
|
||||
{
|
||||
return $this->shadow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Shadow $pValue
|
||||
* @throws \Exception
|
||||
* @return $this
|
||||
*/
|
||||
public function setShadow(Shadow $pValue = null)
|
||||
{
|
||||
$this->shadow = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has Hyperlink?
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasHyperlink()
|
||||
{
|
||||
|
|
@ -383,87 +350,84 @@ abstract class AbstractShape implements ComparableInterface
|
|||
|
||||
/**
|
||||
* Get Hyperlink
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getHyperlink()
|
||||
public function getHyperlink(): Hyperlink
|
||||
{
|
||||
if (is_null($this->hyperlink)) {
|
||||
$this->hyperlink = new Hyperlink();
|
||||
}
|
||||
|
||||
return $this->hyperlink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Hyperlink
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Hyperlink $pHyperlink
|
||||
* @throws \Exception
|
||||
* @return $this
|
||||
*/
|
||||
public function setHyperlink(Hyperlink $pHyperlink = null)
|
||||
public function setHyperlink(Hyperlink $pHyperlink = null): self
|
||||
{
|
||||
$this->hyperlink = $pHyperlink;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
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__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isPlaceholder()
|
||||
public function isPlaceholder(): bool
|
||||
{
|
||||
return !is_null($this->placeholder);
|
||||
}
|
||||
|
||||
public function getPlaceholder()
|
||||
public function getPlaceholder(): ?Placeholder
|
||||
{
|
||||
if (!$this->isPlaceholder()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->placeholder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Placeholder $placeholder
|
||||
* @return $this
|
||||
*/
|
||||
public function setPlaceHolder(Placeholder $placeholder)
|
||||
public function setPlaceHolder(Placeholder $placeholder): self
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
PhpOffice/PhpPresentation/Autoloader.php
Executable file → Normal file
26
PhpOffice/PhpPresentation/Autoloader.php
Executable file → Normal file
|
|
@ -10,42 +10,44 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* Autoloader
|
||||
* Autoloader.
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
/** @const string */
|
||||
const NAMESPACE_PREFIX = 'PhpOffice\\PhpPresentation\\';
|
||||
public const NAMESPACE_PREFIX = 'PhpOffice\\PhpPresentation\\';
|
||||
|
||||
/**
|
||||
* Register
|
||||
*
|
||||
* @return void
|
||||
* Register.
|
||||
*/
|
||||
public static function register()
|
||||
public static function register(): void
|
||||
{
|
||||
spl_autoload_register(array(new self, 'autoload'));
|
||||
spl_autoload_register([new self(), 'autoload']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload
|
||||
*
|
||||
* @param string $class
|
||||
* Autoload.
|
||||
*/
|
||||
public static function autoload($class)
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
if (file_exists($file)) {
|
||||
/** @noinspection PhpIncludeInspection Dynamic includes */
|
||||
require_once $file;
|
||||
|
|
|
|||
|
|
@ -1,674 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
25
PhpOffice/PhpPresentation/ComparableInterface.php
Executable file → Normal file
25
PhpOffice/PhpPresentation/ComparableInterface.php
Executable file → Normal file
|
|
@ -10,42 +10,47 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* PhpOffice\PhpPresentation\ComparableInterface
|
||||
* PhpOffice\PhpPresentation\ComparableInterface.
|
||||
*/
|
||||
interface ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
public function getHashCode(): string;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex();
|
||||
public function getHashIndex(): ?int;
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHashIndex($value);
|
||||
public function setHashIndex(int $value);
|
||||
}
|
||||
|
|
|
|||
141
PhpOffice/PhpPresentation/DocumentLayout.php
Executable file → Normal file
141
PhpOffice/PhpPresentation/DocumentLayout.php
Executable file → Normal file
|
|
@ -10,83 +10,90 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use PhpOffice\Common\Drawing;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\DocumentLayout
|
||||
* \PhpOffice\PhpPresentation\DocumentLayout.
|
||||
*/
|
||||
class DocumentLayout
|
||||
{
|
||||
const LAYOUT_CUSTOM = '';
|
||||
const LAYOUT_SCREEN_4X3 = 'screen4x3';
|
||||
const LAYOUT_SCREEN_16X10 = 'screen16x10';
|
||||
const LAYOUT_SCREEN_16X9 = 'screen16x9';
|
||||
const LAYOUT_35MM = '35mm';
|
||||
const LAYOUT_A3 = 'A3';
|
||||
const LAYOUT_A4 = 'A4';
|
||||
const LAYOUT_B4ISO = 'B4ISO';
|
||||
const LAYOUT_B5ISO = 'B5ISO';
|
||||
const LAYOUT_BANNER = 'banner';
|
||||
const LAYOUT_LETTER = 'letter';
|
||||
const LAYOUT_OVERHEAD = 'overhead';
|
||||
public const LAYOUT_CUSTOM = '';
|
||||
public const LAYOUT_SCREEN_4X3 = 'screen4x3';
|
||||
public const LAYOUT_SCREEN_16X10 = 'screen16x10';
|
||||
public const LAYOUT_SCREEN_16X9 = 'screen16x9';
|
||||
public const LAYOUT_35MM = '35mm';
|
||||
public const LAYOUT_A3 = 'A3';
|
||||
public const LAYOUT_A4 = 'A4';
|
||||
public const LAYOUT_B4ISO = 'B4ISO';
|
||||
public const LAYOUT_B5ISO = 'B5ISO';
|
||||
public const LAYOUT_BANNER = 'banner';
|
||||
public const LAYOUT_LETTER = 'letter';
|
||||
public const LAYOUT_OVERHEAD = 'overhead';
|
||||
|
||||
const UNIT_EMU = 'emu';
|
||||
const UNIT_CENTIMETER = 'cm';
|
||||
const UNIT_INCH = 'in';
|
||||
const UNIT_MILLIMETER = 'mm';
|
||||
const UNIT_PIXEL = 'px';
|
||||
const UNIT_POINT = 'pt';
|
||||
public const UNIT_EMU = 'emu';
|
||||
public const UNIT_CENTIMETER = 'cm';
|
||||
public const UNIT_INCH = 'in';
|
||||
public const UNIT_MILLIMETER = 'mm';
|
||||
public const UNIT_PIXEL = 'px';
|
||||
public const UNIT_POINT = 'pt';
|
||||
|
||||
/**
|
||||
* Dimension types
|
||||
* Dimension types.
|
||||
*
|
||||
* 1 px = 9525 EMU @ 96dpi (which is seems to be the default)
|
||||
* Absolute distances are specified in English Metric Units (EMUs),
|
||||
* occasionally referred to as A units; there are 360000 EMUs per
|
||||
* centimeter, 914400 EMUs per inch, 12700 EMUs per point.
|
||||
*
|
||||
* @var array<string, array<string, int>>
|
||||
*/
|
||||
private $dimension = array(
|
||||
self::LAYOUT_SCREEN_4X3 => array('cx' => 9144000, 'cy' => 6858000),
|
||||
self::LAYOUT_SCREEN_16X10 => array('cx' => 9144000, 'cy' => 5715000),
|
||||
self::LAYOUT_SCREEN_16X9 => array('cx' => 9144000, 'cy' => 5143500),
|
||||
self::LAYOUT_35MM => array('cx' => 10287000, 'cy' => 6858000),
|
||||
self::LAYOUT_A3 => array('cx' => 15120000, 'cy' => 10692000),
|
||||
self::LAYOUT_A4 => array('cx' => 10692000, 'cy' => 7560000),
|
||||
self::LAYOUT_B4ISO => array('cx' => 10826750, 'cy' => 8120063),
|
||||
self::LAYOUT_B5ISO => array('cx' => 7169150, 'cy' => 5376863),
|
||||
self::LAYOUT_BANNER => array('cx' => 7315200, 'cy' => 914400),
|
||||
self::LAYOUT_LETTER => array('cx' => 9144000, 'cy' => 6858000),
|
||||
self::LAYOUT_OVERHEAD => array('cx' => 9144000, 'cy' => 6858000),
|
||||
);
|
||||
private $dimension = [
|
||||
self::LAYOUT_SCREEN_4X3 => ['cx' => 9144000, 'cy' => 6858000],
|
||||
self::LAYOUT_SCREEN_16X10 => ['cx' => 9144000, 'cy' => 5715000],
|
||||
self::LAYOUT_SCREEN_16X9 => ['cx' => 9144000, 'cy' => 5143500],
|
||||
self::LAYOUT_35MM => ['cx' => 10287000, 'cy' => 6858000],
|
||||
self::LAYOUT_A3 => ['cx' => 15120000, 'cy' => 10692000],
|
||||
self::LAYOUT_A4 => ['cx' => 10692000, 'cy' => 7560000],
|
||||
self::LAYOUT_B4ISO => ['cx' => 10826750, 'cy' => 8120063],
|
||||
self::LAYOUT_B5ISO => ['cx' => 7169150, 'cy' => 5376863],
|
||||
self::LAYOUT_BANNER => ['cx' => 7315200, 'cy' => 914400],
|
||||
self::LAYOUT_LETTER => ['cx' => 9144000, 'cy' => 6858000],
|
||||
self::LAYOUT_OVERHEAD => ['cx' => 9144000, 'cy' => 6858000],
|
||||
];
|
||||
|
||||
/**
|
||||
* Layout name
|
||||
* Layout name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $layout;
|
||||
|
||||
/**
|
||||
* Layout X dimension
|
||||
* Layout X dimension.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $dimensionX;
|
||||
|
||||
/**
|
||||
* Layout Y dimension
|
||||
* Layout Y dimension.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $dimensionY;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\DocumentLayout
|
||||
* Create a new \PhpOffice\PhpPresentation\DocumentLayout.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -94,23 +101,20 @@ class DocumentLayout
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout
|
||||
*
|
||||
* @return string
|
||||
* Get Document Layout.
|
||||
*/
|
||||
public function getDocumentLayout()
|
||||
public function getDocumentLayout(): string
|
||||
{
|
||||
return $this->layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Document Layout
|
||||
* Set Document Layout.
|
||||
*
|
||||
* @param array|string $pValue
|
||||
* @param boolean $isLandscape
|
||||
* @return \PhpOffice\PhpPresentation\DocumentLayout
|
||||
* @param array<string, int>|string $pValue
|
||||
* @param bool $isLandscape
|
||||
*/
|
||||
public function setDocumentLayout($pValue = self::LAYOUT_SCREEN_4X3, $isLandscape = true)
|
||||
public function setDocumentLayout($pValue = self::LAYOUT_SCREEN_4X3, $isLandscape = true): self
|
||||
{
|
||||
switch ($pValue) {
|
||||
case self::LAYOUT_SCREEN_4X3:
|
||||
|
|
@ -146,63 +150,47 @@ class DocumentLayout
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout cx
|
||||
*
|
||||
* @param string $unit
|
||||
* @return integer
|
||||
* Get Document Layout cx.
|
||||
*/
|
||||
public function getCX($unit = self::UNIT_EMU)
|
||||
public function getCX(string $unit = self::UNIT_EMU): float
|
||||
{
|
||||
return $this->convertUnit($this->dimensionX, self::UNIT_EMU, $unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout cy
|
||||
*
|
||||
* @param string $unit
|
||||
* @return integer
|
||||
* Get Document Layout cy.
|
||||
*/
|
||||
public function getCY($unit = self::UNIT_EMU)
|
||||
public function getCY(string $unit = self::UNIT_EMU): float
|
||||
{
|
||||
return $this->convertUnit($this->dimensionY, self::UNIT_EMU, $unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout cx
|
||||
*
|
||||
* @param float $value
|
||||
* @param string $unit
|
||||
* @return DocumentLayout
|
||||
* Get Document Layout cx.
|
||||
*/
|
||||
public function setCX($value, $unit = self::UNIT_EMU)
|
||||
public function setCX(float $value, string $unit = self::UNIT_EMU): self
|
||||
{
|
||||
$this->layout = self::LAYOUT_CUSTOM;
|
||||
$this->dimensionX = $this->convertUnit($value, $unit, self::UNIT_EMU);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document Layout cy
|
||||
*
|
||||
* @param float $value
|
||||
* @param string $unit
|
||||
* @return DocumentLayout
|
||||
* Get Document Layout cy.
|
||||
*/
|
||||
public function setCY($value, $unit = self::UNIT_EMU)
|
||||
public function setCY(float $value, string $unit = self::UNIT_EMU): self
|
||||
{
|
||||
$this->layout = self::LAYOUT_CUSTOM;
|
||||
$this->dimensionY = $this->convertUnit($value, $unit, self::UNIT_EMU);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EMUs to differents units
|
||||
* @param float $value
|
||||
* @param string $fromUnit
|
||||
* @param string $toUnit
|
||||
* @return float
|
||||
* Convert EMUs to differents units.
|
||||
*/
|
||||
protected function convertUnit($value, $fromUnit, $toUnit)
|
||||
protected function convertUnit(float $value, string $fromUnit, string $toUnit): float
|
||||
{
|
||||
// Convert from $fromUnit to EMU
|
||||
switch ($fromUnit) {
|
||||
|
|
@ -238,7 +226,7 @@ class DocumentLayout
|
|||
$value /= 914400;
|
||||
break;
|
||||
case self::UNIT_PIXEL:
|
||||
$value = Drawing::emuToPixels($value);
|
||||
$value = Drawing::emuToPixels((int) $value);
|
||||
break;
|
||||
case self::UNIT_POINT:
|
||||
$value /= 12700;
|
||||
|
|
@ -247,6 +235,7 @@ class DocumentLayout
|
|||
default:
|
||||
// no changes
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
222
PhpOffice/PhpPresentation/DocumentProperties.php
Executable file → Normal file
222
PhpOffice/PhpPresentation/DocumentProperties.php
Executable file → Normal file
|
|
@ -10,108 +10,125 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\DocumentProperties
|
||||
* \PhpOffice\PhpPresentation\DocumentProperties.
|
||||
*/
|
||||
class DocumentProperties
|
||||
{
|
||||
public const PROPERTY_TYPE_BOOLEAN = 'b';
|
||||
public const PROPERTY_TYPE_INTEGER = 'i';
|
||||
public const PROPERTY_TYPE_FLOAT = 'f';
|
||||
public const PROPERTY_TYPE_DATE = 'd';
|
||||
public const PROPERTY_TYPE_STRING = 's';
|
||||
public const PROPERTY_TYPE_UNKNOWN = 'u';
|
||||
|
||||
/**
|
||||
* Creator
|
||||
* Creator.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $creator;
|
||||
|
||||
/**
|
||||
* LastModifiedBy
|
||||
* LastModifiedBy.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $lastModifiedBy;
|
||||
|
||||
/**
|
||||
* Created
|
||||
* Created.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $created;
|
||||
|
||||
/**
|
||||
* Modified
|
||||
* Modified.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $modified;
|
||||
|
||||
/**
|
||||
* Title
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* Description
|
||||
* Description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* Subject
|
||||
* Subject.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $subject;
|
||||
|
||||
/**
|
||||
* Keywords
|
||||
* Keywords.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $keywords;
|
||||
|
||||
/**
|
||||
* Category
|
||||
* Category.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $category;
|
||||
|
||||
/**
|
||||
* Company
|
||||
* Company.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $company;
|
||||
|
||||
/**
|
||||
* Custom Properties.
|
||||
*
|
||||
* @var array<string, array<string, mixed>>
|
||||
*/
|
||||
private $customProperties = [];
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->creator = 'Unknown Creator';
|
||||
$this->creator = 'Unknown Creator';
|
||||
$this->lastModifiedBy = $this->creator;
|
||||
$this->created = time();
|
||||
$this->modified = time();
|
||||
$this->title = "Untitled Presentation";
|
||||
$this->subject = '';
|
||||
$this->description = '';
|
||||
$this->keywords = '';
|
||||
$this->category = '';
|
||||
$this->company = 'Microsoft Corporation';
|
||||
$this->created = time();
|
||||
$this->modified = time();
|
||||
$this->title = 'Untitled Presentation';
|
||||
$this->subject = '';
|
||||
$this->description = '';
|
||||
$this->keywords = '';
|
||||
$this->category = '';
|
||||
$this->company = 'Microsoft Corporation';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Creator
|
||||
* Get Creator.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -121,9 +138,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Creator
|
||||
* Set Creator.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setCreator($pValue = '')
|
||||
|
|
@ -134,7 +152,7 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Last Modified By
|
||||
* Get Last Modified By.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -144,9 +162,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Last Modified By
|
||||
* Set Last Modified By.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setLastModifiedBy($pValue = '')
|
||||
|
|
@ -157,7 +176,7 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Created
|
||||
* Get Created.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -167,9 +186,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Created
|
||||
* Set Created.
|
||||
*
|
||||
* @param int $pValue
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setCreated($pValue = null)
|
||||
|
|
@ -183,7 +203,7 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Modified
|
||||
* Get Modified.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -193,9 +213,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Modified
|
||||
* Set Modified.
|
||||
*
|
||||
* @param int $pValue
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setModified($pValue = null)
|
||||
|
|
@ -209,7 +230,7 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
* Get Title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -219,9 +240,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
* Set Title.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setTitle($pValue = '')
|
||||
|
|
@ -232,7 +254,7 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
* Get Description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -242,9 +264,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
* Set Description.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setDescription($pValue = '')
|
||||
|
|
@ -255,7 +278,7 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Subject
|
||||
* Get Subject.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -265,9 +288,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Subject
|
||||
* Set Subject.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setSubject($pValue = '')
|
||||
|
|
@ -278,7 +302,7 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Keywords
|
||||
* Get Keywords.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -288,9 +312,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Keywords
|
||||
* Set Keywords.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setKeywords($pValue = '')
|
||||
|
|
@ -301,7 +326,7 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Category
|
||||
* Get Category.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -311,9 +336,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Category
|
||||
* Set Category.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setCategory($pValue = '')
|
||||
|
|
@ -324,7 +350,7 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Company
|
||||
* Get Company.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -334,9 +360,10 @@ class DocumentProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Company
|
||||
* Set Company.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function setCompany($pValue = '')
|
||||
|
|
@ -345,4 +372,99 @@ class DocumentProperties
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List of Custom Property Names.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function getCustomProperties(): array
|
||||
{
|
||||
return array_keys($this->customProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Custom Property is defined.
|
||||
*
|
||||
* @param string $propertyName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCustomPropertySet(string $propertyName): bool
|
||||
{
|
||||
return isset($this->customProperties[$propertyName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Custom Property Value.
|
||||
*
|
||||
* @param string $propertyName
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getCustomPropertyValue(string $propertyName)
|
||||
{
|
||||
if ($this->isCustomPropertySet($propertyName)) {
|
||||
return $this->customProperties[$propertyName]['value'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Custom Property Type.
|
||||
*
|
||||
* @param string $propertyName
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCustomPropertyType(string $propertyName): ?string
|
||||
{
|
||||
if ($this->isCustomPropertySet($propertyName)) {
|
||||
return $this->customProperties[$propertyName]['type'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a Custom Property.
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @param mixed $propertyValue
|
||||
* @param string|null $propertyType
|
||||
* 'i' : Integer
|
||||
* 'f' : Floating Point
|
||||
* 's' : String
|
||||
* 'd' : Date/Time
|
||||
* 'b' : Boolean
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setCustomProperty(string $propertyName, $propertyValue = '', ?string $propertyType = null): self
|
||||
{
|
||||
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)) {
|
||||
$propertyType = self::PROPERTY_TYPE_FLOAT;
|
||||
} elseif (is_int($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_INTEGER;
|
||||
} elseif (is_bool($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
|
||||
} else {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
}
|
||||
}
|
||||
$this->customProperties[$propertyName] = [
|
||||
'value' => $propertyValue,
|
||||
'type' => $propertyType,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class DirectoryNotFoundException extends PhpPresentationException
|
||||
{
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'The directory %s doesn\'t exist',
|
||||
$path
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class FeatureNotImplementedException extends PhpPresentationException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The feature is not implemented. Please create an issue.');
|
||||
}
|
||||
}
|
||||
33
PhpOffice/PhpPresentation/Exception/FileCopyException.php
Normal file
33
PhpOffice/PhpPresentation/Exception/FileCopyException.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class FileCopyException extends PhpPresentationException
|
||||
{
|
||||
public function __construct(string $source, string $destination)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'The file %s can\'t be copied to %s',
|
||||
$source,
|
||||
$destination
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class FileNotFoundException extends PhpPresentationException
|
||||
{
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'The file "%s" doesn\'t exist',
|
||||
$path
|
||||
));
|
||||
}
|
||||
}
|
||||
32
PhpOffice/PhpPresentation/Exception/FileRemoveException.php
Normal file
32
PhpOffice/PhpPresentation/Exception/FileRemoveException.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class FileRemoveException extends PhpPresentationException
|
||||
{
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'The file %s can\'t be removed',
|
||||
$path
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class InvalidClassException extends PhpPresentationException
|
||||
{
|
||||
public function __construct(string $class, string $error)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'The class %s is invalid (%s)',
|
||||
$class,
|
||||
$error
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class InvalidFileFormatException extends PhpPresentationException
|
||||
{
|
||||
public function __construct(string $path, string $class, string $error = '')
|
||||
{
|
||||
if ($class) {
|
||||
$class = 'class ' . $class;
|
||||
}
|
||||
if ($error) {
|
||||
$error = '(' . $error . ')';
|
||||
}
|
||||
|
||||
parent::__construct(sprintf(
|
||||
'The file %s is not in the format supported by %s%s%s',
|
||||
$path,
|
||||
$class,
|
||||
!empty($error) ? ' ' : '',
|
||||
$error
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class InvalidParameterException extends PhpPresentationException
|
||||
{
|
||||
public function __construct(string $parameter, string $value)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'The parameter %s can\'t have the value "%s"',
|
||||
$parameter,
|
||||
$value
|
||||
));
|
||||
}
|
||||
}
|
||||
34
PhpOffice/PhpPresentation/Exception/OutOfBoundsException.php
Normal file
34
PhpOffice/PhpPresentation/Exception/OutOfBoundsException.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class OutOfBoundsException extends PhpPresentationException
|
||||
{
|
||||
public function __construct(int $minBounds, ?int $maxBounds, int $expectedBounds)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'The expected value (%d) is out of bounds (%d, %s)',
|
||||
$expectedBounds,
|
||||
$minBounds,
|
||||
$maxBounds ?? 'Infinite'
|
||||
));
|
||||
}
|
||||
}
|
||||
15
PhpOffice/PhpPresentation/Shape/Drawing.php → PhpOffice/PhpPresentation/Exception/PhpPresentationException.php
Executable file → Normal file
15
PhpOffice/PhpPresentation/Shape/Drawing.php → PhpOffice/PhpPresentation/Exception/PhpPresentationException.php
Executable file → Normal file
|
|
@ -10,19 +10,18 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\File;
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
/**
|
||||
* Drawing element
|
||||
* @deprecated Drawing\File
|
||||
*/
|
||||
class Drawing extends File
|
||||
use Exception;
|
||||
|
||||
class PhpPresentationException extends Exception
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class ShapeContainerAlreadyAssignedException extends PhpPresentationException
|
||||
{
|
||||
public function __construct(string $class)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'The shape %s has already a container assigned',
|
||||
$class
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
class UnauthorizedMimetypeException extends PhpPresentationException
|
||||
{
|
||||
/**
|
||||
* @param string $expectedMimetype
|
||||
* @param array<string> $authorizedMimetypes
|
||||
*/
|
||||
public function __construct(string $expectedMimetype, array $authorizedMimetypes)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'The mime type %s is not found in autorized values (%s)',
|
||||
$expectedMimetype,
|
||||
implode(', ', $authorizedMimetypes)
|
||||
));
|
||||
}
|
||||
}
|
||||
17
PhpOffice/PhpPresentation/Shape/MemoryDrawing.php → PhpOffice/PhpPresentation/Exception/UndefinedChartTypeException.php
Executable file → Normal file
17
PhpOffice/PhpPresentation/Shape/MemoryDrawing.php → PhpOffice/PhpPresentation/Exception/UndefinedChartTypeException.php
Executable file → Normal file
|
|
@ -10,19 +10,20 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\Gd;
|
||||
namespace PhpOffice\PhpPresentation\Exception;
|
||||
|
||||
/**
|
||||
* Memory drawing shape
|
||||
* @deprecated Drawing\Gd
|
||||
*/
|
||||
class MemoryDrawing extends Gd
|
||||
class UndefinedChartTypeException extends PhpPresentationException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The chart type has not been defined');
|
||||
}
|
||||
}
|
||||
58
PhpOffice/PhpPresentation/GeometryCalculator.php
Executable file → Normal file
58
PhpOffice/PhpPresentation/GeometryCalculator.php
Executable file → Normal file
|
|
@ -10,40 +10,42 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* PhpOffice\PhpPresentation\GeometryCalculator
|
||||
* PhpOffice\PhpPresentation\GeometryCalculator.
|
||||
*/
|
||||
class GeometryCalculator
|
||||
{
|
||||
const X = 'X';
|
||||
const Y = 'Y';
|
||||
public const X = 'X';
|
||||
public const Y = 'Y';
|
||||
|
||||
/**
|
||||
* Calculate X and Y offsets for a set of shapes within a container such as a slide or group.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ShapeContainerInterface $container
|
||||
* @return array
|
||||
*/
|
||||
public static function calculateOffsets(ShapeContainerInterface $container)
|
||||
* Calculate X and Y offsets for a set of shapes within a container such as a slide or group.
|
||||
*
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public static function calculateOffsets(ShapeContainerInterface $container): array
|
||||
{
|
||||
$offsets = array(self::X => 0, self::Y => 0);
|
||||
$offsets = [self::X => 0, self::Y => 0];
|
||||
|
||||
if ($container !== null && count($container->getShapeCollection()) != 0) {
|
||||
if (null !== $container && 0 != count($container->getShapeCollection())) {
|
||||
$shapes = $container->getShapeCollection();
|
||||
if ($shapes[0] !== null) {
|
||||
if (null !== $shapes[0]) {
|
||||
$offsets[self::X] = $shapes[0]->getOffsetX();
|
||||
$offsets[self::Y] = $shapes[0]->getOffsetY();
|
||||
}
|
||||
|
||||
foreach ($shapes as $shape) {
|
||||
if ($shape !== null) {
|
||||
if (null !== $shape) {
|
||||
if ($shape->getOffsetX() < $offsets[self::X]) {
|
||||
$offsets[self::X] = $shape->getOffsetX();
|
||||
}
|
||||
|
|
@ -59,26 +61,26 @@ class GeometryCalculator
|
|||
}
|
||||
|
||||
/**
|
||||
* Calculate X and Y extents for a set of shapes within a container such as a slide or group.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ShapeContainerInterface $container
|
||||
* @return array
|
||||
*/
|
||||
public static function calculateExtents(ShapeContainerInterface $container)
|
||||
* Calculate X and Y extents for a set of shapes within a container such as a slide or group.
|
||||
*
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public static function calculateExtents(ShapeContainerInterface $container): array
|
||||
{
|
||||
$extents = array(self::X => 0, self::Y => 0);
|
||||
/** @var array<string, int> $extents */
|
||||
$extents = [self::X => 0, self::Y => 0];
|
||||
|
||||
if ($container !== null && count($container->getShapeCollection()) != 0) {
|
||||
if (null !== $container && 0 != count($container->getShapeCollection())) {
|
||||
$shapes = $container->getShapeCollection();
|
||||
if ($shapes[0] !== null) {
|
||||
$extents[self::X] = $shapes[0]->getOffsetX() + $shapes[0]->getWidth();
|
||||
$extents[self::Y] = $shapes[0]->getOffsetY() + $shapes[0]->getHeight();
|
||||
if (null !== $shapes[0]) {
|
||||
$extents[self::X] = (int) ($shapes[0]->getOffsetX() + $shapes[0]->getWidth());
|
||||
$extents[self::Y] = (int) ($shapes[0]->getOffsetY() + $shapes[0]->getHeight());
|
||||
}
|
||||
|
||||
foreach ($shapes as $shape) {
|
||||
if ($shape !== null) {
|
||||
$extentX = $shape->getOffsetX() + $shape->getWidth();
|
||||
$extentY = $shape->getOffsetY() + $shape->getHeight();
|
||||
if (null !== $shape) {
|
||||
$extentX = (int) ($shape->getOffsetX() + $shape->getWidth());
|
||||
$extentY = (int) ($shape->getOffsetY() + $shape->getHeight());
|
||||
|
||||
if ($extentX > $extents[self::X]) {
|
||||
$extents[self::X] = $extentX;
|
||||
|
|
|
|||
115
PhpOffice/PhpPresentation/HashTable.php
Executable file → Normal file
115
PhpOffice/PhpPresentation/HashTable.php
Executable file → Normal file
|
|
@ -10,88 +10,76 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\HashTable
|
||||
* \PhpOffice\PhpPresentation\HashTable.
|
||||
*/
|
||||
class HashTable
|
||||
{
|
||||
/**
|
||||
* HashTable elements
|
||||
* HashTable elements.
|
||||
*
|
||||
* @var array
|
||||
* @var array<string, ComparableInterface>
|
||||
*/
|
||||
public $items = array();
|
||||
public $items = [];
|
||||
|
||||
/**
|
||||
* HashTable key map
|
||||
* HashTable key map.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public $keyMap = array();
|
||||
public $keyMap = [];
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\HashTable
|
||||
* Create a new \PhpOffice\PhpPresentation\HashTable.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ComparableInterface[] $pSource Optional source array to create HashTable from
|
||||
* @throws \Exception
|
||||
* @param array<int, ComparableInterface> $pSource Optional source array to create HashTable from
|
||||
*/
|
||||
public function __construct(array $pSource = null)
|
||||
public function __construct(array $pSource = [])
|
||||
{
|
||||
if (!is_null($pSource)) {
|
||||
// Create HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable items from source
|
||||
* Add HashTable items from source.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ComparableInterface[] $pSource Source array to create HashTable from
|
||||
* @throws \Exception
|
||||
* @param array<int, ComparableInterface> $pSource Source array to create HashTable from
|
||||
*/
|
||||
public function addFromSource($pSource = null)
|
||||
public function addFromSource(array $pSource = []): void
|
||||
{
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
} elseif (!is_array($pSource)) {
|
||||
throw new \Exception('Invalid array parameter passed.');
|
||||
}
|
||||
|
||||
foreach ($pSource as $item) {
|
||||
$this->add($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable item
|
||||
* Add HashTable item.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ComparableInterface $pSource Item to add
|
||||
* @param ComparableInterface $pSource Item to add
|
||||
*/
|
||||
public function add(ComparableInterface $pSource)
|
||||
public function add(ComparableInterface $pSource): void
|
||||
{
|
||||
// Determine hashcode
|
||||
$hashIndex = $pSource->getHashIndex();
|
||||
$hashCode = $pSource->getHashCode();
|
||||
|
||||
if (is_null($hashIndex)) {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
} elseif (isset($this->keyMap[$hashIndex])) {
|
||||
if (isset($this->keyMap[$hashIndex])) {
|
||||
$hashCode = $this->keyMap[$hashIndex];
|
||||
}
|
||||
|
||||
// Add value
|
||||
if (!isset($this->items[$hashCode])) {
|
||||
$this->items[$hashCode] = $pSource;
|
||||
$index = count($this->items) - 1;
|
||||
$this->keyMap[$index] = $hashCode;
|
||||
$index = count($this->items) - 1;
|
||||
$this->keyMap[$index] = $hashCode;
|
||||
$pSource->setHashIndex($index);
|
||||
} else {
|
||||
$pSource->setHashIndex($this->items[$hashCode]->getHashIndex());
|
||||
|
|
@ -99,12 +87,11 @@ class HashTable
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove HashTable item
|
||||
* Remove HashTable item.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\ComparableInterface $pSource Item to remove
|
||||
* @throws \Exception
|
||||
* @param ComparableInterface $pSource Item to remove
|
||||
*/
|
||||
public function remove(ComparableInterface $pSource)
|
||||
public function remove(ComparableInterface $pSource): void
|
||||
{
|
||||
if (isset($this->items[$pSource->getHashCode()])) {
|
||||
unset($this->items[$pSource->getHashCode()]);
|
||||
|
|
@ -124,44 +111,38 @@ class HashTable
|
|||
}
|
||||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
* Clear HashTable.
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): void
|
||||
{
|
||||
$this->items = array();
|
||||
$this->keyMap = array();
|
||||
$this->items = [];
|
||||
$this->keyMap = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count
|
||||
*
|
||||
* @return int
|
||||
* Count.
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for hash code
|
||||
* Get index for hash code.
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
* @return int Index (-1 if not found)
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '')
|
||||
public function getIndexForHashCode(string $pHashCode = ''): int
|
||||
{
|
||||
return array_search($pHashCode, $this->keyMap);
|
||||
$index = array_search($pHashCode, $this->keyMap);
|
||||
|
||||
return false === $index ? -1 : $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return \PhpOffice\PhpPresentation\ComparableInterface
|
||||
*
|
||||
* Get by index.
|
||||
*/
|
||||
public function getByIndex($pIndex = 0)
|
||||
public function getByIndex(int $pIndex = 0): ?ComparableInterface
|
||||
{
|
||||
if (isset($this->keyMap[$pIndex])) {
|
||||
return $this->getByHashCode($this->keyMap[$pIndex]);
|
||||
|
|
@ -171,13 +152,9 @@ class HashTable
|
|||
}
|
||||
|
||||
/**
|
||||
* Get by hashcode
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return \PhpOffice\PhpPresentation\ComparableInterface
|
||||
*
|
||||
* Get by hashcode.
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '')
|
||||
public function getByHashCode(string $pHashCode = ''): ?ComparableInterface
|
||||
{
|
||||
if (isset($this->items[$pHashCode])) {
|
||||
return $this->items[$pHashCode];
|
||||
|
|
@ -187,11 +164,11 @@ class HashTable
|
|||
}
|
||||
|
||||
/**
|
||||
* HashTable to array
|
||||
* HashTable to array.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\ComparableInterface[]
|
||||
* @return array<ComparableInterface>
|
||||
*/
|
||||
public function toArray()
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
|
|
|||
90
PhpOffice/PhpPresentation/IOFactory.php
Executable file → Normal file
90
PhpOffice/PhpPresentation/IOFactory.php
Executable file → Normal file
|
|
@ -10,60 +10,61 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use PhpOffice\PhpPresentation\Exception\InvalidClassException;
|
||||
use PhpOffice\PhpPresentation\Exception\InvalidFileFormatException;
|
||||
use PhpOffice\PhpPresentation\Reader\ReaderInterface;
|
||||
use PhpOffice\PhpPresentation\Writer\WriterInterface;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* IOFactory
|
||||
* IOFactory.
|
||||
*/
|
||||
class IOFactory
|
||||
{
|
||||
/**
|
||||
* Autoresolve classes
|
||||
* Autoresolve classes.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private static $autoResolveClasses = array('Serialized', 'ODPresentation', 'PowerPoint97', 'PowerPoint2007');
|
||||
private static $autoResolveClasses = ['Serialized', 'ODPresentation', 'PowerPoint97', 'PowerPoint2007'];
|
||||
|
||||
/**
|
||||
* Create writer
|
||||
* Create writer.
|
||||
*
|
||||
* @param PhpPresentation $phpPresentation
|
||||
* @param string $name
|
||||
* @return \PhpOffice\PhpPresentation\Writer\WriterInterface
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function createWriter(PhpPresentation $phpPresentation, $name = 'PowerPoint2007')
|
||||
public static function createWriter(PhpPresentation $phpPresentation, string $name = 'PowerPoint2007'): WriterInterface
|
||||
{
|
||||
$class = 'PhpOffice\\PhpPresentation\\Writer\\' . $name;
|
||||
return self::loadClass($class, $name, 'writer', $phpPresentation);
|
||||
return self::loadClass('PhpOffice\\PhpPresentation\\Writer\\' . $name, 'Writer', $phpPresentation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create reader
|
||||
* Create reader.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \PhpOffice\PhpPresentation\Reader\ReaderInterface
|
||||
* @throws \Exception
|
||||
* @param string $name
|
||||
*/
|
||||
public static function createReader($name = '')
|
||||
public static function createReader(string $name): ReaderInterface
|
||||
{
|
||||
$class = 'PhpOffice\\PhpPresentation\\Reader\\' . $name;
|
||||
return self::loadClass($class, $name, 'reader');
|
||||
return self::loadClass('PhpOffice\\PhpPresentation\\Reader\\' . $name, 'Reader');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PhpPresentation from file using automatic \PhpOffice\PhpPresentation\Reader\ReaderInterface resolution
|
||||
* Loads PhpPresentation from file using automatic ReaderInterface resolution.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PhpPresentation
|
||||
* @throws \Exception
|
||||
* @throws InvalidFileFormatException
|
||||
*/
|
||||
public static function load($pFilename)
|
||||
public static function load(string $pFilename): PhpPresentation
|
||||
{
|
||||
// Try loading using self::$autoResolveClasses
|
||||
foreach (self::$autoResolveClasses as $autoResolveClass) {
|
||||
|
|
@ -73,42 +74,45 @@ class IOFactory
|
|||
}
|
||||
}
|
||||
|
||||
throw new \Exception("Could not automatically determine \PhpOffice\PhpPresentation\Reader\ReaderInterface for file.");
|
||||
throw new InvalidFileFormatException(
|
||||
$pFilename,
|
||||
IOFactory::class,
|
||||
'Could not automatically determine the good ' . ReaderInterface::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load class
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @param \PhpOffice\PhpPresentation\PhpPresentation $phpPresentation
|
||||
* @return mixed
|
||||
* @throws \ReflectionException
|
||||
* @param PhpPresentation|null $phpPresentation
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @throws InvalidClassException
|
||||
*/
|
||||
private static function loadClass($class, $name, $type, PhpPresentation $phpPresentation = null)
|
||||
private static function loadClass(string $class, string $type, PhpPresentation $phpPresentation = null)
|
||||
{
|
||||
if (class_exists($class) && self::isConcreteClass($class)) {
|
||||
if (is_null($phpPresentation)) {
|
||||
return new $class();
|
||||
} else {
|
||||
return new $class($phpPresentation);
|
||||
}
|
||||
} else {
|
||||
throw new \Exception('"'.$name.'" is not a valid '.$type.'.');
|
||||
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)) {
|
||||
return new $class();
|
||||
}
|
||||
|
||||
return new $class($phpPresentation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is it a concrete class?
|
||||
*
|
||||
* @param string $class
|
||||
* @return bool
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
private static function isConcreteClass($class)
|
||||
private static function isConcreteClass(string $class): bool
|
||||
{
|
||||
$reflection = new \ReflectionClass($class);
|
||||
$reflection = new ReflectionClass($class);
|
||||
|
||||
return !$reflection->isAbstract() && !$reflection->isInterface();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
PHPPresentation, a pure PHP library for writing presentations files.
|
||||
|
||||
Copyright (c) 2010-2015 PHPPresentation.
|
||||
|
||||
PHPPresentation is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 3 as published by
|
||||
the Free Software Foundation.
|
||||
|
||||
PHPPresentation is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License version 3 for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License version 3
|
||||
along with PHPPresentation. If not, see <http://www.gnu.org/licenses/>.
|
||||
280
PhpOffice/PhpPresentation/PhpPresentation.php
Executable file → Normal file
280
PhpOffice/PhpPresentation/PhpPresentation.php
Executable file → Normal file
|
|
@ -10,65 +10,70 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use PhpOffice\PhpPresentation\Slide;
|
||||
use ArrayObject;
|
||||
use PhpOffice\PhpPresentation\Exception\OutOfBoundsException;
|
||||
use PhpOffice\PhpPresentation\Slide\Iterator;
|
||||
use PhpOffice\PhpPresentation\Slide\SlideMaster;
|
||||
|
||||
/**
|
||||
* PhpPresentation
|
||||
* PhpPresentation.
|
||||
*/
|
||||
class PhpPresentation
|
||||
{
|
||||
/**
|
||||
* Document properties
|
||||
* Document properties.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\DocumentProperties
|
||||
* @var DocumentProperties
|
||||
*/
|
||||
protected $documentProperties;
|
||||
|
||||
/**
|
||||
* Presentation properties
|
||||
* Presentation properties.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\PresentationProperties
|
||||
* @var PresentationProperties
|
||||
*/
|
||||
protected $presentationProps;
|
||||
|
||||
/**
|
||||
* Document layout
|
||||
* Document layout.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\DocumentLayout
|
||||
* @var DocumentLayout
|
||||
*/
|
||||
protected $layout;
|
||||
|
||||
/**
|
||||
* Collection of Slide objects
|
||||
* Collection of Slide objects.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Slide[]
|
||||
* @var array<int, Slide>
|
||||
*/
|
||||
protected $slideCollection = array();
|
||||
protected $slideCollection = [];
|
||||
|
||||
/**
|
||||
* Active slide index
|
||||
* Active slide index.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $activeSlideIndex = 0;
|
||||
|
||||
/**
|
||||
* Collection of Master Slides
|
||||
* @var \ArrayObject|\PhpOffice\PhpPresentation\Slide\SlideMaster[]
|
||||
* Collection of Master Slides.
|
||||
*
|
||||
* @var array<int, SlideMaster>|ArrayObject<int, SlideMaster>
|
||||
*/
|
||||
protected $slideMasters;
|
||||
|
||||
/**
|
||||
* Create a new PhpPresentation with one Slide
|
||||
* Create a new PhpPresentation with one Slide.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -86,45 +91,17 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* Get properties
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
* @deprecated for getDocumentProperties
|
||||
* Get properties.
|
||||
*/
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->getDocumentProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set properties
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\DocumentProperties $value
|
||||
* @deprecated for setDocumentProperties
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
public function setProperties(DocumentProperties $value)
|
||||
{
|
||||
return $this->setDocumentProperties($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\DocumentProperties
|
||||
*/
|
||||
public function getDocumentProperties()
|
||||
public function getDocumentProperties(): DocumentProperties
|
||||
{
|
||||
return $this->documentProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set properties
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\DocumentProperties $value
|
||||
* @return PhpPresentation
|
||||
* Set properties.
|
||||
*/
|
||||
public function setDocumentProperties(DocumentProperties $value)
|
||||
public function setDocumentProperties(DocumentProperties $value): self
|
||||
{
|
||||
$this->documentProperties = $value;
|
||||
|
||||
|
|
@ -132,44 +109,37 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* Get presentation properties
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\PresentationProperties
|
||||
* Get presentation properties.
|
||||
*/
|
||||
public function getPresentationProperties()
|
||||
public function getPresentationProperties(): PresentationProperties
|
||||
{
|
||||
return $this->presentationProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set presentation properties
|
||||
* Set presentation properties.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\PresentationProperties $value
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
public function setPresentationProperties(PresentationProperties $value)
|
||||
public function setPresentationProperties(PresentationProperties $value): self
|
||||
{
|
||||
$this->presentationProps = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get layout
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\DocumentLayout
|
||||
* Get layout.
|
||||
*/
|
||||
public function getLayout()
|
||||
public function getLayout(): DocumentLayout
|
||||
{
|
||||
return $this->layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set layout
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\DocumentLayout $value
|
||||
* @return PhpPresentation
|
||||
* Set layout.
|
||||
*/
|
||||
public function setLayout(DocumentLayout $value)
|
||||
public function setLayout(DocumentLayout $value): self
|
||||
{
|
||||
$this->layout = $value;
|
||||
|
||||
|
|
@ -177,36 +147,28 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* Get active slide
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* Get active slide.
|
||||
*/
|
||||
public function getActiveSlide()
|
||||
public function getActiveSlide(): Slide
|
||||
{
|
||||
return $this->slideCollection[$this->activeSlideIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create slide and add it to this presentation
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* @throws \Exception
|
||||
* Create slide and add it to this presentation.
|
||||
*/
|
||||
public function createSlide()
|
||||
public function createSlide(): Slide
|
||||
{
|
||||
$newSlide = new Slide($this);
|
||||
$this->addSlide($newSlide);
|
||||
|
||||
return $newSlide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide $slide
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* Add slide.
|
||||
*/
|
||||
public function addSlide(Slide $slide = null)
|
||||
public function addSlide(Slide $slide): Slide
|
||||
{
|
||||
$this->slideCollection[] = $slide;
|
||||
|
||||
|
|
@ -214,16 +176,16 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove slide by index
|
||||
* Remove slide by index.
|
||||
*
|
||||
* @param int $index Slide index
|
||||
* @throws \Exception
|
||||
* @return PhpPresentation
|
||||
* @param int $index Slide index
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function removeSlideByIndex($index = 0)
|
||||
public function removeSlideByIndex(int $index = 0): self
|
||||
{
|
||||
if ($index > count($this->slideCollection) - 1) {
|
||||
throw new \Exception("Slide index is out of bounds.");
|
||||
throw new OutOfBoundsException(0, count($this->slideCollection) - 1, $index);
|
||||
}
|
||||
array_splice($this->slideCollection, $index, 1);
|
||||
|
||||
|
|
@ -231,80 +193,77 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* Get slide by index
|
||||
* Get slide by index.
|
||||
*
|
||||
* @param int $index Slide index
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* @throws \Exception
|
||||
* @param int $index Slide index
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function getSlide($index = 0)
|
||||
public function getSlide(int $index = 0): Slide
|
||||
{
|
||||
if ($index > count($this->slideCollection) - 1) {
|
||||
throw new \Exception("Slide index is out of bounds.");
|
||||
throw new OutOfBoundsException(0, count($this->slideCollection) - 1, $index);
|
||||
}
|
||||
|
||||
return $this->slideCollection[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all slides
|
||||
* Get all slides.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide[]
|
||||
* @return array<int, Slide>
|
||||
*/
|
||||
public function getAllSlides()
|
||||
public function getAllSlides(): array
|
||||
{
|
||||
return $this->slideCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\AbstractSlide $slide
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
* Get index for slide.
|
||||
*/
|
||||
public function getIndex(Slide\AbstractSlide $slide)
|
||||
public function getIndex(Slide\AbstractSlide $slide): ?int
|
||||
{
|
||||
$index = null;
|
||||
if (empty($this->slideCollection)) {
|
||||
return null;
|
||||
}
|
||||
foreach ($this->slideCollection as $key => $value) {
|
||||
if ($value->getHashCode() == $slide->getHashCode()) {
|
||||
$index = $key;
|
||||
break;
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
return $index;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide count
|
||||
*
|
||||
* @return int
|
||||
* Get slide count.
|
||||
*/
|
||||
public function getSlideCount()
|
||||
public function getSlideCount(): int
|
||||
{
|
||||
return count($this->slideCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active slide index
|
||||
* Get active slide index.
|
||||
*
|
||||
* @return int Active slide index
|
||||
*/
|
||||
public function getActiveSlideIndex()
|
||||
public function getActiveSlideIndex(): int
|
||||
{
|
||||
return $this->activeSlideIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active slide index
|
||||
* Set active slide index.
|
||||
*
|
||||
* @param int $index Active slide index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* @param int $index Active slide index
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function setActiveSlideIndex($index = 0)
|
||||
public function setActiveSlideIndex(int $index = 0): Slide
|
||||
{
|
||||
if ($index > count($this->slideCollection) - 1) {
|
||||
throw new \Exception("Active slide index is out of bounds.");
|
||||
throw new OutOfBoundsException(0, count($this->slideCollection) - 1, $index);
|
||||
}
|
||||
$this->activeSlideIndex = $index;
|
||||
|
||||
|
|
@ -312,13 +271,11 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* Add external slide
|
||||
* Add external slide.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide $slide External slide to add
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* @param Slide $slide External slide to add
|
||||
*/
|
||||
public function addExternalSlide(Slide $slide)
|
||||
public function addExternalSlide(Slide $slide): Slide
|
||||
{
|
||||
$slide->rebindParent($this);
|
||||
|
||||
|
|
@ -328,36 +285,28 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* Get slide iterator
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\Iterator
|
||||
* Get slide iterator.
|
||||
*/
|
||||
public function getSlideIterator()
|
||||
public function getSlideIterator(): Iterator
|
||||
{
|
||||
return new Iterator($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a masterslide and add it to this presentation
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\SlideMaster
|
||||
* @throws \Exception
|
||||
* Create a masterslide and add it to this presentation.
|
||||
*/
|
||||
public function createMasterSlide()
|
||||
public function createMasterSlide(): SlideMaster
|
||||
{
|
||||
$newMasterSlide = new SlideMaster($this);
|
||||
$this->addMasterSlide($newMasterSlide);
|
||||
|
||||
return $newMasterSlide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add masterslide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\SlideMaster $slide
|
||||
* @return \PhpOffice\PhpPresentation\Slide\SlideMaster
|
||||
* @throws \Exception
|
||||
* Add masterslide.
|
||||
*/
|
||||
public function addMasterSlide(SlideMaster $slide = null)
|
||||
public function addMasterSlide(SlideMaster $slide): SlideMaster
|
||||
{
|
||||
$this->slideMasters[] = $slide;
|
||||
|
||||
|
|
@ -365,12 +314,9 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* Copy presentation (!= clone!)
|
||||
*
|
||||
* @return PhpPresentation
|
||||
* @throws \Exception
|
||||
* Copy presentation (!= clone!).
|
||||
*/
|
||||
public function copy()
|
||||
public function copy(): PhpPresentation
|
||||
{
|
||||
$copied = clone $this;
|
||||
|
||||
|
|
@ -384,49 +330,7 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* Mark a document as final
|
||||
* @param bool $state
|
||||
* @return PresentationProperties
|
||||
* @deprecated for getPresentationProperties()->markAsFinal()
|
||||
*/
|
||||
public function markAsFinal($state = true)
|
||||
{
|
||||
return $this->getPresentationProperties()->markAsFinal($state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if this document is marked as final
|
||||
* @return bool
|
||||
* @deprecated for getPresentationProperties()->isMarkedAsFinal()
|
||||
*/
|
||||
public function isMarkedAsFinal()
|
||||
{
|
||||
return $this->getPresentationProperties()->isMarkedAsFinal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zoom of the document (in percentage)
|
||||
* @param float $zoom
|
||||
* @return PresentationProperties
|
||||
* @deprecated for getPresentationProperties()->setZoom()
|
||||
*/
|
||||
public function setZoom($zoom = 1.0)
|
||||
{
|
||||
return $this->getPresentationProperties()->setZoom($zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the zoom (in percentage)
|
||||
* @return float
|
||||
* @deprecated for getPresentationProperties()->getZoom()
|
||||
*/
|
||||
public function getZoom()
|
||||
{
|
||||
return $this->getPresentationProperties()->getZoom();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ArrayObject|Slide\SlideMaster[]
|
||||
* @return array<int, Slide\SlideMaster>|ArrayObject<int, Slide\SlideMaster>
|
||||
*/
|
||||
public function getAllMasterSlides()
|
||||
{
|
||||
|
|
@ -434,14 +338,14 @@ class PhpPresentation
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \ArrayObject|Slide\SlideMaster[] $slideMasters
|
||||
* @return $this
|
||||
* @param array<int, Slide\SlideMaster>|ArrayObject<int, Slide\SlideMaster> $slideMasters
|
||||
*/
|
||||
public function setAllMasterSlides($slideMasters = array())
|
||||
public function setAllMasterSlides($slideMasters = []): self
|
||||
{
|
||||
if ($slideMasters instanceof \ArrayObject || is_array($slideMasters)) {
|
||||
if ($slideMasters instanceof ArrayObject || is_array($slideMasters)) {
|
||||
$this->slideMasters = $slideMasters;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
186
PhpOffice/PhpPresentation/PresentationProperties.php
Executable file → Normal file
186
PhpOffice/PhpPresentation/PresentationProperties.php
Executable file → Normal file
|
|
@ -10,27 +10,31 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\PresentationProperties
|
||||
*/
|
||||
class PresentationProperties
|
||||
{
|
||||
const VIEW_HANDOUT = 'handoutView';
|
||||
const VIEW_NOTES = 'notesView';
|
||||
const VIEW_NOTES_MASTER = 'notesMasterView';
|
||||
const VIEW_OUTLINE = 'outlineView';
|
||||
const VIEW_SLIDE = 'sldView';
|
||||
const VIEW_SLIDE_MASTER = 'sldMasterView';
|
||||
const VIEW_SLIDE_SORTER = 'sldSorterView';
|
||||
const VIEW_SLIDE_THUMBNAIL = 'sldThumbnailView';
|
||||
public const VIEW_HANDOUT = 'handoutView';
|
||||
public const VIEW_NOTES = 'notesView';
|
||||
public const VIEW_NOTES_MASTER = 'notesMasterView';
|
||||
public const VIEW_OUTLINE = 'outlineView';
|
||||
public const VIEW_SLIDE = 'sldView';
|
||||
public const VIEW_SLIDE_MASTER = 'sldMasterView';
|
||||
public const VIEW_SLIDE_SORTER = 'sldSorterView';
|
||||
public const VIEW_SLIDE_THUMBNAIL = 'sldThumbnailView';
|
||||
|
||||
protected $arrayView = array(
|
||||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $arrayView = [
|
||||
self::VIEW_HANDOUT,
|
||||
self::VIEW_NOTES,
|
||||
self::VIEW_NOTES_MASTER,
|
||||
|
|
@ -39,163 +43,189 @@ class PresentationProperties
|
|||
self::VIEW_SLIDE_MASTER,
|
||||
self::VIEW_SLIDE_SORTER,
|
||||
self::VIEW_SLIDE_THUMBNAIL,
|
||||
);
|
||||
];
|
||||
|
||||
/*
|
||||
* @var boolean
|
||||
public const SLIDESHOW_TYPE_PRESENT = 'present';
|
||||
public const SLIDESHOW_TYPE_BROWSE = 'browse';
|
||||
public const SLIDESHOW_TYPE_KIOSK = 'kiosk';
|
||||
|
||||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $arraySlideshowTypes = [
|
||||
self::SLIDESHOW_TYPE_PRESENT,
|
||||
self::SLIDESHOW_TYPE_BROWSE,
|
||||
self::SLIDESHOW_TYPE_KIOSK,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isLoopUntilEsc = false;
|
||||
|
||||
/**
|
||||
* Mark as final
|
||||
* Mark as final.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $markAsFinal = false;
|
||||
|
||||
/*
|
||||
* @var string
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $thumbnail;
|
||||
|
||||
/**
|
||||
* Zoom
|
||||
* Zoom.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $zoom = 1;
|
||||
protected $zoom = 1.0;
|
||||
|
||||
/*
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $lastView = self::VIEW_SLIDE;
|
||||
|
||||
/*
|
||||
* @var boolean
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $slideshowType = self::SLIDESHOW_TYPE_PRESENT;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isCommentVisible = false;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLoopContinuouslyUntilEsc()
|
||||
|
||||
public function isLoopContinuouslyUntilEsc(): bool
|
||||
{
|
||||
return $this->isLoopUntilEsc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
* @return \PhpOffice\PhpPresentation\PresentationProperties
|
||||
*/
|
||||
public function setLoopContinuouslyUntilEsc($value = false)
|
||||
|
||||
public function setLoopContinuouslyUntilEsc(bool $value = false): self
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->isLoopUntilEsc = $value;
|
||||
}
|
||||
$this->isLoopUntilEsc = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the thumbnail file path
|
||||
* @return string
|
||||
* Return the thumbnail file path.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getThumbnailPath()
|
||||
public function getThumbnailPath(): ?string
|
||||
{
|
||||
return $this->thumbnail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define the path for the thumbnail file / preview picture
|
||||
* Define the path for the thumbnail file / preview picture.
|
||||
*
|
||||
* @param string $path
|
||||
* @return \PhpOffice\PhpPresentation\PresentationProperties
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setThumbnailPath($path = '')
|
||||
public function setThumbnailPath(string $path = ''): self
|
||||
{
|
||||
if (file_exists($path)) {
|
||||
$this->thumbnail = $path;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a document as final
|
||||
* @param bool $state
|
||||
* @return PresentationProperties
|
||||
* Mark a document as final.
|
||||
*/
|
||||
public function markAsFinal($state = true)
|
||||
public function markAsFinal(bool $state = true): self
|
||||
{
|
||||
if (is_bool($state)) {
|
||||
$this->markAsFinal = $state;
|
||||
}
|
||||
$this->markAsFinal = $state;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if this document is marked as final
|
||||
* Return if this document is marked as final.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMarkedAsFinal()
|
||||
public function isMarkedAsFinal(): bool
|
||||
{
|
||||
return $this->markAsFinal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zoom of the document (in percentage)
|
||||
* @param float $zoom
|
||||
* @return PresentationProperties
|
||||
* Set the zoom of the document (in percentage).
|
||||
*/
|
||||
public function setZoom($zoom = 1.0)
|
||||
public function setZoom(float $zoom = 1.0): self
|
||||
{
|
||||
if (is_numeric($zoom)) {
|
||||
$this->zoom = (float)$zoom;
|
||||
}
|
||||
$this->zoom = $zoom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the zoom (in percentage)
|
||||
* @return float
|
||||
* Return the zoom (in percentage).
|
||||
*/
|
||||
public function getZoom()
|
||||
public function getZoom(): float
|
||||
{
|
||||
return $this->zoom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setLastView($value = self::VIEW_SLIDE)
|
||||
public function setLastView(string $value = self::VIEW_SLIDE): self
|
||||
{
|
||||
if (in_array($value, $this->arrayView)) {
|
||||
$this->lastView = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastView()
|
||||
public function getLastView(): string
|
||||
{
|
||||
return $this->lastView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setCommentVisible($value = false)
|
||||
public function setCommentVisible(bool $value = false): self
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->isCommentVisible = $value;
|
||||
}
|
||||
$this->isCommentVisible = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isCommentVisible(): bool
|
||||
{
|
||||
return $this->isCommentVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function isCommentVisible()
|
||||
public function getSlideshowType(): string
|
||||
{
|
||||
return $this->isCommentVisible;
|
||||
return $this->slideshowType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSlideshowType(string $value = self::SLIDESHOW_TYPE_PRESENT): self
|
||||
{
|
||||
if (in_array($value, $this->arraySlideshowTypes)) {
|
||||
$this->slideshowType = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
594
PhpOffice/PhpPresentation/Reader/ODPresentation.php
Executable file → Normal file
594
PhpOffice/PhpPresentation/Reader/ODPresentation.php
Executable file → Normal file
|
|
@ -10,64 +10,76 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Reader;
|
||||
|
||||
use ZipArchive;
|
||||
use PhpOffice\Common\XMLReader;
|
||||
use DateTime;
|
||||
use DOMElement;
|
||||
use PhpOffice\Common\Drawing as CommonDrawing;
|
||||
use PhpOffice\Common\XMLReader;
|
||||
use PhpOffice\PhpPresentation\DocumentProperties;
|
||||
use PhpOffice\PhpPresentation\Exception\FileNotFoundException;
|
||||
use PhpOffice\PhpPresentation\Exception\InvalidFileFormatException;
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
use PhpOffice\PhpPresentation\PresentationProperties;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\Base64;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\Gd;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
|
||||
use PhpOffice\PhpPresentation\Slide\Background\Image;
|
||||
use PhpOffice\PhpPresentation\Style\Alignment;
|
||||
use PhpOffice\PhpPresentation\Style\Bullet;
|
||||
use PhpOffice\PhpPresentation\Style\Color;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
use PhpOffice\PhpPresentation\Style\Shadow;
|
||||
use PhpOffice\PhpPresentation\Style\Alignment;
|
||||
use ZipArchive;
|
||||
|
||||
/**
|
||||
* Serialized format reader
|
||||
* Serialized format reader.
|
||||
*/
|
||||
class ODPresentation implements ReaderInterface
|
||||
{
|
||||
/**
|
||||
* Output Object
|
||||
* Output Object.
|
||||
*
|
||||
* @var PhpPresentation
|
||||
*/
|
||||
protected $oPhpPresentation;
|
||||
/**
|
||||
* Output Object
|
||||
* Output Object.
|
||||
*
|
||||
* @var \ZipArchive
|
||||
*/
|
||||
protected $oZip;
|
||||
/**
|
||||
* @var array[]
|
||||
* @var array<string, array{alignment: Alignment|null, background: null, shadow: Shadow|null, fill: Fill|null, spacingAfter: int|null, spacingBefore: int|null, lineSpacingMode: null, lineSpacing: null, font: null, listStyle: null}>
|
||||
*/
|
||||
protected $arrayStyles = array();
|
||||
protected $arrayStyles = [];
|
||||
/**
|
||||
* @var array[]
|
||||
* @var array<string, array<string, string|null>>
|
||||
*/
|
||||
protected $arrayCommonStyles = array();
|
||||
protected $arrayCommonStyles = [];
|
||||
/**
|
||||
* @var \PhpOffice\Common\XMLReader
|
||||
*/
|
||||
protected $oXMLReader;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $levelParagraph = 0;
|
||||
|
||||
/**
|
||||
* Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws \Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead(string $pFilename): bool
|
||||
{
|
||||
return $this->fileSupportsUnserializePhpPresentation($pFilename);
|
||||
}
|
||||
|
|
@ -75,83 +87,81 @@ class ODPresentation implements ReaderInterface
|
|||
/**
|
||||
* Does a file support UnserializePhpPresentation ?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws \Exception
|
||||
* @return boolean
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function fileSupportsUnserializePhpPresentation($pFilename = '')
|
||||
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new \Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new FileNotFoundException($pFilename);
|
||||
}
|
||||
|
||||
|
||||
$oZip = new ZipArchive();
|
||||
// Is it a zip ?
|
||||
if ($oZip->open($pFilename) === true) {
|
||||
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')) && $oZip->getFromName('mimetype') == 'application/vnd.oasis.opendocument.presentation') {
|
||||
if (is_array($oZip->statName('META-INF/manifest.xml')) && is_array($oZip->statName('mimetype')) && 'application/vnd.oasis.opendocument.presentation' == $oZip->getFromName('mimetype')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PhpPresentation Serialized file
|
||||
* Loads PhpPresentation Serialized file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
* @throws \Exception
|
||||
* @throws InvalidFileFormatException
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load(string $pFilename): PhpPresentation
|
||||
{
|
||||
// Unserialize... First make sure the file supports it!
|
||||
if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
|
||||
throw new \Exception("Invalid file format for PhpOffice\PhpPresentation\Reader\ODPresentation: " . $pFilename . ".");
|
||||
throw new InvalidFileFormatException($pFilename, ODPresentation::class);
|
||||
}
|
||||
|
||||
return $this->loadFile($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load PhpPresentation Serialized file
|
||||
* Load PhpPresentation Serialized file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
* @throws \Exception
|
||||
* @param string $pFilename
|
||||
*
|
||||
* @return PhpPresentation
|
||||
*/
|
||||
protected function loadFile($pFilename)
|
||||
{
|
||||
$this->oPhpPresentation = new PhpPresentation();
|
||||
$this->oPhpPresentation->removeSlideByIndex();
|
||||
|
||||
|
||||
$this->oZip = new ZipArchive();
|
||||
$this->oZip->open($pFilename);
|
||||
|
||||
|
||||
$this->oXMLReader = new XMLReader();
|
||||
if ($this->oXMLReader->getDomFromZip($pFilename, 'meta.xml') !== false) {
|
||||
if (false !== $this->oXMLReader->getDomFromZip($pFilename, 'meta.xml')) {
|
||||
$this->loadDocumentProperties();
|
||||
}
|
||||
$this->oXMLReader = new XMLReader();
|
||||
if ($this->oXMLReader->getDomFromZip($pFilename, 'styles.xml') !== false) {
|
||||
if (false !== $this->oXMLReader->getDomFromZip($pFilename, 'styles.xml')) {
|
||||
$this->loadStylesFile();
|
||||
}
|
||||
$this->oXMLReader = new XMLReader();
|
||||
if ($this->oXMLReader->getDomFromZip($pFilename, 'content.xml') !== false) {
|
||||
if (false !== $this->oXMLReader->getDomFromZip($pFilename, 'content.xml')) {
|
||||
$this->loadSlides();
|
||||
$this->loadPresentationProperties();
|
||||
}
|
||||
|
||||
return $this->oPhpPresentation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read Document Properties
|
||||
*/
|
||||
protected function loadDocumentProperties()
|
||||
protected function loadDocumentProperties(): void
|
||||
{
|
||||
$arrayProperties = array(
|
||||
$arrayProperties = [
|
||||
'/office:document-meta/office:meta/meta:initial-creator' => 'setCreator',
|
||||
'/office:document-meta/office:meta/dc:creator' => 'setLastModifiedBy',
|
||||
'/office:document-meta/office:meta/dc:title' => 'setTitle',
|
||||
|
|
@ -160,62 +170,99 @@ class ODPresentation implements ReaderInterface
|
|||
'/office:document-meta/office:meta/meta:keyword' => 'setKeywords',
|
||||
'/office:document-meta/office:meta/meta:creation-date' => 'setCreated',
|
||||
'/office:document-meta/office:meta/dc:date' => 'setModified',
|
||||
);
|
||||
$oProperties = $this->oPhpPresentation->getDocumentProperties();
|
||||
];
|
||||
$properties = $this->oPhpPresentation->getDocumentProperties();
|
||||
foreach ($arrayProperties as $path => $property) {
|
||||
$oElement = $this->oXMLReader->getElement($path);
|
||||
if ($oElement instanceof \DOMElement) {
|
||||
if (in_array($property, array('setCreated', 'setModified'))) {
|
||||
$oDateTime = new \DateTime();
|
||||
$oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
|
||||
$oProperties->{$property}($oDateTime->getTimestamp());
|
||||
} else {
|
||||
$oProperties->{$property}($oElement->nodeValue);
|
||||
if ($oElement instanceof DOMElement) {
|
||||
$value = $oElement->nodeValue;
|
||||
if (in_array($property, ['setCreated', 'setModified'])) {
|
||||
$dateTime = DateTime::createFromFormat(DateTime::W3C, $value);
|
||||
if (!$dateTime) {
|
||||
$dateTime = new DateTime();
|
||||
}
|
||||
$value = $dateTime->getTimestamp();
|
||||
}
|
||||
$properties->{$property}($value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->oXMLReader->getElements('/office:document-meta/office:meta/meta:user-defined') as $element) {
|
||||
if (!($element instanceof DOMElement)
|
||||
|| !$element->hasAttribute('meta:name')) {
|
||||
continue;
|
||||
}
|
||||
$propertyName = $element->getAttribute('meta:name');
|
||||
$propertyValue = (string) $element->nodeValue;
|
||||
$propertyType = $element->getAttribute('meta:value-type');
|
||||
switch ($propertyType) {
|
||||
case 'boolean':
|
||||
$propertyType = DocumentProperties::PROPERTY_TYPE_BOOLEAN;
|
||||
break;
|
||||
case 'float':
|
||||
$propertyType = filter_var($propertyValue, FILTER_VALIDATE_INT) === false
|
||||
? DocumentProperties::PROPERTY_TYPE_FLOAT
|
||||
: DocumentProperties::PROPERTY_TYPE_INTEGER;
|
||||
break;
|
||||
case 'date':
|
||||
$propertyType = DocumentProperties::PROPERTY_TYPE_DATE;
|
||||
break;
|
||||
case 'string':
|
||||
default:
|
||||
$propertyType = DocumentProperties::PROPERTY_TYPE_STRING;
|
||||
break;
|
||||
}
|
||||
$properties->setCustomProperty($propertyName, $propertyValue, $propertyType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract all slides
|
||||
*/
|
||||
protected function loadSlides()
|
||||
protected function loadSlides(): void
|
||||
{
|
||||
foreach ($this->oXMLReader->getElements('/office:document-content/office:automatic-styles/*') as $oElement) {
|
||||
if ($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->nodeName == 'draw:page') {
|
||||
if ($oElement instanceof DOMElement && 'draw:page' == $oElement->nodeName) {
|
||||
$this->loadSlide($oElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadPresentationProperties(): void
|
||||
{
|
||||
$element = $this->oXMLReader->getElement('/office:document-content/office:body/office:presentation/presentation:settings');
|
||||
if ($element instanceof DOMElement) {
|
||||
if ($element->getAttribute('presentation:full-screen') === 'false') {
|
||||
$this->oPhpPresentation->getPresentationProperties()->setSlideshowType(PresentationProperties::SLIDESHOW_TYPE_BROWSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract style
|
||||
* @param \DOMElement $nodeStyle
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadStyle(\DOMElement $nodeStyle)
|
||||
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') && $nodeDrawingPageProps->getAttribute('draw:fill') == 'solid') {
|
||||
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));
|
||||
$oBackground->setColor($oColor);
|
||||
}
|
||||
// Read Background Image
|
||||
if ($nodeDrawingPageProps->getAttribute('draw:fill') == 'bitmap' && $nodeDrawingPageProps->hasAttribute('draw:fill-image-name')) {
|
||||
if ('bitmap' == $nodeDrawingPageProps->getAttribute('draw:fill') && $nodeDrawingPageProps->hasAttribute('draw:fill-image-name')) {
|
||||
$nameStyle = $nodeDrawingPageProps->getAttribute('draw:fill-image-name');
|
||||
if (!empty($this->arrayCommonStyles[$nameStyle]) && $this->arrayCommonStyles[$nameStyle]['type'] == 'image' && !empty($this->arrayCommonStyles[$nameStyle]['path'])) {
|
||||
if (!empty($this->arrayCommonStyles[$nameStyle]) && 'image' == $this->arrayCommonStyles[$nameStyle]['type'] && !empty($this->arrayCommonStyles[$nameStyle]['path'])) {
|
||||
$tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderODPBkg');
|
||||
$contentImg = $this->oZip->getFromName($this->arrayCommonStyles[$nameStyle]['path']);
|
||||
file_put_contents($tmpBkgImg, $contentImg);
|
||||
|
|
@ -227,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') && $nodeGraphicProps->getAttribute('draw:shadow') == 'visible') {
|
||||
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));
|
||||
}
|
||||
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 = substr($nodeGraphicProps->getAttribute('draw:shadow-offset-x'), 0, -2);
|
||||
$offsetY = 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 ($offsetX != 0) {
|
||||
if (0 != $offsetX) {
|
||||
$distance = ($offsetX < 0 ? $offsetX * -1 : $offsetX);
|
||||
} elseif ($offsetY != 0) {
|
||||
} elseif (0 != $offsetY) {
|
||||
$distance = ($offsetY < 0 ? $offsetY * -1 : $offsetY);
|
||||
}
|
||||
$oShadow->setDirection(rad2deg(atan2($offsetY, $offsetX)));
|
||||
$oShadow->setDirection((int) rad2deg(atan2($offsetY, $offsetX)));
|
||||
$oShadow->setDistance(CommonDrawing::centimetersToPixels($distance));
|
||||
}
|
||||
}
|
||||
|
|
@ -272,91 +319,177 @@ 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));
|
||||
}
|
||||
// Font Latin
|
||||
if ($nodeTextProperties->hasAttribute('fo:font-family')) {
|
||||
$oFont->setName($nodeTextProperties->getAttribute('fo:font-family'));
|
||||
$oFont
|
||||
->setName($nodeTextProperties->getAttribute('fo:font-family'))
|
||||
->setFormat(Font::FORMAT_LATIN);
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('fo:font-weight') && $nodeTextProperties->getAttribute('fo:font-weight') == 'bold') {
|
||||
$oFont->setBold(true);
|
||||
if ($nodeTextProperties->hasAttribute('fo:font-weight') && 'bold' == $nodeTextProperties->getAttribute('fo:font-weight')) {
|
||||
$oFont
|
||||
->setBold(true)
|
||||
->setFormat(Font::FORMAT_LATIN);
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('fo:font-size')) {
|
||||
$oFont->setSize(substr($nodeTextProperties->getAttribute('fo:font-size'), 0, -2));
|
||||
$oFont
|
||||
->setSize((int) substr($nodeTextProperties->getAttribute('fo:font-size'), 0, -2))
|
||||
->setFormat(Font::FORMAT_LATIN);
|
||||
}
|
||||
// Font East Asian
|
||||
if ($nodeTextProperties->hasAttribute('style:font-family-asian')) {
|
||||
$oFont
|
||||
->setName($nodeTextProperties->getAttribute('style:font-family-asian'))
|
||||
->setFormat(Font::FORMAT_EAST_ASIAN);
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('style:font-weight-asian') && 'bold' == $nodeTextProperties->getAttribute('style:font-weight-asian')) {
|
||||
$oFont
|
||||
->setBold(true)
|
||||
->setFormat(Font::FORMAT_EAST_ASIAN);
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('style:font-size-asian')) {
|
||||
$oFont
|
||||
->setSize((int) substr($nodeTextProperties->getAttribute('style:font-size-asian'), 0, -2))
|
||||
->setFormat(Font::FORMAT_EAST_ASIAN);
|
||||
}
|
||||
// Font Complex Script
|
||||
if ($nodeTextProperties->hasAttribute('style:font-family-complex')) {
|
||||
$oFont
|
||||
->setName($nodeTextProperties->getAttribute('style:font-family-complex'))
|
||||
->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('style:font-weight-complex') && 'bold' == $nodeTextProperties->getAttribute('style:font-weight-complex')) {
|
||||
$oFont
|
||||
->setBold(true)
|
||||
->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('style:font-size-complex')) {
|
||||
$oFont
|
||||
->setSize((int) substr($nodeTextProperties->getAttribute('style:font-size-complex'), 0, -2))
|
||||
->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
|
||||
}
|
||||
if ($nodeTextProperties->hasAttribute('style:script-type')) {
|
||||
switch ($nodeTextProperties->getAttribute('style:script-type')) {
|
||||
case 'latin':
|
||||
$oFont->setFormat(Font::FORMAT_LATIN);
|
||||
break;
|
||||
case 'asian':
|
||||
$oFont->setFormat(Font::FORMAT_EAST_ASIAN);
|
||||
break;
|
||||
case 'complex':
|
||||
$oFont->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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 = CommonDrawing::centimetersToPoints($spacingAfter);
|
||||
}
|
||||
if ($nodeParagraphProps->hasAttribute('fo:margin-top')) {
|
||||
$spacingBefore = (float) substr($nodeParagraphProps->getAttribute('fo:margin-top'), 0, -2);
|
||||
$spacingBefore = CommonDrawing::centimetersToPoints($spacingBefore);
|
||||
}
|
||||
$oAlignment = new Alignment();
|
||||
if ($nodeParagraphProps->hasAttribute('fo:text-align')) {
|
||||
$oAlignment->setHorizontal($nodeParagraphProps->getAttribute('fo:text-align'));
|
||||
}
|
||||
if ($nodeParagraphProps->hasAttribute('style:writing-mode')) {
|
||||
switch ($nodeParagraphProps->getAttribute('style:writing-mode')) {
|
||||
case 'lr-tb':
|
||||
case 'tb-lr':
|
||||
case 'lr':
|
||||
$oAlignment->setIsRTL(false);
|
||||
break;
|
||||
case 'rl-tb':
|
||||
case 'tb-rl':
|
||||
case 'rl':
|
||||
$oAlignment->setIsRTL(false);
|
||||
break;
|
||||
case 'tb':
|
||||
case 'page':
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($nodeStyle->nodeName == 'text:list-style') {
|
||||
$arrayListStyle = array();
|
||||
|
||||
if ('text:list-style' == $nodeStyle->nodeName) {
|
||||
$arrayListStyle = [];
|
||||
foreach ($this->oXMLReader->getElements('text:list-level-style-bullet', $nodeStyle) as $oNodeListLevel) {
|
||||
$oAlignment = new Alignment();
|
||||
$oBullet = new Bullet();
|
||||
$oBullet->setBulletType(Bullet::TYPE_NONE);
|
||||
if ($oNodeListLevel->hasAttribute('text:level')) {
|
||||
$oAlignment->setLevel((int) $oNodeListLevel->getAttribute('text:level') - 1);
|
||||
}
|
||||
if ($oNodeListLevel->hasAttribute('text:bullet-char')) {
|
||||
$oBullet->setBulletChar($oNodeListLevel->getAttribute('text:bullet-char'));
|
||||
$oBullet->setBulletType(Bullet::TYPE_BULLET);
|
||||
}
|
||||
|
||||
$oNodeListProperties = $this->oXMLReader->getElement('style:list-level-properties', $oNodeListLevel);
|
||||
if ($oNodeListProperties instanceof \DOMElement) {
|
||||
if ($oNodeListProperties->hasAttribute('text:min-label-width')) {
|
||||
$oAlignment->setIndent((int)round(CommonDrawing::centimetersToPixels(substr($oNodeListProperties->getAttribute('text:min-label-width'), 0, -2))));
|
||||
if ($oNodeListLevel instanceof DOMElement) {
|
||||
if ($oNodeListLevel->hasAttribute('text:level')) {
|
||||
$oAlignment->setLevel((int) $oNodeListLevel->getAttribute('text:level') - 1);
|
||||
}
|
||||
if ($oNodeListProperties->hasAttribute('text:space-before')) {
|
||||
$iSpaceBefore = CommonDrawing::centimetersToPixels(substr($oNodeListProperties->getAttribute('text:space-before'), 0, -2));
|
||||
$iMarginLeft = $iSpaceBefore + $oAlignment->getIndent();
|
||||
$oAlignment->setMarginLeft($iMarginLeft);
|
||||
if ($oNodeListLevel->hasAttribute('text:bullet-char')) {
|
||||
$oBullet->setBulletChar($oNodeListLevel->getAttribute('text:bullet-char'));
|
||||
$oBullet->setBulletType(Bullet::TYPE_BULLET);
|
||||
}
|
||||
|
||||
$oNodeListProperties = $this->oXMLReader->getElement('style:list-level-properties', $oNodeListLevel);
|
||||
if ($oNodeListProperties instanceof DOMElement) {
|
||||
if ($oNodeListProperties->hasAttribute('text:min-label-width')) {
|
||||
$oAlignment->setIndent(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));
|
||||
$iMarginLeft = $iSpaceBefore + $oAlignment->getIndent();
|
||||
$oAlignment->setMarginLeft($iMarginLeft);
|
||||
}
|
||||
}
|
||||
|
||||
$oNodeTextProperties = $this->oXMLReader->getElement('style:text-properties', $oNodeListLevel);
|
||||
if ($oNodeTextProperties instanceof DOMElement) {
|
||||
if ($oNodeTextProperties->hasAttribute('fo:font-family')) {
|
||||
$oBullet->setBulletFont($oNodeTextProperties->getAttribute('fo:font-family'));
|
||||
}
|
||||
}
|
||||
}
|
||||
$oNodeTextProperties = $this->oXMLReader->getElement('style:text-properties', $oNodeListLevel);
|
||||
if ($oNodeTextProperties instanceof \DOMElement) {
|
||||
if ($oNodeTextProperties->hasAttribute('fo:font-family')) {
|
||||
$oBullet->setBulletFont($oNodeTextProperties->getAttribute('fo:font-family'));
|
||||
}
|
||||
}
|
||||
|
||||
$arrayListStyle[$oAlignment->getLevel()] = array(
|
||||
|
||||
$arrayListStyle[$oAlignment->getLevel()] = [
|
||||
'alignment' => $oAlignment,
|
||||
'bullet' => $oBullet,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$this->arrayStyles[$keyStyle] = array(
|
||||
'alignment' => isset($oAlignment) ? $oAlignment : null,
|
||||
'background' => isset($oBackground) ? $oBackground : null,
|
||||
'fill' => isset($oFill) ? $oFill : null,
|
||||
'font' => isset($oFont) ? $oFont : null,
|
||||
'shadow' => isset($oShadow) ? $oShadow : null,
|
||||
'listStyle' => isset($arrayListStyle) ? $arrayListStyle : null,
|
||||
);
|
||||
|
||||
|
||||
$this->arrayStyles[$keyStyle] = [
|
||||
'alignment' => $oAlignment ?? null,
|
||||
'background' => $oBackground ?? null,
|
||||
'fill' => $oFill ?? null,
|
||||
'font' => $oFont ?? null,
|
||||
'shadow' => $oShadow ?? null,
|
||||
'listStyle' => $arrayListStyle ?? null,
|
||||
'spacingAfter' => $spacingAfter ?? null,
|
||||
'spacingBefore' => $spacingBefore ?? null,
|
||||
'lineSpacingMode' => $lineSpacingMode ?? null,
|
||||
'lineSpacing' => $lineSpacing ?? null,
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Slide
|
||||
*
|
||||
* @param \DOMElement $nodeSlide
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadSlide(\DOMElement $nodeSlide)
|
||||
protected function loadSlide(DOMElement $nodeSlide): bool
|
||||
{
|
||||
// Core
|
||||
$this->oPhpPresentation->createSlide();
|
||||
|
|
@ -371,128 +504,151 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
}
|
||||
foreach ($this->oXMLReader->getElements('draw:frame', $nodeSlide) as $oNodeFrame) {
|
||||
if ($this->oXMLReader->getElement('draw:image', $oNodeFrame)) {
|
||||
$this->loadShapeDrawing($oNodeFrame);
|
||||
continue;
|
||||
}
|
||||
if ($this->oXMLReader->getElement('draw:text-box', $oNodeFrame)) {
|
||||
$this->loadShapeRichText($oNodeFrame);
|
||||
continue;
|
||||
if ($oNodeFrame instanceof DOMElement) {
|
||||
if ($this->oXMLReader->getElement('draw:image', $oNodeFrame)) {
|
||||
$this->loadShapeDrawing($oNodeFrame);
|
||||
continue;
|
||||
}
|
||||
if ($this->oXMLReader->getElement('draw:text-box', $oNodeFrame)) {
|
||||
$this->loadShapeRichText($oNodeFrame);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Shape Drawing
|
||||
*
|
||||
* @param \DOMElement $oNodeFrame
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadShapeDrawing(\DOMElement $oNodeFrame)
|
||||
protected function loadShapeDrawing(DOMElement $oNodeFrame): void
|
||||
{
|
||||
// Core
|
||||
$oShape = new Gd();
|
||||
$oShape->getShadow()->setVisible(false);
|
||||
$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 (pathinfo($sFilename, PATHINFO_EXTENSION) == 'svm') {
|
||||
if ('svm' == pathinfo($sFilename, PATHINFO_EXTENSION)) {
|
||||
return;
|
||||
}
|
||||
$imageFile = $this->oZip->getFromName($sFilename);
|
||||
if (!empty($imageFile)) {
|
||||
$oShape->setImageResource(imagecreatefromstring($imageFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oShape->setName($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
|
||||
$oShape->setDescription($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
|
||||
$oShape->setResizeProportional(false);
|
||||
$oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:width'), 0, -2))) : '');
|
||||
$oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:height'), 0, -2))) : '');
|
||||
$oShape->setResizeProportional(true);
|
||||
$oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:x'), 0, -2))) : '');
|
||||
$oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:y'), 0, -2))) : '');
|
||||
|
||||
|
||||
if (empty($imageFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Contents of file
|
||||
if (empty($mimetype)) {
|
||||
$shape = new Gd();
|
||||
$shape->setImageResource(imagecreatefromstring($imageFile));
|
||||
} else {
|
||||
$shape = new Base64();
|
||||
$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->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);
|
||||
|
||||
if ($oNodeFrame->hasAttribute('draw:style-name')) {
|
||||
$keyStyle = $oNodeFrame->getAttribute('draw:style-name');
|
||||
if (isset($this->arrayStyles[$keyStyle])) {
|
||||
$oShape->setShadow($this->arrayStyles[$keyStyle]['shadow']);
|
||||
$oShape->setFill($this->arrayStyles[$keyStyle]['fill']);
|
||||
$shape->setShadow($this->arrayStyles[$keyStyle]['shadow']);
|
||||
$shape->setFill($this->arrayStyles[$keyStyle]['fill']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->oPhpPresentation->getActiveSlide()->addShape($oShape);
|
||||
|
||||
$this->oPhpPresentation->getActiveSlide()->addShape($shape);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Shape RichText
|
||||
*
|
||||
* @param \DOMElement $oNodeFrame
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadShapeRichText(\DOMElement $oNodeFrame)
|
||||
protected function loadShapeRichText(DOMElement $oNodeFrame): void
|
||||
{
|
||||
// Core
|
||||
$oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
|
||||
$oShape->setParagraphs(array());
|
||||
|
||||
$oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:width'), 0, -2))) : '');
|
||||
$oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:height'), 0, -2))) : '');
|
||||
$oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:x'), 0, -2))) : '');
|
||||
$oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? (int)round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:y'), 0, -2))) : '');
|
||||
|
||||
$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);
|
||||
|
||||
foreach ($this->oXMLReader->getElements('draw:text-box/*', $oNodeFrame) as $oNodeParagraph) {
|
||||
$this->levelParagraph = 0;
|
||||
if ($oNodeParagraph->nodeName == 'text:p') {
|
||||
$this->readParagraph($oShape, $oNodeParagraph);
|
||||
}
|
||||
if ($oNodeParagraph->nodeName == 'text:list') {
|
||||
$this->readList($oShape, $oNodeParagraph);
|
||||
if ($oNodeParagraph instanceof DOMElement) {
|
||||
if ('text:p' == $oNodeParagraph->nodeName) {
|
||||
$this->readParagraph($oShape, $oNodeParagraph);
|
||||
}
|
||||
if ('text:list' == $oNodeParagraph->nodeName) {
|
||||
$this->readList($oShape, $oNodeParagraph);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (count($oShape->getParagraphs()) > 0) {
|
||||
$oShape->setActiveParagraph(0);
|
||||
}
|
||||
}
|
||||
|
||||
protected $levelParagraph = 0;
|
||||
|
||||
/**
|
||||
* Read Paragraph
|
||||
* @param RichText $oShape
|
||||
* @param \DOMElement $oNodeParent
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function readParagraph(RichText $oShape, \DOMElement $oNodeParent)
|
||||
protected function readParagraph(RichText $oShape, DOMElement $oNodeParent): void
|
||||
{
|
||||
$oParagraph = $oShape->createParagraph();
|
||||
if ($oNodeParent->hasAttribute('text:style-name')) {
|
||||
$keyStyle = $oNodeParent->getAttribute('text:style-name');
|
||||
if (isset($this->arrayStyles[$keyStyle])) {
|
||||
if (!empty($this->arrayStyles[$keyStyle]['spacingAfter'])) {
|
||||
$oParagraph->setSpacingAfter($this->arrayStyles[$keyStyle]['spacingAfter']);
|
||||
}
|
||||
if (!empty($this->arrayStyles[$keyStyle]['spacingBefore'])) {
|
||||
$oParagraph->setSpacingBefore($this->arrayStyles[$keyStyle]['spacingBefore']);
|
||||
}
|
||||
if (!empty($this->arrayStyles[$keyStyle]['lineSpacingMode'])) {
|
||||
$oParagraph->setLineSpacingMode($this->arrayStyles[$keyStyle]['lineSpacingMode']);
|
||||
}
|
||||
if (!empty($this->arrayStyles[$keyStyle]['lineSpacing'])) {
|
||||
$oParagraph->setLineSpacing($this->arrayStyles[$keyStyle]['lineSpacing']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$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));
|
||||
}
|
||||
}
|
||||
foreach ($oDomList as $oNodeRichTextElement) {
|
||||
$this->readParagraphItem($oParagraph, $oNodeRichTextElement);
|
||||
if ($oNodeRichTextElement instanceof DOMElement) {
|
||||
$this->readParagraphItem($oParagraph, $oNodeRichTextElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Paragraph Item
|
||||
* @param Paragraph $oParagraph
|
||||
* @param \DOMElement $oNodeParent
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function readParagraphItem(Paragraph $oParagraph, \DOMElement $oNodeParent)
|
||||
protected function readParagraphItem(Paragraph $oParagraph, DOMElement $oNodeParent): void
|
||||
{
|
||||
if ($this->oXMLReader->elementExists('text:line-break', $oNodeParent)) {
|
||||
$oParagraph->createBreak();
|
||||
|
|
@ -505,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'));
|
||||
|
|
@ -518,33 +674,27 @@ class ODPresentation implements ReaderInterface
|
|||
|
||||
/**
|
||||
* Read List
|
||||
*
|
||||
* @param RichText $oShape
|
||||
* @param \DOMElement $oNodeParent
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function readList(RichText $oShape, \DOMElement $oNodeParent)
|
||||
protected function readList(RichText $oShape, DOMElement $oNodeParent): void
|
||||
{
|
||||
foreach ($this->oXMLReader->getElements('text:list-item/*', $oNodeParent) as $oNodeListItem) {
|
||||
if ($oNodeListItem->nodeName == 'text:p') {
|
||||
$this->readListItem($oShape, $oNodeListItem, $oNodeParent);
|
||||
}
|
||||
if ($oNodeListItem->nodeName == 'text:list') {
|
||||
$this->levelParagraph++;
|
||||
$this->readList($oShape, $oNodeListItem);
|
||||
$this->levelParagraph--;
|
||||
if ($oNodeListItem instanceof DOMElement) {
|
||||
if ('text:p' == $oNodeListItem->nodeName) {
|
||||
$this->readListItem($oShape, $oNodeListItem, $oNodeParent);
|
||||
}
|
||||
if ('text:list' == $oNodeListItem->nodeName) {
|
||||
++$this->levelParagraph;
|
||||
$this->readList($oShape, $oNodeListItem);
|
||||
--$this->levelParagraph;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read List Item
|
||||
* @param RichText $oShape
|
||||
* @param \DOMElement $oNodeParent
|
||||
* @param \DOMElement $oNodeParagraph
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function readListItem(RichText $oShape, \DOMElement $oNodeParent, \DOMElement $oNodeParagraph)
|
||||
protected function readListItem(RichText $oShape, DOMElement $oNodeParent, DOMElement $oNodeParagraph): void
|
||||
{
|
||||
$oParagraph = $oShape->createParagraph();
|
||||
if ($oNodeParagraph->hasAttribute('text:style-name')) {
|
||||
|
|
@ -555,22 +705,52 @@ class ODPresentation implements ReaderInterface
|
|||
}
|
||||
}
|
||||
foreach ($this->oXMLReader->getElements('text:span', $oNodeParent) as $oNodeRichTextElement) {
|
||||
$this->readParagraphItem($oParagraph, $oNodeRichTextElement);
|
||||
if ($oNodeRichTextElement instanceof DOMElement) {
|
||||
$this->readParagraphItem($oParagraph, $oNodeRichTextElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load file 'styles.xml'
|
||||
* Load file 'styles.xml'.
|
||||
*/
|
||||
protected function loadStylesFile()
|
||||
protected function loadStylesFile(): void
|
||||
{
|
||||
foreach ($this->oXMLReader->getElements('/office:document-styles/office:styles/*') as $oElement) {
|
||||
if ($oElement->nodeName == 'draw:fill-image') {
|
||||
$this->arrayCommonStyles[$oElement->getAttribute('draw:name')] = array(
|
||||
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
|
||||
);
|
||||
'path' => $oElement->hasAttribute('xlink:href') ? $oElement->getAttribute('xlink:href') : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expr
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getExpressionUnit(string $expr): string
|
||||
{
|
||||
if (substr($expr, -1) == '%') {
|
||||
return '%';
|
||||
}
|
||||
|
||||
return substr($expr, -2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expr
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getExpressionValue(string $expr): string
|
||||
{
|
||||
if (substr($expr, -1) == '%') {
|
||||
return substr($expr, 0, -1);
|
||||
}
|
||||
|
||||
return substr($expr, 0, -2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
834
PhpOffice/PhpPresentation/Reader/PowerPoint2007.php
Executable file → Normal file
834
PhpOffice/PhpPresentation/Reader/PowerPoint2007.php
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
2136
PhpOffice/PhpPresentation/Reader/PowerPoint97.php
Executable file → Normal file
2136
PhpOffice/PhpPresentation/Reader/PowerPoint97.php
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
22
PhpOffice/PhpPresentation/Reader/ReaderInterface.php
Executable file → Normal file
22
PhpOffice/PhpPresentation/Reader/ReaderInterface.php
Executable file → Normal file
|
|
@ -10,32 +10,30 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Reader;
|
||||
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
|
||||
/**
|
||||
* Reader interface
|
||||
* Reader interface.
|
||||
*/
|
||||
interface ReaderInterface
|
||||
{
|
||||
/**
|
||||
* Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename);
|
||||
public function canRead(string $pFilename): bool;
|
||||
|
||||
/**
|
||||
* Loads PhpPresentation from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
* @throws \Exception
|
||||
* Loads PhpPresentation from file.
|
||||
*/
|
||||
public function load($pFilename);
|
||||
public function load(string $pFilename): PhpPresentation;
|
||||
}
|
||||
|
|
|
|||
87
PhpOffice/PhpPresentation/Reader/Serialized.php
Executable file → Normal file
87
PhpOffice/PhpPresentation/Reader/Serialized.php
Executable file → Normal file
|
|
@ -10,29 +10,33 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Reader;
|
||||
|
||||
use PhpOffice\Common\File;
|
||||
use PhpOffice\PhpPresentation\Exception\FileNotFoundException;
|
||||
use PhpOffice\PhpPresentation\Exception\InvalidFileFormatException;
|
||||
use PhpOffice\PhpPresentation\PhpPresentation;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\AbstractDrawingAdapter;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\File as DrawingFile;
|
||||
use ZipArchive;
|
||||
|
||||
/**
|
||||
* Serialized format reader
|
||||
* Serialized format reader.
|
||||
*/
|
||||
class Serialized implements ReaderInterface
|
||||
{
|
||||
/**
|
||||
* Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws \Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead(string $pFilename): bool
|
||||
{
|
||||
return $this->fileSupportsUnserializePhpPresentation($pFilename);
|
||||
}
|
||||
|
|
@ -40,15 +44,13 @@ class Serialized implements ReaderInterface
|
|||
/**
|
||||
* Does a file support UnserializePhpPresentation ?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws \Exception
|
||||
* @return boolean
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function fileSupportsUnserializePhpPresentation($pFilename = '')
|
||||
public function fileSupportsUnserializePhpPresentation(string $pFilename): bool
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new \Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new FileNotFoundException($pFilename);
|
||||
}
|
||||
|
||||
// File exists, does it contain PhpPresentation.xml?
|
||||
|
|
@ -56,58 +58,63 @@ class Serialized implements ReaderInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Loads PhpPresentation Serialized file
|
||||
* Loads PhpPresentation Serialized file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
* @throws \Exception
|
||||
* @throws FileNotFoundException
|
||||
* @throws InvalidFileFormatException
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load(string $pFilename): PhpPresentation
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new \Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
throw new FileNotFoundException($pFilename);
|
||||
}
|
||||
|
||||
// Unserialize... First make sure the file supports it!
|
||||
if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
|
||||
throw new \Exception("Invalid file format for PhpOffice\PhpPresentation\Reader\Serialized: " . $pFilename . ".");
|
||||
throw new InvalidFileFormatException($pFilename, Serialized::class);
|
||||
}
|
||||
|
||||
return $this->loadSerialized($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load PhpPresentation Serialized file
|
||||
* Load PhpPresentation Serialized file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return \PhpOffice\PhpPresentation\PhpPresentation
|
||||
* @throws InvalidFileFormatException
|
||||
*/
|
||||
private function loadSerialized($pFilename)
|
||||
private function loadSerialized(string $pFilename): PhpPresentation
|
||||
{
|
||||
$oArchive = new \ZipArchive();
|
||||
if ($oArchive->open($pFilename) === true) {
|
||||
$xmlContent = $oArchive->getFromName('PhpPresentation.xml');
|
||||
$oArchive = new ZipArchive();
|
||||
if (true !== $oArchive->open($pFilename)) {
|
||||
throw new InvalidFileFormatException($pFilename, Serialized::class);
|
||||
}
|
||||
|
||||
if (!empty($xmlContent)) {
|
||||
$xmlData = simplexml_load_string($xmlContent);
|
||||
$file = unserialize(base64_decode((string) $xmlData->data));
|
||||
$xmlContent = $oArchive->getFromName('PhpPresentation.xml');
|
||||
if (empty($xmlContent)) {
|
||||
throw new InvalidFileFormatException($pFilename, Serialized::class, 'The file PhpPresentation.xml is malformed');
|
||||
}
|
||||
|
||||
// Update media links
|
||||
for ($i = 0; $i < $file->getSlideCount(); ++$i) {
|
||||
for ($j = 0; $j < $file->getSlide($i)->getShapeCollection()->count(); ++$j) {
|
||||
if ($file->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawingAdapter) {
|
||||
$imgTemp = $file->getSlide($i)->getShapeCollection()->offsetGet($j);
|
||||
$imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getImageIndex() . '/' . pathinfo($imgTemp->getPath(), PATHINFO_BASENAME), false);
|
||||
}
|
||||
$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);
|
||||
if ($imgTemp instanceof DrawingFile) {
|
||||
$imgTemp->setPath($imgPath, false);
|
||||
} else {
|
||||
$imgTemp->setPath($imgPath);
|
||||
}
|
||||
}
|
||||
|
||||
$oArchive->close();
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
$oArchive->close();
|
||||
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
105
PhpOffice/PhpPresentation/Shape/AbstractGraphic.php
Executable file → Normal file
105
PhpOffice/PhpPresentation/Shape/AbstractGraphic.php
Executable file → Normal file
|
|
@ -10,91 +10,94 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* Abstract drawing
|
||||
* Abstract drawing.
|
||||
*/
|
||||
abstract class AbstractGraphic extends AbstractShape implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Image counter
|
||||
* Image counter.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $imageCounter = 0;
|
||||
|
||||
/**
|
||||
* Image index
|
||||
* Image index.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $imageIndex = 0;
|
||||
|
||||
/**
|
||||
* Name
|
||||
* Name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Description
|
||||
* Description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* Proportional resize
|
||||
* Proportional resize.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $resizeProportional;
|
||||
|
||||
/**
|
||||
* Slide relation ID (should not be used by user code!)
|
||||
* Slide relation ID (should not be used by user code!).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $relationId = null;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Slide\AbstractDrawing
|
||||
* Create a new \PhpOffice\PhpPresentation\Slide\AbstractDrawing.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->name = '';
|
||||
$this->description = '';
|
||||
$this->name = '';
|
||||
$this->description = '';
|
||||
$this->resizeProportional = true;
|
||||
|
||||
// Set image index
|
||||
self::$imageCounter++;
|
||||
++self::$imageCounter;
|
||||
$this->imageIndex = self::$imageCounter;
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
parent::__clone();
|
||||
|
||||
self::$imageCounter++;
|
||||
|
||||
++self::$imageCounter;
|
||||
$this->imageIndex = self::$imageCounter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image index
|
||||
* Get image index.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -104,7 +107,7 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
* Get Name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -114,19 +117,21 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Name
|
||||
* Set Name.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($pValue = '')
|
||||
{
|
||||
$this->name = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
* Get Description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -136,9 +141,10 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
* Set Description.
|
||||
*
|
||||
* @param string $pValue
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($pValue = '')
|
||||
|
|
@ -149,16 +155,15 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
* Set Width.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic
|
||||
* @return self
|
||||
*/
|
||||
public function setWidth($pValue = 0)
|
||||
public function setWidth(int $pValue = 0)
|
||||
{
|
||||
// Resize proportional?
|
||||
if ($this->resizeProportional && $pValue != 0 && $this->width != 0) {
|
||||
$ratio = $this->height / $this->width;
|
||||
if ($this->resizeProportional && 0 != $pValue && 0 != $this->width) {
|
||||
$ratio = $this->height / $this->width;
|
||||
$this->height = (int) round($ratio * $pValue);
|
||||
}
|
||||
|
||||
|
|
@ -169,16 +174,15 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
* Set Height.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic
|
||||
* @return self
|
||||
*/
|
||||
public function setHeight($pValue = 0)
|
||||
public function setHeight(int $pValue = 0)
|
||||
{
|
||||
// Resize proportional?
|
||||
if ($this->resizeProportional && $pValue != 0 && $this->height != 0) {
|
||||
$ratio = $this->width / $this->height;
|
||||
if ($this->resizeProportional && 0 != $pValue && 0 != $this->height) {
|
||||
$ratio = $this->width / $this->height;
|
||||
$this->width = (int) round($ratio * $pValue);
|
||||
}
|
||||
|
||||
|
|
@ -189,22 +193,22 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Set width and height with proportional resize
|
||||
* Set width and height with proportional resize.
|
||||
*
|
||||
* @author Vincent@luo MSN:kele_100@hotmail.com
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setWidthAndHeight($width = 0, $height = 0)
|
||||
public function setWidthAndHeight(int $width = 0, int $height = 0)
|
||||
{
|
||||
$xratio = $width / $this->width;
|
||||
$yratio = $height / $this->height;
|
||||
if ($this->resizeProportional && !($width == 0 || $height == 0)) {
|
||||
if ($this->resizeProportional && !(0 == $width || 0 == $height)) {
|
||||
if (($xratio * $this->height) < $height) {
|
||||
$this->height = (int) ceil($xratio * $this->height);
|
||||
$this->width = $width;
|
||||
$this->width = $width;
|
||||
} else {
|
||||
$this->width = (int) ceil($yratio * $this->width);
|
||||
$this->width = (int) ceil($yratio * $this->width);
|
||||
$this->height = $height;
|
||||
}
|
||||
}
|
||||
|
|
@ -213,9 +217,9 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Get ResizeProportional
|
||||
* Get ResizeProportional.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isResizeProportional()
|
||||
{
|
||||
|
|
@ -223,12 +227,11 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Set ResizeProportional
|
||||
* Set ResizeProportional.
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic
|
||||
* @param bool $pValue
|
||||
*/
|
||||
public function setResizeProportional($pValue = true)
|
||||
public function setResizeProportional($pValue = true): self
|
||||
{
|
||||
$this->resizeProportional = $pValue;
|
||||
|
||||
|
|
@ -236,11 +239,11 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->name . $this->description . parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
300
PhpOffice/PhpPresentation/Shape/AutoShape.php
Normal file
300
PhpOffice/PhpPresentation/Shape/AutoShape.php
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Outline;
|
||||
|
||||
/**
|
||||
* AutoShape shape
|
||||
*
|
||||
* @see : https://github.com/scanny/python-pptx/blob/eaa1e0fd3db28b03a353e116a5c7d2084dd87c26/pptx/enum/shapes.py
|
||||
*/
|
||||
class AutoShape extends AbstractShape implements ComparableInterface
|
||||
{
|
||||
public const TYPE_10_POINT_STAR = 'star10';
|
||||
public const TYPE_12_POINT_STAR = 'star12';
|
||||
public const TYPE_16_POINT_STAR = 'star16';
|
||||
public const TYPE_24_POINT_STAR = 'star24';
|
||||
public const TYPE_32_POINT_STAR = 'star32';
|
||||
public const TYPE_4_POINT_STAR = 'star4';
|
||||
public const TYPE_5_POINT_STAR = 'star5';
|
||||
public const TYPE_6_POINT_STAR = 'star6';
|
||||
public const TYPE_7_POINT_STAR = 'star7';
|
||||
public const TYPE_8_POINT_STAR = 'star8';
|
||||
public const TYPE_ACTION_BUTTON_BACK_OR_PREVIOUS = 'actionButtonBackPrevious';
|
||||
public const TYPE_ACTION_BUTTON_BEGINNING = 'actionButtonBeginning';
|
||||
public const TYPE_ACTION_BUTTON_CUSTOM = 'actionButtonBlank';
|
||||
public const TYPE_ACTION_BUTTON_DOCUMENT = 'actionButtonDocument';
|
||||
public const TYPE_ACTION_BUTTON_END = 'actionButtonEnd';
|
||||
public const TYPE_ACTION_BUTTON_FORWARD_OR_NEXT = 'actionButtonForwardNext';
|
||||
public const TYPE_ACTION_BUTTON_HELP = 'actionButtonHelp';
|
||||
public const TYPE_ACTION_BUTTON_HOME = 'actionButtonHome';
|
||||
public const TYPE_ACTION_BUTTON_INFORMATION = 'actionButtonInformation';
|
||||
public const TYPE_ACTION_BUTTON_MOVIE = 'actionButtonMovie';
|
||||
public const TYPE_ACTION_BUTTON_RETURN = 'actionButtonReturn';
|
||||
public const TYPE_ACTION_BUTTON_SOUND = 'actionButtonSound';
|
||||
public const TYPE_ARC = 'arc';
|
||||
public const TYPE_BALLOON = 'wedgeRoundRectCallout';
|
||||
public const TYPE_BENT_ARROW = 'bentArrow';
|
||||
public const TYPE_BENT_UP_ARROW = 'bentUpArrow';
|
||||
public const TYPE_BEVEL = 'bevel';
|
||||
public const TYPE_BLOCK_ARC = 'blockArc';
|
||||
public const TYPE_CAN = 'can';
|
||||
public const TYPE_CHART_PLUS = 'chartPlus';
|
||||
public const TYPE_CHART_STAR = 'chartStar';
|
||||
public const TYPE_CHARTX = 'chartX';
|
||||
public const TYPE_CHEVRON = 'chevron';
|
||||
public const TYPE_CHORD = 'chord';
|
||||
public const TYPE_CIRCULAR_ARROW = 'circularArrow';
|
||||
public const TYPE_CLOUD = 'cloud';
|
||||
public const TYPE_CLOUD_CALLOUT = 'cloudCallout';
|
||||
public const TYPE_CORNER = 'corner';
|
||||
public const TYPE_CORNER_TABS = 'cornerTabs';
|
||||
public const TYPE_CROSS = 'plus';
|
||||
public const TYPE_CUBE = 'cube';
|
||||
public const TYPE_CURVED_DOWN_ARROW = 'curvedDownArrow';
|
||||
public const TYPE_CURVED_DOWN_RIBBON = 'ellipseRibbon';
|
||||
public const TYPE_CURVED_LEFT_ARROW = 'curvedLeftArrow';
|
||||
public const TYPE_CURVED_RIGHT_ARROW = 'curvedRightArrow';
|
||||
public const TYPE_CURVED_UP_ARROW = 'curvedUpArrow';
|
||||
public const TYPE_CURVED_UP_RIBBON = 'ellipseRibbon2';
|
||||
public const TYPE_DECAGON = 'decagon';
|
||||
public const TYPE_DIAGONALSTRIPE = 'diagStripe';
|
||||
public const TYPE_DIAMOND = 'diamond';
|
||||
public const TYPE_DODECAGON = 'dodecagon';
|
||||
public const TYPE_DONUT = 'donut';
|
||||
public const TYPE_DOUBLE_BRACE = 'bracePair';
|
||||
public const TYPE_DOUBLE_BRACKET = 'bracketPair';
|
||||
public const TYPE_DOUBLE_WAVE = 'doubleWave';
|
||||
public const TYPE_DOWN_ARROW = 'downArrow';
|
||||
public const TYPE_DOWN_ARROWCALLOUT = 'downArrowCallout';
|
||||
public const TYPE_DOWN_RIBBON = 'ribbon';
|
||||
public const TYPE_EXPLOSIONEXPLOSION1 = 'irregularSeal1';
|
||||
public const TYPE_EXPLOSIONEXPLOSION2 = 'irregularSeal2';
|
||||
public const TYPE_FLOWCHART_ALTERNATEPROCESS = 'flowChartAlternateProcess';
|
||||
public const TYPE_FLOWCHART_CARD = 'flowChartPunchedCard';
|
||||
public const TYPE_FLOWCHART_COLLATE = 'flowChartCollate';
|
||||
public const TYPE_FLOWCHART_CONNECTOR = 'flowChartConnector';
|
||||
public const TYPE_FLOWCHART_DATA = 'flowChartInputOutput';
|
||||
public const TYPE_FLOWCHART_DECISION = 'flowChartDecision';
|
||||
public const TYPE_FLOWCHART_DELAY = 'flowChartDelay';
|
||||
public const TYPE_FLOWCHART_DIRECT_ACCESS_STORAGE = 'flowChartMagneticDrum';
|
||||
public const TYPE_FLOWCHART_DISPLAY = 'flowChartDisplay';
|
||||
public const TYPE_FLOWCHART_DOCUMENT = 'flowChartDocument';
|
||||
public const TYPE_FLOWCHART_EXTRACT = 'flowChartExtract';
|
||||
public const TYPE_FLOWCHART_INTERNAL_STORAGE = 'flowChartInternalStorage';
|
||||
public const TYPE_FLOWCHART_MAGNETIC_DISK = 'flowChartMagneticDisk';
|
||||
public const TYPE_FLOWCHART_MANUAL_INPUT = 'flowChartManualInput';
|
||||
public const TYPE_FLOWCHART_MANUAL_OPERATION = 'flowChartManualOperation';
|
||||
public const TYPE_FLOWCHART_MERGE = 'flowChartMerge';
|
||||
public const TYPE_FLOWCHART_MULTIDOCUMENT = 'flowChartMultidocument';
|
||||
public const TYPE_FLOWCHART_OFFLINE_STORAGE = 'flowChartOfflineStorage';
|
||||
public const TYPE_FLOWCHART_OFFPAGE_CONNECTOR = 'flowChartOffpageConnector';
|
||||
public const TYPE_FLOWCHART_OR = 'flowChartOr';
|
||||
public const TYPE_FLOWCHART_PREDEFINED_PROCESS = 'flowChartPredefinedProcess';
|
||||
public const TYPE_FLOWCHART_PREPARATION = 'flowChartPreparation';
|
||||
public const TYPE_FLOWCHART_PROCESS = 'flowChartProcess';
|
||||
public const TYPE_FLOWCHART_PUNCHEDTAPE = 'flowChartPunchedTape';
|
||||
public const TYPE_FLOWCHART_SEQUENTIAL_ACCESS_STORAGE = 'flowChartMagneticTape';
|
||||
public const TYPE_FLOWCHART_SORT = 'flowChartSort';
|
||||
public const TYPE_FLOWCHART_STORED_DATA = 'flowChartOnlineStorage';
|
||||
public const TYPE_FLOWCHART_SUMMING_JUNCTION = 'flowChartSummingJunction';
|
||||
public const TYPE_FLOWCHART_TERMINATOR = 'flowChartTerminator';
|
||||
public const TYPE_FOLDED_CORNER = 'foldedCorner';
|
||||
public const TYPE_FRAME = 'frame';
|
||||
public const TYPE_FUNNEL = 'funnel';
|
||||
public const TYPE_GEAR_6 = 'gear6';
|
||||
public const TYPE_GEAR_9 = 'gear9';
|
||||
public const TYPE_HALF_FRAME = 'halfFrame';
|
||||
public const TYPE_HEART = 'heart';
|
||||
public const TYPE_HEPTAGON = 'heptagon';
|
||||
public const TYPE_HEXAGON = 'hexagon';
|
||||
public const TYPE_HORIZONTAL_SCROLL = 'horizontalScroll';
|
||||
public const TYPE_ISOSCELES_TRIANGLE = 'triangle';
|
||||
public const TYPE_LEFT_ARROW = 'leftArrow';
|
||||
public const TYPE_LEFT_ARROW_CALLOUT = 'leftArrowCallout';
|
||||
public const TYPE_LEFT_BRACE = 'leftBrace';
|
||||
public const TYPE_LEFT_BRACKET = 'leftBracket';
|
||||
public const TYPE_LEFT_CIRCULAR_ARROW = 'leftCircularArrow';
|
||||
public const TYPE_LEFT_RIGHT_ARROW = 'leftRightArrow';
|
||||
public const TYPE_LEFT_RIGHT_ARROW_CALLOUT = 'leftRightArrowCallout';
|
||||
public const TYPE_LEFT_RIGHT_CIRCULAR_ARROW = 'leftRightCircularArrow';
|
||||
public const TYPE_LEFT_RIGHT_RIBBON = 'leftRightRibbon';
|
||||
public const TYPE_LEFT_RIGHT_UP_ARROW = 'leftRightUpArrow';
|
||||
public const TYPE_LEFT_UP_ARROW = 'leftUpArrow';
|
||||
public const TYPE_LIGHTNING_BOLT = 'lightningBolt';
|
||||
public const TYPE_LINE_CALLOUT_1 = 'borderCallout1';
|
||||
public const TYPE_LINE_CALLOUT_1_ACCENT_BAR = 'accentCallout1';
|
||||
public const TYPE_LINE_CALLOUT_1_BORDER_AND_ACCENT_BAR = 'accentBorderCallout1';
|
||||
public const TYPE_LINE_CALLOUT_1_NO_BORDER = 'callout1';
|
||||
public const TYPE_LINE_CALLOUT_2 = 'borderCallout2';
|
||||
public const TYPE_LINE_CALLOUT_2_ACCENT_BAR = 'accentCallout2';
|
||||
public const TYPE_LINE_CALLOUT_2_BORDER_AND_ACCENT_BAR = 'accentBorderCallout2';
|
||||
public const TYPE_LINE_CALLOUT_2_NO_BORDER = 'callout2';
|
||||
public const TYPE_LINE_CALLOUT_3 = 'borderCallout3';
|
||||
public const TYPE_LINE_CALLOUT_3_ACCENT_BAR = 'accentCallout3';
|
||||
public const TYPE_LINE_CALLOUT_3_BORDER_AND_ACCENT_BAR = 'accentBorderCallout3';
|
||||
public const TYPE_LINE_CALLOUT_3_NO_BORDER = 'callout3';
|
||||
public const TYPE_LINE_CALLOUT_4 = 'borderCallout4';
|
||||
public const TYPE_LINE_CALLOUT_4_ACCENT_BAR = 'accentCallout4';
|
||||
public const TYPE_LINE_CALLOUT_4_BORDER_AND_ACCENT_BAR = 'accentBorderCallout4';
|
||||
public const TYPE_LINE_CALLOUT_4_NO_BORDER = 'callout4';
|
||||
public const TYPE_LINE_INVERSE = 'lineInv';
|
||||
public const TYPE_MATH_DIVIDE = 'mathDivide';
|
||||
public const TYPE_MATH_EQUAL = 'mathEqual';
|
||||
public const TYPE_MATH_MINUS = 'mathMinus';
|
||||
public const TYPE_MATH_MULTIPLY = 'mathMultiply';
|
||||
public const TYPE_MATH_NOT_EQUAL = 'mathNotEqual';
|
||||
public const TYPE_MATH_PLUS = 'mathPlus';
|
||||
//public const TYPE_MIXED = '';
|
||||
public const TYPE_MOON = 'moon';
|
||||
public const TYPE_NON_ISOSCELES_TRAPEZOID = 'nonIsoscelesTrapezoid';
|
||||
public const TYPE_NO_SYMBOL = 'noSmoking';
|
||||
public const TYPE_NOTCHED_RIGHT_ARROW = 'notchedRightArrow';
|
||||
//public const TYPE_NOTPRIMITIVE = '';
|
||||
public const TYPE_OCTAGON = 'octagon';
|
||||
public const TYPE_OVAL = 'ellipse';
|
||||
public const TYPE_OVAL_CALLOUT = 'wedgeEllipseCallout';
|
||||
public const TYPE_PARALLELOGRAM = 'parallelogram';
|
||||
public const TYPE_PENTAGON = 'homePlate';
|
||||
public const TYPE_PIE = 'pie';
|
||||
public const TYPE_PIE_WEDGE = 'pieWedge';
|
||||
public const TYPE_PLAQUE = 'plaque';
|
||||
public const TYPE_PLAQUE_TABS = 'plaqueTabs';
|
||||
public const TYPE_QUAD_ARROW = 'quadArrow';
|
||||
public const TYPE_QUAD_ARROW_CALLOUT = 'quadArrowCallout';
|
||||
public const TYPE_RECTANGLE = 'rect';
|
||||
public const TYPE_RECTANGULAR_CALLOUT = 'wedgeRectCallout';
|
||||
public const TYPE_REGULARP_ENTAGON = 'pentagon';
|
||||
public const TYPE_RIGHT_ARROW = 'rightArrow';
|
||||
public const TYPE_RIGHT_ARROW_CALLOUT = 'rightArrowCallout';
|
||||
public const TYPE_RIGHT_BRACE = 'rightBrace';
|
||||
public const TYPE_RIGHT_BRACKET = 'rightBracket';
|
||||
public const TYPE_RIGHT_TRIANGLE = 'rtTriangle';
|
||||
public const TYPE_ROUND_1_RECTANGLE = 'round1Rect';
|
||||
public const TYPE_ROUND_2_DIAG_RECTANGLE = 'round2DiagRect';
|
||||
public const TYPE_ROUND_2_SAME_RECTANGLE = 'round2SameRect';
|
||||
public const TYPE_ROUNDED_RECTANGLE = 'roundRect';
|
||||
public const TYPE_ROUNDED_RECTANGULAR_CALLOUT = 'wedgeRoundRectCallout';
|
||||
public const TYPE_SMILEY_FACE = 'smileyFace';
|
||||
public const TYPE_SNIP_1_RECTANGLE = 'snip1Rect';
|
||||
public const TYPE_SNIP_2_DIAG_RECTANGLE = 'snip2DiagRect';
|
||||
public const TYPE_SNIP_2_SAME_RECTANGLE = 'snip2SameRect';
|
||||
public const TYPE_SNIP_ROUND_RECTANGLE = 'snipRoundRect';
|
||||
public const TYPE_SQUARE_TABS = 'squareTabs';
|
||||
public const TYPE_STRIPED_RIGHT_ARROW = 'stripedRightArrow';
|
||||
public const TYPE_SUN = 'sun';
|
||||
public const TYPE_SWOOSH_ARROW = 'swooshArrow';
|
||||
public const TYPE_TEAR = 'teardrop';
|
||||
public const TYPE_TRAPEZOID = 'trapezoid';
|
||||
public const TYPE_UP_ARROW = 'upArrow';
|
||||
public const TYPE_UP_ARROW_CALLOUT = 'upArrowCallout';
|
||||
public const TYPE_UP_DOWN_ARROW = 'upDownArrow';
|
||||
public const TYPE_UP_DOWN_ARROW_CALLOUT = 'upDownArrowCallout';
|
||||
public const TYPE_UP_RIBBON = 'ribbon2';
|
||||
public const TYPE_U_TURN_ARROW = 'uturnArrow';
|
||||
public const TYPE_VERTICAL_SCROLL = 'verticalScroll';
|
||||
public const TYPE_WAVE = 'wave';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $text = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = self::TYPE_HEART;
|
||||
|
||||
/**
|
||||
* @var Outline
|
||||
*/
|
||||
protected $outline;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->outline = new Outline();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setText(string $text): self
|
||||
{
|
||||
$this->text = $text;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setType(string $type): self
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Outline
|
||||
*/
|
||||
public function getOutline(): Outline
|
||||
{
|
||||
return $this->outline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Outline $outline
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setOutline(Outline $outline): self
|
||||
{
|
||||
$this->outline = $outline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
132
PhpOffice/PhpPresentation/Shape/Chart.php
Executable file → Normal file
132
PhpOffice/PhpPresentation/Shape/Chart.php
Executable file → Normal file
|
|
@ -10,11 +10,14 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
|
@ -24,148 +27,187 @@ use PhpOffice\PhpPresentation\Shape\Chart\Title;
|
|||
use PhpOffice\PhpPresentation\Shape\Chart\View3D;
|
||||
|
||||
/**
|
||||
* Chart element
|
||||
* Chart element.
|
||||
*/
|
||||
class Chart extends AbstractGraphic implements ComparableInterface
|
||||
{
|
||||
public const BLANKAS_GAP = 'gap';
|
||||
public const BLANKAS_ZERO = 'zero';
|
||||
public const BLANKAS_SPAN = 'span';
|
||||
|
||||
/**
|
||||
* Title
|
||||
* Title.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
* @var Title
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* Legend
|
||||
* Legend.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
* @var Legend
|
||||
*/
|
||||
private $legend;
|
||||
|
||||
/**
|
||||
* Plot area
|
||||
* Plot area.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
* @var PlotArea
|
||||
*/
|
||||
private $plotArea;
|
||||
|
||||
/**
|
||||
* View 3D
|
||||
* View 3D.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
* @var View3D
|
||||
*/
|
||||
private $view3D;
|
||||
|
||||
/**
|
||||
* Include spreadsheet for editing data? Requires PHPExcel in the same folder as PhpPresentation
|
||||
* Is the spreadsheet included for editing data ?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $includeSpreadsheet = false;
|
||||
|
||||
/**
|
||||
* Create a new Chart
|
||||
* How to display blank (missing) values? Not set by default.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $displayBlankAs = self::BLANKAS_ZERO;
|
||||
|
||||
/**
|
||||
* Create a new Chart.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialize
|
||||
$this->title = new Title();
|
||||
$this->legend = new Legend();
|
||||
$this->title = new Title();
|
||||
$this->legend = new Legend();
|
||||
$this->plotArea = new PlotArea();
|
||||
$this->view3D = new View3D();
|
||||
$this->view3D = new View3D();
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
parent::__clone();
|
||||
|
||||
$this->title = clone $this->title;
|
||||
$this->legend = clone $this->legend;
|
||||
$this->plotArea = clone $this->plotArea;
|
||||
$this->view3D = clone $this->view3D;
|
||||
|
||||
$this->title = clone $this->title;
|
||||
$this->legend = clone $this->legend;
|
||||
$this->plotArea = clone $this->plotArea;
|
||||
$this->view3D = clone $this->view3D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
* How missing/blank values are displayed on chart (dispBlanksAs property)
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
public function getDisplayBlankAs(): string
|
||||
{
|
||||
return $this->displayBlankAs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title.
|
||||
*
|
||||
* @return Title
|
||||
*/
|
||||
public function getTitle(): Title
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Legend
|
||||
* Get Legend.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
* @return Legend
|
||||
*/
|
||||
public function getLegend()
|
||||
public function getLegend(): Legend
|
||||
{
|
||||
return $this->legend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PlotArea
|
||||
* Get PlotArea.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
* @return PlotArea
|
||||
*/
|
||||
public function getPlotArea()
|
||||
public function getPlotArea(): PlotArea
|
||||
{
|
||||
return $this->plotArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View3D
|
||||
* Get View3D.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
* @return View3D
|
||||
*/
|
||||
public function getView3D()
|
||||
public function getView3D(): View3D
|
||||
{
|
||||
return $this->view3D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include spreadsheet for editing data? Requires PHPExcel in the same folder as PhpPresentation
|
||||
* Is the spreadsheet included for editing data ?
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasIncludedSpreadsheet()
|
||||
public function hasIncludedSpreadsheet(): bool
|
||||
{
|
||||
return $this->includeSpreadsheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include spreadsheet for editing data? Requires PHPExcel in the same folder as PhpPresentation
|
||||
* Define a way to display missing/blank values (dispBlanksAs property)
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setIncludeSpreadsheet($value = false)
|
||||
public function setDisplayBlankAs(string $value): self
|
||||
{
|
||||
$this->includeSpreadsheet = $value;
|
||||
if (in_array($value, [self::BLANKAS_GAP, self::BLANKAS_SPAN, self::BLANKAS_ZERO])) {
|
||||
$this->displayBlankAs = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indexed filename (using image index)
|
||||
* Is the spreadsheet included for editing data ?
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setIncludeSpreadsheet(bool $value = false): self
|
||||
{
|
||||
$this->includeSpreadsheet = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indexed filename (using image index).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
public function getIndexedFilename(): string
|
||||
{
|
||||
return 'chart' . $this->getImageIndex() . '.xml';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
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__);
|
||||
}
|
||||
|
|
|
|||
380
PhpOffice/PhpPresentation/Shape/Chart/Axis.php
Executable file → Normal file
380
PhpOffice/PhpPresentation/Shape/Chart/Axis.php
Executable file → Normal file
|
|
@ -10,37 +10,50 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
use PhpOffice\PhpPresentation\Style\Outline;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
class Axis implements ComparableInterface
|
||||
{
|
||||
const AXIS_X = 'x';
|
||||
const AXIS_Y = 'y';
|
||||
public const AXIS_X = 'x';
|
||||
public const AXIS_Y = 'y';
|
||||
|
||||
const TICK_MARK_NONE = 'none';
|
||||
const TICK_MARK_CROSS = 'cross';
|
||||
const TICK_MARK_INSIDE = 'in';
|
||||
const TICK_MARK_OUTSIDE = 'out';
|
||||
public const TICK_MARK_NONE = 'none';
|
||||
public const TICK_MARK_CROSS = 'cross';
|
||||
public const TICK_MARK_INSIDE = 'in';
|
||||
public const TICK_MARK_OUTSIDE = 'out';
|
||||
|
||||
public const TICK_LABEL_POSITION_NEXT_TO = 'nextTo';
|
||||
public const TICK_LABEL_POSITION_HIGH = 'high';
|
||||
public const TICK_LABEL_POSITION_LOW = 'low';
|
||||
|
||||
public const CROSSES_AUTO = 'autoZero';
|
||||
public const CROSSES_MIN = 'min';
|
||||
public const CROSSES_MAX = 'max';
|
||||
|
||||
/**
|
||||
* Title
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $title = 'Axis Title';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $titleRotation = 0;
|
||||
|
||||
/**
|
||||
* Format code
|
||||
*
|
||||
|
|
@ -49,19 +62,19 @@ class Axis implements ComparableInterface
|
|||
private $formatCode = '';
|
||||
|
||||
/**
|
||||
* Font
|
||||
* Font.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
* @var Font
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* @var Gridlines
|
||||
* @var Gridlines|null
|
||||
*/
|
||||
protected $majorGridlines;
|
||||
|
||||
/**
|
||||
* @var Gridlines
|
||||
* @var Gridlines|null
|
||||
*/
|
||||
protected $minorGridlines;
|
||||
|
||||
|
|
@ -75,6 +88,16 @@ class Axis implements ComparableInterface
|
|||
*/
|
||||
protected $maxBounds;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $crossesAt = self::CROSSES_AUTO;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isReversedOrder = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -85,6 +108,11 @@ class Axis implements ComparableInterface
|
|||
*/
|
||||
protected $majorTickMark = self::TICK_MARK_NONE;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tickLabelPosition = self::TICK_LABEL_POSITION_NEXT_TO;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
|
|
@ -101,39 +129,40 @@ class Axis implements ComparableInterface
|
|||
protected $outline;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $isVisible = true;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance.
|
||||
*
|
||||
* @param string $title Title
|
||||
*/
|
||||
public function __construct($title = 'Axis Title')
|
||||
public function __construct(string $title = 'Axis Title')
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->outline = new Outline();
|
||||
$this->font = new Font();
|
||||
$this->font = new Font();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
* Get Title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
* Set Title.
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setTitle($value = 'Axis Title')
|
||||
public function setTitle(string $value = 'Axis Title'): self
|
||||
{
|
||||
$this->title = $value;
|
||||
|
||||
|
|
@ -141,45 +170,47 @@ class Axis implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
* Get font.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
* @return Font|null
|
||||
*/
|
||||
public function getFont()
|
||||
public function getFont(): ?Font
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
* Set font.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
* @param Font|null $font
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
public function setFont(Font $font = null): self
|
||||
{
|
||||
$this->font = $pFont;
|
||||
$this->font = $font;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Format Code
|
||||
* Get Format Code.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormatCode()
|
||||
public function getFormatCode(): string
|
||||
{
|
||||
return $this->formatCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Format Code
|
||||
* Set Format Code.
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setFormatCode($value = '')
|
||||
public function setFormatCode(string $value = ''): self
|
||||
{
|
||||
$this->formatCode = $value;
|
||||
|
||||
|
|
@ -189,162 +220,230 @@ class Axis implements ComparableInterface
|
|||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMinBounds()
|
||||
public function getMinBounds(): ?int
|
||||
{
|
||||
return $this->minBounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $minBounds
|
||||
* @return Axis
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMinBounds($minBounds = null)
|
||||
public function setMinBounds(int $minBounds = null): self
|
||||
{
|
||||
$this->minBounds = is_null($minBounds) ? null : (int)$minBounds;
|
||||
$this->minBounds = is_null($minBounds) ? null : $minBounds;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMaxBounds()
|
||||
public function getMaxBounds(): ?int
|
||||
{
|
||||
return $this->maxBounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $maxBounds
|
||||
* @return Axis
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMaxBounds($maxBounds = null)
|
||||
public function setMaxBounds(int $maxBounds = null): self
|
||||
{
|
||||
$this->maxBounds = is_null($maxBounds) ? null : (int)$maxBounds;
|
||||
return $this;
|
||||
}
|
||||
$this->maxBounds = is_null($maxBounds) ? null : $maxBounds;
|
||||
|
||||
/**
|
||||
* @return Gridlines
|
||||
*/
|
||||
public function getMajorGridlines()
|
||||
{
|
||||
return $this->majorGridlines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gridlines $majorGridlines
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMajorGridlines(Gridlines $majorGridlines)
|
||||
{
|
||||
$this->majorGridlines = $majorGridlines;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gridlines
|
||||
*/
|
||||
public function getMinorGridlines()
|
||||
{
|
||||
return $this->minorGridlines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gridlines $minorGridlines
|
||||
* @return Axis
|
||||
*/
|
||||
public function setMinorGridlines(Gridlines $minorGridlines)
|
||||
{
|
||||
$this->minorGridlines = $minorGridlines;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMinorTickMark()
|
||||
public function getCrossesAt(): string
|
||||
{
|
||||
return $this->crossesAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setCrossesAt(string $value = self::CROSSES_AUTO): self
|
||||
{
|
||||
$this->crossesAt = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isReversedOrder(): bool
|
||||
{
|
||||
return $this->isReversedOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setIsReversedOrder(bool $value = false): self
|
||||
{
|
||||
$this->isReversedOrder = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMajorGridlines(): ?Gridlines
|
||||
{
|
||||
return $this->majorGridlines;
|
||||
}
|
||||
|
||||
public function setMajorGridlines(Gridlines $majorGridlines): self
|
||||
{
|
||||
$this->majorGridlines = $majorGridlines;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMinorGridlines(): ?Gridlines
|
||||
{
|
||||
return $this->minorGridlines;
|
||||
}
|
||||
|
||||
public function setMinorGridlines(Gridlines $minorGridlines): self
|
||||
{
|
||||
$this->minorGridlines = $minorGridlines;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMinorTickMark(): string
|
||||
{
|
||||
return $this->minorTickMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pTickMark
|
||||
* @return Axis
|
||||
* @param string $tickMark
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMinorTickMark($pTickMark = self::TICK_MARK_NONE)
|
||||
public function setMinorTickMark(string $tickMark = self::TICK_MARK_NONE): self
|
||||
{
|
||||
$this->minorTickMark = $pTickMark;
|
||||
$this->minorTickMark = $tickMark;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMajorTickMark()
|
||||
public function getMajorTickMark(): string
|
||||
{
|
||||
return $this->majorTickMark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pTickMark
|
||||
* @return Axis
|
||||
* @param string $tickMark
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMajorTickMark($pTickMark = self::TICK_MARK_NONE)
|
||||
public function setMajorTickMark(string $tickMark = self::TICK_MARK_NONE): self
|
||||
{
|
||||
$this->majorTickMark = $pTickMark;
|
||||
$this->majorTickMark = $tickMark;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return float|null
|
||||
*/
|
||||
public function getMinorUnit()
|
||||
public function getMinorUnit(): ?float
|
||||
{
|
||||
return $this->minorUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $pUnit
|
||||
* @return Axis
|
||||
* @param float|null $unit
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMinorUnit($pUnit = null)
|
||||
public function setMinorUnit($unit = null): self
|
||||
{
|
||||
$this->minorUnit = $pUnit;
|
||||
$this->minorUnit = $unit;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return float|null
|
||||
*/
|
||||
public function getMajorUnit()
|
||||
public function getMajorUnit(): ?float
|
||||
{
|
||||
return $this->majorUnit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $pUnit
|
||||
* @return Axis
|
||||
* @param float|null $unit
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMajorUnit($pUnit = null)
|
||||
public function setMajorUnit(float $unit = null): self
|
||||
{
|
||||
$this->majorUnit = $pUnit;
|
||||
$this->majorUnit = $unit;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Outline
|
||||
*/
|
||||
public function getOutline()
|
||||
public function getOutline(): Outline
|
||||
{
|
||||
return $this->outline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Outline $outline
|
||||
* @return Axis
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setOutline(Outline $outline)
|
||||
public function setOutline(Outline $outline): self
|
||||
{
|
||||
$this->outline = $outline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTitleRotation(): int
|
||||
{
|
||||
return $this->titleRotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $titleRotation
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setTitleRotation(int $titleRotation): self
|
||||
{
|
||||
if ($titleRotation < 0) {
|
||||
$titleRotation = 0;
|
||||
}
|
||||
if ($titleRotation > 360) {
|
||||
$titleRotation = 360;
|
||||
}
|
||||
$this->titleRotation = $titleRotation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -353,64 +452,95 @@ class Axis implements ComparableInterface
|
|||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->title . $this->formatCode . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @return $this
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Axis is hidden ?
|
||||
* @return boolean
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisible()
|
||||
public function isVisible(): bool
|
||||
{
|
||||
return $this->isVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide an axis
|
||||
* Hide an axis.
|
||||
*
|
||||
* @param boolean $value delete
|
||||
* @return $this
|
||||
* @param bool $value delete
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setIsVisible($value)
|
||||
public function setIsVisible(bool $value): self
|
||||
{
|
||||
$this->isVisible = (bool)$value;
|
||||
$this->isVisible = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTickLabelPosition(): string
|
||||
{
|
||||
return $this->tickLabelPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setTickLabelPosition(string $value = self::TICK_LABEL_POSITION_NEXT_TO): self
|
||||
{
|
||||
if (in_array($value, [
|
||||
self::TICK_LABEL_POSITION_HIGH,
|
||||
self::TICK_LABEL_POSITION_LOW,
|
||||
self::TICK_LABEL_POSITION_NEXT_TO,
|
||||
])) {
|
||||
$this->tickLabelPosition = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
PhpOffice/PhpPresentation/Shape/Chart/Gridlines.php
Executable file → Normal file
20
PhpOffice/PhpPresentation/Shape/Chart/Gridlines.php
Executable file → Normal file
|
|
@ -1,4 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
|
|
@ -25,12 +43,12 @@ class Gridlines
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Outline $outline
|
||||
* @return Gridlines
|
||||
*/
|
||||
public function setOutline(Outline $outline)
|
||||
{
|
||||
$this->outline = $outline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
186
PhpOffice/PhpPresentation/Shape/Chart/Legend.php
Executable file → Normal file
186
PhpOffice/PhpPresentation/Shape/Chart/Legend.php
Executable file → Normal file
|
|
@ -10,11 +10,14 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
|
@ -24,102 +27,102 @@ use PhpOffice\PhpPresentation\Style\Fill;
|
|||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Legend.
|
||||
*/
|
||||
class Legend implements ComparableInterface
|
||||
{
|
||||
/** Legend positions */
|
||||
const POSITION_BOTTOM = 'b';
|
||||
const POSITION_LEFT = 'l';
|
||||
const POSITION_RIGHT = 'r';
|
||||
const POSITION_TOP = 't';
|
||||
const POSITION_TOPRIGHT = 'tr';
|
||||
public const POSITION_BOTTOM = 'b';
|
||||
public const POSITION_LEFT = 'l';
|
||||
public const POSITION_RIGHT = 'r';
|
||||
public const POSITION_TOP = 't';
|
||||
public const POSITION_TOPRIGHT = 'tr';
|
||||
|
||||
/**
|
||||
* Visible
|
||||
* Visible.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $visible = true;
|
||||
|
||||
/**
|
||||
* Position
|
||||
* Position.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $position = self::POSITION_RIGHT;
|
||||
|
||||
/**
|
||||
* OffsetX (as a fraction of the chart)
|
||||
* OffsetX (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetX = 0;
|
||||
|
||||
/**
|
||||
* OffsetY (as a fraction of the chart)
|
||||
* OffsetY (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetY = 0;
|
||||
|
||||
/**
|
||||
* Width (as a fraction of the chart)
|
||||
* Width (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $width = 0;
|
||||
|
||||
/**
|
||||
* Height (as a fraction of the chart)
|
||||
* Height (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $height = 0;
|
||||
|
||||
/**
|
||||
* Font
|
||||
* Font.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
* @var Font|null
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* Border
|
||||
* Border.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
private $border;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
* Fill.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
private $fill;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
* Alignment.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
private $alignment;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Legend instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Legend instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->font = new Font();
|
||||
$this->border = new Border();
|
||||
$this->fill = new Fill();
|
||||
$this->font = new Font();
|
||||
$this->border = new Border();
|
||||
$this->fill = new Fill();
|
||||
$this->alignment = new Alignment();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Visible
|
||||
* Get Visible.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
|
|
@ -127,19 +130,21 @@ class Legend implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
* Set Visible.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setVisible($value = true)
|
||||
{
|
||||
$this->visible = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Position
|
||||
* Get Position.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -149,130 +154,113 @@ class Legend implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Position
|
||||
* Set Position.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setPosition($value = self::POSITION_RIGHT)
|
||||
{
|
||||
$this->position = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get OffsetX (as a fraction of the chart).
|
||||
*/
|
||||
public function getOffsetX()
|
||||
public function getOffsetX(): float
|
||||
{
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
* Set OffsetX (as a fraction of the chart).
|
||||
*/
|
||||
public function setOffsetX($value = 0)
|
||||
public function setOffsetX(float $pValue = 0): self
|
||||
{
|
||||
$this->offsetX = (double)$value;
|
||||
$this->offsetX = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get OffsetY (as a fraction of the chart).
|
||||
*/
|
||||
public function getOffsetY()
|
||||
public function getOffsetY(): float
|
||||
{
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
* Set OffsetY (as a fraction of the chart).
|
||||
*/
|
||||
public function setOffsetY($value = 0)
|
||||
public function setOffsetY(float $pValue = 0): self
|
||||
{
|
||||
$this->offsetY = (double)$value;
|
||||
$this->offsetY = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get Width (as a fraction of the chart).
|
||||
*/
|
||||
public function getWidth()
|
||||
public function getWidth(): float
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
* Set Width (as a fraction of the chart).
|
||||
*/
|
||||
public function setWidth($value = 0)
|
||||
public function setWidth(float $pValue = 0): self
|
||||
{
|
||||
$this->width = (double)$value;
|
||||
$this->width = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get Height (as a fraction of the chart).
|
||||
*/
|
||||
public function getHeight()
|
||||
public function getHeight(): float
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
* Set Height (as a fraction of the chart).
|
||||
*/
|
||||
public function setHeight($value = 0)
|
||||
public function setHeight(float $value = 0): self
|
||||
{
|
||||
$this->height = (double)$value;
|
||||
$this->height = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
* Get font.
|
||||
*/
|
||||
public function getFont()
|
||||
public function getFont(): ?Font
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
* Set font.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
* @param Font|null $pFont Font
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
public function setFont(Font $pFont = null): self
|
||||
{
|
||||
$this->font = $pFont;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Border
|
||||
* Get Border.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Border
|
||||
*/
|
||||
|
|
@ -282,19 +270,19 @@ class Legend implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Border
|
||||
* Set Border.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Border $border
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setBorder(Border $border)
|
||||
{
|
||||
$this->border = $border;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill
|
||||
* Get Fill.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
|
|
@ -304,19 +292,19 @@ class Legend implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Fill
|
||||
* Set Fill.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $fill
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setFill(Fill $fill)
|
||||
{
|
||||
$this->fill = $fill;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
* Get alignment.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
|
|
@ -326,59 +314,61 @@ class Legend implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
* Set alignment.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Alignment $alignment
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
|
||||
*/
|
||||
public function setAlignment(Alignment $alignment)
|
||||
{
|
||||
$this->alignment = $alignment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
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__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return Legend
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
116
PhpOffice/PhpPresentation/Shape/Chart/Marker.php
Executable file → Normal file
116
PhpOffice/PhpPresentation/Shape/Chart/Marker.php
Executable file → Normal file
|
|
@ -10,30 +10,36 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
*/
|
||||
use PhpOffice\PhpPresentation\Style\Border;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
|
||||
class Marker
|
||||
{
|
||||
const SYMBOL_CIRCLE = 'circle';
|
||||
const SYMBOL_DASH = 'dash';
|
||||
const SYMBOL_DIAMOND = 'diamond';
|
||||
const SYMBOL_DOT = 'dot';
|
||||
const SYMBOL_NONE = 'none';
|
||||
const SYMBOL_PLUS = 'plus';
|
||||
const SYMBOL_SQUARE = 'square';
|
||||
const SYMBOL_STAR = 'star';
|
||||
const SYMBOL_TRIANGLE = 'triangle';
|
||||
const SYMBOL_X = 'x';
|
||||
public const SYMBOL_CIRCLE = 'circle';
|
||||
public const SYMBOL_DASH = 'dash';
|
||||
public const SYMBOL_DIAMOND = 'diamond';
|
||||
public const SYMBOL_DOT = 'dot';
|
||||
public const SYMBOL_NONE = 'none';
|
||||
public const SYMBOL_PLUS = 'plus';
|
||||
public const SYMBOL_SQUARE = 'square';
|
||||
public const SYMBOL_STAR = 'star';
|
||||
public const SYMBOL_TRIANGLE = 'triangle';
|
||||
public const SYMBOL_X = 'x';
|
||||
|
||||
public static $arraySymbol = array(
|
||||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public static $arraySymbol = [
|
||||
self::SYMBOL_CIRCLE,
|
||||
self::SYMBOL_DASH,
|
||||
self::SYMBOL_DIAMOND,
|
||||
|
|
@ -43,8 +49,8 @@ class Marker
|
|||
self::SYMBOL_SQUARE,
|
||||
self::SYMBOL_STAR,
|
||||
self::SYMBOL_TRIANGLE,
|
||||
self::SYMBOL_X
|
||||
);
|
||||
self::SYMBOL_X,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
|
@ -57,38 +63,82 @@ class Marker
|
|||
protected $size = 5;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @var Fill
|
||||
*/
|
||||
public function getSymbol()
|
||||
protected $fill;
|
||||
|
||||
/**
|
||||
* @var Border
|
||||
*/
|
||||
protected $border;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fill = new Fill();
|
||||
$this->border = new Border();
|
||||
}
|
||||
|
||||
public function getSymbol(): string
|
||||
{
|
||||
return $this->symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $symbol
|
||||
* @return $this
|
||||
*/
|
||||
public function setSymbol($symbol = self::SYMBOL_NONE)
|
||||
public function setSymbol(string $symbol = self::SYMBOL_NONE): self
|
||||
{
|
||||
$this->symbol = $symbol;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSize()
|
||||
public function getSize(): int
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $size
|
||||
* @return $this
|
||||
*/
|
||||
public function setSize($size = 5)
|
||||
public function setSize(int $size = 5): self
|
||||
{
|
||||
$this->size = $size;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Fill
|
||||
*/
|
||||
public function getFill(): Fill
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Fill $fill
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setFill(Fill $fill): self
|
||||
{
|
||||
$this->fill = $fill;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Border
|
||||
*/
|
||||
public function getBorder(): Border
|
||||
{
|
||||
return $this->border;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Border $border
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setBorder(Border $border): self
|
||||
{
|
||||
$this->border = $border;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
145
PhpOffice/PhpPresentation/Shape/Chart/PlotArea.php
Executable file → Normal file
145
PhpOffice/PhpPresentation/Shape/Chart/PlotArea.php
Executable file → Normal file
|
|
@ -10,108 +10,99 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Exception\UndefinedChartTypeException;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractType;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\PlotArea.
|
||||
*/
|
||||
class PlotArea implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Type
|
||||
* Type.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractType
|
||||
* @var AbstractType|null
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* Axis X
|
||||
* Axis X.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
* @var Axis
|
||||
*/
|
||||
private $axisX;
|
||||
|
||||
/**
|
||||
* Axis Y
|
||||
* Axis Y.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
* @var Axis
|
||||
*/
|
||||
private $axisY;
|
||||
|
||||
/**
|
||||
* OffsetX (as a fraction of the chart)
|
||||
* OffsetX (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetX = 0;
|
||||
|
||||
/**
|
||||
* OffsetY (as a fraction of the chart)
|
||||
* OffsetY (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetY = 0;
|
||||
|
||||
/**
|
||||
* Width (as a fraction of the chart)
|
||||
* Width (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $width = 0;
|
||||
|
||||
/**
|
||||
* Height (as a fraction of the chart)
|
||||
* Height (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $height = 0;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\PlotArea instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = null;
|
||||
$this->axisX = new Axis();
|
||||
$this->axisY = new Axis();
|
||||
}
|
||||
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->axisX = clone $this->axisX;
|
||||
$this->axisY = clone $this->axisY;
|
||||
$this->axisX = clone $this->axisX;
|
||||
$this->axisY = clone $this->axisY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
*
|
||||
* @return AbstractType
|
||||
* @throws \Exception
|
||||
* @throws UndefinedChartTypeException
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): AbstractType
|
||||
{
|
||||
if (is_null($this->type)) {
|
||||
throw new \Exception('Chart type has not been set.');
|
||||
throw new UndefinedChartTypeException();
|
||||
}
|
||||
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractType $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
public function setType(Type\AbstractType $value)
|
||||
public function setType(AbstractType $value): self
|
||||
{
|
||||
$this->type = $value;
|
||||
|
||||
|
|
@ -119,159 +110,141 @@ class PlotArea implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Axis X
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
* Get Axis X.
|
||||
*/
|
||||
public function getAxisX()
|
||||
public function getAxisX(): Axis
|
||||
{
|
||||
return $this->axisX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Axis Y
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
|
||||
* Get Axis Y.
|
||||
*/
|
||||
public function getAxisY()
|
||||
public function getAxisY(): Axis
|
||||
{
|
||||
return $this->axisY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get OffsetX (as a fraction of the chart).
|
||||
*/
|
||||
public function getOffsetX()
|
||||
public function getOffsetX(): float
|
||||
{
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
* Set OffsetX (as a fraction of the chart).
|
||||
*/
|
||||
public function setOffsetX($value = 0)
|
||||
public function setOffsetX(float $pValue = 0): self
|
||||
{
|
||||
$this->offsetX = (double)$value;
|
||||
$this->offsetX = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get OffsetY (as a fraction of the chart).
|
||||
*/
|
||||
public function getOffsetY()
|
||||
public function getOffsetY(): float
|
||||
{
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY (as a fraction of the chart)
|
||||
* Set OffsetY (as a fraction of the chart).
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
public function setOffsetY($value = 0)
|
||||
public function setOffsetY(float $pValue = 0): self
|
||||
{
|
||||
$this->offsetY = (double)$value;
|
||||
$this->offsetY = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get Width (as a fraction of the chart).
|
||||
*/
|
||||
public function getWidth()
|
||||
public function getWidth(): float
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
* Set Width (as a fraction of the chart).
|
||||
*/
|
||||
public function setWidth($value = 0)
|
||||
public function setWidth(int $pValue = 0): self
|
||||
{
|
||||
$this->width = (double)$value;
|
||||
$this->width = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get Height (as a fraction of the chart).
|
||||
*/
|
||||
public function getHeight()
|
||||
public function getHeight(): float
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height (as a fraction of the chart)
|
||||
* Set Height (as a fraction of the chart).
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
|
||||
*/
|
||||
public function setHeight($value = 0)
|
||||
public function setHeight(float $value = 0): self
|
||||
{
|
||||
$this->height = (double)$value;
|
||||
$this->height = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
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__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return PlotArea
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
366
PhpOffice/PhpPresentation/Shape/Chart/Series.php
Executable file → Normal file
366
PhpOffice/PhpPresentation/Shape/Chart/Series.php
Executable file → Normal file
|
|
@ -10,11 +10,14 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
|
@ -22,54 +25,49 @@ use PhpOffice\PhpPresentation\Style\Fill;
|
|||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
use PhpOffice\PhpPresentation\Style\Outline;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
class Series implements ComparableInterface
|
||||
{
|
||||
/* Label positions */
|
||||
const LABEL_BESTFIT = 'bestFit';
|
||||
const LABEL_BOTTOM = 'b';
|
||||
const LABEL_CENTER = 'ctr';
|
||||
const LABEL_INSIDEBASE = 'inBase';
|
||||
const LABEL_INSIDEEND = 'inEnd';
|
||||
const LABEL_LEFT = 'i';
|
||||
const LABEL_OUTSIDEEND = 'outEnd';
|
||||
const LABEL_RIGHT = 'r';
|
||||
const LABEL_TOP = 't';
|
||||
public const LABEL_BESTFIT = 'bestFit';
|
||||
public const LABEL_BOTTOM = 'b';
|
||||
public const LABEL_CENTER = 'ctr';
|
||||
public const LABEL_INSIDEBASE = 'inBase';
|
||||
public const LABEL_INSIDEEND = 'inEnd';
|
||||
public const LABEL_LEFT = 'i';
|
||||
public const LABEL_OUTSIDEEND = 'outEnd';
|
||||
public const LABEL_RIGHT = 'r';
|
||||
public const LABEL_TOP = 't';
|
||||
|
||||
/**
|
||||
* DataPointFills (key/value)
|
||||
* @var array
|
||||
* DataPointFills (key/value).
|
||||
*
|
||||
* @var array<int, Fill>
|
||||
*/
|
||||
protected $dataPointFills = array();
|
||||
protected $dataPointFills = [];
|
||||
|
||||
/**
|
||||
* Data Label Number Format
|
||||
* Data Label Number Format.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $DlblNumFormat = '';
|
||||
|
||||
/**
|
||||
* Separator
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $separator = null;
|
||||
protected $separator;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
* @var Fill|null
|
||||
*/
|
||||
protected $fill;
|
||||
|
||||
/**
|
||||
* Font
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
* @var Font|null
|
||||
*/
|
||||
protected $font;
|
||||
|
||||
/**
|
||||
* Label position
|
||||
* @var string
|
||||
*/
|
||||
protected $labelPosition = 'ctr';
|
||||
|
|
@ -80,98 +78,101 @@ class Series implements ComparableInterface
|
|||
protected $marker;
|
||||
|
||||
/**
|
||||
* @var Outline
|
||||
* @var Outline|null
|
||||
*/
|
||||
protected $outline;
|
||||
|
||||
/**
|
||||
* Show Category Name
|
||||
* @var boolean
|
||||
* Show Category Name.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $showCategoryName = false;
|
||||
|
||||
/**
|
||||
* Show Leader Lines
|
||||
* @var boolean
|
||||
* Show Leader Lines.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $showLeaderLines = true;
|
||||
|
||||
/**
|
||||
* Show Legend Key
|
||||
* @var boolean
|
||||
* Show Legend Key.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $showLegendKey = false;
|
||||
|
||||
/**
|
||||
* ShowPercentage
|
||||
* @var boolean
|
||||
* ShowPercentage.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $showPercentage = false;
|
||||
|
||||
/**
|
||||
* ShowSeriesName
|
||||
* @var boolean
|
||||
* ShowSeriesName.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $showSeriesName = false;
|
||||
|
||||
/**
|
||||
* ShowValue
|
||||
* @var boolean
|
||||
* ShowValue.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $showValue = true;
|
||||
|
||||
/**
|
||||
* Title
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $title = 'Series Title';
|
||||
|
||||
/**
|
||||
* Values (key/value)
|
||||
* @var array
|
||||
* Values (key/value).
|
||||
*
|
||||
* @var array<string, string|null>
|
||||
*/
|
||||
private $values = array();
|
||||
private $values = [];
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* @var string
|
||||
* Hash index.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Series instance
|
||||
*
|
||||
* @param string $title Title
|
||||
* @param array $values Values
|
||||
* @param string $title
|
||||
* @param array<string, string|null> $values
|
||||
*/
|
||||
public function __construct($title = 'Series Title', $values = array())
|
||||
public function __construct(string $title = 'Series Title', array $values = [])
|
||||
{
|
||||
$this->fill = new Fill();
|
||||
$this->font = new Font();
|
||||
$this->font->setName('Calibri');
|
||||
$this->font->setSize(9);
|
||||
$this->title = $title;
|
||||
$this->values = $values;
|
||||
$this->marker = new Marker();
|
||||
|
||||
$this->title = $title;
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* Get Title.
|
||||
*/
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* Set Title.
|
||||
*/
|
||||
public function setTitle($value = 'Series Title')
|
||||
public function setTitle(string $value = 'Series Title'): self
|
||||
{
|
||||
$this->title = $value;
|
||||
|
||||
|
|
@ -179,66 +180,50 @@ class Series implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Data Label NumFormat
|
||||
*
|
||||
* @return string
|
||||
* Get Data Label NumFormat.
|
||||
*/
|
||||
public function getDlblNumFormat()
|
||||
public function getDlblNumFormat(): string
|
||||
{
|
||||
return $this->DlblNumFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has Data Label NumFormat
|
||||
*
|
||||
* @return string
|
||||
* Has Data Label NumFormat.
|
||||
*/
|
||||
public function hasDlblNumFormat()
|
||||
public function hasDlblNumFormat(): bool
|
||||
{
|
||||
return !empty($this->DlblNumFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Data Label NumFormat
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* Set Data Label NumFormat.
|
||||
*/
|
||||
public function setDlblNumFormat($value = '')
|
||||
public function setDlblNumFormat(string $value = ''): self
|
||||
{
|
||||
$this->DlblNumFormat = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
* @return Fill
|
||||
*/
|
||||
public function getFill()
|
||||
public function getFill(): ?Fill
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $fill
|
||||
* @return Series
|
||||
*/
|
||||
public function setFill(Fill $fill = null)
|
||||
public function setFill(Fill $fill = null): self
|
||||
{
|
||||
$this->fill = $fill;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DataPointFill
|
||||
*
|
||||
* @param int $dataPointIndex Data point index.
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
* @param int $dataPointIndex data point index
|
||||
*/
|
||||
public function getDataPointFill($dataPointIndex)
|
||||
public function getDataPointFill(int $dataPointIndex): Fill
|
||||
{
|
||||
if (!isset($this->dataPointFills[$dataPointIndex])) {
|
||||
$this->dataPointFills[$dataPointIndex] = new Fill();
|
||||
|
|
@ -248,46 +233,44 @@ class Series implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get DataPointFills
|
||||
*
|
||||
* @return Fill[]
|
||||
*/
|
||||
public function getDataPointFills()
|
||||
public function getDataPointFills(): array
|
||||
{
|
||||
return $this->dataPointFills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Values
|
||||
* Get Values.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string|null>
|
||||
*/
|
||||
public function getValues()
|
||||
public function getValues(): array
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Values
|
||||
* Set Values.
|
||||
*
|
||||
* @param array $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* @param array<string, string|null> $values
|
||||
*/
|
||||
public function setValues($value = array())
|
||||
public function setValues(array $values = []): self
|
||||
{
|
||||
$this->values = $value;
|
||||
$this->values = $values;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Value
|
||||
* Add Value.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* @param string $key
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function addValue($key, $value)
|
||||
public function addValue(string $key, ?string $value): self
|
||||
{
|
||||
$this->values[$key] = $value;
|
||||
|
||||
|
|
@ -295,22 +278,17 @@ class Series implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get ShowSeriesName
|
||||
*
|
||||
* @return boolean
|
||||
* Get ShowSeriesName.
|
||||
*/
|
||||
public function hasShowSeriesName()
|
||||
public function hasShowSeriesName(): bool
|
||||
{
|
||||
return $this->showSeriesName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowSeriesName
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* Set ShowSeriesName.
|
||||
*/
|
||||
public function setShowSeriesName($value)
|
||||
public function setShowSeriesName(bool $value): self
|
||||
{
|
||||
$this->showSeriesName = $value;
|
||||
|
||||
|
|
@ -318,22 +296,17 @@ class Series implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get ShowCategoryName
|
||||
*
|
||||
* @return boolean
|
||||
* Get ShowCategoryName.
|
||||
*/
|
||||
public function hasShowCategoryName()
|
||||
public function hasShowCategoryName(): bool
|
||||
{
|
||||
return $this->showCategoryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowCategoryName
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* Set ShowCategoryName.
|
||||
*/
|
||||
public function setShowCategoryName($value)
|
||||
public function setShowCategoryName(bool $value): self
|
||||
{
|
||||
$this->showCategoryName = $value;
|
||||
|
||||
|
|
@ -341,45 +314,35 @@ class Series implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get ShowValue
|
||||
*
|
||||
* @return boolean
|
||||
* Get ShowValue.
|
||||
*/
|
||||
public function hasShowLegendKey()
|
||||
public function hasShowLegendKey(): bool
|
||||
{
|
||||
return $this->showLegendKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowValue
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* Set ShowValue.
|
||||
*/
|
||||
public function setShowLegendKey($value)
|
||||
public function setShowLegendKey(bool $value): self
|
||||
{
|
||||
$this->showLegendKey = (bool)$value;
|
||||
$this->showLegendKey = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowValue
|
||||
*
|
||||
* @return boolean
|
||||
* Get ShowValue.
|
||||
*/
|
||||
public function hasShowValue()
|
||||
public function hasShowValue(): bool
|
||||
{
|
||||
return $this->showValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowValue
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* Set ShowValue.
|
||||
*/
|
||||
public function setShowValue($value)
|
||||
public function setShowValue(bool $value): self
|
||||
{
|
||||
$this->showValue = $value;
|
||||
|
||||
|
|
@ -387,73 +350,54 @@ class Series implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get ShowPercentage
|
||||
*
|
||||
* @return boolean
|
||||
* Get ShowPercentage.
|
||||
*/
|
||||
public function hasShowPercentage()
|
||||
public function hasShowPercentage(): bool
|
||||
{
|
||||
return $this->showPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowPercentage
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* Set ShowPercentage.
|
||||
*/
|
||||
public function setShowPercentage($value)
|
||||
public function setShowPercentage(bool $value): self
|
||||
{
|
||||
$this->showPercentage = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowLeaderLines
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasShowSeparator()
|
||||
public function hasShowSeparator(): bool
|
||||
{
|
||||
return !is_null($this->separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Separator
|
||||
* @param string $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setSeparator($pValue)
|
||||
public function setSeparator(?string $pValue): self
|
||||
{
|
||||
$this->separator = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Separator
|
||||
* @return string
|
||||
*/
|
||||
public function getSeparator()
|
||||
public function getSeparator(): ?string
|
||||
{
|
||||
return $this->separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ShowLeaderLines
|
||||
*
|
||||
* @return boolean
|
||||
* Get ShowLeaderLines.
|
||||
*/
|
||||
public function hasShowLeaderLines()
|
||||
public function hasShowLeaderLines(): bool
|
||||
{
|
||||
return $this->showLeaderLines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ShowLeaderLines
|
||||
* Set ShowLeaderLines.
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* @param bool $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setShowLeaderLines($value)
|
||||
{
|
||||
|
|
@ -463,23 +407,21 @@ class Series implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
* Get font.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
* @return Font
|
||||
*/
|
||||
public function getFont()
|
||||
public function getFont(): ?Font
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
* Set font.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* @param Font|null $pFont Font
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
public function setFont(Font $pFont = null): self
|
||||
{
|
||||
$this->font = $pFont;
|
||||
|
||||
|
|
@ -487,105 +429,87 @@ class Series implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get label position
|
||||
*
|
||||
* @return string
|
||||
* Get label position.
|
||||
*/
|
||||
public function getLabelPosition()
|
||||
public function getLabelPosition(): string
|
||||
{
|
||||
return $this->labelPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set label position
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* Set label position.
|
||||
*/
|
||||
public function setLabelPosition($value)
|
||||
public function setLabelPosition(string $value): self
|
||||
{
|
||||
$this->labelPosition = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Marker
|
||||
*/
|
||||
public function getMarker()
|
||||
public function getMarker(): Marker
|
||||
{
|
||||
return $this->marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Marker $marker
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setMarker(Marker $marker)
|
||||
public function setMarker(Marker $marker): self
|
||||
{
|
||||
$this->marker = $marker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Outline
|
||||
*/
|
||||
public function getOutline()
|
||||
public function getOutline(): ?Outline
|
||||
{
|
||||
return $this->outline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Outline $outline
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
*/
|
||||
public function setOutline(Outline $outline)
|
||||
public function setOutline(?Outline $outline): self
|
||||
{
|
||||
$this->outline = $outline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
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__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* @param int $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value): self
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @link http://php.net/manual/en/language.oop5.cloning.php
|
||||
* @see http://php.net/manual/en/language.oop5.cloning.php
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
|
|
|
|||
144
PhpOffice/PhpPresentation/Shape/Chart/Title.php
Executable file → Normal file
144
PhpOffice/PhpPresentation/Shape/Chart/Title.php
Executable file → Normal file
|
|
@ -10,11 +10,14 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
|
@ -22,88 +25,88 @@ use PhpOffice\PhpPresentation\Style\Alignment;
|
|||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Title.
|
||||
*/
|
||||
class Title implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Visible
|
||||
* Visible.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $visible = true;
|
||||
|
||||
/**
|
||||
* Text
|
||||
* Text.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $text = 'Chart Title';
|
||||
|
||||
/**
|
||||
* OffsetX (as a fraction of the chart)
|
||||
* OffsetX (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetX = 0.01;
|
||||
|
||||
/**
|
||||
* OffsetY (as a fraction of the chart)
|
||||
* OffsetY (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $offsetY = 0.01;
|
||||
|
||||
/**
|
||||
* Width (as a fraction of the chart)
|
||||
* Width (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $width = 0;
|
||||
|
||||
/**
|
||||
* Height (as a fraction of the chart)
|
||||
* Height (as a fraction of the chart).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $height = 0;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
* Alignment.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
private $alignment;
|
||||
|
||||
/**
|
||||
* Font
|
||||
* Font.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Title instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Title instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->alignment = new Alignment();
|
||||
$this->font = new Font();
|
||||
$this->font = new Font();
|
||||
$this->font->setName('Calibri');
|
||||
$this->font->setSize(18);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Visible
|
||||
* Get Visible.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
|
|
@ -111,9 +114,10 @@ class Title implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
* Set Visible.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setVisible($value = true)
|
||||
|
|
@ -124,7 +128,7 @@ class Title implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Text
|
||||
* Get Text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -134,9 +138,10 @@ class Title implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Text
|
||||
* Set Text.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setText($value = null)
|
||||
|
|
@ -147,22 +152,17 @@ class Title implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get OffsetX (as a fraction of the chart).
|
||||
*/
|
||||
public function getOffsetX()
|
||||
public function getOffsetX(): float
|
||||
{
|
||||
return $this->offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX (as a fraction of the chart)
|
||||
*
|
||||
* @param float $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
* Set OffsetX (as a fraction of the chart).
|
||||
*/
|
||||
public function setOffsetX($value = 0.01)
|
||||
public function setOffsetX(float $value = 0.01): self
|
||||
{
|
||||
$this->offsetX = $value;
|
||||
|
||||
|
|
@ -170,92 +170,73 @@ class Title implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get OffsetY (as a fraction of the chart).
|
||||
*/
|
||||
public function getOffsetY()
|
||||
public function getOffsetY(): float
|
||||
{
|
||||
return $this->offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY (as a fraction of the chart)
|
||||
*
|
||||
* @param float $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
* Set OffsetY (as a fraction of the chart).
|
||||
*/
|
||||
public function setOffsetY($value = 0.01)
|
||||
public function setOffsetY(float $pValue = 0.01): self
|
||||
{
|
||||
$this->offsetY = $value;
|
||||
$this->offsetY = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get Width (as a fraction of the chart).
|
||||
*/
|
||||
public function getWidth()
|
||||
public function getWidth(): float
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
* Set Width (as a fraction of the chart).
|
||||
*/
|
||||
public function setWidth($value = 0)
|
||||
public function setWidth(float $pValue = 0): self
|
||||
{
|
||||
$this->width = (double)$value;
|
||||
$this->width = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height (as a fraction of the chart)
|
||||
*
|
||||
* @return float
|
||||
* Get Height (as a fraction of the chart).
|
||||
*/
|
||||
public function getHeight()
|
||||
public function getHeight(): float
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height (as a fraction of the chart)
|
||||
*
|
||||
* @param float|int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
* Set Height (as a fraction of the chart).
|
||||
*/
|
||||
public function setHeight($value = 0)
|
||||
public function setHeight(float $value = 0): self
|
||||
{
|
||||
$this->height = (double)$value;
|
||||
$this->height = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
* Get font.
|
||||
*/
|
||||
public function getFont()
|
||||
public function getFont(): ?Font
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
* Set font.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
* @param Font|null $pFont Font
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
public function setFont(Font $pFont = null): self
|
||||
{
|
||||
$this->font = $pFont;
|
||||
|
||||
|
|
@ -263,7 +244,7 @@ class Title implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
* Get alignment.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
*/
|
||||
|
|
@ -273,9 +254,8 @@ class Title implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
* Set alignment.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Alignment $alignment
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Title
|
||||
*/
|
||||
public function setAlignment(Alignment $alignment)
|
||||
|
|
@ -286,40 +266,42 @@ class Title implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
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__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return Title
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
99
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractType.php
Executable file → Normal file
99
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractType.php
Executable file → Normal file
|
|
@ -10,162 +10,141 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Chart\Series;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type.
|
||||
*/
|
||||
abstract class AbstractType implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Has Axis X?
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $hasAxisX = true;
|
||||
|
||||
/**
|
||||
* Has Axis Y?
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $hasAxisY = true;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
|
||||
/**
|
||||
* Data
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, Series>
|
||||
*/
|
||||
private $data = array();
|
||||
private $series = [];
|
||||
|
||||
/**
|
||||
* Has Axis X?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasAxisX()
|
||||
public function hasAxisX(): bool
|
||||
{
|
||||
return $this->hasAxisX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has Axis Y?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasAxisY()
|
||||
public function hasAxisY(): bool
|
||||
{
|
||||
return $this->hasAxisY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return AbstractType
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Series
|
||||
* Add Series.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Chart\Series $value
|
||||
* @return $this
|
||||
*/
|
||||
public function addSeries(Series $value)
|
||||
{
|
||||
$this->data[] = $value;
|
||||
$this->series[] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series
|
||||
* Get Series.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series[]
|
||||
* @return array<int, Series>
|
||||
*/
|
||||
public function getSeries()
|
||||
public function getSeries(): array
|
||||
{
|
||||
return $this->data;
|
||||
return $this->series;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series
|
||||
* Set Series.
|
||||
*
|
||||
* @param array<int, Series> $series
|
||||
*
|
||||
* @param array $value Array of \PhpOffice\PhpPresentation\Shape\Chart\Series
|
||||
* @return $this
|
||||
*/
|
||||
public function setSeries($value = array())
|
||||
public function setSeries(array $series = [])
|
||||
{
|
||||
$this->data = $value;
|
||||
$this->series = $series;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Data
|
||||
*
|
||||
* @deprecated getSeries
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->getSeries();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Data
|
||||
*
|
||||
* @deprecated setSeries
|
||||
* @param array $value
|
||||
* @return AbstractType
|
||||
*/
|
||||
public function setData($value = array())
|
||||
{
|
||||
return $this->setSeries($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @link http://php.net/manual/en/language.oop5.cloning.php
|
||||
* @see http://php.net/manual/en/language.oop5.cloning.php
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$arrayClone = array();
|
||||
foreach ($this->data as $itemSeries) {
|
||||
$arrayClone = [];
|
||||
foreach ($this->series as $itemSeries) {
|
||||
$arrayClone[] = clone $itemSeries;
|
||||
}
|
||||
$this->data = $arrayClone;
|
||||
$this->series = $arrayClone;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
89
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php
Executable file → Normal file
89
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php
Executable file → Normal file
|
|
@ -10,66 +10,75 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar.
|
||||
*/
|
||||
class AbstractTypeBar extends AbstractType
|
||||
{
|
||||
/** Orientation of bars */
|
||||
const DIRECTION_VERTICAL = 'col';
|
||||
const DIRECTION_HORIZONTAL = 'bar';
|
||||
public const DIRECTION_VERTICAL = 'col';
|
||||
public const DIRECTION_HORIZONTAL = 'bar';
|
||||
|
||||
/** Grouping of bars */
|
||||
const GROUPING_CLUSTERED = 'clustered'; //Chart series are drawn next to each other along the category axis.
|
||||
const GROUPING_STACKED = 'stacked'; //Chart series are drawn next to each other on the value axis.
|
||||
const GROUPING_PERCENTSTACKED = 'percentStacked'; //Chart series are drawn next to each other along the value axis and scaled to total 100%
|
||||
|
||||
public const GROUPING_CLUSTERED = 'clustered'; //Chart series are drawn next to each other along the category axis.
|
||||
public const GROUPING_STACKED = 'stacked'; //Chart series are drawn next to each other on the value axis.
|
||||
public const GROUPING_PERCENTSTACKED = 'percentStacked'; //Chart series are drawn next to each other along the value axis and scaled to total 100%
|
||||
|
||||
/**
|
||||
* Orientation of bars
|
||||
* Orientation of bars.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $barDirection = self::DIRECTION_VERTICAL;
|
||||
|
||||
|
||||
/**
|
||||
* Grouping of bars
|
||||
* Grouping of bars.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $barGrouping = self::GROUPING_CLUSTERED;
|
||||
|
||||
|
||||
/**
|
||||
* Space between bar or columns clusters
|
||||
* Space between bar or columns clusters.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $gapWidthPercent = 150;
|
||||
|
||||
/**
|
||||
* Overlap within bar or columns clusters. Value between 100 and -100 percent.
|
||||
* For stacked bar charts, the default overlap will be 100, for grouped bar charts 0.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $overlapWidthPercent = 0;
|
||||
|
||||
/**
|
||||
* Set bar orientation
|
||||
* Set bar orientation.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypeBar
|
||||
*/
|
||||
public function setBarDirection($value = self::DIRECTION_VERTICAL)
|
||||
{
|
||||
$this->barDirection = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get orientation
|
||||
* Get orientation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -79,19 +88,26 @@ class AbstractTypeBar extends AbstractType
|
|||
}
|
||||
|
||||
/**
|
||||
* Set bar grouping (stack or expanded style bar)
|
||||
* Set bar grouping (stack or expanded style bar).
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypeBar
|
||||
*/
|
||||
public function setBarGrouping($value = self::GROUPING_CLUSTERED)
|
||||
{
|
||||
$this->barGrouping = $value;
|
||||
$this->overlapWidthPercent = 0;
|
||||
|
||||
if ($value === self::GROUPING_STACKED || $value === self::GROUPING_PERCENTSTACKED) {
|
||||
$this->overlapWidthPercent = 100;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get grouping (stack or expanded style bar)
|
||||
* Get grouping (stack or expanded style bar).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -110,6 +126,7 @@ class AbstractTypeBar extends AbstractType
|
|||
|
||||
/**
|
||||
* @param int $gapWidthPercent
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setGapWidthPercent($gapWidthPercent)
|
||||
|
|
@ -121,20 +138,48 @@ class AbstractTypeBar extends AbstractType
|
|||
$gapWidthPercent = 500;
|
||||
}
|
||||
$this->gapWidthPercent = $gapWidthPercent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* @return int
|
||||
*/
|
||||
public function getOverlapWidthPercent(): int
|
||||
{
|
||||
return $this->overlapWidthPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $value overlap width percentage
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setOverlapWidthPercent(int $value): self
|
||||
{
|
||||
if ($value < -100) {
|
||||
$value = -100;
|
||||
}
|
||||
if ($value > 100) {
|
||||
$value = 100;
|
||||
}
|
||||
$this->overlapWidthPercent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
class AbstractTypeLine extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Is Line Smooth?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isSmooth = false;
|
||||
|
||||
/**
|
||||
* Is Line Smooth?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSmooth(): bool
|
||||
{
|
||||
return $this->isSmooth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Line Smoothness
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return AbstractTypeLine
|
||||
*/
|
||||
public function setIsSmooth(bool $value = true): AbstractTypeLine
|
||||
{
|
||||
$this->isSmooth = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->isSmooth() ? '1' : '0');
|
||||
}
|
||||
}
|
||||
40
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractTypePie.php
Executable file → Normal file
40
PhpOffice/PhpPresentation/Shape/Chart/Type/AbstractTypePie.php
Executable file → Normal file
|
|
@ -10,67 +10,67 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar.
|
||||
*/
|
||||
class AbstractTypePie extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Create a new self instance
|
||||
* Create a new self instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->hasAxisX = false;
|
||||
$this->hasAxisY = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Explosion of the Pie
|
||||
* Explosion of the Pie.
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $explosion = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set explosion
|
||||
*
|
||||
* @param integer $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypePie
|
||||
* Set explosion.
|
||||
*/
|
||||
public function setExplosion($value = 0)
|
||||
public function setExplosion(int $value = 0): self
|
||||
{
|
||||
$this->explosion = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get orientation
|
||||
*
|
||||
* @return string
|
||||
* Get orientation.
|
||||
*/
|
||||
public function getExplosion()
|
||||
public function getExplosion(): int
|
||||
{
|
||||
return $this->explosion;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
PhpOffice/PhpPresentation/Shape/Chart/Type/Area.php
Executable file → Normal file
12
PhpOffice/PhpPresentation/Shape/Chart/Type/Area.php
Executable file → Normal file
|
|
@ -10,31 +10,35 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Area
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Area.
|
||||
*/
|
||||
class Area extends AbstractType implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
PhpOffice/PhpPresentation/Shape/Chart/Type/Bar.php
Executable file → Normal file
11
PhpOffice/PhpPresentation/Shape/Chart/Type/Bar.php
Executable file → Normal file
|
|
@ -10,26 +10,29 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar.
|
||||
*/
|
||||
class Bar extends AbstractTypeBar implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
11
PhpOffice/PhpPresentation/Shape/Chart/Type/Bar3D.php
Executable file → Normal file
11
PhpOffice/PhpPresentation/Shape/Chart/Type/Bar3D.php
Executable file → Normal file
|
|
@ -10,26 +10,29 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D.
|
||||
*/
|
||||
class Bar3D extends AbstractTypeBar implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
19
PhpOffice/PhpPresentation/Shape/Chart/Type/Doughnut.php
Executable file → Normal file
19
PhpOffice/PhpPresentation/Shape/Chart/Type/Doughnut.php
Executable file → Normal file
|
|
@ -10,22 +10,26 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* self
|
||||
* self.
|
||||
*/
|
||||
class Doughnut extends AbstractTypePie implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Hole Size
|
||||
* Hole Size.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $holeSize = 50;
|
||||
|
|
@ -40,8 +44,10 @@ class Doughnut extends AbstractTypePie implements ComparableInterface
|
|||
|
||||
/**
|
||||
* @param int $holeSize
|
||||
*
|
||||
* @return Doughnut
|
||||
* @link https://msdn.microsoft.com/en-us/library/documentformat.openxml.drawing.charts.holesize(v=office.14).aspx
|
||||
*
|
||||
* @see https://msdn.microsoft.com/en-us/library/documentformat.openxml.drawing.charts.holesize(v=office.14).aspx
|
||||
*/
|
||||
public function setHoleSize($holeSize = 50)
|
||||
{
|
||||
|
|
@ -52,15 +58,16 @@ class Doughnut extends AbstractTypePie implements ComparableInterface
|
|||
$holeSize = 90;
|
||||
}
|
||||
$this->holeSize = $holeSize;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
17
PhpOffice/PhpPresentation/Shape/Chart/Type/Line.php
Executable file → Normal file
17
PhpOffice/PhpPresentation/Shape/Chart/Type/Line.php
Executable file → Normal file
|
|
@ -10,31 +10,32 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Line
|
||||
*/
|
||||
class Line extends AbstractType implements ComparableInterface
|
||||
class Line extends AbstractTypeLine implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
return md5($hash . __CLASS__);
|
||||
|
||||
return md5(parent::getHashCode() . $hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
PhpOffice/PhpPresentation/Shape/Chart/Type/Pie.php
Executable file → Normal file
11
PhpOffice/PhpPresentation/Shape/Chart/Type/Pie.php
Executable file → Normal file
|
|
@ -10,26 +10,29 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* self
|
||||
* self.
|
||||
*/
|
||||
class Pie extends AbstractTypePie implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
11
PhpOffice/PhpPresentation/Shape/Chart/Type/Pie3D.php
Executable file → Normal file
11
PhpOffice/PhpPresentation/Shape/Chart/Type/Pie3D.php
Executable file → Normal file
|
|
@ -10,26 +10,29 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* self
|
||||
* self.
|
||||
*/
|
||||
class Pie3D extends AbstractTypePie implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
41
PhpOffice/PhpPresentation/Shape/Chart/Type/Radar.php
Normal file
41
PhpOffice/PhpPresentation/Shape/Chart/Type/Radar.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
class Radar extends AbstractType implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
17
PhpOffice/PhpPresentation/Shape/Chart/Type/Scatter.php
Executable file → Normal file
17
PhpOffice/PhpPresentation/Shape/Chart/Type/Scatter.php
Executable file → Normal file
|
|
@ -10,31 +10,32 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Scatter
|
||||
*/
|
||||
class Scatter extends AbstractType implements ComparableInterface
|
||||
class Scatter extends AbstractTypeLine implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hash = '';
|
||||
foreach ($this->getSeries() as $series) {
|
||||
$hash .= $series->getHashCode();
|
||||
}
|
||||
return md5($hash . __CLASS__);
|
||||
|
||||
return md5(parent::getHashCode() . $hash . __CLASS__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
97
PhpOffice/PhpPresentation/Shape/Chart/View3D.php
Executable file → Normal file
97
PhpOffice/PhpPresentation/Shape/Chart/View3D.php
Executable file → Normal file
|
|
@ -10,78 +10,81 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Chart;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
* \PhpOffice\PhpPresentation\Shape\Chart\View3D.
|
||||
*/
|
||||
class View3D implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Rotation X
|
||||
* Rotation X.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $rotationX = 0;
|
||||
|
||||
/**
|
||||
* Rotation Y
|
||||
* Rotation Y.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $rotationY = 0;
|
||||
|
||||
/**
|
||||
* Right Angle Axes
|
||||
* Right Angle Axes.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $rightAngleAxes = true;
|
||||
|
||||
/**
|
||||
* Perspective
|
||||
* Perspective.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $perspective = 30;
|
||||
|
||||
/**
|
||||
* Height Percent
|
||||
* Height Percent.
|
||||
*
|
||||
* @var int
|
||||
* @var int|null
|
||||
*/
|
||||
private $heightPercent = 100;
|
||||
|
||||
/**
|
||||
* Depth Percent
|
||||
* Depth Percent.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $depthPercent = 100;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\View3D instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\View3D instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation X
|
||||
* Get Rotation X.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -91,9 +94,10 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Rotation X (-90 to 90)
|
||||
* Set Rotation X (-90 to 90).
|
||||
*
|
||||
* @param int $pValue
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
public function setRotationX($pValue = 0)
|
||||
|
|
@ -104,7 +108,7 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Rotation Y
|
||||
* Get Rotation Y.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -114,9 +118,10 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Rotation Y (-90 to 90)
|
||||
* Set Rotation Y (-90 to 90).
|
||||
*
|
||||
* @param int $pValue
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
public function setRotationY($pValue = 0)
|
||||
|
|
@ -127,9 +132,9 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get RightAngleAxes
|
||||
* Get RightAngleAxes.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRightAngleAxes()
|
||||
{
|
||||
|
|
@ -137,9 +142,10 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set RightAngleAxes
|
||||
* Set RightAngleAxes.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
public function setRightAngleAxes($value = true)
|
||||
|
|
@ -150,7 +156,7 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Perspective
|
||||
* Get Perspective.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -160,9 +166,10 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Perspective (0 to 100)
|
||||
* Set Perspective (0 to 100).
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
|
||||
*/
|
||||
public function setPerspective($value = 30)
|
||||
|
|
@ -173,7 +180,7 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get HeightPercent
|
||||
* Get HeightPercent.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -183,12 +190,9 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set HeightPercent (5 to 500)
|
||||
*
|
||||
* @param int $value
|
||||
* @return $this
|
||||
* Set HeightPercent (5 to 500).
|
||||
*/
|
||||
public function setHeightPercent($value = 100)
|
||||
public function setHeightPercent(?int $value = 100): self
|
||||
{
|
||||
$this->heightPercent = $value;
|
||||
|
||||
|
|
@ -196,19 +200,18 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get DepthPercent
|
||||
*
|
||||
* @return int
|
||||
* Get DepthPercent.
|
||||
*/
|
||||
public function getDepthPercent()
|
||||
public function getDepthPercent(): ?int
|
||||
{
|
||||
return $this->depthPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set DepthPercent (20 to 2000)
|
||||
* Set DepthPercent (20 to 2000).
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @param int $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setDepthPercent($value = 100)
|
||||
|
|
@ -219,40 +222,42 @@ class View3D implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->rotationX . $this->rotationY . ($this->rightAngleAxes ? 't' : 'f') . $this->perspective . $this->heightPercent . $this->depthPercent . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return View3D
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
47
PhpOffice/PhpPresentation/Shape/Comment.php
Executable file → Normal file
47
PhpOffice/PhpPresentation/Shape/Comment.php
Executable file → Normal file
|
|
@ -10,11 +10,14 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
|
|
@ -22,12 +25,12 @@ use PhpOffice\PhpPresentation\ComparableInterface;
|
|||
use PhpOffice\PhpPresentation\Shape\Comment\Author;
|
||||
|
||||
/**
|
||||
* Comment shape
|
||||
* Comment shape.
|
||||
*/
|
||||
class Comment extends AbstractShape implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* @var Author
|
||||
* @var Author|null
|
||||
*/
|
||||
protected $author;
|
||||
|
||||
|
|
@ -47,21 +50,15 @@ class Comment extends AbstractShape implements ComparableInterface
|
|||
$this->setDate(time());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Author
|
||||
*/
|
||||
public function getAuthor()
|
||||
public function getAuthor(): ?Author
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Author $author
|
||||
* @return Comment
|
||||
*/
|
||||
public function setAuthor(Author $author)
|
||||
public function setAuthor(Author $author): self
|
||||
{
|
||||
$this->author = $author;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -75,11 +72,13 @@ class Comment extends AbstractShape implements ComparableInterface
|
|||
|
||||
/**
|
||||
* @param int $dtComment timestamp of the comment
|
||||
*
|
||||
* @return Comment
|
||||
*/
|
||||
public function setDate($dtComment)
|
||||
{
|
||||
$this->dtComment = (int)$dtComment;
|
||||
$this->dtComment = (int) $dtComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -93,18 +92,20 @@ class Comment extends AbstractShape implements ComparableInterface
|
|||
|
||||
/**
|
||||
* @param string $text
|
||||
*
|
||||
* @return Comment
|
||||
*/
|
||||
public function setText($text = '')
|
||||
{
|
||||
$this->text = $text;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment has not height
|
||||
* Comment has not height.
|
||||
*
|
||||
* @return null
|
||||
* @return int|null
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
|
|
@ -112,20 +113,19 @@ class Comment extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
* Set Height.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeight($pValue = 0)
|
||||
public function setHeight(int $pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment has not width
|
||||
* Comment has not width.
|
||||
*
|
||||
* @return null
|
||||
* @return int|null
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
|
|
@ -133,12 +133,11 @@ class Comment extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
* Set Width.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setWidth($pValue = 0)
|
||||
public function setWidth(int $pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
28
PhpOffice/PhpPresentation/Shape/Comment/Author.php
Executable file → Normal file
28
PhpOffice/PhpPresentation/Shape/Comment/Author.php
Executable file → Normal file
|
|
@ -1,4 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Comment;
|
||||
|
||||
|
|
@ -29,11 +47,13 @@ class Author
|
|||
|
||||
/**
|
||||
* @param int $idxAuthor
|
||||
*
|
||||
* @return Author
|
||||
*/
|
||||
public function setIndex($idxAuthor)
|
||||
{
|
||||
$this->idxAuthor = (int) $idxAuthor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -47,11 +67,13 @@ class Author
|
|||
|
||||
/**
|
||||
* @param mixed $initials
|
||||
*
|
||||
* @return Author
|
||||
*/
|
||||
public function setInitials($initials)
|
||||
{
|
||||
$this->initials = $initials;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -65,20 +87,22 @@ class Author
|
|||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Author
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->getInitials() . $this->getName() . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
45
PhpOffice/PhpPresentation/Shape/Drawing/AbstractDrawingAdapter.php
Executable file → Normal file
45
PhpOffice/PhpPresentation/Shape/Drawing/AbstractDrawingAdapter.php
Executable file → Normal file
|
|
@ -1,4 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
|
|
@ -6,23 +24,18 @@ use PhpOffice\PhpPresentation\Shape\AbstractGraphic;
|
|||
|
||||
abstract class AbstractDrawingAdapter extends AbstractGraphic
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getContents();
|
||||
abstract public function getContents(): string;
|
||||
|
||||
abstract public function getExtension(): string;
|
||||
|
||||
abstract public function getIndexedFilename(): string;
|
||||
|
||||
abstract public function getMimeType(): string;
|
||||
|
||||
abstract public function getPath(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return self
|
||||
*/
|
||||
abstract public function getExtension();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getIndexedFilename();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getMimeType();
|
||||
abstract public function setPath(string $path);
|
||||
}
|
||||
|
|
|
|||
97
PhpOffice/PhpPresentation/Shape/Drawing/Base64.php
Executable file → Normal file
97
PhpOffice/PhpPresentation/Shape/Drawing/Base64.php
Executable file → Normal file
|
|
@ -1,7 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
use PhpOffice\PhpPresentation\Exception\UnauthorizedMimetypeException;
|
||||
|
||||
class Base64 extends AbstractDrawingAdapter
|
||||
{
|
||||
/**
|
||||
|
|
@ -10,20 +30,26 @@ class Base64 extends AbstractDrawingAdapter
|
|||
protected $data;
|
||||
|
||||
/**
|
||||
* Unique name
|
||||
* Unique name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $uniqueName;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $arrayMimeExtension = array(
|
||||
protected $arrayMimeExtension = [
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/png' => 'png',
|
||||
'image/gif' => 'gif',
|
||||
);
|
||||
'image/svg+xml' => 'svg',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Base64 constructor.
|
||||
|
|
@ -32,65 +58,58 @@ class Base64 extends AbstractDrawingAdapter
|
|||
{
|
||||
parent::__construct();
|
||||
$this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999));
|
||||
$this->data = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getData()
|
||||
public function getData(): string
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
* @return Base64
|
||||
*/
|
||||
public function setData($data)
|
||||
public function setData(string $data): self
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContents()
|
||||
public function getContents(): string
|
||||
{
|
||||
list(, $imageContents) = explode(';', $this->getData());
|
||||
list(, $imageContents) = explode(',', $imageContents);
|
||||
|
||||
return base64_decode($imageContents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @throws UnauthorizedMimetypeException
|
||||
*/
|
||||
public function getExtension()
|
||||
public function getExtension(): string
|
||||
{
|
||||
list($data, ) = explode(';', $this->getData());
|
||||
list($data) = explode(';', $this->getData());
|
||||
list(, $mime) = explode(':', $data);
|
||||
|
||||
if (!array_key_exists($mime, $this->arrayMimeExtension)) {
|
||||
throw new \Exception('Type Mime not found : "'.$mime.'"');
|
||||
throw new UnauthorizedMimetypeException($mime, $this->arrayMimeExtension);
|
||||
}
|
||||
|
||||
return $this->arrayMimeExtension[$mime];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
public function getIndexedFilename(): string
|
||||
{
|
||||
return $this->uniqueName . $this->getImageIndex() . '.' . $this->getExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType()
|
||||
public function getMimeType(): string
|
||||
{
|
||||
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);
|
||||
|
|
@ -98,6 +117,22 @@ class Base64 extends AbstractDrawingAdapter
|
|||
} else {
|
||||
$image = getimagesizefromstring($sImage);
|
||||
}
|
||||
|
||||
return image_type_to_mime_type($image[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Path.
|
||||
*/
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function setPath(string $path): self
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
78
PhpOffice/PhpPresentation/Shape/Drawing/File.php
Executable file → Normal file
78
PhpOffice/PhpPresentation/Shape/Drawing/File.php
Executable file → Normal file
|
|
@ -1,45 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
use PhpOffice\Common\File as CommonFile;
|
||||
use PhpOffice\PhpPresentation\Exception\FileNotFoundException;
|
||||
|
||||
class File extends AbstractDrawingAdapter
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
protected $path = '';
|
||||
|
||||
/**
|
||||
* Get Path
|
||||
*
|
||||
* @return string
|
||||
* Get Path.
|
||||
*/
|
||||
public function getPath()
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Path
|
||||
* Set Path.
|
||||
*
|
||||
* @param string $pValue File path
|
||||
* @param boolean $pVerifyFile Verify file
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Drawing\File
|
||||
* @param string $pValue File path
|
||||
* @param bool $pVerifyFile Verify file
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPath($pValue = '', $pVerifyFile = true)
|
||||
public function setPath(string $pValue = '', bool $pVerifyFile = true): self
|
||||
{
|
||||
if ($pVerifyFile) {
|
||||
if (!file_exists($pValue)) {
|
||||
throw new \Exception("File $pValue not found!");
|
||||
throw new FileNotFoundException($pValue);
|
||||
}
|
||||
}
|
||||
$this->path = $pValue;
|
||||
|
||||
if ($pVerifyFile) {
|
||||
if ($this->width == 0 && $this->height == 0) {
|
||||
if (0 == $this->width && 0 == $this->height) {
|
||||
list($this->width, $this->height) = getimagesize($this->getPath());
|
||||
}
|
||||
}
|
||||
|
|
@ -47,45 +66,40 @@ class File extends AbstractDrawingAdapter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContents()
|
||||
public function getContents(): string
|
||||
{
|
||||
return CommonFile::fileGetContents($this->getPath());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension()
|
||||
public function getExtension(): string
|
||||
{
|
||||
return pathinfo($this->getPath(), PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
* @return string
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function getMimeType()
|
||||
public function getMimeType(): string
|
||||
{
|
||||
if (!CommonFile::fileExists($this->getPath())) {
|
||||
throw new \Exception('File '.$this->getPath().' does not exist');
|
||||
throw new FileNotFoundException($this->getPath());
|
||||
}
|
||||
$image = getimagesizefromstring(CommonFile::fileGetContents($this->getPath()));
|
||||
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 string
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
public function getIndexedFilename(): string
|
||||
{
|
||||
$output = str_replace('.' . $this->getExtension(), '', pathinfo($this->getPath(), PATHINFO_FILENAME));
|
||||
$output .= $this->getImageIndex();
|
||||
$output .= '.'.$this->getExtension();
|
||||
$output .= '.' . $this->getExtension();
|
||||
$output = str_replace(' ', '_', $output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
112
PhpOffice/PhpPresentation/Shape/Drawing/Gd.php
Executable file → Normal file
112
PhpOffice/PhpPresentation/Shape/Drawing/Gd.php
Executable file → Normal file
|
|
@ -1,51 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
class Gd extends AbstractDrawingAdapter
|
||||
{
|
||||
/* Rendering functions */
|
||||
const RENDERING_DEFAULT = 'imagepng';
|
||||
const RENDERING_PNG = 'imagepng';
|
||||
const RENDERING_GIF = 'imagegif';
|
||||
const RENDERING_JPEG = 'imagejpeg';
|
||||
public const RENDERING_DEFAULT = 'imagepng';
|
||||
public const RENDERING_PNG = 'imagepng';
|
||||
public const RENDERING_GIF = 'imagegif';
|
||||
public const RENDERING_JPEG = 'imagejpeg';
|
||||
|
||||
/* MIME types */
|
||||
const MIMETYPE_DEFAULT = 'image/png';
|
||||
const MIMETYPE_PNG = 'image/png';
|
||||
const MIMETYPE_GIF = 'image/gif';
|
||||
const MIMETYPE_JPEG = 'image/jpeg';
|
||||
public const MIMETYPE_DEFAULT = 'image/png';
|
||||
public const MIMETYPE_PNG = 'image/png';
|
||||
public const MIMETYPE_GIF = 'image/gif';
|
||||
public const MIMETYPE_JPEG = 'image/jpeg';
|
||||
|
||||
/**
|
||||
* Image resource
|
||||
* Image resource.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
protected $imageResource;
|
||||
|
||||
/**
|
||||
* Rendering function
|
||||
* Rendering function.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $renderingFunction = self::RENDERING_DEFAULT;
|
||||
|
||||
/**
|
||||
* Mime type
|
||||
* Mime type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $mimeType = self::MIMETYPE_DEFAULT;
|
||||
|
||||
/**
|
||||
* Unique name
|
||||
* Unique name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $uniqueName;
|
||||
|
||||
/**
|
||||
* Gd constructor
|
||||
* Gd constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -54,7 +72,7 @@ class Gd extends AbstractDrawingAdapter
|
|||
}
|
||||
|
||||
/**
|
||||
* Get image resource
|
||||
* Get image resource.
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
|
|
@ -64,9 +82,10 @@ class Gd extends AbstractDrawingAdapter
|
|||
}
|
||||
|
||||
/**
|
||||
* Set image resource
|
||||
* Set image resource.
|
||||
*
|
||||
* @param resource $value
|
||||
*
|
||||
* @param $value resource
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageResource($value = null)
|
||||
|
|
@ -75,7 +94,7 @@ class Gd extends AbstractDrawingAdapter
|
|||
|
||||
if (!is_null($this->imageResource)) {
|
||||
// Get width/height
|
||||
$this->width = imagesx($this->imageResource);
|
||||
$this->width = imagesx($this->imageResource);
|
||||
$this->height = imagesy($this->imageResource);
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +102,7 @@ class Gd extends AbstractDrawingAdapter
|
|||
}
|
||||
|
||||
/**
|
||||
* Get rendering function
|
||||
* Get rendering function.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -93,71 +112,86 @@ class Gd extends AbstractDrawingAdapter
|
|||
}
|
||||
|
||||
/**
|
||||
* Set rendering function
|
||||
* Set rendering function.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setRenderingFunction($value = self::RENDERING_DEFAULT)
|
||||
{
|
||||
$this->renderingFunction = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mime type
|
||||
*
|
||||
* @return string
|
||||
* Get mime type.
|
||||
*/
|
||||
public function getMimeType()
|
||||
public function getMimeType(): string
|
||||
{
|
||||
return $this->mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mime type
|
||||
* Set mime type.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setMimeType($value = self::MIMETYPE_DEFAULT)
|
||||
{
|
||||
$this->mimeType = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContents()
|
||||
public function getContents(): string
|
||||
{
|
||||
ob_start();
|
||||
if ($this->getMimeType() === self::MIMETYPE_DEFAULT) {
|
||||
if (self::MIMETYPE_DEFAULT === $this->getMimeType()) {
|
||||
imagealphablending($this->getImageResource(), false);
|
||||
imagesavealpha($this->getImageResource(), true);
|
||||
}
|
||||
call_user_func($this->getRenderingFunction(), $this->getImageResource());
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $imageContents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension()
|
||||
public function getExtension(): string
|
||||
{
|
||||
$extension = strtolower($this->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
||||
return $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
public function getIndexedFilename(): string
|
||||
{
|
||||
return $this->uniqueName . $this->getImageIndex() . '.' . $this->getExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Get Path.
|
||||
*/
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function setPath(string $path): self
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
69
PhpOffice/PhpPresentation/Shape/Drawing/ZipFile.php
Executable file → Normal file
69
PhpOffice/PhpPresentation/Shape/Drawing/ZipFile.php
Executable file → Normal file
|
|
@ -1,8 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPPresentation - A pure PHP library for reading and writing
|
||||
* presentations documents.
|
||||
*
|
||||
* PHPPresentation is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
|
||||
use PhpOffice\Common\File as CommonFile;
|
||||
use PhpOffice\PhpPresentation\Exception\FileNotFoundException;
|
||||
|
||||
class ZipFile extends AbstractDrawingAdapter
|
||||
{
|
||||
|
|
@ -12,35 +31,34 @@ class ZipFile extends AbstractDrawingAdapter
|
|||
protected $path;
|
||||
|
||||
/**
|
||||
* Get Path
|
||||
*
|
||||
* @return string
|
||||
* Get Path.
|
||||
*/
|
||||
public function getPath()
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Path
|
||||
* Set Path.
|
||||
*
|
||||
* @param string $pValue File path
|
||||
*
|
||||
* @param string $pValue File path
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Drawing\ZipFile
|
||||
*/
|
||||
public function setPath($pValue = '')
|
||||
public function setPath(string $pValue = ''): self
|
||||
{
|
||||
$this->path = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function getContents()
|
||||
public function getContents(): string
|
||||
{
|
||||
if (!CommonFile::fileExists($this->getZipFileOut())) {
|
||||
throw new \Exception('File '.$this->getZipFileOut().' does not exist');
|
||||
throw new FileNotFoundException($this->getZipFileOut());
|
||||
}
|
||||
|
||||
$imageZip = new \ZipArchive();
|
||||
|
|
@ -48,26 +66,22 @@ class ZipFile extends AbstractDrawingAdapter
|
|||
$imageContents = $imageZip->getFromName($this->getZipFileIn());
|
||||
$imageZip->close();
|
||||
unset($imageZip);
|
||||
|
||||
return $imageContents;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension()
|
||||
public function getExtension(): string
|
||||
{
|
||||
return pathinfo($this->getZipFileIn(), PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function getMimeType()
|
||||
public function getMimeType(): string
|
||||
{
|
||||
if (!CommonFile::fileExists($this->getZipFileOut())) {
|
||||
throw new \Exception('File '.$this->getZipFileOut().' does not exist');
|
||||
throw new FileNotFoundException($this->getZipFileOut());
|
||||
}
|
||||
$oArchive = new \ZipArchive();
|
||||
$oArchive->open($this->getZipFileOut());
|
||||
|
|
@ -77,33 +91,34 @@ class ZipFile extends AbstractDrawingAdapter
|
|||
} else {
|
||||
$image = getimagesizefromstring($oArchive->getFromName($this->getZipFileIn()));
|
||||
}
|
||||
|
||||
return image_type_to_mime_type($image[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename()
|
||||
public function getIndexedFilename(): string
|
||||
{
|
||||
$output = pathinfo($this->getZipFileIn(), PATHINFO_FILENAME);
|
||||
$output = str_replace('.' . $this->getExtension(), '', $output);
|
||||
$output .= $this->getImageIndex();
|
||||
$output .= '.'.$this->getExtension();
|
||||
$output .= '.' . $this->getExtension();
|
||||
$output = str_replace(' ', '_', $output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function getZipFileOut()
|
||||
protected function getZipFileOut(): string
|
||||
{
|
||||
$path = str_replace('zip://', '', $this->getPath());
|
||||
$path = explode('#', $path);
|
||||
|
||||
return empty($path[0]) ? '' : $path[0];
|
||||
}
|
||||
|
||||
protected function getZipFileIn()
|
||||
protected function getZipFileIn(): string
|
||||
{
|
||||
$path = str_replace('zip://', '', $this->getPath());
|
||||
$path = explode('#', $path);
|
||||
|
||||
return empty($path[1]) ? '' : $path[1];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
210
PhpOffice/PhpPresentation/Shape/Group.php
Executable file → Normal file
210
PhpOffice/PhpPresentation/Shape/Group.php
Executable file → Normal file
|
|
@ -10,73 +10,68 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use ArrayObject;
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\GeometryCalculator;
|
||||
use PHPOffice\PhpPresentation\ShapeContainerInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText;
|
||||
use PhpOffice\PhpPresentation\Shape\Table;
|
||||
use PhpOffice\PhpPresentation\ShapeContainerInterface;
|
||||
|
||||
class Group extends AbstractShape implements ShapeContainerInterface
|
||||
{
|
||||
/**
|
||||
* Collection of shapes
|
||||
*
|
||||
* @var \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[]
|
||||
*/
|
||||
private $shapeCollection = null;
|
||||
* Collection of shapes.
|
||||
*
|
||||
* @var array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
private $shapeCollection;
|
||||
|
||||
/**
|
||||
* Extent X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
* Extent X.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $extentX;
|
||||
|
||||
/**
|
||||
* Extent Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
* Extent Y.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $extentY;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// For logic purposes.
|
||||
$this->offsetX = null;
|
||||
$this->offsetY = null;
|
||||
|
||||
// Shape collection
|
||||
$this->shapeCollection = new \ArrayObject();
|
||||
$this->shapeCollection = new ArrayObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of shapes
|
||||
*
|
||||
* @return \ArrayObject|AbstractShape[]
|
||||
*/
|
||||
* Get collection of shapes.
|
||||
*
|
||||
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
return $this->shapeCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shape to slide
|
||||
* Add shape to slide.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\AbstractShape $shape
|
||||
* @return \PhpOffice\PhpPresentation\AbstractShape
|
||||
* @throws \Exception
|
||||
* @return AbstractShape
|
||||
*/
|
||||
public function addShape(AbstractShape $shape)
|
||||
public function addShape(AbstractShape $shape): AbstractShape
|
||||
{
|
||||
$shape->setContainer($this);
|
||||
|
||||
|
|
@ -84,13 +79,11 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get X Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetX()
|
||||
* Get X Offset.
|
||||
*/
|
||||
public function getOffsetX(): int
|
||||
{
|
||||
if ($this->offsetX === null) {
|
||||
if (empty($this->offsetX)) {
|
||||
$offsets = GeometryCalculator::calculateOffsets($this);
|
||||
$this->offsetX = $offsets[GeometryCalculator::X];
|
||||
$this->offsetY = $offsets[GeometryCalculator::Y];
|
||||
|
|
@ -100,24 +93,21 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Ignores setting the X Offset, preserving the default behavior.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetX($pValue = 0)
|
||||
* Ignores setting the X Offset, preserving the default behavior.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetX(int $pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetY()
|
||||
* Get Y Offset.
|
||||
*/
|
||||
public function getOffsetY(): int
|
||||
{
|
||||
if ($this->offsetY === null) {
|
||||
if (empty($this->offsetY)) {
|
||||
$offsets = GeometryCalculator::calculateOffsets($this);
|
||||
$this->offsetX = $offsets[GeometryCalculator::X];
|
||||
$this->offsetY = $offsets[GeometryCalculator::Y];
|
||||
|
|
@ -127,24 +117,21 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Ignores setting the Y Offset, preserving the default behavior.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetY($pValue = 0)
|
||||
* Ignores setting the Y Offset, preserving the default behavior.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOffsetY(int $pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentX()
|
||||
* Get X Extent.
|
||||
*/
|
||||
public function getExtentX(): int
|
||||
{
|
||||
if ($this->extentX === null) {
|
||||
if (null === $this->extentX) {
|
||||
$extents = GeometryCalculator::calculateExtents($this);
|
||||
$this->extentX = $extents[GeometryCalculator::X] - $this->getOffsetX();
|
||||
$this->extentY = $extents[GeometryCalculator::Y] - $this->getOffsetY();
|
||||
|
|
@ -154,13 +141,11 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Y Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentY()
|
||||
* Get Y Extent.
|
||||
*/
|
||||
public function getExtentY(): int
|
||||
{
|
||||
if ($this->extentY === null) {
|
||||
if (null === $this->extentY) {
|
||||
$extents = GeometryCalculator::calculateExtents($this);
|
||||
$this->extentX = $extents[GeometryCalculator::X] - $this->getOffsetX();
|
||||
$this->extentY = $extents[GeometryCalculator::Y] - $this->getOffsetY();
|
||||
|
|
@ -170,34 +155,31 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Ignores setting the width, preserving the default behavior.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setWidth($pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignores setting the height, preserving the default behavior.
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeight($pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create rich text shape
|
||||
* Ignores setting the width, preserving the default behavior.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @throws \Exception
|
||||
* @return self
|
||||
*/
|
||||
public function createRichTextShape()
|
||||
public function setWidth(int $pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignores setting the height, preserving the default behavior.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeight(int $pValue = 0)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create rich text shape.
|
||||
*
|
||||
* @return RichText
|
||||
*/
|
||||
public function createRichTextShape(): RichText
|
||||
{
|
||||
$shape = new RichText();
|
||||
$this->addShape($shape);
|
||||
|
|
@ -206,16 +188,16 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create line shape
|
||||
* Create line shape.
|
||||
*
|
||||
* @param int $fromX Starting point x offset
|
||||
* @param int $fromY Starting point y offset
|
||||
* @param int $toX Ending point x offset
|
||||
* @param int $toY Ending point y offset
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Line
|
||||
* @throws \Exception
|
||||
* @param int $fromX Starting point x offset
|
||||
* @param int $fromY Starting point y offset
|
||||
* @param int $toX Ending point x offset
|
||||
* @param int $toY Ending point y offset
|
||||
*
|
||||
* @return Line
|
||||
*/
|
||||
public function createLineShape($fromX, $fromY, $toX, $toY)
|
||||
public function createLineShape(int $fromX, int $fromY, int $toX, int $toY): Line
|
||||
{
|
||||
$shape = new Line($fromX, $fromY, $toX, $toY);
|
||||
$this->addShape($shape);
|
||||
|
|
@ -224,12 +206,11 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create chart shape
|
||||
* Create chart shape.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Chart
|
||||
* @throws \Exception
|
||||
* @return Chart
|
||||
*/
|
||||
public function createChartShape()
|
||||
public function createChartShape(): Chart
|
||||
{
|
||||
$shape = new Chart();
|
||||
$this->addShape($shape);
|
||||
|
|
@ -238,12 +219,11 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create drawing shape
|
||||
* Create drawing shape.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Drawing\File
|
||||
* @throws \Exception
|
||||
* @return Drawing\File
|
||||
*/
|
||||
public function createDrawingShape()
|
||||
public function createDrawingShape(): Drawing\File
|
||||
{
|
||||
$shape = new Drawing\File();
|
||||
$this->addShape($shape);
|
||||
|
|
@ -252,13 +232,13 @@ class Group extends AbstractShape implements ShapeContainerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create table shape
|
||||
* Create table shape.
|
||||
*
|
||||
* @param int $columns Number of columns
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table
|
||||
* @throws \Exception
|
||||
* @param int $columns Number of columns
|
||||
*
|
||||
* @return Table
|
||||
*/
|
||||
public function createTableShape($columns = 1)
|
||||
public function createTableShape(int $columns = 1): Table
|
||||
{
|
||||
$shape = new Table($columns);
|
||||
$this->addShape($shape);
|
||||
|
|
|
|||
133
PhpOffice/PhpPresentation/Shape/Hyperlink.php
Executable file → Normal file
133
PhpOffice/PhpPresentation/Shape/Hyperlink.php
Executable file → Normal file
|
|
@ -10,84 +10,93 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
/**
|
||||
* Hyperlink element
|
||||
* Hyperlink element.
|
||||
*/
|
||||
class Hyperlink
|
||||
{
|
||||
/**
|
||||
* URL to link the shape to
|
||||
* URL to link the shape to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* Tooltip to display on the hyperlink
|
||||
* Tooltip to display on the hyperlink.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tooltip;
|
||||
|
||||
/**
|
||||
* Slide number to link to
|
||||
* Slide number to link to.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $slideNumber = null;
|
||||
|
||||
/**
|
||||
* Slide relation ID (should not be used by user code!)
|
||||
* Slide relation ID (should not be used by user code!).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $relationId = null;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* If true, uses the text color, instead of theme color
|
||||
*
|
||||
* @param string $pUrl Url to link the shape to
|
||||
* @param string $pTooltip Tooltip to display on the hyperlink
|
||||
* @throws \Exception
|
||||
* @var bool
|
||||
*/
|
||||
public function __construct($pUrl = '', $pTooltip = '')
|
||||
private $isTextColorUsed = false;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Hyperlink.
|
||||
*
|
||||
* @param string $pUrl Url to link the shape to
|
||||
* @param string $pTooltip Tooltip to display on the hyperlink
|
||||
*/
|
||||
public function __construct(string $pUrl = '', string $pTooltip = '')
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->setUrl($pUrl);
|
||||
$this->setTooltip($pTooltip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
* Get URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set URL
|
||||
* Set URL.
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setUrl($value = '')
|
||||
public function setUrl(string $value = ''): self
|
||||
{
|
||||
$this->url = $value;
|
||||
|
||||
|
|
@ -95,22 +104,23 @@ class Hyperlink
|
|||
}
|
||||
|
||||
/**
|
||||
* Get tooltip
|
||||
* Get tooltip.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTooltip()
|
||||
public function getTooltip(): string
|
||||
{
|
||||
return $this->tooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tooltip
|
||||
* Set tooltip.
|
||||
*
|
||||
* @param string $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setTooltip($value = '')
|
||||
public function setTooltip(string $value = ''): self
|
||||
{
|
||||
$this->tooltip = $value;
|
||||
|
||||
|
|
@ -118,72 +128,105 @@ class Hyperlink
|
|||
}
|
||||
|
||||
/**
|
||||
* Get slide number
|
||||
* Get slide number.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSlideNumber()
|
||||
public function getSlideNumber(): int
|
||||
{
|
||||
return $this->slideNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide number
|
||||
* Set slide number.
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* @param int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSlideNumber($value = 1)
|
||||
public function setSlideNumber(int $value = 1): self
|
||||
{
|
||||
$this->url = 'ppaction://hlinksldjump';
|
||||
$this->url = 'ppaction://hlinksldjump';
|
||||
$this->slideNumber = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this hyperlink internal? (to another slide)
|
||||
* Is this hyperlink internal? (to another slide).
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isInternal()
|
||||
public function isInternal(): bool
|
||||
{
|
||||
return strpos($this->url, 'ppaction://') !== false;
|
||||
return false !== strpos($this->url, 'ppaction://');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->url . $this->tooltip . __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether or not to use text color for a hyperlink, instead of theme color.
|
||||
*
|
||||
* @see https://docs.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/014fbc20-3705-4812-b8cd-93f5af05b504
|
||||
*
|
||||
* @return bool whether or not to use text color for a hyperlink, instead of theme color
|
||||
*/
|
||||
public function isTextColorUsed(): bool
|
||||
{
|
||||
return $this->isTextColorUsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not to use text color for a hyperlink, instead of theme color.
|
||||
*
|
||||
* @see https://docs.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/014fbc20-3705-4812-b8cd-93f5af05b504
|
||||
*
|
||||
* @param bool $isTextColorUsed
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setIsTextColorUsed(bool $isTextColorUsed): self
|
||||
{
|
||||
$this->isTextColorUsed = $isTextColorUsed;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
PhpOffice/PhpPresentation/Shape/Line.php
Executable file → Normal file
13
PhpOffice/PhpPresentation/Shape/Line.php
Executable file → Normal file
|
|
@ -10,11 +10,14 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
|
|
@ -22,12 +25,12 @@ use PhpOffice\PhpPresentation\ComparableInterface;
|
|||
use PhpOffice\PhpPresentation\Style\Border;
|
||||
|
||||
/**
|
||||
* Line shape
|
||||
* Line shape.
|
||||
*/
|
||||
class Line extends AbstractShape implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Line instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Line instance.
|
||||
*
|
||||
* @param int $fromX
|
||||
* @param int $fromY
|
||||
|
|
@ -46,11 +49,11 @@ class Line extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->getBorder()->getLineStyle() . parent::getHashCode() . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
14
PhpOffice/PhpPresentation/Shape/Media.php
Executable file → Normal file
14
PhpOffice/PhpPresentation/Shape/Media.php
Executable file → Normal file
|
|
@ -10,26 +10,25 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Shape\Drawing\File;
|
||||
|
||||
/**
|
||||
* Media element
|
||||
* Media element.
|
||||
*/
|
||||
class Media extends File implements ComparableInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType()
|
||||
public function getMimeType(): string
|
||||
{
|
||||
switch (strtolower($this->getExtension())) {
|
||||
case 'mp4':
|
||||
|
|
@ -44,6 +43,7 @@ class Media extends File implements ComparableInterface
|
|||
default:
|
||||
$mimetype = 'application/octet-stream';
|
||||
}
|
||||
|
||||
return $mimetype;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
61
PhpOffice/PhpPresentation/Shape/Placeholder.php
Executable file → Normal file
61
PhpOffice/PhpPresentation/Shape/Placeholder.php
Executable file → Normal file
|
|
@ -10,86 +10,75 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
class Placeholder
|
||||
{
|
||||
/** Placeholder Type constants */
|
||||
const PH_TYPE_BODY = 'body';
|
||||
const PH_TYPE_CHART = 'chart';
|
||||
const PH_TYPE_SUBTITLE = 'subTitle';
|
||||
const PH_TYPE_TITLE = 'title';
|
||||
const PH_TYPE_FOOTER = 'ftr';
|
||||
const PH_TYPE_DATETIME = 'dt';
|
||||
const PH_TYPE_SLIDENUM = 'sldNum';
|
||||
public const PH_TYPE_BODY = 'body';
|
||||
public const PH_TYPE_CHART = 'chart';
|
||||
public const PH_TYPE_SUBTITLE = 'subTitle';
|
||||
public const PH_TYPE_TITLE = 'title';
|
||||
public const PH_TYPE_FOOTER = 'ftr';
|
||||
public const PH_TYPE_DATETIME = 'dt';
|
||||
public const PH_TYPE_SLIDENUM = 'sldNum';
|
||||
|
||||
/**
|
||||
* hasCustomPrompt
|
||||
* Indicates whether the placeholder should have a customer prompt.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $hasCustomPrompt;
|
||||
|
||||
/**
|
||||
* idx
|
||||
* Specifies the index of the placeholder. This is used when applying templates or changing layouts to
|
||||
* match a placeholder on one template or master to another.
|
||||
*
|
||||
* @var int
|
||||
* @var int|null
|
||||
*/
|
||||
protected $idx;
|
||||
|
||||
/**
|
||||
* type
|
||||
* Specifies what content type the placeholder is to contains
|
||||
* Specifies what content type the placeholder is to contains.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Placeholder constructor.
|
||||
* @param $type
|
||||
*/
|
||||
public function __construct($type)
|
||||
public function __construct(string $type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $type
|
||||
* @return Placeholder
|
||||
*/
|
||||
public function setType($type)
|
||||
public function setType(string $type): self
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIdx()
|
||||
public function getIdx(): ?int
|
||||
{
|
||||
return $this->idx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $idx
|
||||
* @return Placeholder
|
||||
*/
|
||||
public function setIdx($idx)
|
||||
public function setIdx(int $idx): self
|
||||
{
|
||||
$this->idx = $idx;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
463
PhpOffice/PhpPresentation/Shape/RichText.php
Executable file → Normal file
463
PhpOffice/PhpPresentation/Shape/RichText.php
Executable file → Normal file
|
|
@ -10,74 +10,78 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\AbstractShape;
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Exception\OutOfBoundsException;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* \PhpOffice\PhpPresentation\Shape\RichText.
|
||||
*/
|
||||
class RichText extends AbstractShape implements ComparableInterface
|
||||
{
|
||||
/** Wrapping */
|
||||
const WRAP_NONE = 'none';
|
||||
const WRAP_SQUARE = 'square';
|
||||
public const WRAP_NONE = 'none';
|
||||
public const WRAP_SQUARE = 'square';
|
||||
|
||||
/** Autofit */
|
||||
const AUTOFIT_DEFAULT = 'spAutoFit';
|
||||
const AUTOFIT_SHAPE = 'spAutoFit';
|
||||
const AUTOFIT_NOAUTOFIT = 'noAutofit';
|
||||
const AUTOFIT_NORMAL = 'normAutofit';
|
||||
public const AUTOFIT_DEFAULT = 'spAutoFit';
|
||||
public const AUTOFIT_SHAPE = 'spAutoFit';
|
||||
public const AUTOFIT_NOAUTOFIT = 'noAutofit';
|
||||
public const AUTOFIT_NORMAL = 'normAutofit';
|
||||
|
||||
/** Overflow */
|
||||
const OVERFLOW_CLIP = 'clip';
|
||||
const OVERFLOW_OVERFLOW = 'overflow';
|
||||
public const OVERFLOW_CLIP = 'clip';
|
||||
public const OVERFLOW_OVERFLOW = 'overflow';
|
||||
|
||||
/**
|
||||
* Rich text paragraphs
|
||||
* Rich text paragraphs.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[]
|
||||
* @var array<Paragraph>
|
||||
*/
|
||||
private $richTextParagraphs;
|
||||
|
||||
/**
|
||||
* Active paragraph
|
||||
* Active paragraph.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $activeParagraph = 0;
|
||||
|
||||
/**
|
||||
* Text wrapping
|
||||
* Text wrapping.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $wrap = self::WRAP_SQUARE;
|
||||
|
||||
/**
|
||||
* Autofit
|
||||
* Autofit.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $autoFit = self::AUTOFIT_DEFAULT;
|
||||
|
||||
/**
|
||||
* Horizontal overflow
|
||||
* Horizontal overflow.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $horizontalOverflow = self::OVERFLOW_OVERFLOW;
|
||||
|
||||
/**
|
||||
* Vertical overflow
|
||||
* Vertical overflow.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -86,122 +90,125 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
/**
|
||||
* Text upright?
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $upright = false;
|
||||
|
||||
/**
|
||||
* Vertical text?
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $vertical = false;
|
||||
|
||||
/**
|
||||
* Number of columns (1 - 16)
|
||||
* Number of columns (1 - 16).
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $columns = 1;
|
||||
|
||||
/**
|
||||
* Bottom inset (in pixels)
|
||||
* The spacing between columns
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $columnSpacing = 0;
|
||||
|
||||
/**
|
||||
* Bottom inset (in pixels).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $bottomInset = 4.8;
|
||||
|
||||
/**
|
||||
* Left inset (in pixels)
|
||||
* Left inset (in pixels).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $leftInset = 9.6;
|
||||
|
||||
/**
|
||||
* Right inset (in pixels)
|
||||
* Right inset (in pixels).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $rightInset = 9.6;
|
||||
|
||||
/**
|
||||
* Top inset (in pixels)
|
||||
* Top inset (in pixels).
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $topInset = 4.8;
|
||||
|
||||
/**
|
||||
* Horizontal Auto Shrink
|
||||
* @var boolean
|
||||
* Horizontal Auto Shrink.
|
||||
*
|
||||
* @var bool|null
|
||||
*/
|
||||
private $autoShrinkHorizontal;
|
||||
|
||||
/**
|
||||
* Vertical Auto Shrink
|
||||
* @var boolean
|
||||
* Vertical Auto Shrink.
|
||||
*
|
||||
* @var bool|null
|
||||
*/
|
||||
private $autoShrinkVertical;
|
||||
|
||||
|
||||
/**
|
||||
* The percentage of the original font size to which the text is scaled
|
||||
* @var float
|
||||
* The percentage of the original font size to which the text is scaled.
|
||||
*
|
||||
* @var float|null
|
||||
*/
|
||||
private $fontScale;
|
||||
|
||||
|
||||
/**
|
||||
* The percentage of the reduction of the line spacing
|
||||
* @var float
|
||||
* The percentage of the reduction of the line spacing.
|
||||
*
|
||||
* @var float|null
|
||||
*/
|
||||
private $lnSpcReduction;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->richTextParagraphs = array(
|
||||
new Paragraph()
|
||||
);
|
||||
$this->activeParagraph = 0;
|
||||
$this->richTextParagraphs = [
|
||||
new Paragraph(),
|
||||
];
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active paragraph index
|
||||
* Get active paragraph index.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getActiveParagraphIndex()
|
||||
public function getActiveParagraphIndex(): int
|
||||
{
|
||||
return $this->activeParagraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active paragraph
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function getActiveParagraph()
|
||||
public function getActiveParagraph(): Paragraph
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active paragraph
|
||||
* Set active paragraph.
|
||||
*
|
||||
* @param int $index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function setActiveParagraph($index = 0)
|
||||
public function setActiveParagraph(int $index = 0): Paragraph
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new \Exception("Invalid paragraph count.");
|
||||
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index);
|
||||
}
|
||||
|
||||
$this->activeParagraph = $index;
|
||||
|
|
@ -210,38 +217,33 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get paragraph
|
||||
* Get paragraph.
|
||||
*
|
||||
* @param int $index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function getParagraph($index = 0)
|
||||
public function getParagraph(int $index = 0): Paragraph
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new \Exception("Invalid paragraph count.");
|
||||
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index);
|
||||
}
|
||||
|
||||
return $this->richTextParagraphs[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create paragraph
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @throws \Exception
|
||||
* Create paragraph.
|
||||
*/
|
||||
public function createParagraph()
|
||||
public function createParagraph(): Paragraph
|
||||
{
|
||||
$numParagraphs = count($this->richTextParagraphs);
|
||||
if ($numParagraphs > 0) {
|
||||
$alignment = clone $this->getActiveParagraph()->getAlignment();
|
||||
$font = clone $this->getActiveParagraph()->getFont();
|
||||
$alignment = clone $this->getActiveParagraph()->getAlignment();
|
||||
$font = clone $this->getActiveParagraph()->getFont();
|
||||
$bulletStyle = clone $this->getActiveParagraph()->getBulletStyle();
|
||||
}
|
||||
|
||||
$this->richTextParagraphs[] = new Paragraph();
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
|
||||
if (isset($alignment)) {
|
||||
$this->getActiveParagraph()->setAlignment($alignment);
|
||||
|
|
@ -252,17 +254,18 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
if (isset($bulletStyle)) {
|
||||
$this->getActiveParagraph()->setBulletStyle($bulletStyle);
|
||||
}
|
||||
|
||||
return $this->getActiveParagraph();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
* Add text.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface $pText Rich text element
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param TextElementInterface|null $pText Rich text element
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function addText(TextElementInterface $pText = null)
|
||||
public function addText(TextElementInterface $pText = null): self
|
||||
{
|
||||
$this->richTextParagraphs[$this->activeParagraph]->addText($pText);
|
||||
|
||||
|
|
@ -270,51 +273,50 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create text (can not be formatted !)
|
||||
* Create text (can not be formatted !).
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement
|
||||
* @throws \Exception
|
||||
* @param string $pText Text
|
||||
*
|
||||
* @return RichText\TextElement
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
public function createText(string $pText = ''): RichText\TextElement
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createText($pText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create break
|
||||
* Create break.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\BreakElement
|
||||
* @throws \Exception
|
||||
* @return RichText\BreakElement
|
||||
*/
|
||||
public function createBreak()
|
||||
public function createBreak(): RichText\BreakElement
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createBreak();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text run (can be formatted)
|
||||
* Create text run (can be formatted).
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Run
|
||||
* @throws \Exception
|
||||
* @param string $pText Text
|
||||
*
|
||||
* @return RichText\Run
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
public function createTextRun(string $pText = ''): RichText\Run
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createTextRun($pText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
* Get plain text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlainText()
|
||||
public function getPlainText(): string
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop trough all \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
// Loop trough all Paragraph
|
||||
foreach ($this->richTextParagraphs as $p) {
|
||||
$returnValue .= $p->getPlainText();
|
||||
}
|
||||
|
|
@ -324,7 +326,7 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
* Convert to string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -334,50 +336,44 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get paragraphs
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[]
|
||||
* @return array<Paragraph>
|
||||
*/
|
||||
public function getParagraphs()
|
||||
public function getParagraphs(): array
|
||||
{
|
||||
return $this->richTextParagraphs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set paragraphs
|
||||
* Set paragraphs.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] $paragraphs Array of paragraphs
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param array<Paragraph> $paragraphs Array of paragraphs
|
||||
*/
|
||||
public function setParagraphs($paragraphs = null)
|
||||
public function setParagraphs(array $paragraphs = []): self
|
||||
{
|
||||
if (!is_array($paragraphs)) {
|
||||
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] array passed.");
|
||||
}
|
||||
|
||||
$this->richTextParagraphs = $paragraphs;
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text wrapping
|
||||
* Get text wrapping.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWrap()
|
||||
public function getWrap(): string
|
||||
{
|
||||
return $this->wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text wrapping
|
||||
* Set text wrapping.
|
||||
*
|
||||
* @param $value string
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setWrap($value = self::WRAP_SQUARE)
|
||||
public function setWrap(string $value = self::WRAP_SQUARE): self
|
||||
{
|
||||
$this->wrap = $value;
|
||||
|
||||
|
|
@ -385,51 +381,48 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get autofit
|
||||
* Get autofit.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAutoFit()
|
||||
public function getAutoFit(): string
|
||||
{
|
||||
return $this->autoFit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pourcentage of fontScale
|
||||
*
|
||||
* @return float
|
||||
* Get pourcentage of fontScale.
|
||||
*/
|
||||
public function getFontScale()
|
||||
public function getFontScale(): ?float
|
||||
{
|
||||
return $this->fontScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pourcentage of the line space reduction
|
||||
*
|
||||
* @return float
|
||||
* Get pourcentage of the line space reduction.
|
||||
*/
|
||||
public function getLineSpaceReduction()
|
||||
public function getLineSpaceReduction(): ?float
|
||||
{
|
||||
return $this->lnSpcReduction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set autofit
|
||||
* Set autofit.
|
||||
*
|
||||
* @param $value string
|
||||
* @param $fontScale float
|
||||
* @param $lnSpcReduction float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param string $value
|
||||
* @param float|null $fontScale
|
||||
* @param float|null $lnSpcReduction
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAutoFit($value = self::AUTOFIT_DEFAULT, $fontScale = null, $lnSpcReduction = null)
|
||||
public function setAutoFit(string $value = self::AUTOFIT_DEFAULT, float $fontScale = null, float $lnSpcReduction = null): self
|
||||
{
|
||||
$this->autoFit = $value;
|
||||
|
||||
|
||||
if (!is_null($fontScale)) {
|
||||
$this->fontScale = $fontScale;
|
||||
}
|
||||
|
||||
|
||||
if (!is_null($lnSpcReduction)) {
|
||||
$this->lnSpcReduction = $lnSpcReduction;
|
||||
}
|
||||
|
|
@ -438,22 +431,23 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get horizontal overflow
|
||||
* Get horizontal overflow.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontalOverflow()
|
||||
public function getHorizontalOverflow(): string
|
||||
{
|
||||
return $this->horizontalOverflow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set horizontal overflow
|
||||
* Set horizontal overflow.
|
||||
*
|
||||
* @param $value string
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setHorizontalOverflow($value = self::OVERFLOW_OVERFLOW)
|
||||
public function setHorizontalOverflow(string $value = self::OVERFLOW_OVERFLOW): self
|
||||
{
|
||||
$this->horizontalOverflow = $value;
|
||||
|
||||
|
|
@ -461,22 +455,23 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get vertical overflow
|
||||
* Get vertical overflow.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVerticalOverflow()
|
||||
public function getVerticalOverflow(): string
|
||||
{
|
||||
return $this->verticalOverflow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical overflow
|
||||
* Set vertical overflow.
|
||||
*
|
||||
* @param $value string
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setVerticalOverflow($value = self::OVERFLOW_OVERFLOW)
|
||||
public function setVerticalOverflow(string $value = self::OVERFLOW_OVERFLOW): self
|
||||
{
|
||||
$this->verticalOverflow = $value;
|
||||
|
||||
|
|
@ -484,22 +479,23 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get upright
|
||||
* Get upright.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isUpright()
|
||||
public function isUpright(): bool
|
||||
{
|
||||
return $this->upright;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical
|
||||
* Set vertical.
|
||||
*
|
||||
* @param $value boolean
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param bool $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setUpright($value = false)
|
||||
public function setUpright(bool $value = false): self
|
||||
{
|
||||
$this->upright = $value;
|
||||
|
||||
|
|
@ -507,22 +503,23 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get vertical
|
||||
* Get vertical.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isVertical()
|
||||
public function isVertical(): bool
|
||||
{
|
||||
return $this->vertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical
|
||||
* Set vertical.
|
||||
*
|
||||
* @param $value boolean
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param bool $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setVertical($value = false)
|
||||
public function setVertical(bool $value = false): self
|
||||
{
|
||||
$this->vertical = $value;
|
||||
|
||||
|
|
@ -530,26 +527,28 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get columns
|
||||
* Get columns.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColumns()
|
||||
public function getColumns(): int
|
||||
{
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set columns
|
||||
* Set columns.
|
||||
*
|
||||
* @param $value int
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param int $value
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function setColumns($value = 1)
|
||||
public function setColumns(int $value = 1): self
|
||||
{
|
||||
if ($value > 16 || $value < 1) {
|
||||
throw new \Exception('Number of columns should be 1-16');
|
||||
throw new OutOfBoundsException(1, 16, $value);
|
||||
}
|
||||
|
||||
$this->columns = $value;
|
||||
|
|
@ -558,22 +557,23 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get bottom inset
|
||||
* Get bottom inset.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getInsetBottom()
|
||||
public function getInsetBottom(): float
|
||||
{
|
||||
return $this->bottomInset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bottom inset
|
||||
* Set bottom inset.
|
||||
*
|
||||
* @param $value float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param float $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setInsetBottom($value = 4.8)
|
||||
public function setInsetBottom(float $value = 4.8): self
|
||||
{
|
||||
$this->bottomInset = $value;
|
||||
|
||||
|
|
@ -581,22 +581,23 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get left inset
|
||||
* Get left inset.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getInsetLeft()
|
||||
public function getInsetLeft(): float
|
||||
{
|
||||
return $this->leftInset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left inset
|
||||
* Set left inset.
|
||||
*
|
||||
* @param $value float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param float $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setInsetLeft($value = 9.6)
|
||||
public function setInsetLeft(float $value = 9.6): self
|
||||
{
|
||||
$this->leftInset = $value;
|
||||
|
||||
|
|
@ -604,22 +605,23 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get right inset
|
||||
* Get right inset.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getInsetRight()
|
||||
public function getInsetRight(): float
|
||||
{
|
||||
return $this->rightInset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left inset
|
||||
* Set left inset.
|
||||
*
|
||||
* @param $value float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param float $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setInsetRight($value = 9.6)
|
||||
public function setInsetRight(float $value = 9.6): self
|
||||
{
|
||||
$this->rightInset = $value;
|
||||
|
||||
|
|
@ -627,84 +629,115 @@ class RichText extends AbstractShape implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get top inset
|
||||
* Get top inset.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getInsetTop()
|
||||
public function getInsetTop(): float
|
||||
{
|
||||
return $this->topInset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top inset
|
||||
* Set top inset.
|
||||
*
|
||||
* @param $value float
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText
|
||||
* @param float $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setInsetTop($value = 4.8)
|
||||
public function setInsetTop(float $value = 4.8): self
|
||||
{
|
||||
$this->topInset = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set horizontal auto shrink
|
||||
* @param bool $value
|
||||
* @return RichText
|
||||
*/
|
||||
public function setAutoShrinkHorizontal($value = null)
|
||||
public function setAutoShrinkHorizontal(bool $value = null): self
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->autoShrinkHorizontal = $value;
|
||||
}
|
||||
$this->autoShrinkHorizontal = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get horizontal auto shrink
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAutoShrinkHorizontal()
|
||||
|
||||
public function hasAutoShrinkHorizontal(): ?bool
|
||||
{
|
||||
return $this->autoShrinkHorizontal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical auto shrink
|
||||
* @param bool $value
|
||||
* Set vertical auto shrink.
|
||||
*
|
||||
* @return RichText
|
||||
*/
|
||||
public function setAutoShrinkVertical($value = null)
|
||||
public function setAutoShrinkVertical(bool $value = null): self
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
$this->autoShrinkVertical = $value;
|
||||
}
|
||||
$this->autoShrinkVertical = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set vertical auto shrink
|
||||
* @return bool
|
||||
* Set vertical auto shrink.
|
||||
*/
|
||||
public function hasAutoShrinkVertical()
|
||||
public function hasAutoShrinkVertical(): ?bool
|
||||
{
|
||||
return $this->autoShrinkVertical;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get spacing between columns
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColumnSpacing(): int
|
||||
{
|
||||
return $this->columnSpacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set spacing between columns
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setColumnSpacing(int $value = 0): self
|
||||
{
|
||||
if ($value >= 0) {
|
||||
$this->columnSpacing = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->richTextParagraphs as $element) {
|
||||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5($hashElements . $this->wrap . $this->autoFit . $this->horizontalOverflow . $this->verticalOverflow . ($this->upright ? '1' : '0') . ($this->vertical ? '1' : '0') . $this->columns . $this->bottomInset . $this->leftInset . $this->rightInset . $this->topInset . parent::getHashCode() . __CLASS__);
|
||||
return md5(
|
||||
$hashElements
|
||||
. $this->wrap
|
||||
. $this->autoFit
|
||||
. $this->horizontalOverflow
|
||||
. $this->verticalOverflow
|
||||
. ($this->upright ? '1' : '0')
|
||||
. ($this->vertical ? '1' : '0')
|
||||
. $this->columns
|
||||
. $this->columnSpacing
|
||||
. $this->bottomInset
|
||||
. $this->leftInset
|
||||
. $this->rightInset
|
||||
. $this->topInset
|
||||
. parent::getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
43
PhpOffice/PhpPresentation/Shape/RichText/BreakElement.php
Executable file → Normal file
43
PhpOffice/PhpPresentation/Shape/RichText/BreakElement.php
Executable file → Normal file
|
|
@ -10,27 +10,32 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* Rich text break
|
||||
* Rich text break.
|
||||
*/
|
||||
class BreakElement implements TextElementInterface
|
||||
{
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\Break instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\Break instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
* Get text.
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
|
|
@ -40,53 +45,47 @@ class BreakElement implements TextElementInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
* Set text.
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
* @param string $pText Text value
|
||||
*/
|
||||
public function setText($pText = '')
|
||||
public function setText($pText = ''): self
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
* Get font.
|
||||
*/
|
||||
public function getFont()
|
||||
public function getFont(): ?Font
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
* Set language.
|
||||
*
|
||||
* @param $lang
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
* @param string $lang
|
||||
*/
|
||||
public function setLanguage($lang)
|
||||
public function setLanguage($lang): self
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
* @return string Language
|
||||
* Get language.
|
||||
*/
|
||||
public function getLanguage()
|
||||
public function getLanguage(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5(__CLASS__);
|
||||
}
|
||||
|
|
|
|||
260
PhpOffice/PhpPresentation/Shape/RichText/Paragraph.php
Executable file → Normal file
260
PhpOffice/PhpPresentation/Shape/RichText/Paragraph.php
Executable file → Normal file
|
|
@ -10,11 +10,14 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
|
|
@ -23,79 +26,90 @@ use PhpOffice\PhpPresentation\Style\Bullet;
|
|||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* \PhpOffice\PhpPresentation\Shape\RichText\Paragraph.
|
||||
*/
|
||||
class Paragraph implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Rich text elements
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface[]
|
||||
*/
|
||||
private $richTextElements;
|
||||
public const LINE_SPACING_MODE_PERCENT = 'percent';
|
||||
public const LINE_SPACING_MODE_POINT = 'point';
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
* Rich text elements.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Alignment
|
||||
* @var array<TextElementInterface>
|
||||
*/
|
||||
private $richTextElements = [];
|
||||
|
||||
/**
|
||||
* Alignment.
|
||||
*
|
||||
* @var Alignment
|
||||
*/
|
||||
private $alignment;
|
||||
|
||||
/**
|
||||
* Font
|
||||
* Font.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
* @var Font|null
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* Bullet style
|
||||
* Bullet style.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Bullet
|
||||
* @var Bullet
|
||||
*/
|
||||
private $bulletStyle;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $lineSpacing = 100;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $lineSpacingMode = self::LINE_SPACING_MODE_PERCENT;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $spacingBefore = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $spacingAfter = 0;
|
||||
|
||||
/**
|
||||
* Hash index.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\Paragraph instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\Paragraph instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->richTextElements = array();
|
||||
$this->alignment = new Alignment();
|
||||
$this->font = new Font();
|
||||
$this->bulletStyle = new Bullet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Alignment
|
||||
* Get alignment.
|
||||
*/
|
||||
public function getAlignment()
|
||||
public function getAlignment(): Alignment
|
||||
{
|
||||
return $this->alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Alignment $alignment
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* Set alignment.
|
||||
*/
|
||||
public function setAlignment(Alignment $alignment)
|
||||
public function setAlignment(Alignment $alignment): self
|
||||
{
|
||||
$this->alignment = $alignment;
|
||||
|
||||
|
|
@ -103,23 +117,19 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
* Get font.
|
||||
*/
|
||||
public function getFont()
|
||||
public function getFont(): ?Font
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
* Set font.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @param Font|null $pFont Font
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
public function setFont(Font $pFont = null): self
|
||||
{
|
||||
$this->font = $pFont;
|
||||
|
||||
|
|
@ -127,23 +137,17 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get bullet style
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Bullet
|
||||
* Get bullet style.
|
||||
*/
|
||||
public function getBulletStyle()
|
||||
public function getBulletStyle(): ?Bullet
|
||||
{
|
||||
return $this->bulletStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bullet style
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Bullet $style
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
*/
|
||||
public function setBulletStyle(Bullet $style = null)
|
||||
public function setBulletStyle(Bullet $style = null): self
|
||||
{
|
||||
$this->bulletStyle = $style;
|
||||
|
||||
|
|
@ -151,13 +155,11 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create text (can not be formatted !)
|
||||
* Create text (can not be formatted !).
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement
|
||||
* @throws \Exception
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
public function createText(string $pText = ''): TextElement
|
||||
{
|
||||
$objText = new TextElement($pText);
|
||||
$this->addText($objText);
|
||||
|
|
@ -166,13 +168,11 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
* Add text.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface $pText Rich text element
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @param TextElementInterface|null $pText Rich text element
|
||||
*/
|
||||
public function addText(TextElementInterface $pText = null)
|
||||
public function addText(TextElementInterface $pText = null): self
|
||||
{
|
||||
$this->richTextElements[] = $pText;
|
||||
|
||||
|
|
@ -180,12 +180,9 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create break
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\BreakElement
|
||||
* @throws \Exception
|
||||
* Create break.
|
||||
*/
|
||||
public function createBreak()
|
||||
public function createBreak(): BreakElement
|
||||
{
|
||||
$objText = new BreakElement();
|
||||
$this->addText($objText);
|
||||
|
|
@ -194,13 +191,11 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create text run (can be formatted)
|
||||
* Create text run (can be formatted).
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Run
|
||||
* @throws \Exception
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
public function createTextRun(string $pText = ''): Run
|
||||
{
|
||||
$objText = new Run($pText);
|
||||
$objText->setFont(clone $this->font);
|
||||
|
|
@ -210,7 +205,7 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
* Convert to string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -220,16 +215,14 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
* @return string
|
||||
* Get plain text.
|
||||
*/
|
||||
public function getPlainText()
|
||||
public function getPlainText(): string
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop trough all \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
// Loop trough all TextElementInterface
|
||||
foreach ($this->richTextElements as $text) {
|
||||
if ($text instanceof TextElementInterface) {
|
||||
$returnValue .= $text->getText();
|
||||
|
|
@ -241,37 +234,33 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Rich Text elements
|
||||
* Get Rich Text elements.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface[]
|
||||
* @return array<TextElementInterface>
|
||||
*/
|
||||
public function getRichTextElements()
|
||||
public function getRichTextElements(): array
|
||||
{
|
||||
return $this->richTextElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich Text elements
|
||||
* Set Rich Text elements.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface[] $pElements Array of elements
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @param array<TextElementInterface> $pElements Array of elements
|
||||
*/
|
||||
public function setRichTextElements($pElements = null)
|
||||
public function setRichTextElements(array $pElements = []): self
|
||||
{
|
||||
if (!is_array($pElements)) {
|
||||
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface[] array passed.");
|
||||
}
|
||||
$this->richTextElements = $pElements;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->richTextElements as $element) {
|
||||
|
|
@ -282,46 +271,127 @@ class Paragraph implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLineSpacing()
|
||||
public function getLineSpacing(): int
|
||||
{
|
||||
return $this->lineSpacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value in points
|
||||
*
|
||||
* @param int $lineSpacing
|
||||
* @return Paragraph
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setLineSpacing($lineSpacing)
|
||||
public function setLineSpacing($lineSpacing): self
|
||||
{
|
||||
$this->lineSpacing = $lineSpacing;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLineSpacingMode(): string
|
||||
{
|
||||
return $this->lineSpacingMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $lineSpacingMode
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setLineSpacingMode(string $lineSpacingMode): self
|
||||
{
|
||||
if (in_array($lineSpacingMode, [
|
||||
self::LINE_SPACING_MODE_PERCENT,
|
||||
self::LINE_SPACING_MODE_POINT,
|
||||
])) {
|
||||
$this->lineSpacingMode = $lineSpacingMode;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value in points
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpacingBefore(): int
|
||||
{
|
||||
return $this->spacingBefore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value in points
|
||||
*
|
||||
* @param int $spacingBefore
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSpacingBefore(int $spacingBefore): self
|
||||
{
|
||||
$this->spacingBefore = $spacingBefore;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value in points
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpacingAfter(): int
|
||||
{
|
||||
return $this->spacingAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value in points
|
||||
*
|
||||
* @param int $spacingAfter
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSpacingAfter(int $spacingAfter): self
|
||||
{
|
||||
$this->spacingAfter = $spacingAfter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
PhpOffice/PhpPresentation/Shape/RichText/Run.php
Executable file → Normal file
27
PhpOffice/PhpPresentation/Shape/RichText/Run.php
Executable file → Normal file
|
|
@ -10,29 +10,32 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* Rich text run
|
||||
* Rich text run.
|
||||
*/
|
||||
class Run extends TextElement implements TextElementInterface
|
||||
{
|
||||
/**
|
||||
* Font
|
||||
* Font.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
private $font;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\Run instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\Run instance.
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
|
|
@ -44,20 +47,18 @@ class Run extends TextElement implements TextElementInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
* Get font.
|
||||
*/
|
||||
public function getFont()
|
||||
public function getFont(): Font
|
||||
{
|
||||
return $this->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
* Set font.
|
||||
*
|
||||
* @param Font|null $pFont Font
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setFont(Font $pFont = null)
|
||||
|
|
@ -68,11 +69,11 @@ class Run extends TextElement implements TextElementInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->getText() . $this->font->getHashCode() . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
60
PhpOffice/PhpPresentation/Shape/RichText/TextElement.php
Executable file → Normal file
60
PhpOffice/PhpPresentation/Shape/RichText/TextElement.php
Executable file → Normal file
|
|
@ -10,22 +10,26 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\Hyperlink;
|
||||
use PhpOffice\PhpPresentation\Style\Font;
|
||||
|
||||
/**
|
||||
* Rich text text element
|
||||
* Rich text text element.
|
||||
*/
|
||||
class TextElement implements TextElementInterface
|
||||
{
|
||||
/**
|
||||
* Text
|
||||
* Text.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -37,14 +41,14 @@ class TextElement implements TextElementInterface
|
|||
protected $language;
|
||||
|
||||
/**
|
||||
* Hyperlink
|
||||
* Hyperlink.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* @var Hyperlink|null
|
||||
*/
|
||||
protected $hyperlink;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\TextElement instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText\TextElement instance.
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
|
|
@ -55,7 +59,7 @@ class TextElement implements TextElementInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
* Get text.
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
|
|
@ -65,9 +69,10 @@ class TextElement implements TextElementInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
* Set text.
|
||||
*
|
||||
* @param string $pText Text value
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setText($pText = '')
|
||||
|
|
@ -78,32 +83,19 @@ class TextElement implements TextElementInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
* Get font.
|
||||
*/
|
||||
public function getFont()
|
||||
public function getFont(): ?Font
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has Hyperlink?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasHyperlink()
|
||||
public function hasHyperlink(): bool
|
||||
{
|
||||
return !is_null($this->hyperlink);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Hyperlink
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Hyperlink
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getHyperlink()
|
||||
public function getHyperlink(): Hyperlink
|
||||
{
|
||||
if (is_null($this->hyperlink)) {
|
||||
$this->hyperlink = new Hyperlink();
|
||||
|
|
@ -113,10 +105,8 @@ class TextElement implements TextElementInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Hyperlink
|
||||
* Set Hyperlink.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\Hyperlink $pHyperlink
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement
|
||||
*/
|
||||
public function setHyperlink(Hyperlink $pHyperlink = null)
|
||||
|
|
@ -127,7 +117,8 @@ class TextElement implements TextElementInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
* Get language.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLanguage()
|
||||
|
|
@ -136,22 +127,25 @@ class TextElement implements TextElementInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
* Set language.
|
||||
*
|
||||
* @param string $language
|
||||
*
|
||||
* @return TextElement
|
||||
*/
|
||||
public function setLanguage($language)
|
||||
{
|
||||
$this->language = $language;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
return md5($this->text . (is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
|
||||
}
|
||||
|
|
|
|||
21
PhpOffice/PhpPresentation/Shape/RichText/TextElementInterface.php
Executable file → Normal file
21
PhpOffice/PhpPresentation/Shape/RichText/TextElementInterface.php
Executable file → Normal file
|
|
@ -10,35 +10,39 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\RichText;
|
||||
|
||||
/**
|
||||
* Rich text element interface
|
||||
* Rich text element interface.
|
||||
*/
|
||||
interface TextElementInterface
|
||||
{
|
||||
/**
|
||||
* Get text
|
||||
* Get text.
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText();
|
||||
|
||||
/**
|
||||
* Set text
|
||||
* Set text.
|
||||
*
|
||||
* @param string $pText Text value
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setText($pText = '');
|
||||
|
||||
/**
|
||||
* Get font
|
||||
* Get font.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Font
|
||||
*/
|
||||
|
|
@ -51,14 +55,15 @@ interface TextElementInterface
|
|||
|
||||
/**
|
||||
* @param string $lang
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
|
||||
*/
|
||||
public function setLanguage($lang);
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
public function getHashCode(): string;
|
||||
}
|
||||
|
|
|
|||
76
PhpOffice/PhpPresentation/Shape/Table.php
Executable file → Normal file
76
PhpOffice/PhpPresentation/Shape/Table.php
Executable file → Normal file
|
|
@ -10,44 +10,46 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Exception\OutOfBoundsException;
|
||||
use PhpOffice\PhpPresentation\Shape\Table\Row;
|
||||
|
||||
/**
|
||||
* Table shape
|
||||
* Table shape.
|
||||
*/
|
||||
class Table extends AbstractGraphic implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Rows
|
||||
* Rows.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Table\Row[]
|
||||
* @var array<int, Row>
|
||||
*/
|
||||
private $rows;
|
||||
private $rows = [];
|
||||
|
||||
/**
|
||||
* Number of columns
|
||||
* Number of columns.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $columnCount = 1;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Table instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Table instance.
|
||||
*
|
||||
* @param int $columns Number of columns
|
||||
*/
|
||||
public function __construct($columns = 1)
|
||||
{
|
||||
// Initialise variables
|
||||
$this->rows = array();
|
||||
$this->columnCount = $columns;
|
||||
|
||||
// Initialize parent
|
||||
|
|
@ -58,43 +60,53 @@ class Table extends AbstractGraphic implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get row
|
||||
* Get row.
|
||||
*
|
||||
* @param int $row Row number
|
||||
* @param boolean $exceptionAsNull Return a null value instead of an exception?
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row
|
||||
* @param int $row Row number
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function getRow($row = 0, $exceptionAsNull = false)
|
||||
public function getRow(int $row = 0): Row
|
||||
{
|
||||
if (!isset($this->rows[$row])) {
|
||||
if ($exceptionAsNull) {
|
||||
return null;
|
||||
}
|
||||
throw new \Exception('Row number out of bounds.');
|
||||
throw new OutOfBoundsException(
|
||||
0,
|
||||
(count($this->rows) - 1) < 0 ? 0 : count($this->rows) - 1,
|
||||
$row
|
||||
);
|
||||
}
|
||||
|
||||
return $this->rows[$row];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows
|
||||
* @param int $row
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row[]
|
||||
* @return bool
|
||||
*/
|
||||
public function getRows()
|
||||
public function hasRow(int $row): bool
|
||||
{
|
||||
return isset($this->rows[$row]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows.
|
||||
*
|
||||
* @return Row[]
|
||||
*/
|
||||
public function getRows(): array
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create row
|
||||
* Create row.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row
|
||||
* @return Row
|
||||
*/
|
||||
public function createRow()
|
||||
public function createRow(): Row
|
||||
{
|
||||
$row = new Row($this->columnCount);
|
||||
$row = new Row($this->columnCount);
|
||||
$this->rows[] = $row;
|
||||
|
||||
return $row;
|
||||
|
|
@ -103,27 +115,29 @@ class Table extends AbstractGraphic implements ComparableInterface
|
|||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNumColumns()
|
||||
public function getNumColumns(): int
|
||||
{
|
||||
return $this->columnCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $numColumn
|
||||
* @return Table
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setNumColumns($numColumn)
|
||||
public function setNumColumns(int $numColumn): self
|
||||
{
|
||||
$this->columnCount = $numColumn;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->rows as $row) {
|
||||
|
|
|
|||
196
PhpOffice/PhpPresentation/Shape/Table/Cell.php
Executable file → Normal file
196
PhpOffice/PhpPresentation/Shape/Table/Cell.php
Executable file → Normal file
|
|
@ -10,90 +10,94 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Table;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Exception\OutOfBoundsException;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface;
|
||||
use PhpOffice\PhpPresentation\Style\Borders;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
|
||||
/**
|
||||
* Table cell
|
||||
* Table cell.
|
||||
*/
|
||||
class Cell implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Rich text paragraphs
|
||||
* Rich text paragraphs.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[]
|
||||
* @var array<Paragraph>
|
||||
*/
|
||||
private $richTextParagraphs;
|
||||
|
||||
/**
|
||||
* Active paragraph
|
||||
* Active paragraph.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $activeParagraph = 0;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
* Fill.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
private $fill;
|
||||
|
||||
/**
|
||||
* Borders
|
||||
* Borders.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Borders
|
||||
*/
|
||||
private $borders;
|
||||
|
||||
/**
|
||||
* Width (in pixels)
|
||||
* Width (in pixels).
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $width = 0;
|
||||
|
||||
/**
|
||||
* Colspan
|
||||
* Colspan.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $colSpan = 0;
|
||||
|
||||
/**
|
||||
* Rowspan
|
||||
* Rowspan.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $rowSpan = 0;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText instance
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\RichText instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->richTextParagraphs = array(
|
||||
new Paragraph()
|
||||
);
|
||||
$this->activeParagraph = 0;
|
||||
$this->richTextParagraphs = [
|
||||
new Paragraph(),
|
||||
];
|
||||
$this->activeParagraph = 0;
|
||||
|
||||
// Set fill
|
||||
$this->fill = new Fill();
|
||||
|
|
@ -103,7 +107,7 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get active paragraph index
|
||||
* Get active paragraph index.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -113,26 +117,24 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get active paragraph
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* Get active paragraph.
|
||||
*/
|
||||
public function getActiveParagraph()
|
||||
public function getActiveParagraph(): Paragraph
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active paragraph
|
||||
* Set active paragraph.
|
||||
*
|
||||
* @param int $index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @param int $index
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function setActiveParagraph($index = 0)
|
||||
public function setActiveParagraph($index = 0): Paragraph
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new \Exception("Invalid paragraph count.");
|
||||
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index);
|
||||
}
|
||||
|
||||
$this->activeParagraph = $index;
|
||||
|
|
@ -141,28 +143,25 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get paragraph
|
||||
* Get paragraph.
|
||||
*
|
||||
* @param int $index
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @param int $index
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function getParagraph($index = 0)
|
||||
public function getParagraph(int $index = 0): Paragraph
|
||||
{
|
||||
if ($index >= count($this->richTextParagraphs)) {
|
||||
throw new \Exception("Invalid paragraph count.");
|
||||
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index);
|
||||
}
|
||||
|
||||
return $this->richTextParagraphs[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create paragraph
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
* @throws \Exception
|
||||
* Create paragraph.
|
||||
*/
|
||||
public function createParagraph()
|
||||
public function createParagraph(): Paragraph
|
||||
{
|
||||
$this->richTextParagraphs[] = new Paragraph();
|
||||
$totalRichTextParagraphs = count($this->richTextParagraphs);
|
||||
|
|
@ -177,14 +176,15 @@ class Cell implements ComparableInterface
|
|||
$this->getActiveParagraph()->setFont($font);
|
||||
$this->getActiveParagraph()->setBulletStyle($bulletStyle);
|
||||
}
|
||||
|
||||
return $this->getActiveParagraph();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
* Add text.
|
||||
*
|
||||
* @param TextElementInterface $pText Rich text element
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface $pText Rich text element
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function addText(TextElementInterface $pText = null)
|
||||
|
|
@ -195,11 +195,11 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create text (can not be formatted !)
|
||||
* Create text (can not be formatted !).
|
||||
*
|
||||
* @param string $pText Text
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
|
|
@ -207,10 +207,9 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create break
|
||||
* Create break.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\BreakElement
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createBreak()
|
||||
{
|
||||
|
|
@ -218,19 +217,19 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Create text run (can be formatted)
|
||||
* Create text run (can be formatted).
|
||||
*
|
||||
* @param string $pText Text
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Run
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
public function createTextRun(string $pText = '')
|
||||
{
|
||||
return $this->richTextParagraphs[$this->activeParagraph]->createTextRun($pText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
* Get plain text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -239,7 +238,7 @@ class Cell implements ComparableInterface
|
|||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop trough all \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
|
||||
// Loop trough all Paragraph
|
||||
foreach ($this->richTextParagraphs as $p) {
|
||||
$returnValue .= $p->getPlainText();
|
||||
}
|
||||
|
|
@ -249,7 +248,7 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
* Convert to string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -259,9 +258,9 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get paragraphs
|
||||
* Get paragraphs.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[]
|
||||
* @return array<Paragraph>
|
||||
*/
|
||||
public function getParagraphs()
|
||||
{
|
||||
|
|
@ -269,24 +268,22 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set paragraphs
|
||||
* Set paragraphs.
|
||||
*
|
||||
* @param array<Paragraph> $paragraphs Array of paragraphs
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] $paragraphs Array of paragraphs
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setParagraphs($paragraphs = null)
|
||||
public function setParagraphs(array $paragraphs = []): self
|
||||
{
|
||||
if (!is_array($paragraphs)) {
|
||||
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] array passed.");
|
||||
}
|
||||
$this->richTextParagraphs = $paragraphs;
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
$this->activeParagraph = count($this->richTextParagraphs) - 1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fill
|
||||
* Get fill.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
*/
|
||||
|
|
@ -296,9 +293,8 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set fill
|
||||
* Set fill.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $fill
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setFill(Fill $fill)
|
||||
|
|
@ -309,7 +305,7 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get borders
|
||||
* Get borders.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Borders
|
||||
*/
|
||||
|
|
@ -319,9 +315,8 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set borders
|
||||
* Set borders.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Borders $borders
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setBorders(Borders $borders)
|
||||
|
|
@ -332,7 +327,7 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get width
|
||||
* Get width.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -342,58 +337,35 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set width
|
||||
* Set width.
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
* @return self
|
||||
*/
|
||||
public function setWidth($value = 0)
|
||||
public function setWidth(int $pValue = 0)
|
||||
{
|
||||
$this->width = $value;
|
||||
$this->width = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colSpan
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColSpan()
|
||||
public function getColSpan(): int
|
||||
{
|
||||
return $this->colSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set colSpan
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setColSpan($value = 0)
|
||||
public function setColSpan(int $value = 0): self
|
||||
{
|
||||
$this->colSpan = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rowSpan
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRowSpan()
|
||||
public function getRowSpan(): int
|
||||
{
|
||||
return $this->rowSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set rowSpan
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
*/
|
||||
public function setRowSpan($value = 0)
|
||||
public function setRowSpan(int $value = 0): self
|
||||
{
|
||||
$this->rowSpan = $value;
|
||||
|
||||
|
|
@ -401,11 +373,11 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->richTextParagraphs as $element) {
|
||||
|
|
@ -416,28 +388,32 @@ class Cell implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
143
PhpOffice/PhpPresentation/Shape/Table/Row.php
Executable file → Normal file
143
PhpOffice/PhpPresentation/Shape/Table/Row.php
Executable file → Normal file
|
|
@ -10,136 +10,154 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation\Shape\Table;
|
||||
|
||||
use PhpOffice\PhpPresentation\ComparableInterface;
|
||||
use PhpOffice\PhpPresentation\Exception\OutOfBoundsException;
|
||||
use PhpOffice\PhpPresentation\Style\Fill;
|
||||
|
||||
/**
|
||||
* Table row
|
||||
* Table row.
|
||||
*/
|
||||
class Row implements ComparableInterface
|
||||
{
|
||||
/**
|
||||
* Cells
|
||||
* Cells.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Shape\Table\Cell[]
|
||||
* @var Cell[]
|
||||
*/
|
||||
private $cells;
|
||||
private $cells = [];
|
||||
|
||||
/**
|
||||
* Fill
|
||||
* Fill.
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Style\Fill
|
||||
* @var Fill
|
||||
*/
|
||||
private $fill;
|
||||
|
||||
/**
|
||||
* Height (in pixels)
|
||||
* Height (in pixels).
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $height = 38;
|
||||
|
||||
/**
|
||||
* Active cell index
|
||||
* Active cell index.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $activeCellIndex = -1;
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
* Hash index.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $hashIndex;
|
||||
|
||||
/**
|
||||
* Create a new \PhpOffice\PhpPresentation\Shape\Table\Row instance
|
||||
*
|
||||
* @param int $columns Number of columns
|
||||
*/
|
||||
public function __construct($columns = 1)
|
||||
public function __construct(int $columns = 1)
|
||||
{
|
||||
// Initialise variables
|
||||
$this->cells = array();
|
||||
for ($i = 0; $i < $columns; $i++) {
|
||||
// Fill
|
||||
$this->fill = new Fill();
|
||||
// Cells
|
||||
for ($inc = 0; $inc < $columns; ++$inc) {
|
||||
$this->cells[] = new Cell();
|
||||
}
|
||||
|
||||
// Set fill
|
||||
$this->fill = new Fill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell
|
||||
* Get cell.
|
||||
*
|
||||
* @param int $cell Cell number
|
||||
* @param boolean $exceptionAsNull Return a null value instead of an exception?
|
||||
* @throws \Exception
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
* @param int $cell Cell number
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function getCell($cell = 0, $exceptionAsNull = false)
|
||||
public function getCell(int $cell = 0): Cell
|
||||
{
|
||||
if (!isset($this->cells[$cell])) {
|
||||
if ($exceptionAsNull) {
|
||||
return null;
|
||||
}
|
||||
throw new \Exception('Cell number out of bounds.');
|
||||
throw new OutOfBoundsException(
|
||||
0,
|
||||
(count($this->cells) - 1) < 0 ? count($this->cells) - 1 : 0,
|
||||
$cell
|
||||
);
|
||||
}
|
||||
|
||||
return $this->cells[$cell];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cells
|
||||
* Get cell.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell[]
|
||||
* @param int $cell Cell number
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getCells()
|
||||
public function hasCell(int $cell): bool
|
||||
{
|
||||
return isset($this->cells[$cell]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cells.
|
||||
*
|
||||
* @return array<Cell>
|
||||
*/
|
||||
public function getCells(): array
|
||||
{
|
||||
return $this->cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next cell (moves one cell to the right)
|
||||
* Next cell (moves one cell to the right).
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Cell
|
||||
* @throws \Exception
|
||||
* @return Cell
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function nextCell()
|
||||
public function nextCell(): Cell
|
||||
{
|
||||
$this->activeCellIndex++;
|
||||
++$this->activeCellIndex;
|
||||
if (isset($this->cells[$this->activeCellIndex])) {
|
||||
$this->cells[$this->activeCellIndex]->setFill(clone $this->getFill());
|
||||
|
||||
return $this->cells[$this->activeCellIndex];
|
||||
}
|
||||
throw new \Exception("Cell count out of bounds.");
|
||||
|
||||
throw new OutOfBoundsException(
|
||||
0,
|
||||
(count($this->cells) - 1) < 0 ? count($this->cells) - 1 : 0,
|
||||
$this->activeCellIndex
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fill
|
||||
* Get fill.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Style\Fill
|
||||
* @return Fill
|
||||
*/
|
||||
public function getFill()
|
||||
public function getFill(): Fill
|
||||
{
|
||||
return $this->fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fill
|
||||
* Set fill.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Style\Fill $fill
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row
|
||||
* @return self
|
||||
*/
|
||||
public function setFill(Fill $fill)
|
||||
public function setFill(Fill $fill): self
|
||||
{
|
||||
$this->fill = $fill;
|
||||
|
||||
|
|
@ -147,22 +165,23 @@ class Row implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get height
|
||||
* Get height.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight()
|
||||
public function getHeight(): int
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set height
|
||||
* Set height.
|
||||
*
|
||||
* @param int $value
|
||||
* @return \PhpOffice\PhpPresentation\Shape\Table\Row
|
||||
* @param int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setHeight($value = 0)
|
||||
public function setHeight(int $value = 0): self
|
||||
{
|
||||
$this->height = $value;
|
||||
|
||||
|
|
@ -170,11 +189,11 @@ class Row implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
* Get hash code.
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
public function getHashCode(): string
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->cells as $cell) {
|
||||
|
|
@ -185,28 +204,32 @@ class Row implements ComparableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
* Get hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
* @return int|null Hash index
|
||||
*/
|
||||
public function getHashIndex()
|
||||
public function getHashIndex(): ?int
|
||||
{
|
||||
return $this->hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
* Set hash index.
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
* @param int $value Hash index
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHashIndex($value)
|
||||
public function setHashIndex(int $value)
|
||||
{
|
||||
$this->hashIndex = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
60
PhpOffice/PhpPresentation/ShapeContainerInterface.php
Executable file → Normal file
60
PhpOffice/PhpPresentation/ShapeContainerInterface.php
Executable file → Normal file
|
|
@ -10,58 +10,56 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use ArrayObject;
|
||||
|
||||
/**
|
||||
* PhpOffice\PhpPresentation\ShapeContainerInterface
|
||||
* PhpOffice\PhpPresentation\ShapeContainerInterface.
|
||||
*/
|
||||
interface ShapeContainerInterface
|
||||
{
|
||||
/**
|
||||
* Get collection of shapes
|
||||
*
|
||||
* @return \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[]
|
||||
*/
|
||||
* Get collection of shapes.
|
||||
*
|
||||
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape>
|
||||
*/
|
||||
public function getShapeCollection();
|
||||
|
||||
/**
|
||||
* Add shape to slide
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\AbstractShape $shape
|
||||
* @return \PhpOffice\PhpPresentation\AbstractShape
|
||||
*/
|
||||
* Add shape to slide.
|
||||
*
|
||||
* @return AbstractShape
|
||||
*/
|
||||
public function addShape(AbstractShape $shape);
|
||||
|
||||
/**
|
||||
* Get X Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetX();
|
||||
* Get X Offset.
|
||||
*/
|
||||
public function getOffsetX(): int;
|
||||
|
||||
/**
|
||||
* Get Y Offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetY();
|
||||
* Get Y Offset.
|
||||
*/
|
||||
public function getOffsetY(): int;
|
||||
|
||||
/**
|
||||
* Get X Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentX();
|
||||
* Get X Extent.
|
||||
*/
|
||||
public function getExtentX(): int;
|
||||
|
||||
/**
|
||||
* Get Y Extent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExtentY();
|
||||
* Get Y Extent.
|
||||
*/
|
||||
public function getExtentY(): int;
|
||||
|
||||
public function getHashCode(): string;
|
||||
}
|
||||
|
|
|
|||
109
PhpOffice/PhpPresentation/Slide.php
Executable file → Normal file
109
PhpOffice/PhpPresentation/Slide.php
Executable file → Normal file
|
|
@ -10,66 +10,65 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPPresentation
|
||||
* @see https://github.com/PHPOffice/PHPPresentation
|
||||
*
|
||||
* @copyright 2009-2015 PHPPresentation contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpOffice\PhpPresentation;
|
||||
|
||||
use PhpOffice\PhpPresentation\Shape\Chart;
|
||||
use PhpOffice\PhpPresentation\Shape\RichText;
|
||||
use PhpOffice\PhpPresentation\Shape\Table;
|
||||
use PhpOffice\PhpPresentation\Slide\AbstractSlide;
|
||||
use PhpOffice\PhpPresentation\Slide\Note;
|
||||
use PhpOffice\PhpPresentation\Slide\SlideLayout;
|
||||
|
||||
/**
|
||||
* Slide class
|
||||
* Slide class.
|
||||
*/
|
||||
class Slide extends AbstractSlide implements ComparableInterface, ShapeContainerInterface
|
||||
{
|
||||
/**
|
||||
* The slide is shown in presentation
|
||||
* The slide is shown in presentation.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isVisible = true;
|
||||
|
||||
/**
|
||||
* Slide layout
|
||||
* Slide layout.
|
||||
*
|
||||
* @var SlideLayout
|
||||
* @var SlideLayout|null
|
||||
*/
|
||||
private $slideLayout;
|
||||
|
||||
/**
|
||||
* Slide master id
|
||||
* Slide master id.
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $slideMasterId = 1;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Slide\Note
|
||||
* @var Note
|
||||
*/
|
||||
private $slideNote;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \PhpOffice\PhpPresentation\Slide\Animation[]
|
||||
*/
|
||||
protected $animations = array();
|
||||
protected $animations = [];
|
||||
|
||||
/**
|
||||
* Name of the title
|
||||
* Name of the title.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Create a new slide
|
||||
* Create a new slide.
|
||||
*
|
||||
* @param PhpPresentation $pParent
|
||||
*/
|
||||
|
|
@ -89,32 +88,30 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
|
|||
$oSlideLayout = reset($arraySlideLayouts);
|
||||
$this->setSlideLayout($oSlideLayout);
|
||||
}
|
||||
// Set note
|
||||
$this->setNote(new Note());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide layout
|
||||
*
|
||||
* @return SlideLayout
|
||||
* Get slide layout.
|
||||
*/
|
||||
public function getSlideLayout()
|
||||
public function getSlideLayout(): ?SlideLayout
|
||||
{
|
||||
return $this->slideLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide layout
|
||||
*
|
||||
* @param SlideLayout $layout
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
* Set slide layout.
|
||||
*/
|
||||
public function setSlideLayout(SlideLayout $layout)
|
||||
public function setSlideLayout(SlideLayout $layout): self
|
||||
{
|
||||
$this->slideLayout = $layout;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide master id
|
||||
* Get slide master id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -124,9 +121,10 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
|
|||
}
|
||||
|
||||
/**
|
||||
* Set slide master id
|
||||
* Set slide master id.
|
||||
*
|
||||
* @param int $masterId
|
||||
*
|
||||
* @param int $masterId
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function setSlideMasterId($masterId = 1)
|
||||
|
|
@ -137,7 +135,7 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
|
|||
}
|
||||
|
||||
/**
|
||||
* Copy slide (!= clone!)
|
||||
* Copy slide (!= clone!).
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
|
|
@ -148,24 +146,12 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
|
|||
return $copied;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\Note
|
||||
*/
|
||||
public function getNote()
|
||||
public function getNote(): Note
|
||||
{
|
||||
if (is_null($this->slideNote)) {
|
||||
$this->setNote();
|
||||
}
|
||||
return $this->slideNote;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\Note $note
|
||||
* @return \PhpOffice\PhpPresentation\Slide
|
||||
*/
|
||||
public function setNote(Note $note = null)
|
||||
public function setNote(Note $note = null): self
|
||||
{
|
||||
$this->slideNote = (is_null($note) ? new Note() : $note);
|
||||
$this->slideNote->setParent($this);
|
||||
|
|
@ -174,27 +160,27 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the name of the slide
|
||||
* Get the name of the slide.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the slide
|
||||
* @param string $name
|
||||
* @return $this
|
||||
* Set the name of the slide.
|
||||
*/
|
||||
public function setName($name = null)
|
||||
public function setName(?string $name = null): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
|
|
@ -202,29 +188,33 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
|
|||
}
|
||||
|
||||
/**
|
||||
* @param boolean $value
|
||||
* @param bool $value
|
||||
*
|
||||
* @return Slide
|
||||
*/
|
||||
public function setIsVisible($value = true)
|
||||
{
|
||||
$this->isVisible = (bool)$value;
|
||||
$this->isVisible = (bool) $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an animation to the slide
|
||||
* Add an animation to the slide.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\Animation $animation
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\Animation
|
||||
* @return Slide
|
||||
*/
|
||||
public function addAnimation($animation)
|
||||
{
|
||||
$this->animations[] = $animation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of animations
|
||||
* Get collection of animations.
|
||||
*
|
||||
* @return \PhpOffice\PhpPresentation\Slide\Animation[]
|
||||
*/
|
||||
|
|
@ -234,13 +224,16 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
|
|||
}
|
||||
|
||||
/**
|
||||
* Set collection of animations
|
||||
* Set collection of animations.
|
||||
*
|
||||
* @param \PhpOffice\PhpPresentation\Slide\Animation[] $array
|
||||
*
|
||||
* @return Slide
|
||||
*/
|
||||
public function setAnimations(array $array = array())
|
||||
public function setAnimations(array $array = [])
|
||||
{
|
||||
$this->animations = $array;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user