Merge pull request #1996 from liborm85/drop-common-package
Remove legacy PHPOffice/Common package, fix PHP 8.0 compatibility
This commit is contained in:
commit
06c82488a8
|
|
@ -24,8 +24,6 @@ matrix:
|
||||||
dist: trusty
|
dist: trusty
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: COVERAGE=1
|
env: COVERAGE=1
|
||||||
- php: 8.0
|
|
||||||
env: DEPENDENCIES="--ignore-platform-reqs"
|
|
||||||
exclude:
|
exclude:
|
||||||
- php: 5.3
|
- php: 5.3
|
||||||
dist: xenial
|
dist: xenial
|
||||||
|
|
@ -33,8 +31,6 @@ matrix:
|
||||||
dist: xenial
|
dist: xenial
|
||||||
- php: 5.5
|
- php: 5.5
|
||||||
dist: xenial
|
dist: xenial
|
||||||
allow_failures:
|
|
||||||
- php: 8.0
|
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,7 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.3.3 || ^7.0 || ^8.0",
|
"php": "^5.3.3 || ^7.0 || ^8.0",
|
||||||
"ext-xml": "*",
|
"ext-xml": "*",
|
||||||
"laminas/laminas-escaper": "^2.2",
|
"laminas/laminas-escaper": "^2.2"
|
||||||
"phpoffice/common": "^0.2.9"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-zip": "*",
|
"ext-zip": "*",
|
||||||
|
|
@ -71,7 +70,7 @@
|
||||||
"friendsofphp/php-cs-fixer": "^2.2",
|
"friendsofphp/php-cs-fixer": "^2.2",
|
||||||
"phpmd/phpmd": "2.*",
|
"phpmd/phpmd": "2.*",
|
||||||
"phploc/phploc": "2.* || 3.* || 4.* || 5.* || 6.* || 7.*",
|
"phploc/phploc": "2.* || 3.* || 4.* || 5.* || 6.* || 7.*",
|
||||||
"dompdf/dompdf":"0.8.*",
|
"dompdf/dompdf":"0.8.* || 1.0.*",
|
||||||
"tecnickcom/tcpdf": "6.*",
|
"tecnickcom/tcpdf": "6.*",
|
||||||
"mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
|
"mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
|
||||||
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
|
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\Text as CommonText;
|
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bookmark element
|
* Bookmark element
|
||||||
|
|
@ -45,7 +45,7 @@ class Bookmark extends AbstractElement
|
||||||
*/
|
*/
|
||||||
public function __construct($name = '')
|
public function __construct($name = '')
|
||||||
{
|
{
|
||||||
$this->name = CommonText::toUTF8($name);
|
$this->name = SharedText::toUTF8($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\Text as CommonText;
|
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check box element
|
* Check box element
|
||||||
|
|
@ -55,7 +55,7 @@ class CheckBox extends Text
|
||||||
*/
|
*/
|
||||||
public function setName($name)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
$this->name = CommonText::toUTF8($name);
|
$this->name = SharedText::toUTF8($name);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\Text as CommonText;
|
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
|
|
||||||
|
|
@ -79,8 +79,8 @@ class Link extends AbstractElement
|
||||||
*/
|
*/
|
||||||
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
|
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
|
||||||
{
|
{
|
||||||
$this->source = CommonText::toUTF8($source);
|
$this->source = SharedText::toUTF8($source);
|
||||||
$this->text = is_null($text) ? $this->source : CommonText::toUTF8($text);
|
$this->text = is_null($text) ? $this->source : SharedText::toUTF8($text);
|
||||||
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
||||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
$this->internal = $internal;
|
$this->internal = $internal;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\Text as CommonText;
|
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||||
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
|
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -57,7 +57,7 @@ class ListItem extends AbstractElement
|
||||||
*/
|
*/
|
||||||
public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
|
public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
$this->textObject = new Text(CommonText::toUTF8($text), $fontStyle, $paragraphStyle);
|
$this->textObject = new Text(SharedText::toUTF8($text), $fontStyle, $paragraphStyle);
|
||||||
$this->depth = $depth;
|
$this->depth = $depth;
|
||||||
|
|
||||||
// Version >= 0.10.0 will pass numbering style name. Older version will use old method
|
// Version >= 0.10.0 will pass numbering style name. Older version will use old method
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\Text as CommonText;
|
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ class PreserveText extends AbstractElement
|
||||||
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
||||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
|
|
||||||
$this->text = CommonText::toUTF8($text);
|
$this->text = SharedText::toUTF8($text);
|
||||||
$matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
$matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||||
if (isset($matches[0])) {
|
if (isset($matches[0])) {
|
||||||
$this->text = $matches;
|
$this->text = $matches;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\Text as CommonText;
|
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ class Text extends AbstractElement
|
||||||
*/
|
*/
|
||||||
public function setText($text)
|
public function setText($text)
|
||||||
{
|
{
|
||||||
$this->text = CommonText::toUTF8($text);
|
$this->text = SharedText::toUTF8($text);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\Text as CommonText;
|
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,7 +62,7 @@ class Title extends AbstractElement
|
||||||
public function __construct($text, $depth = 1)
|
public function __construct($text, $depth = 1)
|
||||||
{
|
{
|
||||||
if (is_string($text)) {
|
if (is_string($text)) {
|
||||||
$this->text = CommonText::toUTF8($text);
|
$this->text = SharedText::toUTF8($text);
|
||||||
} elseif ($text instanceof TextRun) {
|
} elseif ($text instanceof TextRun) {
|
||||||
$this->text = $text;
|
$this->text = $text;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Metadata;
|
namespace PhpOffice\PhpWord\Metadata;
|
||||||
|
|
||||||
use PhpOffice\Common\Microsoft\PasswordEncoder;
|
use PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder;
|
||||||
use PhpOffice\PhpWord\SimpleType\DocProtect;
|
use PhpOffice\PhpWord\SimpleType\DocProtect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader;
|
namespace PhpOffice\PhpWord\Reader;
|
||||||
|
|
||||||
use PhpOffice\Common\Drawing;
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\Drawing;
|
||||||
use PhpOffice\PhpWord\Shared\OLERead;
|
use PhpOffice\PhpWord\Shared\OLERead;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader;
|
namespace PhpOffice\PhpWord\Reader;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reader for ODText
|
* Reader for ODText
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\ODText;
|
namespace PhpOffice\PhpWord\Reader\ODText;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\Element\TrackChange;
|
use PhpOffice\PhpWord\Element\TrackChange;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content reader
|
* Content reader
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\ODText;
|
namespace PhpOffice\PhpWord\Reader\ODText;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta reader
|
* Meta reader
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader;
|
namespace PhpOffice\PhpWord\Reader;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
use PhpOffice\PhpWord\Shared\ZipArchive;
|
use PhpOffice\PhpWord\Shared\ZipArchive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\ComplexType\TblWidth as TblWidthComplexType;
|
use PhpOffice\PhpWord\ComplexType\TblWidth as TblWidthComplexType;
|
||||||
use PhpOffice\PhpWord\Element\AbstractContainer;
|
use PhpOffice\PhpWord\Element\AbstractContainer;
|
||||||
use PhpOffice\PhpWord\Element\TextRun;
|
use PhpOffice\PhpWord\Element\TextRun;
|
||||||
use PhpOffice\PhpWord\Element\TrackChange;
|
use PhpOffice\PhpWord\Element\TrackChange;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract part reader
|
* Abstract part reader
|
||||||
|
|
@ -95,7 +95,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:p.
|
* Read w:p.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
|
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
|
||||||
* @param string $docPart
|
* @param string $docPart
|
||||||
|
|
@ -202,7 +202,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:r.
|
* Read w:r.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
|
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
|
||||||
* @param string $docPart
|
* @param string $docPart
|
||||||
|
|
@ -320,7 +320,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:tbl.
|
* Read w:tbl.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @param mixed $parent
|
* @param mixed $parent
|
||||||
* @param string $docPart
|
* @param string $docPart
|
||||||
|
|
@ -378,7 +378,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:pPr.
|
* Read w:pPr.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
|
|
@ -413,7 +413,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:rPr
|
* Read w:rPr
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
|
|
@ -459,7 +459,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:tblPr
|
* Read w:tblPr
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @return string|array|null
|
* @return string|array|null
|
||||||
* @todo Capture w:tblStylePr w:type="firstRow"
|
* @todo Capture w:tblStylePr w:type="firstRow"
|
||||||
|
|
@ -509,7 +509,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:tblpPr
|
* Read w:tblpPr
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|
@ -534,7 +534,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:tblInd
|
* Read w:tblInd
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @return TblWidthComplexType
|
* @return TblWidthComplexType
|
||||||
*/
|
*/
|
||||||
|
|
@ -552,7 +552,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:tcPr
|
* Read w:tcPr
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|
@ -620,7 +620,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read style definition
|
* Read style definition
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $parentNode
|
* @param \DOMElement $parentNode
|
||||||
* @param array $styleDefs
|
* @param array $styleDefs
|
||||||
* @ignoreScrutinizerPatch
|
* @ignoreScrutinizerPatch
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core properties reader
|
* Core properties reader
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\Metadata\DocInfo;
|
use PhpOffice\PhpWord\Metadata\DocInfo;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom properties reader
|
* Custom properties reader
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\Element\Section;
|
use PhpOffice\PhpWord\Element\Section;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document reader
|
* Document reader
|
||||||
|
|
@ -97,7 +97,7 @@ class Document extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:sectPr
|
* Read w:sectPr
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $domNode
|
* @param \DOMElement $domNode
|
||||||
* @ignoreScrutinizerPatch
|
* @ignoreScrutinizerPatch
|
||||||
* @return array
|
* @return array
|
||||||
|
|
@ -141,7 +141,7 @@ class Document extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:p node.
|
* Read w:p node.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $node
|
* @param \DOMElement $node
|
||||||
* @param \PhpOffice\PhpWord\Element\Section &$section
|
* @param \PhpOffice\PhpWord\Element\Section &$section
|
||||||
*
|
*
|
||||||
|
|
@ -170,7 +170,7 @@ class Document extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read w:sectPr node.
|
* Read w:sectPr node.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $node
|
* @param \DOMElement $node
|
||||||
* @param \PhpOffice\PhpWord\Element\Section &$section
|
* @param \PhpOffice\PhpWord\Element\Section &$section
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Footnotes reader
|
* Footnotes reader
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Numbering reader
|
* Numbering reader
|
||||||
|
|
@ -89,7 +89,7 @@ class Numbering extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Read numbering level definition from w:abstractNum and w:num
|
* Read numbering level definition from w:abstractNum and w:num
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||||
* @param \DOMElement $subnode
|
* @param \DOMElement $subnode
|
||||||
* @param int $levelId
|
* @param int $levelId
|
||||||
* @return array
|
* @return array
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
use PhpOffice\PhpWord\Style\Language;
|
use PhpOffice\PhpWord\Style\Language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLReader;
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||||
use PhpOffice\PhpWord\Style\Language;
|
use PhpOffice\PhpWord\Style\Language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,248 @@
|
||||||
|
<?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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drawing
|
||||||
|
*/
|
||||||
|
class Drawing
|
||||||
|
{
|
||||||
|
const DPI_96 = 96;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert pixels to EMU
|
||||||
|
*
|
||||||
|
* @param int $pValue Value in pixels
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function pixelsToEmu($pValue = 0)
|
||||||
|
{
|
||||||
|
return round($pValue * 9525);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert EMU to pixels
|
||||||
|
*
|
||||||
|
* @param int $pValue Value in EMU
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function emuToPixels($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return round($pValue / 9525);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert pixels to points
|
||||||
|
*
|
||||||
|
* @param int $pValue Value in pixels
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function pixelsToPoints($pValue = 0)
|
||||||
|
{
|
||||||
|
return $pValue * 0.67777777;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert points width to centimeters
|
||||||
|
*
|
||||||
|
* @param int $pValue Value in points
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function pointsToCentimeters($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (($pValue * 1.333333333) / self::DPI_96) * 2.54;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert points width to pixels
|
||||||
|
*
|
||||||
|
* @param int $pValue Value in points
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function pointsToPixels($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pValue * 1.333333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert pixels to centimeters
|
||||||
|
*
|
||||||
|
* @param int $pValue Value in pixels
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function pixelsToCentimeters($pValue = 0)
|
||||||
|
{
|
||||||
|
//return $pValue * 0.028;
|
||||||
|
return ($pValue / self::DPI_96) * 2.54;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert centimeters width to pixels
|
||||||
|
*
|
||||||
|
* @param int $pValue Value in centimeters
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function centimetersToPixels($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($pValue / 2.54) * self::DPI_96;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert degrees to angle
|
||||||
|
*
|
||||||
|
* @param int $pValue Degrees
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function degreesToAngle($pValue = 0)
|
||||||
|
{
|
||||||
|
return (int) round($pValue * 60000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert angle to degrees
|
||||||
|
*
|
||||||
|
* @param int $pValue Angle
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function angleToDegrees($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return round($pValue / 60000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert centimeters width to twips
|
||||||
|
*
|
||||||
|
* @param int $pValue
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function centimetersToTwips($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pValue * 566.928;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert twips width to centimeters
|
||||||
|
*
|
||||||
|
* @param int $pValue
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function twipsToCentimeters($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pValue / 566.928;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert inches width to twips
|
||||||
|
*
|
||||||
|
* @param int $pValue
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function inchesToTwips($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pValue * 1440;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert twips width to inches
|
||||||
|
*
|
||||||
|
* @param int $pValue
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function twipsToInches($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pValue / 1440;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert twips width to pixels
|
||||||
|
*
|
||||||
|
* @param int $pValue
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function twipsToPixels($pValue = 0)
|
||||||
|
{
|
||||||
|
if ($pValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return round($pValue / 15.873984);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert HTML hexadecimal to RGB
|
||||||
|
*
|
||||||
|
* @param string $pValue HTML Color in hexadecimal
|
||||||
|
* @return array|false Value in RGB
|
||||||
|
*/
|
||||||
|
public static function htmlToRGB($pValue)
|
||||||
|
{
|
||||||
|
if ($pValue[0] == '#') {
|
||||||
|
$pValue = substr($pValue, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($pValue) == 6) {
|
||||||
|
list($colorR, $colorG, $colorB) = array($pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]);
|
||||||
|
} elseif (strlen($pValue) == 3) {
|
||||||
|
list($colorR, $colorG, $colorB) = array($pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$colorR = hexdec($colorR);
|
||||||
|
$colorG = hexdec($colorG);
|
||||||
|
$colorB = hexdec($colorB);
|
||||||
|
|
||||||
|
return array($colorR, $colorG, $colorB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,235 @@
|
||||||
|
<?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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared\Microsoft;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Password encoder for microsoft office applications
|
||||||
|
*/
|
||||||
|
class PasswordEncoder
|
||||||
|
{
|
||||||
|
const ALGORITHM_MD2 = 'MD2';
|
||||||
|
const ALGORITHM_MD4 = 'MD4';
|
||||||
|
const ALGORITHM_MD5 = 'MD5';
|
||||||
|
const ALGORITHM_SHA_1 = 'SHA-1';
|
||||||
|
const ALGORITHM_SHA_256 = 'SHA-256';
|
||||||
|
const ALGORITHM_SHA_384 = 'SHA-384';
|
||||||
|
const ALGORITHM_SHA_512 = 'SHA-512';
|
||||||
|
const ALGORITHM_RIPEMD = 'RIPEMD';
|
||||||
|
const ALGORITHM_RIPEMD_160 = 'RIPEMD-160';
|
||||||
|
const ALGORITHM_MAC = 'MAC';
|
||||||
|
const ALGORITHM_HMAC = 'HMAC';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping between algorithm name and algorithm ID
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see https://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.writeprotection.cryptographicalgorithmsid(v=office.14).aspx
|
||||||
|
*/
|
||||||
|
private static $algorithmMapping = array(
|
||||||
|
self::ALGORITHM_MD2 => array(1, 'md2'),
|
||||||
|
self::ALGORITHM_MD4 => array(2, 'md4'),
|
||||||
|
self::ALGORITHM_MD5 => array(3, 'md5'),
|
||||||
|
self::ALGORITHM_SHA_1 => array(4, 'sha1'),
|
||||||
|
self::ALGORITHM_MAC => array(5, ''), // 'mac' -> not possible with hash()
|
||||||
|
self::ALGORITHM_RIPEMD => array(6, 'ripemd'),
|
||||||
|
self::ALGORITHM_RIPEMD_160 => array(7, 'ripemd160'),
|
||||||
|
self::ALGORITHM_HMAC => array(9, ''), //'hmac' -> not possible with hash()
|
||||||
|
self::ALGORITHM_SHA_256 => array(12, 'sha256'),
|
||||||
|
self::ALGORITHM_SHA_384 => array(13, 'sha384'),
|
||||||
|
self::ALGORITHM_SHA_512 => array(14, 'sha512'),
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $initialCodeArray = array(
|
||||||
|
0xE1F0,
|
||||||
|
0x1D0F,
|
||||||
|
0xCC9C,
|
||||||
|
0x84C0,
|
||||||
|
0x110C,
|
||||||
|
0x0E10,
|
||||||
|
0xF1CE,
|
||||||
|
0x313E,
|
||||||
|
0x1872,
|
||||||
|
0xE139,
|
||||||
|
0xD40F,
|
||||||
|
0x84F9,
|
||||||
|
0x280C,
|
||||||
|
0xA96A,
|
||||||
|
0x4EC3,
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $encryptionMatrix = array(
|
||||||
|
array(0xAEFC, 0x4DD9, 0x9BB2, 0x2745, 0x4E8A, 0x9D14, 0x2A09),
|
||||||
|
array(0x7B61, 0xF6C2, 0xFDA5, 0xEB6B, 0xC6F7, 0x9DCF, 0x2BBF),
|
||||||
|
array(0x4563, 0x8AC6, 0x05AD, 0x0B5A, 0x16B4, 0x2D68, 0x5AD0),
|
||||||
|
array(0x0375, 0x06EA, 0x0DD4, 0x1BA8, 0x3750, 0x6EA0, 0xDD40),
|
||||||
|
array(0xD849, 0xA0B3, 0x5147, 0xA28E, 0x553D, 0xAA7A, 0x44D5),
|
||||||
|
array(0x6F45, 0xDE8A, 0xAD35, 0x4A4B, 0x9496, 0x390D, 0x721A),
|
||||||
|
array(0xEB23, 0xC667, 0x9CEF, 0x29FF, 0x53FE, 0xA7FC, 0x5FD9),
|
||||||
|
array(0x47D3, 0x8FA6, 0x0F6D, 0x1EDA, 0x3DB4, 0x7B68, 0xF6D0),
|
||||||
|
array(0xB861, 0x60E3, 0xC1C6, 0x93AD, 0x377B, 0x6EF6, 0xDDEC),
|
||||||
|
array(0x45A0, 0x8B40, 0x06A1, 0x0D42, 0x1A84, 0x3508, 0x6A10),
|
||||||
|
array(0xAA51, 0x4483, 0x8906, 0x022D, 0x045A, 0x08B4, 0x1168),
|
||||||
|
array(0x76B4, 0xED68, 0xCAF1, 0x85C3, 0x1BA7, 0x374E, 0x6E9C),
|
||||||
|
array(0x3730, 0x6E60, 0xDCC0, 0xA9A1, 0x4363, 0x86C6, 0x1DAD),
|
||||||
|
array(0x3331, 0x6662, 0xCCC4, 0x89A9, 0x0373, 0x06E6, 0x0DCC),
|
||||||
|
array(0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48C4),
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $passwordMaxLength = 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a hashed password that MS Word will be able to work with
|
||||||
|
* @see https://blogs.msdn.microsoft.com/vsod/2010/04/05/how-to-set-the-editing-restrictions-in-word-using-open-xml-sdk-2-0/
|
||||||
|
*
|
||||||
|
* @param string $password
|
||||||
|
* @param string $algorithmName
|
||||||
|
* @param string $salt
|
||||||
|
* @param int $spinCount
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function hashPassword($password, $algorithmName = self::ALGORITHM_SHA_1, $salt = null, $spinCount = 10000)
|
||||||
|
{
|
||||||
|
$origEncoding = mb_internal_encoding();
|
||||||
|
mb_internal_encoding('UTF-8');
|
||||||
|
|
||||||
|
$password = mb_substr($password, 0, min(self::$passwordMaxLength, mb_strlen($password)));
|
||||||
|
|
||||||
|
// Get the single-byte values by iterating through the Unicode characters of the truncated password.
|
||||||
|
// For each character, if the low byte is not equal to 0, take it. Otherwise, take the high byte.
|
||||||
|
$passUtf8 = mb_convert_encoding($password, 'UCS-2LE', 'UTF-8');
|
||||||
|
$byteChars = array();
|
||||||
|
|
||||||
|
for ($i = 0; $i < mb_strlen($password); $i++) {
|
||||||
|
$byteChars[$i] = ord(substr($passUtf8, $i * 2, 1));
|
||||||
|
|
||||||
|
if ($byteChars[$i] == 0) {
|
||||||
|
$byteChars[$i] = ord(substr($passUtf8, $i * 2 + 1, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// build low-order word and hig-order word and combine them
|
||||||
|
$combinedKey = self::buildCombinedKey($byteChars);
|
||||||
|
// build reversed hexadecimal string
|
||||||
|
$hex = str_pad(strtoupper(dechex($combinedKey & 0xFFFFFFFF)), 8, '0', \STR_PAD_LEFT);
|
||||||
|
$reversedHex = $hex[6] . $hex[7] . $hex[4] . $hex[5] . $hex[2] . $hex[3] . $hex[0] . $hex[1];
|
||||||
|
|
||||||
|
$generatedKey = mb_convert_encoding($reversedHex, 'UCS-2LE', 'UTF-8');
|
||||||
|
|
||||||
|
// Implementation Notes List:
|
||||||
|
// Word requires that the initial hash of the password with the salt not be considered in the count.
|
||||||
|
// The initial hash of salt + key is not included in the iteration count.
|
||||||
|
$algorithm = self::getAlgorithm($algorithmName);
|
||||||
|
$generatedKey = hash($algorithm, $salt . $generatedKey, true);
|
||||||
|
|
||||||
|
for ($i = 0; $i < $spinCount; $i++) {
|
||||||
|
$generatedKey = hash($algorithm, $generatedKey . pack('CCCC', $i, $i >> 8, $i >> 16, $i >> 24), true);
|
||||||
|
}
|
||||||
|
$generatedKey = base64_encode($generatedKey);
|
||||||
|
|
||||||
|
mb_internal_encoding($origEncoding);
|
||||||
|
|
||||||
|
return $generatedKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get algorithm from self::$algorithmMapping
|
||||||
|
*
|
||||||
|
* @param string $algorithmName
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function getAlgorithm($algorithmName)
|
||||||
|
{
|
||||||
|
$algorithm = self::$algorithmMapping[$algorithmName][1];
|
||||||
|
if ($algorithm == '') {
|
||||||
|
$algorithm = 'sha1';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $algorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the algorithm ID
|
||||||
|
*
|
||||||
|
* @param string $algorithmName
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getAlgorithmId($algorithmName)
|
||||||
|
{
|
||||||
|
return self::$algorithmMapping[$algorithmName][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build combined key from low-order word and high-order word
|
||||||
|
*
|
||||||
|
* @param array $byteChars byte array representation of password
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private static function buildCombinedKey($byteChars)
|
||||||
|
{
|
||||||
|
$byteCharsLength = count($byteChars);
|
||||||
|
// Compute the high-order word
|
||||||
|
// Initialize from the initial code array (see above), depending on the passwords length.
|
||||||
|
$highOrderWord = self::$initialCodeArray[$byteCharsLength - 1];
|
||||||
|
|
||||||
|
// For each character in the password:
|
||||||
|
// For every bit in the character, starting with the least significant and progressing to (but excluding)
|
||||||
|
// the most significant, if the bit is set, XOR the key’s high-order word with the corresponding word from
|
||||||
|
// the Encryption Matrix
|
||||||
|
for ($i = 0; $i < $byteCharsLength; $i++) {
|
||||||
|
$tmp = self::$passwordMaxLength - $byteCharsLength + $i;
|
||||||
|
$matrixRow = self::$encryptionMatrix[$tmp];
|
||||||
|
for ($intBit = 0; $intBit < 7; $intBit++) {
|
||||||
|
if (($byteChars[$i] & (0x0001 << $intBit)) != 0) {
|
||||||
|
$highOrderWord = ($highOrderWord ^ $matrixRow[$intBit]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute low-order word
|
||||||
|
// Initialize with 0
|
||||||
|
$lowOrderWord = 0;
|
||||||
|
// For each character in the password, going backwards
|
||||||
|
for ($i = $byteCharsLength - 1; $i >= 0; $i--) {
|
||||||
|
// low-order word = (((low-order word SHR 14) AND 0x0001) OR (low-order word SHL 1) AND 0x7FFF)) XOR character
|
||||||
|
$lowOrderWord = (((($lowOrderWord >> 14) & 0x0001) | (($lowOrderWord << 1) & 0x7FFF)) ^ $byteChars[$i]);
|
||||||
|
}
|
||||||
|
// Lastly, low-order word = (((low-order word SHR 14) AND 0x0001) OR (low-order word SHL 1) AND 0x7FFF)) XOR strPassword length XOR 0xCE4B.
|
||||||
|
$lowOrderWord = (((($lowOrderWord >> 14) & 0x0001) | (($lowOrderWord << 1) & 0x7FFF)) ^ $byteCharsLength ^ 0xCE4B);
|
||||||
|
|
||||||
|
// Combine the Low and High Order Word
|
||||||
|
return self::int32(($highOrderWord << 16) + $lowOrderWord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulate behaviour of (signed) int32
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
* @param int $value
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private static function int32($value)
|
||||||
|
{
|
||||||
|
$value = ($value & 0xFFFFFFFF);
|
||||||
|
|
||||||
|
if ($value & 0x80000000) {
|
||||||
|
$value = -((~$value & 0xFFFFFFFF) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,236 @@
|
||||||
|
<?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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text
|
||||||
|
*/
|
||||||
|
class Text
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Control characters array
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
private static $controlCharacters = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build control characters array
|
||||||
|
*/
|
||||||
|
private static function buildControlCharacters()
|
||||||
|
{
|
||||||
|
for ($i = 0; $i <= 19; ++$i) {
|
||||||
|
if ($i != 9 && $i != 10 && $i != 13) {
|
||||||
|
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
|
||||||
|
$replace = chr($i);
|
||||||
|
self::$controlCharacters[$find] = $replace;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert from PHP control character to OpenXML escaped control character
|
||||||
|
*
|
||||||
|
* Excel 2007 team:
|
||||||
|
* ----------------
|
||||||
|
* That's correct, control characters are stored directly in the shared-strings table.
|
||||||
|
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
||||||
|
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
||||||
|
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
||||||
|
* element or in the shared string <t> element.
|
||||||
|
*
|
||||||
|
* @param string $value Value to escape
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function controlCharacterPHP2OOXML($value = '')
|
||||||
|
{
|
||||||
|
if (empty(self::$controlCharacters)) {
|
||||||
|
self::buildControlCharacters();
|
||||||
|
}
|
||||||
|
|
||||||
|
return str_replace(array_values(self::$controlCharacters), array_keys(self::$controlCharacters), $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a number formatted for being integrated in xml files
|
||||||
|
* @param float $number
|
||||||
|
* @param int $decimals
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function numberFormat($number, $decimals)
|
||||||
|
{
|
||||||
|
return number_format($number, $decimals, '.', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $dec
|
||||||
|
* @see http://stackoverflow.com/a/7153133/2235790
|
||||||
|
* @author velcrow
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function chr($dec)
|
||||||
|
{
|
||||||
|
if ($dec <= 0x7F) {
|
||||||
|
return chr($dec);
|
||||||
|
}
|
||||||
|
if ($dec <= 0x7FF) {
|
||||||
|
return chr(($dec >> 6) + 192) . chr(($dec & 63) + 128);
|
||||||
|
}
|
||||||
|
if ($dec <= 0xFFFF) {
|
||||||
|
return chr(($dec >> 12) + 224) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
|
||||||
|
}
|
||||||
|
if ($dec <= 0x1FFFFF) {
|
||||||
|
return chr(($dec >> 18) + 240) . chr((($dec >> 12) & 63) + 128) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert from OpenXML escaped control character to PHP control character
|
||||||
|
*
|
||||||
|
* @param string $value Value to unescape
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function controlCharacterOOXML2PHP($value = '')
|
||||||
|
{
|
||||||
|
if (empty(self::$controlCharacters)) {
|
||||||
|
self::buildControlCharacters();
|
||||||
|
}
|
||||||
|
|
||||||
|
return str_replace(array_keys(self::$controlCharacters), array_values(self::$controlCharacters), $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a string contains UTF-8 data
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isUTF8($value = '')
|
||||||
|
{
|
||||||
|
return is_string($value) && ($value === '' || preg_match('/^./su', $value) == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return UTF8 encoded value
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toUTF8($value = '')
|
||||||
|
{
|
||||||
|
if (!is_null($value) && !self::isUTF8($value)) {
|
||||||
|
$value = utf8_encode($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns unicode from UTF8 text
|
||||||
|
*
|
||||||
|
* The function is splitted to reduce cyclomatic complexity
|
||||||
|
*
|
||||||
|
* @param string $text UTF8 text
|
||||||
|
* @return string Unicode text
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
public static function toUnicode($text)
|
||||||
|
{
|
||||||
|
return self::unicodeToEntities(self::utf8ToUnicode($text));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns unicode array from UTF8 text
|
||||||
|
*
|
||||||
|
* @param string $text UTF8 text
|
||||||
|
* @return array
|
||||||
|
* @since 0.11.0
|
||||||
|
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||||
|
*/
|
||||||
|
public static function utf8ToUnicode($text)
|
||||||
|
{
|
||||||
|
$unicode = array();
|
||||||
|
$values = array();
|
||||||
|
$lookingFor = 1;
|
||||||
|
|
||||||
|
// Gets unicode for each character
|
||||||
|
for ($i = 0; $i < strlen($text); $i++) {
|
||||||
|
$thisValue = ord($text[$i]);
|
||||||
|
if ($thisValue < 128) {
|
||||||
|
$unicode[] = $thisValue;
|
||||||
|
} else {
|
||||||
|
if (count($values) == 0) {
|
||||||
|
$lookingFor = $thisValue < 224 ? 2 : 3;
|
||||||
|
}
|
||||||
|
$values[] = $thisValue;
|
||||||
|
if (count($values) == $lookingFor) {
|
||||||
|
if ($lookingFor == 3) {
|
||||||
|
$number = (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64);
|
||||||
|
} else {
|
||||||
|
$number = (($values[0] % 32) * 64) + ($values[1] % 64);
|
||||||
|
}
|
||||||
|
$unicode[] = $number;
|
||||||
|
$values = array();
|
||||||
|
$lookingFor = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $unicode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns entites from unicode array
|
||||||
|
*
|
||||||
|
* @param array $unicode
|
||||||
|
* @return string
|
||||||
|
* @since 0.11.0
|
||||||
|
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||||
|
*/
|
||||||
|
private static function unicodeToEntities($unicode)
|
||||||
|
{
|
||||||
|
$entities = '';
|
||||||
|
|
||||||
|
foreach ($unicode as $value) {
|
||||||
|
if ($value != 65279) {
|
||||||
|
$entities .= $value > 127 ? '\uc0{\u' . $value . '}' : chr($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return name without underscore for < 0.10.0 variable name compatibility
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function removeUnderscorePrefix($value)
|
||||||
|
{
|
||||||
|
if (!is_null($value)) {
|
||||||
|
if (substr($value, 0, 1) == '_') {
|
||||||
|
$value = substr($value, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,216 @@
|
||||||
|
<?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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML Reader wrapper
|
||||||
|
*
|
||||||
|
* @since 0.2.1
|
||||||
|
*/
|
||||||
|
class XMLReader
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* DOMDocument object
|
||||||
|
*
|
||||||
|
* @var \DOMDocument
|
||||||
|
*/
|
||||||
|
private $dom = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOMXpath object
|
||||||
|
*
|
||||||
|
* @var \DOMXpath
|
||||||
|
*/
|
||||||
|
private $xpath = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get DOMDocument from ZipArchive
|
||||||
|
*
|
||||||
|
* @param string $zipFile
|
||||||
|
* @param string $xmlFile
|
||||||
|
* @throws \Exception
|
||||||
|
* @return \DOMDocument|false
|
||||||
|
*/
|
||||||
|
public function getDomFromZip($zipFile, $xmlFile)
|
||||||
|
{
|
||||||
|
if (file_exists($zipFile) === false) {
|
||||||
|
throw new \Exception('Cannot find archive file.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip = new \ZipArchive();
|
||||||
|
$zip->open($zipFile);
|
||||||
|
$content = $zip->getFromName($xmlFile);
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
if ($content === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getDomFromString($content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get DOMDocument from content string
|
||||||
|
*
|
||||||
|
* @param string $content
|
||||||
|
* @return \DOMDocument
|
||||||
|
*/
|
||||||
|
public function getDomFromString($content)
|
||||||
|
{
|
||||||
|
if (\PHP_VERSION_ID < 80000) {
|
||||||
|
$originalLibXMLEntityValue = libxml_disable_entity_loader(true);
|
||||||
|
}
|
||||||
|
$this->dom = new \DOMDocument();
|
||||||
|
$this->dom->loadXML($content);
|
||||||
|
if (\PHP_VERSION_ID < 80000) {
|
||||||
|
libxml_disable_entity_loader($originalLibXMLEntityValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->dom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get elements
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param \DOMElement $contextNode
|
||||||
|
* @return \DOMNodeList
|
||||||
|
*/
|
||||||
|
public function getElements($path, \DOMElement $contextNode = null)
|
||||||
|
{
|
||||||
|
if ($this->dom === null) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
if ($this->xpath === null) {
|
||||||
|
$this->xpath = new \DOMXpath($this->dom);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($contextNode)) {
|
||||||
|
return $this->xpath->query($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->xpath->query($path, $contextNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the namespace with the DOMXPath object
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix
|
||||||
|
* @param string $namespaceURI The URI of the namespace
|
||||||
|
* @throws \InvalidArgumentException If called before having loaded the DOM document
|
||||||
|
* @return bool true on success or false on failure
|
||||||
|
*/
|
||||||
|
public function registerNamespace($prefix, $namespaceURI)
|
||||||
|
{
|
||||||
|
if ($this->dom === null) {
|
||||||
|
throw new \InvalidArgumentException('Dom needs to be loaded before registering a namespace');
|
||||||
|
}
|
||||||
|
if ($this->xpath === null) {
|
||||||
|
$this->xpath = new \DOMXpath($this->dom);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->xpath->registerNamespace($prefix, $namespaceURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get element
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param \DOMElement $contextNode
|
||||||
|
* @return \DOMElement|null
|
||||||
|
*/
|
||||||
|
public function getElement($path, \DOMElement $contextNode = null)
|
||||||
|
{
|
||||||
|
$elements = $this->getElements($path, $contextNode);
|
||||||
|
if ($elements->length > 0) {
|
||||||
|
return $elements->item(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get element attribute
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @param \DOMElement $contextNode
|
||||||
|
* @param string $path
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getAttribute($attribute, \DOMElement $contextNode = null, $path = null)
|
||||||
|
{
|
||||||
|
$return = null;
|
||||||
|
if ($path !== null) {
|
||||||
|
$elements = $this->getElements($path, $contextNode);
|
||||||
|
if ($elements->length > 0) {
|
||||||
|
/** @var \DOMElement $node Type hint */
|
||||||
|
$node = $elements->item(0);
|
||||||
|
$return = $node->getAttribute($attribute);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($contextNode !== null) {
|
||||||
|
$return = $contextNode->getAttribute($attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($return == '') ? null : $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get element value
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param \DOMElement $contextNode
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getValue($path, \DOMElement $contextNode = null)
|
||||||
|
{
|
||||||
|
$elements = $this->getElements($path, $contextNode);
|
||||||
|
if ($elements->length > 0) {
|
||||||
|
return $elements->item(0)->nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count elements
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param \DOMElement $contextNode
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function countElements($path, \DOMElement $contextNode = null)
|
||||||
|
{
|
||||||
|
$elements = $this->getElements($path, $contextNode);
|
||||||
|
|
||||||
|
return $elements->length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Element exists
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param \DOMElement $contextNode
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function elementExists($path, \DOMElement $contextNode = null)
|
||||||
|
{
|
||||||
|
return $this->getElements($path, $contextNode)->length > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,182 @@
|
||||||
|
<?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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XMLWriter
|
||||||
|
*
|
||||||
|
* @method bool endElement()
|
||||||
|
* @method mixed flush(bool $empty = null)
|
||||||
|
* @method bool openMemory()
|
||||||
|
* @method string outputMemory(bool $flush = null)
|
||||||
|
* @method bool setIndent(bool $indent)
|
||||||
|
* @method bool startDocument(string $version = 1.0, string $encoding = null, string $standalone = null)
|
||||||
|
* @method bool startElement(string $name)
|
||||||
|
* @method bool text(string $content)
|
||||||
|
* @method bool writeCData(string $content)
|
||||||
|
* @method bool writeComment(string $content)
|
||||||
|
* @method bool writeElement(string $name, string $content = null)
|
||||||
|
* @method bool writeRaw(string $content)
|
||||||
|
*/
|
||||||
|
class XMLWriter extends \XMLWriter
|
||||||
|
{
|
||||||
|
/** Temporary storage method */
|
||||||
|
const STORAGE_MEMORY = 1;
|
||||||
|
const STORAGE_DISK = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary filename
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $tempFileName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new \PhpOffice\PhpWord\Shared\XMLWriter instance
|
||||||
|
*
|
||||||
|
* @param int $pTemporaryStorage Temporary storage location
|
||||||
|
* @param string $pTemporaryStorageDir Temporary storage folder
|
||||||
|
* @param bool $compatibility
|
||||||
|
*/
|
||||||
|
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageDir = null, $compatibility = false)
|
||||||
|
{
|
||||||
|
// Open temporary storage
|
||||||
|
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
||||||
|
$this->openMemory();
|
||||||
|
} else {
|
||||||
|
if (!is_dir($pTemporaryStorageDir)) {
|
||||||
|
$pTemporaryStorageDir = sys_get_temp_dir();
|
||||||
|
}
|
||||||
|
// Create temporary filename
|
||||||
|
$this->tempFileName = @tempnam($pTemporaryStorageDir, 'xml');
|
||||||
|
|
||||||
|
// Open storage
|
||||||
|
$this->openUri($this->tempFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($compatibility) {
|
||||||
|
$this->setIndent(false);
|
||||||
|
$this->setIndentString('');
|
||||||
|
} else {
|
||||||
|
$this->setIndent(true);
|
||||||
|
$this->setIndentString(' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
|
// Unlink temporary files
|
||||||
|
if (empty($this->tempFileName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (PHP_OS != 'WINNT' && @unlink($this->tempFileName) === false) {
|
||||||
|
throw new \Exception('The file ' . $this->tempFileName . ' could not be deleted.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get written data
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
if ($this->tempFileName == '') {
|
||||||
|
return $this->outputMemory(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->flush();
|
||||||
|
|
||||||
|
return file_get_contents($this->tempFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write simple element and attribute(s) block
|
||||||
|
*
|
||||||
|
* There are two options:
|
||||||
|
* 1. If the `$attributes` is an array, then it's an associative array of attributes
|
||||||
|
* 2. If not, then it's a simple attribute-value pair
|
||||||
|
*
|
||||||
|
* @param string $element
|
||||||
|
* @param string|array $attributes
|
||||||
|
* @param string $value
|
||||||
|
*/
|
||||||
|
public function writeElementBlock($element, $attributes, $value = null)
|
||||||
|
{
|
||||||
|
$this->startElement($element);
|
||||||
|
if (!is_array($attributes)) {
|
||||||
|
$attributes = array($attributes => $value);
|
||||||
|
}
|
||||||
|
foreach ($attributes as $attribute => $value) {
|
||||||
|
$this->writeAttribute($attribute, $value);
|
||||||
|
}
|
||||||
|
$this->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write element if ...
|
||||||
|
*
|
||||||
|
* @param bool $condition
|
||||||
|
* @param string $element
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function writeElementIf($condition, $element, $attribute = null, $value = null)
|
||||||
|
{
|
||||||
|
if ($condition == true) {
|
||||||
|
if (is_null($attribute)) {
|
||||||
|
$this->writeElement($element, $value);
|
||||||
|
} else {
|
||||||
|
$this->startElement($element);
|
||||||
|
$this->writeAttribute($attribute, $value);
|
||||||
|
$this->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write attribute if ...
|
||||||
|
*
|
||||||
|
* @param bool $condition
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function writeAttributeIf($condition, $attribute, $value)
|
||||||
|
{
|
||||||
|
if ($condition == true) {
|
||||||
|
$this->writeAttribute($attribute, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function writeAttribute($name, $value)
|
||||||
|
{
|
||||||
|
if (is_float($value)) {
|
||||||
|
$value = json_encode($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::writeAttribute($name, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Style;
|
namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
use PhpOffice\Common\Text;
|
use PhpOffice\PhpWord\Shared\Text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract style class
|
* Abstract style class
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Style;
|
namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
use PhpOffice\Common\Text;
|
|
||||||
use PhpOffice\PhpWord\Exception\InvalidStyleException;
|
use PhpOffice\PhpWord\Exception\InvalidStyleException;
|
||||||
|
use PhpOffice\PhpWord\Shared\Text;
|
||||||
use PhpOffice\PhpWord\SimpleType\Jc;
|
use PhpOffice\PhpWord\SimpleType\Jc;
|
||||||
use PhpOffice\PhpWord\SimpleType\TextAlignment;
|
use PhpOffice\PhpWord\SimpleType\TextAlignment;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,13 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord;
|
namespace PhpOffice\PhpWord;
|
||||||
|
|
||||||
use PhpOffice\Common\Text;
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Escaper\RegExp;
|
use PhpOffice\PhpWord\Escaper\RegExp;
|
||||||
use PhpOffice\PhpWord\Escaper\Xml;
|
use PhpOffice\PhpWord\Escaper\Xml;
|
||||||
use PhpOffice\PhpWord\Exception\CopyFileException;
|
use PhpOffice\PhpWord\Exception\CopyFileException;
|
||||||
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
|
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
use PhpOffice\PhpWord\Exception\Exception;
|
||||||
|
use PhpOffice\PhpWord\Shared\Text;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Shared\ZipArchive;
|
use PhpOffice\PhpWord\Shared\ZipArchive;
|
||||||
|
|
||||||
class TemplateProcessor
|
class TemplateProcessor
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\Row as RowElement;
|
use PhpOffice\PhpWord\Element\Row as RowElement;
|
||||||
use PhpOffice\PhpWord\Element\Table as TableElement;
|
use PhpOffice\PhpWord\Element\Table as TableElement;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table element writer
|
* Table element writer
|
||||||
|
|
@ -60,7 +60,7 @@ class Table extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write column.
|
* Write column.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Table $element
|
* @param \PhpOffice\PhpWord\Element\Table $element
|
||||||
*/
|
*/
|
||||||
private function writeColumns(XMLWriter $xmlWriter, TableElement $element)
|
private function writeColumns(XMLWriter $xmlWriter, TableElement $element)
|
||||||
|
|
@ -77,7 +77,7 @@ class Table extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write row.
|
* Write row.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Row $row
|
* @param \PhpOffice\PhpWord\Element\Row $row
|
||||||
*/
|
*/
|
||||||
private function writeRow(XMLWriter $xmlWriter, RowElement $row)
|
private function writeRow(XMLWriter $xmlWriter, RowElement $row)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart as Word2007AbstractPart;
|
use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart as Word2007AbstractPart;
|
||||||
|
|
@ -36,7 +36,7 @@ abstract class AbstractPart extends Word2007AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write common root attributes.
|
* Write common root attributes.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
protected function writeCommonRootAttributes(XMLWriter $xmlWriter)
|
protected function writeCommonRootAttributes(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
@ -72,7 +72,7 @@ abstract class AbstractPart extends Word2007AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write font faces declaration.
|
* Write font faces declaration.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
protected function writeFontFaces(XMLWriter $xmlWriter)
|
protected function writeFontFaces(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\AbstractContainer;
|
use PhpOffice\PhpWord\Element\AbstractContainer;
|
||||||
use PhpOffice\PhpWord\Element\Field;
|
use PhpOffice\PhpWord\Element\Field;
|
||||||
use PhpOffice\PhpWord\Element\Image;
|
use PhpOffice\PhpWord\Element\Image;
|
||||||
|
|
@ -26,6 +25,7 @@ use PhpOffice\PhpWord\Element\Text;
|
||||||
use PhpOffice\PhpWord\Element\TextRun;
|
use PhpOffice\PhpWord\Element\TextRun;
|
||||||
use PhpOffice\PhpWord\Element\TrackChange;
|
use PhpOffice\PhpWord\Element\TrackChange;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
|
|
@ -151,7 +151,7 @@ class Content extends AbstractPart
|
||||||
*
|
*
|
||||||
* @since 0.11.0
|
* @since 0.11.0
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function writeAutoStyles(XMLWriter $xmlWriter)
|
private function writeAutoStyles(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
@ -173,7 +173,7 @@ class Content extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write automatic styles.
|
* Write automatic styles.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function writeTextStyles(XMLWriter $xmlWriter)
|
private function writeTextStyles(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ODText meta part writer: meta.xml
|
* ODText meta part writer: meta.xml
|
||||||
|
|
@ -86,7 +86,7 @@ class Meta extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write individual property
|
* Write individual property
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $property
|
* @param string $property
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
use PhpOffice\PhpWord\Shared\Converter;
|
use PhpOffice\PhpWord\Shared\Converter;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,7 +66,7 @@ class Styles extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write default styles.
|
* Write default styles.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function writeDefault(XMLWriter $xmlWriter)
|
private function writeDefault(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
@ -118,7 +118,7 @@ class Styles extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write named styles.
|
* Write named styles.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function writeNamed(XMLWriter $xmlWriter)
|
private function writeNamed(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
@ -155,7 +155,7 @@ class Styles extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* call writePageLayoutIndiv to write page layout styles for each page
|
* call writePageLayoutIndiv to write page layout styles for each page
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function writePageLayout(XMLWriter $xmlWriter)
|
private function writePageLayout(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
@ -169,7 +169,7 @@ class Styles extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write page layout styles.
|
* Write page layout styles.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Section $section
|
* @param \PhpOffice\PhpWord\Element\Section $section
|
||||||
* @param int $sectionNbr
|
* @param int $sectionNbr
|
||||||
*/
|
*/
|
||||||
|
|
@ -255,7 +255,7 @@ class Styles extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write master style.
|
* Write master style.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function writeMaster(XMLWriter $xmlWriter)
|
private function writeMaster(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\RTF\Element;
|
namespace PhpOffice\PhpWord\Writer\RTF\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\Text as CommonText;
|
|
||||||
use PhpOffice\PhpWord\Element\AbstractElement as Element;
|
use PhpOffice\PhpWord\Element\AbstractElement as Element;
|
||||||
use PhpOffice\PhpWord\Escaper\Rtf;
|
use PhpOffice\PhpWord\Escaper\Rtf;
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Font as FontStyle;
|
use PhpOffice\PhpWord\Style\Font as FontStyle;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
|
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
|
||||||
|
|
@ -126,7 +126,7 @@ abstract class AbstractElement extends HTMLAbstractElement
|
||||||
return $this->escaper->escape($text);
|
return $this->escaper->escape($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommonText::toUnicode($text); // todo: replace with `return $text;` later.
|
return SharedText::toUnicode($text); // todo: replace with `return $text;` later.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\Text as CommonText;
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\AbstractElement as Element;
|
use PhpOffice\PhpWord\Element\AbstractElement as Element;
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
use PhpOffice\PhpWord\Shared\Text as SharedText;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract element writer
|
* Abstract element writer
|
||||||
|
|
@ -32,7 +32,7 @@ abstract class AbstractElement
|
||||||
/**
|
/**
|
||||||
* XML writer
|
* XML writer
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\Common\XMLWriter
|
* @var \PhpOffice\PhpWord\Shared\XMLWriter
|
||||||
*/
|
*/
|
||||||
private $xmlWriter;
|
private $xmlWriter;
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ abstract class AbstractElement
|
||||||
/**
|
/**
|
||||||
* Create new instance
|
* Create new instance
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
|
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
|
||||||
* @param bool $withoutP
|
* @param bool $withoutP
|
||||||
*/
|
*/
|
||||||
|
|
@ -72,7 +72,7 @@ abstract class AbstractElement
|
||||||
/**
|
/**
|
||||||
* Get XML Writer
|
* Get XML Writer
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\Common\XMLWriter
|
* @return \PhpOffice\PhpWord\Shared\XMLWriter
|
||||||
*/
|
*/
|
||||||
protected function getXmlWriter()
|
protected function getXmlWriter()
|
||||||
{
|
{
|
||||||
|
|
@ -207,7 +207,7 @@ abstract class AbstractElement
|
||||||
*/
|
*/
|
||||||
protected function getText($text)
|
protected function getText($text)
|
||||||
{
|
{
|
||||||
return CommonText::controlCharacterPHP2OOXML($text);
|
return SharedText::controlCharacterPHP2OOXML($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement;
|
use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement;
|
||||||
use PhpOffice\PhpWord\Element\AbstractElement as Element;
|
use PhpOffice\PhpWord\Element\AbstractElement as Element;
|
||||||
use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement;
|
use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container element writer (section, textrun, header, footnote, cell, etc.)
|
* Container element writer (section, textrun, header, footnote, cell, etc.)
|
||||||
|
|
@ -71,7 +71,7 @@ class Container extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write individual element
|
* Write individual element
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
|
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
|
||||||
* @param bool $withoutP
|
* @param bool $withoutP
|
||||||
* @return string
|
* @return string
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\FormField as FormFieldElement;
|
use PhpOffice\PhpWord\Element\FormField as FormFieldElement;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FormField element writer
|
* FormField element writer
|
||||||
|
|
@ -105,7 +105,7 @@ class FormField extends Text
|
||||||
* Write textinput.
|
* Write textinput.
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_FFTextInput.html
|
* @see http://www.datypic.com/sc/ooxml/t-w_CT_FFTextInput.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\FormField $element
|
* @param \PhpOffice\PhpWord\Element\FormField $element
|
||||||
*/
|
*/
|
||||||
private function writeTextInput(XMLWriter $xmlWriter, FormFieldElement $element)
|
private function writeTextInput(XMLWriter $xmlWriter, FormFieldElement $element)
|
||||||
|
|
@ -121,7 +121,7 @@ class FormField extends Text
|
||||||
* Write checkbox.
|
* Write checkbox.
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_FFCheckBox.html
|
* @see http://www.datypic.com/sc/ooxml/t-w_CT_FFCheckBox.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\FormField $element
|
* @param \PhpOffice\PhpWord\Element\FormField $element
|
||||||
*/
|
*/
|
||||||
private function writeCheckBox(XMLWriter $xmlWriter, FormFieldElement $element)
|
private function writeCheckBox(XMLWriter $xmlWriter, FormFieldElement $element)
|
||||||
|
|
@ -144,7 +144,7 @@ class FormField extends Text
|
||||||
* Write dropdown.
|
* Write dropdown.
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_FFDDList.html
|
* @see http://www.datypic.com/sc/ooxml/t-w_CT_FFDDList.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\FormField $element
|
* @param \PhpOffice\PhpWord\Element\FormField $element
|
||||||
*/
|
*/
|
||||||
private function writeDropDown(XMLWriter $xmlWriter, FormFieldElement $element)
|
private function writeDropDown(XMLWriter $xmlWriter, FormFieldElement $element)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\Image as ImageElement;
|
use PhpOffice\PhpWord\Element\Image as ImageElement;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style\Font as FontStyle;
|
use PhpOffice\PhpWord\Style\Font as FontStyle;
|
||||||
use PhpOffice\PhpWord\Style\Frame as FrameStyle;
|
use PhpOffice\PhpWord\Style\Frame as FrameStyle;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\SDT as SDTElement;
|
use PhpOffice\PhpWord\Element\SDT as SDTElement;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structured document tag element writer
|
* Structured document tag element writer
|
||||||
|
|
@ -77,7 +77,7 @@ class SDT extends Text
|
||||||
* Write text.
|
* Write text.
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtText.html
|
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtText.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function writePlainText(XMLWriter $xmlWriter)
|
private function writePlainText(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
@ -89,7 +89,7 @@ class SDT extends Text
|
||||||
* Write combo box.
|
* Write combo box.
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtComboBox.html
|
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtComboBox.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\SDT $element
|
* @param \PhpOffice\PhpWord\Element\SDT $element
|
||||||
*/
|
*/
|
||||||
private function writeComboBox(XMLWriter $xmlWriter, SDTElement $element)
|
private function writeComboBox(XMLWriter $xmlWriter, SDTElement $element)
|
||||||
|
|
@ -108,7 +108,7 @@ class SDT extends Text
|
||||||
* Write drop down list.
|
* Write drop down list.
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtDropDownList.html
|
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtDropDownList.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\SDT $element
|
* @param \PhpOffice\PhpWord\Element\SDT $element
|
||||||
*/
|
*/
|
||||||
private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element)
|
private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element)
|
||||||
|
|
@ -120,7 +120,7 @@ class SDT extends Text
|
||||||
* Write date.
|
* Write date.
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtDate.html
|
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtDate.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\SDT $element
|
* @param \PhpOffice\PhpWord\Element\SDT $element
|
||||||
*/
|
*/
|
||||||
private function writeDate(XMLWriter $xmlWriter, SDTElement $element)
|
private function writeDate(XMLWriter $xmlWriter, SDTElement $element)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\Shape as ShapeElement;
|
use PhpOffice\PhpWord\Element\Shape as ShapeElement;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style\Shape as ShapeStyle;
|
use PhpOffice\PhpWord\Style\Shape as ShapeStyle;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Shape as ShapeStyleWriter;
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Shape as ShapeStyleWriter;
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ class Shape extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write arc.
|
* Write arc.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Shape $style
|
* @param \PhpOffice\PhpWord\Style\Shape $style
|
||||||
*/
|
*/
|
||||||
private function writeArc(XMLWriter $xmlWriter, ShapeStyle $style)
|
private function writeArc(XMLWriter $xmlWriter, ShapeStyle $style)
|
||||||
|
|
@ -91,7 +91,7 @@ class Shape extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write curve.
|
* Write curve.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Shape $style
|
* @param \PhpOffice\PhpWord\Style\Shape $style
|
||||||
*/
|
*/
|
||||||
private function writeCurve(XMLWriter $xmlWriter, ShapeStyle $style)
|
private function writeCurve(XMLWriter $xmlWriter, ShapeStyle $style)
|
||||||
|
|
@ -106,7 +106,7 @@ class Shape extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write line.
|
* Write line.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Shape $style
|
* @param \PhpOffice\PhpWord\Style\Shape $style
|
||||||
*/
|
*/
|
||||||
private function writeLine(XMLWriter $xmlWriter, ShapeStyle $style)
|
private function writeLine(XMLWriter $xmlWriter, ShapeStyle $style)
|
||||||
|
|
@ -120,7 +120,7 @@ class Shape extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write polyline.
|
* Write polyline.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Shape $style
|
* @param \PhpOffice\PhpWord\Style\Shape $style
|
||||||
*/
|
*/
|
||||||
private function writePolyline(XMLWriter $xmlWriter, ShapeStyle $style)
|
private function writePolyline(XMLWriter $xmlWriter, ShapeStyle $style)
|
||||||
|
|
@ -131,7 +131,7 @@ class Shape extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write rectangle.
|
* Write rectangle.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Shape $style
|
* @param \PhpOffice\PhpWord\Style\Shape $style
|
||||||
*/
|
*/
|
||||||
private function writeRoundRect(XMLWriter $xmlWriter, ShapeStyle $style)
|
private function writeRoundRect(XMLWriter $xmlWriter, ShapeStyle $style)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\TOC as TOCElement;
|
use PhpOffice\PhpWord\Element\TOC as TOCElement;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
|
||||||
|
|
@ -64,7 +64,7 @@ class TOC extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write title
|
* Write title
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\TOC $element
|
* @param \PhpOffice\PhpWord\Element\TOC $element
|
||||||
* @param \PhpOffice\PhpWord\Element\Title $title
|
* @param \PhpOffice\PhpWord\Element\Title $title
|
||||||
* @param bool $writeFieldMark
|
* @param bool $writeFieldMark
|
||||||
|
|
@ -132,7 +132,7 @@ class TOC extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write style
|
* Write style
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\TOC $element
|
* @param \PhpOffice\PhpWord\Element\TOC $element
|
||||||
* @param int $indent
|
* @param int $indent
|
||||||
*/
|
*/
|
||||||
|
|
@ -178,7 +178,7 @@ class TOC extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write TOC Field.
|
* Write TOC Field.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\TOC $element
|
* @param \PhpOffice\PhpWord\Element\TOC $element
|
||||||
*/
|
*/
|
||||||
private function writeFieldMark(XMLWriter $xmlWriter, TOCElement $element)
|
private function writeFieldMark(XMLWriter $xmlWriter, TOCElement $element)
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\Cell as CellElement;
|
use PhpOffice\PhpWord\Element\Cell as CellElement;
|
||||||
use PhpOffice\PhpWord\Element\Row as RowElement;
|
use PhpOffice\PhpWord\Element\Row as RowElement;
|
||||||
use PhpOffice\PhpWord\Element\Table as TableElement;
|
use PhpOffice\PhpWord\Element\Table as TableElement;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style\Cell as CellStyle;
|
use PhpOffice\PhpWord\Style\Cell as CellStyle;
|
||||||
use PhpOffice\PhpWord\Style\Row as RowStyle;
|
use PhpOffice\PhpWord\Style\Row as RowStyle;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter;
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter;
|
||||||
|
|
@ -71,7 +71,7 @@ class Table extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write column.
|
* Write column.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Table $element
|
* @param \PhpOffice\PhpWord\Element\Table $element
|
||||||
*/
|
*/
|
||||||
private function writeColumns(XMLWriter $xmlWriter, TableElement $element)
|
private function writeColumns(XMLWriter $xmlWriter, TableElement $element)
|
||||||
|
|
@ -93,7 +93,7 @@ class Table extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write row.
|
* Write row.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Row $row
|
* @param \PhpOffice\PhpWord\Element\Row $row
|
||||||
*/
|
*/
|
||||||
private function writeRow(XMLWriter $xmlWriter, RowElement $row)
|
private function writeRow(XMLWriter $xmlWriter, RowElement $row)
|
||||||
|
|
@ -119,7 +119,7 @@ class Table extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Write cell.
|
* Write cell.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Cell $cell
|
* @param \PhpOffice\PhpWord\Element\Cell $cell
|
||||||
*/
|
*/
|
||||||
private function writeCell(XMLWriter $xmlWriter, CellElement $cell)
|
private function writeCell(XMLWriter $xmlWriter, CellElement $cell)
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
use PhpOffice\PhpWord\Exception\Exception;
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Writer\AbstractWriter;
|
use PhpOffice\PhpWord\Writer\AbstractWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -73,7 +73,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Get XML Writer
|
* Get XML Writer
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\Common\XMLWriter
|
* @return \PhpOffice\PhpWord\Shared\XMLWriter
|
||||||
*/
|
*/
|
||||||
protected function getXmlWriter()
|
protected function getXmlWriter()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\Chart as ChartElement;
|
use PhpOffice\PhpWord\Element\Chart as ChartElement;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Word2007 chart part writer: word/charts/chartx.xml
|
* Word2007 chart part writer: word/charts/chartx.xml
|
||||||
|
|
@ -99,7 +99,7 @@ class Chart extends AbstractPart
|
||||||
* Write chart
|
* Write chart
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_Chart.html
|
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_Chart.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function writeChart(XMLWriter $xmlWriter)
|
private function writeChart(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
@ -121,7 +121,7 @@ class Chart extends AbstractPart
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_AreaChart.html
|
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_AreaChart.html
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_RadarChart.html
|
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_RadarChart.html
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_ScatterChart.html
|
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_ScatterChart.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function writePlotArea(XMLWriter $xmlWriter)
|
private function writePlotArea(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
|
|
@ -209,7 +209,7 @@ class Chart extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write series.
|
* Write series.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param bool $scatter
|
* @param bool $scatter
|
||||||
*/
|
*/
|
||||||
private function writeSeries(XMLWriter $xmlWriter, $scatter = false)
|
private function writeSeries(XMLWriter $xmlWriter, $scatter = false)
|
||||||
|
|
@ -294,7 +294,7 @@ class Chart extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write series items.
|
* Write series items.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param array $values
|
* @param array $values
|
||||||
*/
|
*/
|
||||||
|
|
@ -335,7 +335,7 @@ class Chart extends AbstractPart
|
||||||
* Write axis
|
* Write axis
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_CatAx.html
|
* @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_CatAx.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $type
|
* @param string $type
|
||||||
*/
|
*/
|
||||||
private function writeAxis(XMLWriter $xmlWriter, $type)
|
private function writeAxis(XMLWriter $xmlWriter, $type)
|
||||||
|
|
@ -400,7 +400,7 @@ class Chart extends AbstractPart
|
||||||
* Write shape
|
* Write shape
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-a_CT_ShapeProperties.html
|
* @see http://www.datypic.com/sc/ooxml/t-a_CT_ShapeProperties.html
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param bool $line
|
* @param bool $line
|
||||||
*/
|
*/
|
||||||
private function writeShape(XMLWriter $xmlWriter, $line = false)
|
private function writeShape(XMLWriter $xmlWriter, $line = false)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\Comment;
|
use PhpOffice\PhpWord\Element\Comment;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
|
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -70,7 +70,7 @@ class Comments extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write comment item.
|
* Write comment item.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Comment $comment
|
* @param \PhpOffice\PhpWord\Element\Comment $comment
|
||||||
*/
|
*/
|
||||||
protected function writeComment(XMLWriter $xmlWriter, Comment $comment)
|
protected function writeComment(XMLWriter $xmlWriter, Comment $comment)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Word2007 contenttypes part writer: [Content_Types].xml
|
* Word2007 contenttypes part writer: [Content_Types].xml
|
||||||
|
|
@ -80,7 +80,7 @@ class ContentTypes extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write content types element
|
* Write content types element
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter XML Writer
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer
|
||||||
* @param array $parts
|
* @param array $parts
|
||||||
* @param bool $isDefault
|
* @param bool $isDefault
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\Section;
|
use PhpOffice\PhpWord\Element\Section;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
|
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter;
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter;
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ class Document extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write begin section.
|
* Write begin section.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Section $section
|
* @param \PhpOffice\PhpWord\Element\Section $section
|
||||||
*/
|
*/
|
||||||
private function writeSection(XMLWriter $xmlWriter, Section $section)
|
private function writeSection(XMLWriter $xmlWriter, Section $section)
|
||||||
|
|
@ -95,7 +95,7 @@ class Document extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write end section.
|
* Write end section.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Section $section
|
* @param \PhpOffice\PhpWord\Element\Section $section
|
||||||
*/
|
*/
|
||||||
private function writeSectionSettings(XMLWriter $xmlWriter, Section $section)
|
private function writeSectionSettings(XMLWriter $xmlWriter, Section $section)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\Footnote;
|
use PhpOffice\PhpWord\Element\Footnote;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
|
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
|
||||||
|
|
||||||
|
|
@ -135,7 +135,7 @@ class Footnotes extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write note item.
|
* Write note item.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Footnote|\PhpOffice\PhpWord\Element\Endnote $element
|
* @param \PhpOffice\PhpWord\Element\Footnote|\PhpOffice\PhpWord\Element\Endnote $element
|
||||||
*/
|
*/
|
||||||
protected function writeNote(XMLWriter $xmlWriter, $element)
|
protected function writeNote(XMLWriter $xmlWriter, $element)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
|
use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
|
||||||
use PhpOffice\PhpWord\Style\NumberingLevel;
|
use PhpOffice\PhpWord\Style\NumberingLevel;
|
||||||
|
|
@ -97,7 +97,7 @@ class Numbering extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write level.
|
* Write level.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
|
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
|
||||||
*/
|
*/
|
||||||
private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level)
|
private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level)
|
||||||
|
|
@ -137,7 +137,7 @@ class Numbering extends AbstractPart
|
||||||
*
|
*
|
||||||
* @since 0.11.0
|
* @since 0.11.0
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
|
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
|
||||||
* @todo Use paragraph style writer
|
* @todo Use paragraph style writer
|
||||||
*/
|
*/
|
||||||
|
|
@ -169,7 +169,7 @@ class Numbering extends AbstractPart
|
||||||
*
|
*
|
||||||
* @since 0.11.0
|
* @since 0.11.0
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
|
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
|
||||||
* @todo Use font style writer
|
* @todo Use font style writer
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
use PhpOffice\PhpWord\Exception\Exception;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Word2007 main relationship writer: _rels/.rels
|
* Word2007 main relationship writer: _rels/.rels
|
||||||
|
|
@ -49,7 +49,7 @@ class Rels extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write relationships.
|
* Write relationships.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param array $xmlRels
|
* @param array $xmlRels
|
||||||
* @param array $mediaRels
|
* @param array $mediaRels
|
||||||
* @param int $relId
|
* @param int $relId
|
||||||
|
|
@ -76,7 +76,7 @@ class Rels extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write media relationships.
|
* Write media relationships.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param int $relId
|
* @param int $relId
|
||||||
* @param array $mediaRel
|
* @param array $mediaRel
|
||||||
*/
|
*/
|
||||||
|
|
@ -101,7 +101,7 @@ class Rels extends AbstractPart
|
||||||
* Format:
|
* Format:
|
||||||
* <Relationship Id="rId..." Type="http://..." Target="....xml" TargetMode="..." />
|
* <Relationship Id="rId..." Type="http://..." Target="....xml" TargetMode="..." />
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param int $relId Relationship ID
|
* @param int $relId Relationship ID
|
||||||
* @param string $type Relationship type
|
* @param string $type Relationship type
|
||||||
* @param string $target Relationship target
|
* @param string $target Relationship target
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\Microsoft\PasswordEncoder;
|
|
||||||
use PhpOffice\PhpWord\ComplexType\ProofState;
|
use PhpOffice\PhpWord\ComplexType\ProofState;
|
||||||
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
||||||
|
use PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder;
|
||||||
use PhpOffice\PhpWord\Style\Language;
|
use PhpOffice\PhpWord\Style\Language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,7 +69,7 @@ class Settings extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write indivual setting, recursive to any child settings.
|
* Write indivual setting, recursive to any child settings.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $settingKey
|
* @param string $settingKey
|
||||||
* @param array|string $settingValue
|
* @param array|string $settingValue
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Font as FontStyle;
|
use PhpOffice\PhpWord\Style\Font as FontStyle;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
|
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
|
||||||
|
|
@ -76,7 +76,7 @@ class Styles extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write default font and other default styles.
|
* Write default font and other default styles.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\AbstractStyle[] $styles
|
* @param \PhpOffice\PhpWord\Style\AbstractStyle[] $styles
|
||||||
*/
|
*/
|
||||||
private function writeDefaultStyles(XMLWriter $xmlWriter, $styles)
|
private function writeDefaultStyles(XMLWriter $xmlWriter, $styles)
|
||||||
|
|
@ -161,7 +161,7 @@ class Styles extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write font style.
|
* Write font style.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param \PhpOffice\PhpWord\Style\Font $style
|
* @param \PhpOffice\PhpWord\Style\Font $style
|
||||||
*/
|
*/
|
||||||
|
|
@ -229,7 +229,7 @@ class Styles extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write paragraph style.
|
* Write paragraph style.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param \PhpOffice\PhpWord\Style\Paragraph $style
|
* @param \PhpOffice\PhpWord\Style\Paragraph $style
|
||||||
*/
|
*/
|
||||||
|
|
@ -261,7 +261,7 @@ class Styles extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write table style.
|
* Write table style.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param \PhpOffice\PhpWord\Style\Table $style
|
* @param \PhpOffice\PhpWord\Style\Table $style
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style writer
|
* Style writer
|
||||||
|
|
@ -30,7 +30,7 @@ abstract class AbstractStyle
|
||||||
/**
|
/**
|
||||||
* XML writer
|
* XML writer
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\Common\XMLWriter
|
* @var \PhpOffice\PhpWord\Shared\XMLWriter
|
||||||
*/
|
*/
|
||||||
private $xmlWriter;
|
private $xmlWriter;
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ abstract class AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Create new instance.
|
* Create new instance.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string|\PhpOffice\PhpWord\Style\AbstractStyle $style
|
* @param string|\PhpOffice\PhpWord\Style\AbstractStyle $style
|
||||||
*/
|
*/
|
||||||
public function __construct(XMLWriter $xmlWriter, $style = null)
|
public function __construct(XMLWriter $xmlWriter, $style = null)
|
||||||
|
|
@ -61,7 +61,7 @@ abstract class AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Get XML Writer
|
* Get XML Writer
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\Common\XMLWriter
|
* @return \PhpOffice\PhpWord\Shared\XMLWriter
|
||||||
*/
|
*/
|
||||||
protected function getXmlWriter()
|
protected function getXmlWriter()
|
||||||
{
|
{
|
||||||
|
|
@ -106,7 +106,7 @@ abstract class AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write child style.
|
* Write child style.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style\Frame as FrameStyle;
|
use PhpOffice\PhpWord\Style\Frame as FrameStyle;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
|
use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ class Frame extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write wrap.
|
* Write wrap.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Frame $style
|
* @param \PhpOffice\PhpWord\Style\Frame $style
|
||||||
* @param string $wrap
|
* @param string $wrap
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Margin border style writer
|
* Margin border style writer
|
||||||
|
|
@ -78,7 +78,7 @@ class MarginBorder extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write side.
|
* Write side.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $side
|
* @param string $side
|
||||||
* @param int $width
|
* @param int $width
|
||||||
* @param string $color
|
* @param string $color
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
|
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
|
use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
|
||||||
|
|
@ -146,7 +146,7 @@ class Paragraph extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write tabs.
|
* Write tabs.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Tab[] $tabs
|
* @param \PhpOffice\PhpWord\Style\Tab[] $tabs
|
||||||
*/
|
*/
|
||||||
private function writeTabs(XMLWriter $xmlWriter, $tabs)
|
private function writeTabs(XMLWriter $xmlWriter, $tabs)
|
||||||
|
|
@ -164,7 +164,7 @@ class Paragraph extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write numbering.
|
* Write numbering.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param array $numbering
|
* @param array $numbering
|
||||||
*/
|
*/
|
||||||
private function writeNumbering(XMLWriter $xmlWriter, $numbering)
|
private function writeNumbering(XMLWriter $xmlWriter, $numbering)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\SimpleType\TblWidth;
|
use PhpOffice\PhpWord\SimpleType\TblWidth;
|
||||||
use PhpOffice\PhpWord\Style\Table as TableStyle;
|
use PhpOffice\PhpWord\Style\Table as TableStyle;
|
||||||
use PhpOffice\PhpWord\Writer\Word2007\Element\TableAlignment;
|
use PhpOffice\PhpWord\Writer\Word2007\Element\TableAlignment;
|
||||||
|
|
@ -59,7 +59,7 @@ class Table extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write full style.
|
* Write full style.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Table $style
|
* @param \PhpOffice\PhpWord\Style\Table $style
|
||||||
*/
|
*/
|
||||||
private function writeStyle(XMLWriter $xmlWriter, TableStyle $style)
|
private function writeStyle(XMLWriter $xmlWriter, TableStyle $style)
|
||||||
|
|
@ -106,7 +106,7 @@ class Table extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Enable/Disable automatic resizing of the table
|
* Enable/Disable automatic resizing of the table
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $layout autofit / fixed
|
* @param string $layout autofit / fixed
|
||||||
*/
|
*/
|
||||||
private function writeLayout(XMLWriter $xmlWriter, $layout)
|
private function writeLayout(XMLWriter $xmlWriter, $layout)
|
||||||
|
|
@ -119,7 +119,7 @@ class Table extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write margin.
|
* Write margin.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Table $style
|
* @param \PhpOffice\PhpWord\Style\Table $style
|
||||||
*/
|
*/
|
||||||
private function writeMargin(XMLWriter $xmlWriter, TableStyle $style)
|
private function writeMargin(XMLWriter $xmlWriter, TableStyle $style)
|
||||||
|
|
@ -138,7 +138,7 @@ class Table extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write border.
|
* Write border.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Table $style
|
* @param \PhpOffice\PhpWord\Style\Table $style
|
||||||
*/
|
*/
|
||||||
private function writeBorder(XMLWriter $xmlWriter, TableStyle $style)
|
private function writeBorder(XMLWriter $xmlWriter, TableStyle $style)
|
||||||
|
|
@ -158,7 +158,7 @@ class Table extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Writes a table width
|
* Writes a table width
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param string $elementName
|
* @param string $elementName
|
||||||
* @param string $unit
|
* @param string $unit
|
||||||
* @param int|float $width
|
* @param int|float $width
|
||||||
|
|
@ -177,7 +177,7 @@ class Table extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write row style.
|
* Write row style.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Table $style
|
* @param \PhpOffice\PhpWord\Style\Table $style
|
||||||
*/
|
*/
|
||||||
private function writeFirstRow(XMLWriter $xmlWriter, TableStyle $style)
|
private function writeFirstRow(XMLWriter $xmlWriter, TableStyle $style)
|
||||||
|
|
@ -196,7 +196,7 @@ class Table extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Write shading.
|
* Write shading.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\Common\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Style\Table $style
|
* @param \PhpOffice\PhpWord\Style\Table $style
|
||||||
*/
|
*/
|
||||||
private function writeShading(XMLWriter $xmlWriter, TableStyle $style)
|
private function writeShading(XMLWriter $xmlWriter, TableStyle $style)
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for PhpOffice\PhpWord\Shared\Drawing
|
||||||
|
*
|
||||||
|
* @coversDefaultClass \PhpOffice\PhpWord\Shared\Drawing
|
||||||
|
*/
|
||||||
|
class DrawingTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDegreesAngle()
|
||||||
|
{
|
||||||
|
$value = rand(1, 100);
|
||||||
|
|
||||||
|
$this->assertEquals(0, Drawing::degreesToAngle());
|
||||||
|
$this->assertEquals((int) round($value * 60000), Drawing::degreesToAngle($value));
|
||||||
|
$this->assertEquals(0, Drawing::angleToDegrees());
|
||||||
|
$this->assertEquals(round($value / 60000), Drawing::angleToDegrees($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPixelsCentimeters()
|
||||||
|
{
|
||||||
|
$value = rand(1, 100);
|
||||||
|
|
||||||
|
$this->assertEquals(0, Drawing::pixelsToCentimeters());
|
||||||
|
$this->assertEquals($value / Drawing::DPI_96 * 2.54, Drawing::pixelsToCentimeters($value));
|
||||||
|
$this->assertEquals(0, Drawing::centimetersToPixels());
|
||||||
|
$this->assertEquals($value / 2.54 * Drawing::DPI_96, Drawing::centimetersToPixels($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPixelsEMU()
|
||||||
|
{
|
||||||
|
$value = rand(1, 100);
|
||||||
|
|
||||||
|
$this->assertEquals(0, Drawing::pixelsToEmu());
|
||||||
|
$this->assertEquals(round($value * 9525), Drawing::pixelsToEmu($value));
|
||||||
|
$this->assertEquals(0, Drawing::emuToPixels());
|
||||||
|
$this->assertEquals(round($value / 9525), Drawing::emuToPixels($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPixelsPoints()
|
||||||
|
{
|
||||||
|
$value = rand(1, 100);
|
||||||
|
|
||||||
|
$this->assertEquals(0, Drawing::pixelsToPoints());
|
||||||
|
$this->assertEquals($value * 0.67777777, Drawing::pixelsToPoints($value));
|
||||||
|
$this->assertEquals(0, Drawing::pointsToPixels());
|
||||||
|
$this->assertEquals($value * 1.333333333, Drawing::pointsToPixels($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPointsCentimeters()
|
||||||
|
{
|
||||||
|
$value = rand(1, 100);
|
||||||
|
|
||||||
|
$this->assertEquals(0, Drawing::pointsToCentimeters());
|
||||||
|
$this->assertEquals($value * 1.333333333 / Drawing::DPI_96 * 2.54, Drawing::pointsToCentimeters($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTwips()
|
||||||
|
{
|
||||||
|
$value = rand(1, 100);
|
||||||
|
|
||||||
|
// Centimeters
|
||||||
|
$this->assertEquals(0, Drawing::centimetersToTwips());
|
||||||
|
$this->assertEquals($value * 566.928, Drawing::centimetersToTwips($value));
|
||||||
|
|
||||||
|
$this->assertEquals(0, Drawing::twipsToCentimeters());
|
||||||
|
$this->assertEquals($value / 566.928, Drawing::twipsToCentimeters($value));
|
||||||
|
|
||||||
|
// Inches
|
||||||
|
$this->assertEquals(0, Drawing::inchesToTwips());
|
||||||
|
$this->assertEquals($value * 1440, Drawing::inchesToTwips($value));
|
||||||
|
|
||||||
|
$this->assertEquals(0, Drawing::twipsToInches());
|
||||||
|
$this->assertEquals($value / 1440, Drawing::twipsToInches($value));
|
||||||
|
|
||||||
|
// Pixels
|
||||||
|
$this->assertEquals(0, Drawing::twipsToPixels());
|
||||||
|
$this->assertEquals(round($value / 15.873984), Drawing::twipsToPixels($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHTML()
|
||||||
|
{
|
||||||
|
$this->assertFalse(Drawing::htmlToRGB('0'));
|
||||||
|
$this->assertFalse(Drawing::htmlToRGB('00'));
|
||||||
|
$this->assertFalse(Drawing::htmlToRGB('0000'));
|
||||||
|
$this->assertFalse(Drawing::htmlToRGB('00000'));
|
||||||
|
|
||||||
|
$this->assertInternalType('array', Drawing::htmlToRGB('ABCDEF'));
|
||||||
|
$this->assertCount(3, Drawing::htmlToRGB('ABCDEF'));
|
||||||
|
$this->assertEquals(array(0xAB, 0xCD, 0xEF), Drawing::htmlToRGB('ABCDEF'));
|
||||||
|
$this->assertEquals(array(0xAB, 0xCD, 0xEF), Drawing::htmlToRGB('#ABCDEF'));
|
||||||
|
$this->assertEquals(array(0xAA, 0xBB, 0xCC), Drawing::htmlToRGB('ABC'));
|
||||||
|
$this->assertEquals(array(0xAA, 0xBB, 0xCC), Drawing::htmlToRGB('#ABC'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared\Microsoft;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \PhpOffice\PhpWord\Shared\Microsoft
|
||||||
|
* @coversDefaultClass \PhpOffice\PhpWord\Shared\Microsoft
|
||||||
|
*/
|
||||||
|
class PasswordEncoderTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test that a password can be hashed without specifying any additional parameters
|
||||||
|
*/
|
||||||
|
public function testEncodePassword()
|
||||||
|
{
|
||||||
|
//given
|
||||||
|
$password = 'test';
|
||||||
|
|
||||||
|
//when
|
||||||
|
$hashPassword = PasswordEncoder::hashPassword($password);
|
||||||
|
|
||||||
|
//then
|
||||||
|
$this->assertEquals('M795/MAlmGU8RIsY9Q9uDLHC7bk=', $hashPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that a password can be hashed with a custom salt
|
||||||
|
*/
|
||||||
|
public function testEncodePasswordWithSalt()
|
||||||
|
{
|
||||||
|
//given
|
||||||
|
$password = 'test';
|
||||||
|
$salt = base64_decode('uq81pJRRGFIY5U+E9gt8tA==');
|
||||||
|
|
||||||
|
//when
|
||||||
|
$hashPassword = PasswordEncoder::hashPassword($password, PasswordEncoder::ALGORITHM_SHA_1, $salt);
|
||||||
|
|
||||||
|
//then
|
||||||
|
$this->assertEquals('QiDOcpia1YzSVJPiKPwWebl9p/0=', $hashPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the encoder falls back on SHA-1 if a non supported algorithm is given
|
||||||
|
*/
|
||||||
|
public function testDefaultsToSha1IfUnsupportedAlgorithm()
|
||||||
|
{
|
||||||
|
//given
|
||||||
|
$password = 'test';
|
||||||
|
$salt = base64_decode('uq81pJRRGFIY5U+E9gt8tA==');
|
||||||
|
|
||||||
|
//when
|
||||||
|
$hashPassword = PasswordEncoder::hashPassword($password, PasswordEncoder::ALGORITHM_MAC, $salt);
|
||||||
|
|
||||||
|
//then
|
||||||
|
$this->assertEquals('QiDOcpia1YzSVJPiKPwWebl9p/0=', $hashPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the encoder falls back on SHA-1 if a non supported algorithm is given
|
||||||
|
*/
|
||||||
|
public function testEncodePasswordWithNullAsciiCodeInPassword()
|
||||||
|
{
|
||||||
|
//given
|
||||||
|
$password = 'test' . chr(0);
|
||||||
|
$salt = base64_decode('uq81pJRRGFIY5U+E9gt8tA==');
|
||||||
|
|
||||||
|
//when
|
||||||
|
$hashPassword = PasswordEncoder::hashPassword($password, PasswordEncoder::ALGORITHM_MAC, $salt, 1);
|
||||||
|
|
||||||
|
//then
|
||||||
|
$this->assertEquals('rDV9sgdDsztoCQlvRCb1lF2wxNg=', $hashPassword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
<?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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for Text
|
||||||
|
*
|
||||||
|
* @coversDefaultClass \PhpOffice\PhpWord\Shared\Text
|
||||||
|
*/
|
||||||
|
class TextTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testControlCharacters()
|
||||||
|
{
|
||||||
|
$this->assertEquals('', Text::controlCharacterPHP2OOXML());
|
||||||
|
$this->assertEquals('aeiou', Text::controlCharacterPHP2OOXML('aeiou'));
|
||||||
|
$this->assertEquals('àéîöù', Text::controlCharacterPHP2OOXML('àéîöù'));
|
||||||
|
|
||||||
|
$value = rand(0, 8);
|
||||||
|
$this->assertEquals('_x' . sprintf('%04s', strtoupper(dechex($value))) . '_', Text::controlCharacterPHP2OOXML(chr($value)));
|
||||||
|
|
||||||
|
$this->assertEquals('', Text::controlCharacterOOXML2PHP(''));
|
||||||
|
$this->assertEquals(chr(0x08), Text::controlCharacterOOXML2PHP('_x0008_'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNumberFormat()
|
||||||
|
{
|
||||||
|
$this->assertEquals('2.1', Text::numberFormat('2.06', 1));
|
||||||
|
$this->assertEquals('2.1', Text::numberFormat('2.12', 1));
|
||||||
|
$this->assertEquals('1234.0', Text::numberFormat(1234, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testChr()
|
||||||
|
{
|
||||||
|
$this->assertEquals('A', Text::chr(65));
|
||||||
|
$this->assertEquals('A', Text::chr(0x41));
|
||||||
|
$this->assertEquals('é', Text::chr(233));
|
||||||
|
$this->assertEquals('é', Text::chr(0xE9));
|
||||||
|
$this->assertEquals('⼳', Text::chr(12083));
|
||||||
|
$this->assertEquals('⼳', Text::chr(0x2F33));
|
||||||
|
$this->assertEquals('🌃', Text::chr(127747));
|
||||||
|
$this->assertEquals('🌃', Text::chr(0x1F303));
|
||||||
|
$this->assertEquals('', Text::chr(2097152));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is UTF8
|
||||||
|
*/
|
||||||
|
public function testIsUTF8()
|
||||||
|
{
|
||||||
|
$this->assertTrue(Text::isUTF8(''));
|
||||||
|
$this->assertTrue(Text::isUTF8('éééé'));
|
||||||
|
$this->assertFalse(Text::isUTF8(utf8_decode('éééé')));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test unicode conversion
|
||||||
|
*/
|
||||||
|
public function testToUnicode()
|
||||||
|
{
|
||||||
|
$this->assertEquals('a', Text::toUnicode('a'));
|
||||||
|
$this->assertEquals('\uc0{\u8364}', Text::toUnicode('€'));
|
||||||
|
$this->assertEquals('\uc0{\u233}', Text::toUnicode('é'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test remove underscore prefix
|
||||||
|
*/
|
||||||
|
public function testRemoveUnderscorePrefix()
|
||||||
|
{
|
||||||
|
$this->assertEquals('item', Text::removeUnderscorePrefix('_item'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,134 @@
|
||||||
|
<?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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for XMLReader
|
||||||
|
*
|
||||||
|
* @coversDefaultClass \PhpOffice\PhpWord\Shared\XMLReader
|
||||||
|
*/
|
||||||
|
class XMLReaderTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test reading XML from string
|
||||||
|
*/
|
||||||
|
public function testDomFromString()
|
||||||
|
{
|
||||||
|
$reader = new XMLReader();
|
||||||
|
$reader->getDomFromString('<element attr="test"><child attr="subtest">AAA</child></element>');
|
||||||
|
|
||||||
|
$this->assertTrue($reader->elementExists('/element/child'));
|
||||||
|
$this->assertEquals('AAA', $reader->getElement('/element/child')->textContent);
|
||||||
|
$this->assertEquals('AAA', $reader->getValue('/element/child'));
|
||||||
|
$this->assertEquals('test', $reader->getAttribute('attr', $reader->getElement('/element')));
|
||||||
|
$this->assertEquals('subtest', $reader->getAttribute('attr', $reader->getElement('/element'), 'child'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test reading XML from zip
|
||||||
|
*/
|
||||||
|
public function testDomFromZip()
|
||||||
|
{
|
||||||
|
$archiveFile = __DIR__ . '/../_files/xml/reader.zip';
|
||||||
|
|
||||||
|
$reader = new XMLReader();
|
||||||
|
$reader->getDomFromZip($archiveFile, 'test.xml');
|
||||||
|
|
||||||
|
$this->assertTrue($reader->elementExists('/element/child'));
|
||||||
|
|
||||||
|
$this->assertFalse($reader->getDomFromZip($archiveFile, 'non_existing_xml_file.xml'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that read from non existing archive throws exception
|
||||||
|
*
|
||||||
|
* @expectedException \Exception
|
||||||
|
*/
|
||||||
|
public function testThrowsExceptionOnNonExistingArchive()
|
||||||
|
{
|
||||||
|
$archiveFile = __DIR__ . '/../_files/xml/readers.zip';
|
||||||
|
|
||||||
|
$reader = new XMLReader();
|
||||||
|
$reader->getDomFromZip($archiveFile, 'test.xml');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test elements count
|
||||||
|
*/
|
||||||
|
public function testCountElements()
|
||||||
|
{
|
||||||
|
$reader = new XMLReader();
|
||||||
|
$reader->getDomFromString('<element attr="test"><child>AAA</child><child>BBB</child></element>');
|
||||||
|
|
||||||
|
$this->assertEquals(2, $reader->countElements('/element/child'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test read non existing elements
|
||||||
|
*/
|
||||||
|
public function testReturnNullOnNonExistingNode()
|
||||||
|
{
|
||||||
|
$reader = new XMLReader();
|
||||||
|
$this->assertEmpty($reader->getElements('/element/children'));
|
||||||
|
$reader->getDomFromString('<element><child>AAA</child></element>');
|
||||||
|
|
||||||
|
$this->assertNull($reader->getElement('/element/children'));
|
||||||
|
$this->assertNull($reader->getValue('/element/children'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that xpath fails if custom namespace is not registered
|
||||||
|
*/
|
||||||
|
public function testShouldThrowExceptionIfNamespaceIsNotKnown()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$reader = new XMLReader();
|
||||||
|
$reader->getDomFromString('<element><test:child xmlns:test="http://phpword.com/my/custom/namespace">AAA</test:child></element>');
|
||||||
|
|
||||||
|
$this->assertTrue($reader->elementExists('/element/test:child'));
|
||||||
|
$this->assertEquals('AAA', $reader->getElement('/element/test:child')->textContent);
|
||||||
|
$this->fail();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test reading XML with manually registered namespace
|
||||||
|
*/
|
||||||
|
public function testShouldParseXmlWithCustomNamespace()
|
||||||
|
{
|
||||||
|
$reader = new XMLReader();
|
||||||
|
$reader->getDomFromString('<element><test:child xmlns:test="http://phpword.com/my/custom/namespace">AAA</test:child></element>');
|
||||||
|
$reader->registerNamespace('test', 'http://phpword.com/my/custom/namespace');
|
||||||
|
|
||||||
|
$this->assertTrue($reader->elementExists('/element/test:child'));
|
||||||
|
$this->assertEquals('AAA', $reader->getElement('/element/test:child')->textContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that xpath fails if custom namespace is not registered
|
||||||
|
*
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testShouldThowExceptionIfTryingToRegisterNamespaceBeforeReadingDoc()
|
||||||
|
{
|
||||||
|
$reader = new XMLReader();
|
||||||
|
$reader->registerNamespace('test', 'http://phpword.com/my/custom/namespace');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?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
|
||||||
|
* @copyright 2010-2018 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for XMLWriter
|
||||||
|
*
|
||||||
|
* @coversDefaultClass \PhpOffice\PhpWord\Shared\XMLWriter
|
||||||
|
*/
|
||||||
|
class XMLWriterTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testConstruct()
|
||||||
|
{
|
||||||
|
// Memory
|
||||||
|
$object = new XMLWriter();
|
||||||
|
$object->startElement('element');
|
||||||
|
$object->text('AAA');
|
||||||
|
$object->endElement();
|
||||||
|
$this->assertEquals('<element>AAA</element>' . chr(10), $object->getData());
|
||||||
|
|
||||||
|
// Disk
|
||||||
|
$object = new XMLWriter(XMLWriter::STORAGE_DISK);
|
||||||
|
$object->startElement('element');
|
||||||
|
$object->text('BBB');
|
||||||
|
$object->endElement();
|
||||||
|
$this->assertEquals('<element>BBB</element>' . chr(10), $object->getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWriteAttribute()
|
||||||
|
{
|
||||||
|
$xmlWriter = new XMLWriter();
|
||||||
|
$xmlWriter->startElement('element');
|
||||||
|
$xmlWriter->writeAttribute('name', 'value');
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
|
$this->assertSame('<element name="value"/>' . chr(10), $xmlWriter->getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWriteAttributeShouldWriteFloatValueLocaleIndependent()
|
||||||
|
{
|
||||||
|
$value = 1.2;
|
||||||
|
|
||||||
|
$xmlWriter = new XMLWriter();
|
||||||
|
$xmlWriter->startElement('element');
|
||||||
|
$xmlWriter->writeAttribute('name', $value);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
|
$currentLocale = setlocale(LC_NUMERIC, 0);
|
||||||
|
|
||||||
|
setlocale(LC_NUMERIC, 'de_DE.UTF-8', 'de');
|
||||||
|
|
||||||
|
$this->assertSame('<element name="1.2"/>' . chr(10), $xmlWriter->getData());
|
||||||
|
|
||||||
|
setlocale(LC_NUMERIC, $currentLocale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText;
|
namespace PhpOffice\PhpWord\Writer\ODText;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\TrackChange;
|
use PhpOffice\PhpWord\Element\TrackChange;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\TestHelperDOCX;
|
use PhpOffice\PhpWord\TestHelperDOCX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText;
|
namespace PhpOffice\PhpWord\Writer\ODText;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for PhpOffice\PhpWord\Writer\ODText\Style subnamespace
|
* Test class for PhpOffice\PhpWord\Writer\ODText\Style subnamespace
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,12 @@ class TCPDFTest extends \PHPUnit\Framework\TestCase
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TCPDF version 6.3.5 doesn't support PHP 8.0, fixed via https://github.com/tecnickcom/TCPDF/pull/293,
|
||||||
|
// pending new release.
|
||||||
|
if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$file = __DIR__ . '/../../_files/tcpdf.pdf';
|
$file = __DIR__ . '/../../_files/tcpdf.pdf';
|
||||||
|
|
||||||
$phpWord = new PhpWord();
|
$phpWord = new PhpWord();
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
|
||||||
use PhpOffice\PhpWord\Element\Comment;
|
use PhpOffice\PhpWord\Element\Comment;
|
||||||
use PhpOffice\PhpWord\Element\TextRun;
|
use PhpOffice\PhpWord\Element\TextRun;
|
||||||
use PhpOffice\PhpWord\Element\TrackChange;
|
use PhpOffice\PhpWord\Element\TrackChange;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\TestHelperDOCX;
|
use PhpOffice\PhpWord\TestHelperDOCX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\Microsoft\PasswordEncoder;
|
|
||||||
use PhpOffice\PhpWord\ComplexType\ProofState;
|
use PhpOffice\PhpWord\ComplexType\ProofState;
|
||||||
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder;
|
||||||
use PhpOffice\PhpWord\SimpleType\Zoom;
|
use PhpOffice\PhpWord\SimpleType\Zoom;
|
||||||
use PhpOffice\PhpWord\Style\Language;
|
use PhpOffice\PhpWord\Style\Language;
|
||||||
use PhpOffice\PhpWord\TestHelperDOCX;
|
use PhpOffice\PhpWord\TestHelperDOCX;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Style subnamespace
|
* Test class for PhpOffice\PhpWord\Writer\Word2007\Style subnamespace
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue