getLevels();
/** @var \PhpOffice\PhpWord\Style\NumberingLevel */
$level = $levels[0];
- if($start > 0){
+ if ($start > 0) {
$level->setStart($start);
}
- if($type && !!($type = self::mapListType($type))){
+ if ($type && !!($type = self::mapListType($type))) {
$level->setFormat($type);
}
}
@@ -675,10 +675,10 @@ class Html
// must have exact order [width color style], e.g. "1px #0011CC solid" or "2pt green solid"
// Word does not accept shortened hex colors e.g. #CCC, only full e.g. #CCCCCC
if (preg_match('/([0-9]+[^0-9]*)\s+(\#[a-fA-F0-9]+|[a-zA-Z]+)\s+([a-z]+)/', $cValue, $matches)) {
- if(false !== strpos($cKey, '-')){
+ if (false !== strpos($cKey, '-')) {
$which = explode('-', $cKey)[1];
$which = ucfirst($which); // e.g. bottom -> Bottom
- }else{
+ } else {
$which = '';
}
// normalization: in HTML 1px means tinest possible line width, so we cannot convert 1px -> 15 twips, coz line'd be bold, we use smallest twip instead
@@ -883,6 +883,10 @@ class Html
case 'baseline':
return 'top';
default:
+ // @discuss - which one should apply:
+ // - Word uses default vert. alignment: top
+ // - all browsers use default vert. alignment: middle
+ // Returning empty string means attribute wont be set so use Word default (top).
return '';
}
}
From 70ad01550bab55c6f1f6558a36945777a18ffb53 Mon Sep 17 00:00:00 2001
From: lubosdz
Date: Mon, 13 Jul 2020 19:16:38 +0200
Subject: [PATCH 050/139] Make scrunitizer happier
---
src/PhpWord/Shared/Html.php | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index 7d45b4ba..edd418bf 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -96,13 +96,13 @@ class Html
$attributes = $node->attributes; // get all the attributes(eg: id, class)
foreach ($attributes as $attribute) {
- $val = trim($attribute->value);
+ $val = $attribute->value;
switch (strtolower($attribute->name)) {
case 'style':
$styles = self::parseStyle($attribute, $styles);
break;
case 'align':
- $styles['alignment'] = self::mapAlign($val);
+ $styles['alignment'] = self::mapAlign(trim($val));
break;
case 'lang':
$styles['lang'] = $val;
@@ -121,7 +121,7 @@ class Html
break;
case 'cellspacing':
// tables e.g.
, where "2" = 2px (always pixels)
- $val = intval($attribute->value).'px';
+ $val = intval($val).'px';
$styles['cellSpacing'] = Converter::cssToTwip($val);
break;
case 'bgcolor':
@@ -475,7 +475,8 @@ class Html
if ($start > 0) {
$level->setStart($start);
}
- if ($type && !!($type = self::mapListType($type))) {
+ $type = $type ? self::mapListType($type) : null;
+ if ($type) {
$level->setFormat($type);
}
}
From 4448bda7215c7389bec955988004c4d13a5ac482 Mon Sep 17 00:00:00 2001
From: lubosdz
Date: Tue, 14 Jul 2020 01:31:16 +0200
Subject: [PATCH 051/139] Better normalization for width of borders
---
src/PhpWord/Shared/Html.php | 20 ++++++++++++--------
tests/PhpWord/Shared/HtmlTest.php | 2 +-
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index edd418bf..c8a7fa69 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -682,10 +682,14 @@ class Html
} else {
$which = '';
}
- // normalization: in HTML 1px means tinest possible line width, so we cannot convert 1px -> 15 twips, coz line'd be bold, we use smallest twip instead
- $size = strtolower(trim($matches[1]));
- // BC change: up to ver. 0.17.0 incorrectly converted to points - Converter::cssToPoint($size)
- $size = ($size == '1px') ? 1 : Converter::cssToTwip($size);
+ // Note - border width normalization:
+ // Width of border in Word is calculated differently than HTML borders, usually showing up too bold.
+ // Smallest 1px (or 1pt) appears in Word like 2-3px/pt in HTML once converted to twips.
+ // Therefore we need to normalize converted twip value to cca 1/2 of value.
+ // This may be adjusted, if better ratio or formula found.
+ // BC change: up to ver. 0.17.0 was $size converted to points - Converter::cssToPoint($size)
+ $size = Converter::cssToTwip($matches[1]);
+ $size = intval($size / 2);
// valid variants may be e.g. borderSize, borderTopSize, borderLeftColor, etc ..
$styles["border{$which}Size"] = $size; // twips
$styles["border{$which}Color"] = trim($matches[2], '#');
@@ -884,10 +888,10 @@ class Html
case 'baseline':
return 'top';
default:
- // @discuss - which one should apply:
- // - Word uses default vert. alignment: top
- // - all browsers use default vert. alignment: middle
- // Returning empty string means attribute wont be set so use Word default (top).
+ // @discuss - which one should apply:
+ // - Word uses default vert. alignment: top
+ // - all browsers use default vert. alignment: middle
+ // Returning empty string means attribute wont be set so use Word default (top).
return '';
}
}
diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php
index 010d1918..93df9337 100644
--- a/tests/PhpWord/Shared/HtmlTest.php
+++ b/tests/PhpWord/Shared/HtmlTest.php
@@ -774,7 +774,7 @@ HTML;
$xpath = '/w:document/w:body/w:p[4]/w:pPr/w:pBdr/w:bottom';
$this->assertTrue($doc->elementExists($xpath));
$this->assertEquals('single', $doc->getElement($xpath)->getAttribute('w:val'));
- $this->assertEquals(5 * 15, $doc->getElement($xpath)->getAttribute('w:sz'));
+ $this->assertEquals(intval(5 * 15 / 2), $doc->getElement($xpath)->getAttribute('w:sz'));
$this->assertEquals('lightblue', $doc->getElement($xpath)->getAttribute('w:color'));
$xpath = '/w:document/w:body/w:p[4]/w:pPr/w:spacing';
From f69885e7b92e4e149c7a535aaa6dabf5c4d57117 Mon Sep 17 00:00:00 2001
From: lubosdz
Date: Wed, 22 Jul 2020 10:04:12 +0200
Subject: [PATCH 052/139] fix bug - don't decode double quotes inside double
quoted string
---
src/PhpWord/Shared/Html.php | 4 ++--
tests/PhpWord/Shared/HtmlTest.php | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index c8a7fa69..d3e452e4 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -62,10 +62,10 @@ class Html
// Preprocess: remove all line ends, decode HTML entity,
// fix ampersand and angle brackets and add body tag for HTML fragments
$html = str_replace(array("\n", "\r"), '', $html);
- $html = str_replace(array('<', '>', '&'), array('_lt_', '_gt_', '_amp_'), $html);
+ $html = str_replace(array('<', '>', '&', '"'), array('_lt_', '_gt_', '_amp_', '_quot_'), $html);
$html = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
$html = str_replace('&', '&', $html);
- $html = str_replace(array('_lt_', '_gt_', '_amp_'), array('<', '>', '&'), $html);
+ $html = str_replace(array('_lt_', '_gt_', '_amp_', '_quot_'), array('<', '>', '&', '"'), $html);
if (false === $fullHTML) {
$html = '' . $html . '';
diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php
index 93df9337..7a806c26 100644
--- a/tests/PhpWord/Shared/HtmlTest.php
+++ b/tests/PhpWord/Shared/HtmlTest.php
@@ -884,4 +884,22 @@ HTML;
$this->assertTrue($doc->elementExists($xpath));
$this->assertEquals('bottom', $doc->getElement($xpath)->getAttribute('w:val'));
}
+
+ /**
+ * Fix bug - don't decode double quotes inside double quoted string
+ */
+ public function testDontDecodeAlreadyEncodedDoubleQuotes()
+ {
+ $phpWord = new \PhpOffice\PhpWord\PhpWord();
+ $section = $phpWord->addSection();
+
+ // borders & backgrounds are here just for better visual comparison
+ $html = <<This would crash if inline quotes also decoded at loading XML into DOMDocument!
+HTML;
+
+ Html::addHtml($section, $html);
+ $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
+ $this->assertTrue(is_object($doc));
+ }
}
From 69632b3f0333cbdbd51f4c71cdbce67240144b2f Mon Sep 17 00:00:00 2001
From: lubosdz
Date: Wed, 22 Jul 2020 10:46:23 +0200
Subject: [PATCH 053/139] remove extra line at the end, which possibly causes
CI job fail
---
src/PhpWord/Shared/Html.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index d3e452e4..04200b31 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -987,5 +987,4 @@ class Html
// - line - that is a shape, has different behaviour
// - repeated text, e.g. underline "_", because of unpredictable line wrapping
}
-
}
From d6260988bd6df5f20bf662f0467f6d1a10bea1cf Mon Sep 17 00:00:00 2001
From: Maxim
Date: Thu, 23 Jul 2020 18:49:25 +0300
Subject: [PATCH 054/139] Allow to redefine TCPDF object
Sometimes we need create TCPDF object with modified initial arguments.
This change allow rewrite only createExternalWriterInstance() in user defined TCPDF class.
---
src/PhpWord/Writer/PDF/TCPDF.php | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/PhpWord/Writer/PDF/TCPDF.php b/src/PhpWord/Writer/PDF/TCPDF.php
index badab046..2558c29e 100644
--- a/src/PhpWord/Writer/PDF/TCPDF.php
+++ b/src/PhpWord/Writer/PDF/TCPDF.php
@@ -36,6 +36,20 @@ class TCPDF extends AbstractRenderer implements WriterInterface
*/
protected $includeFile = 'tcpdf.php';
+ /**
+ * Gets the implementation of external PDF library that should be used.
+ *
+ * @param string $orientation Page orientation
+ * @param string $unit Unit measure
+ * @param string $paperSize Paper size
+ *
+ * @return \TCPDF implementation
+ */
+ protected function createExternalWriterInstance($orientation, $unit, $paperSize)
+ {
+ return new \TCPDF($orientation, $unit, $paperSize);
+ }
+
/**
* Save PhpWord to file.
*
@@ -50,7 +64,7 @@ class TCPDF extends AbstractRenderer implements WriterInterface
$orientation = 'P';
// Create PDF
- $pdf = new \TCPDF($orientation, 'pt', $paperSize);
+ $pdf = $this->createExternalWriterInstance($orientation, 'pt', $paperSize);
$pdf->setFontSubsetting(false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
From 6f1b18937c89df8b27956f788c731050341dbbfb Mon Sep 17 00:00:00 2001
From: csk83
Date: Wed, 26 Aug 2020 12:50:08 +0800
Subject: [PATCH 055/139] code format
---
src/PhpWord/Writer/Word2007/Part/Chart.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php
index dd738d1e..b661a102 100644
--- a/src/PhpWord/Writer/Word2007/Part/Chart.php
+++ b/src/PhpWord/Writer/Word2007/Part/Chart.php
@@ -155,7 +155,7 @@ class Chart extends AbstractPart
//Chart legend
if ($showLegend) {
- $xmlWriter->writeRaw('');
+ $xmlWriter->writeRaw('');
}
$xmlWriter->startElement('c:plotArea');
From d42854ddb6c0083622c7905cb607f453b01aa0c3 Mon Sep 17 00:00:00 2001
From: csk83
Date: Sat, 29 Aug 2020 20:41:25 +0800
Subject: [PATCH 056/139] chart doc/sample/code comments
---
docs/styles.rst | 1 +
samples/Sample_32_Chart.php | 5 +++++
src/PhpWord/Style/Chart.php | 19 ++++++++++++++-----
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/docs/styles.rst b/docs/styles.rst
index 18a9c2ec..06d983e5 100644
--- a/docs/styles.rst
+++ b/docs/styles.rst
@@ -201,6 +201,7 @@ Available Chart style options:
- ``colors``. A list of colors to use in the chart.
- ``title``. The title for the chart.
- ``showLegend``. Show legend, *true* or *false*.
+- ``LegendPosition``. Legend position, *r* (default), *b*, *t*, *l* or *tr*.
- ``categoryLabelPosition``. Label position for categories, *nextTo* (default), *low* or *high*.
- ``valueLabelPosition``. Label position for values, *nextTo* (default), *low* or *high*.
- ``categoryAxisTitle``. The title for the category axis.
diff --git a/samples/Sample_32_Chart.php b/samples/Sample_32_Chart.php
index c24a6f8e..bfb9ffe8 100644
--- a/samples/Sample_32_Chart.php
+++ b/samples/Sample_32_Chart.php
@@ -25,6 +25,9 @@ $series2 = array(3, 1, 7, 2, 6);
$series3 = array(8, 3, 2, 5, 4);
$showGridLines = false;
$showAxisLabels = false;
+$showLegend = true;
+$legendPosition = 't';
+// r = right, l = left, t = top, b = bottom, tr = top right
foreach ($chartTypes as $chartType) {
$section->addTitle(ucfirst($chartType), 2);
@@ -33,6 +36,8 @@ foreach ($chartTypes as $chartType) {
$chart->getStyle()->setShowGridX($showGridLines);
$chart->getStyle()->setShowGridY($showGridLines);
$chart->getStyle()->setShowAxisLabels($showAxisLabels);
+ $chart->getStyle()->setShowLegend($showLegend);
+ $chart->getStyle()->setLegendPosition($legendPosition);
if (in_array($chartType, $twoSeries)) {
$chart->addSeries($categories, $series2);
}
diff --git a/src/PhpWord/Style/Chart.php b/src/PhpWord/Style/Chart.php
index f6de7c22..c02c0af4 100644
--- a/src/PhpWord/Style/Chart.php
+++ b/src/PhpWord/Style/Chart.php
@@ -67,7 +67,8 @@ class Chart extends AbstractStyle
private $showLegend = false;
/**
- * Chart legend Position.
+ * Chart legend Position.
+ * Possible values are 'r', 't', 'b', 'l', 'tr'
*
* @var string
*/
@@ -240,6 +241,7 @@ class Chart extends AbstractStyle
* Set the colors to use in a chart.
*
* @param array $value a list of colors to use in the chart
+ * @return self
*/
public function setColors($value = array())
{
@@ -262,6 +264,7 @@ class Chart extends AbstractStyle
* Set the chart title
*
* @param string $value
+ * @return self
*/
public function setTitle($value = null)
{
@@ -284,6 +287,7 @@ class Chart extends AbstractStyle
* Set chart legend visibility
*
* @param bool $value
+ * @return self
*/
public function setShowLegend($value = false)
{
@@ -312,11 +316,13 @@ class Chart extends AbstractStyle
*
* default: right
*
- * @param bool $value
+ * @param string $legendPosition
+ * @return self
*/
- public function setLegendPosition($value = 'r')
+ public function setLegendPosition($legendPosition = 'r')
{
- $this->legendPosition = $value;
+ $enum = array('r', 'b', 't', 'l', 'tr');
+ $this->legendPosition = $this->setEnumVal($legendPosition, $enum, $this->legendPosition);
return $this;
}
@@ -364,7 +370,10 @@ class Chart extends AbstractStyle
{
foreach (array_keys($this->dataLabelOptions) as $option) {
if (isset($values[$option])) {
- $this->dataLabelOptions[$option] = $this->setBoolVal($values[$option], $this->dataLabelOptions[$option]);
+ $this->dataLabelOptions[$option] = $this->setBoolVal(
+ $values[$option],
+ $this->dataLabelOptions[$option]
+ );
}
}
}
From 9a59cf0590e25b1d018712fd4e6f55fcd1ffe97b Mon Sep 17 00:00:00 2001
From: csk83
Date: Mon, 31 Aug 2020 11:56:21 +0800
Subject: [PATCH 057/139] format check
---
src/PhpWord/Element/AbstractContainer.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php
index 0c773dbe..f9451c8d 100644
--- a/src/PhpWord/Element/AbstractContainer.php
+++ b/src/PhpWord/Element/AbstractContainer.php
@@ -108,7 +108,8 @@ abstract class AbstractContainer extends AbstractElement
}
} else {
// All other elements
- array_unshift($args, $element); // Prepend element name to the beginning of args array
+ array_unshift($args, $element);
+ // Prepend element name to the beginning of args array
return call_user_func_array(array($this, 'addElement'), $args);
}
}
From 3a7dd774a2fa723a05b6c3345997f41f838a4b6c Mon Sep 17 00:00:00 2001
From: Sven Ahrens
Date: Tue, 1 Sep 2020 18:13:25 +0200
Subject: [PATCH 058/139] Add support for mc:AlternateContent
---
.gitignore | 3 +++
src/PhpWord/Reader/Word2007/AbstractPart.php | 13 +++++++++++++
2 files changed, 16 insertions(+)
diff --git a/.gitignore b/.gitignore
index dd858cea..da661ee3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,6 @@ phpword.ini
/.project
/nbproject
/.php_cs.cache
+docker-compose.yml
+/phpdocker
+/public
diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php
index 06dfe37b..17dbceb4 100644
--- a/src/PhpWord/Reader/Word2007/AbstractPart.php
+++ b/src/PhpWord/Reader/Word2007/AbstractPart.php
@@ -292,6 +292,19 @@ abstract class AbstractPart
$parent->addTextBreak();
} elseif ($node->nodeName == 'w:tab') {
$parent->addText("\t");
+ } elseif ($node->nodeName == 'mc:AlternateContent') {
+ $hasChildren = $node->childNodes->length > 0;
+
+ if ($hasChildren) {
+ $origin = $node->childNodes->item($node->childNodes->length - 1);
+
+ if ($origin->nodeValue) {
+ // TextRun
+ $textContent = htmlspecialchars($origin->nodeValue, ENT_QUOTES, 'UTF-8');
+
+ $parent->addText($textContent, $fontStyle, $paragraphStyle);
+ }
+ }
} elseif ($node->nodeName == 'w:t' || $node->nodeName == 'w:delText') {
// TextRun
$textContent = htmlspecialchars($xmlReader->getValue('.', $node), ENT_QUOTES, 'UTF-8');
From 63d1ffceb8f5aa627d706fc02d82b6ccd37a7691 Mon Sep 17 00:00:00 2001
From: Sven Ahrens
Date: Tue, 1 Sep 2020 18:14:27 +0200
Subject: [PATCH 059/139] Restore gitignore
---
.gitignore | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.gitignore b/.gitignore
index da661ee3..dd858cea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,3 @@ phpword.ini
/.project
/nbproject
/.php_cs.cache
-docker-compose.yml
-/phpdocker
-/public
From 58e0200fbdb5634becb4c777f9624998935a38ff Mon Sep 17 00:00:00 2001
From: Sven Ahrens
Date: Wed, 2 Sep 2020 12:12:48 +0200
Subject: [PATCH 060/139] Get fallback value instead of taking the last element
---
src/PhpWord/Reader/Word2007/AbstractPart.php | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php
index 17dbceb4..2bc71b3a 100644
--- a/src/PhpWord/Reader/Word2007/AbstractPart.php
+++ b/src/PhpWord/Reader/Word2007/AbstractPart.php
@@ -293,14 +293,14 @@ abstract class AbstractPart
} elseif ($node->nodeName == 'w:tab') {
$parent->addText("\t");
} elseif ($node->nodeName == 'mc:AlternateContent') {
- $hasChildren = $node->childNodes->length > 0;
-
- if ($hasChildren) {
- $origin = $node->childNodes->item($node->childNodes->length - 1);
+ if ($node->hasChildNodes()) {
+ // Get fallback instead of mc:Choice to make sure it is compatible
+ $fallbackElements = $node->getElementsByTagName('Fallback');
- if ($origin->nodeValue) {
+ if ($fallbackElements->length) {
+ $fallback = $fallbackElements->item(0);
// TextRun
- $textContent = htmlspecialchars($origin->nodeValue, ENT_QUOTES, 'UTF-8');
+ $textContent = htmlspecialchars($fallback->nodeValue, ENT_QUOTES, 'UTF-8');
$parent->addText($textContent, $fontStyle, $paragraphStyle);
}
From ae34ae9518efc2bb6bdfc150e03b24fd72848702 Mon Sep 17 00:00:00 2001
From: Sven Ahrens
Date: Wed, 2 Sep 2020 13:03:29 +0200
Subject: [PATCH 061/139] Add testcase
---
composer.json | 2 +-
tests/PhpWord/Reader/Word2007/ElementTest.php | 43 +++++++++++++++++++
.../PhpWord/_includes/AbstractTestReader.php | 2 +-
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index f5f751ec..e8720b7b 100644
--- a/composer.json
+++ b/composer.json
@@ -36,7 +36,7 @@
],
"scripts": {
"test": [
- "phpunit --color=always"
+ "phpunit --color=always --filter testReadAlternateContent"
],
"test-no-coverage": [
"phpunit --color=always --no-coverage"
diff --git a/tests/PhpWord/Reader/Word2007/ElementTest.php b/tests/PhpWord/Reader/Word2007/ElementTest.php
index cb72ef9f..a0875a67 100644
--- a/tests/PhpWord/Reader/Word2007/ElementTest.php
+++ b/tests/PhpWord/Reader/Word2007/ElementTest.php
@@ -25,6 +25,49 @@ use PhpOffice\PhpWord\Element\TrackChange;
*/
class ElementTest extends AbstractTestReader
{
+ /**
+ * Test reading of alternate content value
+ */
+ public function testReadAlternateContent()
+ {
+ $documentXml = '
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Test node value
+
+
+
+
+
+
+
+
+
+ ';
+
+ $phpWord = $this->getDocumentFromString(array('document' => $documentXml));
+
+ $elements = $phpWord->getSection(0)->getElements();
+
+ $this->assertInstanceOf('PhpOffice\PhpWord\Element\TextRun', $elements[0]);
+ $this->assertInstanceOf('PhpOffice\PhpWord\Element\Text', $elements[0]->getElement(0));
+
+ $text = $elements[0];
+
+ $this->assertEquals('Test node value', trim($text->getElement(0)->getText()));
+ }
+
/**
* Test reading of textbreak
*/
diff --git a/tests/PhpWord/_includes/AbstractTestReader.php b/tests/PhpWord/_includes/AbstractTestReader.php
index d9097d71..12bd437a 100644
--- a/tests/PhpWord/_includes/AbstractTestReader.php
+++ b/tests/PhpWord/_includes/AbstractTestReader.php
@@ -24,7 +24,7 @@ abstract class AbstractTestReader extends \PHPUnit\Framework\TestCase
{
private $parts = array(
'styles' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Styles', 'xml' => '{toReplace}'),
- 'document' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Document', 'xml' => '{toReplace}'),
+ 'document' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Document', 'xml' => '{toReplace}'),
'footnotes' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Footnotes', 'xml' => '{toReplace}'),
'endnotes' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Endnotes', 'xml' => '{toReplace}'),
'settings' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Settings', 'xml' => '{toReplace}'),
From 51034af207cd5f39636a541b7705e33edb09a69c Mon Sep 17 00:00:00 2001
From: Sven Ahrens
Date: Wed, 2 Sep 2020 13:03:49 +0200
Subject: [PATCH 062/139] Remove filter option
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index e8720b7b..f5f751ec 100644
--- a/composer.json
+++ b/composer.json
@@ -36,7 +36,7 @@
],
"scripts": {
"test": [
- "phpunit --color=always --filter testReadAlternateContent"
+ "phpunit --color=always"
],
"test-no-coverage": [
"phpunit --color=always --no-coverage"
From 166a136f221b9d2c8dcfd0f740925492ce29d262 Mon Sep 17 00:00:00 2001
From: Sven Ahrens
Date: Wed, 2 Sep 2020 14:36:08 +0200
Subject: [PATCH 063/139] Fix spacing
---
tests/PhpWord/Reader/Word2007/ElementTest.php | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tests/PhpWord/Reader/Word2007/ElementTest.php b/tests/PhpWord/Reader/Word2007/ElementTest.php
index a0875a67..d5db6be8 100644
--- a/tests/PhpWord/Reader/Word2007/ElementTest.php
+++ b/tests/PhpWord/Reader/Word2007/ElementTest.php
@@ -59,12 +59,9 @@ class ElementTest extends AbstractTestReader
$phpWord = $this->getDocumentFromString(array('document' => $documentXml));
$elements = $phpWord->getSection(0)->getElements();
-
$this->assertInstanceOf('PhpOffice\PhpWord\Element\TextRun', $elements[0]);
$this->assertInstanceOf('PhpOffice\PhpWord\Element\Text', $elements[0]->getElement(0));
-
$text = $elements[0];
-
$this->assertEquals('Test node value', trim($text->getElement(0)->getText()));
}
From aa7c1d0fe87c27f49fcb15ce2895301307773707 Mon Sep 17 00:00:00 2001
From: Yannik Firre <3316758+YannikFirre@users.noreply.github.com>
Date: Tue, 22 Sep 2020 16:28:52 +0200
Subject: [PATCH 064/139] FIX - When setComplexValue is not found
---
src/PhpWord/TemplateProcessor.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 7efc0f1a..7f50e3fb 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -274,6 +274,11 @@ class TemplateProcessor
$elementWriter->write();
$where = $this->findContainingXmlBlockForMacro($search, 'w:r');
+
+ if($where === false) {
+ return ;
+ }
+
$block = $this->getSlice($where['start'], $where['end']);
$textParts = $this->splitTextIntoTexts($block);
$this->replaceXmlBlock($search, $textParts, 'w:r');
From adb917273c3f0504516a9e281ea61e6e97ed1382 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 12:56:06 +0200
Subject: [PATCH 065/139] allow PHP 7.4, 8.0
---
.travis.yml | 11 +++++++----
composer.json | 8 ++++----
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index acdf95cc..421e772c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,8 @@ php:
- 7.1
- 7.2
- 7.3
- - 7.4snapshot
+ - 7.4
+ - nightly
matrix:
include:
@@ -26,14 +27,16 @@ matrix:
env: COVERAGE=1
- php: 7.3
env: DEPENDENCIES="--ignore-platform-reqs"
+ - php: 7.4
+ env: DEPENDENCIES="--ignore-platform-reqs"
+ - php: nightly
+ env: DEPENDENCIES="--ignore-platform-reqs"
exclude:
- php: 5.3
- php: 5.4
- php: 5.5
- - php: 7.0
- - php: 7.3
allow_failures:
- - php: 7.4snapshot
+ - php: nightly
cache:
directories:
diff --git a/composer.json b/composer.json
index f5f751ec..43738937 100644
--- a/composer.json
+++ b/composer.json
@@ -58,7 +58,7 @@
"fix": "Fixes issues found by PHP-CS"
},
"require": {
- "php": "^5.3.3 || ^7.0",
+ "php": "^5.3.3 || ^7.0 || ^8.0",
"ext-xml": "*",
"zendframework/zend-escaper": "^2.2",
"phpoffice/common": "^0.2.9"
@@ -67,13 +67,13 @@
"ext-zip": "*",
"ext-gd": "*",
"phpunit/phpunit": "^4.8.36 || ^7.0",
- "squizlabs/php_codesniffer": "^2.9",
+ "squizlabs/php_codesniffer": "^2.9 || ^3.5",
"friendsofphp/php-cs-fixer": "^2.2",
"phpmd/phpmd": "2.*",
- "phploc/phploc": "2.* || 3.* || 4.*",
+ "phploc/phploc": "2.* || 3.* || 4.* || 5.* || 6.* || 7.*",
"dompdf/dompdf":"0.8.*",
"tecnickcom/tcpdf": "6.*",
- "mpdf/mpdf": "5.7.4 || 6.* || 7.*",
+ "mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
},
"suggest": {
From e334ecf059aa19b7ba82fa8600501efcb0b45ff4 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 13:39:22 +0200
Subject: [PATCH 066/139] compatibility with phpmd 2.9
---
phpmd.xml.dist | 2 ++
src/PhpWord/Reader/MsDoc.php | 16 ++++++++--------
tests/PhpWord/Element/TableTest.php | 6 +++---
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/phpmd.xml.dist b/phpmd.xml.dist
index 2077e02b..cfb9353b 100644
--- a/phpmd.xml.dist
+++ b/phpmd.xml.dist
@@ -5,6 +5,8 @@
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
+
+
diff --git a/src/PhpWord/Reader/MsDoc.php b/src/PhpWord/Reader/MsDoc.php
index 1a9e4988..eb64e00a 100644
--- a/src/PhpWord/Reader/MsDoc.php
+++ b/src/PhpWord/Reader/MsDoc.php
@@ -1581,7 +1581,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
// Variables
$sprmCPicLocation = null;
$sprmCFData = null;
- $sprmCFSpec = null;
+ //$sprmCFSpec = null;
do {
// Variables
@@ -1830,7 +1830,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
break;
// sprmCFSpec
case 0x55:
- $sprmCFSpec = $operand;
+ //$sprmCFSpec = $operand;
break;
// sprmCFtcBi
case 0x5E:
@@ -2094,11 +2094,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
$sprmCPicLocation += 1;
// stPicName
- $stPicName = '';
+ //$stPicName = '';
for ($inc = 0; $inc <= $cchPicName; $inc++) {
- $chr = self::getInt1d($this->dataData, $sprmCPicLocation);
+ //$chr = self::getInt1d($this->dataData, $sprmCPicLocation);
$sprmCPicLocation += 1;
- $stPicName .= chr($chr);
+ //$stPicName .= chr($chr);
}
}
@@ -2143,11 +2143,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
$sprmCPicLocation += 1;
// nameData
if ($cbName > 0) {
- $nameData = '';
+ //$nameData = '';
for ($inc = 0; $inc <= ($cbName / 2); $inc++) {
- $chr = self::getInt2d($this->dataData, $sprmCPicLocation);
+ //$chr = self::getInt2d($this->dataData, $sprmCPicLocation);
$sprmCPicLocation += 2;
- $nameData .= chr($chr);
+ //$nameData .= chr($chr);
}
}
// embeddedBlip
diff --git a/tests/PhpWord/Element/TableTest.php b/tests/PhpWord/Element/TableTest.php
index 8ae5306c..17aa13a3 100644
--- a/tests/PhpWord/Element/TableTest.php
+++ b/tests/PhpWord/Element/TableTest.php
@@ -99,10 +99,10 @@ class TableTest extends \PHPUnit\Framework\TestCase
{
$oTable = new Table();
$oTable->addRow();
- $element = $oTable->addCell();
+ $oTable->addCell();
$this->assertEquals($oTable->countColumns(), 1);
- $element = $oTable->addCell();
- $element = $oTable->addCell();
+ $oTable->addCell();
+ $oTable->addCell();
$this->assertEquals($oTable->countColumns(), 3);
}
}
From 9dad1d20e8ca3375fd7e8413ba3722232e758236 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 14:05:52 +0200
Subject: [PATCH 067/139] PHP 7.4 - fixed invalid value in hexdec
avoid notice: "Invalid characters passed for attempted conversion, these have been ignored"
---
src/PhpWord/Shared/Converter.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/PhpWord/Shared/Converter.php b/src/PhpWord/Shared/Converter.php
index 39e80545..05755ef7 100644
--- a/src/PhpWord/Shared/Converter.php
+++ b/src/PhpWord/Shared/Converter.php
@@ -338,9 +338,9 @@ class Converter
return false;
}
- $red = hexdec($red);
- $green = hexdec($green);
- $blue = hexdec($blue);
+ $red = ctype_xdigit($red) ? hexdec($red) : 0;
+ $green = ctype_xdigit($green) ? hexdec($green) : 0;
+ $blue = ctype_xdigit($blue) ? hexdec($blue) : 0;
return array($red, $green, $blue);
}
From 7fd4b64e8ad678d9017c08f89077344f2f024bee Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 14:26:19 +0200
Subject: [PATCH 068/139] - composer in php 5.x require increase memory limit -
in PHP 7.3, 7.4 not necessary remove ignore platforms
---
.travis.yml | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 421e772c..421df777 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,17 +18,12 @@ matrix:
include:
- php: 5.3
dist: precise
- env: COMPOSER_MEMORY_LIMIT=3G
- php: 5.4
dist: trusty
- php: 5.5
dist: trusty
- php: 7.0
env: COVERAGE=1
- - php: 7.3
- env: DEPENDENCIES="--ignore-platform-reqs"
- - php: 7.4
- env: DEPENDENCIES="--ignore-platform-reqs"
- php: nightly
env: DEPENDENCIES="--ignore-platform-reqs"
exclude:
@@ -58,6 +53,8 @@ before_script:
- if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini || echo "xdebug not available" ; fi
## Composer
- composer self-update
+ ## Composer in PHP versions 5.x requires 3 GB memory
+ - if [ ${TRAVIS_PHP_VERSION:0:2} == "5." ]; then export COMPOSER_MEMORY_LIMIT=3G ; fi
- travis_wait composer install --prefer-source $(if [ -n "$DEPENDENCIES" ]; then echo $DEPENDENCIES; fi)
## PHPDocumentor
##- mkdir -p build/docs
From 93978211a13dbccd197e47090085a6565a6a2504 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 15:48:39 +0200
Subject: [PATCH 069/139] PHP 8.0 - depracated libxml_disable_entity_loader, is
disabled by default
---
src/PhpWord/Shared/Html.php | 8 ++++++--
src/PhpWord/TemplateProcessor.php | 8 ++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index 54e9509e..be1ef742 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -72,7 +72,9 @@ class Html
}
// Load DOM
- $orignalLibEntityLoader = libxml_disable_entity_loader(true);
+ if (\PHP_VERSION_ID < 80000) {
+ $orignalLibEntityLoader = libxml_disable_entity_loader(true);
+ }
$dom = new \DOMDocument();
$dom->preserveWhiteSpace = $preserveWhiteSpace;
$dom->loadXML($html);
@@ -80,7 +82,9 @@ class Html
$node = $dom->getElementsByTagName('body');
self::parseNode($node->item(0), $element);
- libxml_disable_entity_loader($orignalLibEntityLoader);
+ if (\PHP_VERSION_ID < 80000) {
+ libxml_disable_entity_loader($orignalLibEntityLoader);
+ }
}
/**
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 7efc0f1a..8aadb8c5 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -170,7 +170,9 @@ class TemplateProcessor
*/
protected function transformSingleXml($xml, $xsltProcessor)
{
- $orignalLibEntityLoader = libxml_disable_entity_loader(true);
+ if (\PHP_VERSION_ID < 80000) {
+ $orignalLibEntityLoader = libxml_disable_entity_loader(true);
+ }
$domDocument = new \DOMDocument();
if (false === $domDocument->loadXML($xml)) {
throw new Exception('Could not load the given XML document.');
@@ -180,7 +182,9 @@ class TemplateProcessor
if (false === $transformedXml) {
throw new Exception('Could not transform the given XML document.');
}
- libxml_disable_entity_loader($orignalLibEntityLoader);
+ if (\PHP_VERSION_ID < 80000) {
+ libxml_disable_entity_loader($orignalLibEntityLoader);
+ }
return $transformedXml;
}
From 9c6cf6fdb622db07332d0c23f1ba47b123005670 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 15:56:40 +0200
Subject: [PATCH 070/139] PHP 8.0 fix - ValueError: file_exists(): Argument #1
($filename) must not contain any null bytes
---
src/PhpWord/Element/Image.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php
index bae87ff5..c6dd0e58 100644
--- a/src/PhpWord/Element/Image.php
+++ b/src/PhpWord/Element/Image.php
@@ -454,7 +454,7 @@ class Image extends AbstractElement
} else {
$this->sourceType = self::SOURCE_GD;
}
- } elseif (@file_exists($this->source)) {
+ } elseif (is_string($this->source) && @file_exists($this->source)) {
$this->memoryImage = false;
$this->sourceType = self::SOURCE_LOCAL;
} else {
From 93579e90efed9836d247c412715c1daf95906587 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 16:05:30 +0200
Subject: [PATCH 071/139] forgotten condition for libxml_disable_entity_loader
---
tests/PhpWord/_includes/XmlDocument.php | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/PhpWord/_includes/XmlDocument.php b/tests/PhpWord/_includes/XmlDocument.php
index 3a7869bc..14735511 100644
--- a/tests/PhpWord/_includes/XmlDocument.php
+++ b/tests/PhpWord/_includes/XmlDocument.php
@@ -76,10 +76,14 @@ class XmlDocument
$this->file = $file;
$file = $this->path . '/' . $file;
- $orignalLibEntityLoader = libxml_disable_entity_loader(false);
+ if (\PHP_VERSION_ID < 80000) {
+ $orignalLibEntityLoader = libxml_disable_entity_loader(false);
+ }
$this->dom = new \DOMDocument();
$this->dom->load($file);
- libxml_disable_entity_loader($orignalLibEntityLoader);
+ if (\PHP_VERSION_ID < 80000) {
+ libxml_disable_entity_loader($orignalLibEntityLoader);
+ }
return $this->dom;
}
From a36a42912880d77fe6caabb0689b5c294fb3793d Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 17:08:23 +0200
Subject: [PATCH 072/139] rewrite check to local file
---
src/PhpWord/Element/Image.php | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php
index c6dd0e58..081e3b5d 100644
--- a/src/PhpWord/Element/Image.php
+++ b/src/PhpWord/Element/Image.php
@@ -454,7 +454,7 @@ class Image extends AbstractElement
} else {
$this->sourceType = self::SOURCE_GD;
}
- } elseif (is_string($this->source) && @file_exists($this->source)) {
+ } elseif ($this->isFile($this->source)) {
$this->memoryImage = false;
$this->sourceType = self::SOURCE_LOCAL;
} else {
@@ -463,6 +463,18 @@ class Image extends AbstractElement
}
}
+ /**
+ * @param string $filename
+ * @return bool
+ */
+ private function isFile($filename) {
+ try {
+ return @file_exists($filename);
+ } catch(\Exception $ex) {
+ return false;
+ }
+ }
+
/**
* Get image size from archive
*
From bf1bb2b7ca5262312b17f8f7ebcb3f1121ff523d Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 17:17:46 +0200
Subject: [PATCH 073/139] PHP 8.0 - fixed Error: Unknown named parameter
$styles
---
src/PhpWord/Shared/Html.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index be1ef742..252665e7 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -182,7 +182,7 @@ class Html
}
}
$method = "parse{$method}";
- $newElement = call_user_func_array(array('PhpOffice\PhpWord\Shared\Html', $method), $arguments);
+ $newElement = call_user_func_array(array('PhpOffice\PhpWord\Shared\Html', $method), array_values($arguments));
// Retrieve back variables from arguments
foreach ($keys as $key) {
From 2845284284260844169951689aa744646d1ca1c0 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 17:25:02 +0200
Subject: [PATCH 074/139] revert from develop branch
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index 421df777..c7add667 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,6 +30,7 @@ matrix:
- php: 5.3
- php: 5.4
- php: 5.5
+ - php: 7.0
allow_failures:
- php: nightly
From 236c7c44998c64e7603574bbf084303a64a04ec9 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 17 Oct 2020 17:34:51 +0200
Subject: [PATCH 075/139] fix code format
---
src/PhpWord/Element/Image.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php
index 081e3b5d..0662bd4c 100644
--- a/src/PhpWord/Element/Image.php
+++ b/src/PhpWord/Element/Image.php
@@ -467,10 +467,11 @@ class Image extends AbstractElement
* @param string $filename
* @return bool
*/
- private function isFile($filename) {
+ private function isFile($filename)
+ {
try {
return @file_exists($filename);
- } catch(\Exception $ex) {
+ } catch (\Exception $ex) {
return false;
}
}
From 0edcab0da6a6075f6fee4e3bc0851c5cff08e885 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 18 Oct 2020 07:26:06 +0200
Subject: [PATCH 076/139] allow php 5.3, 5.4, 5.5 except xenial os
---
.travis.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index c7add667..1b7b71da 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,8 +28,11 @@ matrix:
env: DEPENDENCIES="--ignore-platform-reqs"
exclude:
- php: 5.3
+ dist: xenial
- php: 5.4
+ dist: xenial
- php: 5.5
+ dist: xenial
- php: 7.0
allow_failures:
- php: nightly
From eaf2212aa8d2e5cc85757fb6f76428ab72748b5a Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 18 Oct 2020 07:45:57 +0200
Subject: [PATCH 077/139] fix format for coverage
---
.travis.yml | 1 -
src/PhpWord/Element/AbstractContainer.php | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 1b7b71da..05d21d82 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,7 +33,6 @@ matrix:
dist: xenial
- php: 5.5
dist: xenial
- - php: 7.0
allow_failures:
- php: nightly
diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php
index 0c773dbe..6a1ed930 100644
--- a/src/PhpWord/Element/AbstractContainer.php
+++ b/src/PhpWord/Element/AbstractContainer.php
@@ -109,6 +109,7 @@ abstract class AbstractContainer extends AbstractElement
} else {
// All other elements
array_unshift($args, $element); // Prepend element name to the beginning of args array
+
return call_user_func_array(array($this, 'addElement'), $args);
}
}
From 6d49b28678466a63d09530b637e3ae4fdc96627b Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 18 Oct 2020 07:47:25 +0200
Subject: [PATCH 078/139] skip TCPDF test in PHP 5.3, because
version 6.3.5 doesn't support PHP 5.3, fixed via https://github.com/tecnickcom/TCPDF/pull/197, pending new release.
---
tests/PhpWord/Writer/PDF/TCPDFTest.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/PhpWord/Writer/PDF/TCPDFTest.php b/tests/PhpWord/Writer/PDF/TCPDFTest.php
index 6dc8f24c..c8f5d222 100644
--- a/tests/PhpWord/Writer/PDF/TCPDFTest.php
+++ b/tests/PhpWord/Writer/PDF/TCPDFTest.php
@@ -33,6 +33,12 @@ class TCPDFTest extends \PHPUnit\Framework\TestCase
*/
public function testConstruct()
{
+ // TCPDF version 6.3.5 doesn't support PHP 5.3, fixed via https://github.com/tecnickcom/TCPDF/pull/197,
+ // pending new release.
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
+ return;
+ }
+
$file = __DIR__ . '/../../_files/tcpdf.pdf';
$phpWord = new PhpWord();
From b7dc71ab1b64e0b42d0497c61d29f4732549a358 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 18 Oct 2020 08:18:39 +0200
Subject: [PATCH 079/139] scrutinizer fix, allow zip extension
---
.scrutinizer.yml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 2b395afd..d1fe5961 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -3,6 +3,12 @@ build:
analysis:
tests:
override: [php-scrutinizer-run]
+ environment:
+ php:
+ version: '7.4'
+ pecl_extensions:
+ - zip
+
filter:
excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ]
From b8ffe0477be771e9c09ce9edf28e6ea6b61bf13a Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 18 Oct 2020 08:54:12 +0200
Subject: [PATCH 080/139] fix cs issue: "Arguments with default values must be
at the end of the argument list"
---
src/PhpWord/Reader/Word2007/AbstractPart.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php
index 06dfe37b..eab659fa 100644
--- a/src/PhpWord/Reader/Word2007/AbstractPart.php
+++ b/src/PhpWord/Reader/Word2007/AbstractPart.php
@@ -573,11 +573,11 @@ abstract class AbstractPart
* Returns the first child element found
*
* @param XMLReader $xmlReader
- * @param \DOMElement $parentNode
- * @param string|array $elements
+ * @param \DOMElement|null $parentNode
+ * @param string|array|null $elements
* @return string|null
*/
- private function findPossibleElement(XMLReader $xmlReader, \DOMElement $parentNode = null, $elements)
+ private function findPossibleElement(XMLReader $xmlReader, \DOMElement $parentNode = null, $elements = null)
{
if (is_array($elements)) {
//if element is an array, we take the first element that exists in the XML
From 4e4282a76e7269f8e9586efd22f1364110e6e0d6 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 18 Oct 2020 10:56:24 +0200
Subject: [PATCH 081/139] refixed "must not contain any null bytes"
---
src/PhpWord/Element/Image.php | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php
index 0662bd4c..2e25fd18 100644
--- a/src/PhpWord/Element/Image.php
+++ b/src/PhpWord/Element/Image.php
@@ -454,7 +454,7 @@ class Image extends AbstractElement
} else {
$this->sourceType = self::SOURCE_GD;
}
- } elseif ($this->isFile($this->source)) {
+ } elseif ((strpos($this->source, chr(0)) === false) && @file_exists($this->source)) {
$this->memoryImage = false;
$this->sourceType = self::SOURCE_LOCAL;
} else {
@@ -463,19 +463,6 @@ class Image extends AbstractElement
}
}
- /**
- * @param string $filename
- * @return bool
- */
- private function isFile($filename)
- {
- try {
- return @file_exists($filename);
- } catch (\Exception $ex) {
- return false;
- }
- }
-
/**
* Get image size from archive
*
From f2516b08b146da9b2be66326bb36d6f54fe56781 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 18 Oct 2020 13:16:43 +0200
Subject: [PATCH 082/139] migrate from abandoned `Zend\Escaper` to `Laminas
Escaper`
---
README.md | 3 +--
composer.json | 5 ++++-
docs/installing.rst | 4 +---
src/PhpWord/Writer/HTML/Element/AbstractElement.php | 4 ++--
src/PhpWord/Writer/HTML/Part/AbstractPart.php | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index b15f83d7..30b008a2 100644
--- a/README.md
+++ b/README.md
@@ -62,8 +62,7 @@ PHPWord requires the following:
- PHP 5.3.3+
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
-- [Zend\Escaper component](http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html)
-- [Zend\Stdlib component](http://framework.zend.com/manual/current/en/modules/zend.stdlib.hydrator.html)
+- [Laminas Escaper component](https://docs.laminas.dev/laminas-escaper/intro/)
- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)
- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images)
- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write OOXML and ODF)
diff --git a/composer.json b/composer.json
index 43738937..19997215 100644
--- a/composer.json
+++ b/composer.json
@@ -60,7 +60,7 @@
"require": {
"php": "^5.3.3 || ^7.0 || ^8.0",
"ext-xml": "*",
- "zendframework/zend-escaper": "^2.2",
+ "laminas/laminas-escaper": "^2.2",
"phpoffice/common": "^0.2.9"
},
"require-dev": {
@@ -76,6 +76,9 @@
"mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
},
+ "replace": {
+ "laminas/laminas-zendframework-bridge": "*"
+ },
"suggest": {
"ext-zip": "Allows writing OOXML and ODF",
"ext-gd2": "Allows adding images",
diff --git a/docs/installing.rst b/docs/installing.rst
index 2a9582d0..baf966bd 100644
--- a/docs/installing.rst
+++ b/docs/installing.rst
@@ -10,9 +10,7 @@ Mandatory:
- PHP 5.3.3+
- `XML Parser `__ extension
-- `Zend\\Escaper `__ component
-- Zend\\Stdlib component
-- `Zend\\Validator `__ component
+- `Laminas Escaper `__ component
Optional:
diff --git a/src/PhpWord/Writer/HTML/Element/AbstractElement.php b/src/PhpWord/Writer/HTML/Element/AbstractElement.php
index dc5ccfaa..30d1ccaa 100644
--- a/src/PhpWord/Writer/HTML/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/HTML/Element/AbstractElement.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\HTML\Element;
+use Laminas\Escaper\Escaper;
use PhpOffice\PhpWord\Element\AbstractElement as Element;
use PhpOffice\PhpWord\Writer\AbstractWriter;
-use Zend\Escaper\Escaper;
/**
* Abstract HTML element writer
@@ -50,7 +50,7 @@ abstract class AbstractElement
protected $withoutP = false;
/**
- * @var \Zend\Escaper\Escaper|\PhpOffice\PhpWord\Escaper\AbstractEscaper
+ * @var \Laminas\Escaper\Escaper|\PhpOffice\PhpWord\Escaper\AbstractEscaper
*/
protected $escaper;
diff --git a/src/PhpWord/Writer/HTML/Part/AbstractPart.php b/src/PhpWord/Writer/HTML/Part/AbstractPart.php
index 2d86f399..97c76375 100644
--- a/src/PhpWord/Writer/HTML/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/HTML/Part/AbstractPart.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\HTML\Part;
+use Laminas\Escaper\Escaper;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Writer\AbstractWriter;
-use Zend\Escaper\Escaper;
/**
* @since 0.11.0
@@ -32,7 +32,7 @@ abstract class AbstractPart
private $parentWriter;
/**
- * @var \Zend\Escaper\Escaper
+ * @var \Laminas\Escaper\Escaper
*/
protected $escaper;
From 4cc2cc1aeb54c29521fcc6e5a00e9016b4e604f3 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Mon, 19 Oct 2020 11:24:25 +0200
Subject: [PATCH 083/139] travis upgrade to PHPUnit 8 for PHP 8
---
.travis.yml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index 05d21d82..3c3e1819 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -59,6 +59,12 @@ before_script:
## Composer in PHP versions 5.x requires 3 GB memory
- if [ ${TRAVIS_PHP_VERSION:0:2} == "5." ]; then export COMPOSER_MEMORY_LIMIT=3G ; fi
- travis_wait composer install --prefer-source $(if [ -n "$DEPENDENCIES" ]; then echo $DEPENDENCIES; fi)
+ ## PHP 8 require PHPUnit 8
+ - |
+ if [[ ${TRAVIS_PHP_VERSION:0:2} == "8." ]] || [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
+ travis_wait composer remove phpunit/phpunit --dev --no-interaction --ignore-platform-reqs
+ travis_wait composer require phpunit/phpunit ^8.0 --dev --ignore-platform-reqs
+ fi
## PHPDocumentor
##- mkdir -p build/docs
- mkdir -p build/coverage
From 6b999233630eb99016906a46f34d77eb13ff1777 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Mon, 19 Oct 2020 14:44:28 +0200
Subject: [PATCH 084/139] travis php 8 - convert tests from phpunit 7 format to
phpunit 8 format
---
.travis.yml | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 3c3e1819..ef850687 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -59,11 +59,23 @@ before_script:
## Composer in PHP versions 5.x requires 3 GB memory
- if [ ${TRAVIS_PHP_VERSION:0:2} == "5." ]; then export COMPOSER_MEMORY_LIMIT=3G ; fi
- travis_wait composer install --prefer-source $(if [ -n "$DEPENDENCIES" ]; then echo $DEPENDENCIES; fi)
- ## PHP 8 require PHPUnit 8
+ ## PHP 8 require PHPUnit 8 (ugly hack for support PHPUnit 7 and 8 together)
- |
if [[ ${TRAVIS_PHP_VERSION:0:2} == "8." ]] || [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
travis_wait composer remove phpunit/phpunit --dev --no-interaction --ignore-platform-reqs
travis_wait composer require phpunit/phpunit ^8.0 --dev --ignore-platform-reqs
+
+ find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function setUpBeforeClass()$/function setUpBeforeClass(): void/' {} \;
+ find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function tearDownAfterClass()$/function tearDownAfterClass(): void/' {} \;
+ find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function setUp()$/function setUp(): void/' {} \;
+ find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function tearDown()$/function tearDown(): void/' {} \;
+
+ find ./tests/ -name "*.php" -type f -exec sed -i -e 's/->assertContains(/->assertStringContainsString(/' {} \;
+ find ./tests/ -name "*.php" -type f -exec sed -i -e 's/->assertNotContains(/->assertStringNotContainsString(/' {} \;
+ find ./tests/ -name "*.php" -type f -exec sed -i -e "s/->assertInternalType('array', /->assertIsArray(/" {} \;
+
+ sed -i "s/\$this->addWarning('The @expectedException,/\/\/\$this->addWarning('The @expectedException,/" ./vendor/phpunit/phpunit/src/Framework/TestCase.php
+ sed -i "s/self::createWarning('The optional \$delta/\/\/self::createWarning('The optional \$delta/" ./vendor/phpunit/phpunit/src/Framework/Assert.php
fi
## PHPDocumentor
##- mkdir -p build/docs
From ecc13ff62a87322f1f71f4a9b4dee76a1f98dc84 Mon Sep 17 00:00:00 2001
From: Nicholas Moore
Date: Thu, 22 Oct 2020 13:53:28 +0300
Subject: [PATCH 085/139] Update templates-processing.rst
fix typo in doc
---
docs/templates-processing.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/templates-processing.rst b/docs/templates-processing.rst
index 5bc11454..bac421c3 100644
--- a/docs/templates-processing.rst
+++ b/docs/templates-processing.rst
@@ -190,7 +190,7 @@ Finds a row in a table row identified by `$search` param and clones it as many t
['userId' => 1, 'userName' => 'Batman', 'userAddress' => 'Gotham City'],
['userId' => 2, 'userName' => 'Superman', 'userAddress' => 'Metropolis'],
];
- $templateProcessor->cloneRowAndSetValues('userId', );
+ $templateProcessor->cloneRowAndSetValues('userId', $values);
Will result in
From b86c60694ca074ef5cb629794f77b0041ba8211f Mon Sep 17 00:00:00 2001
From: Julien Aupart
Date: Sun, 8 Nov 2020 20:58:06 +0100
Subject: [PATCH 086/139] feat: Update addHtml to handle style inheritance The
aim is to get the output closer to the source html
---
src/PhpWord/Element/AbstractContainer.php | 1 +
src/PhpWord/Shared/Html.php | 44 ++++++++++++++++++++---
tests/PhpWord/Shared/HtmlTest.php | 14 +++++---
3 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php
index 0c773dbe..6a1ed930 100644
--- a/src/PhpWord/Element/AbstractContainer.php
+++ b/src/PhpWord/Element/AbstractContainer.php
@@ -109,6 +109,7 @@ abstract class AbstractContainer extends AbstractElement
} else {
// All other elements
array_unshift($args, $element); // Prepend element name to the beginning of args array
+
return call_user_func_array(array($this, 'addElement'), $args);
}
}
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index 54e9509e..b29c9a1b 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -364,7 +364,7 @@ class Html
$cell = $element->addCell(null, $cellStyles);
if (self::shouldAddTextRun($node)) {
- return $cell->addTextRun(self::parseInlineStyle($node, $styles['paragraph']));
+ return $cell->addTextRun(self::filterOutNonInheritedStyles(self::parseInlineStyle($node, $styles['paragraph'])));
}
return $cell;
@@ -395,15 +395,51 @@ class Html
*/
protected static function recursiveParseStylesInHierarchy(\DOMNode $node, array $style)
{
- $parentStyle = self::parseInlineStyle($node, array());
- $style = array_merge($parentStyle, $style);
+ $parentStyle = array();
if ($node->parentNode != null && XML_ELEMENT_NODE == $node->parentNode->nodeType) {
- $style = self::recursiveParseStylesInHierarchy($node->parentNode, $style);
+ $parentStyle = self::recursiveParseStylesInHierarchy($node->parentNode, array());
}
+ if ($node->nodeName === '#text') {
+ $parentStyle = array_merge($parentStyle, $style);
+ } else {
+ $parentStyle = self::filterOutNonInheritedStyles($parentStyle);
+ }
+ $style = self::parseInlineStyle($node, $parentStyle);
return $style;
}
+ /**
+ * Removes non-inherited styles from array
+ *
+ * @param array &$styles
+ */
+ protected static function filterOutNonInheritedStyles(array $styles)
+ {
+ $nonInheritedStyles = array(
+ 'borderSize',
+ 'borderTopSize',
+ 'borderRightSize',
+ 'borderBottomSize',
+ 'borderLeftSize',
+ 'borderColor',
+ 'borderTopColor',
+ 'borderRightColor',
+ 'borderBottomColor',
+ 'borderLeftColor',
+ 'borderStyle',
+ 'spaceAfter',
+ 'spaceBefore',
+ 'underline',
+ 'strikethrough',
+ 'hidden',
+ );
+
+ $styles = array_diff_key($styles, array_flip($nonInheritedStyles));
+
+ return $styles;
+ }
+
/**
* Parse list node
*
diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php
index 5bc9e241..0dfef405 100644
--- a/tests/PhpWord/Shared/HtmlTest.php
+++ b/tests/PhpWord/Shared/HtmlTest.php
@@ -293,11 +293,11 @@ class HtmlTest extends AbstractWebServerEmbeddedTest
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
- $html = '
+ $html = '
-
-
header a
-
header b
+
+
header a
+
header b
header c
@@ -324,6 +324,12 @@ class HtmlTest extends AbstractWebServerEmbeddedTest
$this->assertEquals('00BB00', $doc->getElementAttribute('/w:document/w:body/w:tbl/w:tr[1]/w:tc[3]/w:tcPr/w:tcBorders/w:right', 'w:color'));
$this->assertEquals('00CC00', $doc->getElementAttribute('/w:document/w:body/w:tbl/w:tr[1]/w:tc[3]/w:tcPr/w:tcBorders/w:bottom', 'w:color'));
$this->assertEquals('00DD00', $doc->getElementAttribute('/w:document/w:body/w:tbl/w:tr[1]/w:tc[3]/w:tcPr/w:tcBorders/w:left', 'w:color'));
+
+ //check borders are not propagated inside cells
+ $this->assertTrue($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p'));
+ $this->assertFalse($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:pBdr'));
+ $this->assertTrue($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p'));
+ $this->assertFalse($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:pBdr'));
}
/**
From f7242e12501829d26574bd10b2649fde0dbfd013 Mon Sep 17 00:00:00 2001
From: Johannes Sochor
Date: Wed, 11 Nov 2020 17:18:52 +0100
Subject: [PATCH 087/139] fix image limit
---
src/PhpWord/TemplateProcessor.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 7efc0f1a..5973dd88 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -577,6 +577,7 @@ class TemplateProcessor
// result can be verified via "Open XML SDK 2.5 Productivity Tool" (http://www.microsoft.com/en-us/download/details.aspx?id=30425)
$imgTpl = '';
+ $i = 0;
foreach ($searchParts as $partFileName => &$partContent) {
$partVariables = $this->getVariablesForPart($partContent);
@@ -609,6 +610,10 @@ class TemplateProcessor
// replace on each iteration, because in one tag we can have 2+ inline variables => before proceed next variable we need to change $partContent
$partContent = $this->setValueForPart($wholeTag, $replaceXml, $partContent, $limit);
}
+ $i++;
+ if($i >= $limit) {
+ break;
+ }
}
}
}
From a9e012530d9bdbdf426077917ff7974d2a6a5afb Mon Sep 17 00:00:00 2001
From: Libor M
Date: Wed, 9 Dec 2020 13:03:49 +0100
Subject: [PATCH 088/139] travis support latest php as 8.0 now
---
.travis.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index ef850687..2d68941a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,7 @@ php:
- 7.2
- 7.3
- 7.4
- - nightly
+ - 8.0
matrix:
include:
@@ -24,7 +24,7 @@ matrix:
dist: trusty
- php: 7.0
env: COVERAGE=1
- - php: nightly
+ - php: 8.0
env: DEPENDENCIES="--ignore-platform-reqs"
exclude:
- php: 5.3
@@ -34,7 +34,7 @@ matrix:
- php: 5.5
dist: xenial
allow_failures:
- - php: nightly
+ - php: 8.0
cache:
directories:
From 4b4dfb4ccd392219a12579316e88fb477809e727 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Thu, 10 Dec 2020 15:27:31 +0100
Subject: [PATCH 089/139] update ugly hack for PHPUnit 8 support
---
.travis.yml | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 2d68941a..aca5dbf8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -58,13 +58,17 @@ before_script:
- composer self-update
## Composer in PHP versions 5.x requires 3 GB memory
- if [ ${TRAVIS_PHP_VERSION:0:2} == "5." ]; then export COMPOSER_MEMORY_LIMIT=3G ; fi
+ ## PHP 8 require PHPUnit 8 (ugly hack for support PHPUnit 7 and 8 together)
+ - |
+ if [[ ${TRAVIS_PHP_VERSION:0:2} == "8." ]] || [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
+ travis_wait composer remove phpunit/phpunit --dev --no-update --no-interaction
+ travis_wait composer require phpunit/phpunit ^8.0 --dev --no-update
+ fi
+ ## Install composer packages
- travis_wait composer install --prefer-source $(if [ -n "$DEPENDENCIES" ]; then echo $DEPENDENCIES; fi)
## PHP 8 require PHPUnit 8 (ugly hack for support PHPUnit 7 and 8 together)
- |
if [[ ${TRAVIS_PHP_VERSION:0:2} == "8." ]] || [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
- travis_wait composer remove phpunit/phpunit --dev --no-interaction --ignore-platform-reqs
- travis_wait composer require phpunit/phpunit ^8.0 --dev --ignore-platform-reqs
-
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function setUpBeforeClass()$/function setUpBeforeClass(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function tearDownAfterClass()$/function tearDownAfterClass(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function setUp()$/function setUp(): void/' {} \;
From 36b63a107c51db41f1bf042c2365888dff338f89 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Fri, 11 Dec 2020 07:53:33 +0100
Subject: [PATCH 090/139] skip test, because php 8.0 contain internally
validation
---
tests/PhpWord/TemplateProcessorTest.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/PhpWord/TemplateProcessorTest.php b/tests/PhpWord/TemplateProcessorTest.php
index 4caca77a..5b922f71 100644
--- a/tests/PhpWord/TemplateProcessorTest.php
+++ b/tests/PhpWord/TemplateProcessorTest.php
@@ -140,6 +140,11 @@ final class TemplateProcessorTest extends \PHPUnit\Framework\TestCase
*/
final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue()
{
+ // Test is not needed for PHP 8.0, because internally validation throws TypeError exception.
+ if (\PHP_VERSION_ID >= 80000) {
+ $this->markTestSkipped('not needed for PHP 8.0');
+ }
+
$templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/blank.docx');
$xslDomDocument = new \DOMDocument();
From c8de86a7ec9e368e5e7cb48e03d51e20e979a6c0 Mon Sep 17 00:00:00 2001
From: SailorMax
Date: Wed, 16 Dec 2020 17:24:42 +0300
Subject: [PATCH 091/139] allow to use customized pdf library
---
src/PhpWord/Element/AbstractContainer.php | 1 +
src/PhpWord/Writer/PDF/DomPDF.php | 12 +++++++++++-
src/PhpWord/Writer/PDF/MPDF.php | 15 +++++++++++++--
src/PhpWord/Writer/PDF/TCPDF.php | 16 +++++++++++++++-
4 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php
index 0c773dbe..6a1ed930 100644
--- a/src/PhpWord/Element/AbstractContainer.php
+++ b/src/PhpWord/Element/AbstractContainer.php
@@ -109,6 +109,7 @@ abstract class AbstractContainer extends AbstractElement
} else {
// All other elements
array_unshift($args, $element); // Prepend element name to the beginning of args array
+
return call_user_func_array(array($this, 'addElement'), $args);
}
}
diff --git a/src/PhpWord/Writer/PDF/DomPDF.php b/src/PhpWord/Writer/PDF/DomPDF.php
index 5fa8f75d..53eea815 100644
--- a/src/PhpWord/Writer/PDF/DomPDF.php
+++ b/src/PhpWord/Writer/PDF/DomPDF.php
@@ -35,6 +35,16 @@ class DomPDF extends AbstractRenderer implements WriterInterface
*/
protected $includeFile = null;
+ /**
+ * Gets the implementation of external PDF library that should be used.
+ *
+ * @return Dompdf implementation
+ */
+ protected function createExternalWriterInstance()
+ {
+ return new DompdfLib();
+ }
+
/**
* Save PhpWord to file.
*
@@ -49,7 +59,7 @@ class DomPDF extends AbstractRenderer implements WriterInterface
$orientation = 'portrait';
// Create PDF
- $pdf = new DompdfLib();
+ $pdf = $this->createExternalWriterInstance();
$pdf->setPaper(strtolower($paperSize), $orientation);
$pdf->loadHtml(str_replace(PHP_EOL, '', $this->getContent()));
$pdf->render();
diff --git a/src/PhpWord/Writer/PDF/MPDF.php b/src/PhpWord/Writer/PDF/MPDF.php
index e63f5dfd..464f156c 100644
--- a/src/PhpWord/Writer/PDF/MPDF.php
+++ b/src/PhpWord/Writer/PDF/MPDF.php
@@ -44,6 +44,18 @@ class MPDF extends AbstractRenderer implements WriterInterface
parent::__construct($phpWord);
}
+ /**
+ * Gets the implementation of external PDF library that should be used.
+ *
+ * @return Mpdf implementation
+ */
+ protected function createExternalWriterInstance()
+ {
+ $mPdfClass = $this->getMPdfClassName();
+
+ return new $mPdfClass();
+ }
+
/**
* Save PhpWord to file.
*
@@ -58,8 +70,7 @@ class MPDF extends AbstractRenderer implements WriterInterface
$orientation = strtoupper('portrait');
// Create PDF
- $mPdfClass = $this->getMPdfClassName();
- $pdf = new $mPdfClass();
+ $pdf = $this->createExternalWriterInstance();
$pdf->_setPageSize($paperSize, $orientation);
$pdf->addPage($orientation);
diff --git a/src/PhpWord/Writer/PDF/TCPDF.php b/src/PhpWord/Writer/PDF/TCPDF.php
index badab046..3abbbf06 100644
--- a/src/PhpWord/Writer/PDF/TCPDF.php
+++ b/src/PhpWord/Writer/PDF/TCPDF.php
@@ -36,6 +36,20 @@ class TCPDF extends AbstractRenderer implements WriterInterface
*/
protected $includeFile = 'tcpdf.php';
+ /**
+ * Gets the implementation of external PDF library that should be used.
+ *
+ * @param string $orientation Page orientation
+ * @param string $unit Unit measure
+ * @param string $paperSize Paper size
+ *
+ * @return \TCPDF implementation
+ */
+ protected function createExternalWriterInstance($orientation, $unit, $paperSize)
+ {
+ return new \TCPDF($orientation, $unit, $paperSize);
+ }
+
/**
* Save PhpWord to file.
*
@@ -50,7 +64,7 @@ class TCPDF extends AbstractRenderer implements WriterInterface
$orientation = 'P';
// Create PDF
- $pdf = new \TCPDF($orientation, 'pt', $paperSize);
+ $pdf = $this->createExternalWriterInstance($orientation, 'pt', $paperSize);
$pdf->setFontSubsetting(false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
From cc9dfb86302671f88d4ed8fdad37dcbf67619987 Mon Sep 17 00:00:00 2001
From: emhome
Date: Sat, 19 Dec 2020 16:36:55 +0800
Subject: [PATCH 092/139] add/setting page element border style.
---
src/PhpWord/Style/Border.php | 35 +++++++++++++++++++
.../Writer/Word2007/Style/Paragraph.php | 1 +
2 files changed, 36 insertions(+)
diff --git a/src/PhpWord/Style/Border.php b/src/PhpWord/Style/Border.php
index d032d07f..8d2ca37c 100644
--- a/src/PhpWord/Style/Border.php
+++ b/src/PhpWord/Style/Border.php
@@ -22,6 +22,41 @@ namespace PhpOffice\PhpWord\Style;
*/
class Border extends AbstractStyle
{
+ /**
+ * Border Style Val.
+ * Wordprocessing Paragraphs Borders
+ * Specifies the style of the border. Paragraph borders can be only line borders. (Page borders can also be art borders.) Possible values are:
+ * @see http://officeopenxml.com/WPborders.php
+ * @const string
+ */
+ const BORDER_STYLE_SINGLE = 'single'; //A single line
+ const BORDER_STYLE_DASH_DOT_STROKED = 'dashDotStroked'; //A line with a series of alternating thin and thick strokes
+ const BORDER_STYLE_DASHED = 'dashed'; //A dashed line
+ const BORDER_STYLE_DASH_SMALL_GAP = 'dashSmallGap'; //A dashed line with small gaps
+ const BORDER_STYLE_DOT_DASH = 'dotDash'; //A line with alternating dots and dashes
+ const BORDER_STYLE_DOT_DOT_DASH = 'dotDotDash'; //A line with a repeating dot - dot - dash sequence
+ const BORDER_STYLE_DOTTED = 'dotted'; //A dotted line
+ const BORDER_STYLE_DOUBLE = 'double'; //A double line
+ const BORDER_STYLE_DOUBLE_WAVE = 'doubleWave'; //A double wavy line
+ const BORDER_STYLE_INSET = 'inset'; //An inset set of lines
+ const BORDER_STYLE_NIL = 'nil'; //No border
+ const BORDER_STYLE_NONE = 'none'; //No border
+ const BORDER_STYLE_OUTSET = 'outset'; //An outset set of lines
+ const BORDER_STYLE_THICK = 'thick'; //A single line
+ const BORDER_STYLE_THICK_THIN_LARGE_GAP = 'thickThinLargeGap'; //A thick line contained within a thin line with a large-sized intermediate gap
+ const BORDER_STYLE_THICK_THIN_MEDIUM_GAP = 'thickThinMediumGap'; //A thick line contained within a thin line with a medium-sized intermediate gap
+ const BORDER_STYLE_THICK_THIN_SMALL_GAP = 'thickThinSmallGap'; //A thick line contained within a thin line with a small intermediate gap
+ const BORDER_STYLE_THIN_THICK_LARGE_GAP = 'thinThickLargeGap'; //A thin line contained within a thick line with a large-sized intermediate gap
+ const BORDER_STYLE_THIN_THICK_MEDIUM_GAP = 'thinThickMediumGap'; //A thick line contained within a thin line with a medium-sized intermediate gap
+ const BORDER_STYLE_THIN_THICK_SMALL_GAP = 'thinThickSmallGap'; //A thick line contained within a thin line with a small intermediate gap
+ const BORDER_STYLE_THIN_THICK_THINLARGE_GAP = 'thinThickThinLargeGap'; //A thin-thick-thin line with a large gap
+ const BORDER_STYLE_THIN_THICK_THIN_MEDIUM_GAP = 'thinThickThinMediumGap'; //A thin-thick-thin line with a medium gap
+ const BORDER_STYLE_THIN_THICK_THIN_SMALL_GAP = 'thinThickThinSmallGap'; //A thin-thick-thin line with a small gap
+ const BORDER_STYLE_THREE_D_EMBOSS = 'threeDEmboss'; //A three-staged gradient line, getting darker towards the paragraph
+ const BORDER_STYLE_THREE_D_ENGRAVE = 'threeDEngrave'; //A three-staged gradient like, getting darker away from the paragraph
+ const BORDER_STYLE_TRIPLE = 'triple'; //A triple line
+ const BORDER_STYLE_WAVE = 'wave'; //A wavy line
+
/**
* Border Top Size
*
diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php
index 67616086..1e37f844 100644
--- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php
+++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php
@@ -132,6 +132,7 @@ class Paragraph extends AbstractStyle
$styleWriter = new MarginBorder($xmlWriter);
$styleWriter->setSizes($style->getBorderSize());
+ $styleWriter->setStyles($style->getBorderStyle());
$styleWriter->setColors($style->getBorderColor());
$styleWriter->write();
From 1f67c993e286b642f8d5600f302d6351d8565ef0 Mon Sep 17 00:00:00 2001
From: Ciki
Date: Tue, 22 Dec 2020 12:12:18 +0100
Subject: [PATCH 093/139] Fix deprecated warning for non-hexadecimal number
I've come across this deprecated warning when trying to save docx to pdf.. if cellBgColor is set to `auto` it should be converted back to `null` which has in practice the same functionality.
---
src/PhpWord/Writer/HTML/Element/Table.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php
index a6f14792..f19ad683 100644
--- a/src/PhpWord/Writer/HTML/Element/Table.php
+++ b/src/PhpWord/Writer/HTML/Element/Table.php
@@ -52,6 +52,7 @@ class Table extends AbstractElement
for ($j = 0; $j < $rowCellCount; $j++) {
$cellStyle = $rowCells[$j]->getStyle();
$cellBgColor = $cellStyle->getBgColor();
+ $cellBgColor === 'auto' && $cellBgColor = null; // Fix deprecated warning for non-hexadecimal number
$cellFgColor = null;
if ($cellBgColor) {
$red = hexdec(substr($cellBgColor, 0, 2));
From 18e41a1c4e0a9afcc1317dffb35c48318a260b7e Mon Sep 17 00:00:00 2001
From: Ergashev Adizbek
Date: Wed, 23 Dec 2020 16:00:06 +0500
Subject: [PATCH 094/139] Update TemplateProcessor.php
---
src/PhpWord/TemplateProcessor.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 7efc0f1a..c8fc0b8a 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -575,7 +575,7 @@ class TemplateProcessor
// define templates
// result can be verified via "Open XML SDK 2.5 Productivity Tool" (http://www.microsoft.com/en-us/download/details.aspx?id=30425)
- $imgTpl = '';
+ $imgTpl = '';
foreach ($searchParts as $partFileName => &$partContent) {
$partVariables = $this->getVariablesForPart($partContent);
From 15ee5dee05067dd7217a4a22e92f0780c1a3e5ac Mon Sep 17 00:00:00 2001
From: Yannik Firre <3316758+YannikFirre@users.noreply.github.com>
Date: Wed, 30 Dec 2020 14:02:29 +0100
Subject: [PATCH 095/139] Fix missing space after if keyword
---
src/PhpWord/TemplateProcessor.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 7f50e3fb..ece29c35 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -275,7 +275,7 @@ class TemplateProcessor
$where = $this->findContainingXmlBlockForMacro($search, 'w:r');
- if($where === false) {
+ if ($where === false) {
return ;
}
From 834a95c503361b8e15353e2ac98295561aea8d55 Mon Sep 17 00:00:00 2001
From: Antoine de Troostembergh
Date: Wed, 30 Dec 2020 20:29:43 +0100
Subject: [PATCH 096/139] fix formatting
---
src/PhpWord/Writer/PDF/TCPDF.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/Writer/PDF/TCPDF.php b/src/PhpWord/Writer/PDF/TCPDF.php
index f31ca1b1..9cd01ffd 100644
--- a/src/PhpWord/Writer/PDF/TCPDF.php
+++ b/src/PhpWord/Writer/PDF/TCPDF.php
@@ -36,7 +36,7 @@ class TCPDF extends AbstractRenderer implements WriterInterface
*/
protected $includeFile = 'tcpdf.php';
- /**
+ /**
* Gets the implementation of external PDF library that should be used.
*
* @param string $orientation Page orientation
From cf808cb3fcc436f344eef5b4b3e60b75e515d240 Mon Sep 17 00:00:00 2001
From: Antoine de Troostembergh
Date: Thu, 31 Dec 2020 21:56:45 +0100
Subject: [PATCH 097/139] Fix merge issue
---
src/PhpWord/Writer/PDF/TCPDF.php | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/src/PhpWord/Writer/PDF/TCPDF.php b/src/PhpWord/Writer/PDF/TCPDF.php
index 9cd01ffd..3abbbf06 100644
--- a/src/PhpWord/Writer/PDF/TCPDF.php
+++ b/src/PhpWord/Writer/PDF/TCPDF.php
@@ -50,20 +50,6 @@ class TCPDF extends AbstractRenderer implements WriterInterface
return new \TCPDF($orientation, $unit, $paperSize);
}
- /**
- * Gets the implementation of external PDF library that should be used.
- *
- * @param string $orientation Page orientation
- * @param string $unit Unit measure
- * @param string $paperSize Paper size
- *
- * @return \TCPDF implementation
- */
- protected function createExternalWriterInstance($orientation, $unit, $paperSize)
- {
- return new \TCPDF($orientation, $unit, $paperSize);
- }
-
/**
* Save PhpWord to file.
*
From c52686c2436eed853ec2a993811a12c3d5829dd8 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Fri, 1 Jan 2021 16:09:16 +0100
Subject: [PATCH 098/139] \PhpOffice\Common\Text ->
\PhpOffice\PhpWord\Shared\Text
---
src/PhpWord/Element/Bookmark.php | 4 +-
src/PhpWord/Element/CheckBox.php | 4 +-
src/PhpWord/Element/Link.php | 6 +-
src/PhpWord/Element/ListItem.php | 4 +-
src/PhpWord/Element/PreserveText.php | 4 +-
src/PhpWord/Element/Text.php | 4 +-
src/PhpWord/Element/Title.php | 4 +-
src/PhpWord/Shared/Text.php | 235 ++++++++++++++++++
src/PhpWord/Style/AbstractStyle.php | 2 +-
src/PhpWord/Style/Paragraph.php | 2 +-
src/PhpWord/TemplateProcessor.php | 2 +-
.../Writer/RTF/Element/AbstractElement.php | 4 +-
.../Word2007/Element/AbstractElement.php | 4 +-
tests/PhpWord/Shared/TextTest.php | 88 +++++++
14 files changed, 345 insertions(+), 22 deletions(-)
create mode 100644 src/PhpWord/Shared/Text.php
create mode 100644 tests/PhpWord/Shared/TextTest.php
diff --git a/src/PhpWord/Element/Bookmark.php b/src/PhpWord/Element/Bookmark.php
index 16b020d7..856f6860 100644
--- a/src/PhpWord/Element/Bookmark.php
+++ b/src/PhpWord/Element/Bookmark.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\Common\Text as CommonText;
+use PhpOffice\PhpWord\Shared\Text as SharedText;
/**
* Bookmark element
@@ -45,7 +45,7 @@ class Bookmark extends AbstractElement
*/
public function __construct($name = '')
{
- $this->name = CommonText::toUTF8($name);
+ $this->name = SharedText::toUTF8($name);
}
/**
diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php
index f3e87176..beabf8a0 100644
--- a/src/PhpWord/Element/CheckBox.php
+++ b/src/PhpWord/Element/CheckBox.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\Common\Text as CommonText;
+use PhpOffice\PhpWord\Shared\Text as SharedText;
/**
* Check box element
@@ -55,7 +55,7 @@ class CheckBox extends Text
*/
public function setName($name)
{
- $this->name = CommonText::toUTF8($name);
+ $this->name = SharedText::toUTF8($name);
return $this;
}
diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php
index 2bec32dd..25a87fee 100644
--- a/src/PhpWord/Element/Link.php
+++ b/src/PhpWord/Element/Link.php
@@ -17,7 +17,7 @@
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\Paragraph;
@@ -79,8 +79,8 @@ class Link extends AbstractElement
*/
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
{
- $this->source = CommonText::toUTF8($source);
- $this->text = is_null($text) ? $this->source : CommonText::toUTF8($text);
+ $this->source = SharedText::toUTF8($source);
+ $this->text = is_null($text) ? $this->source : SharedText::toUTF8($text);
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
$this->internal = $internal;
diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php
index 8b064c47..40381de0 100644
--- a/src/PhpWord/Element/ListItem.php
+++ b/src/PhpWord/Element/ListItem.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\Common\Text as CommonText;
+use PhpOffice\PhpWord\Shared\Text as SharedText;
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)
{
- $this->textObject = new Text(CommonText::toUTF8($text), $fontStyle, $paragraphStyle);
+ $this->textObject = new Text(SharedText::toUTF8($text), $fontStyle, $paragraphStyle);
$this->depth = $depth;
// Version >= 0.10.0 will pass numbering style name. Older version will use old method
diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php
index 374f1a99..c0e64268 100644
--- a/src/PhpWord/Element/PreserveText.php
+++ b/src/PhpWord/Element/PreserveText.php
@@ -17,7 +17,7 @@
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\Paragraph;
@@ -59,7 +59,7 @@ class PreserveText extends AbstractElement
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
$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);
if (isset($matches[0])) {
$this->text = $matches;
diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php
index f4d7f081..1ad497b0 100644
--- a/src/PhpWord/Element/Text.php
+++ b/src/PhpWord/Element/Text.php
@@ -17,7 +17,7 @@
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\Paragraph;
@@ -136,7 +136,7 @@ class Text extends AbstractElement
*/
public function setText($text)
{
- $this->text = CommonText::toUTF8($text);
+ $this->text = SharedText::toUTF8($text);
return $this;
}
diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php
index d01f7f33..f061b3d5 100644
--- a/src/PhpWord/Element/Title.php
+++ b/src/PhpWord/Element/Title.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\Common\Text as CommonText;
+use PhpOffice\PhpWord\Shared\Text as SharedText;
use PhpOffice\PhpWord\Style;
/**
@@ -62,7 +62,7 @@ class Title extends AbstractElement
public function __construct($text, $depth = 1)
{
if (is_string($text)) {
- $this->text = CommonText::toUTF8($text);
+ $this->text = SharedText::toUTF8($text);
} elseif ($text instanceof TextRun) {
$this->text = $text;
} else {
diff --git a/src/PhpWord/Shared/Text.php b/src/PhpWord/Shared/Text.php
new file mode 100644
index 00000000..b9bea3ad
--- /dev/null
+++ b/src/PhpWord/Shared/Text.php
@@ -0,0 +1,235 @@
+)
+ * element or in the shared string 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 integer $decimals
+ * @return string
+ */
+ public static function numberFormat($number, $decimals)
+ {
+ return number_format($number, $decimals, '.', '');
+ }
+
+ /**
+ * @param int $dec
+ * @link 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 boolean
+ */
+ 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
+ * @link 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
+ * @link 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;
+ }
+}
diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php
index 8edbe80b..aca6635f 100644
--- a/src/PhpWord/Style/AbstractStyle.php
+++ b/src/PhpWord/Style/AbstractStyle.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Style;
-use PhpOffice\Common\Text;
+use PhpOffice\PhpWord\Shared\Text;
/**
* Abstract style class
diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php
index 580ef54a..522dea9b 100644
--- a/src/PhpWord/Style/Paragraph.php
+++ b/src/PhpWord/Style/Paragraph.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Style;
-use PhpOffice\Common\Text;
use PhpOffice\PhpWord\Exception\InvalidStyleException;
+use PhpOffice\PhpWord\Shared\Text;
use PhpOffice\PhpWord\SimpleType\Jc;
use PhpOffice\PhpWord\SimpleType\TextAlignment;
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 08d328b1..7806530b 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -17,13 +17,13 @@
namespace PhpOffice\PhpWord;
-use PhpOffice\Common\Text;
use PhpOffice\Common\XMLWriter;
use PhpOffice\PhpWord\Escaper\RegExp;
use PhpOffice\PhpWord\Escaper\Xml;
use PhpOffice\PhpWord\Exception\CopyFileException;
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
use PhpOffice\PhpWord\Exception\Exception;
+use PhpOffice\PhpWord\Shared\Text;
use PhpOffice\PhpWord\Shared\ZipArchive;
class TemplateProcessor
diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php
index 132890e6..fa1058bd 100644
--- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php
@@ -17,10 +17,10 @@
namespace PhpOffice\PhpWord\Writer\RTF\Element;
-use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Element\AbstractElement as Element;
use PhpOffice\PhpWord\Escaper\Rtf;
use PhpOffice\PhpWord\Settings;
+use PhpOffice\PhpWord\Shared\Text as SharedText;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Font as FontStyle;
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
@@ -126,7 +126,7 @@ abstract class AbstractElement extends HTMLAbstractElement
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.
}
/**
diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
index 63f45a76..6f83df67 100644
--- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
@@ -17,10 +17,10 @@
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\Settings;
+use PhpOffice\PhpWord\Shared\Text as SharedText;
/**
* Abstract element writer
@@ -207,7 +207,7 @@ abstract class AbstractElement
*/
protected function getText($text)
{
- return CommonText::controlCharacterPHP2OOXML($text);
+ return SharedText::controlCharacterPHP2OOXML($text);
}
/**
diff --git a/tests/PhpWord/Shared/TextTest.php b/tests/PhpWord/Shared/TextTest.php
new file mode 100644
index 00000000..ded00e96
--- /dev/null
+++ b/tests/PhpWord/Shared/TextTest.php
@@ -0,0 +1,88 @@
+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'));
+ }
+}
From b656720619768c5a423b7e26a1c0423b74c6ef4d Mon Sep 17 00:00:00 2001
From: Libor M
Date: Fri, 1 Jan 2021 16:15:24 +0100
Subject: [PATCH 099/139] \PhpOffice\Common\Drawing ->
\PhpOffice\PhpWord\Shared\Drawing
---
src/PhpWord/Reader/MsDoc.php | 2 +-
src/PhpWord/Shared/Drawing.php | 238 +++++++++++++++++++++++++++
tests/PhpWord/Shared/DrawingTest.php | 124 ++++++++++++++
3 files changed, 363 insertions(+), 1 deletion(-)
create mode 100644 src/PhpWord/Shared/Drawing.php
create mode 100644 tests/PhpWord/Shared/DrawingTest.php
diff --git a/src/PhpWord/Reader/MsDoc.php b/src/PhpWord/Reader/MsDoc.php
index eb64e00a..b4c194ca 100644
--- a/src/PhpWord/Reader/MsDoc.php
+++ b/src/PhpWord/Reader/MsDoc.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Reader;
-use PhpOffice\Common\Drawing;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\Drawing;
use PhpOffice\PhpWord\Shared\OLERead;
use PhpOffice\PhpWord\Style;
diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php
new file mode 100644
index 00000000..25110582
--- /dev/null
+++ b/src/PhpWord/Shared/Drawing.php
@@ -0,0 +1,238 @@
+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'));
+ }
+}
From 9a26ad9189f9cf29aad5e429f62fdff81aa1dd30 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Fri, 1 Jan 2021 16:23:58 +0100
Subject: [PATCH 100/139] \PhpOffice\Common\Microsoft\PasswordEncoder ->
\PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder
---
src/PhpWord/Metadata/Protection.php | 2 +-
.../Shared/Microsoft/PasswordEncoder.php | 235 ++++++++++++++++++
src/PhpWord/Writer/Word2007/Part/Settings.php | 2 +-
.../Shared/Microsoft/PasswordEncoderTest.php | 88 +++++++
4 files changed, 325 insertions(+), 2 deletions(-)
create mode 100644 src/PhpWord/Shared/Microsoft/PasswordEncoder.php
create mode 100644 tests/PhpWord/Shared/Microsoft/PasswordEncoderTest.php
diff --git a/src/PhpWord/Metadata/Protection.php b/src/PhpWord/Metadata/Protection.php
index 15aa3ff1..a46d43b9 100644
--- a/src/PhpWord/Metadata/Protection.php
+++ b/src/PhpWord/Metadata/Protection.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Metadata;
-use PhpOffice\Common\Microsoft\PasswordEncoder;
+use PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder;
use PhpOffice\PhpWord\SimpleType\DocProtect;
/**
diff --git a/src/PhpWord/Shared/Microsoft/PasswordEncoder.php b/src/PhpWord/Shared/Microsoft/PasswordEncoder.php
new file mode 100644
index 00000000..fc0c7ecd
--- /dev/null
+++ b/src/PhpWord/Shared/Microsoft/PasswordEncoder.php
@@ -0,0 +1,235 @@
+ 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;
+ }
+}
diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php
index b764642a..42d3a5d5 100644
--- a/src/PhpWord/Writer/Word2007/Part/Settings.php
+++ b/src/PhpWord/Writer/Word2007/Part/Settings.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\Microsoft\PasswordEncoder;
use PhpOffice\PhpWord\ComplexType\ProofState;
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
+use PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder;
use PhpOffice\PhpWord\Style\Language;
/**
diff --git a/tests/PhpWord/Shared/Microsoft/PasswordEncoderTest.php b/tests/PhpWord/Shared/Microsoft/PasswordEncoderTest.php
new file mode 100644
index 00000000..47fb5481
--- /dev/null
+++ b/tests/PhpWord/Shared/Microsoft/PasswordEncoderTest.php
@@ -0,0 +1,88 @@
+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);
+ }
+}
From 0cca050bcd21f161062410f4f7fca0faa072755f Mon Sep 17 00:00:00 2001
From: Libor M
Date: Fri, 1 Jan 2021 16:33:27 +0100
Subject: [PATCH 101/139] \PhpOffice\Common\XMLReader ->
\PhpOffice\PhpWord\Shared\XMLReader
---
src/PhpWord/Reader/ODText.php | 2 +-
src/PhpWord/Reader/ODText/Content.php | 2 +-
src/PhpWord/Reader/ODText/Meta.php | 2 +-
src/PhpWord/Reader/Word2007.php | 2 +-
src/PhpWord/Reader/Word2007/AbstractPart.php | 22 +-
src/PhpWord/Reader/Word2007/DocPropsCore.php | 2 +-
.../Reader/Word2007/DocPropsCustom.php | 2 +-
src/PhpWord/Reader/Word2007/Document.php | 8 +-
src/PhpWord/Reader/Word2007/Footnotes.php | 2 +-
src/PhpWord/Reader/Word2007/Numbering.php | 4 +-
src/PhpWord/Reader/Word2007/Settings.php | 2 +-
src/PhpWord/Reader/Word2007/Styles.php | 2 +-
src/PhpWord/Shared/XMLReader.php | 211 ++++++++++++++++++
tests/PhpWord/Shared/XMLReaderTest.php | 134 +++++++++++
tests/PhpWord/_files/xml/reader.zip | Bin 0 -> 272 bytes
15 files changed, 371 insertions(+), 26 deletions(-)
create mode 100644 src/PhpWord/Shared/XMLReader.php
create mode 100644 tests/PhpWord/Shared/XMLReaderTest.php
create mode 100644 tests/PhpWord/_files/xml/reader.zip
diff --git a/src/PhpWord/Reader/ODText.php b/src/PhpWord/Reader/ODText.php
index 0b58dc50..d0aa9138 100644
--- a/src/PhpWord/Reader/ODText.php
+++ b/src/PhpWord/Reader/ODText.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Reader;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Reader for ODText
diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php
index 9dfd6453..cec06418 100644
--- a/src/PhpWord/Reader/ODText/Content.php
+++ b/src/PhpWord/Reader/ODText/Content.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Reader\ODText;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Content reader
diff --git a/src/PhpWord/Reader/ODText/Meta.php b/src/PhpWord/Reader/ODText/Meta.php
index 8801a543..9a3d8341 100644
--- a/src/PhpWord/Reader/ODText/Meta.php
+++ b/src/PhpWord/Reader/ODText/Meta.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Reader\ODText;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Meta reader
diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php
index 52030ef8..699a4ead 100644
--- a/src/PhpWord/Reader/Word2007.php
+++ b/src/PhpWord/Reader/Word2007.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Reader;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
use PhpOffice\PhpWord\Shared\ZipArchive;
/**
diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php
index eab659fa..083161d0 100644
--- a/src/PhpWord/Reader/Word2007/AbstractPart.php
+++ b/src/PhpWord/Reader/Word2007/AbstractPart.php
@@ -17,12 +17,12 @@
namespace PhpOffice\PhpWord\Reader\Word2007;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\ComplexType\TblWidth as TblWidthComplexType;
use PhpOffice\PhpWord\Element\AbstractContainer;
use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Abstract part reader
@@ -95,7 +95,7 @@ abstract class AbstractPart
/**
* Read w:p.
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
* @param string $docPart
@@ -202,7 +202,7 @@ abstract class AbstractPart
/**
* Read w:r.
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
* @param string $docPart
@@ -320,7 +320,7 @@ abstract class AbstractPart
/**
* Read w:tbl.
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @param mixed $parent
* @param string $docPart
@@ -378,7 +378,7 @@ abstract class AbstractPart
/**
* Read w:pPr.
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array|null
*/
@@ -413,7 +413,7 @@ abstract class AbstractPart
/**
* Read w:rPr
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array|null
*/
@@ -459,7 +459,7 @@ abstract class AbstractPart
/**
* Read w:tblPr
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return string|array|null
* @todo Capture w:tblStylePr w:type="firstRow"
@@ -509,7 +509,7 @@ abstract class AbstractPart
/**
* Read w:tblpPr
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array
*/
@@ -534,7 +534,7 @@ abstract class AbstractPart
/**
* Read w:tblInd
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return TblWidthComplexType
*/
@@ -552,7 +552,7 @@ abstract class AbstractPart
/**
* Read w:tcPr
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array
*/
@@ -620,7 +620,7 @@ abstract class AbstractPart
/**
* Read style definition
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $parentNode
* @param array $styleDefs
* @ignoreScrutinizerPatch
diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php
index 36eecebe..d241df18 100644
--- a/src/PhpWord/Reader/Word2007/DocPropsCore.php
+++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Reader\Word2007;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Core properties reader
diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php
index a6835aac..feb41006 100644
--- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php
+++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Reader\Word2007;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\Metadata\DocInfo;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Custom properties reader
diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php
index f0d1194a..13a92e47 100644
--- a/src/PhpWord/Reader/Word2007/Document.php
+++ b/src/PhpWord/Reader/Word2007/Document.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Reader\Word2007;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Document reader
@@ -97,7 +97,7 @@ class Document extends AbstractPart
/**
* Read w:sectPr
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @ignoreScrutinizerPatch
* @return array
@@ -141,7 +141,7 @@ class Document extends AbstractPart
/**
* Read w:p node.
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section
*
@@ -170,7 +170,7 @@ class Document extends AbstractPart
/**
* Read w:sectPr node.
*
- * @param \PhpOffice\Common\XMLReader $xmlReader
+ * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section
*/
diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php
index 634f4739..a8829d0b 100644
--- a/src/PhpWord/Reader/Word2007/Footnotes.php
+++ b/src/PhpWord/Reader/Word2007/Footnotes.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Reader\Word2007;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Footnotes reader
diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php
index 3f57cbf8..dea8f3ee 100644
--- a/src/PhpWord/Reader/Word2007/Numbering.php
+++ b/src/PhpWord/Reader/Word2007/Numbering.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Reader\Word2007;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Numbering reader
@@ -89,7 +89,7 @@ class Numbering extends AbstractPart
/**
* 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 int $levelId
* @return array
diff --git a/src/PhpWord/Reader/Word2007/Settings.php b/src/PhpWord/Reader/Word2007/Settings.php
index 3084943b..0a59e045 100644
--- a/src/PhpWord/Reader/Word2007/Settings.php
+++ b/src/PhpWord/Reader/Word2007/Settings.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Reader\Word2007;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
use PhpOffice\PhpWord\Style\Language;
/**
diff --git a/src/PhpWord/Reader/Word2007/Styles.php b/src/PhpWord/Reader/Word2007/Styles.php
index 97f29b43..37ce4909 100644
--- a/src/PhpWord/Reader/Word2007/Styles.php
+++ b/src/PhpWord/Reader/Word2007/Styles.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Reader\Word2007;
-use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLReader;
use PhpOffice\PhpWord\Style\Language;
/**
diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php
new file mode 100644
index 00000000..77013f6c
--- /dev/null
+++ b/src/PhpWord/Shared/XMLReader.php
@@ -0,0 +1,211 @@
+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)
+ {
+ $originalLibXMLEntityValue = libxml_disable_entity_loader(true);
+ $this->dom = new \DOMDocument();
+ $this->dom->loadXML($content);
+ 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
+ * @return bool true on success or false on failure
+ * @throws \InvalidArgumentException If called before having loaded the DOM document
+ */
+ 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 integer
+ */
+ public function countElements($path, \DOMElement $contextNode = null)
+ {
+ $elements = $this->getElements($path, $contextNode);
+
+ return $elements->length;
+ }
+
+ /**
+ * Element exists
+ *
+ * @param string $path
+ * @param \DOMElement $contextNode
+ * @return boolean
+ */
+ public function elementExists($path, \DOMElement $contextNode = null)
+ {
+ return $this->getElements($path, $contextNode)->length > 0;
+ }
+}
diff --git a/tests/PhpWord/Shared/XMLReaderTest.php b/tests/PhpWord/Shared/XMLReaderTest.php
new file mode 100644
index 00000000..a34d650a
--- /dev/null
+++ b/tests/PhpWord/Shared/XMLReaderTest.php
@@ -0,0 +1,134 @@
+getDomFromString('AAA');
+
+ $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('AAABBB');
+
+ $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('AAA');
+
+ $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('AAA');
+
+ $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('AAA');
+ $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');
+ }
+}
diff --git a/tests/PhpWord/_files/xml/reader.zip b/tests/PhpWord/_files/xml/reader.zip
new file mode 100644
index 0000000000000000000000000000000000000000..dbe69cbbc03f9ab229f52b6ccdce012abfa8fae5
GIT binary patch
literal 272
zcmWIWW@Zs#U|`^2*i|{f`-6HZV-}Ft1{RTFC`m0Y(W}VK2@T<7U{=sFjZy^S(h6<{
zMwYLP3=CkMu4f#%nhgXTE|zldb)K>J*1H%Vo|C>!GjBP}X^?cyU!S13`+Rhb$?rK=
z+`Kzyn%3Mh*LY;ueqwT4=ssWmRUOYC1gBjp2w*hcGtZ+lEh#WA<)T6ei(cJ>AKjWf
z*P`CMTk~Sh>W;hr3%+s&cr!A|G2?Qr1klY43_w>gENKL>5N>CMxE;;i0p6@^Aa#sD
L=m(_NfH({Qga}Y@
literal 0
HcmV?d00001
From 357e905e8b897b0b5b521a8de50a97093106d5e3 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Fri, 1 Jan 2021 16:52:15 +0100
Subject: [PATCH 102/139] fix PasswordEncoder namespace
---
tests/PhpWord/Writer/Word2007/Part/SettingsTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/PhpWord/Writer/Word2007/Part/SettingsTest.php b/tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
index fcf5cabc..d3c1c1dd 100644
--- a/tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
@@ -17,10 +17,10 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\Microsoft\PasswordEncoder;
use PhpOffice\PhpWord\ComplexType\ProofState;
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder;
use PhpOffice\PhpWord\SimpleType\Zoom;
use PhpOffice\PhpWord\Style\Language;
use PhpOffice\PhpWord\TestHelperDOCX;
From a2c8d8c2d50a5ac35f6fa792b833f7f4e01f7267 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 2 Jan 2021 08:26:46 +0100
Subject: [PATCH 103/139] \PhpOffice\Common\XMLWriter ->
\PhpOffice\PhpWord\Shared\XMLWriter
---
src/PhpWord/Shared/XMLWriter.php | 184 ++++++++++++++++++
src/PhpWord/TemplateProcessor.php | 2 +-
src/PhpWord/Writer/ODText/Element/Table.php | 6 +-
.../Writer/ODText/Part/AbstractPart.php | 6 +-
src/PhpWord/Writer/ODText/Part/Content.php | 6 +-
src/PhpWord/Writer/ODText/Part/Meta.php | 4 +-
src/PhpWord/Writer/ODText/Part/Styles.php | 12 +-
.../Word2007/Element/AbstractElement.php | 8 +-
.../Writer/Word2007/Element/Container.php | 4 +-
.../Writer/Word2007/Element/FormField.php | 8 +-
src/PhpWord/Writer/Word2007/Element/Image.php | 2 +-
src/PhpWord/Writer/Word2007/Element/SDT.php | 10 +-
src/PhpWord/Writer/Word2007/Element/Shape.php | 12 +-
src/PhpWord/Writer/Word2007/Element/TOC.php | 8 +-
src/PhpWord/Writer/Word2007/Element/Table.php | 8 +-
.../Writer/Word2007/Part/AbstractPart.php | 4 +-
src/PhpWord/Writer/Word2007/Part/Chart.php | 14 +-
src/PhpWord/Writer/Word2007/Part/Comments.php | 4 +-
.../Writer/Word2007/Part/ContentTypes.php | 4 +-
src/PhpWord/Writer/Word2007/Part/Document.php | 6 +-
.../Writer/Word2007/Part/Footnotes.php | 4 +-
.../Writer/Word2007/Part/Numbering.php | 8 +-
src/PhpWord/Writer/Word2007/Part/Rels.php | 8 +-
src/PhpWord/Writer/Word2007/Part/Settings.php | 2 +-
src/PhpWord/Writer/Word2007/Part/Styles.php | 10 +-
.../Writer/Word2007/Style/AbstractStyle.php | 10 +-
src/PhpWord/Writer/Word2007/Style/Frame.php | 4 +-
.../Writer/Word2007/Style/MarginBorder.php | 4 +-
.../Writer/Word2007/Style/Paragraph.php | 6 +-
src/PhpWord/Writer/Word2007/Style/Table.php | 16 +-
tests/PhpWord/Shared/XMLWriterTest.php | 74 +++++++
tests/PhpWord/Writer/ODText/ElementTest.php | 2 +-
tests/PhpWord/Writer/ODText/StyleTest.php | 2 +-
tests/PhpWord/Writer/Word2007/ElementTest.php | 2 +-
tests/PhpWord/Writer/Word2007/StyleTest.php | 2 +-
35 files changed, 362 insertions(+), 104 deletions(-)
create mode 100644 src/PhpWord/Shared/XMLWriter.php
create mode 100644 tests/PhpWord/Shared/XMLWriterTest.php
diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php
new file mode 100644
index 00000000..1d825dec
--- /dev/null
+++ b/src/PhpWord/Shared/XMLWriter.php
@@ -0,0 +1,184 @@
+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
+ * @return void
+ */
+ 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
+ * @return void
+ */
+ 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
+ * @return void
+ */
+ 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);
+ }
+}
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 7806530b..103e1556 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Escaper\RegExp;
use PhpOffice\PhpWord\Escaper\Xml;
use PhpOffice\PhpWord\Exception\CopyFileException;
diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php
index 088330ae..19f5ac96 100644
--- a/src/PhpWord/Writer/ODText/Element/Table.php
+++ b/src/PhpWord/Writer/ODText/Element/Table.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\ODText\Element;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Row as RowElement;
use PhpOffice\PhpWord\Element\Table as TableElement;
@@ -60,7 +60,7 @@ class Table extends AbstractElement
/**
* Write column.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Table $element
*/
private function writeColumns(XMLWriter $xmlWriter, TableElement $element)
@@ -77,7 +77,7 @@ class Table extends AbstractElement
/**
* Write row.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Row $row
*/
private function writeRow(XMLWriter $xmlWriter, RowElement $row)
diff --git a/src/PhpWord/Writer/ODText/Part/AbstractPart.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php
index f2844de6..67b7a7ae 100644
--- a/src/PhpWord/Writer/ODText/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Font;
@@ -36,7 +36,7 @@ abstract class AbstractPart extends Word2007AbstractPart
/**
* Write common root attributes.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
protected function writeCommonRootAttributes(XMLWriter $xmlWriter)
{
@@ -72,7 +72,7 @@ abstract class AbstractPart extends Word2007AbstractPart
/**
* Write font faces declaration.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
protected function writeFontFaces(XMLWriter $xmlWriter)
{
diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php
index f0e60441..4a84896d 100644
--- a/src/PhpWord/Writer/ODText/Part/Content.php
+++ b/src/PhpWord/Writer/ODText/Part/Content.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\AbstractContainer;
use PhpOffice\PhpWord\Element\Field;
use PhpOffice\PhpWord\Element\Image;
@@ -151,7 +151,7 @@ class Content extends AbstractPart
*
* @since 0.11.0
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function writeAutoStyles(XMLWriter $xmlWriter)
{
@@ -173,7 +173,7 @@ class Content extends AbstractPart
/**
* Write automatic styles.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function writeTextStyles(XMLWriter $xmlWriter)
{
diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php
index f38ad01d..8f3f1fb9 100644
--- a/src/PhpWord/Writer/ODText/Part/Meta.php
+++ b/src/PhpWord/Writer/ODText/Part/Meta.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* ODText meta part writer: meta.xml
@@ -86,7 +86,7 @@ class Meta extends AbstractPart
/**
* Write individual property
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $property
* @param string $value
*
diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php
index bcd57ad5..c026e7bb 100644
--- a/src/PhpWord/Writer/ODText/Part/Styles.php
+++ b/src/PhpWord/Writer/ODText/Part/Styles.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\Converter;
use PhpOffice\PhpWord\Style;
@@ -66,7 +66,7 @@ class Styles extends AbstractPart
/**
* Write default styles.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function writeDefault(XMLWriter $xmlWriter)
{
@@ -118,7 +118,7 @@ class Styles extends AbstractPart
/**
* Write named styles.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\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
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function writePageLayout(XMLWriter $xmlWriter)
{
@@ -169,7 +169,7 @@ class Styles extends AbstractPart
/**
* Write page layout styles.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Section $section
* @param int $sectionNbr
*/
@@ -255,7 +255,7 @@ class Styles extends AbstractPart
/**
* Write master style.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function writeMaster(XMLWriter $xmlWriter)
{
diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
index 6f83df67..d4ec0f7d 100644
--- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\AbstractElement as Element;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\Text as SharedText;
@@ -32,7 +32,7 @@ abstract class AbstractElement
/**
* XML writer
*
- * @var \PhpOffice\Common\XMLWriter
+ * @var \PhpOffice\PhpWord\Shared\XMLWriter
*/
private $xmlWriter;
@@ -58,7 +58,7 @@ abstract class AbstractElement
/**
* Create new instance
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
* @param bool $withoutP
*/
@@ -72,7 +72,7 @@ abstract class AbstractElement
/**
* Get XML Writer
*
- * @return \PhpOffice\Common\XMLWriter
+ * @return \PhpOffice\PhpWord\Shared\XMLWriter
*/
protected function getXmlWriter()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php
index 892da051..8a6aa805 100644
--- a/src/PhpWord/Writer/Word2007/Element/Container.php
+++ b/src/PhpWord/Writer/Word2007/Element/Container.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement;
use PhpOffice\PhpWord\Element\AbstractElement as Element;
use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement;
@@ -71,7 +71,7 @@ class Container extends AbstractElement
/**
* Write individual element
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
* @param bool $withoutP
* @return string
diff --git a/src/PhpWord/Writer/Word2007/Element/FormField.php b/src/PhpWord/Writer/Word2007/Element/FormField.php
index b59cf58f..e1754d0f 100644
--- a/src/PhpWord/Writer/Word2007/Element/FormField.php
+++ b/src/PhpWord/Writer/Word2007/Element/FormField.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\FormField as FormFieldElement;
/**
@@ -105,7 +105,7 @@ class FormField extends Text
* Write textinput.
*
* @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
*/
private function writeTextInput(XMLWriter $xmlWriter, FormFieldElement $element)
@@ -121,7 +121,7 @@ class FormField extends Text
* Write checkbox.
*
* @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
*/
private function writeCheckBox(XMLWriter $xmlWriter, FormFieldElement $element)
@@ -144,7 +144,7 @@ class FormField extends Text
* Write dropdown.
*
* @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
*/
private function writeDropDown(XMLWriter $xmlWriter, FormFieldElement $element)
diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php
index 5bebb89c..8fc4849d 100644
--- a/src/PhpWord/Writer/Word2007/Element/Image.php
+++ b/src/PhpWord/Writer/Word2007/Element/Image.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Image as ImageElement;
use PhpOffice\PhpWord\Style\Font as FontStyle;
use PhpOffice\PhpWord\Style\Frame as FrameStyle;
diff --git a/src/PhpWord/Writer/Word2007/Element/SDT.php b/src/PhpWord/Writer/Word2007/Element/SDT.php
index edf89b53..e2d0d368 100644
--- a/src/PhpWord/Writer/Word2007/Element/SDT.php
+++ b/src/PhpWord/Writer/Word2007/Element/SDT.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\SDT as SDTElement;
/**
@@ -77,7 +77,7 @@ class SDT extends Text
* Write text.
*
* @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)
{
@@ -89,7 +89,7 @@ class SDT extends Text
* Write combo box.
*
* @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
*/
private function writeComboBox(XMLWriter $xmlWriter, SDTElement $element)
@@ -108,7 +108,7 @@ class SDT extends Text
* Write drop down list.
*
* @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
*/
private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element)
@@ -120,7 +120,7 @@ class SDT extends Text
* Write date.
*
* @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
*/
private function writeDate(XMLWriter $xmlWriter, SDTElement $element)
diff --git a/src/PhpWord/Writer/Word2007/Element/Shape.php b/src/PhpWord/Writer/Word2007/Element/Shape.php
index 250d5c1d..445be7e4 100644
--- a/src/PhpWord/Writer/Word2007/Element/Shape.php
+++ b/src/PhpWord/Writer/Word2007/Element/Shape.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Shape as ShapeElement;
use PhpOffice\PhpWord\Style\Shape as ShapeStyle;
use PhpOffice\PhpWord\Writer\Word2007\Style\Shape as ShapeStyleWriter;
@@ -77,7 +77,7 @@ class Shape extends AbstractElement
/**
* Write arc.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
*/
private function writeArc(XMLWriter $xmlWriter, ShapeStyle $style)
@@ -91,7 +91,7 @@ class Shape extends AbstractElement
/**
* Write curve.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
*/
private function writeCurve(XMLWriter $xmlWriter, ShapeStyle $style)
@@ -106,7 +106,7 @@ class Shape extends AbstractElement
/**
* Write line.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
*/
private function writeLine(XMLWriter $xmlWriter, ShapeStyle $style)
@@ -120,7 +120,7 @@ class Shape extends AbstractElement
/**
* Write polyline.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
*/
private function writePolyline(XMLWriter $xmlWriter, ShapeStyle $style)
@@ -131,7 +131,7 @@ class Shape extends AbstractElement
/**
* Write rectangle.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
*/
private function writeRoundRect(XMLWriter $xmlWriter, ShapeStyle $style)
diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php
index 94437cbf..78989f81 100644
--- a/src/PhpWord/Writer/Word2007/Element/TOC.php
+++ b/src/PhpWord/Writer/Word2007/Element/TOC.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\TOC as TOCElement;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;
@@ -64,7 +64,7 @@ class TOC extends AbstractElement
/**
* Write title
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\TOC $element
* @param \PhpOffice\PhpWord\Element\Title $title
* @param bool $writeFieldMark
@@ -132,7 +132,7 @@ class TOC extends AbstractElement
/**
* Write style
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\TOC $element
* @param int $indent
*/
@@ -178,7 +178,7 @@ class TOC extends AbstractElement
/**
* Write TOC Field.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\TOC $element
*/
private function writeFieldMark(XMLWriter $xmlWriter, TOCElement $element)
diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php
index c365b028..4067868d 100644
--- a/src/PhpWord/Writer/Word2007/Element/Table.php
+++ b/src/PhpWord/Writer/Word2007/Element/Table.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Cell as CellElement;
use PhpOffice\PhpWord\Element\Row as RowElement;
use PhpOffice\PhpWord\Element\Table as TableElement;
@@ -71,7 +71,7 @@ class Table extends AbstractElement
/**
* Write column.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Table $element
*/
private function writeColumns(XMLWriter $xmlWriter, TableElement $element)
@@ -93,7 +93,7 @@ class Table extends AbstractElement
/**
* Write row.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Row $row
*/
private function writeRow(XMLWriter $xmlWriter, RowElement $row)
@@ -119,7 +119,7 @@ class Table extends AbstractElement
/**
* Write cell.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Cell $cell
*/
private function writeCell(XMLWriter $xmlWriter, CellElement $cell)
diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
index ce4e41cb..e14b394e 100644
--- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Writer\AbstractWriter;
@@ -73,7 +73,7 @@ abstract class AbstractPart
/**
* Get XML Writer
*
- * @return \PhpOffice\Common\XMLWriter
+ * @return \PhpOffice\PhpWord\Shared\XMLWriter
*/
protected function getXmlWriter()
{
diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php
index 812d3bf1..e413d273 100644
--- a/src/PhpWord/Writer/Word2007/Part/Chart.php
+++ b/src/PhpWord/Writer/Word2007/Part/Chart.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Chart as ChartElement;
/**
@@ -99,7 +99,7 @@ class Chart extends AbstractPart
* Write chart
*
* @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)
{
@@ -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_RadarChart.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)
{
@@ -209,7 +209,7 @@ class Chart extends AbstractPart
/**
* Write series.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param bool $scatter
*/
private function writeSeries(XMLWriter $xmlWriter, $scatter = false)
@@ -294,7 +294,7 @@ class Chart extends AbstractPart
/**
* Write series items.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $type
* @param array $values
*/
@@ -335,7 +335,7 @@ class Chart extends AbstractPart
* Write axis
*
* @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
*/
private function writeAxis(XMLWriter $xmlWriter, $type)
@@ -400,7 +400,7 @@ class Chart extends AbstractPart
* Write shape
*
* @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
*/
private function writeShape(XMLWriter $xmlWriter, $line = false)
diff --git a/src/PhpWord/Writer/Word2007/Part/Comments.php b/src/PhpWord/Writer/Word2007/Part/Comments.php
index 33c9f59e..6bff63ee 100644
--- a/src/PhpWord/Writer/Word2007/Part/Comments.php
+++ b/src/PhpWord/Writer/Word2007/Part/Comments.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Comment;
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
@@ -70,7 +70,7 @@ class Comments extends AbstractPart
/**
* Write comment item.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Comment $comment
*/
protected function writeComment(XMLWriter $xmlWriter, Comment $comment)
diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php
index 28a2d294..14fc5853 100644
--- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php
+++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 contenttypes part writer: [Content_Types].xml
@@ -80,7 +80,7 @@ class ContentTypes extends AbstractPart
/**
* Write content types element
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter XML Writer
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer
* @param array $parts
* @param bool $isDefault
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php
index e0cabd7e..09ef13f0 100644
--- a/src/PhpWord/Writer/Word2007/Part/Document.php
+++ b/src/PhpWord/Writer/Word2007/Part/Document.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter;
@@ -80,7 +80,7 @@ class Document extends AbstractPart
/**
* Write begin section.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Section $section
*/
private function writeSection(XMLWriter $xmlWriter, Section $section)
@@ -95,7 +95,7 @@ class Document extends AbstractPart
/**
* Write end section.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Section $section
*/
private function writeSectionSettings(XMLWriter $xmlWriter, Section $section)
diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php
index 59bf1830..34bf737b 100644
--- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php
+++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Footnote;
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
@@ -135,7 +135,7 @@ class Footnotes extends AbstractPart
/**
* Write note item.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Footnote|\PhpOffice\PhpWord\Element\Endnote $element
*/
protected function writeNote(XMLWriter $xmlWriter, $element)
diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php
index 61e5cc23..1b4f01a6 100644
--- a/src/PhpWord/Writer/Word2007/Part/Numbering.php
+++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
use PhpOffice\PhpWord\Style\NumberingLevel;
@@ -97,7 +97,7 @@ class Numbering extends AbstractPart
/**
* Write level.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
*/
private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level)
@@ -137,7 +137,7 @@ class Numbering extends AbstractPart
*
* @since 0.11.0
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
* @todo Use paragraph style writer
*/
@@ -169,7 +169,7 @@ class Numbering extends AbstractPart
*
* @since 0.11.0
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
* @todo Use font style writer
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php
index 661a4fa8..0a3f934e 100644
--- a/src/PhpWord/Writer/Word2007/Part/Rels.php
+++ b/src/PhpWord/Writer/Word2007/Part/Rels.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Exception\Exception;
/**
@@ -49,7 +49,7 @@ class Rels extends AbstractPart
/**
* Write relationships.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param array $xmlRels
* @param array $mediaRels
* @param int $relId
@@ -76,7 +76,7 @@ class Rels extends AbstractPart
/**
* Write media relationships.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param int $relId
* @param array $mediaRel
*/
@@ -101,7 +101,7 @@ class Rels extends AbstractPart
* Format:
*
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param int $relId Relationship ID
* @param string $type Relationship type
* @param string $target Relationship target
diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php
index 42d3a5d5..4dd8b8be 100644
--- a/src/PhpWord/Writer/Word2007/Part/Settings.php
+++ b/src/PhpWord/Writer/Word2007/Part/Settings.php
@@ -69,7 +69,7 @@ class Settings extends AbstractPart
/**
* Write indivual setting, recursive to any child settings.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $settingKey
* @param array|string $settingValue
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php
index d05338c7..4d8f60c2 100644
--- a/src/PhpWord/Writer/Word2007/Part/Styles.php
+++ b/src/PhpWord/Writer/Word2007/Part/Styles.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Font as FontStyle;
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
@@ -76,7 +76,7 @@ class Styles extends AbstractPart
/**
* Write default font and other default styles.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\AbstractStyle[] $styles
*/
private function writeDefaultStyles(XMLWriter $xmlWriter, $styles)
@@ -161,7 +161,7 @@ class Styles extends AbstractPart
/**
* Write font style.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $styleName
* @param \PhpOffice\PhpWord\Style\Font $style
*/
@@ -229,7 +229,7 @@ class Styles extends AbstractPart
/**
* Write paragraph style.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $styleName
* @param \PhpOffice\PhpWord\Style\Paragraph $style
*/
@@ -261,7 +261,7 @@ class Styles extends AbstractPart
/**
* Write table style.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $styleName
* @param \PhpOffice\PhpWord\Style\Table $style
*/
diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php
index 877ff1db..7e17fbe7 100644
--- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php
+++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Settings;
/**
@@ -30,7 +30,7 @@ abstract class AbstractStyle
/**
* XML writer
*
- * @var \PhpOffice\Common\XMLWriter
+ * @var \PhpOffice\PhpWord\Shared\XMLWriter
*/
private $xmlWriter;
@@ -49,7 +49,7 @@ abstract class AbstractStyle
/**
* Create new instance.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string|\PhpOffice\PhpWord\Style\AbstractStyle $style
*/
public function __construct(XMLWriter $xmlWriter, $style = null)
@@ -61,7 +61,7 @@ abstract class AbstractStyle
/**
* Get XML Writer
*
- * @return \PhpOffice\Common\XMLWriter
+ * @return \PhpOffice\PhpWord\Shared\XMLWriter
*/
protected function getXmlWriter()
{
@@ -106,7 +106,7 @@ abstract class AbstractStyle
/**
* Write child style.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $name
* @param mixed $value
*/
diff --git a/src/PhpWord/Writer/Word2007/Style/Frame.php b/src/PhpWord/Writer/Word2007/Style/Frame.php
index 10e5b151..782bce52 100644
--- a/src/PhpWord/Writer/Word2007/Style/Frame.php
+++ b/src/PhpWord/Writer/Word2007/Style/Frame.php
@@ -17,7 +17,7 @@
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\Writer\Word2007\Element\ParagraphAlignment;
@@ -108,7 +108,7 @@ class Frame extends AbstractStyle
/**
* Write wrap.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Frame $style
* @param string $wrap
*/
diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php
index f5c4b015..a9929563 100644
--- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php
+++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Margin border style writer
@@ -78,7 +78,7 @@ class MarginBorder extends AbstractStyle
/**
* Write side.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $side
* @param int $width
* @param string $color
diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php
index 67616086..08987a6a 100644
--- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php
+++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
@@ -146,7 +146,7 @@ class Paragraph extends AbstractStyle
/**
* Write tabs.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Tab[] $tabs
*/
private function writeTabs(XMLWriter $xmlWriter, $tabs)
@@ -164,7 +164,7 @@ class Paragraph extends AbstractStyle
/**
* Write numbering.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param array $numbering
*/
private function writeNumbering(XMLWriter $xmlWriter, $numbering)
diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php
index 443d6705..eb040e01 100644
--- a/src/PhpWord/Writer/Word2007/Style/Table.php
+++ b/src/PhpWord/Writer/Word2007/Style/Table.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\SimpleType\TblWidth;
use PhpOffice\PhpWord\Style\Table as TableStyle;
use PhpOffice\PhpWord\Writer\Word2007\Element\TableAlignment;
@@ -59,7 +59,7 @@ class Table extends AbstractStyle
/**
* Write full style.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
*/
private function writeStyle(XMLWriter $xmlWriter, TableStyle $style)
@@ -106,7 +106,7 @@ class Table extends AbstractStyle
/**
* Enable/Disable automatic resizing of the table
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $layout autofit / fixed
*/
private function writeLayout(XMLWriter $xmlWriter, $layout)
@@ -119,7 +119,7 @@ class Table extends AbstractStyle
/**
* Write margin.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
*/
private function writeMargin(XMLWriter $xmlWriter, TableStyle $style)
@@ -138,7 +138,7 @@ class Table extends AbstractStyle
/**
* Write border.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
*/
private function writeBorder(XMLWriter $xmlWriter, TableStyle $style)
@@ -158,7 +158,7 @@ class Table extends AbstractStyle
/**
* Writes a table width
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $elementName
* @param string $unit
* @param int|float $width
@@ -177,7 +177,7 @@ class Table extends AbstractStyle
/**
* Write row style.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
*/
private function writeFirstRow(XMLWriter $xmlWriter, TableStyle $style)
@@ -196,7 +196,7 @@ class Table extends AbstractStyle
/**
* Write shading.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
*/
private function writeShading(XMLWriter $xmlWriter, TableStyle $style)
diff --git a/tests/PhpWord/Shared/XMLWriterTest.php b/tests/PhpWord/Shared/XMLWriterTest.php
new file mode 100644
index 00000000..e717ba03
--- /dev/null
+++ b/tests/PhpWord/Shared/XMLWriterTest.php
@@ -0,0 +1,74 @@
+startElement('element');
+ $object->text('AAA');
+ $object->endElement();
+ $this->assertEquals('AAA'.chr(10), $object->getData());
+
+ // Disk
+ $object = new XMLWriter(XMLWriter::STORAGE_DISK);
+ $object->startElement('element');
+ $object->text('BBB');
+ $object->endElement();
+ $this->assertEquals('BBB'.chr(10), $object->getData());
+ }
+
+ public function testWriteAttribute()
+ {
+ $xmlWriter = new XMLWriter();
+ $xmlWriter->startElement('element');
+ $xmlWriter->writeAttribute('name', 'value');
+ $xmlWriter->endElement();
+
+ $this->assertSame('' . 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('1,2', (string)$value);
+ $this->assertSame('' . chr(10), $xmlWriter->getData());
+
+ setlocale(LC_NUMERIC, $currentLocale);
+ }
+}
diff --git a/tests/PhpWord/Writer/ODText/ElementTest.php b/tests/PhpWord/Writer/ODText/ElementTest.php
index eda4568d..8b827347 100644
--- a/tests/PhpWord/Writer/ODText/ElementTest.php
+++ b/tests/PhpWord/Writer/ODText/ElementTest.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\ODText;
-use PhpOffice\Common\XMLWriter;
use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\TestHelperDOCX;
/**
diff --git a/tests/PhpWord/Writer/ODText/StyleTest.php b/tests/PhpWord/Writer/ODText/StyleTest.php
index b1bf417d..bf8a3dd1 100644
--- a/tests/PhpWord/Writer/ODText/StyleTest.php
+++ b/tests/PhpWord/Writer/ODText/StyleTest.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\ODText;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Test class for PhpOffice\PhpWord\Writer\ODText\Style subnamespace
diff --git a/tests/PhpWord/Writer/Word2007/ElementTest.php b/tests/PhpWord/Writer/Word2007/ElementTest.php
index e799e022..8193b3db 100644
--- a/tests/PhpWord/Writer/Word2007/ElementTest.php
+++ b/tests/PhpWord/Writer/Word2007/ElementTest.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Comment;
use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\TrackChange;
diff --git a/tests/PhpWord/Writer/Word2007/StyleTest.php b/tests/PhpWord/Writer/Word2007/StyleTest.php
index 48cff871..8bd27980 100644
--- a/tests/PhpWord/Writer/Word2007/StyleTest.php
+++ b/tests/PhpWord/Writer/Word2007/StyleTest.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007;
-use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Test class for PhpOffice\PhpWord\Writer\Word2007\Style subnamespace
From 67b15986a76fb9c938084731105dacd6f087c481 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 2 Jan 2021 08:36:05 +0100
Subject: [PATCH 104/139] remove require phpoffice/common package
---
composer.json | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index 19997215..7fbf900c 100644
--- a/composer.json
+++ b/composer.json
@@ -60,8 +60,7 @@
"require": {
"php": "^5.3.3 || ^7.0 || ^8.0",
"ext-xml": "*",
- "laminas/laminas-escaper": "^2.2",
- "phpoffice/common": "^0.2.9"
+ "laminas/laminas-escaper": "^2.2"
},
"require-dev": {
"ext-zip": "*",
From 681d5c47094462fe7ad2945cecb904cd3d645280 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 2 Jan 2021 09:08:43 +0100
Subject: [PATCH 105/139] fix PHP 8.0 compatibility
---
src/PhpWord/Shared/XMLReader.php | 8 ++++++--
tests/PhpWord/Shared/XMLWriterTest.php | 1 -
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php
index 77013f6c..ca5cb558 100644
--- a/src/PhpWord/Shared/XMLReader.php
+++ b/src/PhpWord/Shared/XMLReader.php
@@ -72,10 +72,14 @@ class XMLReader
*/
public function getDomFromString($content)
{
- $originalLibXMLEntityValue = libxml_disable_entity_loader(true);
+ if (\PHP_VERSION_ID < 80000) {
+ $originalLibXMLEntityValue = libxml_disable_entity_loader(true);
+ }
$this->dom = new \DOMDocument();
$this->dom->loadXML($content);
- libxml_disable_entity_loader($originalLibXMLEntityValue);
+ if (\PHP_VERSION_ID < 80000) {
+ libxml_disable_entity_loader($originalLibXMLEntityValue);
+ }
return $this->dom;
}
diff --git a/tests/PhpWord/Shared/XMLWriterTest.php b/tests/PhpWord/Shared/XMLWriterTest.php
index e717ba03..843ae716 100644
--- a/tests/PhpWord/Shared/XMLWriterTest.php
+++ b/tests/PhpWord/Shared/XMLWriterTest.php
@@ -66,7 +66,6 @@ class XMLWriterTest extends \PHPUnit\Framework\TestCase
setlocale(LC_NUMERIC, 'de_DE.UTF-8', 'de');
- $this->assertSame('1,2', (string)$value);
$this->assertSame('' . chr(10), $xmlWriter->getData());
setlocale(LC_NUMERIC, $currentLocale);
From 7a131d0ae18ab7718e7443cf0f26bee390b81faa Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sat, 2 Jan 2021 09:37:43 +0100
Subject: [PATCH 106/139] allow dompdf/dompdf 1.0 version
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 7fbf900c..64363fe1 100644
--- a/composer.json
+++ b/composer.json
@@ -70,7 +70,7 @@
"friendsofphp/php-cs-fixer": "^2.2",
"phpmd/phpmd": "2.*",
"phploc/phploc": "2.* || 3.* || 4.* || 5.* || 6.* || 7.*",
- "dompdf/dompdf":"0.8.*",
+ "dompdf/dompdf":"0.8.* || 1.0.*",
"tecnickcom/tcpdf": "6.*",
"mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
From ea917c28daa8c8f7f7b06477aae4a1faae537654 Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 10 Jan 2021 14:06:19 +0100
Subject: [PATCH 107/139] fix coverage
---
src/PhpWord/Shared/Drawing.php | 26 ++++++++++++-----
src/PhpWord/Shared/Text.php | 29 ++++++++++---------
src/PhpWord/Shared/XMLReader.php | 9 +++---
src/PhpWord/Shared/XMLWriter.php | 8 ++---
src/PhpWord/TemplateProcessor.php | 2 +-
src/PhpWord/Writer/ODText/Element/Table.php | 2 +-
.../Writer/ODText/Part/AbstractPart.php | 2 +-
src/PhpWord/Writer/ODText/Part/Content.php | 2 +-
src/PhpWord/Writer/ODText/Part/Styles.php | 2 +-
.../Word2007/Element/AbstractElement.php | 2 +-
.../Writer/Word2007/Element/Container.php | 2 +-
.../Writer/Word2007/Element/FormField.php | 2 +-
src/PhpWord/Writer/Word2007/Element/Image.php | 2 +-
src/PhpWord/Writer/Word2007/Element/SDT.php | 2 +-
src/PhpWord/Writer/Word2007/Element/Shape.php | 2 +-
src/PhpWord/Writer/Word2007/Element/TOC.php | 2 +-
src/PhpWord/Writer/Word2007/Element/Table.php | 2 +-
.../Writer/Word2007/Part/AbstractPart.php | 2 +-
src/PhpWord/Writer/Word2007/Part/Chart.php | 2 +-
src/PhpWord/Writer/Word2007/Part/Comments.php | 2 +-
src/PhpWord/Writer/Word2007/Part/Document.php | 2 +-
.../Writer/Word2007/Part/Footnotes.php | 2 +-
src/PhpWord/Writer/Word2007/Part/Rels.php | 2 +-
.../Writer/Word2007/Style/AbstractStyle.php | 2 +-
tests/PhpWord/Shared/DrawingTest.php | 22 ++++----------
tests/PhpWord/Shared/TextTest.php | 7 ++---
tests/PhpWord/Shared/XMLReaderTest.php | 6 ++--
tests/PhpWord/Shared/XMLWriterTest.php | 10 +++----
tests/PhpWord/Writer/Word2007/ElementTest.php | 2 +-
29 files changed, 77 insertions(+), 82 deletions(-)
diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php
index 25110582..531ee245 100644
--- a/src/PhpWord/Shared/Drawing.php
+++ b/src/PhpWord/Shared/Drawing.php
@@ -46,6 +46,7 @@ class Drawing
if ($pValue == 0) {
return 0;
}
+
return round($pValue / 9525);
}
@@ -71,9 +72,10 @@ class Drawing
if ($pValue == 0) {
return 0;
}
- return ((($pValue * 1.333333333) / self::DPI_96) * 2.54);
+
+ return (($pValue * 1.333333333) / self::DPI_96) * 2.54;
}
-
+
/**
* Convert points width to pixels
*
@@ -85,6 +87,7 @@ class Drawing
if ($pValue == 0) {
return 0;
}
+
return $pValue * 1.333333333;
}
@@ -97,7 +100,7 @@ class Drawing
public static function pixelsToCentimeters($pValue = 0)
{
//return $pValue * 0.028;
- return (($pValue / self::DPI_96) * 2.54);
+ return ($pValue / self::DPI_96) * 2.54;
}
/**
@@ -111,6 +114,7 @@ class Drawing
if ($pValue == 0) {
return 0;
}
+
return ($pValue / 2.54) * self::DPI_96;
}
@@ -136,13 +140,14 @@ class Drawing
if ($pValue == 0) {
return 0;
}
+
return round($pValue / 60000);
}
/**
* Convert centimeters width to twips
*
- * @param integer $pValue
+ * @param int $pValue
* @return float
*/
public static function centimetersToTwips($pValue = 0)
@@ -150,13 +155,14 @@ class Drawing
if ($pValue == 0) {
return 0;
}
+
return $pValue * 566.928;
}
/**
* Convert twips width to centimeters
*
- * @param integer $pValue
+ * @param int $pValue
* @return float
*/
public static function twipsToCentimeters($pValue = 0)
@@ -164,13 +170,14 @@ class Drawing
if ($pValue == 0) {
return 0;
}
+
return $pValue / 566.928;
}
/**
* Convert inches width to twips
*
- * @param integer $pValue
+ * @param int $pValue
* @return float
*/
public static function inchesToTwips($pValue = 0)
@@ -178,13 +185,14 @@ class Drawing
if ($pValue == 0) {
return 0;
}
+
return $pValue * 1440;
}
/**
* Convert twips width to inches
*
- * @param integer $pValue
+ * @param int $pValue
* @return float
*/
public static function twipsToInches($pValue = 0)
@@ -192,13 +200,14 @@ class Drawing
if ($pValue == 0) {
return 0;
}
+
return $pValue / 1440;
}
/**
* Convert twips width to pixels
*
- * @param integer $pValue
+ * @param int $pValue
* @return float
*/
public static function twipsToPixels($pValue = 0)
@@ -206,6 +215,7 @@ class Drawing
if ($pValue == 0) {
return 0;
}
+
return round($pValue / 15.873984);
}
diff --git a/src/PhpWord/Shared/Text.php b/src/PhpWord/Shared/Text.php
index b9bea3ad..c4a1ad62 100644
--- a/src/PhpWord/Shared/Text.php
+++ b/src/PhpWord/Shared/Text.php
@@ -36,8 +36,8 @@ class Text
{
for ($i = 0; $i <= 19; ++$i) {
if ($i != 9 && $i != 10 && $i != 13) {
- $find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
- $replace = chr($i);
+ $find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
+ $replace = chr($i);
self::$controlCharacters[$find] = $replace;
}
}
@@ -69,7 +69,7 @@ class Text
/**
* Return a number formatted for being integrated in xml files
* @param float $number
- * @param integer $decimals
+ * @param int $decimals
* @return string
*/
public static function numberFormat($number, $decimals)
@@ -79,24 +79,25 @@ class Text
/**
* @param int $dec
- * @link http://stackoverflow.com/a/7153133/2235790
+ * @see http://stackoverflow.com/a/7153133/2235790
* @author velcrow
* @return string
*/
public static function chr($dec)
{
- if ($dec<=0x7F) {
+ if ($dec <= 0x7F) {
return chr($dec);
}
- if ($dec<=0x7FF) {
- return chr(($dec>>6)+192).chr(($dec&63)+128);
+ if ($dec <= 0x7FF) {
+ return chr(($dec >> 6) + 192) . chr(($dec & 63) + 128);
}
- if ($dec<=0xFFFF) {
- return chr(($dec>>12)+224).chr((($dec>>6)&63)+128).chr(($dec&63)+128);
+ if ($dec <= 0xFFFF) {
+ return chr(($dec >> 12) + 224) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
}
- if ($dec<=0x1FFFFF) {
- return chr(($dec>>18)+240).chr((($dec>>12)&63)+128).chr((($dec>>6)&63)+128).chr(($dec&63)+128);
+ if ($dec <= 0x1FFFFF) {
+ return chr(($dec >> 18) + 240) . chr((($dec >> 12) & 63) + 128) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
}
+
return '';
}
@@ -119,7 +120,7 @@ class Text
* Check if a string contains UTF-8 data
*
* @param string $value
- * @return boolean
+ * @return bool
*/
public static function isUTF8($value = '')
{
@@ -161,7 +162,7 @@ class Text
* @param string $text UTF8 text
* @return array
* @since 0.11.0
- * @link http://www.randomchaos.com/documents/?source=php_and_unicode
+ * @see http://www.randomchaos.com/documents/?source=php_and_unicode
*/
public static function utf8ToUnicode($text)
{
@@ -201,7 +202,7 @@ class Text
* @param array $unicode
* @return string
* @since 0.11.0
- * @link http://www.randomchaos.com/documents/?source=php_and_unicode
+ * @see http://www.randomchaos.com/documents/?source=php_and_unicode
*/
private static function unicodeToEntities($unicode)
{
diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php
index ca5cb558..3905c52f 100644
--- a/src/PhpWord/Shared/XMLReader.php
+++ b/src/PhpWord/Shared/XMLReader.php
@@ -43,8 +43,8 @@ class XMLReader
*
* @param string $zipFile
* @param string $xmlFile
- * @return \DOMDocument|false
* @throws \Exception
+ * @return \DOMDocument|false
*/
public function getDomFromZip($zipFile, $xmlFile)
{
@@ -112,8 +112,8 @@ class XMLReader
*
* @param string $prefix The prefix
* @param string $namespaceURI The URI of the namespace
- * @return bool true on success or false on failure
* @throws \InvalidArgumentException If called before having loaded the DOM document
+ * @return bool true on success or false on failure
*/
public function registerNamespace($prefix, $namespaceURI)
{
@@ -123,6 +123,7 @@ class XMLReader
if ($this->xpath === null) {
$this->xpath = new \DOMXpath($this->dom);
}
+
return $this->xpath->registerNamespace($prefix, $namespaceURI);
}
@@ -192,7 +193,7 @@ class XMLReader
*
* @param string $path
* @param \DOMElement $contextNode
- * @return integer
+ * @return int
*/
public function countElements($path, \DOMElement $contextNode = null)
{
@@ -206,7 +207,7 @@ class XMLReader
*
* @param string $path
* @param \DOMElement $contextNode
- * @return boolean
+ * @return bool
*/
public function elementExists($path, \DOMElement $contextNode = null)
{
diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php
index 1d825dec..930ad62e 100644
--- a/src/PhpWord/Shared/XMLWriter.php
+++ b/src/PhpWord/Shared/XMLWriter.php
@@ -88,7 +88,7 @@ class XMLWriter extends \XMLWriter
return;
}
if (PHP_OS != 'WINNT' && @unlink($this->tempFileName) === false) {
- throw new \Exception('The file '.$this->tempFileName.' could not be deleted.');
+ throw new \Exception('The file ' . $this->tempFileName . ' could not be deleted.');
}
}
@@ -104,10 +104,10 @@ class XMLWriter extends \XMLWriter
}
$this->flush();
+
return file_get_contents($this->tempFileName);
}
-
/**
* Write simple element and attribute(s) block
*
@@ -118,7 +118,6 @@ class XMLWriter extends \XMLWriter
* @param string $element
* @param string|array $attributes
* @param string $value
- * @return void
*/
public function writeElementBlock($element, $attributes, $value = null)
{
@@ -139,7 +138,6 @@ class XMLWriter extends \XMLWriter
* @param string $element
* @param string $attribute
* @param mixed $value
- * @return void
*/
public function writeElementIf($condition, $element, $attribute = null, $value = null)
{
@@ -160,7 +158,6 @@ class XMLWriter extends \XMLWriter
* @param bool $condition
* @param string $attribute
* @param mixed $value
- * @return void
*/
public function writeAttributeIf($condition, $attribute, $value)
{
@@ -179,6 +176,7 @@ class XMLWriter extends \XMLWriter
if (is_float($value)) {
$value = json_encode($value);
}
+
return parent::writeAttribute($name, $value);
}
}
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 103e1556..fa8d8e65 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -17,13 +17,13 @@
namespace PhpOffice\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Escaper\RegExp;
use PhpOffice\PhpWord\Escaper\Xml;
use PhpOffice\PhpWord\Exception\CopyFileException;
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Shared\Text;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Shared\ZipArchive;
class TemplateProcessor
diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php
index 19f5ac96..adcf8ab4 100644
--- a/src/PhpWord/Writer/ODText/Element/Table.php
+++ b/src/PhpWord/Writer/ODText/Element/Table.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\ODText\Element;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Row as RowElement;
use PhpOffice\PhpWord\Element\Table as TableElement;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Table element writer
diff --git a/src/PhpWord/Writer/ODText/Part/AbstractPart.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php
index 67b7a7ae..4a7ace78 100644
--- a/src/PhpWord/Writer/ODText/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Settings;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart as Word2007AbstractPart;
diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php
index 4a84896d..b6a1c95e 100644
--- a/src/PhpWord/Writer/ODText/Part/Content.php
+++ b/src/PhpWord/Writer/ODText/Part/Content.php
@@ -17,7 +17,6 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\AbstractContainer;
use PhpOffice\PhpWord\Element\Field;
use PhpOffice\PhpWord\Element\Image;
@@ -26,6 +25,7 @@ use PhpOffice\PhpWord\Element\Text;
use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php
index c026e7bb..befd23a2 100644
--- a/src/PhpWord/Writer/ODText/Part/Styles.php
+++ b/src/PhpWord/Writer/ODText/Part/Styles.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\Converter;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style;
/**
diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
index d4ec0f7d..ee0fb2f9 100644
--- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
@@ -17,10 +17,10 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\AbstractElement as Element;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\Text as SharedText;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Abstract element writer
diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php
index 8a6aa805..0a39403d 100644
--- a/src/PhpWord/Writer/Word2007/Element/Container.php
+++ b/src/PhpWord/Writer/Word2007/Element/Container.php
@@ -17,10 +17,10 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement;
use PhpOffice\PhpWord\Element\AbstractElement as Element;
use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Container element writer (section, textrun, header, footnote, cell, etc.)
diff --git a/src/PhpWord/Writer/Word2007/Element/FormField.php b/src/PhpWord/Writer/Word2007/Element/FormField.php
index e1754d0f..72063864 100644
--- a/src/PhpWord/Writer/Word2007/Element/FormField.php
+++ b/src/PhpWord/Writer/Word2007/Element/FormField.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\FormField as FormFieldElement;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* FormField element writer
diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php
index 8fc4849d..f136ba0b 100644
--- a/src/PhpWord/Writer/Word2007/Element/Image.php
+++ b/src/PhpWord/Writer/Word2007/Element/Image.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Image as ImageElement;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Font as FontStyle;
use PhpOffice\PhpWord\Style\Frame as FrameStyle;
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;
diff --git a/src/PhpWord/Writer/Word2007/Element/SDT.php b/src/PhpWord/Writer/Word2007/Element/SDT.php
index e2d0d368..e4964242 100644
--- a/src/PhpWord/Writer/Word2007/Element/SDT.php
+++ b/src/PhpWord/Writer/Word2007/Element/SDT.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\SDT as SDTElement;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Structured document tag element writer
diff --git a/src/PhpWord/Writer/Word2007/Element/Shape.php b/src/PhpWord/Writer/Word2007/Element/Shape.php
index 445be7e4..ef30c484 100644
--- a/src/PhpWord/Writer/Word2007/Element/Shape.php
+++ b/src/PhpWord/Writer/Word2007/Element/Shape.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Shape as ShapeElement;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Shape as ShapeStyle;
use PhpOffice\PhpWord\Writer\Word2007\Style\Shape as ShapeStyleWriter;
diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php
index 78989f81..3dac76fb 100644
--- a/src/PhpWord/Writer/Word2007/Element/TOC.php
+++ b/src/PhpWord/Writer/Word2007/Element/TOC.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\TOC as TOCElement;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php
index 4067868d..25a44fb1 100644
--- a/src/PhpWord/Writer/Word2007/Element/Table.php
+++ b/src/PhpWord/Writer/Word2007/Element/Table.php
@@ -17,10 +17,10 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Cell as CellElement;
use PhpOffice\PhpWord\Element\Row as RowElement;
use PhpOffice\PhpWord\Element\Table as TableElement;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Cell as CellStyle;
use PhpOffice\PhpWord\Style\Row as RowStyle;
use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter;
diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
index e14b394e..4bee5c54 100644
--- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
@@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Settings;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Writer\AbstractWriter;
/**
diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php
index e413d273..8907160b 100644
--- a/src/PhpWord/Writer/Word2007/Part/Chart.php
+++ b/src/PhpWord/Writer/Word2007/Part/Chart.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Chart as ChartElement;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 chart part writer: word/charts/chartx.xml
diff --git a/src/PhpWord/Writer/Word2007/Part/Comments.php b/src/PhpWord/Writer/Word2007/Part/Comments.php
index 6bff63ee..5b867324 100644
--- a/src/PhpWord/Writer/Word2007/Part/Comments.php
+++ b/src/PhpWord/Writer/Word2007/Part/Comments.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Comment;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
/**
diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php
index 09ef13f0..d2ab836b 100644
--- a/src/PhpWord/Writer/Word2007/Part/Document.php
+++ b/src/PhpWord/Writer/Word2007/Part/Document.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Section;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter;
diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php
index 34bf737b..58c2e9b1 100644
--- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php
+++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Footnote;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php
index 0a3f934e..70f632f7 100644
--- a/src/PhpWord/Writer/Word2007/Part/Rels.php
+++ b/src/PhpWord/Writer/Word2007/Part/Rels.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Exception\Exception;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 main relationship writer: _rels/.rels
diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php
index 7e17fbe7..3624a7be 100644
--- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php
+++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php
@@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Settings;
+use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Style writer
diff --git a/tests/PhpWord/Shared/DrawingTest.php b/tests/PhpWord/Shared/DrawingTest.php
index 906a32ce..b7110923 100644
--- a/tests/PhpWord/Shared/DrawingTest.php
+++ b/tests/PhpWord/Shared/DrawingTest.php
@@ -20,12 +20,10 @@ namespace PhpOffice\PhpWord\Shared;
/**
* Test class for PhpOffice\PhpWord\Shared\Drawing
*
- * @coversDefaultClass PhpOffice\PhpWord\Shared\Drawing
+ * @coversDefaultClass \PhpOffice\PhpWord\Shared\Drawing
*/
class DrawingTest extends \PHPUnit\Framework\TestCase
{
- /**
- */
public function testDegreesAngle()
{
$value = rand(1, 100);
@@ -36,8 +34,6 @@ class DrawingTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(round($value / 60000), Drawing::angleToDegrees($value));
}
- /**
- */
public function testPixelsCentimeters()
{
$value = rand(1, 100);
@@ -48,32 +44,26 @@ class DrawingTest extends \PHPUnit\Framework\TestCase
$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(round($value * 9525), Drawing::pixelsToEmu($value));
$this->assertEquals(0, Drawing::emuToPixels());
- $this->assertEquals(round($value/9525), Drawing::emuToPixels($value));
+ $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($value * 0.67777777, Drawing::pixelsToPoints($value));
$this->assertEquals(0, Drawing::pointsToPixels());
- $this->assertEquals($value* 1.333333333, Drawing::pointsToPixels($value));
+ $this->assertEquals($value * 1.333333333, Drawing::pointsToPixels($value));
}
- /**
- */
public function testPointsCentimeters()
{
$value = rand(1, 100);
@@ -82,8 +72,6 @@ class DrawingTest extends \PHPUnit\Framework\TestCase
$this->assertEquals($value * 1.333333333 / Drawing::DPI_96 * 2.54, Drawing::pointsToCentimeters($value));
}
- /**
- */
public function testTwips()
{
$value = rand(1, 100);
diff --git a/tests/PhpWord/Shared/TextTest.php b/tests/PhpWord/Shared/TextTest.php
index ded00e96..6df19b12 100644
--- a/tests/PhpWord/Shared/TextTest.php
+++ b/tests/PhpWord/Shared/TextTest.php
@@ -20,12 +20,10 @@ namespace PhpOffice\PhpWord\Shared;
/**
* Test class for Text
*
- * @coversDefaultClass PhpOffice\PhpWord\Shared\Text
+ * @coversDefaultClass \PhpOffice\PhpWord\Shared\Text
*/
class TextTest extends \PHPUnit\Framework\TestCase
{
- /**
- */
public function testControlCharacters()
{
$this->assertEquals('', Text::controlCharacterPHP2OOXML());
@@ -33,7 +31,7 @@ class TextTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('àéîöù', Text::controlCharacterPHP2OOXML('àéîöù'));
$value = rand(0, 8);
- $this->assertEquals('_x'.sprintf('%04s', strtoupper(dechex($value))).'_', Text::controlCharacterPHP2OOXML(chr($value)));
+ $this->assertEquals('_x' . sprintf('%04s', strtoupper(dechex($value))) . '_', Text::controlCharacterPHP2OOXML(chr($value)));
$this->assertEquals('', Text::controlCharacterOOXML2PHP(''));
$this->assertEquals(chr(0x08), Text::controlCharacterOOXML2PHP('_x0008_'));
@@ -58,6 +56,7 @@ class TextTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('🌃', Text::chr(0x1F303));
$this->assertEquals('', Text::chr(2097152));
}
+
/**
* Is UTF8
*/
diff --git a/tests/PhpWord/Shared/XMLReaderTest.php b/tests/PhpWord/Shared/XMLReaderTest.php
index a34d650a..4d0ee64c 100644
--- a/tests/PhpWord/Shared/XMLReaderTest.php
+++ b/tests/PhpWord/Shared/XMLReaderTest.php
@@ -20,7 +20,7 @@ namespace PhpOffice\PhpWord\Shared;
/**
* Test class for XMLReader
*
- * @coversDefaultClass PhpOffice\PhpWord\Shared\XMLReader
+ * @coversDefaultClass \PhpOffice\PhpWord\Shared\XMLReader
*/
class XMLReaderTest extends \PHPUnit\Framework\TestCase
{
@@ -57,7 +57,7 @@ class XMLReaderTest extends \PHPUnit\Framework\TestCase
/**
* Test that read from non existing archive throws exception
*
- * @expectedException Exception
+ * @expectedException \Exception
*/
public function testThrowsExceptionOnNonExistingArchive()
{
@@ -124,7 +124,7 @@ class XMLReaderTest extends \PHPUnit\Framework\TestCase
/**
* Test that xpath fails if custom namespace is not registered
*
- * @expectedException InvalidArgumentException
+ * @expectedException \InvalidArgumentException
*/
public function testShouldThowExceptionIfTryingToRegisterNamespaceBeforeReadingDoc()
{
diff --git a/tests/PhpWord/Shared/XMLWriterTest.php b/tests/PhpWord/Shared/XMLWriterTest.php
index 843ae716..e86cd50b 100644
--- a/tests/PhpWord/Shared/XMLWriterTest.php
+++ b/tests/PhpWord/Shared/XMLWriterTest.php
@@ -24,23 +24,21 @@ namespace PhpOffice\PhpWord\Shared;
*/
class XMLWriterTest extends \PHPUnit\Framework\TestCase
{
- /**
- */
public function testConstruct()
{
// Memory
$object = new XMLWriter();
$object->startElement('element');
- $object->text('AAA');
+ $object->text('AAA');
$object->endElement();
- $this->assertEquals('AAA'.chr(10), $object->getData());
+ $this->assertEquals('AAA' . chr(10), $object->getData());
// Disk
$object = new XMLWriter(XMLWriter::STORAGE_DISK);
$object->startElement('element');
- $object->text('BBB');
+ $object->text('BBB');
$object->endElement();
- $this->assertEquals('BBB'.chr(10), $object->getData());
+ $this->assertEquals('BBB' . chr(10), $object->getData());
}
public function testWriteAttribute()
diff --git a/tests/PhpWord/Writer/Word2007/ElementTest.php b/tests/PhpWord/Writer/Word2007/ElementTest.php
index 8193b3db..38b1ba75 100644
--- a/tests/PhpWord/Writer/Word2007/ElementTest.php
+++ b/tests/PhpWord/Writer/Word2007/ElementTest.php
@@ -17,11 +17,11 @@
namespace PhpOffice\PhpWord\Writer\Word2007;
-use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Comment;
use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\TestHelperDOCX;
/**
From 293efab0c2bcbfa4331ca6594f5c5a51d83c9c3b Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 10 Jan 2021 14:33:13 +0100
Subject: [PATCH 108/139] TCPDF doesn't support PHP 8.0, skip test
---
tests/PhpWord/Writer/PDF/TCPDFTest.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/PhpWord/Writer/PDF/TCPDFTest.php b/tests/PhpWord/Writer/PDF/TCPDFTest.php
index c8f5d222..53e55ca0 100644
--- a/tests/PhpWord/Writer/PDF/TCPDFTest.php
+++ b/tests/PhpWord/Writer/PDF/TCPDFTest.php
@@ -39,6 +39,12 @@ class TCPDFTest extends \PHPUnit\Framework\TestCase
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';
$phpWord = new PhpWord();
From 40966dd5c5fb1f7f02950fac82e4ee2eadc2f58b Mon Sep 17 00:00:00 2001
From: Libor M
Date: Sun, 10 Jan 2021 14:56:54 +0100
Subject: [PATCH 109/139] remove allow failures for PHP 8.0
---
.travis.yml | 4 ----
1 file changed, 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index aca5dbf8..c368913d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,8 +24,6 @@ matrix:
dist: trusty
- php: 7.0
env: COVERAGE=1
- - php: 8.0
- env: DEPENDENCIES="--ignore-platform-reqs"
exclude:
- php: 5.3
dist: xenial
@@ -33,8 +31,6 @@ matrix:
dist: xenial
- php: 5.5
dist: xenial
- allow_failures:
- - php: 8.0
cache:
directories:
From ca1272bd695ad88c4eff6c4abc0d9bab81ae5d72 Mon Sep 17 00:00:00 2001
From: troosan
Date: Fri, 5 Feb 2021 20:48:05 +0100
Subject: [PATCH 110/139] remove whitespace
---
tests/PhpWord/Reader/Word2007/ElementTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/PhpWord/Reader/Word2007/ElementTest.php b/tests/PhpWord/Reader/Word2007/ElementTest.php
index d5db6be8..08b72418 100644
--- a/tests/PhpWord/Reader/Word2007/ElementTest.php
+++ b/tests/PhpWord/Reader/Word2007/ElementTest.php
@@ -64,7 +64,7 @@ class ElementTest extends AbstractTestReader
$text = $elements[0];
$this->assertEquals('Test node value', trim($text->getElement(0)->getText()));
}
-
+
/**
* Test reading of textbreak
*/
From 13384f63d3e001b5ebcea3007533f8acb89cf5f4 Mon Sep 17 00:00:00 2001
From: troosan
Date: Fri, 5 Feb 2021 21:15:51 +0100
Subject: [PATCH 111/139] update comment
---
src/PhpWord/Writer/HTML/Element/Table.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php
index f19ad683..059574a2 100644
--- a/src/PhpWord/Writer/HTML/Element/Table.php
+++ b/src/PhpWord/Writer/HTML/Element/Table.php
@@ -52,7 +52,7 @@ class Table extends AbstractElement
for ($j = 0; $j < $rowCellCount; $j++) {
$cellStyle = $rowCells[$j]->getStyle();
$cellBgColor = $cellStyle->getBgColor();
- $cellBgColor === 'auto' && $cellBgColor = null; // Fix deprecated warning for non-hexadecimal number
+ $cellBgColor === 'auto' && $cellBgColor = null; // auto cannot be parsed to hexadecimal number
$cellFgColor = null;
if ($cellBgColor) {
$red = hexdec(substr($cellBgColor, 0, 2));
From 24e46544d894c1d401c444ee867a50b04a6a651f Mon Sep 17 00:00:00 2001
From: troosan
Date: Fri, 5 Feb 2021 21:25:21 +0100
Subject: [PATCH 112/139] remove space
---
src/PhpWord/TemplateProcessor.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index ece29c35..18ec6ec4 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -276,7 +276,7 @@ class TemplateProcessor
$where = $this->findContainingXmlBlockForMacro($search, 'w:r');
if ($where === false) {
- return ;
+ return;
}
$block = $this->getSlice($where['start'], $where['end']);
From 31002fc6e867fef24f4dd82827e8f527fd9d479e Mon Sep 17 00:00:00 2001
From: dbarzin
Date: Sat, 6 Feb 2021 10:40:52 +0100
Subject: [PATCH 113/139] add chart in template
---
samples/Sample_41_TemplateSetChart.php | 45 ++++++++++++++++++
.../resources/Sample_41_TemplateSetChart.docx | Bin 0 -> 9576 bytes
src/PhpWord/TemplateProcessor.php | 40 ++++++++++++++++
src/PhpWord/Writer/Word2007/Part/Chart.php | 23 +++++----
4 files changed, 96 insertions(+), 12 deletions(-)
create mode 100644 samples/Sample_41_TemplateSetChart.php
create mode 100644 samples/resources/Sample_41_TemplateSetChart.docx
diff --git a/samples/Sample_41_TemplateSetChart.php b/samples/Sample_41_TemplateSetChart.php
new file mode 100644
index 00000000..102fa3ac
--- /dev/null
+++ b/samples/Sample_41_TemplateSetChart.php
@@ -0,0 +1,45 @@
+addSeries($categories, $series2);
+ }
+ if (in_array($chartType, $threeSeries)) {
+ $chart->addSeries($categories, $series3);
+ }
+
+ $chart->getStyle()
+ ->setWidth(Converter::inchToEmu(3))
+ ->setHeight(Converter::inchToEmu(3));
+
+ $templateProcessor->setChart("chart{$i}", $chart);
+ $i++;
+}
+
+echo date('H:i:s'), ' Saving the result document...', EOL;
+$templateProcessor->saveAs('results/Sample_41_TemplateSetChart.docx');
+
+echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_41_TemplateSetChart.docx');
+if (!CLI) {
+ include_once 'Sample_Footer.php';
+}
diff --git a/samples/resources/Sample_41_TemplateSetChart.docx b/samples/resources/Sample_41_TemplateSetChart.docx
new file mode 100644
index 0000000000000000000000000000000000000000..c958b335c8ffe06c109ef3ccea5fb34bc81e1f8c
GIT binary patch
literal 9576
zcma)i1y~)+vMwIn-Q6JscZWb=A;CS!f}jg`2`<6i-JRfW0fM^+cPBW(9^{;TlC$r-
z`@LG<%r~oh{_2_P>gt~UOF;$_3KI+#78Wc>yFdZ#4?%do*0Tj#*u7?cIhRdzzJq*&
z3bX2#VUXnJRHq_tRNWdhmLlcxDRSr-CPh{%Uvp(y0lrB=wUe0bc4vnocZu+!&9xww
z=oNHHlXr-Z{y|sfs>5|nOCX^Bqu$4gJn^$#gYp5nZ}5^)H=h!RrF3_aDg13G?anj@
z-XP)Dx=cc@HJKi>JRE+qn$WN;^Qoz2D0Iw-dYlbQ7uRCKN21Z}Rj!NS9>~)!@D}$5
zo@@8s#um!3tpdk>o{%29ne0XlcPd57F!RDg%Q&Xz8m3|_X)75aYs@{Ji5CnJ?p-D4
znyxRNclKusM2sd&e2&SO_W)Orc?G*=dnLa6{Q6@MU|a|qebMpSx_aeQ@hU6d5<8n3QhfmOBHZx2tTaL;mcfcpC$S&6LSHmpfr?e
zE2{-oo`&7s8Xv7yYjEeB={McurM+_>mdCOpLCrghZgkubN1d)+qQp^Kt`60QX9G$`
zQRNsrI%Eg9DcW>19K5SZpvd=SXPqLli`EKhD0kG(VMF~(8nxfP@NIQO5?XX|aJChP
z_R>_W5WVM5fvQ2Bgwjq4*fQIdv*+=a0i1-2VG|sFEpZZV6`n=Kl~2aDAgh)wekA5L
zj7XRq8@v-W%r1Yu!vqDH*P|qzrZ1Gan8VOY1Z2uL7NG3sHnV3uMm&G5_&WdVSRhj!
zuI#i@XD^^w*S&40td}=Mo~VnXf}iICO*={X3Gyyk05w9w>k-Zi^QLljn&!pQw#i0%
z^x$A%Tu}dHX~MrO{V#ts0vS4306Ild_M@^#e&*$hoyhQSr!t+eo5}5Rz!k2
zc?7vgNm;VHLZDpZ6BI~n!pX-b%c-N&6rVPJ+xrn*8WU2iOm=+tU5DUGC{E>o_X?6T5SG{vGA@7?XjHK=+J`QYU^*H(9TrzyM
zA486$y$81Y)0{JOS$u=VbaW&7zUC{Njwea?#9es^^I{!Gqhiac=XX!|M?XaS%Q|*I
zdwWwW6T26?P@$8%R2=UW9uK9JlMyK+$JvBN6<*y!UvIDIvO0yW-s_jN>*-=#Lm&TRLQ(OpvmhmJ@
z&I~rU##1-ot1gPv0hfip&A)^)4vTls7|K$(3#p@DLY?7vQcxi`UR$!E7E@y2&ES07
z{@o;Q4G^x8w*OA)&W8t<`6%tNI&eHmECM>rMchDf7x5?HYcQUK*d{2lnBF3Np$Te`
zzlLFfH_qcb1zIvf=F^*N;^hVxbjexBxsI>?+B_{QXN-3v8JkniY>fh%l<@(_OX(`0
zs)}tESLZ`<5f@FDGW2nYqLKM2l=X`q?3I^(ul6pa_s6ns%!J+0{4}4ndbDsnZ(+mc{Yt>x7il@9-$NwPv=0La=04L1c65
zrL1R`^nITOYNNS=5feIL6dzz3vu%t%Djzc`AnLAyR>Rn0V_=w;P>vvsqGmr5f^y<1
z8klVl)UDEYV_A!L5Y~{2GMh^*%~+Y~Z85kRr8OhNX$o
zmlag95lFJXe|B=m#k9&r4bhp#6N#3A3&+dboB5ya&C;Dj0L@X$6ASC+>}z)OwO))S
z3UN@zWjc>%7`-okSpeJ`{1z0)-EQj{}u;dc`N`
z+x)k*R5H8#L|$A`6Nky2!L6`#IYaI!ZfUv#tDkvlQsBhUEg_ax=fc60jm?)rGZTd`
zuXBOR;^=gj^sI53GFCDUO?4UAP4KFD%m|*fxyja$Bp9-4)N`Lx(WG<^q)?UOU@a+;
z=x`gALwHA4&6*JV(DlG-?`kePyQm94EU)wC
zOCsHy($6V_qd2u4>D)Vd_ps)aI;eKshe(7@Mkl`zZ&zhZ7Jb8?DLq$bh4K?eb0)3~
zg?R&j6_rRTOk;~tUnWKUtTDvZ$`RNhiI!9P}BNK|N#)8A=d>`Azjft>$F-8vtYM
zYGO^9Ru0-F9KI1_SsC6rv2TTVzeTsnddDc$J|+(*F5i4a>HsswE^2ihv@L`uJLz?t
zKW;p{RZW@ZW7T2V;8ki+5mpVpj?h!AJ(UPc`Hnp~;Rsw>TeFR+$w<5Isb24;Ypd00
z()l3x+;!)B6S#vbEjg23B}lA&_)op)o;j0y&IDNQhTcvIr)8RxOXX^(
z#}Fq>2P^Z(jwx6z^&MOZrw=j&fclV85wx6sXSlQ;JK`iBqp$NE6fMxFGmPNav|5AZ
zK7xuRwoJX(4ZDz}D9oztB4)|aXjkB~JwFr_QsFvMpv;{@nDm$}fnOpopaCk2KWTdu
z&=9_r>;JVHI(UMwa=w6SmGg+Cqj
z$$LF)A+Razb>Qd;+&;|5;OKc>^<76Go?3bb^12Hfl8*yy{jOXP1Mr|Cv$zR*NV}8^
z=Hx_!F;d5I#{{rc#<&U+^&!i}iiuk&GNBVcsnJ~1!;^>`WEX-v3xqIq=!|FtBIE#O
z*)*DPsHHz*GgI?gk!*;?93BVXTv5|)vT{@%O6F#76Z=MPL{f@p9TJmZ7?3v0nD$gO
zPvK~vMTt7m?SC+{@Bf4xm$Zu?M#iiZr{M)eCb?6p;$vH#n7t;R{G8otmrZ_WNr<-W4_qJ>gg*>e93L7{$pA3
z`FaK-?)-k!qeR8szMZA;Ebz9Q?H^BtXrOMkeq}hC#S{AP{rQVq)y3YC!8
z0MCrc-7e`<5>XU_OrGk4OOt>)5bZ##I6y@RSsK@JUQG$TaV`LI1cPE%ZRV$~Bly{A
zJwmPL{~l-R8*V8>smemjkRc%}tz`jfTeH>c!FQFbFlW6E#$x-5zQ
zTi?YfDF`E3CBw&23##%LH7l-@sV#GU7*EW=MKh1+kd5#K(oV-`8@*1TkSS)chthO$
z7!?(iTbzLnplt|MTBWIm@zY4GVbY7sZ>dX^$G4D^DX5!R4GB_~s`UjbD{R#pp8%r$
zA00-A@2v%4aGSf$=fums@3DKZ^Y4TP@&&`{6=j+;=61Wr2`&!
zI#f7{4M9J}gi)b+3&cuw7gADvWo+srRM0&n7(I`J|jq
zW4mi^0rspKGZY*mhw<$qHV*yznEyo3PY-ZkF=m7dQ3dRzcR|3Dcs8B>wQLX;e+V^>
zq*+FQl)|n(J-Xjv(Zt9si{1XubBEr-LpD1HpyoYtKbgL7scTBo19phGq&Qd_gB0KTM+P(WLL^;@GAIpNSU63=9s|grVJ(?Q4jx9!4
z%}?yr76+-!%wHwB*Ira$kSs&a^I0n-vrv7;k-lCloKJhu19Lxw-kbTgG|D;mr>%ho
z0}~|pr?8LmSJ=0+cd-EeTA&{3EIHRBDt2-`Ce9;UlkfsWs3mr6})hPrIr+M};1a`gXXI+=HFB>Fy}q&fR&`
zr5ioj2#p^@`WWv-N?o$Am?ZGoirVr~x=o^B4wP^B2Ql3Vk!W(p_gIYeSqne(DuH1J
zdeXC2#R}b!6NhZEUNi>0-`u*!Cn$?Hn+
zb7B#*V7o>u;LEl^D)7t_`%7<{Ckz+LxsoKKi^5%ox;@Wo|9FB6ky*1T8q9tTqd;=|
zFj62eCGbu_img=LQg8YB-WfFHKp{@~PtjPvj%LQ4>
z1zV28=@O97%S?-;FY
zLxRORv`A|CJR}~rJcPluN)RRFSI*3N$#UCqKPV9*HX$siYF-Kg2CJ^p_6l3nlO^g9
zZnPODK#*za<9v0%UIxE;;$!2>1usFWVq>8=#hG%j
zWxJ?&fY^<~167eS-99SW&?fE?wx7H
zp{{Q^GSuZKLQBrq25D*;jfNk=R^aF)WCJvqu^%58^zME0y+JCLsV%6NS4`u@Q7|d~
zP%-k}ln~^UaW(+2aS3lP%(_Xp`9~1-I*E{uzAc=@A>U
z^a;QWjjIU%;gezy-rj}0{f|DdoDeo7Nh}lmQ2G&eT$NO!_UjwlqUaAzbiJQ)LwF#g
zt+J&lBWB5gdkAQoDql%(JG)H19TP%;p4IJAA$JvY6Z6BO@2MA|39grOgZDk6~O`*R&g!Dbg>^BG9x>IF;Du{oqof$djI3LV&ufA-;ON$o<
zbp^&|Mu7}ovk(=6Ng37~d%vbYAxl86aBNwk5Vhy|fc{nd(#~%%Z5D(bO_nHT
zjRG0eFXU8Ax~TsZcb2Fd&U5k0@t>*}rT<3z!4IYR!7Kjj@m`vjcZ0`T*zkit(s?e{
z{;#TkD}F|!)3Z3C|9<#|_39RF(`8S+=I?%bmo*}QCcP$lg3I~)S|>}ST0Z4zdcK)l
zwi!M$;?^S&hB;~9l1P^XCVZ>-1H=c|Jgb_<+8ljA?&r`91gX(mh~(VOu?^jda@>hsqn)`!gm@Yvfd
z;#%U0qSS{C1(4ZWFFIS`raRxRwtze)#^nnZ-2mXCTHN@sCXRk}m44b9vsZjE#&35A
z(uuMd!W^M6GgNW;s~lR&Saa?3OHtpKT64wbQR+
zv!MT}P$Vui|3%?1qz}e4*k3TS9Lr7R`auM#NMeCz{gsZT@rY1;
zW^lG!s!U0_jVdzKZdTLL(m7hSP&f7^@%X_G&nG;`lK4aAjp97&;wArmRVEI_u#))F
zmjcydo9Xuq(+y_*avbHFX4&{^&y`1l+|4R7|EVg9Gt;g$D)?3Pj7u);RgnQGU#CVc
z{V({xZu);{*eIrYY5AA>sdvxK|IC#Y_30BCHjIB4ahzm3%cvzi^8_BC7aeOt?z-+B
zc)Wkwc(q@2Pxy1#Xy3VrH(6-@`%PHX^5q*AJ$Nik6zAbJ+l>|p-CMb`Gt#BgGyIar
zRO4b)<_NqnY@Er@8139q8!21rY|2lqZ$X~V
zy+5;e8_VznV*SWtywghGyjNZmvVUWX0pX`>rpV4E(5HtqP}9Cp4O25o2N{&0a-tZ@O-5J&NT6YQJsNlRXuSV
zX<;Vi+RkXsOJ238#Ky~;EMlDdjyazxnQQFs#KZ5znt@*$$phRtw+)3aKlJ7gBUy>a$z4zuk~Zx5?iZQX5o
ziBUeTd-7R3e!gGV1-PB=SO+eE!oTcRjk-`D@##9I^4-bBcO3Mn4)OC~?C~NvKf>T3
zH|`2lgwf>4ozDUaHx>AK?M9-9R=?^m=P+RcVQQCY^ANhKK&RtLIEXB{Ak8opnJtf|xXtjAIkwr`3UmR#
zzVO~%Mu(H-nvdoow!j>s3G3=jW%;tQQs{1zZG;QPg^>eTn)0g|1M_VY4
z2!(0E6(Uvv9_Hn}!W0J{De*3EfToV&3^h(pwRB8>r5Re(;K|{dzHuhegH>+()3w{)
zHF4m+MQ944f;xZ0Klp$)~0V63;FYahnkZHnjkh|{wP
z%MbPW%kOzVT)`G(ZTDK=+WKX$FD+`&s+;tgB71;G01|AxHLFFV-WSu6u*_`&IHCCm
z1Ave|(y{j*(i9rHPFx9mseFhQ4){MeVFf>$n?)DkNq0z<)R>x|jkgS)NTDm>Qn{LE
zQk%dU^?>GjwO$c(_)((E7D@;1#>c|UcanddM7kR#5S4x!`t?GJPq{
zwiac9pZXpqY)i!)aidrG<&0JD#$tr|jNAN!b*u1dMM8>4F(YzlctL3u?N3RRj`QM>
zUfOwIyViJ!4c8k@FE{7A!5kIM{Cd+jTIP1#M{UQ&I<->NNX<9tB#}~s7FW(=t;sl{
za{3k&ny~yP7n+r2m-MIPh8LPu1#-@0Zyu3G2cyS>)19@#mYOlny68^|bTDWFT*h73
zn&xU7#KT!bY|ig-UX1-kT3YM%GXsJ0j|>FHpT;(Hu(JnQzSz5V5&-HV#eH>pCn(X~
zDq5mqzJPDZ!FO2sHGwZ@D!Nt}Y$+MI;$dIw%03@E*)8)ZM2b2rbTGi9n3uHr<`f2&
zI~F5~%`>Res@buiV;tt3P|ar&mtEP{2lPV{j?es;~^5{Yo0`O3T7#!|j5(spGjCX7Ex
zgG#7IF_?>(bdlVdDCEQI$4TO=I)T-I=p2LmJ!{T)yc5_?8S@~1)RT7y2;vf5?*^=fRwf>Fy8*6gzw|*
z)P-ZUi9lDoH0bZt
z;lPyHmDx9uqW-RnX-R2Im#!=es=zPLn-67yL5{HRga?}xT;GVluC{RvL*Mad7S}Mx
z%_ibzUsr=PO)O>NpI`WN39pSFT4OkYI6mRl&EjYa7iXQ8Ip&=@TZb-~>*yU8xncm$
zO_3YOaGH&(yV}dbQAWY5j{T*Uok2^|SJdEn(RoCaPZZ)+OKh>lj4i$`u0hw%X07N-
zsdYJ1q}niV!JESWuKOOdU7k2&qqt~dSV>yg-5S?V8lg)p3JS6gQvLB6I|mz2eL_?wBc5AtQO2yX#O4O)^-du`cTO
z{B|deY$0*(O*0N(AV^|43^@k^7{Mtlvt&7pug_C1QUNr+?rk=x==&V{L)bybKIf!3
znG)YhA;sb*T$v(uJ$lk2N3$V3c?r{POp$y#F>_v}Y^o`Q0K@t(lf$)``!#ImuOy}t
z;dacZpx-C;(VtAY6m}D@4PcT?7=}-RnB}Dv|qUUh(OVgj+{omn#QfvPWfAhTa
z`V0Oi<@|T}pIfvq{M&C)f&Dl9?`+)PRs1>EzwG7y7Fp!KUf@4FyMG7&Id{D*2Y!p>
zvswQWF8{qa_&fT~!22@4{g!H?KhVEtyT2>=GY_1H=NRPgU;{df4EuKC~XZgetNextRelationsIndex($this->getMainPartName());
+ $chart->setRelationId($rId);
+
+ // Define the chart filename
+ $filename = "charts/chart{$rId}.xml";
+
+ // Get the part writer
+ $writerPart = new \PhpOffice\PhpWord\Writer\Word2007\Part\Chart();
+ $writerPart->setElement($chart);
+
+ // ContentTypes.xml
+ $this->zipClass->addFromString("word/{$filename}", $writerPart->write());
+
+ // add chart to content type
+ $xmlRelationsType = "";
+ $this->tempDocumentContentTypes = str_replace('', $xmlRelationsType, $this->tempDocumentContentTypes) . '';
+
+ // Add the chart to relations
+ $xmlChartRelation = "";
+ $this->tempDocumentRelations[$this->getMainPartName()] = str_replace('', $xmlChartRelation, $this->tempDocumentRelations[$this->getMainPartName()]) . '';
+
+ // Write the chart
+ $xmlWriter = new XMLWriter();
+ $elementWriter = new $objectClass($xmlWriter, $chart, true);
+ $elementWriter->write();
+
+ // Place it in the template
+ $this->replaceXmlBlock($search, '' . $xmlWriter->getData() . '', 'w:p');
+ }
+
private function getImageArgs($varNameWithArgs)
{
$varElements = explode(':', $varNameWithArgs);
diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php
index 8907160b..58fa55d6 100644
--- a/src/PhpWord/Writer/Word2007/Part/Chart.php
+++ b/src/PhpWord/Writer/Word2007/Part/Chart.php
@@ -209,7 +209,7 @@ class Chart extends AbstractPart
/**
* Write series.
*
- * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
+ * @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param bool $scatter
*/
private function writeSeries(XMLWriter $xmlWriter, $scatter = false)
@@ -219,6 +219,7 @@ class Chart extends AbstractPart
$colors = $style->getColors();
$index = 0;
+ $colorIndex = 0;
foreach ($series as $seriesItem) {
$categories = $seriesItem['categories'];
$values = $seriesItem['values'];
@@ -265,23 +266,21 @@ class Chart extends AbstractPart
$this->writeSeriesItem($xmlWriter, 'cat', $categories);
$this->writeSeriesItem($xmlWriter, 'val', $values);
- // setting the chart colors was taken from https://github.com/PHPOffice/PHPWord/issues/494
- if (is_array($colors) && count($colors)) {
- // This is a workaround to make each series in a stack chart use a different color
- if ($this->options['type'] == 'bar' && stristr($this->options['grouping'], 'stacked')) {
- array_shift($colors);
- }
- $colorIndex = 0;
- foreach ($colors as $color) {
+ // check that there are colors
+ if (is_array($colors) && count($colors)>0) {
+ // assign a color to each value
+ $valueIndex=0;
+ foreach ($values as $value) {
+ // check that there are still enought colors
$xmlWriter->startElement('c:dPt');
- $xmlWriter->writeElementBlock('c:idx', 'val', $colorIndex);
+ $xmlWriter->writeElementBlock('c:idx', 'val', $valueIndex);
$xmlWriter->startElement('c:spPr');
$xmlWriter->startElement('a:solidFill');
- $xmlWriter->writeElementBlock('a:srgbClr', 'val', $color);
+ $xmlWriter->writeElementBlock('a:srgbClr', 'val', $colors[$colorIndex++ % count($colors)]);
$xmlWriter->endElement(); // a:solidFill
$xmlWriter->endElement(); // c:spPr
$xmlWriter->endElement(); // c:dPt
- $colorIndex++;
+ $valueIndex++;
}
}
}
From 48ee2eb78a5d74bd9845ea86fb277b156759ae34 Mon Sep 17 00:00:00 2001
From: dbarzin
Date: Sat, 6 Feb 2021 10:50:21 +0100
Subject: [PATCH 114/139] fix param error
---
src/PhpWord/Writer/Word2007/Part/Chart.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php
index 58fa55d6..705a5c28 100644
--- a/src/PhpWord/Writer/Word2007/Part/Chart.php
+++ b/src/PhpWord/Writer/Word2007/Part/Chart.php
@@ -209,7 +209,7 @@ class Chart extends AbstractPart
/**
* Write series.
*
- * @param \PhpOffice\Common\XMLWriter $xmlWriter
+ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param bool $scatter
*/
private function writeSeries(XMLWriter $xmlWriter, $scatter = false)
From 214df1a1cbede6a99b643e14a0be2a0dbd31a898 Mon Sep 17 00:00:00 2001
From: dbarzin
Date: Sat, 6 Feb 2021 12:57:16 +0100
Subject: [PATCH 115/139] fix unit test
---
tests/PhpWord/Writer/Word2007/Element/ChartTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/PhpWord/Writer/Word2007/Element/ChartTest.php b/tests/PhpWord/Writer/Word2007/Element/ChartTest.php
index 432d8db8..a4931919 100644
--- a/tests/PhpWord/Writer/Word2007/Element/ChartTest.php
+++ b/tests/PhpWord/Writer/Word2007/Element/ChartTest.php
@@ -113,7 +113,7 @@ class ChartTest extends \PHPUnit\Framework\TestCase
for ($idxp1 = 1; $idxp1 < $numColor; ++$idxp1) {
$idx = $idxp1; // stacked bar chart is shifted
$element = $path . "/c:ser/c:dPt[$idxp1]/c:spPr/a:solidFill/a:srgbClr";
- self::assertEquals($colorArray[$idx], $doc->getElementAttribute($element, 'val'), "bar chart idx=$idx");
+ self::assertEquals($colorArray[$idx-1], $doc->getElementAttribute($element, 'val'), "bar chart idx=$idx");
}
}
From 1168789e8a55e2564cbc02236b23cf69cb0c1504 Mon Sep 17 00:00:00 2001
From: Antoine de Troostembergh
Date: Sat, 6 Feb 2021 21:32:30 +0100
Subject: [PATCH 116/139] fix formatting
---
docs/templates-processing.rst | 17 +++++++++++---
samples/Sample_41_TemplateSetChart.php | 26 +++++++++++-----------
src/PhpWord/TemplateProcessor.php | 4 ++--
src/PhpWord/Writer/Word2007/Part/Chart.php | 6 ++---
tests/PhpWord/TemplateProcessorTest.php | 2 +-
5 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/docs/templates-processing.rst b/docs/templates-processing.rst
index 9166890e..7d0ef2e6 100644
--- a/docs/templates-processing.rst
+++ b/docs/templates-processing.rst
@@ -249,9 +249,20 @@ See ``Sample_40_TemplateSetComplexValue.php`` for examples.
$table->addCell(150)->addText('Cell B2');
$table->addCell(150)->addText('Cell B3');
$templateProcessor->setComplexBlock('table', $table);
-
+
+setChartValue
+"""""""""""""
+Replace a variable by a chart.
+
+.. code-block:: php
+
+ $categories = array('A', 'B', 'C', 'D', 'E');
+ $series1 = array(1, 3, 2, 5, 4);
+ $chart = new Chart('doughnut', $categories, $series1);
+ $templateProcessor->setChartValue('myChart', $chart);
+
save
-"""""""""
+""""
Saves the loaded template within the current directory. Returns the file path.
.. code-block:: php
@@ -259,7 +270,7 @@ Saves the loaded template within the current directory. Returns the file path.
$filepath = $templateProcessor->save();
saveAs
-"""""""""
+""""""
Saves a copy of the loaded template in the indicated path.
.. code-block:: php
diff --git a/samples/Sample_41_TemplateSetChart.php b/samples/Sample_41_TemplateSetChart.php
index 102fa3ac..2b017d7f 100644
--- a/samples/Sample_41_TemplateSetChart.php
+++ b/samples/Sample_41_TemplateSetChart.php
@@ -17,23 +17,23 @@ $series1 = array(1, 3, 2, 5, 4);
$series2 = array(3, 1, 7, 2, 6);
$series3 = array(8, 3, 2, 5, 4);
-$i=0;
+$i = 0;
foreach ($chartTypes as $chartType) {
- $chart = new Chart($chartType, $categories, $series1);
+ $chart = new Chart($chartType, $categories, $series1);
- if (in_array($chartType, $twoSeries)) {
- $chart->addSeries($categories, $series2);
- }
- if (in_array($chartType, $threeSeries)) {
- $chart->addSeries($categories, $series3);
- }
+ if (in_array($chartType, $twoSeries)) {
+ $chart->addSeries($categories, $series2);
+ }
+ if (in_array($chartType, $threeSeries)) {
+ $chart->addSeries($categories, $series3);
+ }
- $chart->getStyle()
- ->setWidth(Converter::inchToEmu(3))
- ->setHeight(Converter::inchToEmu(3));
+ $chart->getStyle()
+ ->setWidth(Converter::inchToEmu(3))
+ ->setHeight(Converter::inchToEmu(3));
- $templateProcessor->setChart("chart{$i}", $chart);
- $i++;
+ $templateProcessor->setChart("chart{$i}", $chart);
+ $i++;
}
echo date('H:i:s'), ' Saving the result document...', EOL;
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index f67bc1cd..2d4ab2be 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -365,12 +365,12 @@ class TemplateProcessor
$objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $elementName;
// Get the next relation id
- $rId= $this->getNextRelationsIndex($this->getMainPartName());
+ $rId = $this->getNextRelationsIndex($this->getMainPartName());
$chart->setRelationId($rId);
// Define the chart filename
$filename = "charts/chart{$rId}.xml";
-
+
// Get the part writer
$writerPart = new \PhpOffice\PhpWord\Writer\Word2007\Part\Chart();
$writerPart->setElement($chart);
diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php
index 705a5c28..168f0216 100644
--- a/src/PhpWord/Writer/Word2007/Part/Chart.php
+++ b/src/PhpWord/Writer/Word2007/Part/Chart.php
@@ -267,10 +267,10 @@ class Chart extends AbstractPart
$this->writeSeriesItem($xmlWriter, 'val', $values);
// check that there are colors
- if (is_array($colors) && count($colors)>0) {
+ if (is_array($colors) && count($colors) > 0) {
// assign a color to each value
- $valueIndex=0;
- foreach ($values as $value) {
+ $valueIndex = 0;
+ for ($i = 1; $i < count($values); $i++) {
// check that there are still enought colors
$xmlWriter->startElement('c:dPt');
$xmlWriter->writeElementBlock('c:idx', 'val', $valueIndex);
diff --git a/tests/PhpWord/TemplateProcessorTest.php b/tests/PhpWord/TemplateProcessorTest.php
index 852bf687..391daa2d 100644
--- a/tests/PhpWord/TemplateProcessorTest.php
+++ b/tests/PhpWord/TemplateProcessorTest.php
@@ -401,7 +401,7 @@ final class TemplateProcessorTest extends \PHPUnit\Framework\TestCase
return $imagePath;
},
'documentContent' => array('path' => $imagePath, 'width' => 500, 'height' => 500),
- 'footerValue' => array('path' => $imagePath, 'width' => 100, 'height' => 50, 'ratio' => false),
+ 'footerValue' => array('path' => $imagePath, 'width' => 100, 'height' => 50, 'ratio' => false),
);
$templateProcessor->setImageValue(array_keys($variablesReplace), $variablesReplace);
From 31259f6448c943e126654ca0ebf86900735b35c7 Mon Sep 17 00:00:00 2001
From: Antoine de Troostembergh
Date: Sat, 6 Feb 2021 22:12:19 +0100
Subject: [PATCH 117/139] fix
---
src/PhpWord/Writer/Word2007/Part/Chart.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php
index 168f0216..e0d1752b 100644
--- a/src/PhpWord/Writer/Word2007/Part/Chart.php
+++ b/src/PhpWord/Writer/Word2007/Part/Chart.php
@@ -270,7 +270,7 @@ class Chart extends AbstractPart
if (is_array($colors) && count($colors) > 0) {
// assign a color to each value
$valueIndex = 0;
- for ($i = 1; $i < count($values); $i++) {
+ for ($i = 0; $i < count($values); $i++) {
// check that there are still enought colors
$xmlWriter->startElement('c:dPt');
$xmlWriter->writeElementBlock('c:idx', 'val', $valueIndex);
From dc9b1edb5b39ff308f4ede2e729fbc57e96122fd Mon Sep 17 00:00:00 2001
From: troosan
Date: Sat, 6 Feb 2021 22:50:11 +0100
Subject: [PATCH 118/139] fix formatting
---
tests/PhpWord/Writer/Word2007/Element/ChartTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/PhpWord/Writer/Word2007/Element/ChartTest.php b/tests/PhpWord/Writer/Word2007/Element/ChartTest.php
index a4931919..a69838a9 100644
--- a/tests/PhpWord/Writer/Word2007/Element/ChartTest.php
+++ b/tests/PhpWord/Writer/Word2007/Element/ChartTest.php
@@ -113,7 +113,7 @@ class ChartTest extends \PHPUnit\Framework\TestCase
for ($idxp1 = 1; $idxp1 < $numColor; ++$idxp1) {
$idx = $idxp1; // stacked bar chart is shifted
$element = $path . "/c:ser/c:dPt[$idxp1]/c:spPr/a:solidFill/a:srgbClr";
- self::assertEquals($colorArray[$idx-1], $doc->getElementAttribute($element, 'val'), "bar chart idx=$idx");
+ self::assertEquals($colorArray[$idx - 1], $doc->getElementAttribute($element, 'val'), "bar chart idx=$idx");
}
}
From 26e479422abda292e255e98aef41b93a900362d9 Mon Sep 17 00:00:00 2001
From: troosan
Date: Sun, 7 Feb 2021 15:06:01 +0100
Subject: [PATCH 119/139] Fix formatting
---
src/PhpWord/TemplateProcessor.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 5973dd88..534f8d60 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -610,8 +610,8 @@ class TemplateProcessor
// replace on each iteration, because in one tag we can have 2+ inline variables => before proceed next variable we need to change $partContent
$partContent = $this->setValueForPart($wholeTag, $replaceXml, $partContent, $limit);
}
- $i++;
- if($i >= $limit) {
+
+ if (++$i >= $limit) {
break;
}
}
From 486321bb02c67c7ddc717df3c847cf1d620adc64 Mon Sep 17 00:00:00 2001
From: troosan
Date: Mon, 8 Feb 2021 00:58:00 +0100
Subject: [PATCH 120/139] Compatibility with old PHP versions
---
src/PhpWord/Shared/Html.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index 244e4aa5..1bd29833 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -284,7 +284,7 @@ class Html
$inputType = $attributes->getNamedItem('type')->value;
switch ($inputType) {
case 'checkbox':
- $checked = ($checked = $attributes->getNamedItem('checked')) && $checked->value === "true" ?? false;
+ $checked = ($checked = $attributes->getNamedItem('checked')) && $checked->value === "true" ? true ? false;
$textrun = $element->addTextRun();
$textrun->addFormField('checkbox')->setValue($checked);
break;
From cba1edc9e8c7297a2ebc1b689e6ac4350cc73cf8 Mon Sep 17 00:00:00 2001
From: troosan
Date: Mon, 8 Feb 2021 00:59:44 +0100
Subject: [PATCH 121/139] remove trailing whitespaces
---
tests/PhpWord/Shared/HtmlTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php
index a6f0b3b6..c12f33ac 100644
--- a/tests/PhpWord/Shared/HtmlTest.php
+++ b/tests/PhpWord/Shared/HtmlTest.php
@@ -636,12 +636,12 @@ class HtmlTest extends AbstractWebServerEmbeddedTest
/**
* Tests checkbox input field
*/
- public function testInputCheckbox()
+ public function testInputCheckbox()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$html = '';
- Html::addHtml($section, $html);
+ Html::addHtml($section, $html);
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
From 264f1590f0991b8f9ebe7039df52fd6073196023 Mon Sep 17 00:00:00 2001
From: troosan
Date: Mon, 8 Feb 2021 22:08:29 +0100
Subject: [PATCH 122/139] make xmlReplaceBlock public
---
src/PhpWord/TemplateProcessor.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index a3ef6d2d..649fde40 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -1182,7 +1182,7 @@ class TemplateProcessor
* @param string $blockType XML tag type of block
* @return \PhpOffice\PhpWord\TemplateProcessor Fluent interface
*/
- protected function replaceXmlBlock($macro, $block, $blockType = 'w:p')
+ public function replaceXmlBlock($macro, $block, $blockType = 'w:p')
{
$where = $this->findContainingXmlBlockForMacro($macro, $blockType);
if (is_array($where)) {
From 1c3fdd27198bdd86d206fd73d234577c12799506 Mon Sep 17 00:00:00 2001
From: troosan
Date: Mon, 8 Feb 2021 22:12:24 +0100
Subject: [PATCH 123/139] prepare release 0.18.0
---
CHANGELOG.md | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5d55fa2b..49418710 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,50 @@ Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
+v0.18.0 (08 feb 2021)
+----------------------
+### Added
+- allow to use customized pdf library [\#1983](https://github.com/PHPOffice/PHPWord/pull/1983) ([SailorMax](https://github.com/SailorMax))
+- Add parsing of Shape node values [\#1924](https://github.com/PHPOffice/PHPWord/pull/1924) ([sven-ahrens](https://github.com/sven-ahrens))
+- Allow to redefine TCPDF object [\#1907](https://github.com/PHPOffice/PHPWord/pull/1907) ([SailorMax](https://github.com/SailorMax))
+- Make Default Paper Configurable [\#1851](https://github.com/PHPOffice/PHPWord/pull/1851) ([oleibman](https://github.com/oleibman))
+- Implement various missing features for the ODT writer [\#1796](https://github.com/PHPOffice/PHPWord/pull/1796) ([oleibman](https://github.com/oleibman))
+- Add support for several features for the RTF writer [\#1775](https://github.com/PHPOffice/PHPWord/pull/1775) ([oleibman](https://github.com/oleibman))
+- Improvements in RTF writer [\#1755](https://github.com/PHPOffice/PHPWord/pull/1755) ([oleibman](https://github.com/oleibman))
+- Add font style for Field elements [\#1774](https://github.com/PHPOffice/PHPWord/pull/1774) ([oleibman](https://github.com/oleibman))
+- Added support for "cloudConvert" images [\#1794](https://github.com/PHPOffice/PHPWord/pull/1794) ([ErnestStaug](https://github.com/ErnestStaug))
+- Add support for ListItemRun in HTML writer [\#1766](https://github.com/PHPOffice/PHPWord/pull/1766) ([stefan-91](https://github.com/stefan-91))
+- Allow a closure to be passed with image replacement tags [\#1716](https://github.com/PHPOffice/PHPWord/pull/1716) ([mbardelmeijer](https://github.com/mbardelmeijer))
+- Add support for charts in template processor [\#2012](https://github.com/PHPOffice/PHPWord/pull/2012) ([dbarzin](https://github.com/dbarzin))
+- Update addHtml to handle style inheritance [\#1965](https://github.com/PHPOffice/PHPWord/pull/1965) ([Julien1138](https://github.com/Julien1138))
+- Add parsing of HTML checkbox input field [\#1832](https://github.com/PHPOffice/PHPWord/pull/1832) ([Matze2010](https://github.com/Matze2010))
+- Add Option for Dynamic Chart Legend Position [\#1922](https://github.com/PHPOffice/PHPWord/pull/1922) ([csk83](https://github.com/csk83))
+
+### Fixed
+- Add null check when setComplexValue is not found [\#1936](https://github.com/PHPOffice/PHPWord/pull/1936) ([YannikFirre](https://github.com/YannikFirre))
+- Fix image stroke in libreoffice 7.x [\#1992](https://github.com/PHPOffice/PHPWord/pull/1992) ([Adizbek](https://github.com/Adizbek))
+- Fix deprecated warning for non-hexadecimal number [\#1988](https://github.com/PHPOffice/PHPWord/pull/1988) ([Ciki](https://github.com/Ciki))
+- Fix typo in docs. Update templates-processing.rst [\#1952](https://github.com/PHPOffice/PHPWord/pull/1952) ([mnvx](https://github.com/mnvx))
+- Fixes PHPDoc @param and @return types for several Converter methods [\#1818](https://github.com/PHPOffice/PHPWord/pull/1818) ([caugner](https://github.com/caugner))
+- Fix documentation and method name for FootnoteProperties [\#1776](https://github.com/PHPOffice/PHPWord/pull/1776) ([mdupont](https://github.com/mdupont))
+- Fix PHPUnit tests on develop branch [\#1771](https://github.com/PHPOffice/PHPWord/pull/1771) ([mdupont](https://github.com/mdupont))
+- fix: documentation about paragraph indentation [\#1764](https://github.com/PHPOffice/PHPWord/pull/1764) ([mdupont](https://github.com/mdupont))
+- Update templates-processing.rst [\#1745](https://github.com/PHPOffice/PHPWord/pull/1745) ([igronus](https://github.com/igronus))
+- Update templates processing docs [\#1729](https://github.com/PHPOffice/PHPWord/pull/1729) ([hcdias](https://github.com/hcdias))
+- Fix limit not taken into account when adding image in template [\#1967](https://github.com/PHPOffice/PHPWord/pull/1967) ([jsochor](https://github.com/jsochor))
+- Fix cloneBlock issue [\#2006](https://github.com/PHPOffice/PHPWord/pull/2006) ([lexdewilligen](https://github.com/lexdewilligen))
+- TemplateProcessor cloneBlock wrongly clones images [\#1763](https://github.com/PHPOffice/PHPWord/pull/1763) ([alarai](https://github.com/alarai))
+- Some document have non-standard locale code [\#1824](https://github.com/PHPOffice/PHPWord/pull/1824) ([ErnestStaug](https://github.com/ErnestStaug))
+- Update the regexp to avoid catastrophic backtracking [\#1809](https://github.com/PHPOffice/PHPWord/pull/1809) ([juzser](https://github.com/juzser))
+
+### Miscellaneous
+- Compatibility with PHP 7.4, PHP 8.0 and migrate to Laminas Escaper [\#1946](https://github.com/PHPOffice/PHPWord/pull/1946) ([liborm85](https://github.com/liborm85))
+- Remove legacy PHPOffice/Common package, fix PHP 8.0 compatibility [\#1996](https://github.com/PHPOffice/PHPWord/pull/1996) ([liborm85](https://github.com/liborm85))
+- Improve Word2007 Test Coverage [\#1858](https://github.com/PHPOffice/PHPWord/pull/1858) ([oleibman](https://github.com/oleibman))
+- Add unit test for NumberingStyle [\#1744](https://github.com/PHPOffice/PHPWord/pull/1744) ([Manunchik](https://github.com/Manunchik))
+- Add unit test for PhpWord Settings [\#1743](https://github.com/PHPOffice/PHPWord/pull/1743) ([Manunchik](https://github.com/Manunchik))
+- Add unit test for Media elements [\#1742](https://github.com/PHPOffice/PHPWord/pull/1742) ([Manunchik](https://github.com/Manunchik))
+
v0.17.0 (01 oct 2019)
----------------------
### Added
From b2585dfd288f8f46dfe0b5d903bd6ba488509066 Mon Sep 17 00:00:00 2001
From: troosan
Date: Mon, 8 Feb 2021 22:20:00 +0100
Subject: [PATCH 124/139] move constants to simpleType
---
src/PhpWord/SimpleType/Border.php | 58 +++++++++++++++++++++++++++++++
src/PhpWord/Style/Border.php | 35 -------------------
2 files changed, 58 insertions(+), 35 deletions(-)
create mode 100644 src/PhpWord/SimpleType/Border.php
diff --git a/src/PhpWord/SimpleType/Border.php b/src/PhpWord/SimpleType/Border.php
new file mode 100644
index 00000000..a73c7b4a
--- /dev/null
+++ b/src/PhpWord/SimpleType/Border.php
@@ -0,0 +1,58 @@
+
Date: Mon, 8 Feb 2021 22:40:46 +0100
Subject: [PATCH 125/139] Make syntax php 5.3 compliant
---
tests/PhpWord/Shared/HtmlTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php
index 7a806c26..05e2398a 100644
--- a/tests/PhpWord/Shared/HtmlTest.php
+++ b/tests/PhpWord/Shared/HtmlTest.php
@@ -639,9 +639,9 @@ class HtmlTest extends AbstractWebServerEmbeddedTest
public function testParseTableAndCellWidth()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
- $section = $phpWord->addSection([
+ $section = $phpWord->addSection(array(
'orientation' => \PhpOffice\PhpWord\Style\Section::ORIENTATION_LANDSCAPE,
- ]);
+ ));
// borders & backgrounds are here just for better visual comparison
$html = <<
Date: Mon, 8 Feb 2021 22:58:14 +0100
Subject: [PATCH 126/139] fix code formatting
---
src/PhpWord/Shared/Html.php | 48 +++++++++++++++----------------
tests/PhpWord/Shared/HtmlTest.php | 32 ++++++++++-----------
2 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index 6fa2a64d..ac90b5f0 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -115,7 +115,7 @@ class Html
// tables, cells
if (false !== strpos($val, '%')) {
// e.g.