From 4105a9aad1bd8e08cd3e7d5a74810a9e73f80fd4 Mon Sep 17 00:00:00 2001 From: Nicolas Dermine Date: Fri, 2 Feb 2018 16:19:21 +0100 Subject: [PATCH 01/40] improve `cloneBlock` regex it wrongly matched `\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', + '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', $this->tempDocumentMainPart, $matches ); diff --git a/tests/PhpWord/TemplateProcessorTest.php b/tests/PhpWord/TemplateProcessorTest.php index 7b064ef7b8..122ed5b613 100644 --- a/tests/PhpWord/TemplateProcessorTest.php +++ b/tests/PhpWord/TemplateProcessorTest.php @@ -223,4 +223,56 @@ public function testCloneDeleteBlock() unlink($docName); $this->assertTrue($docFound); } + + /** + * @covers ::cloneBlock + * @test + */ + public function cloneBlockCanCloneABlockTwice() + { + // create template with placeholders and block + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + $documentElements = array( + 'Title: ${title}', + '${subreport}', + '${subreport.id}: ${subreport.text}. ', + '${/subreport}', + ); + foreach ($documentElements as $documentElement) { + $section->addText($documentElement); + } + $objWriter = IOFactory::createWriter($phpWord); + $templatePath = 'test.docx'; + $objWriter->save($templatePath); + + // replace placeholders and save the file + $templateProcessor = new TemplateProcessor($templatePath); + $templateProcessor->setValue('title', 'Some title'); + $templateProcessor->cloneBlock('subreport', 2); + $templateProcessor->setValue('subreport.id', '123', 1); + $templateProcessor->setValue('subreport.text', 'Some text', 1); + $templateProcessor->setValue('subreport.id', '456', 1); + $templateProcessor->setValue('subreport.text', 'Some other text', 1); + $templateProcessor->saveAs($templatePath); + + // assert the block has been cloned twice + // and the placeholders have been replaced correctly + $phpWord = IOFactory::load($templatePath); + $sections = $phpWord->getSections(); + $actualElements = $sections[0]->getElements(); + unlink($templatePath); + $expectedElements = array( + 'Title: Some title', + '123: Some text. ', + '456: Some other text. ', + ); + $this->assertCount(count($expectedElements), $actualElements); + foreach ($expectedElements as $i => $expectedElement) { + $this->assertEquals( + $expectedElement, + $actualElements[$i]->getText() + ); + } + } } From 0c3eb4bafc9b28313fb31c48c6bfc958a362b47f Mon Sep 17 00:00:00 2001 From: Tom-Magill <41332981+Tom-Magill@users.noreply.github.com> Date: Tue, 17 Jul 2018 14:10:02 +0100 Subject: [PATCH 02/40] Update Chart.php --- src/PhpWord/Style/Chart.php | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/PhpWord/Style/Chart.php b/src/PhpWord/Style/Chart.php index 5b02e63631..5c96afd25d 100644 --- a/src/PhpWord/Style/Chart.php +++ b/src/PhpWord/Style/Chart.php @@ -51,6 +51,20 @@ class Chart extends AbstractStyle * @var array */ private $colors = array(); + + /** + * Chart title + * + * @var string + */ + private $title = null; + + /** + * Chart legend visibility + * + * @var bool + */ + private $showLegend = false; /** * A list of display options for data labels @@ -220,6 +234,50 @@ public function setColors($value = array()) return $this; } + + /** + * Get the chart title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set the chart title + * + * @param string $value + */ + public function setTitle($value = null) + { + $this->title = $value; + + return $this; + } + + /** + * Get chart legend visibility + * + * @return bool + */ + public function getShowLegend() + { + return $this->showLegend; + } + + /** + * Set chart legend visibility + * + * @param bool $value + */ + public function setShowLegend($value = false) + { + $this->showLegend = $value; + + return $this; + } /* * Show labels for axis From 139242612d750f0258472cf0bbc1f7044610785d Mon Sep 17 00:00:00 2001 From: Tom-Magill <41332981+Tom-Magill@users.noreply.github.com> Date: Tue, 17 Jul 2018 14:11:55 +0100 Subject: [PATCH 03/40] Update Chart.php --- src/PhpWord/Writer/Word2007/Part/Chart.php | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php index 5a3ef27678..e14a708be8 100644 --- a/src/PhpWord/Writer/Word2007/Part/Chart.php +++ b/src/PhpWord/Writer/Word2007/Part/Chart.php @@ -105,8 +105,6 @@ private function writeChart(XMLWriter $xmlWriter) { $xmlWriter->startElement('c:chart'); - $xmlWriter->writeElementBlock('c:autoTitleDeleted', 'val', 1); - $this->writePlotArea($xmlWriter); $xmlWriter->endElement(); // c:chart @@ -130,6 +128,36 @@ private function writePlotArea(XMLWriter $xmlWriter) $type = $this->element->getType(); $style = $this->element->getStyle(); $this->options = $this->types[$type]; + + $title = $style->getTitle(); + $showLegend = $style->getShowLegend(); + + //Chart title + if($title){ + $xmlWriter->startElement('c:title'); + $xmlWriter->startElement('c:tx'); + $xmlWriter->startElement('c:rich'); + $xmlWriter->writeRaw(' + + + + + '.$title.' + + '); + + $xmlWriter->endElement(); // c:rich + $xmlWriter->endElement(); // c:tx + $xmlWriter->endElement(); // c:title + + }else{ + $xmlWriter->writeElementBlock('c:autoTitleDeleted', 'val', 1); + } + + //Chart legend + if($showLegend){ + $xmlWriter->writeRaw(''); + } $xmlWriter->startElement('c:plotArea'); $xmlWriter->writeElement('c:layout'); From 8c62cea580e5d9aa7b5c496ccad98114b7466422 Mon Sep 17 00:00:00 2001 From: Humberto Pereira Date: Tue, 17 Jul 2018 21:10:53 -0400 Subject: [PATCH 04/40] Fix Writer losing text when Title contains a TextRun instead a string. --- src/PhpWord/Writer/HTML/Element/Title.php | 2 +- tests/PhpWord/Writer/HTML/ElementTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php index 7307ce0c17..04ed61f57d 100644 --- a/src/PhpWord/Writer/HTML/Element/Title.php +++ b/src/PhpWord/Writer/HTML/Element/Title.php @@ -45,7 +45,7 @@ public function write() $text = $this->escaper->escapeHtml($text); } } elseif ($text instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { - $writer = new Container($this->parentWriter, $this->element); + $writer = new Container($this->parentWriter, $text); $text = $writer->write(); } diff --git a/tests/PhpWord/Writer/HTML/ElementTest.php b/tests/PhpWord/Writer/HTML/ElementTest.php index b76ddded5d..7a6397ef8c 100644 --- a/tests/PhpWord/Writer/HTML/ElementTest.php +++ b/tests/PhpWord/Writer/HTML/ElementTest.php @@ -18,6 +18,7 @@ namespace PhpOffice\PhpWord\Writer\HTML; use PhpOffice\PhpWord\Element\Text as TextElement; +use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\TrackChange; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Writer\HTML; @@ -138,4 +139,22 @@ private function getAsHTML(PhpWord $phpWord) return $dom; } + + public function testWriteTitleTextRun() + { + $expected = 'Title with TextRun'; + + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + + $textRun = new TextRun(); + $textRun->addText($expected); + + $section->addTitle($textRun); + + $htmlWriter = new HTML($phpWord); + $content = $htmlWriter->getContent(); + + $this->assertTrue(strpos($content, $expected) !== false); + } } From e07c6559a9d1bdac676f00e2c290cb2c99e1a7e0 Mon Sep 17 00:00:00 2001 From: troosan Date: Thu, 19 Jul 2018 00:52:22 +0200 Subject: [PATCH 05/40] adapt test --- tests/PhpWord/TemplateProcessorTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/PhpWord/TemplateProcessorTest.php b/tests/PhpWord/TemplateProcessorTest.php index 770428cb69..ea7395610d 100644 --- a/tests/PhpWord/TemplateProcessorTest.php +++ b/tests/PhpWord/TemplateProcessorTest.php @@ -260,6 +260,7 @@ public function cloneBlockCanCloneABlockTwice() // and the placeholders have been replaced correctly $phpWord = IOFactory::load($templatePath); $sections = $phpWord->getSections(); + /** @var \PhpOffice\PhpWord\Element\TextRun[] $actualElements */ $actualElements = $sections[0]->getElements(); unlink($templatePath); $expectedElements = array( @@ -271,7 +272,7 @@ public function cloneBlockCanCloneABlockTwice() foreach ($expectedElements as $i => $expectedElement) { $this->assertEquals( $expectedElement, - $actualElements[$i]->getText() + $actualElements[$i]->getElement(0)->getText() ); } } From 1951db58c18e6a0492db5a1b46dd5963c12b052f Mon Sep 17 00:00:00 2001 From: troosan Date: Thu, 19 Jul 2018 01:16:25 +0200 Subject: [PATCH 06/40] update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a166345cba..d822357cbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +v0.16.0 (xx xxx 2018) +---------------------- +### Added + +### Fixed +- Fix regex in `cloneBlock` function @nicoder #1269 + v0.15.0 (14 Jul 2018) ---------------------- ### Added From d09da0b6f23b5bde65ced648377190291c2b9535 Mon Sep 17 00:00:00 2001 From: troosan Date: Thu, 19 Jul 2018 02:01:40 +0200 Subject: [PATCH 07/40] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d822357cbd..abf3483418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ v0.16.0 (xx xxx 2018) ### Fixed - Fix regex in `cloneBlock` function @nicoder #1269 +- HTML Title Writer loses text when Title contains a TextRun instead a string. @begnini #1436 v0.15.0 (14 Jul 2018) ---------------------- From e61c40e71d8670d3334afeb6e2478d8ee8ef1325 Mon Sep 17 00:00:00 2001 From: Abubakkar Rangara <> Date: Tue, 24 Jul 2018 13:59:16 +0100 Subject: [PATCH 08/40] Adding table layout to the generated HTML if element has layout style. This is useful when using creating PDF from PHPWord (e.g. using dompdf), otherwise the PDF does not contain any layout for table. --- src/PhpWord/Writer/HTML/Element/Table.php | 4 +++- tests/PhpWord/Writer/HTML/ElementTest.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index 844066f49e..068f489af6 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -39,7 +39,9 @@ public function write() $rows = $this->element->getRows(); $rowCount = count($rows); if ($rowCount > 0) { - $content .= '' . PHP_EOL; + $tableStyle = $this->element->getStyle(); + $tableLayout = $tableStyle === null ? '' : $tableStyle->getLayout(); + $content .= ''. PHP_EOL; for ($i = 0; $i < $rowCount; $i++) { /** @var $row \PhpOffice\PhpWord\Element\Row Type hint */ $rowStyle = $rows[$i]->getStyle(); diff --git a/tests/PhpWord/Writer/HTML/ElementTest.php b/tests/PhpWord/Writer/HTML/ElementTest.php index 7a6397ef8c..1f286c5fe1 100644 --- a/tests/PhpWord/Writer/HTML/ElementTest.php +++ b/tests/PhpWord/Writer/HTML/ElementTest.php @@ -157,4 +157,23 @@ public function testWriteTitleTextRun() $this->assertTrue(strpos($content, $expected) !== false); } + + /** + * Tests writing table with layout + */ + public function testWriteTableLayout() + { + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + $section->addTable(); + $table = $section->addTable(array('layout' => 'fixed')); + + $row1 = $table->addRow(); + $row1->addCell()->addText('fixed layout table'); + + $dom = $this->getAsHTML($phpWord); + $xpath = new \DOMXPath($dom); + + $this->assertEquals('table-layout: fixed', $xpath->query('/html/body/table')->item(0)->attributes->getNamedItem('style')->textContent); + } } From 4b9ae18d5aefee34bb631b96a752dfca6be56b4d Mon Sep 17 00:00:00 2001 From: Abubakkar Rangara <> Date: Tue, 24 Jul 2018 14:23:23 +0100 Subject: [PATCH 09/40] Adding table layout to the generated HTML - fixed php-cs-fixer error --- 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 068f489af6..50c5a7775f 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -41,7 +41,7 @@ public function write() if ($rowCount > 0) { $tableStyle = $this->element->getStyle(); $tableLayout = $tableStyle === null ? '' : $tableStyle->getLayout(); - $content .= ''. PHP_EOL; + $content .= '' . PHP_EOL; for ($i = 0; $i < $rowCount; $i++) { /** @var $row \PhpOffice\PhpWord\Element\Row Type hint */ $rowStyle = $rows[$i]->getStyle(); From 677e3f6a19bcd5d3f4a81e6a0059bbce773e8ee7 Mon Sep 17 00:00:00 2001 From: Maxim Bulygin Date: Tue, 31 Jul 2018 18:25:29 +0300 Subject: [PATCH 10/40] writer / word2007 / support valign and watermark withouth paragraph --- src/PhpWord/Writer/Word2007/Element/Image.php | 8 ++++++-- src/PhpWord/Writer/Word2007/Style/Frame.php | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index 3614ec184f..5bebb89c05 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -103,7 +103,9 @@ private function writeWatermark(XMLWriter $xmlWriter, ImageElement $element) $style->setPositioning('absolute'); $styleWriter = new ImageStyleWriter($xmlWriter, $style); - $xmlWriter->startElement('w:p'); + if (!$this->withoutP) { + $xmlWriter->startElement('w:p'); + } $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:pict'); $xmlWriter->startElement('v:shape'); @@ -118,6 +120,8 @@ private function writeWatermark(XMLWriter $xmlWriter, ImageElement $element) $xmlWriter->endElement(); // v:shape $xmlWriter->endElement(); // w:pict $xmlWriter->endElement(); // w:r - $xmlWriter->endElement(); // w:p + if (!$this->withoutP) { + $xmlWriter->endElement(); // w:p + } } } diff --git a/src/PhpWord/Writer/Word2007/Style/Frame.php b/src/PhpWord/Writer/Word2007/Style/Frame.php index ea5abf780a..10e5b151f7 100644 --- a/src/PhpWord/Writer/Word2007/Style/Frame.php +++ b/src/PhpWord/Writer/Word2007/Style/Frame.php @@ -61,6 +61,7 @@ public function write() 'hPos' => 'mso-position-horizontal', 'vPos' => 'mso-position-vertical', 'hPosRelTo' => 'mso-position-horizontal-relative', + 'vPosRelTo' => 'mso-position-vertical-relative', ); $posStyles = $this->getStyles($style, $properties); From 683d91990ff53f46c2ad3dd8ceaeeffc28a62ce1 Mon Sep 17 00:00:00 2001 From: vblinden Date: Mon, 3 Sep 2018 12:30:05 +0200 Subject: [PATCH 11/40] Added Dutch (nl-NL) --- src/PhpWord/Style/Language.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PhpWord/Style/Language.php b/src/PhpWord/Style/Language.php index d7a76f78f3..8a3b0315de 100644 --- a/src/PhpWord/Style/Language.php +++ b/src/PhpWord/Style/Language.php @@ -64,6 +64,9 @@ final class Language extends AbstractStyle const PT_BR = 'pt-BR'; const PT_BR_ID = 1046; + + const NL_NL = 'nl-NL'; + const NL_NL_ID = 1043; /** * Language ID, used for RTF document generation From d8c0441975e2032ba86bb82ecdfc754d15c92cd9 Mon Sep 17 00:00:00 2001 From: vblinden Date: Mon, 3 Sep 2018 13:32:00 +0200 Subject: [PATCH 12/40] Fix indenting --- src/PhpWord/Style/Language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Style/Language.php b/src/PhpWord/Style/Language.php index 8a3b0315de..412a76a744 100644 --- a/src/PhpWord/Style/Language.php +++ b/src/PhpWord/Style/Language.php @@ -64,7 +64,7 @@ final class Language extends AbstractStyle const PT_BR = 'pt-BR'; const PT_BR_ID = 1046; - + const NL_NL = 'nl-NL'; const NL_NL_ID = 1043; From 7f55816ebaa2777cefd759f6628e7753c91e0faf Mon Sep 17 00:00:00 2001 From: Martin Hanzl Date: Thu, 11 Oct 2018 08:55:38 +0200 Subject: [PATCH 13/40] detect actual filename of document xml (prevent mismatching document22.xml as in #1253) --- src/PhpWord/TemplateProcessor.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 7a5eaf55bb..86c9e1c99b 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -507,7 +507,13 @@ protected function getHeaderName($index) */ protected function getMainPartName() { - return 'word/document.xml'; + $contentTypes = $this->zipClass->getFromName('[Content_Types].xml'); + + $pattern = '~PartName="\/(word\/document.*?\.xml)" ContentType="application\/vnd\.openxmlformats-officedocument\.wordprocessingml\.document\.main\+xml"~'; + + preg_match($pattern, $contentTypes, $m); + + return (array_key_exists(1, $m) ? $m[1] : 'word/document.xml'); } /** From 7eb19c8f76c6a0a4ba56bc779d3f6024dc172822 Mon Sep 17 00:00:00 2001 From: Martin Hanzl Date: Thu, 11 Oct 2018 09:40:12 +0200 Subject: [PATCH 14/40] add test case for issue #1253 --- tests/PhpWord/TemplateProcessorTest.php | 10 ++++++++++ .../_files/templates/document22-xml.docx | Bin 0 -> 11126 bytes 2 files changed, 10 insertions(+) create mode 100644 tests/PhpWord/_files/templates/document22-xml.docx diff --git a/tests/PhpWord/TemplateProcessorTest.php b/tests/PhpWord/TemplateProcessorTest.php index ea7395610d..2b3a9fd19c 100644 --- a/tests/PhpWord/TemplateProcessorTest.php +++ b/tests/PhpWord/TemplateProcessorTest.php @@ -276,4 +276,14 @@ public function cloneBlockCanCloneABlockTwice() ); } } + + public function testMainPartNameDetection() + { + $templatePath = 'templates/document22-xml.docx'; + $templateProcessor = new TemplateProcessor($templatePath); + + $variables = array('test'); + + $this->assertEquals($variables, $templateProcessor->getVariables()); + } } diff --git a/tests/PhpWord/_files/templates/document22-xml.docx b/tests/PhpWord/_files/templates/document22-xml.docx new file mode 100644 index 0000000000000000000000000000000000000000..206d80f46063d4f9ec4594b191bbd6f493879b8e GIT binary patch literal 11126 zcmeHtWmH_t)@|eNjT1s}cW(&p65L$^1b27WK+_N)I01rNaF+zPAi*IJJOp=paLzq9 z$@$K^@BP2u9%Jv(yQ=1@+Er^-RnJ;Vaxkz!06YK@z``e|a06?grT_&15W@igH~>Uw zT`_w*7jruoLp4tab7y^K4_h0uTv%w@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%O^8t)`OG&+4Bxhp=>oG$V(*DXn|P{(ivucC3#&`1@X zEPS0bl*db|i=53Gwp-jT(*=X&)R`G-EMSf5QzW)ZY$Y_p)+ROYFhtyeG1Q4)S0F1! z>}TPo?sv>V8Ao^9n=;d&*_1c6J7%Z5S?g1j+^zz%I|$hwoF_i*`*R`dl}}?zT9trz z{N$9O?8vIBLQJW?ozsn2to^NiuA1YFJY@}dpCWRT2xVR?ItSrE$Fd&DvEg=+M9zMK zm>fe)J2~Ii_OKPP@SWCoW#pcHfOWr?*3Ob?HOAS zel7lRD)i(p_y04v=Qk4kE7IpbFkwREG4={>tVFAZMp0G-acVD2p`HrgA;S?nVJ6u^ zc6(OKfwDXRmr`wlysG~bc+&{CzMODTk6Y^j*|l5iDT+nA4SNYvBfn|rdXc_Mtv$bAlX z^CGXlj_2aru(5crX4E>?`DkDI4Q%dom4pV_>*w5?$_ZW~HpFm_^9w=oHJ)1-sQQVF zFOv?eI^=pehk;Y+$coJu#B6Boqx5+T!!lJ%j%DZFaGNxJjD!8;HSLvm4+m;c&`b}C z>|=Q1V_?+p;fa5rA^ss)@$UwHkF5IDK-j~W{1RvNEAXGxM&Kd(DKp$|h& r`7iKq1pGVxcjEqvH=y|!{{Kc}B{{eU2YHO+LjiO@EPWZYk8l46F;eAv literal 0 HcmV?d00001 From e19de8e8a481ce3fb1aa84ff236952c22debb277 Mon Sep 17 00:00:00 2001 From: Martin Hanzl Date: Thu, 11 Oct 2018 11:28:44 +0200 Subject: [PATCH 15/40] #1253 - add explanatory comment --- src/PhpWord/TemplateProcessor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 86c9e1c99b..ced3880e65 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -503,6 +503,8 @@ protected function getHeaderName($index) } /** + * Usually, the name of main part document will be 'document.xml'. However, some .docx files (possibly those from Office 365, experienced also on documents from Word Online created from blank templates) have file 'document22.xml' in their zip archive instead of 'document.xml'. This method searches content types file to correctly determine the file name. + * * @return string */ protected function getMainPartName() From 28505b0b77573d9f36936bf481ff8aef11eeec3a Mon Sep 17 00:00:00 2001 From: Ralph02 Date: Thu, 25 Oct 2018 11:23:53 +0100 Subject: [PATCH 16/40] RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals --- src/PhpWord/Writer/RTF/Style/Section.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Writer/RTF/Style/Section.php b/src/PhpWord/Writer/RTF/Style/Section.php index 5c34fa8683..ee6efcf3a0 100644 --- a/src/PhpWord/Writer/RTF/Style/Section.php +++ b/src/PhpWord/Writer/RTF/Style/Section.php @@ -43,8 +43,8 @@ public function write() $content .= '\sectd '; // Size & margin - $content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . $style->getPageSizeW()); - $content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . $style->getPageSizeH()); + $content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . round($style->getPageSizeW())); + $content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . round($style->getPageSizeH())); $content .= ' '; $content .= $this->getValueIf($style->getMarginTop() !== null, '\margtsxn' . $style->getMarginTop()); $content .= $this->getValueIf($style->getMarginRight() !== null, '\margrsxn' . $style->getMarginRight()); From 54eb6e6f2cf73d9983b08d80e2da9de8311fd6bc Mon Sep 17 00:00:00 2001 From: Stefan Thoolen Date: Tue, 6 Nov 2018 14:24:56 +0100 Subject: [PATCH 17/40] Fix for undefined index PHP Notice: Undefined index: document in /home/stefan/Projects/garrcomm/PHPWord/src/PhpWord/Reader/Word2007.php on line 65 PHP Warning: Invalid argument supplied for foreach() in /home/stefan/Projects/garrcomm/PHPWord/src/PhpWord/Reader/Word2007.php on line 65 --- src/PhpWord/Reader/Word2007.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index deed3ce39c..52030ef8e0 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -62,6 +62,9 @@ public function load($docFile) foreach ($steps as $step) { $stepPart = $step['stepPart']; $stepItems = $step['stepItems']; + if (!isset($relationships[$stepPart])) { + continue; + } foreach ($relationships[$stepPart] as $relItem) { $relType = $relItem['type']; if (isset($stepItems[$relType])) { From 768a07071503cd24b8089f04899bc5f6d43bf61e Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Mon, 12 Nov 2018 08:02:15 +0100 Subject: [PATCH 18/40] add/align possible values from class constant --- docs/styles.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/styles.rst b/docs/styles.rst index 0336642722..8c5de7cb9d 100644 --- a/docs/styles.rst +++ b/docs/styles.rst @@ -29,6 +29,7 @@ Available Section style options: - ``marginRight``. Page margin right in *twip*. - ``marginBottom``. Page margin bottom in *twip*. - ``orientation``. Page orientation (``portrait``, which is default, or ``landscape``). + See ``\PhpOffice\PhpWord\Style\Section::ORIENTATION_...`` class constants for possible values - ``pageSizeH``. Page height in *twip*. Implicitly defined by ``orientation`` option. Any changes are discouraged. - ``pageSizeW``. Page width in *twip*. Implicitly defined by ``orientation`` option. Any changes are discouraged. @@ -45,7 +46,7 @@ Available Font style options: - ``color``. Font color, e.g. *FF0000*. - ``doubleStrikethrough``. Double strikethrough, *true* or *false*. - ``fgColor``. Font highlight color, e.g. *yellow*, *green*, *blue*. - See ``\PhpOffice\PhpWord\Style\Font::FGCOLOR_...`` constants for more values + See ``\PhpOffice\PhpWord\Style\Font::FGCOLOR_...`` class constants for possible values - ``hint``. Font content type, *default*, *eastAsia*, or *cs*. - ``italic``. Italic, *true* or *false*. - ``name``. Font name, e.g. *Arial*. @@ -56,7 +57,7 @@ Available Font style options: - ``subScript``. Subscript, *true* or *false*. - ``superScript``. Superscript, *true* or *false*. - ``underline``. Underline, *single*, *dash*, *dotted*, etc. - See ``\PhpOffice\PhpWord\Style\Font::UNDERLINE_...`` constants for more values + See ``\PhpOffice\PhpWord\Style\Font::UNDERLINE_...`` class constants for possible values - ``lang``. Language, either a language code like *en-US*, *fr-BE*, etc. or an object (or as an array) if you need to set eastAsian or bidirectional languages See ``\PhpOffice\PhpWord\Style\Language`` class for some language codes. - ``position``. The text position, raised or lowered, in half points @@ -69,7 +70,7 @@ Paragraph Available Paragraph style options: - ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012. - See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details. + See ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values. - ``basedOn``. Parent style. - ``hanging``. Hanging in *twip*. - ``indent``. Indent in *twip*. @@ -82,6 +83,7 @@ Available Paragraph style options: - ``spaceAfter``. Space after paragraph in *twip*. - ``spacing``. Space between lines. - ``spacingLineRule``. Line Spacing Rule. *auto*, *exact*, *atLeast* + See ``\PhpOffice\PhpWord\SimpleType\LineSpacingRule`` class constants for possible values. - ``suppressAutoHyphens``. Hyphenation for paragraph, *true* or *false*. - ``tabs``. Set of custom tab stops. - ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*. @@ -89,7 +91,7 @@ Available Paragraph style options: - ``bidi``. Right to Left Paragraph Layout, *true* or *false*. - ``shading``. Paragraph Shading. - ``textAlignment``. Vertical Character Alignment on Line. - See ``\PhpOffice\PhpWord\SimpleType\TextAlignment`` class for possible values. + See ``\PhpOffice\PhpWord\SimpleType\TextAlignment`` class constants for possible values. .. _table-style: @@ -99,7 +101,7 @@ Table Available Table style options: - ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012. - See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details. + See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values. - ``bgColor``. Background color, e.g. '9966CC'. - ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'. - ``border(Top|Right|Bottom|Left)Size``. Border size in *twip*. @@ -168,7 +170,7 @@ Numbering level Available NumberingLevel style options: - ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012. - See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details. + See ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values. - ``font``. Font name. - ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter. - ``hanging``. See paragraph style. From 9f28ece4e9b4d8c917135af05d58370c62a40287 Mon Sep 17 00:00:00 2001 From: troosan Date: Fri, 16 Nov 2018 22:40:37 +0100 Subject: [PATCH 19/40] Fix path to test document --- tests/PhpWord/TemplateProcessorTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/PhpWord/TemplateProcessorTest.php b/tests/PhpWord/TemplateProcessorTest.php index 2b3a9fd19c..1513486e49 100644 --- a/tests/PhpWord/TemplateProcessorTest.php +++ b/tests/PhpWord/TemplateProcessorTest.php @@ -279,8 +279,7 @@ public function cloneBlockCanCloneABlockTwice() public function testMainPartNameDetection() { - $templatePath = 'templates/document22-xml.docx'; - $templateProcessor = new TemplateProcessor($templatePath); + $templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/document22-xml.docx'); $variables = array('test'); From c51b6febc0feb8841202e38b817422ab0bcb09c5 Mon Sep 17 00:00:00 2001 From: troosan Date: Fri, 16 Nov 2018 23:00:23 +0100 Subject: [PATCH 20/40] rename variable to comply with rules --- 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 ced3880e65..b4102bcdf2 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -513,9 +513,9 @@ protected function getMainPartName() $pattern = '~PartName="\/(word\/document.*?\.xml)" ContentType="application\/vnd\.openxmlformats-officedocument\.wordprocessingml\.document\.main\+xml"~'; - preg_match($pattern, $contentTypes, $m); + preg_match($pattern, $contentTypes, $matches); - return (array_key_exists(1, $m) ? $m[1] : 'word/document.xml'); + return (array_key_exists(1, $matches) ? $matches[1] : 'word/document.xml'); } /** From 925e9e091910bf90290dcfcfeb3a36fe94aa6855 Mon Sep 17 00:00:00 2001 From: troosan Date: Fri, 16 Nov 2018 23:33:38 +0100 Subject: [PATCH 21/40] remove trailing spaces --- 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 b4102bcdf2..f9a8ceb6a4 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -514,7 +514,7 @@ protected function getMainPartName() $pattern = '~PartName="\/(word\/document.*?\.xml)" ContentType="application\/vnd\.openxmlformats-officedocument\.wordprocessingml\.document\.main\+xml"~'; preg_match($pattern, $contentTypes, $matches); - + return (array_key_exists(1, $matches) ? $matches[1] : 'word/document.xml'); } From ea6edf95ccefca19ab3a87cd192d8e9ca54a9c61 Mon Sep 17 00:00:00 2001 From: Christopher ARZUR Date: Fri, 16 Nov 2018 23:35:57 +0000 Subject: [PATCH 22/40] Added PHP 7.3 support for travis (#1495) * Added PHP 7.3 support for travis * mark php 7.3 as failable --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index db77ff0598..6fcdad43e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,19 @@ php: - 7.0 - 7.1 - 7.2 + - 7.3 matrix: include: - php: 7.0 env: COVERAGE=1 + - php: 5.3 + env: COMPOSER_MEMORY_LIMIT=2G + exclude: + - php: 7.0 + - php: 5.3 + allow_failures: + - php: 7.3 cache: directories: @@ -32,7 +40,7 @@ before_install: before_script: ## Deactivate xdebug if we don't do code coverage - - if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini ; fi + - if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini || echo "xdebug not available" ; fi ## Composer - composer self-update - travis_wait composer install --prefer-source From 49eb9d1f1700d7a432010b80726a70e3d6a9992c Mon Sep 17 00:00:00 2001 From: troosan Date: Sat, 17 Nov 2018 15:03:29 +0100 Subject: [PATCH 23/40] Fix non auto line spacing (#1508) * Only add 240 twips when in auto lineRule From 9b174e52c1600cb9f302a4dc40354eeb8fc6f01b Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Mon, 19 Nov 2018 01:35:03 -0200 Subject: [PATCH 24/40] Fix typo in the PR template --- docs/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/PULL_REQUEST_TEMPLATE.md b/docs/PULL_REQUEST_TEMPLATE.md index 24ba001cff..5430a996ec 100644 --- a/docs/PULL_REQUEST_TEMPLATE.md +++ b/docs/PULL_REQUEST_TEMPLATE.md @@ -8,4 +8,4 @@ Fixes # (issue) - [ ] I have run `composer run-script check --timeout=0` and no errors were reported - [ ] The new code is covered by unit tests (check build/coverage for coverage report) -- [ ] I have update the documentation to describe the changes +- [ ] I have updated the documentation to describe the changes From 663fb036d003d2cd98c29639818ca3673dda22fb Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Mon, 19 Nov 2018 01:36:23 -0200 Subject: [PATCH 25/40] Use dedicated PHPUnit assertions --- tests/PhpWord/Writer/HTML/ElementTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/PhpWord/Writer/HTML/ElementTest.php b/tests/PhpWord/Writer/HTML/ElementTest.php index 7a6397ef8c..61aaf71c46 100644 --- a/tests/PhpWord/Writer/HTML/ElementTest.php +++ b/tests/PhpWord/Writer/HTML/ElementTest.php @@ -73,8 +73,8 @@ public function testWriteTrackChanges() $dom = $this->getAsHTML($phpWord); $xpath = new \DOMXPath($dom); - $this->assertTrue($xpath->query('/html/body/p[1]/ins')->length == 1); - $this->assertTrue($xpath->query('/html/body/p[2]/del')->length == 1); + $this->assertEquals(1, $xpath->query('/html/body/p[1]/ins')->length); + $this->assertEquals(1, $xpath->query('/html/body/p[2]/del')->length); } /** @@ -97,9 +97,9 @@ public function testWriteColSpan() $dom = $this->getAsHTML($phpWord); $xpath = new \DOMXPath($dom); - $this->assertTrue($xpath->query('/html/body/table/tr[1]/td')->length == 1); + $this->assertEquals(1, $xpath->query('/html/body/table/tr[1]/td')->length); $this->assertEquals('2', $xpath->query('/html/body/table/tr/td[1]')->item(0)->attributes->getNamedItem('colspan')->textContent); - $this->assertTrue($xpath->query('/html/body/table/tr[2]/td')->length == 2); + $this->assertEquals(2, $xpath->query('/html/body/table/tr[2]/td')->length); } /** @@ -126,9 +126,9 @@ public function testWriteRowSpan() $dom = $this->getAsHTML($phpWord); $xpath = new \DOMXPath($dom); - $this->assertTrue($xpath->query('/html/body/table/tr[1]/td')->length == 2); + $this->assertEquals(2, $xpath->query('/html/body/table/tr[1]/td')->length); $this->assertEquals('3', $xpath->query('/html/body/table/tr[1]/td[1]')->item(0)->attributes->getNamedItem('rowspan')->textContent); - $this->assertTrue($xpath->query('/html/body/table/tr[2]/td')->length == 1); + $this->assertEquals(1, $xpath->query('/html/body/table/tr[2]/td')->length); } private function getAsHTML(PhpWord $phpWord) @@ -155,6 +155,6 @@ public function testWriteTitleTextRun() $htmlWriter = new HTML($phpWord); $content = $htmlWriter->getContent(); - $this->assertTrue(strpos($content, $expected) !== false); + $this->assertContains($expected, $content); } } From d9d79c0666928ce564dbdf3d08dca9bcdc678863 Mon Sep 17 00:00:00 2001 From: Ralph02 Date: Thu, 25 Oct 2018 11:23:53 +0100 Subject: [PATCH 26/40] RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals --- src/PhpWord/Writer/RTF/Style/Section.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Writer/RTF/Style/Section.php b/src/PhpWord/Writer/RTF/Style/Section.php index 5c34fa8683..ee6efcf3a0 100644 --- a/src/PhpWord/Writer/RTF/Style/Section.php +++ b/src/PhpWord/Writer/RTF/Style/Section.php @@ -43,8 +43,8 @@ public function write() $content .= '\sectd '; // Size & margin - $content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . $style->getPageSizeW()); - $content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . $style->getPageSizeH()); + $content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . round($style->getPageSizeW())); + $content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . round($style->getPageSizeH())); $content .= ' '; $content .= $this->getValueIf($style->getMarginTop() !== null, '\margtsxn' . $style->getMarginTop()); $content .= $this->getValueIf($style->getMarginRight() !== null, '\margrsxn' . $style->getMarginRight()); From b5865b2fc2bb4773450add0c354e49166d32ea02 Mon Sep 17 00:00:00 2001 From: troosan Date: Tue, 20 Nov 2018 19:59:30 +0100 Subject: [PATCH 27/40] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index abf3483418..7ce722c435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ v0.16.0 (xx xxx 2018) ### Fixed - Fix regex in `cloneBlock` function @nicoder #1269 - HTML Title Writer loses text when Title contains a TextRun instead a string. @begnini #1436 +- RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals @Patrick64 #1493 v0.15.0 (14 Jul 2018) ---------------------- From 1c20a4ed22c791e3cc574291c1f40e53b328568d Mon Sep 17 00:00:00 2001 From: troosan Date: Tue, 20 Nov 2018 21:22:50 +0100 Subject: [PATCH 28/40] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ce722c435..ce553f05b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ v0.16.0 (xx xxx 2018) - Fix regex in `cloneBlock` function @nicoder #1269 - HTML Title Writer loses text when Title contains a TextRun instead a string. @begnini #1436 - RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals @Patrick64 #1493 +- Fix parsing of Office 365 documents @Timanx #1485 v0.15.0 (14 Jul 2018) ---------------------- From c12f98f69a201502f3f994d261c106c8926ef62b Mon Sep 17 00:00:00 2001 From: troosan Date: Tue, 20 Nov 2018 22:40:54 +0100 Subject: [PATCH 29/40] fix check style warning --- 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 f9a8ceb6a4..95468878ab 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -515,7 +515,7 @@ protected function getMainPartName() preg_match($pattern, $contentTypes, $matches); - return (array_key_exists(1, $matches) ? $matches[1] : 'word/document.xml'); + return array_key_exists(1, $matches) ? $matches[1] : 'word/document.xml'; } /** From 5ccf985f9ad1c596c8b60d0730ff0bdaa2124804 Mon Sep 17 00:00:00 2001 From: Christopher ARZUR Date: Fri, 16 Nov 2018 23:35:57 +0000 Subject: [PATCH 30/40] Added PHP 7.3 support for travis (#1495) * Added PHP 7.3 support for travis * mark php 7.3 as failable --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index db77ff0598..6fcdad43e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,19 @@ php: - 7.0 - 7.1 - 7.2 + - 7.3 matrix: include: - php: 7.0 env: COVERAGE=1 + - php: 5.3 + env: COMPOSER_MEMORY_LIMIT=2G + exclude: + - php: 7.0 + - php: 5.3 + allow_failures: + - php: 7.3 cache: directories: @@ -32,7 +40,7 @@ before_install: before_script: ## Deactivate xdebug if we don't do code coverage - - if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini ; fi + - if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini || echo "xdebug not available" ; fi ## Composer - composer self-update - travis_wait composer install --prefer-source From a2a70736addbe2929c3edf41851bb83b75d00414 Mon Sep 17 00:00:00 2001 From: troosan Date: Thu, 22 Nov 2018 23:05:43 +0100 Subject: [PATCH 31/40] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index abf3483418..8c3a174d66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ v0.16.0 (xx xxx 2018) ### Fixed - Fix regex in `cloneBlock` function @nicoder #1269 - HTML Title Writer loses text when Title contains a TextRun instead a string. @begnini #1436 +- Fix loading of Sharepoint document @Garrcomm #1498 v0.15.0 (14 Jul 2018) ---------------------- From 7aef21facaf78e78da3902d1c2dc7766bca52c30 Mon Sep 17 00:00:00 2001 From: troosan Date: Wed, 28 Nov 2018 22:02:39 +0100 Subject: [PATCH 32/40] add test for parsing HTML containing entities --- tests/PhpWord/Shared/HtmlTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php index 51d9243129..89292a20c9 100644 --- a/tests/PhpWord/Shared/HtmlTest.php +++ b/tests/PhpWord/Shared/HtmlTest.php @@ -86,6 +86,21 @@ public function testParseFullHtml() $this->assertCount(2, $section->getElements()); } + /** + * Test HTML entities + */ + public function testParseHtmlEntities() + { + \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true); + $phpWord = new \PhpOffice\PhpWord\PhpWord(); + $section = $phpWord->addSection(); + Html::addHtml($section, 'text with entities <my text>'); + + $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007'); + $this->assertTrue($doc->elementExists('/w:document/w:body/w:p[1]/w:r/w:t')); + $this->assertEquals('text with entities ', $doc->getElement('/w:document/w:body/w:p[1]/w:r/w:t')->nodeValue); + } + /** * Test underline */ From 32fb85fc8e4ad5bc059574995344fd60dc950aaa Mon Sep 17 00:00:00 2001 From: Christopher ARZUR Date: Fri, 16 Nov 2018 23:35:57 +0000 Subject: [PATCH 33/40] Added PHP 7.3 support for travis (#1495) * Added PHP 7.3 support for travis * mark php 7.3 as failable --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index db77ff0598..6fcdad43e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,19 @@ php: - 7.0 - 7.1 - 7.2 + - 7.3 matrix: include: - php: 7.0 env: COVERAGE=1 + - php: 5.3 + env: COMPOSER_MEMORY_LIMIT=2G + exclude: + - php: 7.0 + - php: 5.3 + allow_failures: + - php: 7.3 cache: directories: @@ -32,7 +40,7 @@ before_install: before_script: ## Deactivate xdebug if we don't do code coverage - - if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini ; fi + - if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini || echo "xdebug not available" ; fi ## Composer - composer self-update - travis_wait composer install --prefer-source From b50de97a41f29987901b1370b74cbf08c643e741 Mon Sep 17 00:00:00 2001 From: troosan Date: Wed, 28 Nov 2018 22:54:57 +0100 Subject: [PATCH 34/40] support `auto` table layout too --- CHANGELOG.md | 1 + src/PhpWord/Writer/HTML/Element/Table.php | 26 ++++++++++++++++++++--- tests/PhpWord/Writer/HTML/ElementTest.php | 11 +++++++--- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abf3483418..7e2325fa5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ v0.16.0 (xx xxx 2018) ### Fixed - Fix regex in `cloneBlock` function @nicoder #1269 - HTML Title Writer loses text when Title contains a TextRun instead a string. @begnini #1436 +- Adding table layout to the generated HTML @aarangara #1441 v0.15.0 (14 Jul 2018) ---------------------- diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index 50c5a7775f..a5143d2b46 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -39,9 +39,8 @@ public function write() $rows = $this->element->getRows(); $rowCount = count($rows); if ($rowCount > 0) { - $tableStyle = $this->element->getStyle(); - $tableLayout = $tableStyle === null ? '' : $tableStyle->getLayout(); - $content .= '' . PHP_EOL; + $content .= 'element->getStyle()) . '>' . PHP_EOL; + for ($i = 0; $i < $rowCount; $i++) { /** @var $row \PhpOffice\PhpWord\Element\Row Type hint */ $rowStyle = $rows[$i]->getStyle(); @@ -104,4 +103,25 @@ public function write() return $content; } + + /** + * Translates Table style in CSS equivalent + * + * @param \PhpOffice\PhpWord\Style\Table|null $tableStyle + * @return string + */ + private function getTableStyle(\PhpOffice\PhpWord\Style\Table $tableStyle = null) + { + if ($tableStyle == null) { + return ''; + } + $style = ' style="'; + if ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_FIXED) { + $style .= 'table-layout: fixed;'; + } elseif ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_AUTO) { + $style .= 'table-layout: auto;'; + } + + return $style . '"'; + } } diff --git a/tests/PhpWord/Writer/HTML/ElementTest.php b/tests/PhpWord/Writer/HTML/ElementTest.php index 1f286c5fe1..73c6ede9d1 100644 --- a/tests/PhpWord/Writer/HTML/ElementTest.php +++ b/tests/PhpWord/Writer/HTML/ElementTest.php @@ -166,14 +166,19 @@ public function testWriteTableLayout() $phpWord = new PhpWord(); $section = $phpWord->addSection(); $section->addTable(); - $table = $section->addTable(array('layout' => 'fixed')); - $row1 = $table->addRow(); + $table1 = $section->addTable(array('layout' => \PhpOffice\PhpWord\Style\Table::LAYOUT_FIXED)); + $row1 = $table1->addRow(); $row1->addCell()->addText('fixed layout table'); + $table2 = $section->addTable(array('layout' => \PhpOffice\PhpWord\Style\Table::LAYOUT_AUTO)); + $row2 = $table2->addRow(); + $row2->addCell()->addText('auto layout table'); + $dom = $this->getAsHTML($phpWord); $xpath = new \DOMXPath($dom); - $this->assertEquals('table-layout: fixed', $xpath->query('/html/body/table')->item(0)->attributes->getNamedItem('style')->textContent); + $this->assertEquals('table-layout: fixed;', $xpath->query('/html/body/table[1]')->item(0)->attributes->getNamedItem('style')->textContent); + $this->assertEquals('table-layout: auto;', $xpath->query('/html/body/table[2]')->item(0)->attributes->getNamedItem('style')->textContent); } } From 6a7594630ce1a3adf7dbb8d9893f2f0f0e739faf Mon Sep 17 00:00:00 2001 From: troosan Date: Fri, 30 Nov 2018 23:01:05 +0100 Subject: [PATCH 35/40] add sonar config files --- .gitignore | 1 + phpunit.xml.dist | 1 + sonar-project.properties | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 sonar-project.properties diff --git a/.gitignore b/.gitignore index 2ac6e2b5c7..b2ec7e2398 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ vendor /.settings phpword.ini /.buildpath +/.scannerwork /.project /nbproject /.php_cs.cache diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 17fcfa3983..4a8824468e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -23,5 +23,6 @@ + \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000..7741cfb475 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,17 @@ +# must be unique in a given SonarQube instance +sonar.projectKey=phpoffice:phpword +# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. +sonar.projectName=PHPWord +sonar.projectVersion=0.16 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +# This property is optional if sonar.modules is set. +sonar.sources=src +sonar.tests=tests +sonar.php.coverage.reportPaths=build/logs/clover.xml +sonar.php.tests.reportPath=build/logs/logfile.xml + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 + +sonar.host.url=http://localhost:9000 \ No newline at end of file From a44aee8c34a78ed93d755224b8afd26d99737311 Mon Sep 17 00:00:00 2001 From: troosan Date: Fri, 30 Nov 2018 22:59:21 +0100 Subject: [PATCH 36/40] fix some sonar warnings --- src/PhpWord/Reader/MsDoc.php | 2 ++ src/PhpWord/Shared/Html.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Reader/MsDoc.php b/src/PhpWord/Reader/MsDoc.php index d494522955..187d5b177b 100644 --- a/src/PhpWord/Reader/MsDoc.php +++ b/src/PhpWord/Reader/MsDoc.php @@ -2185,6 +2185,8 @@ private function readPrl($data, $pos, $cbNum) $sprmCPicLocation += $embeddedBlipRH['recLen']; break; + case self::OFFICEARTBLIPPNG: + break; default: // print_r(dechex($embeddedBlipRH['recType'])); } diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 873234de4a..60fd7e165e 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -531,6 +531,7 @@ private static function parseStyle($attribute, $styles) $styles['bgColor'] = trim($cValue, '#'); break; case 'line-height': + $matches = array(); if (preg_match('/([0-9]+\.?[0-9]*[a-z]+)/', $cValue, $matches)) { $spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::EXACT; $spacing = Converter::cssToTwip($matches[1]) / \PhpOffice\PhpWord\Style\Paragraph::LINE_HEIGHT; @@ -743,8 +744,6 @@ private static function mapAlign($cssAlignment) default: return Jc::START; } - - return null; } /** From fb60865b8dfa6b9e038d7798d126a0a717b09a2f Mon Sep 17 00:00:00 2001 From: troosan Date: Sun, 2 Dec 2018 15:39:25 +0100 Subject: [PATCH 37/40] test build php 7.3 --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6fcdad43e5..881decfe2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,9 +18,12 @@ matrix: env: COVERAGE=1 - php: 5.3 env: COMPOSER_MEMORY_LIMIT=2G + - php: 7.3 + env: DEPENDENCIES="--ignore-platform-reqs" exclude: - - php: 7.0 - php: 5.3 + - php: 7.0 + - php: 7.3 allow_failures: - php: 7.3 @@ -43,7 +46,7 @@ before_script: - if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini || echo "xdebug not available" ; fi ## Composer - composer self-update - - travis_wait composer install --prefer-source + - travis_wait composer install --prefer-source $(if [ -n "$DEPENDENCIES" ]; then echo $DEPENDENCIES; fi) ## PHPDocumentor ##- mkdir -p build/docs - mkdir -p build/coverage From 5b688d50d82cf491b6114e94bc84de59dc96941d Mon Sep 17 00:00:00 2001 From: troosan Date: Sun, 2 Dec 2018 23:54:25 +0100 Subject: [PATCH 38/40] fix formatting --- src/PhpWord/Style/Chart.php | 26 +++++++++++++--------- src/PhpWord/Writer/Word2007/Part/Chart.php | 16 ++++++------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/PhpWord/Style/Chart.php b/src/PhpWord/Style/Chart.php index 5c96afd25d..06b4829c3c 100644 --- a/src/PhpWord/Style/Chart.php +++ b/src/PhpWord/Style/Chart.php @@ -51,8 +51,8 @@ class Chart extends AbstractStyle * @var array */ private $colors = array(); - - /** + + /** * Chart title * * @var string @@ -111,9 +111,15 @@ class Chart extends AbstractStyle */ private $valueAxisTitle; + /** + * The position for major tick marks + * Possible values are 'in', 'out', 'cross', 'none' + * + * @var string + */ private $majorTickMarkPos = 'none'; - /* + /** * Show labels for axis * * @var bool @@ -234,7 +240,7 @@ public function setColors($value = array()) return $this; } - + /** * Get the chart title * @@ -248,7 +254,7 @@ public function getTitle() /** * Set the chart title * - * @param string $value + * @param string $value */ public function setTitle($value = null) { @@ -262,7 +268,7 @@ public function setTitle($value = null) * * @return bool */ - public function getShowLegend() + public function isShowLegend() { return $this->showLegend; } @@ -270,7 +276,7 @@ public function getShowLegend() /** * Set chart legend visibility * - * @param bool $value + * @param bool $value */ public function setShowLegend($value = false) { @@ -452,8 +458,8 @@ public function getMajorTickPosition() } /** - * set the position for major tick marks - * @param string $position [description] + * Set the position for major tick marks + * @param string $position */ public function setMajorTickPosition($position) { @@ -461,7 +467,7 @@ public function setMajorTickPosition($position) $this->majorTickMarkPos = $this->setEnumVal($position, $enum, $this->majorTickMarkPos); } - /* + /** * Show Gridlines for X-Axis * * @return bool diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php index e14a708be8..812d3bf1e3 100644 --- a/src/PhpWord/Writer/Word2007/Part/Chart.php +++ b/src/PhpWord/Writer/Word2007/Part/Chart.php @@ -128,12 +128,12 @@ private function writePlotArea(XMLWriter $xmlWriter) $type = $this->element->getType(); $style = $this->element->getStyle(); $this->options = $this->types[$type]; - - $title = $style->getTitle(); - $showLegend = $style->getShowLegend(); + + $title = $style->getTitle(); + $showLegend = $style->isShowLegend(); //Chart title - if($title){ + if ($title) { $xmlWriter->startElement('c:title'); $xmlWriter->startElement('c:tx'); $xmlWriter->startElement('c:rich'); @@ -142,20 +142,18 @@ private function writePlotArea(XMLWriter $xmlWriter) - '.$title.' + ' . $title . ' '); - $xmlWriter->endElement(); // c:rich $xmlWriter->endElement(); // c:tx $xmlWriter->endElement(); // c:title - - }else{ + } else { $xmlWriter->writeElementBlock('c:autoTitleDeleted', 'val', 1); } //Chart legend - if($showLegend){ + if ($showLegend) { $xmlWriter->writeRaw(''); } From 0c4bd1d02f3b175d3944d6577c377a800e27aace Mon Sep 17 00:00:00 2001 From: troosan Date: Sun, 2 Dec 2018 23:54:32 +0100 Subject: [PATCH 39/40] update documentation --- docs/styles.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/styles.rst b/docs/styles.rst index 8c5de7cb9d..f8d26a9b33 100644 --- a/docs/styles.rst +++ b/docs/styles.rst @@ -192,6 +192,14 @@ Available Chart style options: - ``width``. Width (in EMU). - ``height``. Height (in EMU). - ``3d``. Is 3D; applies to pie, bar, line, area, *true* or *false*. +- ``colors``. A list of colors to use in the chart. +- ``title``. The title for the chart. +- ``showLegend``. Show legend, *true* or *false*. +- ``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. +- ``valueAxisTitle``. The title for the values axis. +- ``majorTickMarkPos``. The position for major tick marks, *in*, *out*, *cross*, *none* (default). - ``showAxisLabels``. Show labels for axis, *true* or *false*. - ``gridX``. Show Gridlines for X-Axis, *true* or *false*. - ``gridY``. Show Gridlines for Y-Axis, *true* or *false*. From 9f684c745e3b7f41c304659a77c74967e662f3f1 Mon Sep 17 00:00:00 2001 From: troosan Date: Sun, 2 Dec 2018 23:54:40 +0100 Subject: [PATCH 40/40] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1db7a5e8e..79ae25119d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). v0.16.0 (xx xxx 2018) ---------------------- ### Added +- Add setting Chart Title and Legend visibility @Tom-Magill #1433 ### Fixed - Fix regex in `cloneBlock` function @nicoder #1269