Changes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -21,6 +22,7 @@ namespace PhpOffice\PhpWord\Collection;
|
||||
* Collection abstract class.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*
|
||||
* @template T
|
||||
*/
|
||||
abstract class AbstractCollection
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -23,6 +24,7 @@ use PhpOffice\PhpWord\Element\Bookmark;
|
||||
* Bookmarks collection.
|
||||
*
|
||||
* @since 0.12.0
|
||||
*
|
||||
* @extends AbstractCollection<Bookmark>
|
||||
*/
|
||||
class Bookmarks extends AbstractCollection
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -23,6 +24,7 @@ use PhpOffice\PhpWord\Element\Chart;
|
||||
* Charts collection.
|
||||
*
|
||||
* @since 0.12.0
|
||||
*
|
||||
* @extends AbstractCollection<Chart>
|
||||
*/
|
||||
class Charts extends AbstractCollection
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -23,6 +24,7 @@ use PhpOffice\PhpWord\Element\Comment;
|
||||
* Comments collection.
|
||||
*
|
||||
* @since 0.12.0
|
||||
*
|
||||
* @extends AbstractCollection<Comment>
|
||||
*/
|
||||
class Comments extends AbstractCollection
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -23,6 +24,7 @@ use PhpOffice\PhpWord\Element\Endnote;
|
||||
* Endnotes collection.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*
|
||||
* @extends AbstractCollection<Endnote>
|
||||
*/
|
||||
class Endnotes extends AbstractCollection
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -23,6 +24,7 @@ use PhpOffice\PhpWord\Element\Footnote;
|
||||
* Footnotes collection.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*
|
||||
* @extends AbstractCollection<Footnote>
|
||||
*/
|
||||
class Footnotes extends AbstractCollection
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -23,6 +24,7 @@ use PhpOffice\PhpWord\Element\Title;
|
||||
* Titles collection.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*
|
||||
* @extends AbstractCollection<Title>
|
||||
*/
|
||||
class Titles extends AbstractCollection
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -49,6 +50,7 @@ use ReflectionClass;
|
||||
* @method FormField addFormField(string $type, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method SDT addSDT(string $type)
|
||||
* @method Formula addFormula(Math $math)
|
||||
* @method Ruby addRuby(TextRun $baseText, TextRun $rubyText, \PhpOffice\PhpWord\ComplexType\RubyProperties $properties)
|
||||
* @method \PhpOffice\PhpWord\Element\OLEObject addObject(string $source, mixed $style = null) deprecated, use addOLEObject instead
|
||||
*
|
||||
* @since 0.10.0
|
||||
@@ -58,7 +60,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||
/**
|
||||
* Elements collection.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\AbstractElement[]
|
||||
* @var AbstractElement[]
|
||||
*/
|
||||
protected $elements = [];
|
||||
|
||||
@@ -80,7 +82,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||
* @param mixed $function
|
||||
* @param mixed $args
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
* @return AbstractElement
|
||||
*/
|
||||
public function __call($function, $args)
|
||||
{
|
||||
@@ -90,7 +92,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
|
||||
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
|
||||
'Chart', 'FormField', 'SDT', 'Comment',
|
||||
'Formula',
|
||||
'Formula', 'Ruby',
|
||||
];
|
||||
$functions = [];
|
||||
foreach ($elements as $element) {
|
||||
@@ -130,7 +132,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||
*
|
||||
* @param string $elementName
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
* @return AbstractElement
|
||||
*/
|
||||
protected function addElement($elementName)
|
||||
{
|
||||
@@ -149,7 +151,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||
$elementArgs = $args;
|
||||
array_shift($elementArgs); // Shift the $elementName off the beginning of array
|
||||
|
||||
/** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */
|
||||
/** @var AbstractElement $element Type hint */
|
||||
$element = $reflection->newInstanceArgs($elementArgs);
|
||||
|
||||
// Set parent container
|
||||
@@ -165,7 +167,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||
/**
|
||||
* Get all elements.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement[]
|
||||
* @return AbstractElement[]
|
||||
*/
|
||||
public function getElements()
|
||||
{
|
||||
@@ -177,7 +179,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||
*
|
||||
* @param int $index
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Element\AbstractElement
|
||||
* @return null|AbstractElement
|
||||
*/
|
||||
public function getElement($index)
|
||||
{
|
||||
@@ -191,13 +193,13 @@ abstract class AbstractContainer extends AbstractElement
|
||||
/**
|
||||
* Removes the element at requested index.
|
||||
*
|
||||
* @param int|\PhpOffice\PhpWord\Element\AbstractElement $toRemove
|
||||
* @param AbstractElement|int $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) {
|
||||
} elseif ($toRemove instanceof AbstractElement) {
|
||||
foreach ($this->elements as $key => $element) {
|
||||
if ($element->getElementId() === $toRemove->getElementId()) {
|
||||
unset($this->elements[$key]);
|
||||
@@ -253,7 +255,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||
'Footnote' => ['Section', 'TextRun', 'Cell', 'ListItemRun'],
|
||||
'Endnote' => ['Section', 'TextRun', 'Cell'],
|
||||
'PreserveText' => ['Section', 'Header', 'Footer', 'Cell'],
|
||||
'Title' => ['Section', 'Cell'],
|
||||
'Title' => ['Section', 'Cell', 'Header'],
|
||||
'TOC' => ['Section'],
|
||||
'PageBreak' => ['Section'],
|
||||
'Chart' => ['Section', 'Cell'],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -148,8 +149,6 @@ abstract class AbstractElement
|
||||
|
||||
/**
|
||||
* Get PhpWord.
|
||||
*
|
||||
* @return ?PhpWord
|
||||
*/
|
||||
public function getPhpWord(): ?PhpWord
|
||||
{
|
||||
@@ -256,7 +255,7 @@ abstract class AbstractElement
|
||||
*/
|
||||
public function setElementId(): void
|
||||
{
|
||||
$this->elementId = substr(md5(mt_rand()), 0, 6);
|
||||
$this->elementId = substr(md5((string) mt_rand()), 0, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,8 +290,6 @@ abstract class AbstractElement
|
||||
|
||||
/**
|
||||
* Get comments start.
|
||||
*
|
||||
* @return Comments
|
||||
*/
|
||||
public function getCommentsRangeStart(): ?Comments
|
||||
{
|
||||
@@ -301,8 +298,6 @@ abstract class AbstractElement
|
||||
|
||||
/**
|
||||
* Get comment start.
|
||||
*
|
||||
* @return Comment
|
||||
*/
|
||||
public function getCommentRangeStart(): ?Comment
|
||||
{
|
||||
@@ -339,8 +334,6 @@ abstract class AbstractElement
|
||||
|
||||
/**
|
||||
* Get comments end.
|
||||
*
|
||||
* @return Comments
|
||||
*/
|
||||
public function getCommentsRangeEnd(): ?Comments
|
||||
{
|
||||
@@ -349,8 +342,6 @@ abstract class AbstractElement
|
||||
|
||||
/**
|
||||
* Get comment end.
|
||||
*
|
||||
* @return Comment
|
||||
*/
|
||||
public function getCommentRangeEnd(): ?Comment
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -39,7 +40,7 @@ class Cell extends AbstractContainer
|
||||
/**
|
||||
* Cell style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\Cell
|
||||
* @var ?CellStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
@@ -47,7 +48,7 @@ class Cell extends AbstractContainer
|
||||
* Create new instance.
|
||||
*
|
||||
* @param null|int $width
|
||||
* @param array|\PhpOffice\PhpWord\Style\Cell $style
|
||||
* @param array|CellStyle $style
|
||||
*/
|
||||
public function __construct($width = null, $style = null)
|
||||
{
|
||||
@@ -58,7 +59,7 @@ class Cell extends AbstractContainer
|
||||
/**
|
||||
* Get cell style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\Cell
|
||||
* @return ?CellStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -50,7 +51,7 @@ class Chart extends AbstractElement
|
||||
/**
|
||||
* Chart style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\Chart
|
||||
* @var ?ChartStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
@@ -120,7 +121,7 @@ class Chart extends AbstractElement
|
||||
/**
|
||||
* Get chart style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\Chart
|
||||
* @return ?ChartStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -89,7 +90,7 @@ class Comment extends TrackChange
|
||||
/**
|
||||
* Get the element where this comment starts.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
* @return AbstractElement
|
||||
*/
|
||||
public function getStartElement()
|
||||
{
|
||||
@@ -108,7 +109,7 @@ class Comment extends TrackChange
|
||||
/**
|
||||
* Get the element where this comment ends.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
* @return AbstractElement
|
||||
*/
|
||||
public function getEndElement()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -128,16 +129,16 @@ class Field extends AbstractElement
|
||||
/**
|
||||
* Font style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
* @var Font|string
|
||||
*/
|
||||
protected $fontStyle;
|
||||
|
||||
/**
|
||||
* Set Font style.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Font|string $style
|
||||
* @param array|Font|string $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
* @return Font|string
|
||||
*/
|
||||
public function setFontStyle($style = null)
|
||||
{
|
||||
@@ -158,7 +159,7 @@ class Field extends AbstractElement
|
||||
/**
|
||||
* Get Font style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
* @return Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
@@ -172,7 +173,7 @@ class Field extends AbstractElement
|
||||
* @param array $properties
|
||||
* @param array $options
|
||||
* @param null|string|TextRun $text
|
||||
* @param array|\PhpOffice\PhpWord\Style\Font|string $fontStyle
|
||||
* @param array|Font|string $fontStyle
|
||||
*/
|
||||
public function __construct($type = null, $properties = [], $options = [], $text = null, $fontStyle = null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -29,7 +30,7 @@ class Footnote extends AbstractContainer
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var null|\PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @var null|Paragraph|string
|
||||
*/
|
||||
protected $paragraphStyle;
|
||||
|
||||
@@ -43,7 +44,7 @@ class Footnote extends AbstractContainer
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $paragraphStyle
|
||||
* @param array|Paragraph|string $paragraphStyle
|
||||
*/
|
||||
public function __construct($paragraphStyle = null)
|
||||
{
|
||||
@@ -54,7 +55,7 @@ class Footnote extends AbstractContainer
|
||||
/**
|
||||
* Get paragraph style.
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @return null|Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -27,7 +28,7 @@ class Line extends AbstractElement
|
||||
/**
|
||||
* Line style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\Line
|
||||
* @var ?LineStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
@@ -44,7 +45,7 @@ class Line extends AbstractElement
|
||||
/**
|
||||
* Get line style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\Line
|
||||
* @return ?LineStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -43,14 +44,14 @@ class Link extends AbstractElement
|
||||
/**
|
||||
* Font style.
|
||||
*
|
||||
* @var null|\PhpOffice\PhpWord\Style\Font|string
|
||||
* @var null|Font|string
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var null|\PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @var null|Paragraph|string
|
||||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
@@ -98,10 +99,8 @@ class Link extends AbstractElement
|
||||
|
||||
/**
|
||||
* Get link text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
@@ -109,7 +108,7 @@ class Link extends AbstractElement
|
||||
/**
|
||||
* Get Text style.
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Style\Font|string
|
||||
* @return null|Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
@@ -119,7 +118,7 @@ class Link extends AbstractElement
|
||||
/**
|
||||
* Get Paragraph style.
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @return null|Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -28,14 +29,14 @@ class ListItem extends AbstractElement
|
||||
/**
|
||||
* Element style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\ListItem
|
||||
* @var ?ListItemStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Text object.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\Text
|
||||
* @var Text
|
||||
*/
|
||||
private $textObject;
|
||||
|
||||
@@ -71,7 +72,7 @@ class ListItem extends AbstractElement
|
||||
/**
|
||||
* Get style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\ListItem
|
||||
* @return ?ListItemStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
@@ -81,7 +82,7 @@ class ListItem extends AbstractElement
|
||||
/**
|
||||
* Get Text object.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Text
|
||||
* @return Text
|
||||
*/
|
||||
public function getTextObject()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -32,7 +33,7 @@ class ListItemRun extends TextRun
|
||||
/**
|
||||
* ListItem Style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\ListItem
|
||||
* @var ?ListItemStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
@@ -66,7 +67,7 @@ class ListItemRun extends TextRun
|
||||
/**
|
||||
* Get ListItem style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\ListItem
|
||||
* @return ?ListItemStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -35,7 +36,7 @@ class OLEObject extends AbstractElement
|
||||
/**
|
||||
* Image Style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\Image
|
||||
* @var ?ImageStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
@@ -100,7 +101,7 @@ class OLEObject extends AbstractElement
|
||||
/**
|
||||
* Get object style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\Image
|
||||
* @return ?ImageStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -36,14 +37,14 @@ class PreserveText extends AbstractElement
|
||||
/**
|
||||
* Text style.
|
||||
*
|
||||
* @var null|\PhpOffice\PhpWord\Style\Font|string
|
||||
* @var null|Font|string
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var null|\PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @var null|Paragraph|string
|
||||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
@@ -69,7 +70,7 @@ class PreserveText extends AbstractElement
|
||||
/**
|
||||
* Get Text style.
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Style\Font|string
|
||||
* @return null|Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
@@ -79,7 +80,7 @@ class PreserveText extends AbstractElement
|
||||
/**
|
||||
* Get Paragraph style.
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @return null|Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -36,14 +37,14 @@ class Row extends AbstractElement
|
||||
/**
|
||||
* Row style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\Row
|
||||
* @var ?RowStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Row cells.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\Cell[]
|
||||
* @var Cell[]
|
||||
*/
|
||||
private $cells = [];
|
||||
|
||||
@@ -65,7 +66,7 @@ class Row extends AbstractElement
|
||||
* @param int $width
|
||||
* @param mixed $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Cell
|
||||
* @return Cell
|
||||
*/
|
||||
public function addCell($width = null, $style = null)
|
||||
{
|
||||
@@ -79,7 +80,7 @@ class Row extends AbstractElement
|
||||
/**
|
||||
* Get all cells.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Cell[]
|
||||
* @return Cell[]
|
||||
*/
|
||||
public function getCells()
|
||||
{
|
||||
@@ -89,7 +90,7 @@ class Row extends AbstractElement
|
||||
/**
|
||||
* Get row style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\Row
|
||||
* @return ?RowStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -31,7 +32,7 @@ class Section extends AbstractContainer
|
||||
/**
|
||||
* Section style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\Section
|
||||
* @var ?SectionStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
@@ -87,7 +88,7 @@ class Section extends AbstractContainer
|
||||
/**
|
||||
* Get section style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\Section
|
||||
* @return ?SectionStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
@@ -196,14 +197,14 @@ class Section extends AbstractContainer
|
||||
*/
|
||||
private function addHeaderFooter($type = Header::AUTO, $header = true)
|
||||
{
|
||||
$containerClass = substr(static::class, 0, strrpos(static::class, '\\')) . '\\' .
|
||||
$containerClass = substr(static::class, 0, strrpos(static::class, '\\') ?: 0) . '\\' .
|
||||
($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 */
|
||||
/** @var AbstractContainer $container Type hint */
|
||||
$container = new $containerClass($this->sectionId, ++$index, $type);
|
||||
$container->setPhpWord($this->phpWord);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -36,7 +37,7 @@ class Shape extends AbstractElement
|
||||
/**
|
||||
* Shape style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\Shape
|
||||
* @var ?ShapeStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
@@ -80,7 +81,7 @@ class Shape extends AbstractElement
|
||||
/**
|
||||
* Get shape style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\Shape
|
||||
* @return ?ShapeStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -29,14 +30,14 @@ class TOC extends AbstractElement
|
||||
/**
|
||||
* TOC style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\TOC
|
||||
* @var TOCStyle
|
||||
*/
|
||||
private $tocStyle;
|
||||
|
||||
/**
|
||||
* Font style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
* @var Font|string
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
@@ -94,7 +95,7 @@ class TOC extends AbstractElement
|
||||
|
||||
$titles = $this->phpWord->getTitles()->getItems();
|
||||
foreach ($titles as $i => $title) {
|
||||
/** @var \PhpOffice\PhpWord\Element\Title $title Type hint */
|
||||
/** @var Title $title Type hint */
|
||||
$depth = $title->getDepth();
|
||||
if ($this->minDepth > $depth) {
|
||||
unset($titles[$i]);
|
||||
@@ -110,7 +111,7 @@ class TOC extends AbstractElement
|
||||
/**
|
||||
* Get TOC Style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\TOC
|
||||
* @return TOCStyle
|
||||
*/
|
||||
public function getStyleTOC()
|
||||
{
|
||||
@@ -120,7 +121,7 @@ class TOC extends AbstractElement
|
||||
/**
|
||||
* Get Font Style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
* @return Font|string
|
||||
*/
|
||||
public function getStyleFont()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -27,14 +28,14 @@ class Table extends AbstractElement
|
||||
/**
|
||||
* Table style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\Table
|
||||
* @var ?TableStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* Table rows.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\Row[]
|
||||
* @var Row[]
|
||||
*/
|
||||
private $rows = [];
|
||||
|
||||
@@ -61,7 +62,7 @@ class Table extends AbstractElement
|
||||
* @param int $height
|
||||
* @param mixed $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Row
|
||||
* @return Row
|
||||
*/
|
||||
public function addRow($height = null, $style = null)
|
||||
{
|
||||
@@ -78,7 +79,7 @@ class Table extends AbstractElement
|
||||
* @param int $width
|
||||
* @param mixed $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Cell
|
||||
* @return Cell
|
||||
*/
|
||||
public function addCell($width = null, $style = null)
|
||||
{
|
||||
@@ -92,7 +93,7 @@ class Table extends AbstractElement
|
||||
/**
|
||||
* Get all rows.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Row[]
|
||||
* @return Row[]
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
@@ -102,7 +103,7 @@ class Table extends AbstractElement
|
||||
/**
|
||||
* Get table style.
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Style\Table|string
|
||||
* @return null|string|TableStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
@@ -140,7 +141,7 @@ class Table extends AbstractElement
|
||||
|
||||
$rowCount = count($this->rows);
|
||||
for ($i = 0; $i < $rowCount; ++$i) {
|
||||
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
|
||||
/** @var Row $row Type hint */
|
||||
$row = $this->rows[$i];
|
||||
$cellCount = count($row->getCells());
|
||||
if ($columnCount < $cellCount) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -36,14 +37,14 @@ class Text extends AbstractElement
|
||||
/**
|
||||
* Text style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
* @var Font|string
|
||||
*/
|
||||
protected $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @var Paragraph|string
|
||||
*/
|
||||
protected $paragraphStyle;
|
||||
|
||||
@@ -64,10 +65,10 @@ class Text extends AbstractElement
|
||||
/**
|
||||
* Set Text style.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Font|string $style
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $paragraphStyle
|
||||
* @param array|Font|string $style
|
||||
* @param array|Paragraph|string $paragraphStyle
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
* @return Font|string
|
||||
*/
|
||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||
{
|
||||
@@ -90,7 +91,7 @@ class Text extends AbstractElement
|
||||
/**
|
||||
* Get Text style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
* @return Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
@@ -100,9 +101,9 @@ class Text extends AbstractElement
|
||||
/**
|
||||
* Set Paragraph style.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $style
|
||||
* @param array|Paragraph|string $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @return Paragraph|string
|
||||
*/
|
||||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
@@ -123,7 +124,7 @@ class Text extends AbstractElement
|
||||
/**
|
||||
* Get Paragraph style.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @return Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
@@ -146,10 +147,8 @@ class Text extends AbstractElement
|
||||
|
||||
/**
|
||||
* Get Text content.
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getText()
|
||||
public function getText(): ?string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -34,7 +35,7 @@ class TextBox extends AbstractContainer
|
||||
/**
|
||||
* TextBox style.
|
||||
*
|
||||
* @var ?\PhpOffice\PhpWord\Style\TextBox
|
||||
* @var ?TextBoxStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
@@ -51,7 +52,7 @@ class TextBox extends AbstractContainer
|
||||
/**
|
||||
* Get textbox style.
|
||||
*
|
||||
* @return ?\PhpOffice\PhpWord\Style\TextBox
|
||||
* @return ?TextBoxStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -28,14 +29,14 @@ class TextBreak extends AbstractElement
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var null|\PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @var null|Paragraph|string
|
||||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
/**
|
||||
* Text style.
|
||||
*
|
||||
* @var null|\PhpOffice\PhpWord\Style\Font|string
|
||||
* @var null|Font|string
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
@@ -61,7 +62,7 @@ class TextBreak extends AbstractElement
|
||||
* @param mixed $style
|
||||
* @param mixed $paragraphStyle
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
* @return Font|string
|
||||
*/
|
||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||
{
|
||||
@@ -82,7 +83,7 @@ class TextBreak extends AbstractElement
|
||||
/**
|
||||
* Get Text style.
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Style\Font|string
|
||||
* @return null|Font|string
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
@@ -92,9 +93,9 @@ class TextBreak extends AbstractElement
|
||||
/**
|
||||
* Set Paragraph style.
|
||||
*
|
||||
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $style
|
||||
* @param array|Paragraph|string $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @return Paragraph|string
|
||||
*/
|
||||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
@@ -113,7 +114,7 @@ class TextBreak extends AbstractElement
|
||||
/**
|
||||
* Get Paragraph style.
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Style\Paragraph|string
|
||||
* @return null|Paragraph|string
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -85,6 +86,9 @@ class TextRun extends AbstractContainer
|
||||
foreach ($this->getElements() as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$outstr .= $element->getText();
|
||||
} elseif ($element instanceof Ruby) {
|
||||
$outstr .= $element->getBaseTextRun()->getText() .
|
||||
' (' . $element->getRubyTextRun()->getText() . ')';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -35,7 +36,7 @@ abstract class IOFactory
|
||||
*/
|
||||
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
|
||||
{
|
||||
if ($name !== 'WriterInterface' && !in_array($name, ['ODText', 'RTF', 'Word2007', 'HTML', 'PDF'], true)) {
|
||||
if ($name !== 'WriterInterface' && !in_array($name, ['ODText', 'RTF', 'Word2007', 'HTML', 'PDF', 'EPub3'], true)) {
|
||||
throw new Exception("\"{$name}\" is not a valid writer.");
|
||||
}
|
||||
|
||||
@@ -61,9 +62,9 @@ abstract class IOFactory
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $name
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @param PhpWord $phpWord
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Reader\ReaderInterface|\PhpOffice\PhpWord\Writer\WriterInterface
|
||||
* @return ReaderInterface|WriterInterface
|
||||
*/
|
||||
private static function createObject($type, $name, $phpWord = null)
|
||||
{
|
||||
@@ -81,11 +82,11 @@ abstract class IOFactory
|
||||
* @param string $filename The name of the file
|
||||
* @param string $readerName
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return PhpWord $phpWord
|
||||
*/
|
||||
public static function load($filename, $readerName = 'Word2007')
|
||||
{
|
||||
/** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */
|
||||
/** @var ReaderInterface $reader */
|
||||
$reader = self::createReader($readerName);
|
||||
|
||||
return $reader->load($filename);
|
||||
@@ -100,7 +101,7 @@ abstract class IOFactory
|
||||
*/
|
||||
public static function extractVariables(string $filename, string $readerName = 'Word2007'): array
|
||||
{
|
||||
/** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */
|
||||
/** @var ReaderInterface $reader */
|
||||
$reader = self::createReader($readerName);
|
||||
$document = $reader->load($filename);
|
||||
$extractedVariables = [];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -93,14 +94,14 @@ class Settings
|
||||
/**
|
||||
* Spelling and Grammatical Checking State.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\ComplexType\ProofState
|
||||
* @var ProofState
|
||||
*/
|
||||
private $proofState;
|
||||
|
||||
/**
|
||||
* Document Editing Restrictions.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Metadata\Protection
|
||||
* @var Protection
|
||||
*/
|
||||
private $documentProtection;
|
||||
|
||||
@@ -266,7 +267,7 @@ class Settings
|
||||
/**
|
||||
* Get the Visibility of Annotation Types.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\ComplexType\TrackChangesView
|
||||
* @return TrackChangesView
|
||||
*/
|
||||
public function getRevisionView()
|
||||
{
|
||||
|
||||
57
vendor/phpoffice/phpword/src/PhpWord/PhpWord.php
vendored
57
vendor/phpoffice/phpword/src/PhpWord/PhpWord.php
vendored
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -47,7 +48,7 @@ class PhpWord
|
||||
/**
|
||||
* Collection of sections.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\Section[]
|
||||
* @var Section[]
|
||||
*/
|
||||
private $sections = [];
|
||||
|
||||
@@ -151,7 +152,7 @@ class PhpWord
|
||||
/**
|
||||
* Get document properties object.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Metadata\DocInfo
|
||||
* @return Metadata\DocInfo
|
||||
*/
|
||||
public function getDocInfo()
|
||||
{
|
||||
@@ -161,7 +162,7 @@ class PhpWord
|
||||
/**
|
||||
* Get compatibility.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Metadata\Compatibility
|
||||
* @return Metadata\Compatibility
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
@@ -173,7 +174,7 @@ class PhpWord
|
||||
/**
|
||||
* Get compatibility.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Metadata\Settings
|
||||
* @return Metadata\Settings
|
||||
*
|
||||
* @since 0.14.0
|
||||
*/
|
||||
@@ -185,7 +186,7 @@ class PhpWord
|
||||
/**
|
||||
* Get all sections.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Section[]
|
||||
* @return Section[]
|
||||
*/
|
||||
public function getSections()
|
||||
{
|
||||
@@ -197,7 +198,7 @@ class PhpWord
|
||||
*
|
||||
* @param int $index
|
||||
*
|
||||
* @return null|\PhpOffice\PhpWord\Element\Section
|
||||
* @return null|Section
|
||||
*/
|
||||
public function getSection($index)
|
||||
{
|
||||
@@ -213,7 +214,7 @@ class PhpWord
|
||||
*
|
||||
* @param null|array|string $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Section
|
||||
* @return Section
|
||||
*/
|
||||
public function addSection($style = null)
|
||||
{
|
||||
@@ -256,6 +257,40 @@ class PhpWord
|
||||
Settings::setDefaultFontName($fontName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default asian font name.
|
||||
*/
|
||||
public function getDefaultAsianFontName(): string
|
||||
{
|
||||
return Settings::getDefaultAsianFontName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default asian font name.
|
||||
*
|
||||
* @param string $fontName
|
||||
*/
|
||||
public function setDefaultAsianFontName($fontName): void
|
||||
{
|
||||
Settings::setDefaultAsianFontName($fontName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default font color.
|
||||
*/
|
||||
public function setDefaultFontColor(string $fontColor): void
|
||||
{
|
||||
Settings::setDefaultFontColor($fontColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default font color.
|
||||
*/
|
||||
public function getDefaultFontColor(): string
|
||||
{
|
||||
return Settings::getDefaultFontColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default font size.
|
||||
*
|
||||
@@ -281,7 +316,7 @@ class PhpWord
|
||||
*
|
||||
* @param array $styles Paragraph style definition
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
||||
* @return Style\Paragraph
|
||||
*/
|
||||
public function setDefaultParagraphStyle($styles)
|
||||
{
|
||||
@@ -333,7 +368,7 @@ class PhpWord
|
||||
*
|
||||
* @param array $settings
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Section
|
||||
* @return Section
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
@@ -347,7 +382,7 @@ class PhpWord
|
||||
*
|
||||
* @deprecated 0.12.0
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Metadata\DocInfo
|
||||
* @return Metadata\DocInfo
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
@@ -361,7 +396,7 @@ class PhpWord
|
||||
*
|
||||
* @deprecated 0.12.0
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Metadata\DocInfo $documentProperties
|
||||
* @param Metadata\DocInfo $documentProperties
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -33,7 +34,7 @@ class HTML extends AbstractReader implements ReaderInterface
|
||||
*
|
||||
* @param string $docFile
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\PhpWord
|
||||
* @return PhpWord
|
||||
*/
|
||||
public function load($docFile)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -32,7 +33,7 @@ class ODText extends AbstractReader implements ReaderInterface
|
||||
*
|
||||
* @param string $docFile
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\PhpWord
|
||||
* @return PhpWord
|
||||
*/
|
||||
public function load($docFile)
|
||||
{
|
||||
@@ -58,7 +59,7 @@ class ODText extends AbstractReader implements ReaderInterface
|
||||
{
|
||||
$partClass = "PhpOffice\\PhpWord\\Reader\\ODText\\{$partName}";
|
||||
if (class_exists($partClass)) {
|
||||
/** @var \PhpOffice\PhpWord\Reader\ODText\AbstractPart $part Type hint */
|
||||
/** @var ODText\AbstractPart $part Type hint */
|
||||
$part = new $partClass($docFile, $xmlFile);
|
||||
$part->setRels($relationships);
|
||||
$part->read($phpWord);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -33,7 +34,7 @@ class RTF extends AbstractReader implements ReaderInterface
|
||||
*
|
||||
* @param string $docFile
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\PhpWord
|
||||
* @return PhpWord
|
||||
*/
|
||||
public function load($docFile)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -42,7 +43,7 @@ class Document
|
||||
/**
|
||||
* PhpWord object.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\PhpWord
|
||||
* @var PhpWord
|
||||
*/
|
||||
private $phpWord;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -39,7 +40,7 @@ class Word2007 extends AbstractReader implements ReaderInterface
|
||||
*
|
||||
* @param string $docFile
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\PhpWord
|
||||
* @return PhpWord
|
||||
*/
|
||||
public function load($docFile)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -21,10 +22,13 @@ use DateTime;
|
||||
use DOMElement;
|
||||
use InvalidArgumentException;
|
||||
use PhpOffice\Math\Reader\OfficeMathML;
|
||||
use PhpOffice\PhpWord\ComplexType\RubyProperties;
|
||||
use PhpOffice\PhpWord\ComplexType\TblWidth as TblWidthComplexType;
|
||||
use PhpOffice\PhpWord\Element\AbstractContainer;
|
||||
use PhpOffice\PhpWord\Element\AbstractElement;
|
||||
use PhpOffice\PhpWord\Element\FormField;
|
||||
use PhpOffice\PhpWord\Element\Ruby;
|
||||
use PhpOffice\PhpWord\Element\Text;
|
||||
use PhpOffice\PhpWord\Element\TextRun;
|
||||
use PhpOffice\PhpWord\Element\TrackChange;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
@@ -183,7 +187,7 @@ abstract class AbstractPart
|
||||
/**
|
||||
* Read w:p.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
|
||||
* @param AbstractContainer $parent
|
||||
* @param string $docPart
|
||||
*
|
||||
* @todo Get font style for preserve text
|
||||
@@ -296,7 +300,8 @@ abstract class AbstractPart
|
||||
if ($headingDepth !== null) {
|
||||
$textContent = null;
|
||||
$nodes = $xmlReader->getElements('w:r|w:hyperlink', $domNode);
|
||||
if ($nodes->length === 1) {
|
||||
$hasRubyElement = $xmlReader->elementExists('w:r/w:ruby', $domNode);
|
||||
if ($nodes->length === 1 && !$hasRubyElement) {
|
||||
$textContent = htmlspecialchars($xmlReader->getValue('w:t', $nodes->item(0)), ENT_QUOTES, 'UTF-8');
|
||||
} else {
|
||||
$textContent = new TextRun($paragraphStyle);
|
||||
@@ -450,7 +455,7 @@ abstract class AbstractPart
|
||||
/**
|
||||
* Read w:r.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
|
||||
* @param AbstractContainer $parent
|
||||
* @param string $docPart
|
||||
* @param mixed $paragraphStyle
|
||||
*
|
||||
@@ -584,9 +589,47 @@ abstract class AbstractPart
|
||||
}
|
||||
} elseif ($node->nodeName == 'w:softHyphen') {
|
||||
$element = $parent->addText("\u{200c}", $fontStyle, $paragraphStyle);
|
||||
} elseif ($node->nodeName == 'w:ruby') {
|
||||
$rubyPropertiesNode = $xmlReader->getElement('w:rubyPr', $node);
|
||||
$properties = $this->readRubyProperties($xmlReader, $rubyPropertiesNode);
|
||||
// read base text node
|
||||
$baseText = new TextRun($paragraphStyle);
|
||||
$baseTextNode = $xmlReader->getElement('w:rubyBase/w:r', $node);
|
||||
$this->readRun($xmlReader, $baseTextNode, $baseText, $docPart, $paragraphStyle);
|
||||
// read the actual ruby text (e.g. furigana in Japanese)
|
||||
$rubyText = new TextRun($paragraphStyle);
|
||||
$rubyTextNode = $xmlReader->getElement('w:rt/w:r', $node);
|
||||
$this->readRun($xmlReader, $rubyTextNode, $rubyText, $docPart, $paragraphStyle);
|
||||
// add element to parent
|
||||
$parent->addRuby($baseText, $rubyText, $properties);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read w:rubyPr element.
|
||||
*
|
||||
* @param XMLReader $xmlReader reader for XML
|
||||
* @param DOMElement $domNode w:RubyPr element
|
||||
*
|
||||
* @return RubyProperties ruby properties from element
|
||||
*/
|
||||
protected function readRubyProperties(XMLReader $xmlReader, DOMElement $domNode): RubyProperties
|
||||
{
|
||||
$rubyAlignment = $xmlReader->getElement('w:rubyAlign', $domNode)->getAttribute('w:val');
|
||||
$rubyHps = $xmlReader->getElement('w:hps', $domNode)->getAttribute('w:val'); // font face
|
||||
$rubyHpsRaise = $xmlReader->getElement('w:hpsRaise', $domNode)->getAttribute('w:val'); // pts above base text
|
||||
$rubyHpsBaseText = $xmlReader->getElement('w:hpsBaseText', $domNode)->getAttribute('w:val'); // base text size
|
||||
$rubyLid = $xmlReader->getElement('w:lid', $domNode)->getAttribute('w:val'); // type of ruby
|
||||
$properties = new RubyProperties();
|
||||
$properties->setAlignment($rubyAlignment);
|
||||
$properties->setFontFaceSize((float) $rubyHps);
|
||||
$properties->setFontPointsAboveBaseText((float) $rubyHpsRaise);
|
||||
$properties->setFontSizeForBaseText((float) $rubyHpsBaseText);
|
||||
$properties->setLanguageId($rubyLid);
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read w:tbl.
|
||||
*
|
||||
@@ -661,8 +704,11 @@ abstract class AbstractPart
|
||||
'alignment' => [self::READ_VALUE, 'w:jc'],
|
||||
'basedOn' => [self::READ_VALUE, 'w:basedOn'],
|
||||
'next' => [self::READ_VALUE, 'w:next'],
|
||||
'indent' => [self::READ_VALUE, 'w:ind', 'w:left'],
|
||||
'hanging' => [self::READ_VALUE, 'w:ind', 'w:hanging'],
|
||||
'indentLeft' => [self::READ_VALUE, 'w:ind', 'w:left'],
|
||||
'indentRight' => [self::READ_VALUE, 'w:ind', 'w:right'],
|
||||
'indentHanging' => [self::READ_VALUE, 'w:ind', 'w:hanging'],
|
||||
'indentFirstLine' => [self::READ_VALUE, 'w:ind', 'w:firstLine'],
|
||||
'indentFirstLineChars' => [self::READ_VALUE, 'w:ind', 'w:firstLineChars'],
|
||||
'spaceAfter' => [self::READ_VALUE, 'w:spacing', 'w:after'],
|
||||
'spaceBefore' => [self::READ_VALUE, 'w:spacing', 'w:before'],
|
||||
'widowControl' => [self::READ_FALSE, 'w:widowControl'],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -34,7 +35,7 @@ class Document extends AbstractPart
|
||||
/**
|
||||
* PhpWord object.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\PhpWord
|
||||
* @var PhpWord
|
||||
*/
|
||||
private $phpWord;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -46,6 +47,9 @@ class Styles extends AbstractPart
|
||||
if (array_key_exists('size', $fontDefaultStyle)) {
|
||||
$phpWord->setDefaultFontSize($fontDefaultStyle['size']);
|
||||
}
|
||||
if (array_key_exists('color', $fontDefaultStyle)) {
|
||||
$phpWord->setDefaultFontColor($fontDefaultStyle['color']);
|
||||
}
|
||||
if (array_key_exists('lang', $fontDefaultStyle)) {
|
||||
$phpWord->getSettings()->setThemeFontLang(new Language($fontDefaultStyle['lang']));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -29,7 +30,7 @@ class Settings
|
||||
*/
|
||||
public const ZIPARCHIVE = 'ZipArchive';
|
||||
public const PCLZIP = 'PclZip';
|
||||
public const OLD_LIB = \PhpOffice\PhpWord\Shared\ZipArchive::class; // @deprecated 0.11
|
||||
public const OLD_LIB = Shared\ZipArchive::class; // @deprecated 0.11
|
||||
|
||||
/**
|
||||
* PDF rendering libraries.
|
||||
@@ -117,6 +118,20 @@ class Settings
|
||||
*/
|
||||
private static $defaultFontName = self::DEFAULT_FONT_NAME;
|
||||
|
||||
/**
|
||||
* Default asian font name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $defaultAsianFontName = self::DEFAULT_FONT_NAME;
|
||||
|
||||
/**
|
||||
* Default font color.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $defaultFontColor = self::DEFAULT_FONT_COLOR;
|
||||
|
||||
/**
|
||||
* Default font size.
|
||||
*
|
||||
@@ -354,6 +369,14 @@ class Settings
|
||||
return self::$defaultFontName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default font name.
|
||||
*/
|
||||
public static function getDefaultAsianFontName(): string
|
||||
{
|
||||
return self::$defaultAsianFontName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default font name.
|
||||
*/
|
||||
@@ -368,6 +391,39 @@ class Settings
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function setDefaultAsianFontName(string $value): bool
|
||||
{
|
||||
if (trim($value) !== '') {
|
||||
self::$defaultAsianFontName = $value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default font color.
|
||||
*/
|
||||
public static function getDefaultFontColor(): string
|
||||
{
|
||||
return self::$defaultFontColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default font color.
|
||||
*/
|
||||
public static function setDefaultFontColor(string $value): bool
|
||||
{
|
||||
if (trim($value) !== '') {
|
||||
self::$defaultFontColor = $value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default font size.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -39,10 +40,6 @@ class Css
|
||||
{
|
||||
$cssContent = str_replace(["\r", "\n"], '', $this->cssContent);
|
||||
preg_match_all('/(.+?)\s?\{\s?(.+?)\s?\}/', $cssContent, $cssExtracted);
|
||||
// Check the number of extracted
|
||||
if (count($cssExtracted) != 3) {
|
||||
return;
|
||||
}
|
||||
// Check if there are x selectors and x rules
|
||||
if (count($cssExtracted[1]) != count($cssExtracted[2])) {
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
282
vendor/phpoffice/phpword/src/PhpWord/Shared/Html.php
vendored
282
vendor/phpoffice/phpword/src/PhpWord/Shared/Html.php
vendored
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -22,9 +23,11 @@ use DOMDocument;
|
||||
use DOMNode;
|
||||
use DOMXPath;
|
||||
use Exception;
|
||||
use PhpOffice\PhpWord\ComplexType\RubyProperties;
|
||||
use PhpOffice\PhpWord\Element\AbstractContainer;
|
||||
use PhpOffice\PhpWord\Element\Row;
|
||||
use PhpOffice\PhpWord\Element\Table;
|
||||
use PhpOffice\PhpWord\Element\TextRun;
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
use PhpOffice\PhpWord\SimpleType\Jc;
|
||||
use PhpOffice\PhpWord\SimpleType\NumberFormat;
|
||||
@@ -57,7 +60,7 @@ class Html
|
||||
* Warning: Do not pass user-generated HTML here, as that would allow an attacker to read arbitrary
|
||||
* files or perform server-side request forgery by passing local file paths or URLs in <img>.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element Where the parts need to be added
|
||||
* @param AbstractContainer $element Where the parts need to be added
|
||||
* @param string $html The code to parse
|
||||
* @param bool $fullHTML If it's a full HTML, no need to add 'body' tag
|
||||
* @param bool $preserveWhiteSpace If false, the whitespaces between nodes will be removed
|
||||
@@ -127,21 +130,21 @@ class Html
|
||||
break;
|
||||
case 'width':
|
||||
// tables, cells
|
||||
$val = $val === 'auto' ? '100%' : $val;
|
||||
if (false !== strpos($val, '%')) {
|
||||
// e.g. <table width="100%"> or <td width="50%">
|
||||
$styles['width'] = (int) $val * 50;
|
||||
$styles['unit'] = \PhpOffice\PhpWord\SimpleType\TblWidth::PERCENT;
|
||||
} else {
|
||||
// e.g. <table width="250> where "250" = 250px (always pixels)
|
||||
$styles['width'] = Converter::pixelToTwip($val);
|
||||
$styles['width'] = Converter::pixelToTwip(self::convertHtmlSize($val));
|
||||
$styles['unit'] = \PhpOffice\PhpWord\SimpleType\TblWidth::TWIP;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'cellspacing':
|
||||
// tables e.g. <table cellspacing="2">, where "2" = 2px (always pixels)
|
||||
$val = (int) $val . 'px';
|
||||
$styles['cellSpacing'] = Converter::cssToTwip($val);
|
||||
$styles['cellSpacing'] = Converter::pixelToTwip(self::convertHtmlSize($val));
|
||||
|
||||
break;
|
||||
case 'bgcolor':
|
||||
@@ -185,7 +188,7 @@ class Html
|
||||
* Parse a node and add a corresponding element to the parent element.
|
||||
*
|
||||
* @param DOMNode $node node to parse
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element object to add an element corresponding with the node
|
||||
* @param AbstractContainer $element object to add an element corresponding with the node
|
||||
* @param array $styles Array with all styles
|
||||
* @param array $data Array to transport data to a next level in the DOM tree, for example level of listitems
|
||||
*/
|
||||
@@ -208,16 +211,16 @@ class Html
|
||||
|
||||
// Node mapping table
|
||||
$nodes = [
|
||||
// $method $node $element $styles $data $argument1 $argument2
|
||||
'p' => ['Paragraph', $node, $element, $styles, null, null, null],
|
||||
'h1' => ['Heading', null, $element, $styles, null, 'Heading1', null],
|
||||
'h2' => ['Heading', null, $element, $styles, null, 'Heading2', null],
|
||||
'h3' => ['Heading', null, $element, $styles, null, 'Heading3', null],
|
||||
'h4' => ['Heading', null, $element, $styles, null, 'Heading4', null],
|
||||
'h5' => ['Heading', null, $element, $styles, null, 'Heading5', null],
|
||||
'h6' => ['Heading', null, $element, $styles, null, 'Heading6', null],
|
||||
'#text' => ['Text', $node, $element, $styles, null, null, null],
|
||||
'strong' => ['Property', null, null, $styles, null, 'bold', true],
|
||||
// $method $node $element $styles $data $argument1 $argument2
|
||||
'p' => ['Paragraph', $node, $element, $styles, null, null, null],
|
||||
'h1' => ['Heading', $node, $element, $styles, null, 'Heading1', null],
|
||||
'h2' => ['Heading', $node, $element, $styles, null, 'Heading2', null],
|
||||
'h3' => ['Heading', $node, $element, $styles, null, 'Heading3', null],
|
||||
'h4' => ['Heading', $node, $element, $styles, null, 'Heading4', null],
|
||||
'h5' => ['Heading', $node, $element, $styles, null, 'Heading5', null],
|
||||
'h6' => ['Heading', $node, $element, $styles, null, 'Heading6', null],
|
||||
'#text' => ['Text', $node, $element, $styles, null, null, null],
|
||||
'strong' => ['Property', null, null, $styles, null, 'bold', true],
|
||||
'b' => ['Property', null, null, $styles, null, 'bold', true],
|
||||
'em' => ['Property', null, null, $styles, null, 'italic', true],
|
||||
'i' => ['Property', null, null, $styles, null, 'italic', true],
|
||||
@@ -238,6 +241,7 @@ class Html
|
||||
'a' => ['Link', $node, $element, $styles, null, null, null],
|
||||
'input' => ['Input', $node, $element, $styles, null, null, null],
|
||||
'hr' => ['HorizRule', $node, $element, $styles, null, null, null],
|
||||
'ruby' => ['Ruby', $node, $element, $styles, null, null, null],
|
||||
];
|
||||
|
||||
$newElement = null;
|
||||
@@ -276,7 +280,7 @@ class Html
|
||||
* Parse child nodes.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer|Row|Table $element
|
||||
* @param AbstractContainer|Row|Table $element
|
||||
* @param array $styles
|
||||
* @param array $data
|
||||
*/
|
||||
@@ -298,10 +302,10 @@ class Html
|
||||
* Parse paragraph node.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
* @param array &$styles
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\PageBreak|\PhpOffice\PhpWord\Element\TextRun
|
||||
* @return \PhpOffice\PhpWord\Element\PageBreak|TextRun
|
||||
*/
|
||||
protected static function parseParagraph($node, $element, &$styles)
|
||||
{
|
||||
@@ -317,7 +321,7 @@ class Html
|
||||
* Parse input node.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
* @param array &$styles
|
||||
*/
|
||||
protected static function parseInput($node, $element, &$styles): void
|
||||
@@ -341,28 +345,25 @@ class Html
|
||||
/**
|
||||
* Parse heading node.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param array &$styles
|
||||
* @param string $argument1 Name of heading style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\TextRun
|
||||
*
|
||||
* @todo Think of a clever way of defining header styles, now it is only based on the assumption, that
|
||||
* Heading1 - Heading6 are already defined somewhere
|
||||
*/
|
||||
protected static function parseHeading($element, &$styles, $argument1)
|
||||
protected static function parseHeading(DOMNode $node, AbstractContainer $element, array &$styles, string $argument1): TextRun
|
||||
{
|
||||
$styles['paragraph'] = $argument1;
|
||||
$newElement = $element->addTextRun($styles['paragraph']);
|
||||
$style = new Paragraph();
|
||||
$style->setStyleName($argument1);
|
||||
$style->setStyleByArray(self::parseInlineStyle($node, $styles['paragraph']));
|
||||
|
||||
return $newElement;
|
||||
return $element->addTextRun($style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse text node.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
* @param array &$styles
|
||||
*/
|
||||
protected static function parseText($node, $element, &$styles): void
|
||||
@@ -406,7 +407,7 @@ class Html
|
||||
* Parse table node.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
* @param array &$styles
|
||||
*
|
||||
* @return Table $element
|
||||
@@ -437,7 +438,7 @@ class Html
|
||||
* Parse a table row.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\Table $element
|
||||
* @param Table $element
|
||||
* @param array &$styles
|
||||
*
|
||||
* @return Row $element
|
||||
@@ -460,10 +461,10 @@ class Html
|
||||
* Parse table cell.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\Table $element
|
||||
* @param Table $element
|
||||
* @param array &$styles
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Cell|\PhpOffice\PhpWord\Element\TextRun $element
|
||||
* @return \PhpOffice\PhpWord\Element\Cell|TextRun $element
|
||||
*/
|
||||
protected static function parseCell($node, $element, &$styles)
|
||||
{
|
||||
@@ -554,7 +555,7 @@ class Html
|
||||
* Parse list node.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
* @param array &$styles
|
||||
* @param array &$data
|
||||
*/
|
||||
@@ -627,15 +628,15 @@ class Html
|
||||
return [
|
||||
'type' => 'hybridMultilevel',
|
||||
'levels' => [
|
||||
['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 720, 'left' => 720, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => 'o', 'alignment' => 'left', 'tabPos' => 1440, 'left' => 1440, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 2160, 'left' => 2160, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 2880, 'left' => 2880, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => 'o', 'alignment' => 'left', 'tabPos' => 3600, 'left' => 3600, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 4320, 'left' => 4320, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 5040, 'left' => 5040, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => 'o', 'alignment' => 'left', 'tabPos' => 5760, 'left' => 5760, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 6480, 'left' => 6480, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '•', 'alignment' => 'left', 'tabPos' => 720, 'left' => 720, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '◦', 'alignment' => 'left', 'tabPos' => 1440, 'left' => 1440, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '•', 'alignment' => 'left', 'tabPos' => 2160, 'left' => 2160, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '•', 'alignment' => 'left', 'tabPos' => 2880, 'left' => 2880, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '◦', 'alignment' => 'left', 'tabPos' => 3600, 'left' => 3600, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '•', 'alignment' => 'left', 'tabPos' => 4320, 'left' => 4320, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '•', 'alignment' => 'left', 'tabPos' => 5040, 'left' => 5040, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '◦', 'alignment' => 'left', 'tabPos' => 5760, 'left' => 5760, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],
|
||||
['format' => NumberFormat::BULLET, 'text' => '•', 'alignment' => 'left', 'tabPos' => 6480, 'left' => 6480, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'],
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -644,7 +645,7 @@ class Html
|
||||
* Parse list item node.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
* @param array &$styles
|
||||
* @param array $data
|
||||
*
|
||||
@@ -704,6 +705,10 @@ class Html
|
||||
case 'text-align':
|
||||
$styles['alignment'] = self::mapAlign($value, $bidi);
|
||||
|
||||
break;
|
||||
case 'ruby-align':
|
||||
$styles['rubyAlignment'] = self::mapRubyAlign($value);
|
||||
|
||||
break;
|
||||
case 'display':
|
||||
$styles['hidden'] = $value === 'none' || $value === 'hidden';
|
||||
@@ -733,7 +738,7 @@ class Html
|
||||
break;
|
||||
case 'line-height':
|
||||
$matches = [];
|
||||
if ($value === 'normal') {
|
||||
if ($value === 'normal' || $value === 'inherit') {
|
||||
$spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::AUTO;
|
||||
$spacing = 0;
|
||||
} elseif (preg_match('/([0-9]+\.?[0-9]*[a-z]+)/', $value, $matches)) {
|
||||
@@ -803,6 +808,58 @@ class Html
|
||||
$styles['spaceAfter'] = Converter::cssToTwip($value);
|
||||
|
||||
break;
|
||||
|
||||
case 'padding':
|
||||
$valueTop = $valueRight = $valueBottom = $valueLeft = null;
|
||||
$cValue = preg_replace('# +#', ' ', trim($value));
|
||||
$paddingArr = explode(' ', $cValue);
|
||||
$countParams = count($paddingArr);
|
||||
if ($countParams == 1) {
|
||||
$valueTop = $valueRight = $valueBottom = $valueLeft = $paddingArr[0];
|
||||
} elseif ($countParams == 2) {
|
||||
$valueTop = $valueBottom = $paddingArr[0];
|
||||
$valueRight = $valueLeft = $paddingArr[1];
|
||||
} elseif ($countParams == 3) {
|
||||
$valueTop = $paddingArr[0];
|
||||
$valueRight = $valueLeft = $paddingArr[1];
|
||||
$valueBottom = $paddingArr[2];
|
||||
} elseif ($countParams == 4) {
|
||||
$valueTop = $paddingArr[0];
|
||||
$valueRight = $paddingArr[1];
|
||||
$valueBottom = $paddingArr[2];
|
||||
$valueLeft = $paddingArr[3];
|
||||
}
|
||||
if ($valueTop !== null) {
|
||||
$styles['paddingTop'] = Converter::cssToTwip($valueTop);
|
||||
}
|
||||
if ($valueRight !== null) {
|
||||
$styles['paddingRight'] = Converter::cssToTwip($valueRight);
|
||||
}
|
||||
if ($valueBottom !== null) {
|
||||
$styles['paddingBottom'] = Converter::cssToTwip($valueBottom);
|
||||
}
|
||||
if ($valueLeft !== null) {
|
||||
$styles['paddingLeft'] = Converter::cssToTwip($valueLeft);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'padding-top':
|
||||
$styles['paddingTop'] = Converter::cssToTwip($value);
|
||||
|
||||
break;
|
||||
case 'padding-right':
|
||||
$styles['paddingRight'] = Converter::cssToTwip($value);
|
||||
|
||||
break;
|
||||
case 'padding-bottom':
|
||||
$styles['paddingBottom'] = Converter::cssToTwip($value);
|
||||
|
||||
break;
|
||||
case 'padding-left':
|
||||
$styles['paddingLeft'] = Converter::cssToTwip($value);
|
||||
|
||||
break;
|
||||
|
||||
case 'border-color':
|
||||
self::mapBorderColor($styles, $value);
|
||||
|
||||
@@ -886,7 +943,7 @@ class Html
|
||||
* Parse image node.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Image
|
||||
*/
|
||||
@@ -901,36 +958,12 @@ class Html
|
||||
|
||||
break;
|
||||
case 'width':
|
||||
$width = $attribute->value;
|
||||
|
||||
// pt
|
||||
if (false !== strpos($width, 'pt')) {
|
||||
$width = Converter::pointToPixel((float) str_replace('pt', '', $width));
|
||||
}
|
||||
|
||||
// px
|
||||
if (false !== strpos($width, 'px')) {
|
||||
$width = str_replace('px', '', $width);
|
||||
}
|
||||
|
||||
$style['width'] = $width;
|
||||
$style['width'] = self::convertHtmlSize($attribute->value);
|
||||
$style['unit'] = \PhpOffice\PhpWord\Style\Image::UNIT_PX;
|
||||
|
||||
break;
|
||||
case 'height':
|
||||
$height = $attribute->value;
|
||||
|
||||
// pt
|
||||
if (false !== strpos($height, 'pt')) {
|
||||
$height = Converter::pointToPixel((float) str_replace('pt', '', $height));
|
||||
}
|
||||
|
||||
// px
|
||||
if (false !== strpos($height, 'px')) {
|
||||
$height = str_replace('px', '', $height);
|
||||
}
|
||||
|
||||
$style['height'] = $height;
|
||||
$style['height'] = self::convertHtmlSize($attribute->value);
|
||||
$style['unit'] = \PhpOffice\PhpWord\Style\Image::UNIT_PX;
|
||||
|
||||
break;
|
||||
@@ -970,14 +1003,15 @@ class Html
|
||||
|
||||
$match = [];
|
||||
preg_match('/data:image\/(\w+);base64,(.+)/', $src, $match);
|
||||
if (!empty($match)) {
|
||||
$src = $imgFile = $tmpDir . uniqid() . '.' . $match[1];
|
||||
|
||||
$src = $imgFile = $tmpDir . uniqid() . '.' . $match[1];
|
||||
$ifp = fopen($imgFile, 'wb');
|
||||
|
||||
$ifp = fopen($imgFile, 'wb');
|
||||
|
||||
if ($ifp !== false) {
|
||||
fwrite($ifp, base64_decode($match[2]));
|
||||
fclose($ifp);
|
||||
if ($ifp !== false) {
|
||||
fwrite($ifp, base64_decode($match[2]));
|
||||
fclose($ifp);
|
||||
}
|
||||
}
|
||||
}
|
||||
$src = urldecode($src);
|
||||
@@ -1073,6 +1107,23 @@ class Html
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a HTML/CSS ruby alignment into a \PhpOffice\PhpWord\SimpleType\Jc.
|
||||
*/
|
||||
protected static function mapRubyAlign(string $cssRubyAlignment): string
|
||||
{
|
||||
switch ($cssRubyAlignment) {
|
||||
case 'center':
|
||||
return RubyProperties::ALIGNMENT_CENTER;
|
||||
case 'start':
|
||||
return RubyProperties::ALIGNMENT_LEFT;
|
||||
case 'space-between':
|
||||
return RubyProperties::ALIGNMENT_DISTRIBUTE_SPACE;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a HTML/CSS vertical alignment.
|
||||
*
|
||||
@@ -1129,7 +1180,7 @@ class Html
|
||||
/**
|
||||
* Parse line break.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
*/
|
||||
protected static function parseLineBreak($element): void
|
||||
{
|
||||
@@ -1140,7 +1191,7 @@ class Html
|
||||
* Parse link node.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
* @param array $styles
|
||||
*/
|
||||
protected static function parseLink($node, $element, &$styles)
|
||||
@@ -1172,7 +1223,7 @@ class Html
|
||||
* Note: Word rule is not the same as HTML's <hr> since it does not support width and thus neither alignment.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
|
||||
* @param AbstractContainer $element
|
||||
*/
|
||||
protected static function parseHorizRule($node, $element): void
|
||||
{
|
||||
@@ -1201,6 +1252,59 @@ class Html
|
||||
// - repeated text, e.g. underline "_", because of unpredictable line wrapping
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ruby node.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param AbstractContainer $element
|
||||
* @param array $styles
|
||||
*/
|
||||
protected static function parseRuby($node, $element, &$styles)
|
||||
{
|
||||
$rubyProperties = new RubyProperties();
|
||||
$baseTextRun = new TextRun($styles['paragraph']);
|
||||
$rubyTextRun = new TextRun(null);
|
||||
if ($node->hasAttributes()) {
|
||||
$langAttr = $node->attributes->getNamedItem('lang');
|
||||
if ($langAttr !== null) {
|
||||
$rubyProperties->setLanguageId($langAttr->textContent);
|
||||
}
|
||||
$styleAttr = $node->attributes->getNamedItem('style');
|
||||
if ($styleAttr !== null) {
|
||||
$styles = self::parseStyle($styleAttr, $styles['paragraph']);
|
||||
if (isset($styles['rubyAlignment']) && $styles['rubyAlignment'] !== '') {
|
||||
$rubyProperties->setAlignment($styles['rubyAlignment']);
|
||||
}
|
||||
if (isset($styles['size']) && $styles['size'] !== '') {
|
||||
$rubyProperties->setFontSizeForBaseText($styles['size']);
|
||||
}
|
||||
$baseTextRun->setParagraphStyle($styles);
|
||||
}
|
||||
}
|
||||
foreach ($node->childNodes as $child) {
|
||||
if ($child->nodeName === '#text') {
|
||||
$content = trim($child->textContent);
|
||||
if ($content !== '') {
|
||||
$baseTextRun->addText($content);
|
||||
}
|
||||
} elseif ($child->nodeName === 'rt') {
|
||||
$rubyTextRun->addText(trim($child->textContent));
|
||||
if ($child->hasAttributes()) {
|
||||
$styleAttr = $child->attributes->getNamedItem('style');
|
||||
if ($styleAttr !== null) {
|
||||
$styles = self::parseStyle($styleAttr, []);
|
||||
if (isset($styles['size']) && $styles['size'] !== '') {
|
||||
$rubyProperties->setFontFaceSize($styles['size']);
|
||||
}
|
||||
$rubyTextRun->setParagraphStyle($styles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $element->addRuby($baseTextRun, $rubyTextRun, $rubyProperties);
|
||||
}
|
||||
|
||||
private static function convertRgb(string $rgb): string
|
||||
{
|
||||
if (preg_match(self::RGB_REGEXP, $rgb, $matches) === 1) {
|
||||
@@ -1209,4 +1313,22 @@ class Html
|
||||
|
||||
return trim($rgb, '# ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform HTML sizes (pt, px) in pixels.
|
||||
*/
|
||||
protected static function convertHtmlSize(string $size): float
|
||||
{
|
||||
// pt
|
||||
if (false !== strpos($size, 'pt')) {
|
||||
return Converter::pointToPixel((float) str_replace('pt', '', $size));
|
||||
}
|
||||
|
||||
// px
|
||||
if (false !== strpos($size, 'px')) {
|
||||
return (float) str_replace('px', '', $size);
|
||||
}
|
||||
|
||||
return (float) $size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -17,6 +18,8 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Shared\Microsoft;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
|
||||
/**
|
||||
* Password encoder for microsoft office applications.
|
||||
*/
|
||||
@@ -118,8 +121,11 @@ class PasswordEncoder
|
||||
// Get the single-byte values by iterating through the Unicode characters of the truncated password.
|
||||
// For each character, if the low byte is not equal to 0, take it. Otherwise, take the high byte.
|
||||
$passUtf8 = mb_convert_encoding($password, 'UCS-2LE', 'UTF-8');
|
||||
$byteChars = [];
|
||||
if (!is_string($passUtf8)) {
|
||||
throw new Exception('Failed to convert password to UCS-2LE');
|
||||
}
|
||||
|
||||
$byteChars = [];
|
||||
for ($i = 0; $i < mb_strlen($password); ++$i) {
|
||||
$byteChars[$i] = ord(substr($passUtf8, $i * 2, 1));
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -17,6 +18,8 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Shared;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
|
||||
/**
|
||||
* Text.
|
||||
*/
|
||||
@@ -147,6 +150,9 @@ class Text
|
||||
if (null !== $value && !self::isUTF8($value)) {
|
||||
// PHP8.2 : utf8_encode is deprecated, but mb_convert_encoding always usable
|
||||
$value = (function_exists('mb_convert_encoding')) ? mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1') : utf8_encode($value);
|
||||
if ($value === false) {
|
||||
throw new Exception('Unable to convert text to UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -293,8 +294,10 @@ class ZipArchive
|
||||
|
||||
// Write $contents to a temp file
|
||||
$handle = fopen($this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename'], 'wb');
|
||||
fwrite($handle, $contents);
|
||||
fclose($handle);
|
||||
if ($handle) {
|
||||
fwrite($handle, $contents);
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
// Add temp file to zip
|
||||
$filename = $this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename'];
|
||||
@@ -420,4 +423,15 @@ class ZipArchive
|
||||
|
||||
return ($listIndex > -1) ? $listIndex : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an empty directory to the zip archive (emulate \ZipArchive).
|
||||
*
|
||||
* @param string $dirname Directory name to add to the zip archive
|
||||
*/
|
||||
public function addEmptyDir(string $dirname): bool
|
||||
{
|
||||
// Create a directory entry by adding an empty file with trailing slash
|
||||
return $this->addFromString(rtrim($dirname, '/') . '/', '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -26,7 +27,7 @@ use PhpOffice\PhpWord\Shared\AbstractEnum;
|
||||
* Since ISO/IEC-29500:2008 the type must not be used for table alignment.
|
||||
*
|
||||
* @since 0.13.0
|
||||
* @see \PhpOffice\PhpWord\SimpleType\JcTable For table alignment modes available since ISO/IEC-29500:2008.
|
||||
* @see JcTable For table alignment modes available since ISO/IEC-29500:2008.
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_ST_Jc.html
|
||||
*/
|
||||
final class Jc extends AbstractEnum
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user