From 28fef5f264d1a04f6bb16b666e7ec20f73af6abd Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 16 Mar 2014 00:25:49 +0700 Subject: [PATCH 1/6] Bugfix on PHPWordTest --- Tests/PHPWordTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/PHPWordTest.php b/Tests/PHPWordTest.php index 15106af6..c08d0885 100644 --- a/Tests/PHPWordTest.php +++ b/Tests/PHPWordTest.php @@ -172,7 +172,7 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase /** * @covers PHPWord::loadTemplate - * @expectedException PHPWord_Exception + * @expectedException Exception */ public function testLoadTemplateException() { From 077d87d1bc9406458aff9665af77e3f1b8484af7 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 16 Mar 2014 07:40:02 +0700 Subject: [PATCH 2/6] New unit tests for Writer --- Classes/PHPWord/Writer/ODText/Content.php | 6 +-- Classes/PHPWord/Writer/ODText/Manifest.php | 7 +-- Classes/PHPWord/Writer/Word2007.php | 10 ++++ .../PHPWord/Writer/ODText/WriterPartTest.php | 45 ++++++++++++++++++ Tests/PHPWord/Writer/ODTextTest.php | 13 ------ Tests/PHPWord/Writer/RTFTest.php | 21 ++------- Tests/PHPWord/Writer/Word2007/FooterTest.php | 44 ++++++++++++++++++ Tests/PHPWord/Writer/Word2007/HeaderTest.php | 46 +++++++++++++++++++ .../Writer/Word2007/WriterPartTest.php | 45 ++++++++++++++++++ Tests/PHPWord/Writer/Word2007Test.php | 23 +++++++++- 10 files changed, 224 insertions(+), 36 deletions(-) create mode 100644 Tests/PHPWord/Writer/ODText/WriterPartTest.php create mode 100644 Tests/PHPWord/Writer/Word2007/FooterTest.php create mode 100644 Tests/PHPWord/Writer/Word2007/HeaderTest.php create mode 100644 Tests/PHPWord/Writer/Word2007/WriterPartTest.php diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PHPWord/Writer/ODText/Content.php index 0899990b..316e56fc 100755 --- a/Classes/PHPWord/Writer/ODText/Content.php +++ b/Classes/PHPWord/Writer/ODText/Content.php @@ -33,9 +33,9 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart /** * Write content file to XML format * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception + * @param PHPWord $pPHPWord + * @return string XML Output + * @throws Exception */ public function writeContent(PHPWord $pPHPWord = null) { diff --git a/Classes/PHPWord/Writer/ODText/Manifest.php b/Classes/PHPWord/Writer/ODText/Manifest.php index 89e802dc..0d627ec9 100755 --- a/Classes/PHPWord/Writer/ODText/Manifest.php +++ b/Classes/PHPWord/Writer/ODText/Manifest.php @@ -113,9 +113,10 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart /** * Get image mime type * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception + * @param string $pFile Filename + * @return string Mime Type + * @throws Exception + * @codeCoverageIgnore Image is not yet handled by ODText */ private function _getImageMimeType($pFile = '') { diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php index e62341bf..0f9aac14 100755 --- a/Classes/PHPWord/Writer/Word2007.php +++ b/Classes/PHPWord/Writer/Word2007.php @@ -289,4 +289,14 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter $this->checkContentTypes($element['source']); } } + + /** + * Get disk caching directory + * + * @return string + */ + public function getDiskCachingDirectory() + { + return $this->_diskCachingDirectory; + } } diff --git a/Tests/PHPWord/Writer/ODText/WriterPartTest.php b/Tests/PHPWord/Writer/ODText/WriterPartTest.php new file mode 100644 index 00000000..f7b70ba2 --- /dev/null +++ b/Tests/PHPWord/Writer/ODText/WriterPartTest.php @@ -0,0 +1,45 @@ +getMockForAbstractClass( + 'PHPWord_Writer_Word2007_WriterPart' + ); + $object->setParentWriter(new PHPWord_Writer_ODText()); + $this->assertEquals( + new PHPWord_Writer_ODText(), + $object->getParentWriter() + ); + } + + /** + * covers ::getParentWriter + * @expectedException Exception + * @expectedExceptionMessage No parent PHPWord_Writer_IWriter assigned. + */ + public function testSetGetParentWriterNull() + { + $object = $this->getMockForAbstractClass( + 'PHPWord_Writer_Word2007_WriterPart' + ); + $object->getParentWriter(); + } +} diff --git a/Tests/PHPWord/Writer/ODTextTest.php b/Tests/PHPWord/Writer/ODTextTest.php index ef92d249..7cc49fba 100644 --- a/Tests/PHPWord/Writer/ODTextTest.php +++ b/Tests/PHPWord/Writer/ODTextTest.php @@ -92,19 +92,6 @@ class ODTextTest extends \PHPUnit_Framework_TestCase unlink($file); } - /** - * @covers ::save - * @todo Haven't got any method to test this - */ - public function testSavePhpOutput() - { - $phpWord = new PHPWord(); - $section = $phpWord->createSection(); - $section->addText('Test'); - $writer = new PHPWord_Writer_ODText($phpWord); - $writer->save('php://output'); - } - /** * @covers ::save * @expectedException Exception diff --git a/Tests/PHPWord/Writer/RTFTest.php b/Tests/PHPWord/Writer/RTFTest.php index d071def7..8735c7d7 100644 --- a/Tests/PHPWord/Writer/RTFTest.php +++ b/Tests/PHPWord/Writer/RTFTest.php @@ -35,19 +35,6 @@ class RTFTest extends \PHPUnit_Framework_TestCase $object->getPHPWord(); } - /** - * @covers ::save - * @todo Haven't got any method to test this - */ - public function testSavePhpOutput() - { - $phpWord = new PHPWord(); - $section = $phpWord->createSection(); - $section->addText('Test'); - $writer = new PHPWord_Writer_RTF($phpWord); - $writer->save('php://output'); - } - /** * @covers ::save * @expectedException Exception @@ -78,13 +65,15 @@ class RTFTest extends \PHPUnit_Framework_TestCase array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.rtf') ); + $fontStyle = array('name' => 'Verdana', 'size' => 11, 'bold' => true, 'italic' => true, 'color' => 'F29101', 'fgColor' => '123456'); + $paragraphStyle = array('align' => 'center', 'spaceAfter' => 120); $phpWord = new PHPWord(); - $phpWord->addFontStyle('Font', array('size' => 11)); - $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); + $phpWord->addFontStyle('Font', $fontStyle); + $phpWord->addParagraphStyle('Paragraph', $paragraphStyle); $section = $phpWord->createSection(); $section->addText('Test 1', 'Font'); + $section->addText('Test 2', array('name' => 'Tahoma'), 'Paragraph'); $section->addTextBreak(); - $section->addText('Test 2', null, 'Paragraph'); $section->addLink('http://test.com'); $section->addTitle('Test', 1); $section->addPageBreak(); diff --git a/Tests/PHPWord/Writer/Word2007/FooterTest.php b/Tests/PHPWord/Writer/Word2007/FooterTest.php new file mode 100644 index 00000000..1facc622 --- /dev/null +++ b/Tests/PHPWord/Writer/Word2007/FooterTest.php @@ -0,0 +1,44 @@ +addText(''); + $container->addPreserveText(''); + $container->addTextBreak(); + $container->createTextRun(); + $container->addTable()->addRow()->addCell()->addText(''); + $container->addImage($imageSrc); + + $writer = new PHPWord_Writer_Word2007(); + $object = new PHPWord_Writer_Word2007_Footer(); + $object->setParentWriter($writer); + $object->writeFooter($container); + $writer->setUseDiskCaching(true); + $xml = simplexml_load_string($object->writeFooter($container)); + + $this->assertInstanceOf('SimpleXMLElement', $xml); + } +} diff --git a/Tests/PHPWord/Writer/Word2007/HeaderTest.php b/Tests/PHPWord/Writer/Word2007/HeaderTest.php new file mode 100644 index 00000000..f4972b7c --- /dev/null +++ b/Tests/PHPWord/Writer/Word2007/HeaderTest.php @@ -0,0 +1,46 @@ +addText('Test'); + $container->addPreserveText(''); + $container->addTextBreak(); + $container->createTextRun(); + $container->addTable()->addRow()->addCell()->addText(''); + $container->addImage($imageSrc); + $container->addWatermark($imageSrc); + + $writer = new PHPWord_Writer_Word2007(); + $object = new PHPWord_Writer_Word2007_Header(); + $object->setParentWriter($writer); + $object->writeHeader($container); + $writer->setUseDiskCaching(true); + $xml = simplexml_load_string($object->writeHeader($container)); + + $this->assertInstanceOf('SimpleXMLElement', $xml); + } +} diff --git a/Tests/PHPWord/Writer/Word2007/WriterPartTest.php b/Tests/PHPWord/Writer/Word2007/WriterPartTest.php new file mode 100644 index 00000000..3d983178 --- /dev/null +++ b/Tests/PHPWord/Writer/Word2007/WriterPartTest.php @@ -0,0 +1,45 @@ +getMockForAbstractClass( + 'PHPWord_Writer_Word2007_WriterPart' + ); + $object->setParentWriter(new PHPWord_Writer_Word2007()); + $this->assertEquals( + new PHPWord_Writer_Word2007(), + $object->getParentWriter() + ); + } + + /** + * covers ::getParentWriter + * @expectedException Exception + * @expectedExceptionMessage No parent PHPWord_Writer_IWriter assigned. + */ + public function testSetGetParentWriterNull() + { + $object = $this->getMockForAbstractClass( + 'PHPWord_Writer_Word2007_WriterPart' + ); + $object->getParentWriter(); + } +} diff --git a/Tests/PHPWord/Writer/Word2007Test.php b/Tests/PHPWord/Writer/Word2007Test.php index 95abee83..ca1d7d82 100644 --- a/Tests/PHPWord/Writer/Word2007Test.php +++ b/Tests/PHPWord/Writer/Word2007Test.php @@ -67,6 +67,26 @@ class Word2007Test extends \PHPUnit_Framework_TestCase unlink($file); } + /** + * @covers ::save + * @expectedException Exception + * @expectedExceptionMessage PHPWord object unassigned. + */ + public function testSaveException() + { + $writer = new PHPWord_Writer_Word2007(); + $writer->save(); + } + + /** + * @covers ::getWriterPart + */ + public function testGetWriterPartNull() + { + $object = new PHPWord_Writer_Word2007(); + $this->assertNull($object->getWriterPart('foo')); + } + /** * @covers ::checkContentTypes */ @@ -100,13 +120,14 @@ class Word2007Test extends \PHPUnit_Framework_TestCase /** * @covers ::setUseDiskCaching * @covers ::getUseDiskCaching + * @covers ::getDiskCachingDirectory */ public function testSetGetUseDiskCaching() { $object = new PHPWord_Writer_Word2007(); $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); - $this->assertTrue($object->getUseDiskCaching()); + $this->assertEquals(PHPWORD_TESTS_DIR_ROOT, $object->getDiskCachingDirectory()); } /** From 18c1e5f77b32f66e663509cd72f59c865d5897e7 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 16 Mar 2014 08:42:02 +0700 Subject: [PATCH 3/6] Additional template test --- Tests/PHPWord/TemplateTest.php | 30 ++++++++++++++++++++++-- Tests/_files/templates/clone-merge.docx | Bin 0 -> 14690 bytes Tests/_files/templates/clone-row.docx | Bin 14690 -> 14678 bytes 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 Tests/_files/templates/clone-merge.docx diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index 872ab182..1439cebc 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -145,17 +145,43 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase @$template->applyXslStyleSheet($xslDOMDocument); } + /** + * @covers PHPWord_Template + */ + public function testConstruct() + { + $template = \join( + \DIRECTORY_SEPARATOR, + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-row.docx') + ); + $expectedVar = array('tableHeader', 'userId', 'userName'); + $document = new PHPWord_Template($template); + $actualVar = $document->getVariables(); + $document->cloneRow('userId', 9); + $document->setValue('userId#1', utf8_decode('ééé')); + $document->setValue('userId#2', 'a'); + $document->setValue('userId#3', 'a'); + $document->setValue('userId#3', 'a'); + $document->setValue('userId#4', 'a'); + $document->setValue('userId#5', 'a'); + $document->setValue('userId#6', 'a'); + $document->setValue('userId#7', 'a'); + $document->setValue('userId#8', 'a'); + $document->cloneRow('userId#9', 'a'); + $this->assertEquals($expectedVar, $actualVar); + } + /** * @covers ::setValue * @covers ::getVariables * @covers ::cloneRow * @covers ::saveAs */ - public function testCloneRow() + public function testCloneMergedRow() { $template = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-row.docx') + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-merge.docx') ); $expectedVar = array('tableHeader', 'userId', 'userName', 'userLocation'); $docName = 'clone-test-result.docx'; diff --git a/Tests/_files/templates/clone-merge.docx b/Tests/_files/templates/clone-merge.docx new file mode 100644 index 0000000000000000000000000000000000000000..eb944367f035ea2a39f4ea0fa3ab7e7cc3939bef GIT binary patch literal 14690 zcmd6OWmFwmur365f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pZyQ_+#mjx ziTE1A5SGyQC(Vtlb-zr%=)bT0zmm^hAiSO-Y+(L`c%6#&8sdd#)wcRy5HI?l5Wgou zy@rr@-pKhgU*=Ux)PG^zyY~FTc+vmF_&p2fH3rRdO5Hzma{db;d8p|Z!i)YV!tWU$ zuMvozr<%VI{>uOOFN_xtz36{p{GN938Uy(GdHNT|>m-E#f_Q16FZ!Plzi*?xhKPUn z0`b?T+J6BwS#bI`&miSMAKh_Rj8-M8tFPcNH9K=mie zA2Z%-<1Ze1(f>7c{9KFqJ+gd#3+BHYe;x$?N@e~vwZ2AsaoEe~@uL5}l|Oj-J@9&s z)x&Qh k%kKZxGl}tKzl^?U8F7%G;mq?KjRcVOoHAZW_w(rg0KN^N5dZ)H literal 0 HcmV?d00001 diff --git a/Tests/_files/templates/clone-row.docx b/Tests/_files/templates/clone-row.docx index eb944367f035ea2a39f4ea0fa3ab7e7cc3939bef..8bea4f038347055bb24accfe12d11bc60b976337 100644 GIT binary patch delta 983 zcmaD<12bf)Wacj)V)jVpt0vnxp4Uh&MiVRCBdy;}A;Hv%_p^{hVpkm3J*%YvL4_x^~L zZb>;-q-s2cCrQN6GxS{Q%!SL3zn?BF66v1em!%rncJ0if**Bm2Uk;t6eTzdamW3np z^3-LLtL9wRJT@)NN5EQOj#O&sL$(mkHC;`?^=;v&p8U}AdvxKlTVR^*k>74lCPi#H z+L=7-lFy-(g*^&lbcbmQ>oWFvlj`nu zxyTyTH_xa)q8@TY+3KjK=9}Yhj0Iax^L^g8_@?!pC#NeLRy#N7ooAL2dwy<(+joRquFTHqlwDLQ?}sN(kJZw|nkg~ARokXdeSNpJ$d9vMqHj<9=A`^>T%{*2l-hjETR7!* z@#$l%=6Qz$L!%|O&I%B_CU>CV_o+LQ^Qz6JznN#v70GwpvE}#Q2Y0VG{%+6wCce3l zca;P<`2^^SZ8lMpWCw9J2k0s=gBisJ&WvE`orWg7`&EDfe7*BOhWC&$IchU`Bhy4kimoS&>{p*Z=Eu@qzKWO0)uMu*8&CdrJ- zlkb@%GD=Q%FimFqAu@TXX(D6yWOg$rumgO|q%~O87#Pa)i&FGUGE#F>^|=@nz`1~t zL4v`e?~7%#=}Y@=>!iM()Wv=I(F<%ypp##22OJ6r&h`;rhuJ%;gvpCcih& zWn4cw*22vl7%(ni`=A6Hg9?--0HmV~7#J{3t(g4>>?{}^*|lbpk?7?A7E+9Llcg-3 K*yb66%m4tX{+e3= delta 955 zcmcas^r(n8z?+#xgaHKjqw_cNzT{#C(vyF3Dey^0=ez9FH{WW^#K6GDK3SbxrGCq8 zw%sQ$o$0#V9r{{nZSc}Oeg}hXfoIzp)K4$l`GprCx2tJC^+~2&%+xA`~RuF z$~fEe)GJLx@~B4Aq*ZfH8#&w8*X*3J@Pw68agg>&qb;dovHJJ+&(6OTbJ5M^zgR0Z-@n8E)H>)O2IwgDV=Vxy%=NC4`F1sW;jasCImMp-}rovo51-#rx?>*N-gX zQ}4_4GUn`VHEOaj@a<$Z?C;&juuH9PeZ|?kVmCgPv-b;ua01qH_v6Ja2!hQue^Kljcnehk2VLMDmqMm&dAqYoE@^5U8-I> zS5v-vT1xuHM=vj4dlT89Y{)Nq@dG>8EIsd)JdsxyaCnIwTpu zi+lg`PJSXBv&LXug3a9CbdK$Ol4l{52!M-__ca;PvDQy-~(`N@WTyzzf!HjeRXGU-;TWe^-`{dl65;lkPj9_~6 zJ3|+Ul&P@+Z_3L@U@0&?d9ArPdXk)OY{;6%r_#(e`K+-mQz7r)^eU6)i+3 z&oh%^w3@urER9iovVyrgOqYhUE(1e(eo=~kd{Jsnu|5}r0yz6HGDt9>7zK2(DN~N_ zP3E(7Vq0Yh GvJC*r=!wh# From 745f3c81b5d5696ad449a8e206304a7dfcf96ff6 Mon Sep 17 00:00:00 2001 From: Brandon Skrtich Date: Sun, 16 Mar 2014 11:52:56 -0600 Subject: [PATCH 4/6] Add function to check for image type. Some servers do not have exif_imagetype available. So I added a work around. --- Classes/PHPWord/Media.php | 2 +- Classes/PHPWord/Section/Image.php | 3 +- Classes/PHPWord/Shared/File.php | 47 +++++++++++++++++++++-------- Classes/PHPWord/Writer/Word2007.php | 2 +- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/Classes/PHPWord/Media.php b/Classes/PHPWord/Media.php index 03328184..5fac968b 100755 --- a/Classes/PHPWord/Media.php +++ b/Classes/PHPWord/Media.php @@ -101,7 +101,7 @@ class PHPWord_Media $media['createfunction'] = $memoryImage->getImageCreateFunction(); $media['imagefunction'] = $memoryImage->getImageFunction(); } else { - $imageType = exif_imagetype($src); + $imageType = PHPWord_Shared_File::imagetype($src); if ($imageType === IMAGETYPE_JPEG) { $extension = 'jpg'; } elseif ($imageType === IMAGETYPE_GIF) { diff --git a/Classes/PHPWord/Section/Image.php b/Classes/PHPWord/Section/Image.php index fcaa1cc9..b8272e89 100755 --- a/Classes/PHPWord/Section/Image.php +++ b/Classes/PHPWord/Section/Image.php @@ -61,7 +61,6 @@ class PHPWord_Section_Image */ private $_isWatermark; - /** * Create a new Image * @@ -78,7 +77,7 @@ class PHPWord_Section_Image throw new InvalidImageException; } - if (!in_array(exif_imagetype($src), $supportedImageTypes)) { + if (!in_array(PHPWord_Shared_File::imagetype($src), $supportedImageTypes)) { throw new UnsupportedImageTypeException; } diff --git a/Classes/PHPWord/Shared/File.php b/Classes/PHPWord/Shared/File.php index 26a206ba..43b0cad4 100755 --- a/Classes/PHPWord/Shared/File.php +++ b/Classes/PHPWord/Shared/File.php @@ -33,12 +33,11 @@ class PHPWord_Shared_File /** * Verify if a file exists * - * @param string $pFilename Filename + * @param string $pFilename Filename * @return bool */ public static function file_exists($pFilename) { - // Regular file_exists return file_exists($pFilename); } @@ -50,18 +49,13 @@ class PHPWord_Shared_File */ public static function realpath($pFilename) { - // Returnvalue - $returnValue = ''; - - // Try using realpath() $returnValue = realpath($pFilename); - // Found something? - if ($returnValue == '' || is_null($returnValue)) { + if (!$returnValue) { $pathArray = explode('/', $pFilename); - while (in_array('..', $pathArray) && $pathArray[0] != '..') { + while (in_array('..', $pathArray) && $pathArray[0] !== '..') { for ($i = 0; $i < count($pathArray); ++$i) { - if ($pathArray[$i] == '..' && $i > 0) { + if ($pathArray[$i] === '..' && $i > 0) { unset($pathArray[$i]); unset($pathArray[$i - 1]); break; @@ -71,7 +65,36 @@ class PHPWord_Shared_File $returnValue = implode('/', $pathArray); } - // Return return $returnValue; } -} + + /** + * PHP Words version of exif_imagetype to return the Image Type from a file + * + * @param string $filename + * @return int|bool + */ + public static function PHPWord_imagetype($filename) + { + if ((list($width, $height, $type, $attr) = getimagesize($filename)) !== false) { + return $type; + } + return false; + } + + /** + * Return the Image Type from a file + * + * @param string $filename + * @return int|bool + */ + public static function imagetype($filename) + { + if (function_exists('exif_imagetype')) { + return exif_imagetype($filename); + } else { + return self::PHPWord_imagetype($filename); + } + return false; + } +} \ No newline at end of file diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php index e62341bf..110ba392 100755 --- a/Classes/PHPWord/Writer/Word2007.php +++ b/Classes/PHPWord/Writer/Word2007.php @@ -212,7 +212,7 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter if (stripos(strrev($src), strrev('.php')) === 0) { $extension = 'php'; } else { - $imageType = exif_imagetype($src); + $imageType = PHPWord_Shared_File::imagetype($src); if ($imageType === IMAGETYPE_JPEG) { $extension = 'jpg'; } elseif ($imageType === IMAGETYPE_GIF) { From 74566e38627bb25f66df52a289a046f9eefa7d3c Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Sun, 16 Mar 2014 16:35:24 -0400 Subject: [PATCH 5/6] Added test case for image type detection Conflicts: changelog.txt --- Classes/PHPWord/Media.php | 14 +------ Classes/PHPWord/Section/Image.php | 4 +- Classes/PHPWord/Shared/File.php | 42 +++++++++++++++---- Classes/PHPWord/Writer/Word2007.php | 21 ++-------- Tests/PHPWord/Shared/FileTest.php | 37 +++++++++++++++- .../PHPWord/Writer/Word2007/DocumentTest.php | 2 +- Tests/_inc/TestHelperDOCX.php | 9 ++-- changelog.txt | 3 ++ 8 files changed, 87 insertions(+), 45 deletions(-) diff --git a/Classes/PHPWord/Media.php b/Classes/PHPWord/Media.php index 5fac968b..1d422775 100755 --- a/Classes/PHPWord/Media.php +++ b/Classes/PHPWord/Media.php @@ -94,25 +94,13 @@ class PHPWord_Media if (!$isMemImage) { $isMemImage = (filter_var($src, FILTER_VALIDATE_URL) !== false); } - $extension = ''; if ($isMemImage) { $extension = $memoryImage->getImageExtension(); $media['isMemImage'] = true; $media['createfunction'] = $memoryImage->getImageCreateFunction(); $media['imagefunction'] = $memoryImage->getImageFunction(); } else { - $imageType = PHPWord_Shared_File::imagetype($src); - if ($imageType === IMAGETYPE_JPEG) { - $extension = 'jpg'; - } elseif ($imageType === IMAGETYPE_GIF) { - $extension = 'gif'; - } elseif ($imageType === IMAGETYPE_PNG) { - $extension = 'png'; - } elseif ($imageType === IMAGETYPE_BMP) { - $extension = 'bmp'; - } elseif ($imageType === IMAGETYPE_TIFF_II || $imageType === IMAGETYPE_TIFF_MM) { - $extension = 'tif'; - } + $extension = PHPWord_Shared_File::imagetype($src); } $folder = 'media'; diff --git a/Classes/PHPWord/Section/Image.php b/Classes/PHPWord/Section/Image.php index b8272e89..30a10449 100755 --- a/Classes/PHPWord/Section/Image.php +++ b/Classes/PHPWord/Section/Image.php @@ -71,13 +71,11 @@ class PHPWord_Section_Image */ public function __construct($src, $style = null, $isWatermark = false) { - $supportedImageTypes = array(IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM); - if (!file_exists($src)) { throw new InvalidImageException; } - if (!in_array(PHPWord_Shared_File::imagetype($src), $supportedImageTypes)) { + if (!PHPWord_Shared_File::imagetype($src)) { throw new UnsupportedImageTypeException; } diff --git a/Classes/PHPWord/Shared/File.php b/Classes/PHPWord/Shared/File.php index 43b0cad4..4ed0e725 100755 --- a/Classes/PHPWord/Shared/File.php +++ b/Classes/PHPWord/Shared/File.php @@ -30,6 +30,12 @@ */ class PHPWord_Shared_File { + const IMAGETYPE_JPEG = 'jpg'; + const IMAGETYPE_GIF = 'gif'; + const IMAGETYPE_PNG = 'png'; + const IMAGETYPE_BMP = 'bmp'; + const IMAGETYPE_TIFF = 'tif'; + /** * Verify if a file exists * @@ -74,10 +80,20 @@ class PHPWord_Shared_File * @param string $filename * @return int|bool */ - public static function PHPWord_imagetype($filename) + private static function fallbackImagetype($filename) { if ((list($width, $height, $type, $attr) = getimagesize($filename)) !== false) { - return $type; + if ($type === 2) { + return self::IMAGETYPE_JPEG; + } elseif ($type === 1) { + return self::IMAGETYPE_GIF; + } elseif ($type === 3) { + return self::IMAGETYPE_PNG; + } elseif ($type === 6) { + return self::IMAGETYPE_BMP; + } elseif ($type === 7 || $type === 8) { + return self::IMAGETYPE_TIFF; + } } return false; } @@ -86,14 +102,26 @@ class PHPWord_Shared_File * Return the Image Type from a file * * @param string $filename + * @param bool $userFallbackFunction * @return int|bool */ - public static function imagetype($filename) + public static function imagetype($filename, $userFallbackFunction = false) { - if (function_exists('exif_imagetype')) { - return exif_imagetype($filename); - } else { - return self::PHPWord_imagetype($filename); + if ($userFallbackFunction || !function_exists('exif_imagetype')) { + return self::fallbackImagetype($filename); + } + + $imagetype = exif_imagetype($filename); + if ($imagetype === IMAGETYPE_JPEG) { + return self::IMAGETYPE_JPEG; + } elseif ($imagetype === IMAGETYPE_GIF) { + return self::IMAGETYPE_GIF; + } elseif ($imagetype === IMAGETYPE_PNG) { + return self::IMAGETYPE_PNG; + } elseif ($imagetype === IMAGETYPE_BMP) { + return self::IMAGETYPE_BMP; + } elseif ($imagetype === IMAGETYPE_TIFF_II || $imagetype === IMAGETYPE_TIFF_MM) { + return self::IMAGETYPE_TIFF; } return false; } diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php index 110ba392..50890363 100755 --- a/Classes/PHPWord/Writer/Word2007.php +++ b/Classes/PHPWord/Writer/Word2007.php @@ -212,21 +212,10 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter if (stripos(strrev($src), strrev('.php')) === 0) { $extension = 'php'; } else { - $imageType = PHPWord_Shared_File::imagetype($src); - if ($imageType === IMAGETYPE_JPEG) { - $extension = 'jpg'; - } elseif ($imageType === IMAGETYPE_GIF) { - $extension = 'gif'; - } elseif ($imageType === IMAGETYPE_PNG) { - $extension = 'png'; - } elseif ($imageType === IMAGETYPE_BMP) { - $extension = 'bmp'; - } elseif ($imageType === IMAGETYPE_TIFF_II || $imageType === IMAGETYPE_TIFF_MM) { - $extension = 'tif'; - } + $extension = PHPWord_Shared_File::imagetype($src); } - if (isset($extension)) { + if (isset($extension) && $extension) { $imageData = getimagesize($src); $imageType = image_type_to_mime_type($imageData[2]); $imageExtension = str_replace('.', '', image_type_to_extension($imageData[2])); @@ -236,10 +225,8 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter if (!in_array($imageType, $this->_imageTypes)) { $this->_imageTypes[$imageExtension] = $imageType; } - } else { - if (!in_array($extension, $this->_objectTypes)) { - $this->_objectTypes[] = $extension; - } + } elseif (!in_array($extension, $this->_objectTypes)) { + $this->_objectTypes[] = $extension; } } diff --git a/Tests/PHPWord/Shared/FileTest.php b/Tests/PHPWord/Shared/FileTest.php index a5ac348f..fe825b8f 100644 --- a/Tests/PHPWord/Shared/FileTest.php +++ b/Tests/PHPWord/Shared/FileTest.php @@ -54,4 +54,39 @@ class FileTest extends \PHPUnit_Framework_TestCase $expected = $dir . DIRECTORY_SEPARATOR . $file; $this->assertEquals($expected, PHPWord_Shared_File::realpath($file)); } -} + + /** + * @covers PHPWord_Shared_File::imagetype + * @covers PHPWord_Shared_File::fallbackImagetype + */ + public function testImagetype() + { + $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg"; + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename, true)); + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename)); + + $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg"; + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename, true)); + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename)); + + $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif"; + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_GIF, PHPWord_Shared_File::imagetype($filename, true)); + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_GIF, PHPWord_Shared_File::imagetype($filename)); + + $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png"; + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_PNG, PHPWord_Shared_File::imagetype($filename, true)); + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_PNG, PHPWord_Shared_File::imagetype($filename)); + + $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp"; + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_BMP, PHPWord_Shared_File::imagetype($filename, true)); + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_BMP, PHPWord_Shared_File::imagetype($filename)); + + $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif"; + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_TIFF, PHPWord_Shared_File::imagetype($filename, true)); + $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_TIFF, PHPWord_Shared_File::imagetype($filename)); + + $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/alexz-johnson.pcx"; + $this->assertFalse(PHPWord_Shared_File::imagetype($filename, true)); + $this->assertFalse(PHPWord_Shared_File::imagetype($filename)); + } +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007/DocumentTest.php b/Tests/PHPWord/Writer/Word2007/DocumentTest.php index fe854fee..5bc11b5a 100644 --- a/Tests/PHPWord/Writer/Word2007/DocumentTest.php +++ b/Tests/PHPWord/Writer/Word2007/DocumentTest.php @@ -84,4 +84,4 @@ class DocumentTest extends \PHPUnit_Framework_TestCase $element = $doc->getElement('/w:document/w:body/w:p[11]/w:r/w:object/o:OLEObject'); $this->assertEquals('Embed', $element->getAttribute('Type')); } -} +} \ No newline at end of file diff --git a/Tests/_inc/TestHelperDOCX.php b/Tests/_inc/TestHelperDOCX.php index dec1f077..ba5dcf07 100644 --- a/Tests/_inc/TestHelperDOCX.php +++ b/Tests/_inc/TestHelperDOCX.php @@ -5,11 +5,14 @@ use PHPWord; class TestHelperDOCX { - /** @var string $file */ - static protected $file; + /** + * @var string + */ + protected static $file; /** * @param \PHPWord $PHPWord + * @param string $writer * @return \PHPWord\Tests\XmlDocument */ public static function getDocument(PHPWord $PHPWord, $writer = 'Word2007') @@ -67,4 +70,4 @@ class TestHelperDOCX { return self::$file; } -} +} \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index d603eecd..23c4c4c2 100755 --- a/changelog.txt +++ b/changelog.txt @@ -22,6 +22,9 @@ * @version ##VERSION##, ##DATE## ************************************************************************************** +Changes in branch for release 0.8.1 : +- Feature: (bskrtich, gabrielbull) - Added fallback for computers that do not have exif_imagetype + Changes in branch for release 0.8.0 : - Bugfix: (gabrielbull) - Fixed bug with cell styling - Bugfix: (gabrielbull) - Fixed bug list items inside of cells From fca9e532cfc07ab0e1c58e2eec452b5d98feb702 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 17 Mar 2014 07:26:25 +0700 Subject: [PATCH 6/6] DocBlock corrections --- Classes/PHPWord.php | 23 +-- Classes/PHPWord/Autoloader.php | 2 +- Classes/PHPWord/Exceptions/Exception.php | 25 +++ .../Exceptions/InvalidImageException.php | 25 +++ .../Exceptions/InvalidStyleException.php | 25 +++ .../UnsupportedImageTypeException.php | 25 +++ Classes/PHPWord/Footnote.php | 3 +- Classes/PHPWord/Reader/Abstract.php | 2 + Classes/PHPWord/Section/Footer.php | 3 + .../PHPWord/Section/Footer/PreserveText.php | 6 +- Classes/PHPWord/Section/Footnote.php | 6 +- Classes/PHPWord/Section/Header.php | 3 + Classes/PHPWord/Section/Link.php | 8 +- Classes/PHPWord/Section/ListItem.php | 3 +- Classes/PHPWord/Section/Settings.php | 8 + Classes/PHPWord/Section/Table.php | 3 +- Classes/PHPWord/Section/Table/Cell.php | 4 +- Classes/PHPWord/Section/Text.php | 2 + Classes/PHPWord/Section/TextBreak.php | 7 +- Classes/PHPWord/Section/TextRun.php | 16 +- Classes/PHPWord/Section/Title.php | 9 +- Classes/PHPWord/Shared/Font.php | 26 ++- Classes/PHPWord/Shared/XMLWriter.php | 6 +- Classes/PHPWord/Shared/ZipStreamWrapper.php | 10 ++ Classes/PHPWord/Style.php | 16 +- Classes/PHPWord/Style/Cell.php | 128 ++++++++++++++- Classes/PHPWord/Style/Font.php | 4 + Classes/PHPWord/Style/Image.php | 60 +++++++ Classes/PHPWord/Style/Paragraph.php | 10 +- Classes/PHPWord/Style/Row.php | 25 +++ Classes/PHPWord/Style/Table.php | 68 +++++++- Classes/PHPWord/Style/TableFull.php | 152 +++++++++++++++++- Classes/PHPWord/Style/Tabs.php | 2 + Classes/PHPWord/TOC.php | 2 + Classes/PHPWord/Writer/IWriter.php | 4 +- Classes/PHPWord/Writer/ODText.php | 21 +-- Classes/PHPWord/Writer/ODText/Content.php | 20 ++- Classes/PHPWord/Writer/RTF.php | 63 +++++++- Classes/PHPWord/Writer/Word2007.php | 71 +++++++- Classes/PHPWord/Writer/Word2007/Base.php | 12 +- .../PHPWord/Writer/Word2007/ContentTypes.php | 33 ++-- Classes/PHPWord/Writer/Word2007/DocProps.php | 14 +- Classes/PHPWord/Writer/Word2007/Document.php | 22 ++- .../PHPWord/Writer/Word2007/DocumentRels.php | 23 ++- Classes/PHPWord/Writer/Word2007/Footer.php | 7 +- Classes/PHPWord/Writer/Word2007/Footnotes.php | 10 +- .../PHPWord/Writer/Word2007/FootnotesRels.php | 18 ++- Classes/PHPWord/Writer/Word2007/Header.php | 7 +- Classes/PHPWord/Writer/Word2007/Rels.php | 6 +- Classes/PHPWord/Writer/Word2007/Styles.php | 30 +++- .../PHPWord/Writer/Word2007/WriterPart.php | 15 ++ 51 files changed, 984 insertions(+), 109 deletions(-) diff --git a/Classes/PHPWord.php b/Classes/PHPWord.php index d591b94e..e7501d85 100755 --- a/Classes/PHPWord.php +++ b/Classes/PHPWord.php @@ -188,8 +188,8 @@ class PHPWord /** * Adds a paragraph style definition to styles.xml * - * @param $styleName string - * @param $styles array + * @param string $styleName + * @param array $styles */ public function addParagraphStyle($styleName, $styles) { @@ -199,8 +199,9 @@ class PHPWord /** * Adds a font style definition to styles.xml * - * @param $styleName string - * @param $styles array + * @param string $styleName + * @param array $styleFont + * @param array $styleParagraph */ public function addFontStyle($styleName, $styleFont, $styleParagraph = null) { @@ -210,8 +211,9 @@ class PHPWord /** * Adds a table style definition to styles.xml * - * @param $styleName string - * @param $styles array + * @param string $styleName + * @param array $styleTable + * @param array $styleFirstRow */ public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) { @@ -221,8 +223,9 @@ class PHPWord /** * Adds a heading style definition to styles.xml * - * @param $titleCount int - * @param $styles array + * @param int $titleCount + * @param array $styleFont + * @param array $styleParagraph */ public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) { @@ -232,8 +235,8 @@ class PHPWord /** * Adds a hyperlink style to styles.xml * - * @param $styleName string - * @param $styles array + * @param string $styleName + * @param array $styles */ public function addLinkStyle($styleName, $styles) { diff --git a/Classes/PHPWord/Autoloader.php b/Classes/PHPWord/Autoloader.php index aa36efc8..6a915563 100755 --- a/Classes/PHPWord/Autoloader.php +++ b/Classes/PHPWord/Autoloader.php @@ -69,7 +69,7 @@ class PHPWord_Autoloader /** * Autoloader * - * @param string + * @param string $class */ public static function autoload($class) { diff --git a/Classes/PHPWord/Exceptions/Exception.php b/Classes/PHPWord/Exceptions/Exception.php index 11cb0516..d00ed0a9 100755 --- a/Classes/PHPWord/Exceptions/Exception.php +++ b/Classes/PHPWord/Exceptions/Exception.php @@ -1,4 +1,29 @@ _valign; } + /** + * Set vertical align + * + * @param string $pValue + */ public function setVAlign($pValue = null) { $this->_valign = $pValue; } + /** + * Get text direction + */ public function getTextDirection() { return $this->_textDirection; } + /** + * Set text direction + * + * @param string $pValue + */ public function setTextDirection($pValue = null) { $this->_textDirection = $pValue; } + /** + * Get background color + */ public function getBgColor() { return $this->_bgColor; } + /** + * Set background color + * + * @param string $pValue + */ public function setBgColor($pValue = null) { $this->_bgColor = $pValue; } + /** + * Set border size + * + * @param int $pValue + */ public function setBorderSize($pValue = null) { $this->_borderTopSize = $pValue; @@ -209,6 +238,9 @@ class PHPWord_Style_Cell $this->_borderBottomSize = $pValue; } + /** + * Get border size + */ public function getBorderSize() { $t = $this->getBorderTopSize(); @@ -219,6 +251,11 @@ class PHPWord_Style_Cell return array($t, $l, $r, $b); } + /** + * Set border color + * + * @param string $pValue + */ public function setBorderColor($pValue = null) { $this->_borderTopColor = $pValue; @@ -227,6 +264,9 @@ class PHPWord_Style_Cell $this->_borderBottomColor = $pValue; } + /** + * Get border color + */ public function getBorderColor() { $t = $this->getBorderTopColor(); @@ -237,107 +277,189 @@ class PHPWord_Style_Cell return array($t, $l, $r, $b); } + /** + * Set border top size + * + * @param int $pValue + */ public function setBorderTopSize($pValue = null) { $this->_borderTopSize = $pValue; } + /** + * Get border top size + */ public function getBorderTopSize() { return $this->_borderTopSize; } + /** + * Set border top color + * + * @param string $pValue + */ public function setBorderTopColor($pValue = null) { $this->_borderTopColor = $pValue; } + /** + * Get border top color + */ public function getBorderTopColor() { return $this->_borderTopColor; } + /** + * Set border left size + * + * @param int $pValue + */ public function setBorderLeftSize($pValue = null) { $this->_borderLeftSize = $pValue; } + /** + * Get border left size + */ public function getBorderLeftSize() { return $this->_borderLeftSize; } + /** + * Set border left color + * + * @param string $pValue + */ public function setBorderLeftColor($pValue = null) { $this->_borderLeftColor = $pValue; } + /** + * Get border left color + */ public function getBorderLeftColor() { return $this->_borderLeftColor; } + /** + * Set border right size + * + * @param int $pValue + */ public function setBorderRightSize($pValue = null) { $this->_borderRightSize = $pValue; } + /** + * Get border right size + */ public function getBorderRightSize() { return $this->_borderRightSize; } + /** + * Set border right color + * + * @param string $pValue + */ public function setBorderRightColor($pValue = null) { $this->_borderRightColor = $pValue; } + /** + * Get border right color + */ public function getBorderRightColor() { return $this->_borderRightColor; } - + /** + * Set border bottom size + * + * @param int $pValue + */ public function setBorderBottomSize($pValue = null) { $this->_borderBottomSize = $pValue; } + /** + * Get border bottom size + */ public function getBorderBottomSize() { return $this->_borderBottomSize; } + /** + * Set border bottom color + * + * @param string $pValue + */ public function setBorderBottomColor($pValue = null) { $this->_borderBottomColor = $pValue; } + /** + * Get border bottom color + */ public function getBorderBottomColor() { return $this->_borderBottomColor; } + /** + * Get default border color + */ public function getDefaultBorderColor() { return $this->_defaultBorderColor; } + /** + * Set grid span (colspan) + * + * @param int $pValue + */ public function setGridSpan($pValue = null) { $this->_gridSpan = $pValue; } + /** + * Get grid span (colspan) + */ public function getGridSpan() { return $this->_gridSpan; } + /** + * Set vertical merge (rowspan) + * + * @param string $pValue + */ public function setVMerge($pValue = null) { $this->_vMerge = $pValue; } + /** + * Get vertical merge (rowspan) + */ public function getVMerge() { return $this->_vMerge; diff --git a/Classes/PHPWord/Style/Font.php b/Classes/PHPWord/Style/Font.php index f26f3924..2aa6cbc6 100755 --- a/Classes/PHPWord/Style/Font.php +++ b/Classes/PHPWord/Style/Font.php @@ -185,6 +185,8 @@ class PHPWord_Style_Font } /** + * Set style using associative array + * * @param array $style * @return $this */ @@ -510,6 +512,8 @@ class PHPWord_Style_Font } /** + * Get line height + * * @return int|float */ public function getLineHeight() diff --git a/Classes/PHPWord/Style/Image.php b/Classes/PHPWord/Style/Image.php index 9bec4d5b..a6a128c9 100755 --- a/Classes/PHPWord/Style/Image.php +++ b/Classes/PHPWord/Style/Image.php @@ -36,9 +36,32 @@ class PHPWord_Style_Image const WRAPPING_STYLE_BEHIND = 'behind'; const WRAPPING_STYLE_INFRONT = 'infront'; + /** + * Image width + * + * @var int + */ private $_width; + + /** + * Image width + * + * @var int + */ private $_height; + + /** + * Alignment + * + * @var string + */ private $_align; + + /** + * Wrapping style + * + * @var string + */ private $wrappingStyle; /** @@ -55,6 +78,9 @@ class PHPWord_Style_Image */ private $_marginLeft; + /** + * Constructor + */ public function __construct() { $this->_width = null; @@ -65,36 +91,66 @@ class PHPWord_Style_Image $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); } + /** + * Set style value + * + * @param string $key + * @param mixed $value + */ public function setStyleValue($key, $value) { $this->$key = $value; } + /** + * Get width + */ public function getWidth() { return $this->_width; } + /** + * Set width + * + * @param int $pValue + */ public function setWidth($pValue = null) { $this->_width = $pValue; } + /** + * Get height + */ public function getHeight() { return $this->_height; } + /** + * Set height + * + * @param int $pValue + */ public function setHeight($pValue = null) { $this->_height = $pValue; } + /** + * Get alignment + */ public function getAlign() { return $this->_align; } + /** + * Set alignment + * + * @param string $pValue + */ public function setAlign($pValue = null) { $this->_align = $pValue; @@ -145,6 +201,8 @@ class PHPWord_Style_Image } /** + * Set wrapping style + * * @param string $wrappingStyle * @throws InvalidArgumentException * @return $this @@ -167,6 +225,8 @@ class PHPWord_Style_Image } /** + * Get wrapping style + * * @return string */ public function getWrappingStyle() diff --git a/Classes/PHPWord/Style/Paragraph.php b/Classes/PHPWord/Style/Paragraph.php index 32a44929..14e1f8e0 100755 --- a/Classes/PHPWord/Style/Paragraph.php +++ b/Classes/PHPWord/Style/Paragraph.php @@ -133,6 +133,8 @@ class PHPWord_Style_Paragraph private $_pageBreakBefore = false; /** + * Set style using associative array + * * @param array $style * @return $this */ @@ -319,11 +321,11 @@ class PHPWord_Style_Paragraph return $this->_tabs; } - /* + /** * Set tabs * - * @param array $pValue - * @return PHPWord_Style_Paragraph + * @param array $pValue + * @return PHPWord_Style_Paragraph */ public function setTabs($pValue = null) { @@ -500,6 +502,8 @@ class PHPWord_Style_Paragraph } /** + * Get line height + * * @return int|float */ public function getLineHeight() diff --git a/Classes/PHPWord/Style/Row.php b/Classes/PHPWord/Style/Row.php index 93b5f862..da039d84 100644 --- a/Classes/PHPWord/Style/Row.php +++ b/Classes/PHPWord/Style/Row.php @@ -54,12 +54,21 @@ class PHPWord_Style_Row /** * Set style value + * + * @param string $key + * @param mixed $value */ public function setStyleValue($key, $value) { $this->$key = $value; } + /** + * Set tblHeader + * + * @param boolean $pValue + * @return PHPWord_Style_Row + */ public function setTblHeader($pValue = false) { if (!is_bool($pValue)) { @@ -69,11 +78,22 @@ class PHPWord_Style_Row return $this; } + /** + * Get tblHeader + * + * @return boolean + */ public function getTblHeader() { return $this->_tblHeader; } + /** + * Set cantSplit + * + * @param boolean $pValue + * @return PHPWord_Style_Row + */ public function setCantSplit($pValue = false) { if (!is_bool($pValue)) { @@ -83,6 +103,11 @@ class PHPWord_Style_Row return $this; } + /** + * Get cantSplit + * + * @return boolean + */ public function getCantSplit() { return $this->_cantSplit; diff --git a/Classes/PHPWord/Style/Table.php b/Classes/PHPWord/Style/Table.php index c3ef2e01..223e31c2 100755 --- a/Classes/PHPWord/Style/Table.php +++ b/Classes/PHPWord/Style/Table.php @@ -30,12 +30,37 @@ */ class PHPWord_Style_Table { - + /** + * Cell margin top + * + * @var int + */ private $_cellMarginTop; + + /** + * Cell margin left + * + * @var int + */ private $_cellMarginLeft; + + /** + * Cell margin right + * + * @var int + */ private $_cellMarginRight; + + /** + * Cell margin bottom + * + * @var int + */ private $_cellMarginBottom; + /** + * Constructor + */ public function __construct() { $this->_cellMarginTop = null; @@ -44,51 +69,92 @@ class PHPWord_Style_Table $this->_cellMarginBottom = null; } + /** + * Set style value + * + * @param string $key + * @param mixed $value + */ public function setStyleValue($key, $value) { $this->$key = $value; } + /** + * Set cell margin top + * + * @param int $pValue + */ public function setCellMarginTop($pValue = null) { $this->_cellMarginTop = $pValue; } + /** + * Get cell margin top + */ public function getCellMarginTop() { return $this->_cellMarginTop; } + /** + * Set cell margin left + * + * @param int $pValue + */ public function setCellMarginLeft($pValue = null) { $this->_cellMarginLeft = $pValue; } + /** + * Get cell margin left + */ public function getCellMarginLeft() { return $this->_cellMarginLeft; } + /** + * Set cell margin right + * + * @param int $pValue + */ public function setCellMarginRight($pValue = null) { $this->_cellMarginRight = $pValue; } + /** + * Get cell margin right + */ public function getCellMarginRight() { return $this->_cellMarginRight; } + /** + * Set cell margin bottom + * + * @param int $pValue + */ public function setCellMarginBottom($pValue = null) { $this->_cellMarginBottom = $pValue; } + /** + * Get cell margin bottom + */ public function getCellMarginBottom() { return $this->_cellMarginBottom; } + /** + * Get cell margin + */ public function getCellMargin() { return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); diff --git a/Classes/PHPWord/Style/TableFull.php b/Classes/PHPWord/Style/TableFull.php index 573ae53b..8d145366 100755 --- a/Classes/PHPWord/Style/TableFull.php +++ b/Classes/PHPWord/Style/TableFull.php @@ -30,7 +30,6 @@ */ class PHPWord_Style_TableFull { - /** * Style for first row * @@ -160,6 +159,10 @@ class PHPWord_Style_TableFull /** * Create a new TableFull Font + * + * @param null|array $styleTable + * @param null|array $styleFirstRow + * @param null|array $styleLastRow */ public function __construct($styleTable = null, $styleFirstRow = null, $styleLastRow = null) { @@ -234,11 +237,19 @@ class PHPWord_Style_TableFull return $this->_lastRow; } + /** + * Get background color + */ public function getBgColor() { return $this->_bgColor; } + /** + * Set background color + * + * @param string $pValue + */ public function setBgColor($pValue = null) { $this->_bgColor = $pValue; @@ -247,7 +258,7 @@ class PHPWord_Style_TableFull /** * Set TLRBVH Border Size * - * @param int $pValue Border size in eighths of a point (1/8 point) + * @param int $pValue Border size in eighths of a point (1/8 point) */ public function setBorderSize($pValue = null) { @@ -278,6 +289,8 @@ class PHPWord_Style_TableFull /** * Set TLRBVH Border Color + * + * @param string $pValue */ public function setBorderColor($pValue = null) { @@ -306,161 +319,293 @@ class PHPWord_Style_TableFull return array($t, $l, $r, $b, $h, $v); } + /** + * Set border top size + * + * @param int $pValue + */ public function setBorderTopSize($pValue = null) { $this->_borderTopSize = $pValue; } + /** + * Get border top size + */ public function getBorderTopSize() { return $this->_borderTopSize; } + /** + * Set border top color + * + * @param string $pValue + */ public function setBorderTopColor($pValue = null) { $this->_borderTopColor = $pValue; } + /** + * Get border top color + */ public function getBorderTopColor() { return $this->_borderTopColor; } + /** + * Set border left size + * + * @param int $pValue + */ public function setBorderLeftSize($pValue = null) { $this->_borderLeftSize = $pValue; } + /** + * Get border left size + */ public function getBorderLeftSize() { return $this->_borderLeftSize; } + /** + * Set border left color + * + * @param string $pValue + */ public function setBorderLeftColor($pValue = null) { $this->_borderLeftColor = $pValue; } + /** + * Get border left color + */ public function getBorderLeftColor() { return $this->_borderLeftColor; } + /** + * Set border right size + * + * @param int $pValue + */ public function setBorderRightSize($pValue = null) { $this->_borderRightSize = $pValue; } + /** + * Get border right size + * + * @param int $pValue + */ public function getBorderRightSize() { return $this->_borderRightSize; } + /** + * Set border right color + * + * @param string $pValue + */ public function setBorderRightColor($pValue = null) { $this->_borderRightColor = $pValue; } + /** + * Get border right color + */ public function getBorderRightColor() { return $this->_borderRightColor; } + /** + * Set border bottom size + * + * + * @param string $pValue + * @param int $pValue + */ public function setBorderBottomSize($pValue = null) { $this->_borderBottomSize = $pValue; } + /** + * Get border bottom size + */ public function getBorderBottomSize() { return $this->_borderBottomSize; } + /** + * Set border bottom color + * + * @param string $pValue + */ public function setBorderBottomColor($pValue = null) { $this->_borderBottomColor = $pValue; } + /** + * Get border bottom color + */ public function getBorderBottomColor() { return $this->_borderBottomColor; } + /** + * Set border inside horizontal color + * + * @param string $pValue + */ public function setBorderInsideHColor($pValue = null) { $this->_borderInsideHColor = $pValue; } + /** + * Get border inside horizontal color + */ public function getBorderInsideHColor() { return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null; } + /** + * Set border inside vertical color + * + * @param string $pValue + */ public function setBorderInsideVColor($pValue = null) { $this->_borderInsideVColor = $pValue; } + /** + * Get border inside vertical color + */ public function getBorderInsideVColor() { return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null; } + /** + * Set border inside horizontal size + * + * @param int $pValue + */ public function setBorderInsideHSize($pValue = null) { $this->_borderInsideHSize = $pValue; } + /** + * Get border inside horizontal size + */ public function getBorderInsideHSize() { return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null; } + /** + * Set border inside vertical size + * + * @param int $pValue + */ public function setBorderInsideVSize($pValue = null) { $this->_borderInsideVSize = $pValue; } + /** + * Get border inside vertical size + */ public function getBorderInsideVSize() { return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null; } + /** + * Set cell margin top + * + * @param int $pValue + */ public function setCellMarginTop($pValue = null) { $this->_cellMarginTop = $pValue; } + /** + * Get cell margin top + */ public function getCellMarginTop() { return $this->_cellMarginTop; } + /** + * Set cell margin left + * + * @param int $pValue + */ public function setCellMarginLeft($pValue = null) { $this->_cellMarginLeft = $pValue; } + /** + * Get cell margin left + */ public function getCellMarginLeft() { return $this->_cellMarginLeft; } + /** + * Set cell margin right + * + * @param int $pValue + */ public function setCellMarginRight($pValue = null) { $this->_cellMarginRight = $pValue; } + /** + * Get cell margin right + */ public function getCellMarginRight() { return $this->_cellMarginRight; } + /** + * Set cell margin bottom + * + * @param int $pValue + */ public function setCellMarginBottom($pValue = null) { $this->_cellMarginBottom = $pValue; } + /** + * Get cell margin bottom + */ public function getCellMarginBottom() { return $this->_cellMarginBottom; @@ -479,6 +624,9 @@ class PHPWord_Style_TableFull $this->_cellMarginBottom = $pValue; } + /** + * Get cell margin + */ public function getCellMargin() { return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); diff --git a/Classes/PHPWord/Style/Tabs.php b/Classes/PHPWord/Style/Tabs.php index a5e1a8bb..ece1315f 100755 --- a/Classes/PHPWord/Style/Tabs.php +++ b/Classes/PHPWord/Style/Tabs.php @@ -39,6 +39,7 @@ class PHPWord_Style_Tabs private $_tabs; /** + * Constructor * * @param array $tabs */ @@ -48,6 +49,7 @@ class PHPWord_Style_Tabs } /** + * Convert to XML * * @param PHPWord_Shared_XMLWriter $objWriter */ diff --git a/Classes/PHPWord/TOC.php b/Classes/PHPWord/TOC.php index c81fca22..499fdd64 100755 --- a/Classes/PHPWord/TOC.php +++ b/Classes/PHPWord/TOC.php @@ -105,6 +105,8 @@ class PHPWord_TOC /** * Add a Title * + * @param string $text + * @param int $depth * @return array */ public static function addTitle($text, $depth = 0) diff --git a/Classes/PHPWord/Writer/IWriter.php b/Classes/PHPWord/Writer/IWriter.php index f5ca8299..d00d2d40 100755 --- a/Classes/PHPWord/Writer/IWriter.php +++ b/Classes/PHPWord/Writer/IWriter.php @@ -33,8 +33,8 @@ interface PHPWord_Writer_IWriter /** * Save PHPWord to file * - * @param string $pFileName - * @throws Exception + * @param string $pFilename + * @throws Exception */ public function save($pFilename = null); } diff --git a/Classes/PHPWord/Writer/ODText.php b/Classes/PHPWord/Writer/ODText.php index 7d8c2e4b..e8ab61ee 100755 --- a/Classes/PHPWord/Writer/ODText.php +++ b/Classes/PHPWord/Writer/ODText.php @@ -68,7 +68,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter /** * Create a new PHPWord_Writer_ODText * - * @param PHPWord $pPHPWord + * @param PHPWord $pPHPWord */ public function __construct(PHPWord $pPHPWord = null) { @@ -98,8 +98,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter /** * Save PHPWord to file * - * @param string $pFileName - * @throws Exception + * @param string $pFilename + * @throws Exception */ public function save($pFilename = null) { @@ -212,8 +212,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter /** * Get PHPWord object * - * @param PHPWord $pPHPWord PHPWord object - * @throws Exception + * @param PHPWord $pPHPWord PHPWord object + * @throws Exception * @return PHPWord_Writer_ODText */ public function setPHPWord(PHPWord $pPHPWord = null) @@ -226,6 +226,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter * Get PHPWord_Worksheet_BaseDrawing HashTable * * @return PHPWord_HashTable + * @codeCoverageIgnore */ public function getDrawingHashTable() { @@ -235,8 +236,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter /** * Get writer part * - * @param string $pPartName Writer part name - * @return PHPWord_Writer_ODText_WriterPart + * @param string $pPartName Writer part name + * @return PHPWord_Writer_ODText_WriterPart */ public function getWriterPart($pPartName = '') { @@ -260,9 +261,9 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter /** * Set use disk caching where possible? * - * @param boolean $pValue - * @param string $pDirectory Disk caching directory - * @throws Exception Exception when directory does not exist + * @param boolean $pValue + * @param string $pDirectory Disk caching directory + * @throws Exception Exception when directory does not exist * @return PHPWord_Writer_ODText */ public function setUseDiskCaching($pValue = false, $pDirectory = null) diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PHPWord/Writer/ODText/Content.php index 316e56fc..772e5408 100755 --- a/Classes/PHPWord/Writer/ODText/Content.php +++ b/Classes/PHPWord/Writer/ODText/Content.php @@ -344,9 +344,9 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart /** * Write TextRun section * - * @param PHPWord_Shared_XMLWriter $objWriter - * @param PHPWord_Section_TextRun $textrun - * @todo Enable all other section types + * @param PHPWord_Shared_XMLWriter $objWriter + * @param PHPWord_Section_TextRun $textrun + * @todo Enable all other section types */ protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) { @@ -364,6 +364,8 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart /** * Write TextBreak + * + * @param PHPWord_Shared_XMLWriter $objWriter */ protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) { @@ -373,10 +375,22 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart } // @codeCoverageIgnoreStart + /** + * Write end section + * + * @param PHPWord_Shared_XMLWriter $objWriter + * @param PHPWord_Section $section + */ private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null) { } + /** + * Write section + * + * @param PHPWord_Shared_XMLWriter $objWriter + * @param PHPWord_Section $section + */ private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null) { } diff --git a/Classes/PHPWord/Writer/RTF.php b/Classes/PHPWord/Writer/RTF.php index a090fb17..03aee542 100755 --- a/Classes/PHPWord/Writer/RTF.php +++ b/Classes/PHPWord/Writer/RTF.php @@ -44,14 +44,31 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter */ private $_drawingHashTable; + /** + * Color table + * + * @var array + */ private $_colorTable; + + /** + * Font table + * + * @var array + */ private $_fontTable; + + /** + * Last paragraph style + * + * @var PHPWord_Style_Paragraph + */ private $_lastParagraphStyle; /** * Create a new PHPWord_Writer_ODText * - * @param PHPWord $pPHPWord + * @param PHPWord $pPHPWord */ public function __construct(PHPWord $pPHPWord = null) { @@ -65,8 +82,8 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter /** * Save PHPWord to file * - * @param string $pFileName - * @throws Exception + * @param string $pFilename + * @throws Exception */ public function save($pFilename = null) { @@ -115,8 +132,8 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter /** * Get PHPWord object * - * @param PHPWord $pPHPWord PHPWord object - * @throws Exception + * @param PHPWord $pPHPWord PHPWord object + * @throws Exception * @return PHPWord_Writer_RTF */ public function setPHPWord(PHPWord $pPHPWord = null) @@ -129,12 +146,18 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter * Get PHPWord_Worksheet_BaseDrawing HashTable * * @return PHPWord_HashTable + * @codeCoverageIgnore */ public function getDrawingHashTable() { return $this->_drawingHashTable; } + /** + * Get document data + * + * @return string + */ private function getData() { // PHPWord object : $this->_document @@ -188,6 +211,11 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter return $sRTFContent; } + /** + * Get font table + * + * @return array + */ private function getDataFont() { $pPHPWord = $this->_document; @@ -238,6 +266,11 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter return $arrFonts; } + /** + * Get color tables + * + * @return array + */ private function getDataColor() { $pPHPWord = $this->_document; @@ -294,6 +327,11 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter return $arrColors; } + /** + * Get content + * + * @return string + */ private function getDataContent() { $pPHPWord = $this->_document; @@ -342,6 +380,10 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter /** * Get text + * + * @param PHPWord_Section_Text $text + * @param boolean $withoutP + * @return string */ private function getDataContentText(PHPWord_Section_Text $text, $withoutP = false) { @@ -428,11 +470,15 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter if (!$withoutP) { $sRTFText .= '\par' . PHP_EOL; } + return $sRTFText; } /** * Get text run content + * + * @param PHPWord_Section_TextRun $textrun + * @return string */ private function getDataContentTextRun(PHPWord_Section_TextRun $textrun) { @@ -449,9 +495,15 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter } $sRTFText .= '\par' . PHP_EOL; } + return $sRTFText; } + /** + * Get text break + * + * @return string + */ private function getDataContentTextBreak() { $this->_lastParagraphStyle = ''; @@ -463,6 +515,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter * Write unsupported element * * @param string $element + * @return string */ private function getDataContentUnsupportedElement($element) { diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php index 989fa93f..16d66c66 100755 --- a/Classes/PHPWord/Writer/Word2007.php +++ b/Classes/PHPWord/Writer/Word2007.php @@ -24,7 +24,6 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 */ - use PhpOffice\PhpWord\Exceptions\InvalidImageException; use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException; @@ -33,15 +32,54 @@ use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException; */ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter { - + /** + * PHPWord object + * + * @var PHPWord + */ private $_document; + + /** + * Writer parts + * + * @var array + */ private $_writerParts; + + /** + * Directory for caching + * + * @var string + */ private $_diskCachingDirectory; + + /** + * Use disk caching + * + * @var boolean + */ private $_useDiskCaching = false; + + /** + * Image types + * + * @var array + */ private $_imageTypes = array(); + + /** + * Object types + * + * @var array + */ private $_objectTypes = array(); - public function __construct(PHPWord $PHPWord = null) + /** + * Constructor + * + * @param PHPWord $PHPWord + */ + public function __construct(PHPWord $PHPWord = null) { $this->_document = $PHPWord; @@ -63,6 +101,11 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter } } + /** + * Save + * + * @param string $pFilename + */ public function save($pFilename = null) { if (!is_null($this->_document)) { @@ -204,6 +247,8 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter } /** + * Check content types + * * @param string $src */ private function checkContentTypes($src) @@ -230,6 +275,11 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter } } + /** + * Get writer part + * + * @param string $pPartName + */ public function getWriterPart($pPartName = '') { if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { @@ -239,11 +289,20 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter } } + /** + * Get use disk catching setting + */ public function getUseDiskCaching() { return $this->_useDiskCaching; } + /** + * Set use disk catching setting + * + * @param boolean $pValue + * @param string $pDirectory + */ public function setUseDiskCaching($pValue = false, $pDirectory = null) { $this->_useDiskCaching = $pValue; @@ -259,6 +318,12 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter return $this; } + /** + * Add file to package + * + * @param mixed $objZip + * @param array $element + */ private function _addFileToPackage($objZip, $element) { if (isset($element['isMemImage']) && $element['isMemImage']) { diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php index e9249120..d829bf92 100755 --- a/Classes/PHPWord/Writer/Word2007/Base.php +++ b/Classes/PHPWord/Writer/Word2007/Base.php @@ -31,9 +31,10 @@ */ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart { - /** * Write text + * + * @param boolean $withoutP */ protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) { @@ -232,6 +233,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart /** * Write link + * + * @param boolean $withoutP */ protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) { @@ -791,8 +794,11 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart } /** + * Write image + * * @param \PHPWord_Shared_XMLWriter $objWriter * @param \PHPWord_Section_Image|\PHPWord_Section_MemoryImage $image + * @param boolean $withoutP */ protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image, $withoutP = false) { @@ -873,6 +879,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart /** * Write watermark + * + * @param PHP_Section_Image|PHP_Section_MemoryImage $image */ protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) { @@ -1003,6 +1011,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart /** * Write footnote reference + * + * @param boolean $withoutP */ protected function _writeFootnoteReference(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote, $withoutP = false) { diff --git a/Classes/PHPWord/Writer/Word2007/ContentTypes.php b/Classes/PHPWord/Writer/Word2007/ContentTypes.php index 8a6e39ef..26032ae1 100755 --- a/Classes/PHPWord/Writer/Word2007/ContentTypes.php +++ b/Classes/PHPWord/Writer/Word2007/ContentTypes.php @@ -30,7 +30,15 @@ */ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_WriterPart { - + /** + * Write contenttypes.xml + * + * @param array $_imageTypes + * @param array $_objectTypes + * @param int $_cHdrs + * @param array $footers + * @return string XML data + */ public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers) { // Create XML writer @@ -163,7 +171,6 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write } } - $objWriter->endElement(); // Return @@ -173,9 +180,9 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write /** * Get image mime type * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception + * @param string $pFile Filename + * @return string Mime Type + * @throws Exception */ private function _getImageMimeType($pFile = '') { @@ -190,10 +197,10 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write /** * Write Default content type * - * @param PHPWord_Shared_XMLWriter $objWriter XML Writer - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception + * @param PHPWord_Shared_XMLWriter $objWriter XML Writer + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception */ private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') { @@ -211,10 +218,10 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write /** * Write Override content type * - * @param PHPWord_Shared_XMLWriter $objWriter XML Writer - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception + * @param PHPWord_Shared_XMLWriter $objWriter XML Writer + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception */ private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') { diff --git a/Classes/PHPWord/Writer/Word2007/DocProps.php b/Classes/PHPWord/Writer/Word2007/DocProps.php index 2e8f8b5a..b2ec6f39 100755 --- a/Classes/PHPWord/Writer/Word2007/DocProps.php +++ b/Classes/PHPWord/Writer/Word2007/DocProps.php @@ -30,7 +30,12 @@ */ class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPart { - + /** + * Write app.xml + * + * @param PHPWord $pPHPWord + * @return string XML data + */ public function writeDocPropsApp(PHPWord $pPHPWord = null) { // Create XML writer @@ -122,7 +127,12 @@ class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPar return $objWriter->getData(); } - + /** + * Write core.xml + * + * @param PHPWord $pPHPWord + * @return string XML data + */ public function writeDocPropsCore(PHPWord $pPHPWord = null) { // Create XML writer diff --git a/Classes/PHPWord/Writer/Word2007/Document.php b/Classes/PHPWord/Writer/Word2007/Document.php index abdd92cc..1bd86152 100755 --- a/Classes/PHPWord/Writer/Word2007/Document.php +++ b/Classes/PHPWord/Writer/Word2007/Document.php @@ -30,7 +30,9 @@ */ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base { - + /** + * Write document.xml + */ public function writeDocument(PHPWord $pPHPWord = null) { // Create XML writer @@ -114,6 +116,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base return $objWriter->getData(); } + /** + * Write section start + */ private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) { $objWriter->startElement('w:p'); @@ -123,6 +128,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base $objWriter->endElement(); } + /** + * Write section end + */ private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) { $settings = $section->getSettings(); @@ -256,6 +264,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base $objWriter->endElement(); } + /** + * Write page break element + */ private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null) { $objWriter->startElement('w:p'); @@ -267,6 +278,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base $objWriter->endElement(); } + /** + * Write list item element + */ public function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem) { $textObject = $listItem->getTextObject(); @@ -306,6 +320,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base $objWriter->endElement(); } + /** + * Write object element + */ protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object) { $rIdObject = $object->getRelationId(); @@ -365,6 +382,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base $objWriter->endElement(); // w:p } + /** + * Write TOC element + */ private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null) { $titles = PHPWord_TOC::getTitles(); diff --git a/Classes/PHPWord/Writer/Word2007/DocumentRels.php b/Classes/PHPWord/Writer/Word2007/DocumentRels.php index 9817a31f..eda62c5e 100755 --- a/Classes/PHPWord/Writer/Word2007/DocumentRels.php +++ b/Classes/PHPWord/Writer/Word2007/DocumentRels.php @@ -30,7 +30,12 @@ */ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_WriterPart { - + /** + * Write word/_rels/document.xml.rels + * + * @param array $_relsCollection + * @return string XML data + */ public function writeDocumentRels($_relsCollection) { // Create XML writer @@ -119,6 +124,12 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write return $objWriter->getData(); } + /** + * Write word/_rels/(header|footer)(\d).xml.rels + * + * @param array $_relsCollection + * @return string XML data + */ public function writeHeaderFooterRels($_relsCollection) { // Create XML writer @@ -150,13 +161,21 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write ); } - $objWriter->endElement(); // Return return $objWriter->getData(); } + /** + * Write individual relations + * + * @param PHPWord_Shared_XMLWriter $objWriter + * @param int $pId + * @param string $pType + * @param string $pTarget + * @param string $pTargetMode + */ private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { if ($pType != '' && $pTarget != '') { diff --git a/Classes/PHPWord/Writer/Word2007/Footer.php b/Classes/PHPWord/Writer/Word2007/Footer.php index 6ee18d66..ef81fdb0 100755 --- a/Classes/PHPWord/Writer/Word2007/Footer.php +++ b/Classes/PHPWord/Writer/Word2007/Footer.php @@ -30,7 +30,12 @@ */ class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base { - + /** + * Write footer + * + * @param PHPWord_Section_Footer $footer + * @return string XML data + */ public function writeFooter(PHPWord_Section_Footer $footer) { // Create XML writer diff --git a/Classes/PHPWord/Writer/Word2007/Footnotes.php b/Classes/PHPWord/Writer/Word2007/Footnotes.php index 28d087c7..5d0680ce 100644 --- a/Classes/PHPWord/Writer/Word2007/Footnotes.php +++ b/Classes/PHPWord/Writer/Word2007/Footnotes.php @@ -25,9 +25,17 @@ * @version 0.8.0 */ - +/** + * Class PHPWord_Writer_Word2007_Footnotes + */ class PHPWord_Writer_Word2007_Footnotes extends PHPWord_Writer_Word2007_Base { + /** + * Write footnotes.xml + * + * @param array $allFootnotesCollection + * @return string XML data + */ public function writeFootnotes($allFootnotesCollection) { // Create XML writer diff --git a/Classes/PHPWord/Writer/Word2007/FootnotesRels.php b/Classes/PHPWord/Writer/Word2007/FootnotesRels.php index 0e562b59..48721985 100644 --- a/Classes/PHPWord/Writer/Word2007/FootnotesRels.php +++ b/Classes/PHPWord/Writer/Word2007/FootnotesRels.php @@ -25,9 +25,16 @@ * @version 0.8.0 */ - +/** + * Class PHPWord_Writer_Word2007_FootnotesRels + */ class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_WriterPart { + /** + * Write footnotes relationships + * + * @param array $_relsCollection + */ public function writeFootnotesRels($_relsCollection) { // Create XML writer @@ -61,6 +68,15 @@ class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_Writ return $objWriter->getData(); } + /** + * Write individual relations + * + * @param PHPWord_Shared_XMLWriter $objWriter + * @param int $pId + * @param string $pType + * @param string $pTarget + * @param string $pTargetMode + */ private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { if ($pType != '' && $pTarget != '') { diff --git a/Classes/PHPWord/Writer/Word2007/Header.php b/Classes/PHPWord/Writer/Word2007/Header.php index 59eebd91..0c11183b 100755 --- a/Classes/PHPWord/Writer/Word2007/Header.php +++ b/Classes/PHPWord/Writer/Word2007/Header.php @@ -30,7 +30,12 @@ */ class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base { - + /** + * Write header + * + * @param PHPWord_Section_Header $header + * @return string XML data + */ public function writeHeader(PHPWord_Section_Header $header) { // Create XML writer diff --git a/Classes/PHPWord/Writer/Word2007/Rels.php b/Classes/PHPWord/Writer/Word2007/Rels.php index 06eb59cc..9304bda6 100755 --- a/Classes/PHPWord/Writer/Word2007/Rels.php +++ b/Classes/PHPWord/Writer/Word2007/Rels.php @@ -30,7 +30,11 @@ */ class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart { - + /** + * Write _rels/.rels + * + * @param PHPWord $pPHPWord + */ public function writeRelationships(PHPWord $pPHPWord = null) { // Create XML writer diff --git a/Classes/PHPWord/Writer/Word2007/Styles.php b/Classes/PHPWord/Writer/Word2007/Styles.php index 3724323e..1f61051a 100755 --- a/Classes/PHPWord/Writer/Word2007/Styles.php +++ b/Classes/PHPWord/Writer/Word2007/Styles.php @@ -30,9 +30,18 @@ */ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base { - + /** + * PHPWord object + * + * @var PHPWord + */ private $_document; + /** + * Write styles + * + * @param PHPWord $pPHPWord + */ public function writeStyles(PHPWord $pPHPWord = null) { // Create XML writer @@ -181,6 +190,12 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base return $objWriter->getData(); } + /** + * Write style + * + * @param PHPWord_Shared_XMLWriter $objWriter + * @param PHPWord_Style_TableFull $style + */ private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_TableFull $style) { @@ -302,6 +317,13 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base } } + /** + * Write row style + * + * @param PHPWord_Shared_XMLWriter $objWriter + * @param string $type + * @param PHPWord_Style_TableFull $style + */ private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_TableFull $style) { $brdSz = $style->getBorderSize(); @@ -362,7 +384,11 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base $objWriter->endElement(); } - + /** + * Write doc defaults + * + * @param PHPWord_Shared_XMLWriter $objWriter + */ private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null) { $fontName = $this->_document->getDefaultFontName(); diff --git a/Classes/PHPWord/Writer/Word2007/WriterPart.php b/Classes/PHPWord/Writer/Word2007/WriterPart.php index cc004254..35cf348f 100755 --- a/Classes/PHPWord/Writer/Word2007/WriterPart.php +++ b/Classes/PHPWord/Writer/Word2007/WriterPart.php @@ -30,13 +30,28 @@ */ abstract class PHPWord_Writer_Word2007_WriterPart { + /** + * Parent writer object + * + * @var PHPWord_Writer_Word2007 + */ private $_parentWriter; + /** + * Set parent writer + * + * @param PHPWord_Writer_IWriter + */ public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) { $this->_parentWriter = $pWriter; } + /** + * Get parent writer + * + * @return PHPWord_Writer_IWriter + */ public function getParentWriter() { if (!is_null($this->_parentWriter)) {