1
This commit is contained in:
288
vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php
vendored
Normal file
288
vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php
vendored
Normal file
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use BadMethodCallException;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Container abstract class.
|
||||
*
|
||||
* @method Text addText(string $text, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method TextRun addTextRun(mixed $pStyle = null)
|
||||
* @method Bookmark addBookmark(string $name)
|
||||
* @method Link addLink(string $target, string $text = null, mixed $fStyle = null, mixed $pStyle = null, boolean $internal = false)
|
||||
* @method PreserveText addPreserveText(string $text, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method void addTextBreak(int $count = 1, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method ListItem addListItem(string $txt, int $depth = 0, mixed $font = null, mixed $list = null, mixed $para = null)
|
||||
* @method ListItemRun addListItemRun(int $depth = 0, mixed $listStyle = null, mixed $pStyle = null)
|
||||
* @method Footnote addFootnote(mixed $pStyle = null)
|
||||
* @method Endnote addEndnote(mixed $pStyle = null)
|
||||
* @method CheckBox addCheckBox(string $name, $text, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method Title addTitle(mixed $text, int $depth = 1)
|
||||
* @method TOC addTOC(mixed $fontStyle = null, mixed $tocStyle = null, int $minDepth = 1, int $maxDepth = 9)
|
||||
* @method PageBreak addPageBreak()
|
||||
* @method Table addTable(mixed $style = null)
|
||||
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false, $name = null)
|
||||
* @method OLEObject addOLEObject(string $source, mixed $style = null)
|
||||
* @method TextBox addTextBox(mixed $style = null)
|
||||
* @method Field addField(string $type = null, array $properties = array(), array $options = array(), mixed $text = null)
|
||||
* @method Line addLine(mixed $lineStyle = null)
|
||||
* @method Shape addShape(string $type, mixed $style = null)
|
||||
* @method Chart addChart(string $type, array $categories, array $values, array $style = null, $seriesName = null)
|
||||
* @method FormField addFormField(string $type, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method SDT addSDT(string $type)
|
||||
* @method \PhpOffice\PhpWord\Element\OLEObject addObject(string $source, mixed $style = null) deprecated, use addOLEObject instead
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
abstract class AbstractContainer extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Elements collection.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\AbstractElement[]
|
||||
*/
|
||||
protected $elements = [];
|
||||
|
||||
/**
|
||||
* Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Magic method to catch all 'addElement' variation.
|
||||
*
|
||||
* This removes addText, addTextRun, etc. When adding new element, we have to
|
||||
* add the model in the class docblock with `@method`.
|
||||
*
|
||||
* Warning: This makes capitalization matters, e.g. addCheckbox or addcheckbox won't work.
|
||||
*
|
||||
* @param mixed $function
|
||||
* @param mixed $args
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function __call($function, $args)
|
||||
{
|
||||
$elements = [
|
||||
'Text', 'TextRun', 'Bookmark', 'Link', 'PreserveText', 'TextBreak',
|
||||
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'OLEObject',
|
||||
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
|
||||
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
|
||||
'Chart', 'FormField', 'SDT', 'Comment',
|
||||
];
|
||||
$functions = [];
|
||||
foreach ($elements as $element) {
|
||||
$functions['add' . strtolower($element)] = $element == 'Object' ? 'OLEObject' : $element;
|
||||
}
|
||||
|
||||
// Run valid `add` command
|
||||
$function = strtolower($function);
|
||||
if (isset($functions[$function])) {
|
||||
$element = $functions[$function];
|
||||
|
||||
// Special case for TextBreak
|
||||
// @todo Remove the `$count` parameter in 1.0.0 to make this element similiar to other elements?
|
||||
if ($element == 'TextBreak') {
|
||||
[$count, $fontStyle, $paragraphStyle] = array_pad($args, 3, null);
|
||||
if ($count === null) {
|
||||
$count = 1;
|
||||
}
|
||||
for ($i = 1; $i <= $count; ++$i) {
|
||||
$this->addElement($element, $fontStyle, $paragraphStyle);
|
||||
}
|
||||
} else {
|
||||
// All other elements
|
||||
array_unshift($args, $element); // Prepend element name to the beginning of args array
|
||||
|
||||
return call_user_func_array([$this, 'addElement'], $args);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add element.
|
||||
*
|
||||
* Each element has different number of parameters passed
|
||||
*
|
||||
* @param string $elementName
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
protected function addElement($elementName)
|
||||
{
|
||||
$elementClass = __NAMESPACE__ . '\\' . $elementName;
|
||||
$this->checkValidity($elementName);
|
||||
|
||||
// Get arguments
|
||||
$args = func_get_args();
|
||||
$withoutP = in_array($this->container, ['TextRun', 'Footnote', 'Endnote', 'ListItemRun', 'Field']);
|
||||
if ($withoutP && ($elementName == 'Text' || $elementName == 'PreserveText')) {
|
||||
$args[3] = null; // Remove paragraph style for texts in textrun
|
||||
}
|
||||
|
||||
// Create element using reflection
|
||||
$reflection = new ReflectionClass($elementClass);
|
||||
$elementArgs = $args;
|
||||
array_shift($elementArgs); // Shift the $elementName off the beginning of array
|
||||
|
||||
/** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */
|
||||
$element = $reflection->newInstanceArgs($elementArgs);
|
||||
|
||||
// Set parent container
|
||||
$element->setParentContainer($this);
|
||||
$element->setElementIndex($this->countElements() + 1);
|
||||
$element->setElementId();
|
||||
|
||||
$this->elements[] = $element;
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all elements.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement[]
|
||||
*/
|
||||
public function getElements()
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the element at the requested position.
|
||||
*
|
||||
* @param int $index
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function getElement($index)
|
||||
{
|
||||
if (array_key_exists($index, $this->elements)) {
|
||||
return $this->elements[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the element at requested index.
|
||||
*
|
||||
* @param int|\PhpOffice\PhpWord\Element\AbstractElement $toRemove
|
||||
*/
|
||||
public function removeElement($toRemove): void
|
||||
{
|
||||
if (is_int($toRemove) && array_key_exists($toRemove, $this->elements)) {
|
||||
unset($this->elements[$toRemove]);
|
||||
} elseif ($toRemove instanceof \PhpOffice\PhpWord\Element\AbstractElement) {
|
||||
foreach ($this->elements as $key => $element) {
|
||||
if ($element->getElementId() === $toRemove->getElementId()) {
|
||||
unset($this->elements[$key]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count elements.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countElements()
|
||||
{
|
||||
return count($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a method is allowed for the current container.
|
||||
*
|
||||
* @param string $method
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function checkValidity($method)
|
||||
{
|
||||
$generalContainers = [
|
||||
'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun', 'TrackChange',
|
||||
];
|
||||
|
||||
$validContainers = [
|
||||
'Text' => $generalContainers,
|
||||
'Bookmark' => $generalContainers,
|
||||
'Link' => $generalContainers,
|
||||
'TextBreak' => $generalContainers,
|
||||
'Image' => $generalContainers,
|
||||
'OLEObject' => $generalContainers,
|
||||
'Field' => $generalContainers,
|
||||
'Line' => $generalContainers,
|
||||
'Shape' => $generalContainers,
|
||||
'FormField' => $generalContainers,
|
||||
'SDT' => $generalContainers,
|
||||
'TrackChange' => $generalContainers,
|
||||
'TextRun' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox', 'TrackChange', 'ListItemRun'],
|
||||
'ListItem' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox'],
|
||||
'ListItemRun' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox'],
|
||||
'Table' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox'],
|
||||
'CheckBox' => ['Section', 'Header', 'Footer', 'Cell', 'TextRun'],
|
||||
'TextBox' => ['Section', 'Header', 'Footer', 'Cell'],
|
||||
'Footnote' => ['Section', 'TextRun', 'Cell', 'ListItemRun'],
|
||||
'Endnote' => ['Section', 'TextRun', 'Cell'],
|
||||
'PreserveText' => ['Section', 'Header', 'Footer', 'Cell'],
|
||||
'Title' => ['Section', 'Cell'],
|
||||
'TOC' => ['Section'],
|
||||
'PageBreak' => ['Section'],
|
||||
'Chart' => ['Section', 'Cell'],
|
||||
];
|
||||
|
||||
// Special condition, e.g. preservetext can only exists in cell when
|
||||
// the cell is located in header or footer
|
||||
$validSubcontainers = [
|
||||
'PreserveText' => [['Cell'], ['Header', 'Footer', 'Section']],
|
||||
'Footnote' => [['Cell', 'TextRun'], ['Section']],
|
||||
'Endnote' => [['Cell', 'TextRun'], ['Section']],
|
||||
];
|
||||
|
||||
// Check if a method is valid for current container
|
||||
if (isset($validContainers[$method])) {
|
||||
if (!in_array($this->container, $validContainers[$method])) {
|
||||
throw new BadMethodCallException("Cannot add {$method} in {$this->container}.");
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a method is valid for current container, located in other container
|
||||
if (isset($validSubcontainers[$method])) {
|
||||
$rules = $validSubcontainers[$method];
|
||||
$containers = $rules[0];
|
||||
$allowedDocParts = $rules[1];
|
||||
foreach ($containers as $container) {
|
||||
if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) {
|
||||
throw new BadMethodCallException("Cannot add {$method} in {$this->container}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
503
vendor/phpoffice/phpword/src/PhpWord/Element/AbstractElement.php
vendored
Normal file
503
vendor/phpoffice/phpword/src/PhpWord/Element/AbstractElement.php
vendored
Normal file
@@ -0,0 +1,503 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use DateTime;
|
||||
use InvalidArgumentException;
|
||||
use PhpOffice\PhpWord\Media;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
||||
/**
|
||||
* Element abstract class.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
abstract class AbstractElement
|
||||
{
|
||||
/**
|
||||
* PhpWord object.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\PhpWord
|
||||
*/
|
||||
protected $phpWord;
|
||||
|
||||
/**
|
||||
* Section Id.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $sectionId;
|
||||
|
||||
/**
|
||||
* Document part type: Section|Header|Footer|Footnote|Endnote.
|
||||
*
|
||||
* Used by textrun and cell container to determine where the element is
|
||||
* located because it will affect the availability of other element,
|
||||
* e.g. footnote will not be available when $docPart is header or footer.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $docPart = 'Section';
|
||||
|
||||
/**
|
||||
* Document part Id.
|
||||
*
|
||||
* For header and footer, this will be = ($sectionId - 1) * 3 + $index
|
||||
* because the max number of header/footer in every page is 3, i.e.
|
||||
* AUTO, FIRST, and EVEN (AUTO = ODD)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $docPartId = 1;
|
||||
|
||||
/**
|
||||
* Index of element in the elements collection (start with 1).
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $elementIndex = 1;
|
||||
|
||||
/**
|
||||
* Unique Id for element.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $elementId;
|
||||
|
||||
/**
|
||||
* Relation Id.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $relationId;
|
||||
|
||||
/**
|
||||
* Depth of table container nested level; Primarily used for RTF writer/reader.
|
||||
*
|
||||
* 0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $nestedLevel = 0;
|
||||
|
||||
/**
|
||||
* A reference to the parent.
|
||||
*
|
||||
* @var null|AbstractElement
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* changed element info.
|
||||
*
|
||||
* @var TrackChange
|
||||
*/
|
||||
private $trackChange;
|
||||
|
||||
/**
|
||||
* Parent container type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $parentContainer;
|
||||
|
||||
/**
|
||||
* Has media relation flag; true for Link, Image, and Object.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $mediaRelation = false;
|
||||
|
||||
/**
|
||||
* Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $collectionRelation = false;
|
||||
|
||||
/**
|
||||
* The start position for the linked comment.
|
||||
*
|
||||
* @var Comment
|
||||
*/
|
||||
protected $commentRangeStart;
|
||||
|
||||
/**
|
||||
* The end position for the linked comment.
|
||||
*
|
||||
* @var Comment
|
||||
*/
|
||||
protected $commentRangeEnd;
|
||||
|
||||
/**
|
||||
* Get PhpWord.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\PhpWord
|
||||
*/
|
||||
public function getPhpWord()
|
||||
{
|
||||
return $this->phpWord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set PhpWord as reference.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
*/
|
||||
public function setPhpWord(?PhpWord $phpWord = null): void
|
||||
{
|
||||
$this->phpWord = $phpWord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get section number.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSectionId()
|
||||
{
|
||||
return $this->sectionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set doc part.
|
||||
*
|
||||
* @param string $docPart
|
||||
* @param int $docPartId
|
||||
*/
|
||||
public function setDocPart($docPart, $docPartId = 1): void
|
||||
{
|
||||
$this->docPart = $docPart;
|
||||
$this->docPartId = $docPartId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get doc part.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDocPart()
|
||||
{
|
||||
return $this->docPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get doc part Id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDocPartId()
|
||||
{
|
||||
return $this->docPartId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return media element (image, object, link) container name.
|
||||
*
|
||||
* @return string section|headerx|footerx|footnote|endnote
|
||||
*/
|
||||
private function getMediaPart()
|
||||
{
|
||||
$mediaPart = $this->docPart;
|
||||
if ($mediaPart == 'Header' || $mediaPart == 'Footer') {
|
||||
$mediaPart .= $this->docPartId;
|
||||
}
|
||||
|
||||
return strtolower($mediaPart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element index.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getElementIndex()
|
||||
{
|
||||
return $this->elementIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set element index.
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setElementIndex($value): void
|
||||
{
|
||||
$this->elementIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element unique ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getElementId()
|
||||
{
|
||||
return $this->elementId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set element unique ID from 6 first digit of md5.
|
||||
*/
|
||||
public function setElementId(): void
|
||||
{
|
||||
$this->elementId = substr(md5(mt_rand()), 0, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get relation Id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->relationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set relation Id.
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setRelationId($value): void
|
||||
{
|
||||
$this->relationId = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get nested level.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getNestedLevel()
|
||||
{
|
||||
return $this->nestedLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment start.
|
||||
*
|
||||
* @return Comment
|
||||
*/
|
||||
public function getCommentRangeStart()
|
||||
{
|
||||
return $this->commentRangeStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment start.
|
||||
*/
|
||||
public function setCommentRangeStart(Comment $value): void
|
||||
{
|
||||
if ($this instanceof Comment) {
|
||||
throw new InvalidArgumentException('Cannot set a Comment on a Comment');
|
||||
}
|
||||
$this->commentRangeStart = $value;
|
||||
$this->commentRangeStart->setStartElement($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment end.
|
||||
*
|
||||
* @return Comment
|
||||
*/
|
||||
public function getCommentRangeEnd()
|
||||
{
|
||||
return $this->commentRangeEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment end.
|
||||
*/
|
||||
public function setCommentRangeEnd(Comment $value): void
|
||||
{
|
||||
if ($this instanceof Comment) {
|
||||
throw new InvalidArgumentException('Cannot set a Comment on a Comment');
|
||||
}
|
||||
$this->commentRangeEnd = $value;
|
||||
$this->commentRangeEnd->setEndElement($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent element.
|
||||
*
|
||||
* @return null|AbstractElement
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent container.
|
||||
*
|
||||
* Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $container
|
||||
*/
|
||||
public function setParentContainer(self $container): void
|
||||
{
|
||||
$this->parentContainer = substr(get_class($container), strrpos(get_class($container), '\\') + 1);
|
||||
$this->parent = $container;
|
||||
|
||||
// Set nested level
|
||||
$this->nestedLevel = $container->getNestedLevel();
|
||||
if ($this->parentContainer == 'Cell') {
|
||||
++$this->nestedLevel;
|
||||
}
|
||||
|
||||
// Set phpword
|
||||
$this->setPhpWord($container->getPhpWord());
|
||||
|
||||
// Set doc part
|
||||
if (!$this instanceof Footnote) {
|
||||
$this->setDocPart($container->getDocPart(), $container->getDocPartId());
|
||||
}
|
||||
|
||||
$this->setMediaRelation();
|
||||
$this->setCollectionRelation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set relation Id for media elements (link, image, object; legacy of OOXML).
|
||||
*
|
||||
* - Image element needs to be passed to Media object
|
||||
* - Icon needs to be set for Object element
|
||||
*/
|
||||
private function setMediaRelation(): void
|
||||
{
|
||||
if (!$this instanceof Link && !$this instanceof Image && !$this instanceof OLEObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
$elementName = substr(static::class, strrpos(static::class, '\\') + 1);
|
||||
if ($elementName == 'OLEObject') {
|
||||
$elementName = 'Object';
|
||||
}
|
||||
$mediaPart = $this->getMediaPart();
|
||||
$source = $this->getSource();
|
||||
$image = null;
|
||||
if ($this instanceof Image) {
|
||||
$image = $this;
|
||||
}
|
||||
$rId = Media::addElement($mediaPart, strtolower($elementName), $source, $image);
|
||||
$this->setRelationId($rId);
|
||||
|
||||
if ($this instanceof OLEObject) {
|
||||
$icon = $this->getIcon();
|
||||
$rId = Media::addElement($mediaPart, 'image', $icon, new Image($icon));
|
||||
$this->setImageRelationId($rId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set relation Id for elements that will be registered in the Collection subnamespaces.
|
||||
*/
|
||||
private function setCollectionRelation(): void
|
||||
{
|
||||
if ($this->collectionRelation === true && $this->phpWord instanceof PhpWord) {
|
||||
$elementName = substr(static::class, strrpos(static::class, '\\') + 1);
|
||||
$addMethod = "add{$elementName}";
|
||||
$rId = $this->phpWord->$addMethod($this);
|
||||
$this->setRelationId($rId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if element is located in Section doc part (as opposed to Header/Footer).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInSection()
|
||||
{
|
||||
return $this->docPart == 'Section';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new style value.
|
||||
*
|
||||
* @param mixed $styleObject Style object
|
||||
* @param mixed $styleValue Style value
|
||||
* @param bool $returnObject Always return object
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function setNewStyle($styleObject, $styleValue = null, $returnObject = false)
|
||||
{
|
||||
if (null !== $styleValue && is_array($styleValue)) {
|
||||
$styleObject->setStyleByArray($styleValue);
|
||||
$style = $styleObject;
|
||||
} else {
|
||||
$style = $returnObject ? $styleObject : $styleValue;
|
||||
}
|
||||
|
||||
return $style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the trackChange information.
|
||||
*/
|
||||
public function setTrackChange(TrackChange $trackChange): void
|
||||
{
|
||||
$this->trackChange = $trackChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the trackChange information.
|
||||
*
|
||||
* @return TrackChange
|
||||
*/
|
||||
public function getTrackChange()
|
||||
{
|
||||
return $this->trackChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set changed.
|
||||
*
|
||||
* @param string $type INSERTED|DELETED
|
||||
* @param string $author
|
||||
* @param null|DateTime|int $date allways in UTC
|
||||
*/
|
||||
public function setChangeInfo($type, $author, $date = null): void
|
||||
{
|
||||
$this->trackChange = new TrackChange($type, $author, $date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set enum value.
|
||||
*
|
||||
* @param null|string $value
|
||||
* @param string[] $enum
|
||||
* @param null|string $default
|
||||
*
|
||||
* @return null|string
|
||||
*
|
||||
* @todo Merge with the same method in AbstractStyle
|
||||
*/
|
||||
protected function setEnumVal($value = null, $enum = [], $default = null)
|
||||
{
|
||||
if ($value !== null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
|
||||
throw new InvalidArgumentException("Invalid style value: {$value}");
|
||||
} elseif ($value === null || trim($value) == '') {
|
||||
$value = $default;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
60
vendor/phpoffice/phpword/src/PhpWord/Element/Bookmark.php
vendored
Normal file
60
vendor/phpoffice/phpword/src/PhpWord/Element/Bookmark.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||
|
||||
/**
|
||||
* Bookmark element.
|
||||
*/
|
||||
class Bookmark extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Bookmark Name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Is part of collection.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $collectionRelation = true;
|
||||
|
||||
/**
|
||||
* Create a new Bookmark Element.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($name = '')
|
||||
{
|
||||
$this->name = SharedText::toUTF8($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bookmark name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
77
vendor/phpoffice/phpword/src/PhpWord/Element/Cell.php
vendored
Normal file
77
vendor/phpoffice/phpword/src/PhpWord/Element/Cell.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Cell as CellStyle;
|
||||
|
||||
/**
|
||||
* Table cell element.
|
||||
*/
|
||||
class Cell extends AbstractContainer
|
||||
{
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'Cell';
|
||||
|
||||
/**
|
||||
* Cell width.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $width;
|
||||
|
||||
/**
|
||||
* Cell style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Cell
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param int $width
|
||||
* @param array|\PhpOffice\PhpWord\Style\Cell $style
|
||||
*/
|
||||
public function __construct($width = null, $style = null)
|
||||
{
|
||||
$this->width = $width;
|
||||
$this->style = $this->setNewStyle(new CellStyle(), $style, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Cell
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell width.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
}
|
||||
129
vendor/phpoffice/phpword/src/PhpWord/Element/Chart.php
vendored
Normal file
129
vendor/phpoffice/phpword/src/PhpWord/Element/Chart.php
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Chart as ChartStyle;
|
||||
|
||||
/**
|
||||
* Chart element.
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
class Chart extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Is part of collection.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $collectionRelation = true;
|
||||
|
||||
/**
|
||||
* Type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $type = 'pie';
|
||||
|
||||
/**
|
||||
* Series.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $series = [];
|
||||
|
||||
/**
|
||||
* Chart style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Chart
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $categories
|
||||
* @param array $values
|
||||
* @param array $style
|
||||
* @param null|mixed $seriesName
|
||||
*/
|
||||
public function __construct($type, $categories, $values, $style = null, $seriesName = null)
|
||||
{
|
||||
$this->setType($type);
|
||||
$this->addSeries($categories, $values, $seriesName);
|
||||
$this->style = $this->setNewStyle(new ChartStyle(), $style, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setType($value): void
|
||||
{
|
||||
$enum = ['pie', 'doughnut', 'line', 'bar', 'stacked_bar', 'percent_stacked_bar', 'column', 'stacked_column', 'percent_stacked_column', 'area', 'radar', 'scatter'];
|
||||
$this->type = $this->setEnumVal($value, $enum, 'pie');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add series.
|
||||
*
|
||||
* @param array $categories
|
||||
* @param array $values
|
||||
* @param null|mixed $name
|
||||
*/
|
||||
public function addSeries($categories, $values, $name = null): void
|
||||
{
|
||||
$this->series[] = [
|
||||
'categories' => $categories,
|
||||
'values' => $values,
|
||||
'name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get series.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSeries()
|
||||
{
|
||||
return $this->series;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get chart style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Chart
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
}
|
||||
73
vendor/phpoffice/phpword/src/PhpWord/Element/CheckBox.php
vendored
Normal file
73
vendor/phpoffice/phpword/src/PhpWord/Element/CheckBox.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||
|
||||
/**
|
||||
* Check box element.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
class CheckBox extends Text
|
||||
{
|
||||
/**
|
||||
* Name content.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $text
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($name = null, $text = null, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
$this->setName($name);
|
||||
parent::__construct($text, $fontStyle, $paragraphStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name content.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = SharedText::toUTF8($name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
125
vendor/phpoffice/phpword/src/PhpWord/Element/Comment.php
vendored
Normal file
125
vendor/phpoffice/phpword/src/PhpWord/Element/Comment.php
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* Comment element.
|
||||
*
|
||||
* @see http://datypic.com/sc/ooxml/t-w_CT_Comment.html
|
||||
*/
|
||||
class Comment extends TrackChange
|
||||
{
|
||||
/**
|
||||
* Initials.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $initials;
|
||||
|
||||
/**
|
||||
* The Element where this comment starts.
|
||||
*
|
||||
* @var AbstractElement
|
||||
*/
|
||||
private $startElement;
|
||||
|
||||
/**
|
||||
* The Element where this comment ends.
|
||||
*
|
||||
* @var AbstractElement
|
||||
*/
|
||||
private $endElement;
|
||||
|
||||
/**
|
||||
* Is part of collection.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $collectionRelation = true;
|
||||
|
||||
/**
|
||||
* Create a new Comment Element.
|
||||
*
|
||||
* @param string $author
|
||||
* @param null|DateTime $date
|
||||
* @param string $initials
|
||||
*/
|
||||
public function __construct($author, $date = null, $initials = null)
|
||||
{
|
||||
parent::__construct(null, $author, $date);
|
||||
$this->initials = $initials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Initials.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInitials()
|
||||
{
|
||||
return $this->initials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the element where this comment starts.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||
*/
|
||||
public function setStartElement(AbstractElement $value): void
|
||||
{
|
||||
$this->startElement = $value;
|
||||
if ($value->getCommentRangeStart() == null) {
|
||||
$value->setCommentRangeStart($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element where this comment starts.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function getStartElement()
|
||||
{
|
||||
return $this->startElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the element where this comment ends.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||
*/
|
||||
public function setEndElement(AbstractElement $value): void
|
||||
{
|
||||
$this->endElement = $value;
|
||||
if ($value->getCommentRangeEnd() == null) {
|
||||
$value->setCommentRangeEnd($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element where this comment ends.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function getEndElement()
|
||||
{
|
||||
return $this->endElement;
|
||||
}
|
||||
}
|
||||
41
vendor/phpoffice/phpword/src/PhpWord/Element/Endnote.php
vendored
Normal file
41
vendor/phpoffice/phpword/src/PhpWord/Element/Endnote.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
* Endnote element.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
class Endnote extends Footnote
|
||||
{
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'Endnote';
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $paragraphStyle
|
||||
*/
|
||||
public function __construct($paragraphStyle = null)
|
||||
{
|
||||
parent::__construct($paragraphStyle);
|
||||
}
|
||||
}
|
||||
297
vendor/phpoffice/phpword/src/PhpWord/Element/Field.php
vendored
Normal file
297
vendor/phpoffice/phpword/src/PhpWord/Element/Field.php
vendored
Normal file
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
|
||||
/**
|
||||
* Field element.
|
||||
*
|
||||
* @since 0.11.0
|
||||
* @see http://www.schemacentral.com/sc/ooxml/t-w_CT_SimpleField.html
|
||||
*/
|
||||
class Field extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Field properties and options. Depending on type, a field can have different properties
|
||||
* and options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldsArray = [
|
||||
'PAGE' => [
|
||||
'properties' => [
|
||||
'format' => ['Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'],
|
||||
],
|
||||
'options' => ['PreserveFormat'],
|
||||
],
|
||||
'NUMPAGES' => [
|
||||
'properties' => [
|
||||
'format' => ['Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText',
|
||||
'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper', ],
|
||||
'numformat' => ['0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%'],
|
||||
],
|
||||
'options' => ['PreserveFormat'],
|
||||
],
|
||||
'DATE' => [
|
||||
'properties' => [
|
||||
'dateformat' => [
|
||||
// Generic formats
|
||||
'yyyy-MM-dd', 'yyyy-MM', 'MMM-yy', 'MMM-yyyy', 'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss',
|
||||
// Day-Month-Year formats
|
||||
'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-MMM-yy', 'd MMM. yy',
|
||||
'd-M-yy', 'd-M-yy h:mm', 'd-M-yy h:mm:ss', 'd-M-yy h:mm am/pm', 'd-M-yy h:mm:ss am/pm', 'd-M-yy HH:mm', 'd-M-yy HH:mm:ss',
|
||||
'd/M/yy', 'd/M/yy h:mm', 'd/M/yy h:mm:ss', 'd/M/yy h:mm am/pm', 'd/M/yy h:mm:ss am/pm', 'd/M/yy HH:mm', 'd/M/yy HH:mm:ss',
|
||||
'd-M-yyyy', 'd-M-yyyy h:mm', 'd-M-yyyy h:mm:ss', 'd-M-yyyy h:mm am/pm', 'd-M-yyyy h:mm:ss am/pm', 'd-M-yyyy HH:mm', 'd-M-yyyy HH:mm:ss',
|
||||
'd/M/yyyy', 'd/M/yyyy h:mm', 'd/M/yyyy h:mm:ss', 'd/M/yyyy h:mm am/pm', 'd/M/yyyy h:mm:ss am/pm', 'd/M/yyyy HH:mm', 'd/M/yyyy HH:mm:ss',
|
||||
// Month-Day-Year formats
|
||||
'dddd, MMMM d yyyy', 'MMMM d yyyy', 'MMM-d-yy', 'MMM. d yy',
|
||||
'M-d-yy', 'M-d-yy h:mm', 'M-d-yy h:mm:ss', 'M-d-yy h:mm am/pm', 'M-d-yy h:mm:ss am/pm', 'M-d-yy HH:mm', 'M-d-yy HH:mm:ss',
|
||||
'M/d/yy', 'M/d/yy h:mm', 'M/d/yy h:mm:ss', 'M/d/yy h:mm am/pm', 'M/d/yy h:mm:ss am/pm', 'M/d/yy HH:mm', 'M/d/yy HH:mm:ss',
|
||||
'M-d-yyyy', 'M-d-yyyy h:mm', 'M-d-yyyy h:mm:ss', 'M-d-yyyy h:mm am/pm', 'M-d-yyyy h:mm:ss am/pm', 'M-d-yyyy HH:mm', 'M-d-yyyy HH:mm:ss',
|
||||
'M/d/yyyy', 'M/d/yyyy h:mm', 'M/d/yyyy h:mm:ss', 'M/d/yyyy h:mm am/pm', 'M/d/yyyy h:mm:ss am/pm', 'M/d/yyyy HH:mm', 'M/d/yyyy HH:mm:ss',
|
||||
],
|
||||
],
|
||||
'options' => ['PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat'],
|
||||
],
|
||||
'MACROBUTTON' => [
|
||||
'properties' => ['macroname' => ''],
|
||||
],
|
||||
'XE' => [
|
||||
'properties' => [],
|
||||
'options' => ['Bold', 'Italic'],
|
||||
],
|
||||
'INDEX' => [
|
||||
'properties' => [],
|
||||
'options' => ['PreserveFormat'],
|
||||
],
|
||||
'STYLEREF' => [
|
||||
'properties' => ['StyleIdentifier' => ''],
|
||||
'options' => ['PreserveFormat'],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Field text.
|
||||
*
|
||||
* @var string|TextRun
|
||||
*/
|
||||
protected $text;
|
||||
|
||||
/**
|
||||
* Field properties.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $properties = [];
|
||||
|
||||
/**
|
||||
* Field options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Font style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
protected $fontStyle;
|
||||
|
||||
/**
|
||||
* Set Font style.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Font|string $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function setFontStyle($style = null)
|
||||
{
|
||||
if ($style instanceof Font) {
|
||||
$this->fontStyle = $style;
|
||||
} elseif (is_array($style)) {
|
||||
$this->fontStyle = new Font('text');
|
||||
$this->fontStyle->setStyleByArray($style);
|
||||
} elseif (null === $style) {
|
||||
$this->fontStyle = null;
|
||||
} else {
|
||||
$this->fontStyle = $style;
|
||||
}
|
||||
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Font style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Field Element.
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $properties
|
||||
* @param array $options
|
||||
* @param null|string|TextRun $text
|
||||
* @param array|\PhpOffice\PhpWord\Style\Font|string $fontStyle
|
||||
*/
|
||||
public function __construct($type = null, $properties = [], $options = [], $text = null, $fontStyle = null)
|
||||
{
|
||||
$this->setType($type);
|
||||
$this->setProperties($properties);
|
||||
$this->setOptions($options);
|
||||
$this->setText($text);
|
||||
$this->setFontStyle($fontStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Field type.
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setType($type = null)
|
||||
{
|
||||
if (isset($type)) {
|
||||
if (isset($this->fieldsArray[$type])) {
|
||||
$this->type = $type;
|
||||
} else {
|
||||
throw new InvalidArgumentException("Invalid type '$type'");
|
||||
}
|
||||
}
|
||||
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Field type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Field properties.
|
||||
*
|
||||
* @param array $properties
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setProperties($properties = [])
|
||||
{
|
||||
if (is_array($properties)) {
|
||||
foreach (array_keys($properties) as $propkey) {
|
||||
if (!(isset($this->fieldsArray[$this->type]['properties'][$propkey]))) {
|
||||
throw new InvalidArgumentException("Invalid property '$propkey'");
|
||||
}
|
||||
}
|
||||
$this->properties = array_merge($this->properties, $properties);
|
||||
}
|
||||
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Field properties.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Field options.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setOptions($options = [])
|
||||
{
|
||||
if (is_array($options)) {
|
||||
foreach (array_keys($options) as $optionkey) {
|
||||
if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey])) && substr($optionkey, 0, 1) !== '\\') {
|
||||
throw new InvalidArgumentException("Invalid option '$optionkey', possible values are " . implode(', ', $this->fieldsArray[$this->type]['options']));
|
||||
}
|
||||
}
|
||||
$this->options = array_merge($this->options, $options);
|
||||
}
|
||||
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Field properties.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Field text.
|
||||
*
|
||||
* @param string|TextRun $text
|
||||
*
|
||||
* @return null|string|TextRun
|
||||
*/
|
||||
public function setText($text = null)
|
||||
{
|
||||
if (isset($text)) {
|
||||
if (is_string($text) || $text instanceof TextRun) {
|
||||
$this->text = $text;
|
||||
} else {
|
||||
throw new InvalidArgumentException('Invalid text');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Field text.
|
||||
*
|
||||
* @return string|TextRun
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
}
|
||||
118
vendor/phpoffice/phpword/src/PhpWord/Element/Footer.php
vendored
Normal file
118
vendor/phpoffice/phpword/src/PhpWord/Element/Footer.php
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
* Footer element.
|
||||
*/
|
||||
class Footer extends AbstractContainer
|
||||
{
|
||||
/**
|
||||
* Header/footer types constants.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type
|
||||
*/
|
||||
const AUTO = 'default'; // default and odd pages
|
||||
const FIRST = 'first';
|
||||
const EVEN = 'even';
|
||||
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'Footer';
|
||||
|
||||
/**
|
||||
* Header type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = self::AUTO;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param int $sectionId
|
||||
* @param int $containerId
|
||||
* @param string $type
|
||||
*/
|
||||
public function __construct($sectionId, $containerId = 1, $type = self::AUTO)
|
||||
{
|
||||
$this->sectionId = $sectionId;
|
||||
$this->setType($type);
|
||||
$this->setDocPart($this->container, ($sectionId - 1) * 3 + $containerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setType($value = self::AUTO): void
|
||||
{
|
||||
if (!in_array($value, [self::AUTO, self::FIRST, self::EVEN])) {
|
||||
$value = self::AUTO;
|
||||
}
|
||||
$this->type = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset type to default.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function resetType()
|
||||
{
|
||||
return $this->type = self::AUTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* First page only header.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function firstPage()
|
||||
{
|
||||
return $this->type = self::FIRST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Even numbered pages only.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function evenPage()
|
||||
{
|
||||
return $this->type = self::EVEN;
|
||||
}
|
||||
}
|
||||
63
vendor/phpoffice/phpword/src/PhpWord/Element/Footnote.php
vendored
Normal file
63
vendor/phpoffice/phpword/src/PhpWord/Element/Footnote.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
class Footnote extends AbstractContainer
|
||||
{
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'Footnote';
|
||||
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
protected $paragraphStyle;
|
||||
|
||||
/**
|
||||
* Is part of collection.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $collectionRelation = true;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $paragraphStyle
|
||||
*/
|
||||
public function __construct($paragraphStyle = null)
|
||||
{
|
||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||
$this->setDocPart($this->container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get paragraph style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
}
|
||||
200
vendor/phpoffice/phpword/src/PhpWord/Element/FormField.php
vendored
Normal file
200
vendor/phpoffice/phpword/src/PhpWord/Element/FormField.php
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
* Form field element.
|
||||
*
|
||||
* @since 0.12.0
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html
|
||||
*/
|
||||
class FormField extends Text
|
||||
{
|
||||
/**
|
||||
* Form field type: textinput|checkbox|dropdown.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $type = 'textinput';
|
||||
|
||||
/**
|
||||
* Form field name.
|
||||
*
|
||||
* @var bool|int|string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Default value.
|
||||
*
|
||||
* - TextInput: string
|
||||
* - CheckBox: bool
|
||||
* - DropDown: int Index of entries (zero based)
|
||||
*
|
||||
* @var bool|int|string
|
||||
*/
|
||||
private $default;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*
|
||||
* @var bool|int|string
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Dropdown entries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $entries = [];
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param string $type
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
parent::__construct(null, $fontStyle, $paragraphStyle);
|
||||
$this->setType($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setType($value)
|
||||
{
|
||||
$enum = ['textinput', 'checkbox', 'dropdown'];
|
||||
$this->type = $this->setEnumVal($value, $enum, $this->type);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*
|
||||
* @param bool|int|string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setName($value)
|
||||
{
|
||||
$this->name = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default.
|
||||
*
|
||||
* @return bool|int|string
|
||||
*/
|
||||
public function getDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default.
|
||||
*
|
||||
* @param bool|int|string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setDefault($value)
|
||||
{
|
||||
$this->default = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value.
|
||||
*
|
||||
* @return bool|int|string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value.
|
||||
*
|
||||
* @param bool|int|string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get entries.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEntries()
|
||||
{
|
||||
return $this->entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set entries.
|
||||
*
|
||||
* @param array $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setEntries($value)
|
||||
{
|
||||
$this->entries = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
42
vendor/phpoffice/phpword/src/PhpWord/Element/Header.php
vendored
Normal file
42
vendor/phpoffice/phpword/src/PhpWord/Element/Header.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
* Header element.
|
||||
*/
|
||||
class Header extends Footer
|
||||
{
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'Header';
|
||||
|
||||
/**
|
||||
* Add a Watermark Element.
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
*
|
||||
* @return Image
|
||||
*/
|
||||
public function addWatermark($src, $style = null)
|
||||
{
|
||||
return $this->addImage($src, $style, true);
|
||||
}
|
||||
}
|
||||
557
vendor/phpoffice/phpword/src/PhpWord/Element/Image.php
vendored
Normal file
557
vendor/phpoffice/phpword/src/PhpWord/Element/Image.php
vendored
Normal file
@@ -0,0 +1,557 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
|
||||
use PhpOffice\PhpWord\Exception\InvalidImageException;
|
||||
use PhpOffice\PhpWord\Exception\UnsupportedImageTypeException;
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
use PhpOffice\PhpWord\Shared\ZipArchive;
|
||||
use PhpOffice\PhpWord\Style\Image as ImageStyle;
|
||||
|
||||
/**
|
||||
* Image element.
|
||||
*/
|
||||
class Image extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Image source type constants.
|
||||
*/
|
||||
const SOURCE_LOCAL = 'local'; // Local images
|
||||
const SOURCE_GD = 'gd'; // Generated using GD
|
||||
const SOURCE_ARCHIVE = 'archive'; // Image in archives zip://$archive#$image
|
||||
const SOURCE_STRING = 'string'; // Image from string
|
||||
|
||||
/**
|
||||
* Image source.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* Source type: local|gd|archive.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $sourceType;
|
||||
|
||||
/**
|
||||
* Image style.
|
||||
*
|
||||
* @var ImageStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Is watermark.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $watermark;
|
||||
|
||||
/**
|
||||
* Name of image.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Image type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $imageType;
|
||||
|
||||
/**
|
||||
* Image create function.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $imageCreateFunc;
|
||||
|
||||
/**
|
||||
* Image function.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $imageFunc;
|
||||
|
||||
/**
|
||||
* Image extension.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $imageExtension;
|
||||
|
||||
/**
|
||||
* Is memory image.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $memoryImage;
|
||||
|
||||
/**
|
||||
* Image target file name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $target;
|
||||
|
||||
/**
|
||||
* Image media index.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $mediaIndex;
|
||||
|
||||
/**
|
||||
* Has media relation flag; true for Link, Image, and Object.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $mediaRelation = true;
|
||||
|
||||
/**
|
||||
* Create new image element.
|
||||
*
|
||||
* @param string $source
|
||||
* @param mixed $style
|
||||
* @param bool $watermark
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($source, $style = null, $watermark = false, $name = null)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
||||
$this->setIsWatermark($watermark);
|
||||
$this->setName($name);
|
||||
|
||||
$this->checkImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image style.
|
||||
*
|
||||
* @return ImageStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource()
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image source type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSourceType()
|
||||
{
|
||||
return $this->sourceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image name.
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setName($value): void
|
||||
{
|
||||
$this->name = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image name.
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image media ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaId()
|
||||
{
|
||||
return md5($this->source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get is watermark.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isWatermark()
|
||||
{
|
||||
return $this->watermark;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set is watermark.
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setIsWatermark($value): void
|
||||
{
|
||||
$this->watermark = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageType()
|
||||
{
|
||||
return $this->imageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image create function.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageCreateFunction()
|
||||
{
|
||||
return $this->imageCreateFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image function.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageFunction()
|
||||
{
|
||||
return $this->imageFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image extension.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageExtension()
|
||||
{
|
||||
return $this->imageExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get is memory image.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMemImage()
|
||||
{
|
||||
return $this->memoryImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get target file name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTarget()
|
||||
{
|
||||
return $this->target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set target file name.
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTarget($value): void
|
||||
{
|
||||
$this->target = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media index.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMediaIndex()
|
||||
{
|
||||
return $this->mediaIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set media index.
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setMediaIndex($value): void
|
||||
{
|
||||
$this->mediaIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image string data.
|
||||
*
|
||||
* @param bool $base64
|
||||
*
|
||||
* @return null|string
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
public function getImageStringData($base64 = false)
|
||||
{
|
||||
$source = $this->source;
|
||||
$actualSource = null;
|
||||
$imageBinary = null;
|
||||
$imageData = null;
|
||||
$isTemp = false;
|
||||
|
||||
// Get actual source from archive image or other source
|
||||
// Return null if not found
|
||||
if ($this->sourceType == self::SOURCE_ARCHIVE) {
|
||||
$source = substr($source, 6);
|
||||
[$zipFilename, $imageFilename] = explode('#', $source);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFilename) !== false) {
|
||||
if ($zip->locateName($imageFilename) !== false) {
|
||||
$isTemp = true;
|
||||
$zip->extractTo(Settings::getTempDir(), $imageFilename);
|
||||
$actualSource = Settings::getTempDir() . DIRECTORY_SEPARATOR . $imageFilename;
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
} else {
|
||||
$actualSource = $source;
|
||||
}
|
||||
|
||||
// Can't find any case where $actualSource = null hasn't captured by
|
||||
// preceding exceptions. Please uncomment when you find the case and
|
||||
// put the case into Element\ImageTest.
|
||||
// if ($actualSource === null) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// Read image binary data and convert to hex/base64 string
|
||||
if ($this->sourceType == self::SOURCE_GD) {
|
||||
$imageResource = call_user_func($this->imageCreateFunc, $actualSource);
|
||||
if ($this->imageType === 'image/png') {
|
||||
// PNG images need to preserve alpha channel information
|
||||
imagesavealpha($imageResource, true);
|
||||
}
|
||||
ob_start();
|
||||
call_user_func($this->imageFunc, $imageResource);
|
||||
$imageBinary = ob_get_contents();
|
||||
ob_end_clean();
|
||||
} elseif ($this->sourceType == self::SOURCE_STRING) {
|
||||
$imageBinary = $this->source;
|
||||
} else {
|
||||
$fileHandle = fopen($actualSource, 'rb', false);
|
||||
if ($fileHandle !== false) {
|
||||
$imageBinary = fread($fileHandle, filesize($actualSource));
|
||||
fclose($fileHandle);
|
||||
}
|
||||
}
|
||||
if ($imageBinary !== null) {
|
||||
if ($base64) {
|
||||
$imageData = chunk_split(base64_encode($imageBinary));
|
||||
} else {
|
||||
$imageData = chunk_split(bin2hex($imageBinary));
|
||||
}
|
||||
}
|
||||
|
||||
// Delete temporary file if necessary
|
||||
if ($isTemp === true) {
|
||||
@unlink($actualSource);
|
||||
}
|
||||
|
||||
return $imageData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check memory image, supported type, image functions, and proportional width/height.
|
||||
*/
|
||||
private function checkImage(): void
|
||||
{
|
||||
$this->setSourceType();
|
||||
|
||||
// Check image data
|
||||
if ($this->sourceType == self::SOURCE_ARCHIVE) {
|
||||
$imageData = $this->getArchiveImageSize($this->source);
|
||||
} elseif ($this->sourceType == self::SOURCE_STRING) {
|
||||
$imageData = @getimagesizefromstring($this->source);
|
||||
} else {
|
||||
$imageData = @getimagesize($this->source);
|
||||
}
|
||||
if (!is_array($imageData)) {
|
||||
throw new InvalidImageException(sprintf('Invalid image: %s', $this->source));
|
||||
}
|
||||
[$actualWidth, $actualHeight, $imageType] = $imageData;
|
||||
|
||||
// Check image type support
|
||||
$supportedTypes = [IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG];
|
||||
if ($this->sourceType != self::SOURCE_GD && $this->sourceType != self::SOURCE_STRING) {
|
||||
$supportedTypes = array_merge($supportedTypes, [IMAGETYPE_BMP, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM]);
|
||||
}
|
||||
if (!in_array($imageType, $supportedTypes)) {
|
||||
throw new UnsupportedImageTypeException();
|
||||
}
|
||||
|
||||
// Define image functions
|
||||
$this->imageType = image_type_to_mime_type($imageType);
|
||||
$this->setFunctions();
|
||||
$this->setProportionalSize($actualWidth, $actualHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set source type.
|
||||
*/
|
||||
private function setSourceType(): void
|
||||
{
|
||||
if (stripos(strrev($this->source), strrev('.php')) === 0) {
|
||||
$this->memoryImage = true;
|
||||
$this->sourceType = self::SOURCE_GD;
|
||||
} elseif (strpos($this->source, 'zip://') !== false) {
|
||||
$this->memoryImage = false;
|
||||
$this->sourceType = self::SOURCE_ARCHIVE;
|
||||
} elseif (filter_var($this->source, FILTER_VALIDATE_URL) !== false) {
|
||||
$this->memoryImage = true;
|
||||
if (strpos($this->source, 'https') === 0) {
|
||||
$fileContent = file_get_contents($this->source);
|
||||
$this->source = $fileContent;
|
||||
$this->sourceType = self::SOURCE_STRING;
|
||||
} else {
|
||||
$this->sourceType = self::SOURCE_GD;
|
||||
}
|
||||
} elseif ((strpos($this->source, chr(0)) === false) && @file_exists($this->source)) {
|
||||
$this->memoryImage = false;
|
||||
$this->sourceType = self::SOURCE_LOCAL;
|
||||
} else {
|
||||
$this->memoryImage = true;
|
||||
$this->sourceType = self::SOURCE_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image size from archive.
|
||||
*
|
||||
* @since 0.12.0 Throws CreateTemporaryFileException.
|
||||
*
|
||||
* @param string $source
|
||||
*
|
||||
* @return null|array
|
||||
*/
|
||||
private function getArchiveImageSize($source)
|
||||
{
|
||||
$imageData = null;
|
||||
$source = substr($source, 6);
|
||||
[$zipFilename, $imageFilename] = explode('#', $source);
|
||||
|
||||
$tempFilename = tempnam(Settings::getTempDir(), 'PHPWordImage');
|
||||
if (false === $tempFilename) {
|
||||
throw new CreateTemporaryFileException(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFilename) !== false) {
|
||||
if ($zip->locateName($imageFilename) !== false) {
|
||||
$imageContent = $zip->getFromName($imageFilename);
|
||||
if ($imageContent !== false) {
|
||||
file_put_contents($tempFilename, $imageContent);
|
||||
$imageData = getimagesize($tempFilename);
|
||||
unlink($tempFilename);
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
return $imageData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image functions and extensions.
|
||||
*/
|
||||
private function setFunctions(): void
|
||||
{
|
||||
switch ($this->imageType) {
|
||||
case 'image/png':
|
||||
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefrompng';
|
||||
$this->imageFunc = 'imagepng';
|
||||
$this->imageExtension = 'png';
|
||||
|
||||
break;
|
||||
case 'image/gif':
|
||||
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefromgif';
|
||||
$this->imageFunc = 'imagegif';
|
||||
$this->imageExtension = 'gif';
|
||||
|
||||
break;
|
||||
case 'image/jpeg':
|
||||
case 'image/jpg':
|
||||
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefromjpeg';
|
||||
$this->imageFunc = 'imagejpeg';
|
||||
$this->imageExtension = 'jpg';
|
||||
|
||||
break;
|
||||
case 'image/bmp':
|
||||
case 'image/x-ms-bmp':
|
||||
$this->imageType = 'image/bmp';
|
||||
$this->imageExtension = 'bmp';
|
||||
|
||||
break;
|
||||
case 'image/tiff':
|
||||
$this->imageExtension = 'tif';
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set proportional width/height if one dimension not available.
|
||||
*
|
||||
* @param int $actualWidth
|
||||
* @param int $actualHeight
|
||||
*/
|
||||
private function setProportionalSize($actualWidth, $actualHeight): void
|
||||
{
|
||||
$styleWidth = $this->style->getWidth();
|
||||
$styleHeight = $this->style->getHeight();
|
||||
if (!($styleWidth && $styleHeight)) {
|
||||
if ($styleWidth == null && $styleHeight == null) {
|
||||
$this->style->setWidth($actualWidth);
|
||||
$this->style->setHeight($actualHeight);
|
||||
} elseif ($styleWidth) {
|
||||
$this->style->setHeight($actualHeight * ($styleWidth / $actualWidth));
|
||||
} else {
|
||||
$this->style->setWidth($actualWidth * ($styleHeight / $actualHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
53
vendor/phpoffice/phpword/src/PhpWord/Element/Line.php
vendored
Normal file
53
vendor/phpoffice/phpword/src/PhpWord/Element/Line.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Line as LineStyle;
|
||||
|
||||
/**
|
||||
* Line element.
|
||||
*/
|
||||
class Line extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Line style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Line
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Create new line element.
|
||||
*
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($style = null)
|
||||
{
|
||||
$this->style = $this->setNewStyle(new LineStyle(), $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get line style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Line
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
}
|
||||
138
vendor/phpoffice/phpword/src/PhpWord/Element/Link.php
vendored
Normal file
138
vendor/phpoffice/phpword/src/PhpWord/Element/Link.php
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
/**
|
||||
* Link element.
|
||||
*/
|
||||
class Link extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Link source.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* Link text.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $text;
|
||||
|
||||
/**
|
||||
* Font style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
/**
|
||||
* Has media relation flag; true for Link, Image, and Object.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $mediaRelation = true;
|
||||
|
||||
/**
|
||||
* Has internal flag - anchor to internal bookmark.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $internal = false;
|
||||
|
||||
/**
|
||||
* Create a new Link Element.
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $text
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
* @param bool $internal
|
||||
*/
|
||||
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
|
||||
{
|
||||
$this->source = SharedText::toUTF8($source);
|
||||
$this->text = null === $text ? $this->source : SharedText::toUTF8($text);
|
||||
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||
$this->internal = $internal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource()
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* is internal.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInternal()
|
||||
{
|
||||
return $this->internal;
|
||||
}
|
||||
}
|
||||
112
vendor/phpoffice/phpword/src/PhpWord/Element/ListItem.php
vendored
Normal file
112
vendor/phpoffice/phpword/src/PhpWord/Element/ListItem.php
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
|
||||
|
||||
/**
|
||||
* List item element.
|
||||
*/
|
||||
class ListItem extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Element style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\ListItem
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Text object.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\Text
|
||||
*/
|
||||
private $textObject;
|
||||
|
||||
/**
|
||||
* Depth.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $depth;
|
||||
|
||||
/**
|
||||
* Create a new ListItem.
|
||||
*
|
||||
* @param string $text
|
||||
* @param int $depth
|
||||
* @param mixed $fontStyle
|
||||
* @param null|array|string $listStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
$this->textObject = new Text(SharedText::toUTF8($text), $fontStyle, $paragraphStyle);
|
||||
$this->depth = $depth;
|
||||
|
||||
// Version >= 0.10.0 will pass numbering style name. Older version will use old method
|
||||
if (null !== $listStyle && is_string($listStyle)) {
|
||||
$this->style = new ListItemStyle($listStyle); // @codeCoverageIgnore
|
||||
} else {
|
||||
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\ListItem
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text object.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Text
|
||||
*/
|
||||
public function getTextObject()
|
||||
{
|
||||
return $this->textObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get depth.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDepth()
|
||||
{
|
||||
return $this->depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->textObject->getText();
|
||||
}
|
||||
}
|
||||
85
vendor/phpoffice/phpword/src/PhpWord/Element/ListItemRun.php
vendored
Normal file
85
vendor/phpoffice/phpword/src/PhpWord/Element/ListItemRun.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
|
||||
|
||||
/**
|
||||
* List item element.
|
||||
*/
|
||||
class ListItemRun extends TextRun
|
||||
{
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'ListItemRun';
|
||||
|
||||
/**
|
||||
* ListItem Style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\ListItem
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* ListItem Depth.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $depth;
|
||||
|
||||
/**
|
||||
* Create a new ListItem.
|
||||
*
|
||||
* @param int $depth
|
||||
* @param null|array|string $listStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($depth = 0, $listStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
$this->depth = $depth;
|
||||
|
||||
// Version >= 0.10.0 will pass numbering style name. Older version will use old method
|
||||
if (null !== $listStyle && is_string($listStyle)) {
|
||||
$this->style = new ListItemStyle($listStyle);
|
||||
} else {
|
||||
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
|
||||
}
|
||||
parent::__construct($paragraphStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\ListItem
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem depth.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDepth()
|
||||
{
|
||||
return $this->depth;
|
||||
}
|
||||
}
|
||||
139
vendor/phpoffice/phpword/src/PhpWord/Element/OLEObject.php
vendored
Normal file
139
vendor/phpoffice/phpword/src/PhpWord/Element/OLEObject.php
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\InvalidObjectException;
|
||||
use PhpOffice\PhpWord\Style\Image as ImageStyle;
|
||||
|
||||
/**
|
||||
* OLEObject element.
|
||||
*/
|
||||
class OLEObject extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Ole-Object Src.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* Image Style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Image
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Icon.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $icon;
|
||||
|
||||
/**
|
||||
* Image Relation ID.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $imageRelationId;
|
||||
|
||||
/**
|
||||
* Has media relation flag; true for Link, Image, and Object.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $mediaRelation = true;
|
||||
|
||||
/**
|
||||
* Create a new Ole-Object Element.
|
||||
*
|
||||
* @param string $source
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($source, $style = null)
|
||||
{
|
||||
$supportedTypes = ['xls', 'doc', 'ppt', 'xlsx', 'docx', 'pptx'];
|
||||
$pathInfo = pathinfo($source);
|
||||
|
||||
if (file_exists($source) && in_array($pathInfo['extension'], $supportedTypes)) {
|
||||
$ext = $pathInfo['extension'];
|
||||
if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
|
||||
$ext = substr($ext, 0, -1);
|
||||
}
|
||||
|
||||
$this->source = $source;
|
||||
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
||||
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidObjectException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource()
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Image
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object icon.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image relation ID.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getImageRelationId()
|
||||
{
|
||||
return $this->imageRelationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image Relation ID.
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setImageRelationId($rId): void
|
||||
{
|
||||
$this->imageRelationId = $rId;
|
||||
}
|
||||
}
|
||||
31
vendor/phpoffice/phpword/src/PhpWord/Element/PageBreak.php
vendored
Normal file
31
vendor/phpoffice/phpword/src/PhpWord/Element/PageBreak.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
* Page break element.
|
||||
*/
|
||||
class PageBreak extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Create new page break.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
98
vendor/phpoffice/phpword/src/PhpWord/Element/PreserveText.php
vendored
Normal file
98
vendor/phpoffice/phpword/src/PhpWord/Element/PreserveText.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
/**
|
||||
* Preserve text/field element.
|
||||
*/
|
||||
class PreserveText extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Text content.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
private $text;
|
||||
|
||||
/**
|
||||
* Text style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
/**
|
||||
* Create a new Preserve Text Element.
|
||||
*
|
||||
* @param string $text
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||
|
||||
$this->text = SharedText::toUTF8($text);
|
||||
$matches = preg_split('/({.*?})/', $this->text ?? '', -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
if (isset($matches[0])) {
|
||||
$this->text = $matches;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text content.
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
}
|
||||
108
vendor/phpoffice/phpword/src/PhpWord/Element/Row.php
vendored
Normal file
108
vendor/phpoffice/phpword/src/PhpWord/Element/Row.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Row as RowStyle;
|
||||
|
||||
/**
|
||||
* Table row element.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
class Row extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Row height.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $height;
|
||||
|
||||
/**
|
||||
* Row style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Row
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Row cells.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\Cell[]
|
||||
*/
|
||||
private $cells = [];
|
||||
|
||||
/**
|
||||
* Create a new table row.
|
||||
*
|
||||
* @param int $height
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($height = null, $style = null)
|
||||
{
|
||||
$this->height = $height;
|
||||
$this->style = $this->setNewStyle(new RowStyle(), $style, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a cell.
|
||||
*
|
||||
* @param int $width
|
||||
* @param mixed $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Cell
|
||||
*/
|
||||
public function addCell($width = null, $style = null)
|
||||
{
|
||||
$cell = new Cell($width, $style);
|
||||
$cell->setParentContainer($this);
|
||||
$this->cells[] = $cell;
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all cells.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Cell[]
|
||||
*/
|
||||
public function getCells()
|
||||
{
|
||||
return $this->cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Row
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row height.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
}
|
||||
195
vendor/phpoffice/phpword/src/PhpWord/Element/SDT.php
vendored
Normal file
195
vendor/phpoffice/phpword/src/PhpWord/Element/SDT.php
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
* Structured document tag (SDT) element.
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
class SDT extends Text
|
||||
{
|
||||
/**
|
||||
* Form field type: comboBox|dropDownList|date.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*
|
||||
* @var bool|int|string
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* CheckBox/DropDown list entries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $listItems = [];
|
||||
|
||||
/**
|
||||
* Alias.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $alias;
|
||||
|
||||
/**
|
||||
* Tag.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tag;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param string $type
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
parent::__construct(null, $fontStyle, $paragraphStyle);
|
||||
$this->setType($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setType($value)
|
||||
{
|
||||
$enum = ['plainText', 'comboBox', 'dropDownList', 'date'];
|
||||
$this->type = $this->setEnumVal($value, $enum, 'comboBox');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value.
|
||||
*
|
||||
* @return bool|int|string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value.
|
||||
*
|
||||
* @param bool|int|string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get listItems.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getListItems()
|
||||
{
|
||||
return $this->listItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set listItems.
|
||||
*
|
||||
* @param array $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setListItems($value)
|
||||
{
|
||||
$this->listItems = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tag.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tag.
|
||||
*
|
||||
* @param string $tag
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setTag($tag)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alias.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlias()
|
||||
{
|
||||
return $this->alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alias.
|
||||
*
|
||||
* @param string $alias
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAlias($alias)
|
||||
{
|
||||
$this->alias = $alias;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
219
vendor/phpoffice/phpword/src/PhpWord/Element/Section.php
vendored
Normal file
219
vendor/phpoffice/phpword/src/PhpWord/Element/Section.php
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
|
||||
use PhpOffice\PhpWord\Style\Section as SectionStyle;
|
||||
|
||||
class Section extends AbstractContainer
|
||||
{
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'Section';
|
||||
|
||||
/**
|
||||
* Section style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Section
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Section headers, indexed from 1, not zero.
|
||||
*
|
||||
* @var Header[]
|
||||
*/
|
||||
private $headers = [];
|
||||
|
||||
/**
|
||||
* Section footers, indexed from 1, not zero.
|
||||
*
|
||||
* @var Footer[]
|
||||
*/
|
||||
private $footers = [];
|
||||
|
||||
/**
|
||||
* The properties for the footnote of this section.
|
||||
*
|
||||
* @var FootnoteProperties
|
||||
*/
|
||||
private $footnoteProperties;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param int $sectionCount
|
||||
* @param null|array|\PhpOffice\PhpWord\Style $style
|
||||
*/
|
||||
public function __construct($sectionCount, $style = null)
|
||||
{
|
||||
$this->sectionId = $sectionCount;
|
||||
$this->setDocPart($this->container, $this->sectionId);
|
||||
if (null === $style) {
|
||||
$style = new SectionStyle();
|
||||
}
|
||||
$this->style = $this->setNewStyle(new SectionStyle(), $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set section style.
|
||||
*
|
||||
* @param array $style
|
||||
*/
|
||||
public function setStyle($style = null): void
|
||||
{
|
||||
if (null !== $style && is_array($style)) {
|
||||
$this->style->setStyleByArray($style);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get section style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Section
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add header.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return Header
|
||||
*/
|
||||
public function addHeader($type = Header::AUTO)
|
||||
{
|
||||
return $this->addHeaderFooter($type, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add footer.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return Footer
|
||||
*/
|
||||
public function addFooter($type = Header::AUTO)
|
||||
{
|
||||
return $this->addHeaderFooter($type, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header elements.
|
||||
*
|
||||
* @return Header[]
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get footer elements.
|
||||
*
|
||||
* @return Footer[]
|
||||
*/
|
||||
public function getFooters()
|
||||
{
|
||||
return $this->footers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the footnote properties.
|
||||
*
|
||||
* @return FootnoteProperties
|
||||
*/
|
||||
public function getFootnoteProperties()
|
||||
{
|
||||
return $this->footnoteProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the footnote properties.
|
||||
*
|
||||
* @param FootnoteProperties $footnoteProperties
|
||||
*/
|
||||
public function setFootnoteProperties(?FootnoteProperties $footnoteProperties = null): void
|
||||
{
|
||||
$this->footnoteProperties = $footnoteProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is there a header for this section that is for the first page only?
|
||||
*
|
||||
* If any of the Header instances have a type of Header::FIRST then this method returns true.
|
||||
* False otherwise.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDifferentFirstPage()
|
||||
{
|
||||
foreach ($this->headers as $header) {
|
||||
if ($header->getType() == Header::FIRST) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach ($this->footers as $footer) {
|
||||
if ($footer->getType() == Header::FIRST) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add header/footer.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*
|
||||
* @param string $type
|
||||
* @param bool $header
|
||||
*
|
||||
* @return Footer|Header
|
||||
*/
|
||||
private function addHeaderFooter($type = Header::AUTO, $header = true)
|
||||
{
|
||||
$containerClass = substr(static::class, 0, strrpos(static::class, '\\')) . '\\' .
|
||||
($header ? 'Header' : 'Footer');
|
||||
$collectionArray = $header ? 'headers' : 'footers';
|
||||
$collection = &$this->$collectionArray;
|
||||
|
||||
if (in_array($type, [Header::AUTO, Header::FIRST, Header::EVEN])) {
|
||||
$index = count($collection);
|
||||
/** @var \PhpOffice\PhpWord\Element\AbstractContainer $container Type hint */
|
||||
$container = new $containerClass($this->sectionId, ++$index, $type);
|
||||
$container->setPhpWord($this->phpWord);
|
||||
|
||||
$collection[$index] = $container;
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
throw new Exception('Invalid header/footer type.');
|
||||
}
|
||||
}
|
||||
89
vendor/phpoffice/phpword/src/PhpWord/Element/Shape.php
vendored
Normal file
89
vendor/phpoffice/phpword/src/PhpWord/Element/Shape.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Shape as ShapeStyle;
|
||||
|
||||
/**
|
||||
* Shape element.
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
class Shape extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Shape type arc|curve|line|polyline|rect|oval.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* Shape style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Shape
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param string $type
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($type, $style = null)
|
||||
{
|
||||
$this->setType($type);
|
||||
$this->style = $this->setNewStyle(new ShapeStyle(), $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pattern.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setType($value = null)
|
||||
{
|
||||
$enum = ['arc', 'curve', 'line', 'polyline', 'rect', 'oval'];
|
||||
$this->type = $this->setEnumVal($value, $enum, null);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shape style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Shape
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
}
|
||||
169
vendor/phpoffice/phpword/src/PhpWord/Element/TOC.php
vendored
Normal file
169
vendor/phpoffice/phpword/src/PhpWord/Element/TOC.php
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\TOC as TOCStyle;
|
||||
|
||||
/**
|
||||
* Table of contents.
|
||||
*/
|
||||
class TOC extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* TOC style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\TOC
|
||||
*/
|
||||
private $tocStyle;
|
||||
|
||||
/**
|
||||
* Font style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
/**
|
||||
* Min title depth to show.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $minDepth = 1;
|
||||
|
||||
/**
|
||||
* Max title depth to show.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $maxDepth = 9;
|
||||
|
||||
/**
|
||||
* Create a new Table-of-Contents Element.
|
||||
*
|
||||
* @param mixed $fontStyle
|
||||
* @param array $tocStyle
|
||||
* @param int $minDepth
|
||||
* @param int $maxDepth
|
||||
*/
|
||||
public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9)
|
||||
{
|
||||
$this->tocStyle = new TOCStyle();
|
||||
|
||||
if (null !== $tocStyle && is_array($tocStyle)) {
|
||||
$this->tocStyle->setStyleByArray($tocStyle);
|
||||
}
|
||||
|
||||
if (null !== $fontStyle && is_array($fontStyle)) {
|
||||
$this->fontStyle = new Font();
|
||||
$this->fontStyle->setStyleByArray($fontStyle);
|
||||
} else {
|
||||
$this->fontStyle = $fontStyle;
|
||||
}
|
||||
|
||||
$this->minDepth = $minDepth;
|
||||
$this->maxDepth = $maxDepth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all titles.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTitles()
|
||||
{
|
||||
if (!$this->phpWord instanceof PhpWord) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$titles = $this->phpWord->getTitles()->getItems();
|
||||
foreach ($titles as $i => $title) {
|
||||
/** @var \PhpOffice\PhpWord\Element\Title $title Type hint */
|
||||
$depth = $title->getDepth();
|
||||
if ($this->minDepth > $depth) {
|
||||
unset($titles[$i]);
|
||||
}
|
||||
if (($this->maxDepth != 0) && ($this->maxDepth < $depth)) {
|
||||
unset($titles[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
return $titles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TOC Style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\TOC
|
||||
*/
|
||||
public function getStyleTOC()
|
||||
{
|
||||
return $this->tocStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Font Style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function getStyleFont()
|
||||
{
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set max depth.
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setMaxDepth($value): void
|
||||
{
|
||||
$this->maxDepth = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Max Depth.
|
||||
*
|
||||
* @return int Max depth of titles
|
||||
*/
|
||||
public function getMaxDepth()
|
||||
{
|
||||
return $this->maxDepth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set min depth.
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setMinDepth($value): void
|
||||
{
|
||||
$this->minDepth = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Min Depth.
|
||||
*
|
||||
* @return int Min depth of titles
|
||||
*/
|
||||
public function getMinDepth()
|
||||
{
|
||||
return $this->minDepth;
|
||||
}
|
||||
}
|
||||
176
vendor/phpoffice/phpword/src/PhpWord/Element/Table.php
vendored
Normal file
176
vendor/phpoffice/phpword/src/PhpWord/Element/Table.php
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Table as TableStyle;
|
||||
|
||||
/**
|
||||
* Table element.
|
||||
*/
|
||||
class Table extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Table style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Table
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Table rows.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\Row[]
|
||||
*/
|
||||
private $rows = [];
|
||||
|
||||
/**
|
||||
* Table width.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $width;
|
||||
|
||||
/**
|
||||
* Create a new table.
|
||||
*
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($style = null)
|
||||
{
|
||||
$this->style = $this->setNewStyle(new TableStyle(), $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a row.
|
||||
*
|
||||
* @param int $height
|
||||
* @param mixed $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Row
|
||||
*/
|
||||
public function addRow($height = null, $style = null)
|
||||
{
|
||||
$row = new Row($height, $style);
|
||||
$row->setParentContainer($this);
|
||||
$this->rows[] = $row;
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a cell.
|
||||
*
|
||||
* @param int $width
|
||||
* @param mixed $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Cell
|
||||
*/
|
||||
public function addCell($width = null, $style = null)
|
||||
{
|
||||
$index = count($this->rows) - 1;
|
||||
$row = $this->rows[$index];
|
||||
$cell = $row->addCell($width, $style);
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all rows.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Row[]
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Table
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table width.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set table width.
|
||||
*
|
||||
* @param int $width
|
||||
*/
|
||||
public function setWidth($width): void
|
||||
{
|
||||
$this->width = $width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column count.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countColumns()
|
||||
{
|
||||
$columnCount = 0;
|
||||
|
||||
$rowCount = count($this->rows);
|
||||
for ($i = 0; $i < $rowCount; ++$i) {
|
||||
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
|
||||
$row = $this->rows[$i];
|
||||
$cellCount = count($row->getCells());
|
||||
if ($columnCount < $cellCount) {
|
||||
$columnCount = $cellCount;
|
||||
}
|
||||
}
|
||||
|
||||
return $columnCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* The first declared cell width for each column.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function findFirstDefinedCellWidths()
|
||||
{
|
||||
$cellWidths = [];
|
||||
|
||||
foreach ($this->rows as $row) {
|
||||
$cells = $row->getCells();
|
||||
if (count($cells) <= count($cellWidths)) {
|
||||
continue;
|
||||
}
|
||||
$cellWidths = [];
|
||||
foreach ($cells as $cell) {
|
||||
$cellWidths[] = $cell->getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
return $cellWidths;
|
||||
}
|
||||
}
|
||||
156
vendor/phpoffice/phpword/src/PhpWord/Element/Text.php
vendored
Normal file
156
vendor/phpoffice/phpword/src/PhpWord/Element/Text.php
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
/**
|
||||
* Text element.
|
||||
*/
|
||||
class Text extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Text content.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $text;
|
||||
|
||||
/**
|
||||
* Text style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
protected $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
protected $paragraphStyle;
|
||||
|
||||
/**
|
||||
* Create a new Text Element.
|
||||
*
|
||||
* @param string $text
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
$this->setText($text);
|
||||
$paragraphStyle = $this->setParagraphStyle($paragraphStyle);
|
||||
$this->setFontStyle($fontStyle, $paragraphStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Text style.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Font|string $style
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $paragraphStyle
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||
{
|
||||
if ($style instanceof Font) {
|
||||
$this->fontStyle = $style;
|
||||
$this->setParagraphStyle($paragraphStyle);
|
||||
} elseif (is_array($style)) {
|
||||
$this->fontStyle = new Font('text', $paragraphStyle);
|
||||
$this->fontStyle->setStyleByArray($style);
|
||||
} elseif (null === $style) {
|
||||
$this->fontStyle = new Font('text', $paragraphStyle);
|
||||
} else {
|
||||
$this->fontStyle = $style;
|
||||
$this->setParagraphStyle($paragraphStyle);
|
||||
}
|
||||
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Paragraph style.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
if (is_array($style)) {
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
$this->paragraphStyle->setStyleByArray($style);
|
||||
} elseif ($style instanceof Paragraph) {
|
||||
$this->paragraphStyle = $style;
|
||||
} elseif (null === $style) {
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
} else {
|
||||
$this->paragraphStyle = $style;
|
||||
}
|
||||
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text content.
|
||||
*
|
||||
* @param string $text
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setText($text)
|
||||
{
|
||||
$this->text = SharedText::toUTF8($text);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
}
|
||||
60
vendor/phpoffice/phpword/src/PhpWord/Element/TextBox.php
vendored
Normal file
60
vendor/phpoffice/phpword/src/PhpWord/Element/TextBox.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle;
|
||||
|
||||
/**
|
||||
* TextBox element.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
class TextBox extends AbstractContainer
|
||||
{
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'TextBox';
|
||||
|
||||
/**
|
||||
* TextBox style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\TextBox
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Create a new textbox.
|
||||
*
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($style = null)
|
||||
{
|
||||
$this->style = $this->setNewStyle(new TextBoxStyle(), $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get textbox style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\TextBox
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
}
|
||||
132
vendor/phpoffice/phpword/src/PhpWord/Element/TextBreak.php
vendored
Normal file
132
vendor/phpoffice/phpword/src/PhpWord/Element/TextBreak.php
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
/**
|
||||
* Text break element.
|
||||
*/
|
||||
class TextBreak extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
/**
|
||||
* Text style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
/**
|
||||
* Create a new TextBreak Element.
|
||||
*
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
if (null !== $paragraphStyle) {
|
||||
$paragraphStyle = $this->setParagraphStyle($paragraphStyle);
|
||||
}
|
||||
if (null !== $fontStyle) {
|
||||
$this->setFontStyle($fontStyle, $paragraphStyle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Text style.
|
||||
*
|
||||
* @param mixed $style
|
||||
* @param mixed $paragraphStyle
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||
{
|
||||
if ($style instanceof Font) {
|
||||
$this->fontStyle = $style;
|
||||
$this->setParagraphStyle($paragraphStyle);
|
||||
} elseif (is_array($style)) {
|
||||
$this->fontStyle = new Font('text', $paragraphStyle);
|
||||
$this->fontStyle->setStyleByArray($style);
|
||||
} else {
|
||||
$this->fontStyle = $style;
|
||||
$this->setParagraphStyle($paragraphStyle);
|
||||
}
|
||||
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Paragraph style.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
if (is_array($style)) {
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
$this->paragraphStyle->setStyleByArray($style);
|
||||
} elseif ($style instanceof Paragraph) {
|
||||
$this->paragraphStyle = $style;
|
||||
} else {
|
||||
$this->paragraphStyle = $style;
|
||||
}
|
||||
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has font/paragraph style defined.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasStyle()
|
||||
{
|
||||
return null !== $this->fontStyle || null !== $this->paragraphStyle;
|
||||
}
|
||||
}
|
||||
81
vendor/phpoffice/phpword/src/PhpWord/Element/TextRun.php
vendored
Normal file
81
vendor/phpoffice/phpword/src/PhpWord/Element/TextRun.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
/**
|
||||
* Textrun/paragraph element.
|
||||
*/
|
||||
class TextRun extends AbstractContainer
|
||||
{
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'TextRun';
|
||||
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
protected $paragraphStyle;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $paragraphStyle
|
||||
*/
|
||||
public function __construct($paragraphStyle = null)
|
||||
{
|
||||
$this->paragraphStyle = $this->setParagraphStyle($paragraphStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Paragraph style.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
*/
|
||||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
if (is_array($style)) {
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
$this->paragraphStyle->setStyleByArray($style);
|
||||
} elseif ($style instanceof Paragraph) {
|
||||
$this->paragraphStyle = $style;
|
||||
} elseif (null === $style) {
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
} else {
|
||||
$this->paragraphStyle = $style;
|
||||
}
|
||||
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
}
|
||||
109
vendor/phpoffice/phpword/src/PhpWord/Element/Title.php
vendored
Normal file
109
vendor/phpoffice/phpword/src/PhpWord/Element/Title.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
||||
/**
|
||||
* Title element.
|
||||
*/
|
||||
class Title extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Title Text content.
|
||||
*
|
||||
* @var string|TextRun
|
||||
*/
|
||||
private $text;
|
||||
|
||||
/**
|
||||
* Title depth.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $depth = 1;
|
||||
|
||||
/**
|
||||
* Name of the heading style, e.g. 'Heading1'.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Is part of collection.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $collectionRelation = true;
|
||||
|
||||
/**
|
||||
* Create a new Title Element.
|
||||
*
|
||||
* @param string|TextRun $text
|
||||
* @param int $depth
|
||||
*/
|
||||
public function __construct($text, $depth = 1)
|
||||
{
|
||||
if (is_string($text)) {
|
||||
$this->text = SharedText::toUTF8($text);
|
||||
} elseif ($text instanceof TextRun) {
|
||||
$this->text = $text;
|
||||
} else {
|
||||
throw new InvalidArgumentException('Invalid text, should be a string or a TextRun');
|
||||
}
|
||||
|
||||
$this->depth = $depth;
|
||||
$styleName = $depth === 0 ? 'Title' : "Heading_{$this->depth}";
|
||||
if (array_key_exists($styleName, Style::getStyles())) {
|
||||
$this->style = str_replace('_', '', $styleName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title Text content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get depth.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDepth()
|
||||
{
|
||||
return $this->depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title style.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
}
|
||||
104
vendor/phpoffice/phpword/src/PhpWord/Element/TrackChange.php
vendored
Normal file
104
vendor/phpoffice/phpword/src/PhpWord/Element/TrackChange.php
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* TrackChange element.
|
||||
*
|
||||
* @see http://datypic.com/sc/ooxml/t-w_CT_TrackChange.html
|
||||
* @see http://datypic.com/sc/ooxml/t-w_CT_RunTrackChange.html
|
||||
*/
|
||||
class TrackChange extends AbstractContainer
|
||||
{
|
||||
const INSERTED = 'INSERTED';
|
||||
const DELETED = 'DELETED';
|
||||
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'TrackChange';
|
||||
|
||||
/**
|
||||
* The type of change, (insert or delete), not applicable for PhpOffice\PhpWord\Element\Comment.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $changeType;
|
||||
|
||||
/**
|
||||
* Author.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $author;
|
||||
|
||||
/**
|
||||
* Date.
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* Create a new TrackChange Element.
|
||||
*
|
||||
* @param string $changeType
|
||||
* @param string $author
|
||||
* @param null|bool|DateTime|int $date
|
||||
*/
|
||||
public function __construct($changeType = null, $author = null, $date = null)
|
||||
{
|
||||
$this->changeType = $changeType;
|
||||
$this->author = $author;
|
||||
if ($date !== null && $date !== false) {
|
||||
$this->date = ($date instanceof DateTime) ? $date : new DateTime('@' . $date);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TrackChange Author.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TrackChange Date.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Change type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getChangeType()
|
||||
{
|
||||
return $this->changeType;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user