diff --git a/.gitignore b/.gitignore index 6b4358aac6..81767f6bfb 100644 --- a/.gitignore +++ b/.gitignore @@ -18,5 +18,4 @@ vendor *.docx *.rtf *.txt -*.xml -nbproject +*.xml \ No newline at end of file diff --git a/Classes/PHPWord/Reader/Word2007.php b/Classes/PHPWord/Reader/Word2007.php index 48a13e5912..4d372f2717 100644 --- a/Classes/PHPWord/Reader/Word2007.php +++ b/Classes/PHPWord/Reader/Word2007.php @@ -254,8 +254,8 @@ public function load($pFilename) if ($elm->getName() != 'style') { continue; } - unset($pStyle); - unset($fStyle); + $pStyle = null; + $fStyle = null; $hasParagraphStyle = isset($elm->pPr); $hasFontStyle = isset($elm->rPr); $styleName = (string)$elm->name['val']; diff --git a/Classes/PHPWord/Section.php b/Classes/PHPWord/Section.php index 70dceba276..bdf37f81da 100755 --- a/Classes/PHPWord/Section.php +++ b/Classes/PHPWord/Section.php @@ -243,7 +243,9 @@ public function addObject($src, $style = null) $this->_elementCollection[] = $object; return $object; } else { - trigger_error('Source does not exist or unsupported object type.'); + throw new PHPWord_Exception( + 'Source does not exist or unsupported object type.' + ); } } @@ -265,7 +267,9 @@ public function addImage($src, $style = null) $this->_elementCollection[] = $image; return $image; } else { - trigger_error('Source does not exist or unsupported image type.'); + throw new PHPWord_Exception( + 'Source does not exist or unsupported image type.' + ); } } @@ -286,7 +290,9 @@ public function addMemoryImage($link, $style = null) $this->_elementCollection[] = $memoryImage; return $memoryImage; } else { - trigger_error('Unsupported image type.'); + throw new PHPWord_Exception( + 'Unsupported image type.' + ); } } diff --git a/Classes/PHPWord/Section/Footer.php b/Classes/PHPWord/Section/Footer.php index 04d40f331e..3455adc9c9 100755 --- a/Classes/PHPWord/Section/Footer.php +++ b/Classes/PHPWord/Section/Footer.php @@ -133,7 +133,7 @@ public function addImage($src, $style = null) $this->_elementCollection[] = $image; return $image; } else { - trigger_error('Src does not exist or invalid image type.', E_USER_ERROR); + throw new Exception('Src does not exist or invalid image type.'); } } @@ -154,7 +154,7 @@ public function addMemoryImage($link, $style = null) $this->_elementCollection[] = $memoryImage; return $memoryImage; } else { - trigger_error('Unsupported image type.'); + throw new Exception('Unsupported image type.'); } } diff --git a/Classes/PHPWord/Section/Header.php b/Classes/PHPWord/Section/Header.php index 6c62440657..83c82c4973 100755 --- a/Classes/PHPWord/Section/Header.php +++ b/Classes/PHPWord/Section/Header.php @@ -162,7 +162,7 @@ public function addImage($src, $style = null) $this->_elementCollection[] = $image; return $image; } else { - trigger_error('Src does not exist or invalid image type.', E_USER_ERROR); + throw new Exception('Src does not exist or invalid image type.'); } } @@ -183,7 +183,7 @@ public function addMemoryImage($link, $style = null) $this->_elementCollection[] = $memoryImage; return $memoryImage; } else { - trigger_error('Unsupported image type.'); + throw new Exception('Unsupported image type.'); } } @@ -223,7 +223,7 @@ public function addWatermark($src, $style = null) $this->_elementCollection[] = $image; return $image; } else { - trigger_error('Src does not exist or invalid image type.', E_USER_ERROR); + throw new Exception('Src does not exist or invalid image type.'); } } diff --git a/Classes/PHPWord/Section/MemoryImage.php b/Classes/PHPWord/Section/MemoryImage.php index 8486a2a313..f1488c4543 100755 --- a/Classes/PHPWord/Section/MemoryImage.php +++ b/Classes/PHPWord/Section/MemoryImage.php @@ -229,4 +229,4 @@ public function getImageExtension() { return $this->_imageExtension; } -} \ No newline at end of file +} diff --git a/Classes/PHPWord/Section/Table/Cell.php b/Classes/PHPWord/Section/Table/Cell.php index 4f8f78fee9..898c6bf2b2 100755 --- a/Classes/PHPWord/Section/Table/Cell.php +++ b/Classes/PHPWord/Section/Table/Cell.php @@ -140,7 +140,7 @@ public function addLink($linkSrc, $linkName = null, $style = null) $this->_elementCollection[] = $link; return $link; } else { - trigger_error('Unsupported Link header / footer reference'); + throw new Exception('Unsupported Link header / footer reference'); return false; } } @@ -198,7 +198,7 @@ public function addImage($src, $style = null) $this->_elementCollection[] = $image; return $image; } else { - trigger_error('Source does not exist or unsupported image type.'); + throw new Exception('Source does not exist or unsupported image type.'); } } @@ -225,7 +225,7 @@ public function addMemoryImage($link, $style = null) $this->_elementCollection[] = $memoryImage; return $memoryImage; } else { - trigger_error('Unsupported image type.'); + throw new Exception('Unsupported image type.'); } } @@ -266,7 +266,7 @@ public function addObject($src, $style = null) $this->_elementCollection[] = $object; return $object; } else { - trigger_error('Source does not exist or unsupported object type.'); + throw new Exception('Source does not exist or unsupported object type.'); } } @@ -288,7 +288,7 @@ public function addPreserveText($text, $styleFont = null, $styleParagraph = null $this->_elementCollection[] = $ptext; return $ptext; } else { - trigger_error('addPreserveText only supported in footer/header.'); + throw new Exception('addPreserveText only supported in footer/header.'); } } diff --git a/Classes/PHPWord/Section/TextRun.php b/Classes/PHPWord/Section/TextRun.php index c26b2ef652..eeb936a0db 100755 --- a/Classes/PHPWord/Section/TextRun.php +++ b/Classes/PHPWord/Section/TextRun.php @@ -127,7 +127,7 @@ public function addImage($imageSrc, $style = null) $this->_elementCollection[] = $image; return $image; } else { - trigger_error('Source does not exist or unsupported image type.'); + throw new Exception('Source does not exist or unsupported image type.'); } } diff --git a/Classes/PHPWord/Settings.php b/Classes/PHPWord/Settings.php index 67ef697ea3..af400551c3 100644 --- a/Classes/PHPWord/Settings.php +++ b/Classes/PHPWord/Settings.php @@ -28,7 +28,8 @@ /** * PHPWord_Settings */ -class PHPWord_Settings { +class PHPWord_Settings +{ /** * Compatibility option for XMLWriter * @@ -42,12 +43,13 @@ class PHPWord_Settings { * @param boolean $compatibility This sets the setIndent and setIndentString for better compatibility * @return boolean Success or failure */ - public static function setCompatibility($compatibility) { + public static function setCompatibility($compatibility) + { if (is_bool($compatibility)) { self::$_xmlWriterCompatibility = $compatibility; - return TRUE; + return true; } - return FALSE; + return false; } // function setCompatibility() @@ -56,7 +58,8 @@ public static function setCompatibility($compatibility) { * * @return boolean Compatibility */ - public static function getCompatibility() { + public static function getCompatibility() + { return self::$_xmlWriterCompatibility; } // function getCompatibility() -} \ No newline at end of file +} diff --git a/Classes/PHPWord/Style/Font.php b/Classes/PHPWord/Style/Font.php index d31e38f8b2..bc5ee511e8 100755 --- a/Classes/PHPWord/Style/Font.php +++ b/Classes/PHPWord/Style/Font.php @@ -179,8 +179,6 @@ public function __construct($type = 'text', $paragraphStyle = null) } elseif (is_array($paragraphStyle)) { $this->_paragraphStyle = new PHPWord_Style_Paragraph; $this->_paragraphStyle->setArrayStyle($paragraphStyle); - } elseif (null === $paragraphStyle) { - $this->_paragraphStyle = new PHPWord_Style_Paragraph; } else { $this->_paragraphStyle = $paragraphStyle; } diff --git a/Classes/PHPWord/Style/Row.php b/Classes/PHPWord/Style/Row.php index 66d5505fb8..c7140d5897 100644 --- a/Classes/PHPWord/Style/Row.php +++ b/Classes/PHPWord/Style/Row.php @@ -36,22 +36,20 @@ class PHPWord_Style_Row * * @var bool */ - private $_tblHeader; + private $_tblHeader = false; /** * Table row cannot break across pages * * @var bool */ - private $_cantSplit; + private $_cantSplit = false; /** * Create a new row style */ public function __construct() { - $this->_tblHeader = null; - $this->_cantSplit = null; } /** @@ -62,23 +60,31 @@ public function setStyleValue($key, $value) $this->$key = $value; } - public function setTblHeader($pValue = null) + public function setTblHeader($pValue = false) { + if (!is_bool($pValue)) { + $pValue = false; + } $this->_tblHeader = $pValue; + return $this; } public function getTblHeader() { - return $this->_tblHeader ? 1 : 0; + return $this->_tblHeader; } - public function setCantSplit($pValue = null) + public function setCantSplit($pValue = false) { + if (!is_bool($pValue)) { + $pValue = false; + } $this->_cantSplit = $pValue; + return $this; } public function getCantSplit() { - return $this->_cantSplit ? 1 : 0; + return $this->_cantSplit; } } diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index 4d356dd35c..840d22950a 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -164,7 +164,7 @@ private function _findRowStart($offset) $rowStart = strrpos($this->_documentXML, "", ((strlen($this->_documentXML) - $offset) * -1)); } if (!$rowStart) { - trigger_error("Can not find the start position of the row to clone."); + throw new Exception("Can not find the start position of the row to clone."); return false; } return $rowStart; @@ -208,7 +208,7 @@ public function cloneRow($search, $numberOfClones) $tagPos = strpos($this->_documentXML, $search); if (!$tagPos) { - trigger_error("Can not clone row, template variable not found or variable contains markup."); + throw new Exception("Can not clone row, template variable not found or variable contains markup."); return false; } diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PHPWord/Writer/ODText/Content.php index 7ee571a377..b788478e25 100755 --- a/Classes/PHPWord/Writer/ODText/Content.php +++ b/Classes/PHPWord/Writer/ODText/Content.php @@ -253,28 +253,25 @@ public function writeContent(PHPWord $pPHPWord = null) $this->_writeTextRun($objWriter, $element); } elseif ($element instanceof PHPWord_Section_TextBreak) { $this->_writeTextBreak($objWriter); - /* } elseif ($element instanceof PHPWord_Section_Link) { - $this->_writeLink($objWriter, $element); + $this->writeUnsupportedElement($objWriter, 'link'); } elseif ($element instanceof PHPWord_Section_Title) { - $this->_writeTitle($objWriter, $element); + $this->writeUnsupportedElement($objWriter, 'title'); } elseif ($element instanceof PHPWord_Section_PageBreak) { - $this->_writePageBreak($objWriter); + $this->writeUnsupportedElement($objWriter, 'page break'); } elseif ($element instanceof PHPWord_Section_Table) { - $this->_writeTable($objWriter, $element); + $this->writeUnsupportedElement($objWriter, 'table'); } elseif ($element instanceof PHPWord_Section_ListItem) { - $this->_writeListItem($objWriter, $element); + $this->writeUnsupportedElement($objWriter, 'list item'); } elseif ($element instanceof PHPWord_Section_Image || $element instanceof PHPWord_Section_MemoryImage) { - $this->_writeImage($objWriter, $element); + $this->writeUnsupportedElement($objWriter, 'image'); } elseif ($element instanceof PHPWord_Section_Object) { - $this->_writeObject($objWriter, $element); + $this->writeUnsupportedElement($objWriter, 'object'); } elseif ($element instanceof PHPWord_TOC) { - $this->_writeTOC($objWriter); - */ + $this->writeUnsupportedElement($objWriter, 'TOC'); } else { - print_r($element); - echo '
'; + $this->writeUnsupportedElement($objWriter, 'other'); } } @@ -387,4 +384,17 @@ private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PH private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null) { } + + /** + * Write unsupported element + * + * @param PHPWord_Shared_XMLWriter $objWriter + * @param string $element + */ + private function writeUnsupportedElement($objWriter, $element) + { + $objWriter->startElement('text:p'); + $objWriter->writeRaw("Cannot write content. This version of PHPWord has not supported {$element} element in ODText."); + $objWriter->endElement(); + } } diff --git a/Classes/PHPWord/Writer/RTF.php b/Classes/PHPWord/Writer/RTF.php index 66ec7383e8..9104c6fefb 100755 --- a/Classes/PHPWord/Writer/RTF.php +++ b/Classes/PHPWord/Writer/RTF.php @@ -314,28 +314,25 @@ private function getDataContent() $sRTFBody .= $this->getDataContentTextBreak(); } elseif ($element instanceof PHPWord_Section_TextRun) { $sRTFBody .= $this->getDataContentTextRun($element); - /* - } elseif($element instanceof PHPWord_Section_Link) { - $this->_writeLink($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Title) { - $this->_writeTitle($objWriter, $element); - } elseif($element instanceof PHPWord_Section_PageBreak) { - $this->_writePageBreak($objWriter); - } elseif($element instanceof PHPWord_Section_Table) { - $this->_writeTable($objWriter, $element); - } elseif($element instanceof PHPWord_Section_ListItem) { - $this->_writeListItem($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Image || + } elseif ($element instanceof PHPWord_Section_Link) { + $sRTFBody .= $this->getDataContentUnsupportedElement('link'); + } elseif ($element instanceof PHPWord_Section_Title) { + $sRTFBody .= $this->getDataContentUnsupportedElement('title'); + } elseif ($element instanceof PHPWord_Section_PageBreak) { + $sRTFBody .= $this->getDataContentUnsupportedElement('page break'); + } elseif ($element instanceof PHPWord_Section_Table) { + $sRTFBody .= $this->getDataContentUnsupportedElement('table'); + } elseif ($element instanceof PHPWord_Section_ListItem) { + $sRTFBody .= $this->getDataContentUnsupportedElement('list item'); + } elseif ($element instanceof PHPWord_Section_Image || $element instanceof PHPWord_Section_MemoryImage) { - $this->_writeImage($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Object) { - $this->_writeObject($objWriter, $element); - } elseif($element instanceof PHPWord_TOC) { - $this->_writeTOC($objWriter); - */ + $sRTFBody .= $this->getDataContentUnsupportedElement('image'); + } elseif ($element instanceof PHPWord_Section_Object) { + $sRTFBody .= $this->getDataContentUnsupportedElement('object'); + } elseif ($element instanceof PHPWord_TOC) { + $sRTFBody .= $this->getDataContentUnsupportedElement('TOC'); } else { - print_r($element); - echo '
'; + $sRTFBody .= $this->getDataContentUnsupportedElement('other'); } } } @@ -381,7 +378,7 @@ private function getDataContentText(PHPWord_Section_Text $text, $withoutP = fals $this->_lastParagraphStyle = ''; } - if ($styleFont) { + if ($styleFont instanceof PHPWord_Style_Font) { if ($styleFont->getColor() != null) { $idxColor = array_search($styleFont->getColor(), $this->_colorTable); if ($idxColor !== false) { @@ -413,7 +410,7 @@ private function getDataContentText(PHPWord_Section_Text $text, $withoutP = fals } $sRTFText .= $text->getText(); - if ($styleFont) { + if ($styleFont instanceof PHPWord_Style_Font) { $sRTFText .= '\cf0'; $sRTFText .= '\f0'; @@ -461,4 +458,19 @@ private function getDataContentTextBreak() return '\par' . PHP_EOL; } + + /** + * Write unsupported element + * + * @param string $element + */ + private function getDataContentUnsupportedElement($element) + { + $sRTFText = ''; + $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; + $sRTFText .= "Cannot write content. This version of PHPWord has not supported {$element} element in RTF."; + $sRTFText .= '\par' . PHP_EOL; + + return $sRTFText; + } } diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php old mode 100644 new mode 100755 index 04800dfb17..f132425332 --- a/Classes/PHPWord/Writer/Word2007/Base.php +++ b/Classes/PHPWord/Writer/Word2007/Base.php @@ -29,9 +29,14 @@ /** * Class PHPWord_Writer_Word2007_Base */ -class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart { +class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart +{ - protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) { + /** + * Write text + */ + protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) + { $styleFont = $text->getFontStyle(); $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; @@ -80,7 +85,11 @@ protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWor } } - protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) { + /** + * Write text run + */ + protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) + { $elements = $textrun->getElements(); $styleParagraph = $textrun->getParagraphStyle(); @@ -221,7 +230,11 @@ protected function _writeParagraphStyle( } } - protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) { + /** + * Write link + */ + protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) + { $rID = $link->getRelationId(); $linkName = $link->getLinkName(); if (is_null($linkName)) { @@ -276,7 +289,11 @@ protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWor } } - protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) { + /** + * Write preserve text + */ + protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) + { $styleFont = $textrun->getFontStyle(); $styleParagraph = $textrun->getParagraphStyle(); @@ -367,7 +384,11 @@ protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null $objWriter->endElement(); // p } - protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) { + /** + * Write text style + */ + protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) + { $font = $style->getName(); $bold = $style->getBold(); $italic = $style->getItalic(); @@ -454,11 +475,19 @@ protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, P $objWriter->endElement(); } - protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) { + /** + * Write text break + */ + protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) + { $objWriter->writeElement('w:p', null); } - protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) { + /** + * Write table + */ + protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) + { $_rows = $table->getRows(); $_cRows = count($_rows); @@ -500,14 +529,14 @@ protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo $objWriter->writeAttribute('w:val', $height); $objWriter->endElement(); } - if (!is_null($tblHeader)) { + if ($tblHeader) { $objWriter->startElement('w:tblHeader'); - $objWriter->writeAttribute('w:val', $tblHeader); + $objWriter->writeAttribute('w:val', '1'); $objWriter->endElement(); } - if (!is_null($cantSplit)) { + if ($cantSplit) { $objWriter->startElement('w:cantSplit'); - $objWriter->writeAttribute('w:val', $cantSplit); + $objWriter->writeAttribute('w:val', '1'); $objWriter->endElement(); } $objWriter->endElement(); @@ -566,7 +595,11 @@ protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo } } - protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) { + /** + * Write table style + */ + protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) + { $margins = $style->getCellMargin(); $mTop = (!is_null($margins[0])) ? true : false; $mLeft = (!is_null($margins[1])) ? true : false; @@ -610,7 +643,11 @@ protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, } } - protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Cell $style = null) { + /** + * Write cell style + */ + protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Cell $style = null) + { $bgColor = $style->getBgColor(); $valign = $style->getVAlign(); $textDir = $style->getTextDirection(); @@ -716,7 +753,8 @@ protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, P * @param \PHPWord_Shared_XMLWriter $objWriter * @param \PHPWord_Section_Image $image */ - protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Image $image, $withoutP = false) { + protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Image $image, $withoutP = false) + { $rId = $image->getRelationId(); $style = $image->getStyle(); @@ -792,7 +830,11 @@ protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo } } - protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) { + /** + * Write watermark + */ + protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) + { $rId = $image->getRelationId(); $style = $image->getStyle(); @@ -835,7 +877,11 @@ protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $ $objWriter->endElement(); } - protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) { + /** + * Write title + */ + protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) + { $text = htmlspecialchars($title->getText()); $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); $anchor = $title->getAnchor(); @@ -876,6 +922,9 @@ protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo $objWriter->endElement(); } + /** + * Write footnote + */ protected function _writeFootnote(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote) { $objWriter->startElement('w:footnote'); @@ -911,6 +960,9 @@ protected function _writeFootnote(PHPWord_Shared_XMLWriter $objWriter = null, PH $objWriter->endElement(); // w:footnote } + /** + * Write footnote reference + */ protected function _writeFootnoteReference(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote, $withoutP = false) { if (!$withoutP) { diff --git a/README.md b/README.md index 1003a29a38..9140529218 100755 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ __Want to contribute?__ Fork us! ## Requirements * PHP version 5.3.0 or higher -* PHP extension [php_zip](http://php.net/manual/en/book.zip.php) enabled +* PHP extension [ZipArchive](http://php.net/manual/en/book.zip.php) +* PHP extension [XMLWriter](http://php.net/manual/en/book.xmlwriter.php) ## Installation diff --git a/Tests/PHPWord/MediaTest.php b/Tests/PHPWord/MediaTest.php index 665c59115e..b2ebd6ae89 100644 --- a/Tests/PHPWord/MediaTest.php +++ b/Tests/PHPWord/MediaTest.php @@ -47,4 +47,4 @@ public function testAddSectionMediaElement() $this->assertInstanceOf('PHPWord_Section_Image', $element); } } -} \ No newline at end of file +} diff --git a/Tests/PHPWord/SectionTest.php b/Tests/PHPWord/SectionTest.php index 79c9ca3965..ac540d06a8 100644 --- a/Tests/PHPWord/SectionTest.php +++ b/Tests/PHPWord/SectionTest.php @@ -3,35 +3,131 @@ use PHPWord_Section; +/** + * Class TOCTest + * + * @package PHPWord\Tests + * @covers PHPWord_Section + * @runTestsInSeparateProcesses + */ class SectionTest extends \PHPUnit_Framework_TestCase { + /** + * @covers PHPWord_Section::getSettings + */ public function testGetSettings() { $oSection = new PHPWord_Section(0); $this->assertAttributeEquals($oSection->getSettings(), '_settings', new PHPWord_Section(0)); } - public function testGetElementss() + /** + * @covers PHPWord_Section::getElements + */ + public function testGetElements() { $oSection = new PHPWord_Section(0); $this->assertAttributeEquals($oSection->getElements(), '_elementCollection', new PHPWord_Section(0)); } + /** + * @covers PHPWord_Section::getFooter + */ public function testGetFooter() { $oSection = new PHPWord_Section(0); $this->assertAttributeEquals($oSection->getFooter(), '_footer', new PHPWord_Section(0)); } + /** + * @covers PHPWord_Section::getHeaders + */ public function testGetHeaders() { $oSection = new PHPWord_Section(0); $this->assertAttributeEquals($oSection->getHeaders(), '_headers', new PHPWord_Section(0)); } - public function testGetElements() + /** + * @covers PHPWord_Section::setSettings + */ + public function testSetSettings() { - $oSection = new PHPWord_Section(0); - $this->assertAttributeEquals($oSection->getElements(), '_elementCollection', new PHPWord_Section(0)); + $expected = 'landscape'; + $object = new PHPWord_Section(0); + $object->setSettings(array('orientation' => $expected)); + $this->assertEquals($expected, $object->getSettings()->getOrientation()); + } + + /** + * @covers PHPWord_Section::addText + * @covers PHPWord_Section::addLink + * @covers PHPWord_Section::addTextBreak + * @covers PHPWord_Section::addPageBreak + * @covers PHPWord_Section::addTable + * @covers PHPWord_Section::addListItem + * @covers PHPWord_Section::addObject + * @covers PHPWord_Section::addImage + * @covers PHPWord_Section::addMemoryImage + * @covers PHPWord_Section::addTOC + * @covers PHPWord_Section::addTitle + * @covers PHPWord_Section::createTextRun + * @covers PHPWord_Section::createFootnote + */ + public function testAddElements() + { + $objectSource = join( + DIRECTORY_SEPARATOR, + array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + ); + $imageSource = join( + DIRECTORY_SEPARATOR, + array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PHPWord.png') + ); + $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif'; + + $section = new PHPWord_Section(0); + $section->addText(utf8_decode('ä')); + $section->addLink(utf8_decode('http://äää.com'), utf8_decode('ä')); + $section->addTextBreak(); + $section->addPageBreak(); + $section->addTable(); + $section->addListItem(utf8_decode('ä')); + $section->addObject($objectSource); + $section->addImage($imageSource); + $section->addMemoryImage($imageUrl); + $section->addTOC(); + $section->addTitle(utf8_decode('ä'), 1); + $section->createTextRun(); + $section->createFootnote(); + + $elementCollection = $section->getElements(); + $elementType = 'Link'; + $objectType = "PHPWord_Section_{$elementType}"; + $this->assertInstanceOf($objectType, $elementCollection[1]); + // $elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak', + // 'Table', 'ListItem', 'Object', 'Image', 'MemoryImage', 'TOC', + // 'Title', 'TextRun'); + // $i = 0; + // foreach ($elementTypes as $elementType) { + // $objectType = "PHPWord_Section_{$elementType}"; + // $this->assertInstanceOf($objectType, $elementCollection[$i]); + // $i++; + // } + } + + /** + * @covers PHPWord_Section::createHeader + * @covers PHPWord_Section::createFooter + */ + public function testCreateHeaderFooter() + { + $object = new PHPWord_Section(0); + $elements = array('Header', 'Footer'); + foreach ($elements as $element) { + $objectType = "PHPWord_Section_{$element}"; + $method = "create{$element}"; + $this->assertInstanceOf($objectType, $object->$method()); + } } } diff --git a/Tests/PHPWord/Style/TOCTest.php b/Tests/PHPWord/Style/TOCTest.php index 4202c37e24..4607ba37aa 100644 --- a/Tests/PHPWord/Style/TOCTest.php +++ b/Tests/PHPWord/Style/TOCTest.php @@ -7,6 +7,7 @@ * Class TOCTest * * @package PHPWord\Tests + * @covers PHPWord_Style_TOC * @runTestsInSeparateProcesses */ class TOCTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PHPWord/StyleTest.php b/Tests/PHPWord/StyleTest.php new file mode 100644 index 0000000000..36e961acf5 --- /dev/null +++ b/Tests/PHPWord/StyleTest.php @@ -0,0 +1,45 @@ + 'center'); + $font = array('italic' => true); + $table = array('bgColor' => 'CCCCCC'); + $styles = array('Paragraph' => 'Paragraph', 'Font' => 'Font', + 'Link' => 'Font', 'Table' => 'TableFull', + 'Heading_1' => 'Font', 'Normal' => 'Paragraph'); + $elementCount = 6; + PHPWord_Style::addParagraphStyle('Paragraph', $paragraph); + PHPWord_Style::addFontStyle('Font', $font); + PHPWord_Style::addLinkStyle('Link', $font); + PHPWord_Style::addTableStyle('Table', $table); + PHPWord_Style::addTitleStyle(1, $font); + PHPWord_Style::setDefaultParagraphStyle($paragraph); + + $this->assertEquals($elementCount, count(PHPWord_Style::getStyles())); + foreach ($styles as $name => $style) { + $expected = "PHPWord_Style_{$style}"; + $this->assertInstanceOf($expected, PHPWord_Style::getStyle($name)); + } + $this->assertNull(PHPWord_Style::getStyle('Unknown')); + } +} diff --git a/Tests/PHPWord/TOCTest.php b/Tests/PHPWord/TOCTest.php index 608d4f9fd1..d4503da5fd 100644 --- a/Tests/PHPWord/TOCTest.php +++ b/Tests/PHPWord/TOCTest.php @@ -5,7 +5,11 @@ use PHPWord_Style_TOC; /** - * @covers PHPWord_TOC + * Class TOCTest + * + * @package PHPWord\Tests + * @covers PHPWord_TOC + * @runTestsInSeparateProcesses */ class TOCTest extends \PHPUnit_Framework_TestCase { @@ -45,7 +49,7 @@ public function testAddAndGetTitle() // Prepare variables $titleCount = 3; $anchor = '_Toc' . (252634154 + $titleCount); - $bookmark = $titleCount - 1; // zero based + $bookmark = $titleCount - 1; $titles = array( 'Heading 1' => 1, 'Heading 2' => 2, diff --git a/Tests/PHPWord/Writer/Word2007/BaseTest.php b/Tests/PHPWord/Writer/Word2007/BaseTest.php index 98f6e958b0..56f859d9de 100644 --- a/Tests/PHPWord/Writer/Word2007/BaseTest.php +++ b/Tests/PHPWord/Writer/Word2007/BaseTest.php @@ -6,7 +6,9 @@ /** * Class BaseTest - * @package PHPWord\Tests + * + * @package PHPWord\Tests + * @coversDefaultClass PHPWord_Writer_Word2007_Base * @runTestsInSeparateProcesses */ class BaseTest extends \PHPUnit_Framework_TestCase @@ -19,6 +21,89 @@ public function tearDown() TestHelperDOCX::clear(); } + public function testWriteText() + { + $rStyle = 'rStyle'; + $pStyle = 'pStyle'; + + $PHPWord = new PHPWord(); + $PHPWord->addFontStyle($rStyle, array('bold' => true)); + $PHPWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120)); + $section = $PHPWord->createSection(); + $section->addText('Test', $rStyle, $pStyle); + $doc = TestHelperDOCX::getDocument($PHPWord); + + $element = "/w:document/w:body/w:p/w:r/w:rPr/w:rStyle"; + $this->assertEquals($rStyle, $doc->getElementAttribute($element, 'w:val')); + $element = "/w:document/w:body/w:p/w:pPr/w:pStyle"; + $this->assertEquals($pStyle, $doc->getElementAttribute($element, 'w:val')); + } + + /** + * Write text run + */ + public function testWriteTextRun() + { + $pStyle = 'pStyle'; + $aStyle = array('align' => 'justify', 'spaceBefore' => 120, 'spaceAfter' => 120); + $imageSrc = join( + DIRECTORY_SEPARATOR, + array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + ); + + $PHPWord = new PHPWord(); + $PHPWord->addParagraphStyle($pStyle, $aStyle); + $section = $PHPWord->createSection('Test'); + $textrun = $section->createTextRun($pStyle); + $textrun->addText('Test'); + $textrun->addTextBreak(); + $textrun = $section->createTextRun($aStyle); + $textrun->addLink('http://test.com'); + $textrun->addImage($imageSrc); + $doc = TestHelperDOCX::getDocument($PHPWord); + + $parent = "/w:document/w:body/w:p"; + $this->assertTrue($doc->elementExists("{$parent}/w:pPr/w:pStyle[@w:val='{$pStyle}']")); + } + + /** + * Write link + */ + public function testWriteLink() + { + $PHPWord = new PHPWord(); + $section = $PHPWord->createSection(); + + $expected = 'PHPWord'; + $section->addLink('http://github.com/phpoffice/phpword', $expected); + + $doc = TestHelperDOCX::getDocument($PHPWord); + $element = $doc->getElement('/w:document/w:body/w:p/w:hyperlink/w:r/w:t'); + + $this->assertEquals($expected, $element->nodeValue); + } + + /** + * Write preserve text + */ + public function testWritePreserveText() + { + $PHPWord = new PHPWord(); + $section = $PHPWord->createSection(); + $footer = $section->createFooter(); + + $footer->addPreserveText('{PAGE}'); + + $doc = TestHelperDOCX::getDocument($PHPWord); + $preserve = $doc->getElement("w:p/w:r[2]/w:instrText", 'word/footer1.xml'); + + $this->assertEquals('PAGE', $preserve->nodeValue); + $this->assertEquals('preserve', $preserve->getAttribute('xml:space')); + } + + /** + * Write paragraph style: Alignment + */ public function testWriteParagraphStyleAlign() { $PHPWord = new PHPWord(); @@ -33,7 +118,7 @@ public function testWriteParagraphStyleAlign() } /** - * Test write paragraph pagination + * Write paragraph style: Pagination */ public function testWriteParagraphStylePagination() { @@ -62,6 +147,99 @@ public function testWriteParagraphStylePagination() } } + /** + * covers ::_writeTextStyle + */ + public function testWriteFontStyle() + { + $PHPWord = new PHPWord(); + $styles['name'] = 'Verdana'; + $styles['size'] = 14; + $styles['bold'] = true; + $styles['italic'] = true; + $styles['underline'] = 'dash'; + $styles['strikethrough'] = true; + $styles['superScript'] = true; + $styles['color'] = 'FF0000'; + $styles['fgColor'] = 'yellow'; + + $section = $PHPWord->createSection(); + $section->addText('Test', $styles); + $doc = TestHelperDOCX::getDocument($PHPWord); + + $parent = '/w:document/w:body/w:p/w:r/w:rPr'; + $this->assertEquals($styles['name'], $doc->getElementAttribute("{$parent}/w:rFonts", 'w:ascii')); + $this->assertEquals($styles['size'] * 2, $doc->getElementAttribute("{$parent}/w:sz", 'w:val')); + $this->assertTrue($doc->elementExists("{$parent}/w:b")); + $this->assertTrue($doc->elementExists("{$parent}/w:i")); + $this->assertEquals($styles['underline'], $doc->getElementAttribute("{$parent}/w:u", 'w:val')); + $this->assertTrue($doc->elementExists("{$parent}/w:strike")); + $this->assertEquals('superscript', $doc->getElementAttribute("{$parent}/w:vertAlign", 'w:val')); + $this->assertEquals($styles['color'], $doc->getElementAttribute("{$parent}/w:color", 'w:val')); + $this->assertEquals($styles['fgColor'], $doc->getElementAttribute("{$parent}/w:highlight", 'w:val')); + } + + /** + * Write table + */ + public function testWriteTableStyle() + { + $PHPWord = new PHPWord(); + $tWidth = 120; + $rHeight = 120; + $cWidth = 120; + $tStyles["cellMarginTop"] = 120; + $tStyles["cellMarginRight"] = 120; + $tStyles["cellMarginBottom"] = 120; + $tStyles["cellMarginLeft"] = 120; + $rStyles["tblHeader"] = true; + $rStyles["cantSplit"] = true; + $cStyles["valign"] = 'top'; + $cStyles["textDirection"] = 'btLr'; + $cStyles["bgColor"] = 'FF0000'; + $cStyles["borderTopSize"] = 120; + $cStyles["borderBottomSize"] = 120; + $cStyles["borderLeftSize"] = 120; + $cStyles["borderRightSize"] = 120; + $cStyles["borderTopColor"] = 'FF0000'; + $cStyles["borderBottomColor"] = 'FF0000'; + $cStyles["borderLeftColor"] = 'FF0000'; + $cStyles["borderRightColor"] = 'FF0000'; + + $section = $PHPWord->createSection(); + $table = $section->addTable($tStyles); + $table->setWidth = 100; + $table->addRow($rHeight, $rStyles); + $cell = $table->addCell($cWidth, $cStyles); + $cell->addText('Test'); + $cell->addTextBreak(); + $cell->addLink('http://google.com'); + $cell->addListItem('Test'); + $textrun = $cell->createTextRun(); + $textrun->addText('Test'); + + $doc = TestHelperDOCX::getDocument($PHPWord); + + $parent = '/w:document/w:body/w:tbl/w:tblPr/w:tblCellMar'; + $this->assertEquals($tStyles['cellMarginTop'], $doc->getElementAttribute("{$parent}/w:top", 'w:w')); + $this->assertEquals($tStyles['cellMarginRight'], $doc->getElementAttribute("{$parent}/w:right", 'w:w')); + $this->assertEquals($tStyles['cellMarginBottom'], $doc->getElementAttribute("{$parent}/w:bottom", 'w:w')); + $this->assertEquals($tStyles['cellMarginLeft'], $doc->getElementAttribute("{$parent}/w:right", 'w:w')); + + $parent = '/w:document/w:body/w:tbl/w:tr/w:trPr'; + $this->assertEquals($rHeight, $doc->getElementAttribute("{$parent}/w:trHeight", 'w:val')); + $this->assertEquals($rStyles['tblHeader'], $doc->getElementAttribute("{$parent}/w:tblHeader", 'w:val')); + $this->assertEquals($rStyles['cantSplit'], $doc->getElementAttribute("{$parent}/w:cantSplit", 'w:val')); + + $parent = '/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr'; + $this->assertEquals($cWidth, $doc->getElementAttribute("{$parent}/w:tcW", 'w:w')); + $this->assertEquals($cStyles['valign'], $doc->getElementAttribute("{$parent}/w:vAlign", 'w:val')); + $this->assertEquals($cStyles['textDirection'], $doc->getElementAttribute("{$parent}/w:textDirection", 'w:val')); + } + + /** + * Write cell style + */ public function testWriteCellStyleCellGridSpan() { $PHPWord = new PHPWord(); @@ -86,6 +264,9 @@ public function testWriteCellStyleCellGridSpan() $this->assertEquals(5, $element->getAttribute('w:val')); } + /** + * Write image + */ public function testWriteImagePosition() { $PHPWord = new PHPWord(); @@ -108,18 +289,19 @@ public function testWriteImagePosition() $this->assertRegExp('/position:absolute;/', $style); } - public function testWritePreserveText() + /** + * Write title + */ + public function testWriteTitle() { $PHPWord = new PHPWord(); - $section = $PHPWord->createSection(); - $footer = $section->createFooter(); - - $footer->addPreserveText('{PAGE}'); - + $PHPWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240)); + $PHPWord->createSection()->addTitle('Test', 1); $doc = TestHelperDOCX::getDocument($PHPWord); - $preserve = $doc->getElement("w:p/w:r[2]/w:instrText", 'word/footer1.xml'); - $this->assertEquals('PAGE', $preserve->nodeValue); - $this->assertEquals('preserve', $preserve->getAttribute('xml:space')); + $element = "/w:document/w:body/w:p/w:pPr/w:pStyle"; + $this->assertEquals('Heading1', $doc->getElementAttribute($element, 'w:val')); + $element = "/w:document/w:body/w:p/w:r/w:fldChar"; + $this->assertEquals('end', $doc->getElementAttribute($element, 'w:fldCharType')); } } diff --git a/Tests/PHPWord/Writer/Word2007Test.php b/Tests/PHPWord/Writer/Word2007Test.php index 7b0048e712..ac66af2ae9 100644 --- a/Tests/PHPWord/Writer/Word2007Test.php +++ b/Tests/PHPWord/Writer/Word2007Test.php @@ -65,23 +65,28 @@ public function testSave() */ public function testCheckContentTypes() { + $images = array( + 'mars_noext_jpg' => '1.jpg', + 'mars.jpg' => '2.jpg', + 'mario.gif' => '3.gif', + 'firefox.png' => '4.png', + 'duke_nukem.bmp' => '5.bmp', + 'angela_merkel.tif' => '6.tif', + ); $phpWord = new PHPWord(); $section = $phpWord->createSection(); - $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg"); - $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg"); - $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif"); - $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png"); - $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp"); - $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif"); + foreach ($images as $source => $target) { + $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/{$source}"); + } $doc = TestHelperDOCX::getDocument($phpWord); $mediaPath = $doc->getPath() . "/word/media"; - $this->assertFileEquals(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg", $mediaPath . "/section_image1.jpg"); - $this->assertFileEquals(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg", $mediaPath . "/section_image2.jpg"); - $this->assertFileEquals(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif", $mediaPath . "/section_image3.gif"); - $this->assertFileEquals(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png", $mediaPath . "/section_image4.png"); - $this->assertFileEquals(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp", $mediaPath . "/section_image5.bmp"); - $this->assertFileEquals(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif", $mediaPath . "/section_image6.tif"); + foreach ($images as $source => $target) { + $this->assertFileEquals( + PHPWORD_TESTS_DIR_ROOT . "/_files/images/{$source}", + $mediaPath . "/section_image{$target}" + ); + } } -} \ No newline at end of file +} diff --git a/Tests/PHPWordTest.php b/Tests/PHPWordTest.php index 841ecdb618..15106af6bb 100644 --- a/Tests/PHPWordTest.php +++ b/Tests/PHPWordTest.php @@ -7,7 +7,11 @@ use PHPWord_Style; /** - * @covers PHPWord + * Class PHPWordTest + * + * @package PHPWord\Tests + * @covers PHPWord + * @runTestsInSeparateProcesses */ class PHPWordTest extends \PHPUnit_Framework_TestCase { diff --git a/Tests/_files/images/PHPWord.png b/Tests/_files/images/PHPWord.png new file mode 100644 index 0000000000..9b7f4930f4 Binary files /dev/null and b/Tests/_files/images/PHPWord.png differ diff --git a/Tests/_inc/TestHelperDOCX.php b/Tests/_inc/TestHelperDOCX.php index 2d59dcb636..5f8e51a3f7 100644 --- a/Tests/_inc/TestHelperDOCX.php +++ b/Tests/_inc/TestHelperDOCX.php @@ -67,4 +67,4 @@ public static function getFile() { return self::$file; } -} \ No newline at end of file +} diff --git a/Tests/_inc/XmlDocument.php b/Tests/_inc/XmlDocument.php index f16bd6d8de..4d3d00347d 100644 --- a/Tests/_inc/XmlDocument.php +++ b/Tests/_inc/XmlDocument.php @@ -45,11 +45,11 @@ public function getFileDom($file = 'word/document.xml') } /** - * @param string $path - * @param string $file - * @return \DOMElement + * @param string $path + * @param string $file + * @return \DOMNodeList */ - public function getElement($path, $file = 'word/document.xml') + public function getNodeList($path, $file = 'word/document.xml') { if ($this->dom === null || $file !== $this->file) { $this->getFileDom($file); @@ -60,7 +60,18 @@ public function getElement($path, $file = 'word/document.xml') } - $elements = $this->xpath->query($path); + return $this->xpath->query($path); + } + + /** + * @param string $path + * @param string $file + * @return \DOMElement + */ + public function getElement($path, $file = 'word/document.xml') + { + $elements = $this->getNodeList($path, $file); + return $elements->item(0); } @@ -79,4 +90,26 @@ public function getPath() { return $this->path; } + + /** + * @param string $path + * @param string $attribute + * @param string $file + * @return string + */ + public function getElementAttribute($path, $attribute, $file = 'word/document.xml') + { + return $this->getElement($path, $file)->getAttribute($attribute); + } + + /** + * @param string $path + * @param string $file + * @return string + */ + public function elementExists($path, $file = 'word/document.xml') + { + $nodeList = $this->getNodeList($path, $file); + return !($nodeList->length == 0); + } } diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index 4b055cca8a..55ffaf2589 100755 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -1,50 +1,62 @@ '); -} - +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/PHPWord.php'; // New Word Document echo date('H:i:s') , " Create new PHPWord object" , EOL; $PHPWord = new PHPWord(); +$PHPWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16)); +$PHPWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100)); +$PHPWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240)); // New portrait section $section = $PHPWord->createSection(); -// Add text elements +// Simple text +$section->addTitle('Welcome to PHPWord', 1); $section->addText('Hello World!'); -$section->addTextBreak(2); -$section->addText('I am inline styled.', array('name'=>'Verdana', 'color'=>'006699')); +// Two text break $section->addTextBreak(2); -$PHPWord->addFontStyle('rStyle', array('bold'=>true, 'italic'=>true, 'size'=>16)); -$PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100)); -$section->addText('I am styled by two style definitions.', 'rStyle', 'pStyle'); -$section->addText('I have only a paragraph style definition.', null, 'pStyle'); - -// Save File -echo date('H:i:s') , " Write to Word2007 format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save(str_replace('.php', '.docx', __FILE__)); - -echo date('H:i:s') , " Write to OpenDocumentText format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText'); -$objWriter->save(str_replace('.php', '.odt', __FILE__)); - -echo date('H:i:s') , " Write to RTF format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF'); -$objWriter->save(str_replace('.php', '.rtf', __FILE__)); - - -// Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; +// Defined style +$section->addText('I am styled by a font style definition.', 'rStyle'); +$section->addText('I am styled by a paragraph style definition.', null, 'pStyle'); +$section->addText('I am styled by both font and paragraph style.', 'rStyle', 'pStyle'); +$section->addTextBreak(); + +// Inline font style +$fontStyle['name'] = 'Times New Roman'; +$fontStyle['size'] = 20; +$fontStyle['bold'] = true; +$fontStyle['italic'] = true; +$fontStyle['underline'] = 'dash'; +$fontStyle['strikethrough'] = true; +$fontStyle['superScript'] = true; +$fontStyle['color'] = 'FF0000'; +$fontStyle['fgColor'] = 'yellow'; +$section->addText('I am inline styled.', $fontStyle); +$section->addTextBreak(); + +// Link +$section->addLink('http://www.google.com', null, 'NLink'); +$section->addTextBreak(); + +// Image +$section->addImage('old/_earth.jpg', array('width'=>18, 'height'=>18)); + +// Save file +$name = basename(__FILE__, '.php'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} -// Echo done -echo date('H:i:s') , " Done writing file" , EOL; +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index 177e8598f1..e9e2d84bcb 100755 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -1,14 +1,7 @@ '); -} - +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/PHPWord.php'; // New Word Document @@ -42,22 +35,16 @@ $section->addText("Left Aligned\tRight Aligned", NULL, 'rightTab'); $section->addText("\tCenter Aligned", NULL, 'centerTab'); -// Save File -echo date('H:i:s') , ' Write to Word2007 format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save(str_replace('.php', '.docx', __FILE__)); - -echo date('H:i:s') , ' Write to OpenDocumentText format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText'); -$objWriter->save(str_replace('.php', '.odt', __FILE__)); - -echo date('H:i:s') , ' Write to RTF format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF'); -$objWriter->save(str_replace('.php', '.rtf', __FILE__)); - - -// Echo memory peak usage -echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL; +// Save file +$name = basename(__FILE__, '.php'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} -// Echo done -echo date('H:i:s') , ' Done writing file' , EOL; \ No newline at end of file +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index afca97dae6..1e49629e9c 100755 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -1,13 +1,7 @@ '); -} - +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/PHPWord.php'; // New Word Document @@ -34,22 +28,16 @@ $section->createHeader()->addText('Header'); $section->createFooter()->addText('Footer'); -// Save File -echo date('H:i:s') , ' Write to Word2007 format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save(str_replace('.php', '.docx', __FILE__)); - -echo date('H:i:s') , ' Write to OpenDocumentText format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText'); -$objWriter->save(str_replace('.php', '.odt', __FILE__)); - -echo date('H:i:s') , ' Write to RTF format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF'); -$objWriter->save(str_replace('.php', '.rtf', __FILE__)); - - -// Echo memory peak usage -echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL; +// Save file +$name = basename(__FILE__, '.php'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} -// Echo done -echo date('H:i:s') , ' Done writing file' , EOL; +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php index ac0906c9c2..ce70417e20 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -1,14 +1,7 @@ '); -} - +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/PHPWord.php'; // New Word Document @@ -42,21 +35,16 @@ $textrun->addImage('old/_earth.jpg', array('width'=>18, 'height'=>18)); $textrun->addText(' Here is some more text. '); -// Save File -echo date('H:i:s') , ' Write to Word2007 format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save(str_replace('.php', '.docx', __FILE__)); - -echo date('H:i:s') , ' Write to OpenDocumentText format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText'); -$objWriter->save(str_replace('.php', '.odt', __FILE__)); - -echo date('H:i:s') , ' Write to RTF format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF'); -$objWriter->save(str_replace('.php', '.rtf', __FILE__)); - -// Echo memory peak usage -echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL; +// Save file +$name = basename(__FILE__, '.php'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} -// Echo done -echo date('H:i:s') , ' Done writing file' , EOL; \ No newline at end of file +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php index 7f0a75d0b2..3877defeff 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -1,14 +1,7 @@ '); -} - +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/PHPWord.php'; // New Word Document @@ -45,22 +38,16 @@ $section = $PHPWord->createSection(array('breakType' => 'continuous')); $section->addText('Normal paragraph again.'); -// Save File -echo date('H:i:s') , " Write to Word2007 format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save(str_replace('.php', '.docx', __FILE__)); - -echo date('H:i:s') , " Write to OpenDocumentText format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText'); -$objWriter->save(str_replace('.php', '.odt', __FILE__)); - -echo date('H:i:s') , " Write to RTF format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF'); -$objWriter->save(str_replace('.php', '.rtf', __FILE__)); - - -// Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; +// Save file +$name = basename(__FILE__, '.php'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} -// Echo done -echo date('H:i:s') , " Done writing file" , EOL; +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php index 123dedccdf..daaa6b4636 100755 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -1,12 +1,7 @@ '); -} +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/PHPWord.php'; // New Word Document @@ -41,14 +36,16 @@ $footnote = $section->createFootnote(); $footnote->addText('The reference for this is wrapped in its own line'); -// Save File -echo date('H:i:s') , " Write to Word2007 format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save(str_replace('.php', '.docx', __FILE__)); - - -// Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; +// Save file +$name = basename(__FILE__, '.php'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} -// Echo done -echo date('H:i:s') , " Done writing file" , EOL; +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php index ccdee2c32d..f797b986e5 100755 --- a/samples/Sample_07_TemplateCloneRow.php +++ b/samples/Sample_07_TemplateCloneRow.php @@ -1,9 +1,14 @@ '); require_once '../Classes/PHPWord.php'; +// New Word document +echo date('H:i:s') , " Create new PHPWord object" , EOL; $PHPWord = new PHPWord(); -$document = $PHPWord->loadTemplate('Sample_07_TemplateCloneRow.docx'); +$document = $PHPWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx'); // Simple table $document->cloneRow('rowValue', 10); @@ -51,4 +56,11 @@ $document->setValue('userName#3', 'Ray'); $document->setValue('userPhone#3', '+1 428 889 775'); -$document->saveAs('Sample_07_TemplateCloneRow_result.docx'); +$name = 'Sample_07_TemplateCloneRow_result.docx'; +echo date('H:i:s'), " Write to Word2007 format", EOL; +$document->saveAs($name); +rename($name, "results/{$name}"); + +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index 7bbead7a92..edd1992c43 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -1,14 +1,7 @@ '); -} - +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/PHPWord.php'; // New Word document @@ -55,22 +48,16 @@ 'heading styles.', null, array('pageBreakBefore' => true)); -// Save File -echo date('H:i:s') , " Write to Word2007 format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save(str_replace('.php', '.docx', __FILE__)); - -echo date('H:i:s') , " Write to OpenDocumentText format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText'); -$objWriter->save(str_replace('.php', '.odt', __FILE__)); - -echo date('H:i:s') , " Write to RTF format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF'); -$objWriter->save(str_replace('.php', '.rtf', __FILE__)); - - -// Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; +// Save file +$name = basename(__FILE__, '.php'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} -// Echo done -echo date('H:i:s') , " Done writing file" , EOL; +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index f90ac3c91b..96e411a020 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -1,13 +1,7 @@ '); -} - +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/PHPWord.php'; // New Word Document @@ -82,21 +76,16 @@ $table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered); $table->addCell(null, $cellRowContinue); -// Save File -echo date('H:i:s') , ' Write to Word2007 format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save(str_replace('.php', '.docx', __FILE__)); - -// echo date('H:i:s') , ' Write to OpenDocumentText format' , EOL; -// $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText'); -// $objWriter->save(str_replace('.php', '.odt', __FILE__)); -// -// echo date('H:i:s') , ' Write to RTF format' , EOL; -// $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF'); -// $objWriter->save(str_replace('.php', '.rtf', __FILE__)); - -// Echo memory peak usage -echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL; +// Save file +$name = basename(__FILE__, '.php'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} -// Echo done -echo date('H:i:s') , ' Done writing file' , EOL; +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php index cc0a7ef670..8be721091c 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -1,13 +1,7 @@ '); -} - +define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); require_once '../Classes/PHPWord.php'; // New Word Document @@ -18,13 +12,16 @@ //1.Use EastAisa FontStyle $section->addText('中文楷体样式测试',array('name' => '楷体', 'size' => 16, 'color' => '1B2232')); -// Save File -echo date('H:i:s') , ' Write to Word2007 format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save(str_replace('.php', '.docx', __FILE__)); - -// Echo memory peak usage -echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL; +// Save file +$name = basename(__FILE__, '.php'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} -// Echo done -echo date('H:i:s') , ' Done writing file' , EOL; +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_10_ReadWord2007.php b/samples/Sample_10_ReadWord2007.php deleted file mode 100644 index a837a5745a..0000000000 --- a/samples/Sample_10_ReadWord2007.php +++ /dev/null @@ -1,33 +0,0 @@ -'); - -require_once '../Classes/PHPWord.php'; - -// Read contents -$sample = 'Sample_10_ReadWord2007'; -$source = "resources/{$sample}.docx"; -$target = "results/{$sample}"; -echo '

', date('H:i:s'), " Reading contents from `{$source}`

"; -$PHPWord = PHPWord_IOFactory::load($source); - -// Rewrite contents -echo date('H:i:s') , " Write to Word2007 format" , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save("{$sample}.docx"); -rename("{$sample}.docx", "{$target}.docx"); - -echo date('H:i:s') , ' Write to OpenDocumentText format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText'); -$objWriter->save("{$sample}.odt"); -rename("{$sample}.odt", "{$target}.odt"); - -echo date('H:i:s') , ' Write to RTF format' , EOL; -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF'); -$objWriter->save("{$sample}.rtf"); -rename("{$sample}.rtf", "{$target}.rtf"); - -// Echo memory peak usage -echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; -echo date('H:i:s') , " Done writing file" , EOL; diff --git a/samples/Sample_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php new file mode 100644 index 0000000000..d96e92644c --- /dev/null +++ b/samples/Sample_11_ReadWord2007.php @@ -0,0 +1,24 @@ +'); +require_once '../Classes/PHPWord.php'; + +// Read contents +$name = basename(__FILE__, '.php'); +$source = "resources/{$name}.docx"; +echo date('H:i:s'), " Reading contents from `{$source}`", EOL; +$PHPWord = PHPWord_IOFactory::load($source); + +// (Re)write contents +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $objWriter = PHPWord_IOFactory::createWriter($PHPWord, $writer); + $objWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +} + +// Done +echo date('H:i:s'), " Done writing file(s)", EOL; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; diff --git a/samples/Sample_07_TemplateCloneRow.docx b/samples/resources/Sample_07_TemplateCloneRow.docx similarity index 100% rename from samples/Sample_07_TemplateCloneRow.docx rename to samples/resources/Sample_07_TemplateCloneRow.docx diff --git a/samples/resources/Sample_10_ReadWord2007.docx b/samples/resources/Sample_11_ReadWord2007.docx similarity index 100% rename from samples/resources/Sample_10_ReadWord2007.docx rename to samples/resources/Sample_11_ReadWord2007.docx