From abbd2885092d0a96df7b28eda57f183bf16cd3b4 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 1 Jan 2014 06:28:10 -0800 Subject: [PATCH 01/19] https://github.com/PHPOffice/PHPWord/issues/46 Ability to apply XSLT to Template --- Classes/PHPWord/Template.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index a01a854166..d474195e34 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -75,6 +75,36 @@ public function __construct($strFilename) throw new PHPWord_Exception('Could not create temporary file with unique name in the default temporary directory.'); } } + + /** + * Applies XSL transformation to XML template. + * + * @param DOMDocument &$xslDOMDocument + * @param string $xslOptionsURI + * @param array $xslOptions + */ + public function applyXSLT(&$xslDOMDocument, $xslOptionsURI = '', $xslOptions = []) + { + $processor = new \XSLTProcessor(); + + $processor->importStylesheet($xslDOMDocument); + + if ($processor->setParameter($xslOptionsURI, $xslOptions) === \FALSE) { + throw new \Exception('Could not set values for the given XSL stylesheet parameters.'); + } + + $xmlDOMDocument = new \DOMDocument(); + if ($xmlDOMDocument->loadXML($this->_documentXML) === \FALSE) { + throw new \Exception('Could not create DOM document for the given XML template.'); + } + + $xmlTransformed = $processor->transformToXml($xmlDOMDocument); + if ($xmlTransformed === \FALSE) { + throw new \Exception('Could not apply XSLT to the given DOM document.'); + } + + $this->_documentXML = $xmlTransformed; + } /** * Set a Template value @@ -134,4 +164,4 @@ public function save($strFilename) rename($this->_tempFileName, $strFilename); } -} \ No newline at end of file +} From e5a4e2d8b62e7397f95b6c6b6dbe32c0d2c67bd3 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 1 Mar 2014 05:12:11 -0800 Subject: [PATCH 02/19] https://github.com/PHPOffice/PHPWord/issues/46 The method name was changed to be more correct. --- Classes/PHPWord/Template.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index d474195e34..6a113fbe48 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -77,20 +77,20 @@ public function __construct($strFilename) } /** - * Applies XSL transformation to XML template. + * Applies XSL style sheet to XML template. * * @param DOMDocument &$xslDOMDocument * @param string $xslOptionsURI * @param array $xslOptions */ - public function applyXSLT(&$xslDOMDocument, $xslOptionsURI = '', $xslOptions = []) + public function applyXslStyleSheet(&$xslDOMDocument, $xslOptionsURI = '', $xslOptions = []) { $processor = new \XSLTProcessor(); $processor->importStylesheet($xslDOMDocument); if ($processor->setParameter($xslOptionsURI, $xslOptions) === \FALSE) { - throw new \Exception('Could not set values for the given XSL stylesheet parameters.'); + throw new \Exception('Could not set values for the given XSL style sheet parameters.'); } $xmlDOMDocument = new \DOMDocument(); From b579007611a74a0003fed42f361aed83ed246cbf Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 1 Mar 2014 08:53:19 -0800 Subject: [PATCH 03/19] https://github.com/PHPOffice/PHPWord/issues/46 Signature of the method was changed. Optional parameter should be on the last position. --- Classes/PHPWord/Template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index 6a113fbe48..36270c7c8a 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -80,10 +80,10 @@ public function __construct($strFilename) * Applies XSL style sheet to XML template. * * @param DOMDocument &$xslDOMDocument - * @param string $xslOptionsURI * @param array $xslOptions + * @param string $xslOptionsURI = '' */ - public function applyXslStyleSheet(&$xslDOMDocument, $xslOptionsURI = '', $xslOptions = []) + public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = [], $xslOptionsURI = '') { $processor = new \XSLTProcessor(); From 84807539b165a612656c351472ee3d1199029498 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 2 Mar 2014 04:09:48 -0800 Subject: [PATCH 04/19] https://github.com/PHPOffice/PHPWord/issues/46 Correction of the docblock descrition. --- Classes/PHPWord/Template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index 36270c7c8a..c846c298bc 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -80,7 +80,7 @@ public function __construct($strFilename) * Applies XSL style sheet to XML template. * * @param DOMDocument &$xslDOMDocument - * @param array $xslOptions + * @param array $xslOptions = [] * @param string $xslOptionsURI = '' */ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = [], $xslOptionsURI = '') From 6ed2b1121126c564d677ebba8c4b72ee78da9c70 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 2 Mar 2014 05:14:51 -0800 Subject: [PATCH 05/19] https://github.com/PHPOffice/PHPWord/issues/46 Minor changes in exception messages. --- Classes/PHPWord/Template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index c846c298bc..0e431c3c7b 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -95,12 +95,12 @@ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = [], $xslOptio $xmlDOMDocument = new \DOMDocument(); if ($xmlDOMDocument->loadXML($this->_documentXML) === \FALSE) { - throw new \Exception('Could not create DOM document for the given XML template.'); + throw new \Exception('Could not load XML from the given template.'); } $xmlTransformed = $processor->transformToXml($xmlDOMDocument); if ($xmlTransformed === \FALSE) { - throw new \Exception('Could not apply XSLT to the given DOM document.'); + throw new \Exception('Could not transform the given XML document.'); } $this->_documentXML = $xmlTransformed; From a0165701c724d2a5fce5a64a690e0d62c416f92c Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 2 Mar 2014 05:42:16 -0800 Subject: [PATCH 06/19] https://github.com/PHPOffice/PHPWord/issues/46 Correction of the docblock descrition. --- Classes/PHPWord/Template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index 0e431c3c7b..28c77868c1 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -77,7 +77,7 @@ public function __construct($strFilename) } /** - * Applies XSL style sheet to XML template. + * Applies XSL style sheet to template's parts * * @param DOMDocument &$xslDOMDocument * @param array $xslOptions = [] From 27b7d67cc9cffaa9864ac77db36707d8a1b7fd3c Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 2 Mar 2014 19:52:21 +0400 Subject: [PATCH 07/19] https://github.com/PHPOffice/PHPWord/issues/46 Tests. --- Tests/PHPWord/TemplateTest.php | 85 ++++++++++++++++++++++++++++++++ Tests/_files/xsl/blank.xsl | 4 ++ Tests/_files/xsl/passthrough.xsl | 11 +++++ 3 files changed, 100 insertions(+) create mode 100644 Tests/PHPWord/TemplateTest.php create mode 100644 Tests/_files/xsl/blank.xsl create mode 100644 Tests/_files/xsl/passthrough.xsl diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php new file mode 100644 index 0000000000..99d977b0f6 --- /dev/null +++ b/Tests/PHPWord/TemplateTest.php @@ -0,0 +1,85 @@ +load( + \join(\DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) + ); + + $template->applyXslStyleSheet($xslDOMDocument, [1 => 'somevalue']); + } + + /** + * @covers ::applyXslStyleSheet + * @expectedException Exception + * @expectedExceptionMessage Could not load XML from the given template. + * @test + */ + final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() + { + $template = new PHPWord_Template( + \join(\DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'corrupted_main_document_part.docx')) + ); + + $xslDOMDocument = new \DOMDocument(); + $xslDOMDocument->load( + \join(\DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) + ); + + $template->applyXslStyleSheet($xslDOMDocument); + } + + /** + * @covers ::applyXslStyleSheet + * @expectedException Exception + * @expectedExceptionMessage Could not transform the given XML document. + * @test + */ + final public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation() + { + $template = new PHPWord_Template( + \join(\DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx')) + ); + + $xslDOMDocument = new \DOMDocument(); + $xslDOMDocument->load( + \join(\DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'blank.xsl')) + ); + + $template->applyXslStyleSheet($xslDOMDocument); + } +} \ No newline at end of file diff --git a/Tests/_files/xsl/blank.xsl b/Tests/_files/xsl/blank.xsl new file mode 100644 index 0000000000..48edfd4332 --- /dev/null +++ b/Tests/_files/xsl/blank.xsl @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Tests/_files/xsl/passthrough.xsl b/Tests/_files/xsl/passthrough.xsl new file mode 100644 index 0000000000..4ab21dd745 --- /dev/null +++ b/Tests/_files/xsl/passthrough.xsl @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file From fb5ef658dfb37832ac244e22770876e3b10c5b25 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 2 Mar 2014 20:08:02 +0400 Subject: [PATCH 08/19] https://github.com/PHPOffice/PHPWord/issues/46 Compatibility with PHP 5.3 was fixed. --- Classes/PHPWord/Template.php | 4 ++-- Tests/PHPWord/TemplateTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index 28c77868c1..425bd41308 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -80,10 +80,10 @@ public function __construct($strFilename) * Applies XSL style sheet to template's parts * * @param DOMDocument &$xslDOMDocument - * @param array $xslOptions = [] + * @param array $xslOptions = array() * @param string $xslOptionsURI = '' */ - public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = [], $xslOptionsURI = '') + public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') { $processor = new \XSLTProcessor(); diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index 99d977b0f6..34ef6cb1eb 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -36,7 +36,7 @@ final public function testXsLStyleSheetCanNotBeAppliedOnFailureOfSettingParamete array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) ); - $template->applyXslStyleSheet($xslDOMDocument, [1 => 'somevalue']); + $template->applyXslStyleSheet($xslDOMDocument, array(1 => 'somevalue')); } /** From d324a6480817640ed8045023c4ad1e9efa04e9f9 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 2 Mar 2014 20:14:19 +0400 Subject: [PATCH 09/19] https://github.com/PHPOffice/PHPWord/issues/46 FIXED: misprint in test's name. --- Tests/PHPWord/TemplateTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index 34ef6cb1eb..5326b1c2ca 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -23,7 +23,7 @@ final public function testXslStyleSheetCanBeApplied() * @expectedExceptionMessage Could not set values for the given XSL style sheet parameters. * @test */ - final public function testXsLStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() + final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() { $template = new PHPWord_Template( \join(\DIRECTORY_SEPARATOR, From a765d61b1537bce2c250d1a4fcdc64a22e6aba4b Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 2 Mar 2014 08:44:40 -0800 Subject: [PATCH 10/19] https://github.com/PHPOffice/PHPWord/issues/46 --- Tests/_files/templates/blank.docx | Bin 0 -> 3785 bytes .../templates/corrupted_main_document_part.docx | Bin 0 -> 3806 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Tests/_files/templates/blank.docx create mode 100644 Tests/_files/templates/corrupted_main_document_part.docx diff --git a/Tests/_files/templates/blank.docx b/Tests/_files/templates/blank.docx new file mode 100644 index 0000000000000000000000000000000000000000..071b7f350d7220ca436181046a431e3445489e82 GIT binary patch literal 3785 zcmaJ^2{=^iAGS6I$<9Rx$#Tn*J=+jjvW_MDF4^~evSgQK!dPyy?@hKLd&6MJ9#Kif zTwC@q67iqu-b$YT?RTDYo^zh(yyrW=_xpYC@BMT&iAm@Q$jHbD5O(I*2~GqB?%vAV z!PQ6T3jPXzpruI+qKw)2%AmYH<0=@}H;m;{^5EJ9L}jn8j}8N_-hmCh7rCgh{r zg0?r=Ubqb(bBsmbzc}6x<~c$!+YE0QU0*hY%;2^38S4A3`=n zgsiL%k}XC7Zb{*Psz(&)HNGgN@#K3te(`aldIwrt-y8_{kLY2gBSBnu?+Mbqj1}dX zEQn8g^TksCPY5d4;L>Z(yprX}1D!MU#JtmnM2AnFhi6E}KC5xFaEWHE8kS>WfqsZ^ zKOdu(-T|WBEKlnrl)s{IP!{TTHsjN)+3C)z-J$NoY6Zo@tocQzN4aIu>cfCp#sEAW z`$EFV9$d0?zomobI~_g_zP@+dZ~NehP)XLL>Jp~BzW0#p6Fcp#%?h#_8}nE| zFW=CDIn;9cQ5NEolNw=Ydi%~lD(VC?=@Gr&^>mpRnAY`*wZRC%#Yu^1Xg)lXW5K?Z z*KQe#_$URy0?xF>+?W72v1RzcWtDeoyjnRL!!ofH_#FLTCc{f`8I0o2|DJN%?>Rbp zxceH|*t$C4lZ5LIXrqLw+qM~C8xsY9sKQdii`~Fo#Q}ipjFw%$3;kbt#U@ke7;EW*x5FoizYdL!~RORl!WKu$OC1ycF}`WR@~*Q*;(SaA?_hJ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`^`l+ Date: Sun, 2 Mar 2014 09:33:26 -0800 Subject: [PATCH 11/19] https://github.com/PHPOffice/PHPWord/issues/46 Final keyword was removed in test class. --- Tests/PHPWord/TemplateTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index 5326b1c2ca..bd8e98e2f4 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -12,7 +12,7 @@ class PHPWord_TemplateTest extends \PHPUnit_Framework_TestCase * @covers ::applyXslStyleSheet * @test */ - final public function testXslStyleSheetCanBeApplied() + public function testXslStyleSheetCanBeApplied() { // TODO: implement after merge of the issue https://github.com/PHPOffice/PHPWord/issues/56 } @@ -23,7 +23,7 @@ final public function testXslStyleSheetCanBeApplied() * @expectedExceptionMessage Could not set values for the given XSL style sheet parameters. * @test */ - final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() + public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() { $template = new PHPWord_Template( \join(\DIRECTORY_SEPARATOR, @@ -45,7 +45,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete * @expectedExceptionMessage Could not load XML from the given template. * @test */ - final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() + public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() { $template = new PHPWord_Template( \join(\DIRECTORY_SEPARATOR, @@ -67,7 +67,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromT * @expectedExceptionMessage Could not transform the given XML document. * @test */ - final public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation() + public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation() { $template = new PHPWord_Template( \join(\DIRECTORY_SEPARATOR, @@ -82,4 +82,4 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation( $template->applyXslStyleSheet($xslDOMDocument); } -} \ No newline at end of file +} From e0e48938fa8dc6f52133c85466ee2cd6b1ca1cbd Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 2 Mar 2014 10:06:27 -0800 Subject: [PATCH 12/19] https://github.com/PHPOffice/PHPWord/issues/46 Boolean values now meet PHP-FIG. --- Classes/PHPWord/Template.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index 425bd41308..039b350f68 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -89,17 +89,17 @@ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xsl $processor->importStylesheet($xslDOMDocument); - if ($processor->setParameter($xslOptionsURI, $xslOptions) === \FALSE) { + if ($processor->setParameter($xslOptionsURI, $xslOptions) === false) { throw new \Exception('Could not set values for the given XSL style sheet parameters.'); } $xmlDOMDocument = new \DOMDocument(); - if ($xmlDOMDocument->loadXML($this->_documentXML) === \FALSE) { + if ($xmlDOMDocument->loadXML($this->_documentXML) === false) { throw new \Exception('Could not load XML from the given template.'); } $xmlTransformed = $processor->transformToXml($xmlDOMDocument); - if ($xmlTransformed === \FALSE) { + if ($xmlTransformed === false) { throw new \Exception('Could not transform the given XML document.'); } From 1c3ebe1f919f0b013973da2be3a80ea95dfe2b12 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Mar 2014 16:53:00 +0400 Subject: [PATCH 13/19] https://github.com/PHPOffice/PHPWord/issues/46 An attempt to fix tests. --- Tests/PHPWord/TemplateTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index bd8e98e2f4..d80b1bbdae 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -12,7 +12,7 @@ class PHPWord_TemplateTest extends \PHPUnit_Framework_TestCase * @covers ::applyXslStyleSheet * @test */ - public function testXslStyleSheetCanBeApplied() + final public function testXslStyleSheetCanBeApplied() { // TODO: implement after merge of the issue https://github.com/PHPOffice/PHPWord/issues/56 } @@ -23,7 +23,7 @@ public function testXslStyleSheetCanBeApplied() * @expectedExceptionMessage Could not set values for the given XSL style sheet parameters. * @test */ - public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() + final public function testXsLStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() { $template = new PHPWord_Template( \join(\DIRECTORY_SEPARATOR, @@ -36,7 +36,7 @@ public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) ); - $template->applyXslStyleSheet($xslDOMDocument, array(1 => 'somevalue')); + @$template->applyXslStyleSheet($xslDOMDocument, [1 => 'somevalue']); } /** @@ -45,7 +45,7 @@ public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue * @expectedExceptionMessage Could not load XML from the given template. * @test */ - public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() + final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() { $template = new PHPWord_Template( \join(\DIRECTORY_SEPARATOR, @@ -58,7 +58,7 @@ public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplat array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) ); - $template->applyXslStyleSheet($xslDOMDocument); + @$template->applyXslStyleSheet($xslDOMDocument); } /** @@ -67,7 +67,7 @@ public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplat * @expectedExceptionMessage Could not transform the given XML document. * @test */ - public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation() + final public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation() { $template = new PHPWord_Template( \join(\DIRECTORY_SEPARATOR, @@ -80,6 +80,6 @@ public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation() array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'blank.xsl')) ); - $template->applyXslStyleSheet($xslDOMDocument); + @$template->applyXslStyleSheet($xslDOMDocument); } -} +} \ No newline at end of file From bdcbd149e7809b580dce978daa56662fa538a2f5 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Mar 2014 17:03:09 +0400 Subject: [PATCH 14/19] https://github.com/PHPOffice/PHPWord/issues/46 FIXED (again): compatibility with PHP 5.3. FIXED (again): misprint in method name. --- Tests/PHPWord/TemplateTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index d80b1bbdae..c821323ba4 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -23,7 +23,7 @@ final public function testXslStyleSheetCanBeApplied() * @expectedExceptionMessage Could not set values for the given XSL style sheet parameters. * @test */ - final public function testXsLStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() + final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() { $template = new PHPWord_Template( \join(\DIRECTORY_SEPARATOR, @@ -36,7 +36,7 @@ final public function testXsLStyleSheetCanNotBeAppliedOnFailureOfSettingParamete array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) ); - @$template->applyXslStyleSheet($xslDOMDocument, [1 => 'somevalue']); + @$template->applyXslStyleSheet($xslDOMDocument, array(1 => 'somevalue')); } /** From ec5322d9ab5a0ecfb011d1046cf551e28c7a3ef6 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Mar 2014 08:15:51 -0800 Subject: [PATCH 15/19] https://github.com/PHPOffice/PHPWord/issues/46 --- .../templates/empty_main_document_part.docx | Bin 0 -> 3425 bytes Tests/_files/xsl/blank.xsl | 4 ---- 2 files changed, 4 deletions(-) create mode 100644 Tests/_files/templates/empty_main_document_part.docx delete mode 100644 Tests/_files/xsl/blank.xsl diff --git a/Tests/_files/templates/empty_main_document_part.docx b/Tests/_files/templates/empty_main_document_part.docx new file mode 100644 index 0000000000000000000000000000000000000000..f3ebe478d90f27686dad9594358f37e0d77702e3 GIT binary patch literal 3425 zcmai02|QGL8y;I@%e9j|B+HENo%`XOZrqzD0(;`-m7@fecx5*8)==M zZbt=_nS4*VLYc=^@v55l#yM!WB#XnwyvyDVYuGhI87hSL zW9FRdf1o$lCFx7MMz&~MW@(WerE6KC0-5PRYd`+p+VE7oEAIjiL#G7v$c|zSMY4l7 zMx8ysFukE#D)nT0tlcBS+w>9oK~oJ#ynxJ1%*QUD3=aU%{AGbuCkwQ4^{~NJ=nMnj zL2}Td*6znd29SB#W)`eaJkAmoZoV-ckErFMR}FbK{yZH6AMZ;@JW6Cw+>Mzr74M;V zq7Ubz>L*r3MCrjIUx(*Svr0+dA5d-a4?wB~cjx;E9 zmJGc$-xBdhRY?&v0OMk!PA5NVSdhVC|5@`n>o(29#ctV9+>u z-yZaC^n)y>ox3o6vox!Ft?)$#9JHQv1*?6a*-aR&#jkE@5Z5SBpq zoNZjZaM1p`6VyLnw{>;#(y_2~`q2uwX0HYkMA@=Qm$o*N3k=UI(!JD4vMt{Wbed4N z>M^}#nw<0!)vu_KqzG;um8!j3TRRpgDZoVTBu)3l0;UpL@V#fKDQPV#eg86_1b!C6 zzeB;h+oQJ4sNQdZuSR*P)6b}zze`d-=3WGa@1$cvc&e;K^aArh+4iIkuo8B?RH{79 zV5fwI@lpQm#+zN~h3K!#+fj-!50vG}giR2sr3TMXUU~f_#-u?Y3WMb;I@b?)+k_@y z^ALYJNT{##f3|r(KK>Ie$YwywH29-1L)`o{7uGa$S zpGWRx>s8K1=L#7u3un~$5Hb6ZWO?1+f!jW^4_cybyG$_EWUhGUEou*GEwyw*gmL~lo!>U$+2Bc144kH!;%Ymn}&srDp zSS`Tn7A1f?z;i8;w?-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z{BhCtjy6i#lC!oL=04G|n-MIMlP&xP6G=`9NIEpT34WoX6I*$hfjrLXb|w&l+u>?^o)+=OCI&?rQ@59*`?RKCliEy)_7a z=C@%Wakt@lDsQ3DO`jusQP;rU7L*g(bSkz#4>`)bm5oDWeh80i6kD&%5AxyR(*lmo z?n#%3GrOnbto7AYJDq*f2;uC`aZF+_|IYsDD{<*^fM2;K?!U4*uxDxPQvczdNCCJ< z0016<5#Y7D5w#~ah-X3fIpXB`>< z${=n&A4dh2o`0tQJ+03spA-$8QXYpH@UP@w=;qlko!k>RkvR?*tUmt_$vOLhlN7>j bo#PlKIkk~A)rijF9+F^x=2(Q6esuf4k!)p4 literal 0 HcmV?d00001 diff --git a/Tests/_files/xsl/blank.xsl b/Tests/_files/xsl/blank.xsl deleted file mode 100644 index 48edfd4332..0000000000 --- a/Tests/_files/xsl/blank.xsl +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From bfe7da63fc4b814ce44396065c6ad26ded5afaef Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Mar 2014 20:16:59 +0400 Subject: [PATCH 16/19] https://github.com/PHPOffice/PHPWord/issues/46 FIXED: last negative test. --- Tests/PHPWord/TemplateTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index c821323ba4..748c8d77a2 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -71,13 +71,13 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation( { $template = new PHPWord_Template( \join(\DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx')) + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'empty_main_document_part.docx')) ); $xslDOMDocument = new \DOMDocument(); $xslDOMDocument->load( \join(\DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'blank.xsl')) + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) ); @$template->applyXslStyleSheet($xslDOMDocument); From a8b73b9061166e1997cbc7b2866e6856aa2b517b Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Mar 2014 20:36:02 +0400 Subject: [PATCH 17/19] https://github.com/PHPOffice/PHPWord/issues/46 FIXED: tests (last test was removed, because there is no chance to make it work). --- Tests/PHPWord/TemplateTest.php | 22 ------------------ .../templates/empty_main_document_part.docx | Bin 3425 -> 0 bytes 2 files changed, 22 deletions(-) delete mode 100644 Tests/_files/templates/empty_main_document_part.docx diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index 748c8d77a2..7ea31f64a1 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -60,26 +60,4 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromT @$template->applyXslStyleSheet($xslDOMDocument); } - - /** - * @covers ::applyXslStyleSheet - * @expectedException Exception - * @expectedExceptionMessage Could not transform the given XML document. - * @test - */ - final public function testXslStyleSheetCanNotBeAppliedOnFailureOfTransformation() - { - $template = new PHPWord_Template( - \join(\DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'empty_main_document_part.docx')) - ); - - $xslDOMDocument = new \DOMDocument(); - $xslDOMDocument->load( - \join(\DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) - ); - - @$template->applyXslStyleSheet($xslDOMDocument); - } } \ No newline at end of file diff --git a/Tests/_files/templates/empty_main_document_part.docx b/Tests/_files/templates/empty_main_document_part.docx deleted file mode 100644 index f3ebe478d90f27686dad9594358f37e0d77702e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3425 zcmai02|QGL8y;I@%e9j|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D{<*^fM2;K?!U4*uxDxPQvczdNCCJ< z0016<5#Y7D5w#~ah-X3fIpXB`>< z${=n&A4dh2o`0tQJ+03spA-$8QXYpH@UP@w=;qlko!k>RkvR?*tUmt_$vOLhlN7>j bo#PlKIkk~A)rijF9+F^x=2(Q6esuf4k!)p4 From b76531246952b585b7db8b7cbfbe0cc8bcf6bd53 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Mar 2014 21:12:05 +0400 Subject: [PATCH 18/19] https://github.com/PHPOffice/PHPWord/issues/46 FIXED: indentation. --- Classes/PHPWord/Template.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index 039b350f68..d93cd0c6e3 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -64,7 +64,7 @@ public function __construct($strFilename) if ($this->_tempFileName !== false) { // Copy the source File to the temp File if (!copy($strFilename, $this->_tempFileName)) { - throw new PHPWord_Exception('Could not copy the template from ' . $strFilename . ' to ' . $this->_tempFileName . '.'); + throw new PHPWord_Exception("Could not copy the template from {$strFilename} to {$this->_tempFileName}."); } $this->_objZip = new ZipArchive(); @@ -85,25 +85,25 @@ public function __construct($strFilename) */ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') { - $processor = new \XSLTProcessor(); + $processor = new \XSLTProcessor(); - $processor->importStylesheet($xslDOMDocument); + $processor->importStylesheet($xslDOMDocument); - if ($processor->setParameter($xslOptionsURI, $xslOptions) === false) { - throw new \Exception('Could not set values for the given XSL style sheet parameters.'); - } + if ($processor->setParameter($xslOptionsURI, $xslOptions) === false) { + throw new \Exception('Could not set values for the given XSL style sheet parameters.'); + } - $xmlDOMDocument = new \DOMDocument(); - if ($xmlDOMDocument->loadXML($this->_documentXML) === false) { - throw new \Exception('Could not load XML from the given template.'); - } + $xmlDOMDocument = new \DOMDocument(); + if ($xmlDOMDocument->loadXML($this->_documentXML) === false) { + throw new \Exception('Could not load XML from the given template.'); + } - $xmlTransformed = $processor->transformToXml($xmlDOMDocument); - if ($xmlTransformed === false) { - throw new \Exception('Could not transform the given XML document.'); - } + $xmlTransformed = $processor->transformToXml($xmlDOMDocument); + if ($xmlTransformed === false) { + throw new \Exception('Could not transform the given XML document.'); + } - $this->_documentXML = $xmlTransformed; + $this->_documentXML = $xmlTransformed; } /** From 670765f80f1e7fc94137dcd6c3bd6868d19c84b8 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 4 Mar 2014 14:36:39 +0400 Subject: [PATCH 19/19] https://github.com/PHPOffice/PHPWord/issues/46 Notes on error control usage were added. --- Tests/PHPWord/TemplateTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index 7ea31f64a1..643fa29ce1 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -36,6 +36,10 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) ); + /* + * We have to use error control below, because XSLTProcessor::setParameter omits warning on failure. + * This warning fails the test. + */ @$template->applyXslStyleSheet($xslDOMDocument, array(1 => 'somevalue')); } @@ -58,6 +62,10 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromT array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')) ); + /* + * We have to use error control below, because DOMDocument::loadXML omits warning on failure. + * This warning fails the test. + */ @$template->applyXslStyleSheet($xslDOMDocument); } } \ No newline at end of file