From 510f9cdf796ec05a547773c21bc6a9772eef7268 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 17 Mar 2014 20:25:30 +0400 Subject: [PATCH 01/15] https://github.com/PHPOffice/PHPWord/issues/58 Part I. --- Classes/PHPWord.php | 50 +++---- Classes/PHPWord/DocumentProperties.php | 33 +++-- Classes/PHPWord/Exceptions/Exception.php | 3 - .../Exceptions/InvalidImageException.php | 2 +- .../UnsupportedImageTypeException.php | 2 +- Classes/PHPWord/Footnote.php | 9 +- Classes/PHPWord/HashTable.php | 58 +++----- Classes/PHPWord/Media.php | 21 +-- .../{Abstract.php => AbstractReader.php} | 0 Classes/PHPWord/Reader/IReader.php | 9 +- Classes/PHPWord/Reader/Word2007.php | 21 +-- Classes/PHPWord/Section.php | 131 ++++++++++-------- Classes/PHPWord/Section/Footer.php | 52 +++---- .../PHPWord/Section/Footer/PreserveText.php | 23 +-- Classes/PHPWord/Section/Footnote.php | 26 ++-- Classes/PHPWord/Section/Header.php | 66 ++++----- Classes/PHPWord/Section/Image.php | 13 +- Classes/PHPWord/Section/Link.php | 23 +-- Classes/PHPWord/Section/ListItem.php | 16 +-- Classes/PHPWord/Section/MemoryImage.php | 15 +- Classes/PHPWord/Section/Object.php | 16 +-- Classes/PHPWord/Section/PageBreak.php | 10 +- Classes/PHPWord/Section/Settings.php | 8 +- Classes/PHPWord/Section/Table.php | 20 +-- Classes/PHPWord/Section/Table/Cell.php | 94 +++++++------ Classes/PHPWord/Section/Table/Row.php | 18 ++- Classes/PHPWord/Section/Text.php | 44 +++--- Classes/PHPWord/Section/TextBreak.php | 38 ++--- Classes/PHPWord/Section/TextRun.php | 52 +++---- Classes/PHPWord/Section/Title.php | 8 +- Classes/PHPWord/Settings.php | 7 +- Classes/PHPWord/Shared/Drawing.php | 7 +- Classes/PHPWord/Shared/File.php | 7 +- Classes/PHPWord/Shared/Font.php | 7 +- Classes/PHPWord/Shared/String.php | 7 +- Classes/PHPWord/Shared/XMLWriter.php | 12 +- Classes/PHPWord/Shared/ZipStreamWrapper.php | 8 +- Classes/PHPWord/Style.php | 46 ++---- 38 files changed, 485 insertions(+), 497 deletions(-) rename Classes/PHPWord/Reader/{Abstract.php => AbstractReader.php} (100%) diff --git a/Classes/PHPWord.php b/Classes/PHPWord.php index d591b94ecf..edc4e93a55 100755 --- a/Classes/PHPWord.php +++ b/Classes/PHPWord.php @@ -25,6 +25,13 @@ * @version 0.8.0 */ +namespace PhpOffice; + +use PhpOffice\PhpWord\DocumentProperties; +use PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Template; + /** PHPWORD_BASE_PATH */ // @codeCoverageIgnoreStart if (!defined('PHPWORD_BASE_PATH')) { @@ -36,12 +43,8 @@ use PhpOffice\PhpWord\Exceptions\Exception; -/** - * PHPWord - */ -class PHPWord +class PhpWord { - /** * Default font name (Arial) */ @@ -67,7 +70,7 @@ class PHPWord /** * Document properties * - * @var PHPWord_DocumentProperties + * @var PhpOffice\PhpWord\DocumentProperties */ private $_properties; @@ -98,14 +101,14 @@ class PHPWord */ public function __construct() { - $this->_properties = new PHPWord_DocumentProperties(); + $this->_properties = new DocumentProperties(); $this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME; $this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE; } /** * Get properties - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function getProperties() { @@ -115,10 +118,10 @@ public function getProperties() /** * Set properties * - * @param PHPWord_DocumentProperties $value - * @return PHPWord + * @param PhpOffice\PhpWord\DocumentProperties $value + * @return PhpOffice\PHPWord */ - public function setProperties(PHPWord_DocumentProperties $value) + public function setProperties(DocumentProperties $value) { $this->_properties = $value; return $this; @@ -127,14 +130,14 @@ public function setProperties(PHPWord_DocumentProperties $value) /** * Create a new Section * - * @param PHPWord_Section_Settings $settings - * @return PHPWord_Section + * @param PhpOffice\PhpWord\Section\Settings $settings + * @return PhpOffice\PhpWord\Section */ public function createSection($settings = null) { $sectionCount = $this->_countSections() + 1; - $section = new PHPWord_Section($sectionCount, $settings); + $section = new Section($sectionCount, $settings); $this->_sectionCollection[] = $section; return $section; } @@ -182,7 +185,7 @@ public function setDefaultFontSize($pValue) */ public function setDefaultParagraphStyle($styles) { - PHPWord_Style::setDefaultParagraphStyle($styles); + Style::setDefaultParagraphStyle($styles); } /** @@ -193,7 +196,7 @@ public function setDefaultParagraphStyle($styles) */ public function addParagraphStyle($styleName, $styles) { - PHPWord_Style::addParagraphStyle($styleName, $styles); + Style::addParagraphStyle($styleName, $styles); } /** @@ -204,7 +207,7 @@ public function addParagraphStyle($styleName, $styles) */ public function addFontStyle($styleName, $styleFont, $styleParagraph = null) { - PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph); + Style::addFontStyle($styleName, $styleFont, $styleParagraph); } /** @@ -215,7 +218,7 @@ public function addFontStyle($styleName, $styleFont, $styleParagraph = null) */ public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) { - PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow); + Style::addTableStyle($styleName, $styleTable, $styleFirstRow); } /** @@ -226,7 +229,7 @@ public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) */ public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) { - PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); + Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); } /** @@ -237,12 +240,12 @@ public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) */ public function addLinkStyle($styleName, $styles) { - PHPWord_Style::addLinkStyle($styleName, $styles); + Style::addLinkStyle($styleName, $styles); } /** * Get sections - * @return PHPWord_Section[] + * @return PhpOffice\PhpWord\Section[] */ public function getSections() { @@ -253,14 +256,13 @@ public function getSections() * Load a Template File * * @param string $strFilename - * @return PHPWord_Template + * @return PhpOffice\PhpWord\Template * @throws Exception */ public function loadTemplate($strFilename) { if (file_exists($strFilename)) { - $template = new PHPWord_Template($strFilename); - return $template; + return new Template($strFilename); } throw new Exception("Template file {$strFilename} not found."); } diff --git a/Classes/PHPWord/DocumentProperties.php b/Classes/PHPWord/DocumentProperties.php index 1e64adf402..e280e83427 100755 --- a/Classes/PHPWord/DocumentProperties.php +++ b/Classes/PHPWord/DocumentProperties.php @@ -25,10 +25,9 @@ * @version 0.8.0 */ -/** - * Class PHPWord_DocumentProperties - */ -class PHPWord_DocumentProperties +namespace PhpOffice\PhpWord; + +class DocumentProperties { /** Constants */ const PROPERTY_TYPE_BOOLEAN = 'b'; @@ -123,7 +122,7 @@ class PHPWord_DocumentProperties private $_customProperties = array(); /** - * Create new PHPWord_DocumentProperties + * Create new DocumentProperties */ public function __construct() { @@ -154,7 +153,7 @@ public function getCreator() * Set Creator * * @param string $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setCreator($pValue = '') { @@ -176,7 +175,7 @@ public function getLastModifiedBy() * Set Last Modified By * * @param string $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setLastModifiedBy($pValue = '') { @@ -198,7 +197,7 @@ public function getCreated() * Set Created * * @param datetime $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setCreated($pValue = null) { @@ -223,7 +222,7 @@ public function getModified() * Set Modified * * @param datetime $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setModified($pValue = null) { @@ -248,7 +247,7 @@ public function getTitle() * Set Title * * @param string $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setTitle($pValue = '') { @@ -270,7 +269,7 @@ public function getDescription() * Set Description * * @param string $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setDescription($pValue = '') { @@ -292,7 +291,7 @@ public function getSubject() * Set Subject * * @param string $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setSubject($pValue = '') { @@ -314,7 +313,7 @@ public function getKeywords() * Set Keywords * * @param string $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setKeywords($pValue = '') { @@ -336,7 +335,7 @@ public function getCategory() * Set Category * * @param string $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setCategory($pValue = '') { @@ -358,7 +357,7 @@ public function getCompany() * Set Company * * @param string $pValue - * @return PHPWord_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setCompany($pValue = '') { @@ -380,7 +379,7 @@ public function getManager() * Set Manager * * @param string $pValue - * @return PHPExcel_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setManager($pValue = '') { @@ -448,7 +447,7 @@ public function getCustomPropertyType($propertyName) * 's': String * 'd': Date/Time * 'b': Boolean - * @return PHPExcel_DocumentProperties + * @return PhpOffice\PhpWord\DocumentProperties */ public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) { diff --git a/Classes/PHPWord/Exceptions/Exception.php b/Classes/PHPWord/Exceptions/Exception.php index 11cb05168f..72f5cfedc6 100755 --- a/Classes/PHPWord/Exceptions/Exception.php +++ b/Classes/PHPWord/Exceptions/Exception.php @@ -1,9 +1,6 @@ addFromSource($pSource); } } @@ -63,8 +60,8 @@ public function __construct($pSource = null) /** * Add HashTable items from source * - * @param PHPWord_IComparable[] $pSource Source array to create HashTable from - * @throws Exception + * @param PhpOffice\PhpWord\IComparable[] $pSource Source array to create HashTable from + * @throws Exception */ public function addFromSource($pSource = null) { @@ -83,10 +80,10 @@ public function addFromSource($pSource = null) /** * Add HashTable item * - * @param PHPWord_IComparable $pSource Item to add - * @throws Exception + * @param PhpOffice\PhpWord\IComparable $pSource Item to add + * @throws Exception */ - public function add(PHPWord_IComparable $pSource = null) + public function add(IComparable $pSource = null) { // Determine hashcode $hashCode = null; @@ -113,10 +110,10 @@ public function add(PHPWord_IComparable $pSource = null) /** * Remove HashTable item * - * @param PHPWord_IComparable $pSource Item to remove - * @throws Exception + * @param PhpOffice\PhpWord\IComparable $pSource Item to remove + * @throws Exception */ - public function remove(PHPWord_IComparable $pSource = null) + public function remove(IComparable $pSource = null) { if (isset($this->_items[$pSource->getHashCode()])) { unset($this->_items[$pSource->getHashCode()]); @@ -146,8 +143,6 @@ public function clear() } /** - * Count - * * @return int */ public function count() @@ -156,10 +151,8 @@ public function count() } /** - * Get index for hash code - * - * @param string $pHashCode - * @return int Index + * @param string $pHashCode + * @return int Index */ public function getIndexForHashCode($pHashCode = '') { @@ -167,11 +160,8 @@ public function getIndexForHashCode($pHashCode = '') } /** - * Get by index - * - * @param int $pIndex - * @return PHPWord_IComparable - * + * @param int $pIndex + * @return PhpOffice\PhpWord\IComparable */ public function getByIndex($pIndex = 0) { @@ -183,10 +173,8 @@ public function getByIndex($pIndex = 0) } /** - * Get by hashcode - * - * @param string $pHashCode - * @return PHPWord_IComparable + * @param string $pHashCode + * @return PhpOffice\PhpWord\IComparable * */ public function getByHashCode($pHashCode = '') @@ -199,9 +187,7 @@ public function getByHashCode($pHashCode = '') } /** - * HashTable to array - * - * @return PHPWord_IComparable[] + * @return PhpOffice\PhpWord\IComparable[] */ public function toArray() { @@ -220,4 +206,4 @@ public function __clone() } } } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Media.php b/Classes/PHPWord/Media.php index 0332818460..42a32518e4 100755 --- a/Classes/PHPWord/Media.php +++ b/Classes/PHPWord/Media.php @@ -25,10 +25,11 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Media - */ -class PHPWord_Media +namespace PhpOffice\PhpWord; + +use PhpOffice\PhpWord\Section\MemoryImage; + +class Media { /** * Section Media Elements @@ -67,10 +68,10 @@ class PHPWord_Media * * @param string $src * @param string $type - * @param PHPWord_Section_MemoryImage|null $memoryImage + * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage * @return mixed */ - public static function addSectionMediaElement($src, $type, PHPWord_Section_MemoryImage $memoryImage = null) + public static function addSectionMediaElement($src, $type, MemoryImage $memoryImage = null) { $mediaId = md5($src); $key = ($type === 'image') ? 'images' : 'embeddings'; @@ -205,10 +206,10 @@ public static function countSectionMediaElements($key = null) * * @param int $headerCount * @param string $src - * @param PHPWord_Section_MemoryImage|null $memoryImage + * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage * @return int */ - public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) + public static function addHeaderMediaElement($headerCount, $src, MemoryImage $memoryImage = null) { $mediaId = md5($src); $key = 'header' . $headerCount; @@ -277,10 +278,10 @@ public static function getHeaderMediaElements() * * @param int $footerCount * @param string $src - * @param PHPWord_Section_MemoryImage|null $memoryImage + * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage * @return int */ - public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) + public static function addFooterMediaElement($footerCount, $src, MemoryImage $memoryImage = null) { $mediaId = md5($src); $key = 'footer' . $footerCount; diff --git a/Classes/PHPWord/Reader/Abstract.php b/Classes/PHPWord/Reader/AbstractReader.php similarity index 100% rename from Classes/PHPWord/Reader/Abstract.php rename to Classes/PHPWord/Reader/AbstractReader.php diff --git a/Classes/PHPWord/Reader/IReader.php b/Classes/PHPWord/Reader/IReader.php index 703db57620..0cc3a61280 100644 --- a/Classes/PHPWord/Reader/IReader.php +++ b/Classes/PHPWord/Reader/IReader.php @@ -25,13 +25,12 @@ * @version 0.8.0 */ -/** - * PHPWord_Reader_IReader - */ -interface PHPWord_Reader_IReader +namespace PhpOffice\PhpWord\Reader; + +interface IReader { /** - * Can the current PHPWord_Reader_IReader read the file? + * Can the current IReader read the file? * * @param string $pFilename * @return boolean diff --git a/Classes/PHPWord/Reader/Word2007.php b/Classes/PHPWord/Reader/Word2007.php index 1aa94f86aa..a045462651 100644 --- a/Classes/PHPWord/Reader/Word2007.php +++ b/Classes/PHPWord/Reader/Word2007.php @@ -25,21 +25,22 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord\Reader; + +use PhpOffice\PhpWord\DocumentProperties; +use PhpOffice\PhpWord\Exceptions\Exception; +use PhpOffice\PhpWord\Shared\File; + /** PHPWord root directory */ if (!defined('PHPWORD_BASE_PATH')) { define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/../../'); require(PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php'); } -use PhpOffice\PhpWord\Exceptions\Exception; - -/** - * PHPWord_Reader_Word2007 - */ -class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements PHPWord_Reader_IReader +class Word2007 extends AbstractReader implements IReader { /** - * Can the current PHPWord_Reader_IReader read the file? + * Can the current IReader read the file? * * @param string $pFilename * @return bool @@ -90,7 +91,7 @@ public function getFromZipArchive($archive, $fileName = '', $removeNamespace = f if (strpos($fileName, '//') !== false) { $fileName = substr($fileName, strpos($fileName, '//') + 1); } - $fileName = PHPWord_Shared_File::realpath($fileName); + $fileName = File::realpath($fileName); // Apache POI fixes $contents = $archive->getFromName($fileName); @@ -172,8 +173,8 @@ public function load($pFilename) $cellDataOfficeChildren = $xmlProperty->children("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"); $attributeType = $cellDataOfficeChildren->getName(); $attributeValue = (string)$cellDataOfficeChildren->{$attributeType}; - $attributeValue = PHPWord_DocumentProperties::convertProperty($attributeValue, $attributeType); - $attributeType = PHPWord_DocumentProperties::convertPropertyType($attributeType); + $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType); + $attributeType = DocumentProperties::convertPropertyType($attributeType); $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); } } diff --git a/Classes/PHPWord/Section.php b/Classes/PHPWord/Section.php index a9402dab72..17887d6b04 100755 --- a/Classes/PHPWord/Section.php +++ b/Classes/PHPWord/Section.php @@ -25,12 +25,26 @@ * @version 0.8.0 */ -use PhpOffice\PhpWord\Exceptions\Exception; +namespace PhpOffice\PhpWord; -/** - * Class PHPWord_Section - */ -class PHPWord_Section +use PhpOffice\PhpWord\Exceptions\Exception; +use PhpOffice\PhpWord\Section\Footer; +use PhpOffice\PhpWord\Section\Footnote; +use PhpOffice\PhpWord\Section\Image; +use PhpOffice\PhpWord\Section\Link; +use PhpOffice\PhpWord\Section\ListItem; +use PhpOffice\PhpWord\Section\MemoryImage; +use PhpOffice\PhpWord\Section\Object; +use PhpOffice\PhpWord\Section\PageBreak; +use PhpOffice\PhpWord\Section\Settings; +use PhpOffice\PhpWord\Section\Table; +use PhpOffice\PhpWord\Section\Text; +use PhpOffice\PhpWord\Section\TextBreak; +use PhpOffice\PhpWord\Section\TextRun; +use PhpOffice\PhpWord\Section\Title; +use PhpOffice\PhpWord\Shared\String; + +class Section { /** * Section count @@ -42,7 +56,7 @@ class PHPWord_Section /** * Section settings * - * @var PHPWord_Section_Settings + * @var PhpOffice\PhpWord\Section\Settings */ private $_settings; @@ -63,7 +77,7 @@ class PHPWord_Section /** * Section Footer * - * @var PHPWord_Section_Footer + * @var PhpOffice\PhpWord\Section\Footer */ private $_footer = null; @@ -77,7 +91,7 @@ class PHPWord_Section public function __construct($sectionCount, $settings = null) { $this->_sectionCount = $sectionCount; - $this->_settings = new PHPWord_Section_Settings(); + $this->_settings = new Settings(); $this->setSettings($settings); } @@ -101,7 +115,7 @@ public function setSettings($settings = null) /** * Get Section Settings * - * @return PHPWord_Section_Settings + * @return PhpOffice\PhpWord\Section\Settings */ public function getSettings() { @@ -114,14 +128,14 @@ public function getSettings() * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PHPWord_Section_Text + * @return PhpOffice\PhpWord\Section\Text */ public function addText($text, $styleFont = null, $styleParagraph = null) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $text = new Text($text, $styleFont, $styleParagraph); $this->_elementCollection[] = $text; return $text; } @@ -133,21 +147,21 @@ public function addText($text, $styleFont = null, $styleParagraph = null) * @param string $linkName * @param mixed $styleFont * @param mixed $styleParagraph - * @return PHPWord_Section_Link + * @return PhpOffice\PhpWord\Section\Link */ public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) { - if (!PHPWord_Shared_String::IsUTF8($linkSrc)) { + if (!String::IsUTF8($linkSrc)) { $linkSrc = utf8_encode($linkSrc); } if (!is_null($linkName)) { - if (!PHPWord_Shared_String::IsUTF8($linkName)) { + if (!String::IsUTF8($linkName)) { $linkName = utf8_encode($linkName); } } - $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph); - $rID = PHPWord_Media::addSectionLinkElement($linkSrc); + $link = new Link($linkSrc, $linkName, $styleFont, $styleParagraph); + $rID = Media::addSectionLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; @@ -157,14 +171,14 @@ public function addLink($linkSrc, $linkName = null, $styleFont = null, $stylePar /** * Add a TextBreak Element * - * @param int $count - * @param null|string|array|PHPWord_Style_Font $fontStyle - * @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); } } @@ -173,18 +187,18 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu */ public function addPageBreak() { - $this->_elementCollection[] = new PHPWord_Section_PageBreak(); + $this->_elementCollection[] = new PageBreak(); } /** * Add a Table Element * * @param mixed $style - * @return PHPWord_Section_Table + * @return PhpOffice\PhpWord\Section\Table */ public function addTable($style = null) { - $table = new PHPWord_Section_Table('section', $this->_sectionCount, $style); + $table = new Table('section', $this->_sectionCount, $style); $this->_elementCollection[] = $table; return $table; } @@ -197,14 +211,14 @@ public function addTable($style = null) * @param mixed $styleFont * @param mixed $styleList * @param mixed $styleParagraph - * @return PHPWord_Section_ListItem + * @return PhpOffice\PhpWord\Section\ListItem */ public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $listItem = new PHPWord_Section_ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); + $listItem = new ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); $this->_elementCollection[] = $listItem; return $listItem; } @@ -214,12 +228,12 @@ public function addListItem($text, $depth = 0, $styleFont = null, $styleList = n * * @param string $src * @param mixed $style - * @return PHPWord_Section_Object + * @return PhpOffice\PhpWord\Section\Object * @throws Exception */ public function addObject($src, $style = null) { - $object = new PHPWord_Section_Object($src, $style); + $object = new Object($src, $style); if (!is_null($object->getSource())) { $inf = pathinfo($src); @@ -235,8 +249,8 @@ public function addObject($src, $style = null) $iconSrc .= '_' . $ext . '.png'; } - $rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); - $data = PHPWord_Media::addSectionMediaElement($src, 'oleObject'); + $rIDimg = Media::addSectionMediaElement($iconSrc, 'image'); + $data = Media::addSectionMediaElement($src, 'oleObject'); $rID = $data[0]; $objectId = $data[1]; @@ -255,15 +269,15 @@ public function addObject($src, $style = null) * * @param string $src * @param mixed $style - * @return PHPWord_Section_Image + * @return PhpOffice\PhpWord\Section\Image * @throws Exception */ public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); + $image = new Image($src, $style); if (!is_null($image->getSource())) { - $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); + $rID = Media::addSectionMediaElement($src, 'image'); $image->setRelationId($rID); $this->_elementCollection[] = $image; @@ -277,14 +291,14 @@ public function addImage($src, $style = null) * * @param string $link * @param mixed $style - * @return PHPWord_Section_MemoryImage + * @return PhpOffice\PhpWord\Section\MemoryImage * @throws Exception */ public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + $memoryImage = new MemoryImage($link, $style); if (!is_null($memoryImage->getSource())) { - $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); + $rID = Media::addSectionMediaElement($link, 'image', $memoryImage); $memoryImage->setRelationId($rID); $this->_elementCollection[] = $memoryImage; @@ -298,11 +312,11 @@ public function addMemoryImage($link, $style = null) * * @param mixed $styleFont * @param mixed $styleTOC - * @return PHPWord_TOC + * @return PhpOffice\PhpWord\TOC */ public function addTOC($styleFont = null, $styleTOC = null) { - $toc = new PHPWord_TOC($styleFont, $styleTOC); + $toc = new TOC($styleFont, $styleTOC); $this->_elementCollection[] = $toc; return $toc; } @@ -312,23 +326,23 @@ public function addTOC($styleFont = null, $styleTOC = null) * * @param string $text * @param int $depth - * @return PHPWord_Section_Title + * @return PhpOffice\PhpWord\Section\Title */ public function addTitle($text, $depth = 1) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $styles = PHPWord_Style::getStyles(); + $styles = Style::getStyles(); if (array_key_exists('Heading_' . $depth, $styles)) { $style = 'Heading' . $depth; } else { $style = null; } - $title = new PHPWord_Section_Title($text, $depth, $style); + $title = new Title($text, $depth, $style); - $data = PHPWord_TOC::addTitle($text, $depth); + $data = TOC::addTitle($text, $depth); $anchor = $data[0]; $bookmarkId = $data[1]; @@ -343,11 +357,11 @@ public function addTitle($text, $depth = 1) * Create a new TextRun * * @param mixed $styleParagraph - * @return PHPWord_Section_TextRun + * @return PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); + $textRun = new TextRun($styleParagraph); $this->_elementCollection[] = $textRun; return $textRun; } @@ -365,11 +379,11 @@ public function getElements() /** * Create a new Header * - * @return PHPWord_Section_Header + * @return PhpOffice\PhpWord\Section\Header */ public function createHeader() { - $header = new PHPWord_Section_Header($this->_sectionCount); + $header = new Header($this->_sectionCount); $this->_headers[] = $header; return $header; } @@ -387,16 +401,15 @@ public function getHeaders() /** * Is there a header for this section that is for the first page only? * - * If any of the PHPWord_Section_Header instances have a type of - * PHPWord_Section_Header::FIRST then this method returns true. False - * otherwise. + * If any of the Header instances have a type of Header::FIRST then this method returns true. + * False otherwise. * * @return Boolean */ public function hasDifferentFirstPage() { - $value = array_filter($this->_headers, function (PHPWord_Section_Header &$header) { - return $header->getType() == PHPWord_Section_Header::FIRST; + $value = array_filter($this->_headers, function (Header &$header) { + return $header->getType() == Header::FIRST; }); return count($value) > 0; } @@ -404,11 +417,11 @@ public function hasDifferentFirstPage() /** * Create a new Footer * - * @return PHPWord_Section_Footer + * @return PhpOffice\PhpWord\Section\Footer */ public function createFooter() { - $footer = new PHPWord_Section_Footer($this->_sectionCount); + $footer = new Footer($this->_sectionCount); $this->_footer = $footer; return $footer; } @@ -416,7 +429,7 @@ public function createFooter() /** * Get Footer * - * @return PHPWord_Section_Footer + * @return PhpOffice\PhpWord\Section\Footer */ public function getFooter() { @@ -427,12 +440,12 @@ public function getFooter() * Create a new Footnote Element * * @param mixed $styleParagraph - * @return PHPWord_Section_Footnote + * @return PhpOffice\PhpWord\Section\Footnote */ public function createFootnote($styleParagraph = null) { - $footnote = new PHPWord_Section_Footnote($styleParagraph); - $refID = PHPWord_Footnote::addFootnoteElement($footnote); + $footnote = new Footnote($styleParagraph); + $refID = Footnote::addFootnoteElement($footnote); $footnote->setReferenceId($refID); $this->_elementCollection[] = $footnote; return $footnote; diff --git a/Classes/PHPWord/Section/Footer.php b/Classes/PHPWord/Section/Footer.php index 238bae1b07..07ce6cc5f1 100755 --- a/Classes/PHPWord/Section/Footer.php +++ b/Classes/PHPWord/Section/Footer.php @@ -25,12 +25,14 @@ * @version 0.8.0 */ -/** - * PHPWord_Section_Footer - */ -class PHPWord_Section_Footer -{ +namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Media; +use PhpOffice\PhpWord\Section\Footer\PreserveText; +use PhpOffice\PhpWord\Shared\String; + +class Footer +{ /** * Footer Count * @@ -66,14 +68,14 @@ public function __construct($sectionCount) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PHPWord_Section_Text + * @return PhpOffice\PhpWord\Section\Text */ public function addText($text, $styleFont = null, $styleParagraph = null) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $text = new Text($text, $styleFont, $styleParagraph); $this->_elementCollection[] = $text; return $text; } @@ -81,25 +83,25 @@ public function addText($text, $styleFont = null, $styleParagraph = null) /** * Add TextBreak * - * @param int $count - * @param null|string|array|PHPWord_Style_Font $fontStyle - * @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); } } /** * Create a new TextRun * - * @return PHPWord_Section_TextRun + * @return PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); + $textRun = new TextRun($styleParagraph); $this->_elementCollection[] = $textRun; return $textRun; } @@ -108,11 +110,11 @@ public function createTextRun($styleParagraph = null) * Add a Table Element * * @param mixed $style - * @return PHPWord_Section_Table + * @return PhpOffice\PhpWord\Section\Table */ public function addTable($style = null) { - $table = new PHPWord_Section_Table('footer', $this->_footerCount, $style); + $table = new Table('footer', $this->_footerCount, $style); $this->_elementCollection[] = $table; return $table; } @@ -122,14 +124,14 @@ public function addTable($style = null) * * @param string $src * @param mixed $style - * @return PHPWord_Section_Image + * @return Image */ public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); + $image = new Image($src, $style); if (!is_null($image->getSource())) { - $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src); + $rID = Media::addFooterMediaElement($this->_footerCount, $src); $image->setRelationId($rID); $this->_elementCollection[] = $image; @@ -144,13 +146,13 @@ public function addImage($src, $style = null) * * @param string $link * @param mixed $style - * @return PHPWord_Section_MemoryImage + * @return PhpOffice\PhpWord\Section\MemoryImage */ public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + $memoryImage = new MemoryImage($link, $style); if (!is_null($memoryImage->getSource())) { - $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); + $rID = Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); $memoryImage->setRelationId($rID); $this->_elementCollection[] = $memoryImage; @@ -166,14 +168,14 @@ public function addMemoryImage($link, $style = null) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PHPWord_Section_Footer_PreserveText + * @return PhpOffice\PhpWord\Section\Footer\PreserveText */ public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); + $ptext = new PreserveText($text, $styleFont, $styleParagraph); $this->_elementCollection[] = $ptext; return $ptext; } diff --git a/Classes/PHPWord/Section/Footer/PreserveText.php b/Classes/PHPWord/Section/Footer/PreserveText.php index 7244374386..8b82e817be 100755 --- a/Classes/PHPWord/Section/Footer/PreserveText.php +++ b/Classes/PHPWord/Section/Footer/PreserveText.php @@ -25,12 +25,13 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_Footer_PreserveText - */ -class PHPWord_Section_Footer_PreserveText -{ +namespace PhpOffice\PhpWord\Section\Footer; +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; + +class PreserveText +{ /** * Text content * @@ -41,14 +42,14 @@ class PHPWord_Section_Footer_PreserveText /** * Text style * - * @var PHPWord_Style_Font + * @var PhpOffice\PhpWord\Style\Font */ private $_styleFont; /** * Paragraph style * - * @var PHPWord_Style_Font + * @var PhpOffice\PhpWord\Style\Paragraph */ private $_styleParagraph; @@ -63,7 +64,7 @@ public function __construct($text = null, $styleFont = null, $styleParagraph = n { // Set font style if (is_array($styleFont)) { - $this->_styleFont = new PHPWord_Style_Font('text'); + $this->_styleFont = new Font('text'); foreach ($styleFont as $key => $value) { if (substr($key, 0, 1) != '_') { @@ -77,7 +78,7 @@ public function __construct($text = null, $styleFont = null, $styleParagraph = n // Set paragraph style if (is_array($styleParagraph)) { - $this->_styleParagraph = new PHPWord_Style_Paragraph(); + $this->_styleParagraph = new Paragraph(); foreach ($styleParagraph as $key => $value) { if (substr($key, 0, 1) != '_') { @@ -100,7 +101,7 @@ public function __construct($text = null, $styleFont = null, $styleParagraph = n /** * Get Text style * - * @return PHPWord_Style_Font + * @return PhpOffice\PhpWord\Style\Font */ public function getFontStyle() { @@ -110,7 +111,7 @@ public function getFontStyle() /** * Get Paragraph style * - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/Classes/PHPWord/Section/Footnote.php b/Classes/PHPWord/Section/Footnote.php index 652a3873f3..4d03920fee 100644 --- a/Classes/PHPWord/Section/Footnote.php +++ b/Classes/PHPWord/Section/Footnote.php @@ -25,16 +25,16 @@ * @version 0.8.0 */ -/** - * PHPWord_Section_Footnote - */ -class PHPWord_Section_Footnote -{ +namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Style\Paragraph; + +class Footnote +{ /** * Paragraph style * - * @var PHPWord_Style_Font + * @var PhpOffice\PhpWord\Style\Paragraph */ private $_styleParagraph; @@ -61,7 +61,7 @@ public function __construct($styleParagraph = null) // Set paragraph style if (is_array($styleParagraph)) { - $this->_styleParagraph = new PHPWord_Style_Paragraph(); + $this->_styleParagraph = new Paragraph(); foreach ($styleParagraph as $key => $value) { if (substr($key, 0, 1) != '_') { @@ -80,12 +80,12 @@ public function __construct($styleParagraph = null) * * @var string $text * @var mixed $styleFont - * @return PHPWord_Section_Text + * @return PhpOffice\PhpWord\Section\Text */ public function addText($text = null, $styleFont = null) { $givenText = $text; - $text = new PHPWord_Section_Text($givenText, $styleFont); + $text = new Text($givenText, $styleFont); $this->_elementCollection[] = $text; return $text; } @@ -96,13 +96,13 @@ public function addText($text = null, $styleFont = null) * @param string $linkSrc * @param string $linkName * @param mixed $styleFont - * @return PHPWord_Section_Link + * @return PhpOffice\PhpWord\Section\Link */ public function addLink($linkSrc, $linkName = null, $styleFont = null) { - $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont); - $rID = PHPWord_Footnote::addFootnoteLinkElement($linkSrc); + $link = new Link($linkSrc, $linkName, $styleFont); + $rID = PhpOffice\PhpWord\Footnote::addFootnoteLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; @@ -122,7 +122,7 @@ public function getElements() /** * Get Paragraph style * - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/Classes/PHPWord/Section/Header.php b/Classes/PHPWord/Section/Header.php index 5e1c6bfe73..752571895c 100755 --- a/Classes/PHPWord/Section/Header.php +++ b/Classes/PHPWord/Section/Header.php @@ -25,12 +25,14 @@ * @version 0.8.0 */ -/** - * PHPWord_Section_Header - */ -class PHPWord_Section_Header -{ +namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Media; +use PhpOffice\PhpWord\Section\Footer\PreserveText; +use PhpOffice\PhpWord\Shared\String; + +class Header +{ /** * Header Count * @@ -51,7 +53,7 @@ class PHPWord_Section_Header * @var string * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type */ - private $_type = PHPWord_Section_Header::AUTO; + private $_type = self::AUTO; /** * Even Numbered Pages Only @@ -95,14 +97,14 @@ public function __construct($sectionCount) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PHPWord_Section_Text + * @return PhpOffice\PhpWord\Section\Text */ public function addText($text, $styleFont = null, $styleParagraph = null) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $text = new Text($text, $styleFont, $styleParagraph); $this->_elementCollection[] = $text; return $text; } @@ -110,25 +112,25 @@ public function addText($text, $styleFont = null, $styleParagraph = null) /** * Add TextBreak * - * @param int $count - * @param null|string|array|PHPWord_Style_Font $fontStyle - * @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); } } /** * Create a new TextRun * - * @return PHPWord_Section_TextRun + * @return PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); + $textRun = new TextRun($styleParagraph); $this->_elementCollection[] = $textRun; return $textRun; } @@ -137,11 +139,11 @@ public function createTextRun($styleParagraph = null) * Add a Table Element * * @param mixed $style - * @return PHPWord_Section_Table + * @return PhpOffice\PhpWord\Section\Table */ public function addTable($style = null) { - $table = new PHPWord_Section_Table('header', $this->_headerCount, $style); + $table = new Table('header', $this->_headerCount, $style); $this->_elementCollection[] = $table; return $table; } @@ -151,14 +153,14 @@ public function addTable($style = null) * * @param string $src * @param mixed $style - * @return PHPWord_Section_Image + * @return PhpOffice\PhpWord\Section\Image */ public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); + $image = new Image($src, $style); if (!is_null($image->getSource())) { - $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); + $rID = Media::addHeaderMediaElement($this->_headerCount, $src); $image->setRelationId($rID); $this->_elementCollection[] = $image; @@ -173,13 +175,13 @@ public function addImage($src, $style = null) * * @param string $link * @param mixed $style - * @return PHPWord_Section_MemoryImage + * @return PhpOffice\PhpWord\Section\MemoryImage */ public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + $memoryImage = new MemoryImage($link, $style); if (!is_null($memoryImage->getSource())) { - $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); + $rID = Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); $memoryImage->setRelationId($rID); $this->_elementCollection[] = $memoryImage; @@ -195,14 +197,14 @@ public function addMemoryImage($link, $style = null) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PHPWord_Section_Footer_PreserveText + * @return PhpOffice\PhpWord\Section\Footer\PreserveText */ public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); + $ptext = new PreserveText($text, $styleFont, $styleParagraph); $this->_elementCollection[] = $ptext; return $ptext; } @@ -212,14 +214,14 @@ public function addPreserveText($text, $styleFont = null, $styleParagraph = null * * @param string $src * @param mixed $style - * @return PHPWord_Section_Image + * @return PhpOffice\PhpWord\Section\Image */ public function addWatermark($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style, true); + $image = new Image($src, $style, true); if (!is_null($image->getSource())) { - $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); + $rID = Media::addHeaderMediaElement($this->_headerCount, $src); $image->setRelationId($rID); $this->_elementCollection[] = $image; @@ -276,7 +278,7 @@ public function getType() */ public function resetType() { - return $this->_type = PHPWord_Section_Header::AUTO; + return $this->_type = self::AUTO; } /** @@ -284,7 +286,7 @@ public function resetType() */ public function firstPage() { - return $this->_type = PHPWord_Section_Header::FIRST; + return $this->_type = self::FIRST; } /** @@ -292,6 +294,6 @@ public function firstPage() */ public function evenPage() { - return $this->_type = PHPWord_Section_Header::EVEN; + return $this->_type = self::EVEN; } } diff --git a/Classes/PHPWord/Section/Image.php b/Classes/PHPWord/Section/Image.php index fcaa1cc9ab..3e2924819f 100755 --- a/Classes/PHPWord/Section/Image.php +++ b/Classes/PHPWord/Section/Image.php @@ -25,13 +25,12 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord\Section; + use PhpOffice\PhpWord\Exceptions\InvalidImageException; use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException; -/** - * Class PHPWord_Section_Image - */ -class PHPWord_Section_Image +class Image { /** * Image Src @@ -43,7 +42,7 @@ class PHPWord_Section_Image /** * Image Style * - * @var PHPWord_Style_Image + * @var PhpOffice\PhpWord\Style\Image */ private $_style; @@ -84,7 +83,7 @@ public function __construct($src, $style = null, $isWatermark = false) $this->_src = $src; $this->_isWatermark = $isWatermark; - $this->_style = new PHPWord_Style_Image(); + $this->_style = new PhpOffice\PhpWord\Style\Image(); if (!is_null($style) && is_array($style)) { foreach ($style as $key => $value) { @@ -109,7 +108,7 @@ public function __construct($src, $style = null, $isWatermark = false) /** * Get Image style * - * @return PHPWord_Style_Image + * @return PhpOffice\PhpWord\Style\Image */ public function getStyle() { diff --git a/Classes/PHPWord/Section/Link.php b/Classes/PHPWord/Section/Link.php index 620b08a1bf..022d2ec0cb 100755 --- a/Classes/PHPWord/Section/Link.php +++ b/Classes/PHPWord/Section/Link.php @@ -25,12 +25,13 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_Link - */ -class PHPWord_Section_Link -{ +namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; + +class Link +{ /** * Link source * @@ -55,14 +56,14 @@ class PHPWord_Section_Link /** * Link style * - * @var PHPWord_Style_Font + * @var PhpOffice\PhpWord\Style\Font */ private $_styleFont; /** * Paragraph style * - * @var PHPWord_Style_Font + * @var PhpOffice\PhpWord\Style\Paragraph */ private $_styleParagraph; @@ -82,7 +83,7 @@ public function __construct($linkSrc, $linkName = null, $styleFont = null, $styl // Set font style if (is_array($styleFont)) { - $this->_styleFont = new PHPWord_Style_Font('text'); + $this->_styleFont = new Font('text'); foreach ($styleFont as $key => $value) { if (substr($key, 0, 1) != '_') { @@ -96,7 +97,7 @@ public function __construct($linkSrc, $linkName = null, $styleFont = null, $styl // Set paragraph style if (is_array($styleParagraph)) { - $this->_styleParagraph = new PHPWord_Style_Paragraph(); + $this->_styleParagraph = new Paragraph(); foreach ($styleParagraph as $key => $value) { if (substr($key, 0, 1) != '_') { @@ -154,7 +155,7 @@ public function getLinkName() /** * Get Text style * - * @return PHPWord_Style_Font + * @return PhpOffice\PhpWord\Style\Font */ public function getFontStyle() { @@ -164,7 +165,7 @@ public function getFontStyle() /** * Get Paragraph style * - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/Classes/PHPWord/Section/ListItem.php b/Classes/PHPWord/Section/ListItem.php index 83384a9490..081999b778 100755 --- a/Classes/PHPWord/Section/ListItem.php +++ b/Classes/PHPWord/Section/ListItem.php @@ -25,23 +25,21 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_ListItem - */ -class PHPWord_Section_ListItem -{ +namespace PhpOffice\PhpWord\Section; +class ListItem +{ /** * ListItem Style * - * @var PHPWord_Style_ListItem + * @var PhpOffice\PhpWord\Style\ListItem */ private $_style; /** * Textrun * - * @var PHPWord_Section_Text + * @var PhpOffice\PhpWord\Section\Text */ private $_textObject; @@ -63,8 +61,8 @@ class PHPWord_Section_ListItem */ public function __construct($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) { - $this->_style = new PHPWord_Style_ListItem(); - $this->_textObject = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $this->_style = new PhpOffice\PhpWord\Style\ListItem(); + $this->_textObject = new Text($text, $styleFont, $styleParagraph); $this->_depth = $depth; if (!is_null($styleList) && is_array($styleList)) { diff --git a/Classes/PHPWord/Section/MemoryImage.php b/Classes/PHPWord/Section/MemoryImage.php index 9d4ed97c0e..7b870eb229 100755 --- a/Classes/PHPWord/Section/MemoryImage.php +++ b/Classes/PHPWord/Section/MemoryImage.php @@ -25,10 +25,11 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_MemoryImage - */ -class PHPWord_Section_MemoryImage +namespace PhpOffice\PhpWord\Section; + +use PhpOffice\PhpWord\Style\Image; + +class MemoryImage { /** * Image Src @@ -40,7 +41,7 @@ class PHPWord_Section_MemoryImage /** * Image Style * - * @var PHPWord_Style_Image + * @var PhpOffice\PhpWord\Style\Image */ private $_style; @@ -95,7 +96,7 @@ public function __construct($src, $style = null) if (in_array($this->_imageType, $_supportedImageTypes)) { $this->_src = $src; - $this->_style = new PHPWord_Style_Image(); + $this->_style = new Image(); if (!is_null($style) && is_array($style)) { foreach ($style as $key => $value) { @@ -143,7 +144,7 @@ private function _setFunctions() /** * Get Image style * - * @return PHPWord_Style_Image + * @return PhpOffice\PhpWord\Style\Image */ public function getStyle() { diff --git a/Classes/PHPWord/Section/Object.php b/Classes/PHPWord/Section/Object.php index 33d8cad9bc..cf6b6f3e94 100755 --- a/Classes/PHPWord/Section/Object.php +++ b/Classes/PHPWord/Section/Object.php @@ -25,12 +25,12 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_Object - */ -class PHPWord_Section_Object -{ +namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Style\Image; + +class Object +{ /** * Ole-Object Src * @@ -41,7 +41,7 @@ class PHPWord_Section_Object /** * Image Style * - * @var PHPWord_Style_Image + * @var PhpOffice\PhpWord\Style\Image */ private $_style; @@ -80,7 +80,7 @@ public function __construct($src, $style = null) if (file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) { $this->_src = $src; - $this->_style = new PHPWord_Style_Image(); + $this->_style = new Image(); if (!is_null($style) && is_array($style)) { foreach ($style as $key => $value) { @@ -100,7 +100,7 @@ public function __construct($src, $style = null) /** * Get Image style * - * @return PHPWord_Style_Image + * @return PhpOffice\PhpWord\Style\Image */ public function getStyle() { diff --git a/Classes/PHPWord/Section/PageBreak.php b/Classes/PHPWord/Section/PageBreak.php index 76536304cb..aa47603329 100755 --- a/Classes/PHPWord/Section/PageBreak.php +++ b/Classes/PHPWord/Section/PageBreak.php @@ -25,16 +25,14 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_PageBreak - */ -class PHPWord_Section_PageBreak -{ +namespace PhpOffice\PhpWord\Section; +class PageBreak +{ /** * Create a new PageBreak Element */ public function __construct() { } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Section/Settings.php b/Classes/PHPWord/Section/Settings.php index 1ff3bf64cc..13f4b14266 100755 --- a/Classes/PHPWord/Section/Settings.php +++ b/Classes/PHPWord/Section/Settings.php @@ -25,12 +25,10 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_Settings - */ -class PHPWord_Section_Settings -{ +namespace PhpOffice\PhpWord\Section; +class Settings +{ /** * Default Page Size Width * diff --git a/Classes/PHPWord/Section/Table.php b/Classes/PHPWord/Section/Table.php index f5a8a79900..92664a19bd 100755 --- a/Classes/PHPWord/Section/Table.php +++ b/Classes/PHPWord/Section/Table.php @@ -25,16 +25,16 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_Table - */ -class PHPWord_Section_Table -{ +namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Section\Table\Row; + +class Table +{ /** * Table style * - * @var PHPWord_Style_Table + * @var PhpOffice\PhpWord\Style\Table */ private $_style; @@ -81,7 +81,7 @@ public function __construct($insideOf, $pCount, $style = null) if (!is_null($style)) { if (is_array($style)) { - $this->_style = new PHPWord_Style_Table(); + $this->_style = new PhpOffice\PhpWord\Style\Table(); foreach ($style as $key => $value) { if (substr($key, 0, 1) != '_') { @@ -102,7 +102,7 @@ public function __construct($insideOf, $pCount, $style = null) */ public function addRow($height = null, $style = null) { - $row = new PHPWord_Section_Table_Row($this->_insideOf, $this->_pCount, $height, $style); + $row = new Row($this->_insideOf, $this->_pCount, $height, $style); $this->_rows[] = $row; return $row; } @@ -112,7 +112,7 @@ public function addRow($height = null, $style = null) * * @param int $width * @param mixed $style - * @return PHPWord_Section_Table_Cell + * @return PhpOffice\PhpWord\Section\Table\Cell */ public function addCell($width = null, $style = null) { @@ -134,7 +134,7 @@ public function getRows() /** * Get table style * - * @return PHPWord_Style_Table + * @return PhpOffice\PhpWord\Style\Table */ public function getStyle() { diff --git a/Classes/PHPWord/Section/Table/Cell.php b/Classes/PHPWord/Section/Table/Cell.php index f8d6d3400b..b58a2bc75f 100755 --- a/Classes/PHPWord/Section/Table/Cell.php +++ b/Classes/PHPWord/Section/Table/Cell.php @@ -25,12 +25,22 @@ * @version 0.8.0 */ -/** - * PHPWord_Section_Table_Cell - */ -class PHPWord_Section_Table_Cell -{ +namespace PhpOffice\PhpWord\Section\Table; +use PhpOffice\PhpWord\Media; +use PhpOffice\PhpWord\Section\Footer\PreserveText; +use PhpOffice\PhpWord\Section\Image; +use PhpOffice\PhpWord\Section\Link; +use PhpOffice\PhpWord\Section\ListItem; +use PhpOffice\PhpWord\Section\MemoryImage; +use PhpOffice\PhpWord\Section\Object; +use PhpOffice\PhpWord\Section\Text; +use PhpOffice\PhpWord\Section\TextBreak; +use PhpOffice\PhpWord\Section\TextRun; +use PhpOffice\PhpWord\Shared\String; + +class Cell +{ /** * Cell Width * @@ -41,7 +51,7 @@ class PHPWord_Section_Table_Cell /** * Cell Style * - * @var PHPWord_Style_Cell + * @var PhpOffice\PhpWord\Style\Cell */ private $_style; @@ -80,7 +90,7 @@ public function __construct($insideOf, $pCount, $width = null, $style = null) $this->_insideOf = $insideOf; $this->_pCount = $pCount; $this->_width = $width; - $this->_style = new PHPWord_Style_Cell; + $this->_style = new PhpOffice\PhpWord\Style\Cell(); if (!is_null($style)) { if (is_array($style)) { @@ -101,14 +111,14 @@ public function __construct($insideOf, $pCount, $width = null, $style = null) * * @param string $text * @param mixed $style - * @return PHPWord_Section_Text + * @return PhpOffice\PhpWord\Section\Text */ public function addText($text, $styleFont = null, $styleParagraph = null) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $text = new Text($text, $styleFont, $styleParagraph); $this->_elementCollection[] = $text; return $text; } @@ -119,22 +129,22 @@ public function addText($text, $styleFont = null, $styleParagraph = null) * @param string $linkSrc * @param string $linkName * @param mixed $style - * @return PHPWord_Section_Link + * @return PhpOffice\PhpWord\Section\Link */ public function addLink($linkSrc, $linkName = null, $style = null) { if ($this->_insideOf == 'section') { - if (!PHPWord_Shared_String::IsUTF8($linkSrc)) { + if (!String::IsUTF8($linkSrc)) { $linkSrc = utf8_encode($linkSrc); } if (!is_null($linkName)) { - if (!PHPWord_Shared_String::IsUTF8($linkName)) { + if (!String::IsUTF8($linkName)) { $linkName = utf8_encode($linkName); } } - $link = new PHPWord_Section_Link($linkSrc, $linkName, $style); - $rID = PHPWord_Media::addSectionLinkElement($linkSrc); + $link = new Link($linkSrc, $linkName, $style); + $rID = Media::addSectionLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; @@ -148,14 +158,14 @@ public function addLink($linkSrc, $linkName = null, $style = null) /** * Add TextBreak * - * @param int $count - * @param null|string|array|PHPWord_Style_Font $fontStyle - * @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); } } @@ -166,14 +176,14 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu * @param int $depth * @param mixed $styleText * @param mixed $styleList - * @return PHPWord_Section_ListItem + * @return PhpOffice\PhpWord\Section\ListItem */ public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList); + $listItem = new ListItem($text, $depth, $styleText, $styleList); $this->_elementCollection[] = $listItem; return $listItem; } @@ -183,19 +193,19 @@ public function addListItem($text, $depth = 0, $styleText = null, $styleList = n * * @param string $src * @param mixed $style - * @return PHPWord_Section_Image + * @return PhpOffice\PhpWord\Section\Image */ public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); + $image = new Image($src, $style); if (!is_null($image->getSource())) { if ($this->_insideOf == 'section') { - $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); + $rID = Media::addSectionMediaElement($src, 'image'); } elseif ($this->_insideOf == 'header') { - $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src); + $rID = Media::addHeaderMediaElement($this->_pCount, $src); } elseif ($this->_insideOf == 'footer') { - $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src); + $rID = Media::addFooterMediaElement($this->_pCount, $src); } $image->setRelationId($rID); @@ -211,18 +221,18 @@ public function addImage($src, $style = null) * * @param string $link * @param mixed $style - * @return PHPWord_Section_MemoryImage + * @return PhpOffice\PhpWord\Section\MemoryImage */ public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + $memoryImage = new MemoryImage($link, $style); if (!is_null($memoryImage->getSource())) { if ($this->_insideOf == 'section') { - $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); + $rID = Media::addSectionMediaElement($link, 'image', $memoryImage); } elseif ($this->_insideOf == 'header') { - $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); + $rID = Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); } elseif ($this->_insideOf == 'footer') { - $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); + $rID = Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); } $memoryImage->setRelationId($rID); @@ -238,11 +248,11 @@ public function addMemoryImage($link, $style = null) * * @param string $src * @param mixed $style - * @return PHPWord_Section_Object + * @return PhpOffice\PhpWord\Section\Object */ public function addObject($src, $style = null) { - $object = new PHPWord_Section_Object($src, $style); + $object = new Object($src, $style); if (!is_null($object->getSource())) { $inf = pathinfo($src); @@ -258,8 +268,8 @@ public function addObject($src, $style = null) $iconSrc .= '_' . $ext . '.png'; } - $rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); - $data = PHPWord_Media::addSectionMediaElement($src, 'oleObject'); + $rIDimg = Media::addSectionMediaElement($iconSrc, 'image'); + $data = Media::addSectionMediaElement($src, 'oleObject'); $rID = $data[0]; $objectId = $data[1]; @@ -280,15 +290,15 @@ public function addObject($src, $style = null) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PHPWord_Section_Footer_PreserveText + * @return PhpOffice\PhpWord\Section\Footer\PreserveText */ public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { if ($this->_insideOf == 'footer' || $this->_insideOf == 'header') { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); + $ptext = new PreserveText($text, $styleFont, $styleParagraph); $this->_elementCollection[] = $ptext; return $ptext; } else { @@ -299,11 +309,11 @@ public function addPreserveText($text, $styleFont = null, $styleParagraph = null /** * Create a new TextRun * - * @return PHPWord_Section_TextRun + * @return PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); + $textRun = new TextRun($styleParagraph); $this->_elementCollection[] = $textRun; return $textRun; } @@ -321,7 +331,7 @@ public function getElements() /** * Get Cell Style * - * @return PHPWord_Style_Cell + * @return PhpOffice\PhpWord\Style\Cell */ public function getStyle() { diff --git a/Classes/PHPWord/Section/Table/Row.php b/Classes/PHPWord/Section/Table/Row.php index dd8ea65c12..30259a2214 100644 --- a/Classes/PHPWord/Section/Table/Row.php +++ b/Classes/PHPWord/Section/Table/Row.php @@ -25,12 +25,10 @@ * @version 0.8.0 */ -/** - * PHPWord_Section_Table_Row - */ -class PHPWord_Section_Table_Row -{ +namespace PhpOffice\PhpWord\Section\Table; +class Row +{ /** * Row height * @@ -41,7 +39,7 @@ class PHPWord_Section_Table_Row /** * Row style * - * @var PHPWord_Style_Row + * @var PhpOffice\PhpWord\Style\Row */ private $_style; @@ -80,7 +78,7 @@ public function __construct($insideOf, $pCount, $height = null, $style = null) $this->_insideOf = $insideOf; $this->_pCount = $pCount; $this->_height = $height; - $this->_style = new PHPWord_Style_Row(); + $this->_style = new PhpOffice\PhpWord\Style\Row(); if (!is_null($style)) { if (is_array($style)) { @@ -100,11 +98,11 @@ public function __construct($insideOf, $pCount, $height = null, $style = null) * * @param int $width * @param mixed $style - * @return PHPWord_Section_Table_Cell + * @return PhpOffice\PhpWord\Section\Table\Cell */ public function addCell($width = null, $style = null) { - $cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style); + $cell = new Cell($this->_insideOf, $this->_pCount, $width, $style); $this->_cells[] = $cell; return $cell; } @@ -122,7 +120,7 @@ public function getCells() /** * Get row style * - * @return PHPWord_Style_Row + * @return PhpOffice\PhpWord\Style\Row */ public function getStyle() { diff --git a/Classes/PHPWord/Section/Text.php b/Classes/PHPWord/Section/Text.php index 8631b66e1a..05342b6650 100755 --- a/Classes/PHPWord/Section/Text.php +++ b/Classes/PHPWord/Section/Text.php @@ -25,10 +25,12 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_Text - */ -class PHPWord_Section_Text +namespace PhpOffice\PhpWord\Section; + +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; + +class Text { /** * Text content @@ -40,14 +42,14 @@ class PHPWord_Section_Text /** * Text style * - * @var PHPWord_Style_Font + * @var PhpOffice\PhpWord\Style\Font */ private $fontStyle; /** * Paragraph style * - * @var PHPWord_Style_Paragraph + * @var PhpOffice\PhpWord\Style\Paragraph */ private $paragraphStyle; @@ -55,8 +57,8 @@ class PHPWord_Section_Text * Create a new Text Element * * @param string $text - * @param null|array|\PHPWord_Style_Font $fontStyle - * @param null|array|\PHPWord_Style_Paragraph $paragraphStyle + * @param null|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function __construct($text = null, $fontStyle = null, $paragraphStyle = null) { @@ -68,20 +70,20 @@ public function __construct($text = null, $fontStyle = null, $paragraphStyle = n /** * Set Text style * - * @param null|array|\PHPWord_Style_Font $style - * @param null|array|\PHPWord_Style_Paragraph $paragraphStyle - * @return PHPWord_Style_Font + * @param null|array|PhpOffice\PhpWord\Style\Font $style + * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @return PhpOffice\PhpWord\Style\Font */ public function setFontStyle($style = null, $paragraphStyle = null) { - if ($style instanceof PHPWord_Style_Font) { + if ($style instanceof Font) { $this->fontStyle = $style; $this->setParagraphStyle($paragraphStyle); } elseif (is_array($style)) { - $this->fontStyle = new PHPWord_Style_Font('text', $paragraphStyle); + $this->fontStyle = new Font('text', $paragraphStyle); $this->fontStyle->setArrayStyle($style); } elseif (null === $style) { - $this->fontStyle = new PHPWord_Style_Font('text', $paragraphStyle); + $this->fontStyle = new Font('text', $paragraphStyle); } else { $this->fontStyle = $style; $this->setParagraphStyle($paragraphStyle); @@ -92,7 +94,7 @@ public function setFontStyle($style = null, $paragraphStyle = null) /** * Get Text style * - * @return PHPWord_Style_Font + * @return PhpOffice\PhpWord\Style\Font */ public function getFontStyle() { @@ -102,18 +104,18 @@ public function getFontStyle() /** * Set Paragraph style * - * @param null|array|\PHPWord_Style_Paragraph $style - * @return null|\PHPWord_Style_Paragraph + * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style + * @return null|PhpOffice\PhpWord\Style\Paragraph */ public function setParagraphStyle($style = null) { if (is_array($style)) { - $this->paragraphStyle = new PHPWord_Style_Paragraph; + $this->paragraphStyle = new Paragraph; $this->paragraphStyle->setArrayStyle($style); - } elseif ($style instanceof PHPWord_Style_Paragraph) { + } elseif ($style instanceof Paragraph) { $this->paragraphStyle = $style; } elseif (null === $style) { - $this->paragraphStyle = new PHPWord_Style_Paragraph; + $this->paragraphStyle = new Paragraph; } else { $this->paragraphStyle = $style; } @@ -123,7 +125,7 @@ public function setParagraphStyle($style = null) /** * Get Paragraph style * - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/Classes/PHPWord/Section/TextBreak.php b/Classes/PHPWord/Section/TextBreak.php index 85f53edc9d..f3f76aa725 100755 --- a/Classes/PHPWord/Section/TextBreak.php +++ b/Classes/PHPWord/Section/TextBreak.php @@ -25,22 +25,24 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_TextBreak - */ -class PHPWord_Section_TextBreak +namespace PhpOffice\PhpWord\Section; + +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; + +class TextBreak { /** * Paragraph style * - * @var PHPWord_Style_Pagaraph + * @var PhpOffice\PhpWord\Style\Pagaraph */ private $paragraphStyle = null; /** * Text style * - * @var PHPWord_Style_Font + * @var PhpOffice\PhpWord\Style\Font */ private $fontStyle = null; @@ -60,17 +62,17 @@ public function __construct($fontStyle = null, $paragraphStyle = null) /** * Set Text style * - * @param null|array|\PHPWord_Style_Font $style - * @param null|array|\PHPWord_Style_Paragraph $paragraphStyle - * @return PHPWord_Style_Font + * @param null|array|PhpOffice\PhpWord\Style\Font $style + * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @return PhpOffice\PhpWord\Style\Font */ public function setFontStyle($style = null, $paragraphStyle = null) { - if ($style instanceof PHPWord_Style_Font) { + if ($style instanceof Font) { $this->fontStyle = $style; $this->setParagraphStyle($paragraphStyle); } elseif (is_array($style)) { - $this->fontStyle = new PHPWord_Style_Font('text', $paragraphStyle); + $this->fontStyle = new Font('text', $paragraphStyle); $this->fontStyle->setArrayStyle($style); } else { $this->fontStyle = $style; @@ -82,7 +84,7 @@ public function setFontStyle($style = null, $paragraphStyle = null) /** * Get Text style * - * @return PHPWord_Style_Font + * @return PhpOffice\PhpWord\Style\Font */ public function getFontStyle() { @@ -92,15 +94,15 @@ public function getFontStyle() /** * Set Paragraph style * - * @param null|array|\PHPWord_Style_Paragraph $style - * @return null|\PHPWord_Style_Paragraph + * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style + * @return null|PhpOffice\PhpWord\Style\Paragraph */ public function setParagraphStyle($style = null) { if (is_array($style)) { - $this->paragraphStyle = new PHPWord_Style_Paragraph; + $this->paragraphStyle = new Paragraph; $this->paragraphStyle->setArrayStyle($style); - } elseif ($style instanceof PHPWord_Style_Paragraph) { + } elseif ($style instanceof Paragraph) { $this->paragraphStyle = $style; } else { $this->paragraphStyle = $style; @@ -111,10 +113,10 @@ public function setParagraphStyle($style = null) /** * Get Paragraph style * - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { return $this->paragraphStyle; } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Section/TextRun.php b/Classes/PHPWord/Section/TextRun.php index fcb2bd482b..2036a4dfd7 100755 --- a/Classes/PHPWord/Section/TextRun.php +++ b/Classes/PHPWord/Section/TextRun.php @@ -25,16 +25,18 @@ * @version 0.8.0 */ -/** - * PHPWord_Section_TextRun - */ -class PHPWord_Section_TextRun -{ +namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Media; +use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Style\Paragraph; + +class TextRun +{ /** * Paragraph style * - * @var PHPWord_Style_Font + * @var PhpOffice\PhpWord\Style\Paragraph */ private $_styleParagraph; @@ -55,7 +57,7 @@ public function __construct($styleParagraph = null) // Set paragraph style if (is_array($styleParagraph)) { - $this->_styleParagraph = new PHPWord_Style_Paragraph(); + $this->_styleParagraph = new Paragraph(); foreach ($styleParagraph as $key => $value) { if (substr($key, 0, 1) != '_') { @@ -74,14 +76,14 @@ public function __construct($styleParagraph = null) * * @var string $text * @var mixed $styleFont - * @return PHPWord_Section_Text + * @return PhpOffice\PhpWord\Section\Text */ public function addText($text = null, $styleFont = null) { - if (!PHPWord_Shared_String::IsUTF8($text)) { + if (!String::IsUTF8($text)) { $text = utf8_encode($text); } - $text = new PHPWord_Section_Text($text, $styleFont); + $text = new Text($text, $styleFont); $this->_elementCollection[] = $text; return $text; } @@ -92,7 +94,7 @@ public function addText($text = null, $styleFont = null) * @param string $linkSrc * @param string $linkName * @param mixed $styleFont - * @return PHPWord_Section_Link + * @return PhpOffice\PhpWord\Section\Link */ public function addLink($linkSrc, $linkName = null, $styleFont = null) { @@ -101,8 +103,8 @@ public function addLink($linkSrc, $linkName = null, $styleFont = null) $linkName = utf8_encode($linkName); } - $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont); - $rID = PHPWord_Media::addSectionLinkElement($linkSrc); + $link = new Link($linkSrc, $linkName, $styleFont); + $rID = Media::addSectionLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; @@ -114,14 +116,14 @@ public function addLink($linkSrc, $linkName = null, $styleFont = null) * * @param string $imageSrc * @param mixed $styleFont - * @return PHPWord_Section_Image + * @return PhpOffice\PhpWord\Section\Image */ public function addImage($imageSrc, $style = null) { - $image = new PHPWord_Section_Image($imageSrc, $style); + $image = new Image($imageSrc, $style); if (!is_null($image->getSource())) { - $rID = PHPWord_Media::addSectionMediaElement($imageSrc, 'image'); + $rID = Media::addSectionMediaElement($imageSrc, 'image'); $image->setRelationId($rID); $this->_elementCollection[] = $image; @@ -134,14 +136,14 @@ public function addImage($imageSrc, $style = null) /** * Add TextBreak * - * @param int $count - * @param null|string|array|PHPWord_Style_Font $fontStyle - * @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); } } @@ -149,12 +151,12 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu * Create a new Footnote Element * * @param string $text - * @return PHPWord_Section_Footnote + * @return PhpOffice\PhpWord\Section\Footnote */ public function createFootnote($styleParagraph = null) { - $footnote = new PHPWord_Section_Footnote($styleParagraph); - $refID = PHPWord_Footnote::addFootnoteElement($footnote); + $footnote = new PhpOffice\PhpWord\Section\Footnote($styleParagraph); + $refID = PhpOffice\PhpWord\Footnote::addFootnoteElement($footnote); $footnote->setReferenceId($refID); $this->_elementCollection[] = $footnote; return $footnote; @@ -173,10 +175,10 @@ public function getElements() /** * Get Paragraph style * - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { return $this->_styleParagraph; } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Section/Title.php b/Classes/PHPWord/Section/Title.php index 067370f2f2..74b9734acc 100755 --- a/Classes/PHPWord/Section/Title.php +++ b/Classes/PHPWord/Section/Title.php @@ -25,12 +25,10 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Section_Title - */ -class PHPWord_Section_Title -{ +namespace PhpOffice\PhpWord\Section; +class Title +{ /** * Title Text content * diff --git a/Classes/PHPWord/Settings.php b/Classes/PHPWord/Settings.php index 0869f215fe..79a51bc16e 100644 --- a/Classes/PHPWord/Settings.php +++ b/Classes/PHPWord/Settings.php @@ -25,10 +25,9 @@ * @version 0.8.0 */ -/** - * PHPWord_Settings - */ -class PHPWord_Settings +namespace PhpOffice\PhpWord; + +class Settings { /** * Compatibility option for XMLWriter diff --git a/Classes/PHPWord/Shared/Drawing.php b/Classes/PHPWord/Shared/Drawing.php index 9930b44ee5..74f5080ef2 100755 --- a/Classes/PHPWord/Shared/Drawing.php +++ b/Classes/PHPWord/Shared/Drawing.php @@ -25,10 +25,9 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Shared_Drawing - */ -class PHPWord_Shared_Drawing +namespace PhpOffice\PhpWord\Shared; + +class Drawing { /** * Convert pixels to EMU diff --git a/Classes/PHPWord/Shared/File.php b/Classes/PHPWord/Shared/File.php index 26a206ba6a..623f7152dc 100755 --- a/Classes/PHPWord/Shared/File.php +++ b/Classes/PHPWord/Shared/File.php @@ -25,10 +25,9 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Shared_File - */ -class PHPWord_Shared_File +namespace PhpOffice\PhpWord\Shared; + +class File { /** * Verify if a file exists diff --git a/Classes/PHPWord/Shared/Font.php b/Classes/PHPWord/Shared/Font.php index 3bb783b879..115a3e8839 100755 --- a/Classes/PHPWord/Shared/Font.php +++ b/Classes/PHPWord/Shared/Font.php @@ -25,10 +25,9 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Shared_Font - */ -class PHPWord_Shared_Font +namespace PhpOffice\PhpWord\Shared; + +class Font { /** * Calculate an (approximate) pixel size, based on a font points size diff --git a/Classes/PHPWord/Shared/String.php b/Classes/PHPWord/Shared/String.php index 0f0d072196..e4dc916f4a 100755 --- a/Classes/PHPWord/Shared/String.php +++ b/Classes/PHPWord/Shared/String.php @@ -25,10 +25,9 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Shared_String - */ -class PHPWord_Shared_String +namespace PhpOffice\PhpWord\Shared; + +class String { /** * Control characters array diff --git a/Classes/PHPWord/Shared/XMLWriter.php b/Classes/PHPWord/Shared/XMLWriter.php index 6e6e636058..c83a8ce7f9 100755 --- a/Classes/PHPWord/Shared/XMLWriter.php +++ b/Classes/PHPWord/Shared/XMLWriter.php @@ -25,18 +25,20 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord\Shared; + +use PhpOffice\PhpWord\Settings; + if (!defined('DATE_W3C')) { define('DATE_W3C', 'Y-m-d\TH:i:sP'); } /** - * Class PHPWord_Shared_XMLWriter - * * @method bool startElement(string $name) * @method bool writeAttribute(string $name, string $value) * @method bool endElement() */ -class PHPWord_Shared_XMLWriter +class XMLWriter { /** Temporary storage method */ const STORAGE_MEMORY = 1; @@ -57,7 +59,7 @@ class PHPWord_Shared_XMLWriter private $_tempFileName = ''; /** - * Create a new PHPWord_Shared_XMLWriter instance + * Create a new XMLWriter instance * * @param int $pTemporaryStorage Temporary storage location * @param string $pTemporaryStorageFolder Temporary storage folder @@ -82,7 +84,7 @@ public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTempora } // Set xml Compatibility - $compatibility = PHPWord_Settings::getCompatibility(); + $compatibility = Settings::getCompatibility(); if ($compatibility) { $this->_xmlWriter->setIndent(false); $this->_xmlWriter->setIndentString(''); diff --git a/Classes/PHPWord/Shared/ZipStreamWrapper.php b/Classes/PHPWord/Shared/ZipStreamWrapper.php index fe4ff372d3..1db61db3c9 100755 --- a/Classes/PHPWord/Shared/ZipStreamWrapper.php +++ b/Classes/PHPWord/Shared/ZipStreamWrapper.php @@ -25,12 +25,12 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord\Shared; + /** - * Class PHPWord_Shared_ZipStreamWrapper - * * @codeCoverageIgnore Legacy from PHPExcel */ -class PHPWord_Shared_ZipStreamWrapper +class ZipStreamWrapper { /** * Internal ZipAcrhive @@ -180,4 +180,4 @@ public function stream_seek($offset, $whence) return false; } } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Style.php b/Classes/PHPWord/Style.php index 8366b6583b..fdd2986239 100755 --- a/Classes/PHPWord/Style.php +++ b/Classes/PHPWord/Style.php @@ -25,30 +25,27 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Style - */ -class PHPWord_Style -{ +namespace PhpOffice\PhpWord; + +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\Style\TableFull; +class Style +{ /** - * Style Elements - * * @var array */ private static $_styleElements = array(); - /** - * Add a paragraph style - * * @param string $styleName * @param array $styles */ public static function addParagraphStyle($styleName, $styles) { if (!array_key_exists($styleName, self::$_styleElements)) { - $style = new PHPWord_Style_Paragraph(); + $style = new Paragraph(); foreach ($styles as $key => $value) { if (substr($key, 0, 1) != '_') { $key = '_' . $key; @@ -61,8 +58,6 @@ public static function addParagraphStyle($styleName, $styles) } /** - * Add a font style - * * @param string $styleName * @param array $styleFont * @param array $styleParagraph @@ -70,7 +65,7 @@ public static function addParagraphStyle($styleName, $styles) public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) { if (!array_key_exists($styleName, self::$_styleElements)) { - $font = new PHPWord_Style_Font('text', $styleParagraph); + $font = new Font('text', $styleParagraph); foreach ($styleFont as $key => $value) { if (substr($key, 0, 1) != '_') { $key = '_' . $key; @@ -82,15 +77,13 @@ public static function addFontStyle($styleName, $styleFont, $styleParagraph = nu } /** - * Add a link style - * * @param string $styleName * @param array $styles */ public static function addLinkStyle($styleName, $styles) { if (!array_key_exists($styleName, self::$_styleElements)) { - $style = new PHPWord_Style_Font('link'); + $style = new Font('link'); foreach ($styles as $key => $value) { if (substr($key, 0, 1) != '_') { $key = '_' . $key; @@ -103,23 +96,19 @@ public static function addLinkStyle($styleName, $styles) } /** - * Add a table style - * * @param string $styleName * @param array $styles */ public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null) { if (!array_key_exists($styleName, self::$_styleElements)) { - $style = new PHPWord_Style_TableFull($styleTable, $styleFirstRow, $styleLastRow); + $style = new TableFull($styleTable, $styleFirstRow, $styleLastRow); self::$_styleElements[$styleName] = $style; } } /** - * Add a title style - * * @param string $styleName * @param array $styleFont * @param array $styleParagraph @@ -128,7 +117,7 @@ public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = { $styleName = 'Heading_' . $titleCount; if (!array_key_exists($styleName, self::$_styleElements)) { - $font = new PHPWord_Style_Font('title', $styleParagraph); + $font = new Font('title', $styleParagraph); foreach ($styleFont as $key => $value) { if (substr($key, 0, 1) != '_') { $key = '_' . $key; @@ -141,9 +130,7 @@ public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = } /** - * Set default paragraph style - * - * @param array $styles Paragraph style definition + * @param array $styles Paragraph style definition */ public static function setDefaultParagraphStyle($styles) { @@ -153,7 +140,7 @@ public static function setDefaultParagraphStyle($styles) /** * Get all styles * - * @return PHPWord_Style_Font[] + * @return PhpOffice\PhpWord\Style\Font[] */ public static function getStyles() { @@ -161,10 +148,7 @@ public static function getStyles() } /** - * Get style - * * @param string - * @return PHPWord_Style */ public static function getStyle($styleName) { @@ -174,4 +158,4 @@ public static function getStyle($styleName) return null; } } -} +} \ No newline at end of file From b32c1988246fe3ed6df2db6d9ccbfba24478446b Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 18 Mar 2014 15:04:14 +0400 Subject: [PATCH 02/15] https://github.com/PHPOffice/PHPWord/issues/58 Part II. --- Classes/PHPWord/Style/Cell.php | 8 +- Classes/PHPWord/Style/Font.php | 67 ++-- Classes/PHPWord/Style/Image.php | 7 +- Classes/PHPWord/Style/ListItem.php | 12 +- Classes/PHPWord/Style/Paragraph.php | 37 +- Classes/PHPWord/Style/Row.php | 8 +- Classes/PHPWord/Style/TOC.php | 12 +- Classes/PHPWord/Style/Tab.php | 30 +- Classes/PHPWord/Style/Table.php | 8 +- Classes/PHPWord/Style/TableFull.php | 59 +-- Classes/PHPWord/Style/Tabs.php | 23 +- Classes/PHPWord/TOC.php | 18 +- Classes/PHPWord/Template.php | 11 +- Classes/PHPWord/Writer/IWriter.php | 9 +- Classes/PHPWord/Writer/ODText.php | 54 +-- Classes/PHPWord/Writer/ODText/Content.php | 392 ++++++++++--------- Classes/PHPWord/Writer/ODText/Manifest.php | 80 ++-- Classes/PHPWord/Writer/ODText/Meta.php | 57 +-- Classes/PHPWord/Writer/ODText/Mimetype.php | 7 +- Classes/PHPWord/Writer/ODText/Styles.php | 319 +++++++-------- Classes/PHPWord/Writer/ODText/WriterPart.php | 19 +- 21 files changed, 602 insertions(+), 635 deletions(-) diff --git a/Classes/PHPWord/Style/Cell.php b/Classes/PHPWord/Style/Cell.php index b07eb4c237..569d9f2afe 100755 --- a/Classes/PHPWord/Style/Cell.php +++ b/Classes/PHPWord/Style/Cell.php @@ -25,12 +25,10 @@ * @version 0.8.0 */ -/** - * PHPWord_Style_Cell - */ -class PHPWord_Style_Cell -{ +namespace PhpOffice\PhpWord\Style; +class Cell +{ const TEXT_DIR_BTLR = 'btLr'; const TEXT_DIR_TBRL = 'tbRl'; diff --git a/Classes/PHPWord/Style/Font.php b/Classes/PHPWord/Style/Font.php index f26f392468..b350d8d5f5 100755 --- a/Classes/PHPWord/Style/Font.php +++ b/Classes/PHPWord/Style/Font.php @@ -1,5 +1,4 @@ _type = $type; - if ($paragraphStyle instanceof PHPWord_Style_Paragraph) { + if ($paragraphStyle instanceof Paragraph) { $this->_paragraphStyle = $paragraphStyle; } elseif (is_array($paragraphStyle)) { - $this->_paragraphStyle = new PHPWord_Style_Paragraph; + $this->_paragraphStyle = new Paragraph; $this->_paragraphStyle->setArrayStyle($paragraphStyle); } else { $this->_paragraphStyle = $paragraphStyle; @@ -230,8 +229,8 @@ public function getName() /** * Set font name * - * @param string $pValue - * @return PHPWord_Style_Font + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setName($pValue = PHPWord::DEFAULT_FONT_NAME) { @@ -256,8 +255,8 @@ public function getSize() /** * Set font size * - * @param int|float $pValue - * @return PHPWord_Style_Font + * @param int|float $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE) { @@ -281,8 +280,8 @@ public function getBold() /** * Set bold * - * @param bool $pValue - * @return PHPWord_Style_Font + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setBold($pValue = false) { @@ -306,8 +305,8 @@ public function getItalic() /** * Set italics * - * @param bool $pValue - * @return PHPWord_Style_Font + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setItalic($pValue = false) { @@ -331,8 +330,8 @@ public function getSuperScript() /** * Set superscript * - * @param bool $pValue - * @return PHPWord_Style_Font + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setSuperScript($pValue = false) { @@ -357,8 +356,8 @@ public function getSubScript() /** * Set subscript * - * @param bool $pValue - * @return PHPWord_Style_Font + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setSubScript($pValue = false) { @@ -383,13 +382,13 @@ public function getUnderline() /** * Set underline * - * @param string $pValue - * @return PHPWord_Style_Font + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font */ - public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) + public function setUnderline($pValue = self::UNDERLINE_NONE) { if ($pValue == '') { - $pValue = PHPWord_Style_Font::UNDERLINE_NONE; + $pValue = self::UNDERLINE_NONE; } $this->_underline = $pValue; return $this; @@ -408,8 +407,8 @@ public function getStrikethrough() /** * Set strikethrough * - * @param bool $pValue - * @return PHPWord_Style_Font + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setStrikethrough($pValue = false) { @@ -433,8 +432,8 @@ public function getColor() /** * Set font color * - * @param string $pValue - * @return PHPWord_Style_Font + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR) { @@ -458,8 +457,8 @@ public function getFgColor() /** * Set foreground/highlight color * - * @param string $pValue - * @return PHPWord_Style_Font + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setFgColor($pValue = null) { @@ -480,7 +479,7 @@ public function getStyleType() /** * Get paragraph style * - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { @@ -530,8 +529,8 @@ public function getHint() /** * Set Font Content Type * - * @param string $pValue - * @return PHPWord_Style_Font + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font */ public function setHint($pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE) { diff --git a/Classes/PHPWord/Style/Image.php b/Classes/PHPWord/Style/Image.php index 9bec4d5bd7..c78c6087b2 100755 --- a/Classes/PHPWord/Style/Image.php +++ b/Classes/PHPWord/Style/Image.php @@ -25,10 +25,9 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Style_Image - */ -class PHPWord_Style_Image +namespace PhpOffice\PhpWord\Style; + +class Image { const WRAPPING_STYLE_INLINE = 'inline'; const WRAPPING_STYLE_SQUARE = 'square'; diff --git a/Classes/PHPWord/Style/ListItem.php b/Classes/PHPWord/Style/ListItem.php index 5fbff0d6fb..dc3d8c6aa5 100755 --- a/Classes/PHPWord/Style/ListItem.php +++ b/Classes/PHPWord/Style/ListItem.php @@ -25,12 +25,10 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Style_ListItem - */ -class PHPWord_Style_ListItem -{ +namespace PhpOffice\PhpWord\Style; +class ListItem +{ const TYPE_NUMBER = 7; const TYPE_NUMBER_NESTED = 8; const TYPE_ALPHANUM = 9; @@ -48,7 +46,7 @@ class PHPWord_Style_ListItem */ public function __construct() { - $this->_listType = PHPWord_Style_ListItem::TYPE_BULLET_FILLED; + $this->_listType = self::TYPE_BULLET_FILLED; } /** @@ -67,7 +65,7 @@ public function setStyleValue($key, $value) * * @param int $pValue */ - public function setListType($pValue = PHPWord_Style_ListItem::TYPE_BULLET_FILLED) + public function setListType($pValue = self::TYPE_BULLET_FILLED) { $this->_listType = $pValue; } diff --git a/Classes/PHPWord/Style/Paragraph.php b/Classes/PHPWord/Style/Paragraph.php index 32a44929bf..7913d1053b 100755 --- a/Classes/PHPWord/Style/Paragraph.php +++ b/Classes/PHPWord/Style/Paragraph.php @@ -25,12 +25,11 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord\Style; + use PhpOffice\PhpWord\Exceptions\InvalidStyleException; -/** - * PHPWord_Style_Paragraph - */ -class PHPWord_Style_Paragraph +class Paragraph { const LINE_HEIGHT = 240; @@ -187,7 +186,7 @@ public function getAlign() * Set Paragraph Alignment * * @param string $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setAlign($pValue = null) { @@ -213,7 +212,7 @@ public function getSpaceBefore() * Set Space before Paragraph * * @param int $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setSpaceBefore($pValue = null) { @@ -235,7 +234,7 @@ public function getSpaceAfter() * Set Space after Paragraph * * @param int $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setSpaceAfter($pValue = null) { @@ -257,7 +256,7 @@ public function getSpacing() * Set Spacing between breaks * * @param int $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setSpacing($pValue = null) { @@ -279,7 +278,7 @@ public function getIndent() * Set indentation * * @param int $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setIndent($pValue = null) { @@ -301,7 +300,7 @@ public function getHanging() * Set hanging * * @param int $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setHanging($pValue = null) { @@ -312,7 +311,7 @@ public function setHanging($pValue = null) /** * Get tabs * - * @return PHPWord_Style_Tabs + * @return PhpOffice\PhpWord\Style\Tabs */ public function getTabs() { @@ -323,12 +322,12 @@ public function getTabs() * Set tabs * * @param array $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setTabs($pValue = null) { if (is_array($pValue)) { - $this->_tabs = new PHPWord_Style_Tabs($pValue); + $this->_tabs = new Tabs($pValue); } return $this; } @@ -347,7 +346,7 @@ public function getBasedOn() * Set parent style ID * * @param string $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setBasedOn($pValue = 'Normal') { @@ -369,7 +368,7 @@ public function getNext() * Set style for next paragraph * * @param string $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setNext($pValue = null) { @@ -391,7 +390,7 @@ public function getWidowControl() * Set keep paragraph with next paragraph setting * * @param bool $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setWidowControl($pValue = true) { @@ -416,7 +415,7 @@ public function getKeepNext() * Set keep paragraph with next paragraph setting * * @param bool $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setKeepNext($pValue = false) { @@ -441,7 +440,7 @@ public function getKeepLines() * Set keep all lines on one page setting * * @param bool $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setKeepLines($pValue = false) { @@ -466,7 +465,7 @@ public function getPageBreakBefore() * Set start paragraph on next page setting * * @param bool $pValue - * @return PHPWord_Style_Paragraph + * @return PhpOffice\PhpWord\Style\Paragraph */ public function setPageBreakBefore($pValue = false) { diff --git a/Classes/PHPWord/Style/Row.php b/Classes/PHPWord/Style/Row.php index 93b5f86265..80951f7969 100644 --- a/Classes/PHPWord/Style/Row.php +++ b/Classes/PHPWord/Style/Row.php @@ -25,12 +25,10 @@ * @version 0.8.0 */ -/** - * PHPWord_Style_Row - */ -class PHPWord_Style_Row -{ +namespace PhpOffice\PhpWord\Style; +class Row +{ /** * Repeat table row on every new page * diff --git a/Classes/PHPWord/Style/TOC.php b/Classes/PHPWord/Style/TOC.php index 482ae868fe..f1a4700354 100755 --- a/Classes/PHPWord/Style/TOC.php +++ b/Classes/PHPWord/Style/TOC.php @@ -25,12 +25,10 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Style_TOC - */ -class PHPWord_Style_TOC -{ +namespace PhpOffice\PhpWord\Style; +class TOC +{ const TABLEADER_DOT = 'dot'; const TABLEADER_UNDERSCORE = 'underscore'; const TABLEADER_LINE = 'hyphen'; @@ -64,7 +62,7 @@ class PHPWord_Style_TOC public function __construct() { $this->_tabPos = 9062; - $this->_tabLeader = PHPWord_Style_TOC::TABLEADER_DOT; + $this->_tabLeader = self::TABLEADER_DOT; $this->_indent = 200; } @@ -103,7 +101,7 @@ public function getTabLeader() * * @param string $pValue */ - public function setTabLeader($pValue = PHPWord_Style_TOC::TABLEADER_DOT) + public function setTabLeader($pValue = self::TABLEADER_DOT) { $this->_tabLeader = $pValue; } diff --git a/Classes/PHPWord/Style/Tab.php b/Classes/PHPWord/Style/Tab.php index 8db7abae17..3f22f6be7f 100755 --- a/Classes/PHPWord/Style/Tab.php +++ b/Classes/PHPWord/Style/Tab.php @@ -25,12 +25,12 @@ * @version 0.8.0 */ -/** - * PHPWord_Style_Tabs - */ -class PHPWord_Style_Tab -{ +namespace PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Shared\XMLWriter; + +class Tab +{ /** * Tab Stop Type * @@ -84,7 +84,7 @@ class PHPWord_Style_Tab ); /** - * Create a new instance of PHPWord_Style_Tab. Both $val and $leader + * Create a new instance of Tab. Both $val and $leader * must conform to the values put forth in the schema. If they do not * they will be changed to default values. * @@ -105,20 +105,20 @@ public function __construct($val = null, $position = 0, $leader = null) } /** - * Creates the XML DOM for the instance of PHPWord_Style_Tab. + * Creates the XML DOM for the instance of Tab. * - * @param PHPWord_Shared_XMLWriter $objWriter + * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter */ - public function toXml(PHPWord_Shared_XMLWriter &$objWriter = null) + public function toXml(XMLWriter &$xmlWriter = null) { - if (isset($objWriter)) { - $objWriter->startElement("w:tab"); - $objWriter->writeAttribute("w:val", $this->_val); + if (isset($xmlWriter)) { + $xmlWriter->startElement("w:tab"); + $xmlWriter->writeAttribute("w:val", $this->_val); if (!is_null($this->_leader)) { - $objWriter->writeAttribute("w:leader", $this->_leader); + $xmlWriter->writeAttribute("w:leader", $this->_leader); } - $objWriter->writeAttribute("w:pos", $this->_position); - $objWriter->endElement(); + $xmlWriter->writeAttribute("w:pos", $this->_position); + $xmlWriter->endElement(); } } diff --git a/Classes/PHPWord/Style/Table.php b/Classes/PHPWord/Style/Table.php index c3ef2e0140..becba6517a 100755 --- a/Classes/PHPWord/Style/Table.php +++ b/Classes/PHPWord/Style/Table.php @@ -25,12 +25,10 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Style_Table - */ -class PHPWord_Style_Table -{ +namespace PhpOffice\PhpWord\Style; +class Table +{ private $_cellMarginTop; private $_cellMarginLeft; private $_cellMarginRight; diff --git a/Classes/PHPWord/Style/TableFull.php b/Classes/PHPWord/Style/TableFull.php index 573ae53b66..b6466d8511 100755 --- a/Classes/PHPWord/Style/TableFull.php +++ b/Classes/PHPWord/Style/TableFull.php @@ -25,145 +25,104 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Style_TableFull - */ -class PHPWord_Style_TableFull -{ +namespace PhpOffice\PhpWord\Style; +class TableFull +{ /** * Style for first row * - * @var PHPWord_Style_Table + * @var PhpOffice\PhpWord\Style\TableFull */ private $_firstRow = null; /** - * Cell Margin Top - * * @var int */ private $_cellMarginTop = null; /** - * Cell Margin Left - * * @var int */ private $_cellMarginLeft = null; /** - * Cell Margin Right - * * @var int */ private $_cellMarginRight = null; /** - * Cell Margin Bottom - * * @var int */ private $_cellMarginBottom = null; /** - * Background-Color - * * @var string */ private $_bgColor; /** - * Border Top Size - * * @var int */ private $_borderTopSize; /** - * Border Top Color - * * @var string */ private $_borderTopColor; /** - * Border Left Size - * * @var int */ private $_borderLeftSize; /** - * Border Left Color - * * @var string */ private $_borderLeftColor; /** - * Border Right Size - * * @var int */ private $_borderRightSize; /** - * Border Right Color - * * @var string */ private $_borderRightColor; /** - * Border Bottom Size - * * @var int */ private $_borderBottomSize; /** - * Border Bottom Color - * * @var string */ private $_borderBottomColor; /** - * Border InsideH Size - * * @var int */ private $_borderInsideHSize; /** - * Border InsideH Color - * * @var string */ private $_borderInsideHColor; /** - * Border InsideV Size - * * @var int */ private $_borderInsideVSize; /** - * Border InsideV Color - * * @var string */ private $_borderInsideVColor; - - /** - * Create a new TableFull Font - */ - public function __construct($styleTable = null, $styleFirstRow = null, $styleLastRow = null) + public function __construct($styleTable = null, $styleFirstRow = null) { - if (!is_null($styleFirstRow) && is_array($styleFirstRow)) { $this->_firstRow = clone $this; @@ -196,8 +155,6 @@ public function __construct($styleTable = null, $styleFirstRow = null, $styleLas } /** - * Set style value - * * @param string $key * @param mixed $value */ @@ -217,7 +174,7 @@ public function setStyleValue($key, $value) /** * Get First Row Style * - * @return PHPWord_Style_TableFull + * @return PhpOffice\PhpWord\Style\TableFull */ public function getFirstRow() { @@ -227,7 +184,7 @@ public function getFirstRow() /** * Get Last Row Style * - * @return PHPWord_Style_TableFull + * @return PhpOffice\PhpWord\Style\TableFull */ public function getLastRow() { @@ -483,4 +440,4 @@ public function getCellMargin() { return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Style/Tabs.php b/Classes/PHPWord/Style/Tabs.php index a5e1a8bba1..c56277dc9b 100755 --- a/Classes/PHPWord/Style/Tabs.php +++ b/Classes/PHPWord/Style/Tabs.php @@ -25,12 +25,12 @@ * @version 0.8.0 */ -/** - * PHPWord_Style_Tabs - */ -class PHPWord_Style_Tabs -{ +namespace PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Shared\XMLWriter; + +class Tabs +{ /** * Tabs * @@ -48,17 +48,16 @@ public function __construct(array $tabs) } /** - * - * @param PHPWord_Shared_XMLWriter $objWriter + * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter */ - public function toXml(PHPWord_Shared_XMLWriter &$objWriter = null) + public function toXml(XMLWriter &$xmlWriter = null) { - if (isset($objWriter)) { - $objWriter->startElement("w:tabs"); + if (isset($xmlWriter)) { + $xmlWriter->startElement("w:tabs"); foreach ($this->_tabs as &$tab) { - $tab->toXml($objWriter); + $tab->toXml($xmlWriter); } - $objWriter->endElement(); + $xmlWriter->endElement(); } } } diff --git a/Classes/PHPWord/TOC.php b/Classes/PHPWord/TOC.php index c81fca228e..6c2db1602f 100755 --- a/Classes/PHPWord/TOC.php +++ b/Classes/PHPWord/TOC.php @@ -25,12 +25,12 @@ * @version 0.8.0 */ -/** - * Class PHPWord_TOC - */ -class PHPWord_TOC -{ +namespace PhpOffice\PhpWord; +use PhpOffice\PhpWord\Style\Font; + +class TOC +{ /** * Title Elements * @@ -75,7 +75,7 @@ class PHPWord_TOC */ public function __construct($styleFont = null, $styleTOC = null) { - self::$_styleTOC = new PHPWord_Style_TOC(); + self::$_styleTOC = new PhpOffice\PhpWord\Style\TOC(); if (!is_null($styleTOC) && is_array($styleTOC)) { foreach ($styleTOC as $key => $value) { @@ -88,7 +88,7 @@ public function __construct($styleFont = null, $styleTOC = null) if (!is_null($styleFont)) { if (is_array($styleFont)) { - self::$_styleFont = new PHPWord_Style_Font(); + self::$_styleFont = new Font(); foreach ($styleFont as $key => $value) { if (substr($key, 0, 1) != '_') { @@ -136,7 +136,7 @@ public static function getTitles() /** * Get TOC Style * - * @return PHPWord_Style_TOC + * @return PhpOffice\PhpWord\Style\TOC */ public static function getStyleTOC() { @@ -146,7 +146,7 @@ public static function getStyleTOC() /** * Get Font Style * - * @return PHPWord_Style_Font + * @return PhpOffice\PhpWord\Style\Font */ public static function getStyleFont() { diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index 752fa79222..ffadfcdaea 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -25,14 +25,13 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord; + use PhpOffice\PhpWord\Exceptions\Exception; +use PhpOffice\PhpWord\Shared\String; -/** - * PHPWord_DocumentProperties - */ -class PHPWord_Template +class Template { - /** * ZipArchive * @@ -132,7 +131,7 @@ public function setValue($search, $replace, $limit = -1) } if (!is_array($replace)) { - if (!PHPWord_Shared_String::IsUTF8($replace)) { + if (!String::IsUTF8($replace)) { $replace = utf8_encode($replace); } $replace = htmlspecialchars($replace); diff --git a/Classes/PHPWord/Writer/IWriter.php b/Classes/PHPWord/Writer/IWriter.php index f5ca82992b..764e52cd3a 100755 --- a/Classes/PHPWord/Writer/IWriter.php +++ b/Classes/PHPWord/Writer/IWriter.php @@ -25,10 +25,9 @@ * @version 0.8.0 */ -/** - * Interface PHPWord_Writer_IWriter - */ -interface PHPWord_Writer_IWriter +namespace PhpOffice\PhpWord\Writer; + +interface IWriter { /** * Save PHPWord to file @@ -37,4 +36,4 @@ interface PHPWord_Writer_IWriter * @throws Exception */ public function save($pFilename = null); -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Writer/ODText.php b/Classes/PHPWord/Writer/ODText.php index 7d8c2e4b20..10c47fb893 100755 --- a/Classes/PHPWord/Writer/ODText.php +++ b/Classes/PHPWord/Writer/ODText.php @@ -25,10 +25,16 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_ODText - */ -class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter +namespace PhpOffice\PhpWord\Writer; + +use PhpOffice\PhpWord\HashTable; +use PhpOffice\PhpWord\Writer\ODText\Content; +use PhpOffice\PhpWord\Writer\ODText\Manifest; +use PhpOffice\PhpWord\Writer\ODText\Meta; +use PhpOffice\PhpWord\Writer\ODText\Mimetype; +use PhpOffice\PhpWord\Writer\ODText\Styles; + +class ODText implements IWriter { /** * Private PHPWord @@ -40,14 +46,14 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter /** * Private writer parts * - * @var PHPWord_Writer_ODText_WriterPart[] + * @var PhpOffice\PhpWord\Writer\ODText\WriterPart[] */ private $_writerParts; /** * Private unique PHPWord_Worksheet_BaseDrawing HashTable * - * @var PHPWord_HashTable + * @var PhpOffice\PhpWord\HashTable */ private $_drawingHashTable; @@ -66,9 +72,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter private $_diskCachingDirectory; /** - * Create a new PHPWord_Writer_ODText - * - * @param PHPWord $pPHPWord + * @param PHPWord $pPHPWord */ public function __construct(PHPWord $pPHPWord = null) { @@ -79,11 +83,11 @@ public function __construct(PHPWord $pPHPWord = null) $this->_diskCachingDirectory = './'; // Initialise writer parts - $this->_writerParts['content'] = new PHPWord_Writer_ODText_Content(); - $this->_writerParts['manifest'] = new PHPWord_Writer_ODText_Manifest(); - $this->_writerParts['meta'] = new PHPWord_Writer_ODText_Meta(); - $this->_writerParts['mimetype'] = new PHPWord_Writer_ODText_Mimetype(); - $this->_writerParts['styles'] = new PHPWord_Writer_ODText_Styles(); + $this->_writerParts['content'] = new Content(); + $this->_writerParts['manifest'] = new Manifest(); + $this->_writerParts['meta'] = new Meta(); + $this->_writerParts['mimetype'] = new Mimetype(); + $this->_writerParts['styles'] = new Styles(); // Assign parent IWriter @@ -92,7 +96,7 @@ public function __construct(PHPWord $pPHPWord = null) } // Set HashTable variables - $this->_drawingHashTable = new PHPWord_HashTable(); + $this->_drawingHashTable = new HashTable(); } /** @@ -212,9 +216,9 @@ public function getPHPWord() /** * Get PHPWord object * - * @param PHPWord $pPHPWord PHPWord object - * @throws Exception - * @return PHPWord_Writer_ODText + * @param PHPWord $pPHPWord PHPWord object + * @throws Exception + * @return PhpOffice\PhpWord\Writer\ODText */ public function setPHPWord(PHPWord $pPHPWord = null) { @@ -225,7 +229,7 @@ public function setPHPWord(PHPWord $pPHPWord = null) /** * Get PHPWord_Worksheet_BaseDrawing HashTable * - * @return PHPWord_HashTable + * @return PhpOffice\PhpWord\HashTable */ public function getDrawingHashTable() { @@ -235,8 +239,8 @@ public function getDrawingHashTable() /** * Get writer part * - * @param string $pPartName Writer part name - * @return PHPWord_Writer_ODText_WriterPart + * @param string $pPartName Writer part name + * @return PhpOffice\PhpWord\Writer\ODText\WriterPart */ public function getWriterPart($pPartName = '') { @@ -260,10 +264,10 @@ public function getUseDiskCaching() /** * Set use disk caching where possible? * - * @param boolean $pValue - * @param string $pDirectory Disk caching directory - * @throws Exception Exception when directory does not exist - * @return PHPWord_Writer_ODText + * @param boolean $pValue + * @param string $pDirectory Disk caching directory + * @throws Exception Exception when directory does not exist + * @return PhpOffice\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 0899990b16..5526d06c7f 100755 --- a/Classes/PHPWord/Writer/ODText/Content.php +++ b/Classes/PHPWord/Writer/ODText/Content.php @@ -25,68 +25,85 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_ODText_Manifest - */ -class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart +namespace PhpOffice\PhpWord\Writer\ODText; + +use PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Section\Image; +use PhpOffice\PhpWord\Section\Link; +use PhpOffice\PhpWord\Section\ListItem; +use PhpOffice\PhpWord\Section\MemoryImage; +use PhpOffice\PhpWord\Section\Object; +use PhpOffice\PhpWord\Section\PageBreak; +use PhpOffice\PhpWord\Section\Table; +use PhpOffice\PhpWord\Section\Text; +use PhpOffice\PhpWord\Section\TextBreak; +use PhpOffice\PhpWord\Section\TextRun; +use PhpOffice\PhpWord\Section\Title; +use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\TOC; + +class Content extends WriterPart { /** * Write content file to XML format * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception + * @param PHPWord $phpWord + * @return string XML Output + * @throws Exception */ - public function writeContent(PHPWord $pPHPWord = null) + public function writeContent(PHPWord $phpWord = null) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8'); + $xmlWriter->startDocument('1.0', 'UTF-8'); // office:document-content - $objWriter->startElement('office:document-content'); - $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); - $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); - $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); - $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); - $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); - $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); - $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); - $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); - $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); - $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); - $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); - $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); - $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); - $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); - $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); - $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); - $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); - $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); - $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); - $objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms'); - $objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); - $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); - $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); - $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); - $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); - $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); - $objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0'); - $objWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0'); - $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); - $objWriter->writeAttribute('office:version', '1.2'); + $xmlWriter->startElement('office:document-content'); + $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); + $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); + $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); + $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); + $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); + $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); + $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); + $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); + $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); + $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); + $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); + $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); + $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); + $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); + $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); + $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); + $xmlWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms'); + $xmlWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); + $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); + $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); + $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); + $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); + $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); + $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); + $xmlWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0'); + $xmlWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0'); + $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); + $xmlWriter->writeAttribute('office:version', '1.2'); // We firstly search all fonts used - $_sections = $pPHPWord->getSections(); + $_sections = $phpWord->getSections(); $countSections = count($_sections); if ($countSections > 0) { $pSection = 0; @@ -98,23 +115,23 @@ public function writeContent(PHPWord $pPHPWord = null) $_elements = $section->getElements(); foreach ($_elements as $element) { - if ($element instanceof PHPWord_Section_Text) { + if ($element instanceof Text) { $fStyle = $element->getFontStyle(); $pStyle = $element->getParagraphStyle(); - if ($fStyle instanceof PHPWord_Style_Font) { + if ($fStyle instanceof Font) { $numFStyles++; $arrStyle = array( 'color' => $fStyle->getColor(), 'name' => $fStyle->getName() ); - $pPHPWord->addFontStyle('T' . $numFStyles, $arrStyle); + $phpWord->addFontStyle('T' . $numFStyles, $arrStyle); $element->setFontStyle('T' . $numFStyles); - } elseif ($pStyle instanceof PHPWord_Style_Paragraph) { + } elseif ($pStyle instanceof Paragraph) { $numPStyles++; - $pPHPWord->addParagraphStyle('P' . $numPStyles, array()); + $phpWord->addParagraphStyle('P' . $numPStyles, array()); $element->setParagraphStyle('P' . $numPStyles); } } @@ -123,120 +140,120 @@ public function writeContent(PHPWord $pPHPWord = null) } // office:font-face-decls - $objWriter->startElement('office:font-face-decls'); + $xmlWriter->startElement('office:font-face-decls'); $arrFonts = array(); - $styles = PHPWord_Style::getStyles(); + $styles = Style::getStyles(); $numFonts = 0; if (count($styles) > 0) { foreach ($styles as $styleName => $style) { - // PHPWord_Style_Font - if ($style instanceof PHPWord_Style_Font) { + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { $numFonts++; $name = $style->getName(); if (!in_array($name, $arrFonts)) { $arrFonts[] = $name; // style:font-face - $objWriter->startElement('style:font-face'); - $objWriter->writeAttribute('style:name', $name); - $objWriter->writeAttribute('svg:font-family', $name); - $objWriter->endElement(); + $xmlWriter->startElement('style:font-face'); + $xmlWriter->writeAttribute('style:name', $name); + $xmlWriter->writeAttribute('svg:font-family', $name); + $xmlWriter->endElement(); } } } if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) { - $objWriter->startElement('style:font-face'); - $objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); - $objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); - $objWriter->endElement(); + $xmlWriter->startElement('style:font-face'); + $xmlWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); + $xmlWriter->endElement(); } } - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->startElement('office:automatic-styles'); - $styles = PHPWord_Style::getStyles(); + $xmlWriter->startElement('office:automatic-styles'); + $styles = Style::getStyles(); $numPStyles = 0; if (count($styles) > 0) { foreach ($styles as $styleName => $style) { if (preg_match('#^T[0-9]+$#', $styleName) != 0 || preg_match('#^P[0-9]+$#', $styleName) != 0 ) { - // PHPWord_Style_Font - if ($style instanceof PHPWord_Style_Font) { - $objWriter->startElement('style:style'); - $objWriter->writeAttribute('style:name', $styleName); - $objWriter->writeAttribute('style:family', 'text'); + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $styleName); + $xmlWriter->writeAttribute('style:family', 'text'); // style:text-properties - $objWriter->startElement('style:text-properties'); - $objWriter->writeAttribute('fo:color', '#' . $style->getColor()); - $objWriter->writeAttribute('style:font-name', $style->getName()); - $objWriter->writeAttribute('style:font-name-complex', $style->getName()); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('style:text-properties'); + $xmlWriter->writeAttribute('fo:color', '#' . $style->getColor()); + $xmlWriter->writeAttribute('style:font-name', $style->getName()); + $xmlWriter->writeAttribute('style:font-name-complex', $style->getName()); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - if ($style instanceof PHPWord_Style_Paragraph) { + if ($style instanceof Paragraph) { $numPStyles++; // style:style - $objWriter->startElement('style:style'); - $objWriter->writeAttribute('style:name', $styleName); - $objWriter->writeAttribute('style:family', 'paragraph'); - $objWriter->writeAttribute('style:parent-style-name', 'Standard'); - $objWriter->writeAttribute('style:master-page-name', 'Standard'); + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $styleName); + $xmlWriter->writeAttribute('style:family', 'paragraph'); + $xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); + $xmlWriter->writeAttribute('style:master-page-name', 'Standard'); // style:paragraph-properties - $objWriter->startElement('style:paragraph-properties'); - $objWriter->writeAttribute('style:page-number', 'auto'); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('style:paragraph-properties'); + $xmlWriter->writeAttribute('style:page-number', 'auto'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } } if ($numPStyles == 0) { // style:style - $objWriter->startElement('style:style'); - $objWriter->writeAttribute('style:name', 'P1'); - $objWriter->writeAttribute('style:family', 'paragraph'); - $objWriter->writeAttribute('style:parent-style-name', 'Standard'); - $objWriter->writeAttribute('style:master-page-name', 'Standard'); + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', 'P1'); + $xmlWriter->writeAttribute('style:family', 'paragraph'); + $xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); + $xmlWriter->writeAttribute('style:master-page-name', 'Standard'); // style:paragraph-properties - $objWriter->startElement('style:paragraph-properties'); - $objWriter->writeAttribute('style:page-number', 'auto'); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('style:paragraph-properties'); + $xmlWriter->writeAttribute('style:page-number', 'auto'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } - $objWriter->endElement(); + $xmlWriter->endElement(); // office:body - $objWriter->startElement('office:body'); + $xmlWriter->startElement('office:body'); // office:text - $objWriter->startElement('office:text'); + $xmlWriter->startElement('office:text'); // text:sequence-decls - $objWriter->startElement('text:sequence-decls'); + $xmlWriter->startElement('text:sequence-decls'); // text:sequence-decl - $objWriter->startElement('text:sequence-decl'); - $objWriter->writeAttribute('text:display-outline-level', 0); - $objWriter->writeAttribute('text:name', 'Illustration'); - $objWriter->endElement(); + $xmlWriter->startElement('text:sequence-decl'); + $xmlWriter->writeAttribute('text:display-outline-level', 0); + $xmlWriter->writeAttribute('text:name', 'Illustration'); + $xmlWriter->endElement(); // text:sequence-decl - $objWriter->startElement('text:sequence-decl'); - $objWriter->writeAttribute('text:display-outline-level', 0); - $objWriter->writeAttribute('text:name', 'Table'); - $objWriter->endElement(); + $xmlWriter->startElement('text:sequence-decl'); + $xmlWriter->writeAttribute('text:display-outline-level', 0); + $xmlWriter->writeAttribute('text:name', 'Table'); + $xmlWriter->endElement(); // text:sequence-decl - $objWriter->startElement('text:sequence-decl'); - $objWriter->writeAttribute('text:display-outline-level', 0); - $objWriter->writeAttribute('text:name', 'Text'); - $objWriter->endElement(); + $xmlWriter->startElement('text:sequence-decl'); + $xmlWriter->writeAttribute('text:display-outline-level', 0); + $xmlWriter->writeAttribute('text:name', 'Text'); + $xmlWriter->endElement(); // text:sequence-decl - $objWriter->startElement('text:sequence-decl'); - $objWriter->writeAttribute('text:display-outline-level', 0); - $objWriter->writeAttribute('text:name', 'Drawing'); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('text:sequence-decl'); + $xmlWriter->writeAttribute('text:display-outline-level', 0); + $xmlWriter->writeAttribute('text:name', 'Drawing'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $_sections = $pPHPWord->getSections(); + $_sections = $phpWord->getSections(); $countSections = count($_sections); $pSection = 0; @@ -247,66 +264,63 @@ public function writeContent(PHPWord $pPHPWord = null) $_elements = $section->getElements(); foreach ($_elements as $element) { - if ($element instanceof PHPWord_Section_Text) { - $this->_writeText($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_TextRun) { - $this->_writeTextRun($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_TextBreak) { - $this->_writeTextBreak($objWriter); - } elseif ($element instanceof PHPWord_Section_Link) { - $this->writeUnsupportedElement($objWriter, 'Link'); - } elseif ($element instanceof PHPWord_Section_Title) { - $this->writeUnsupportedElement($objWriter, 'Title'); - } elseif ($element instanceof PHPWord_Section_PageBreak) { - $this->writeUnsupportedElement($objWriter, 'Page Break'); - } elseif ($element instanceof PHPWord_Section_Table) { - $this->writeUnsupportedElement($objWriter, 'Table'); - } elseif ($element instanceof PHPWord_Section_ListItem) { - $this->writeUnsupportedElement($objWriter, 'List Item'); - } elseif ($element instanceof PHPWord_Section_Image || - $element instanceof PHPWord_Section_MemoryImage) { - $this->writeUnsupportedElement($objWriter, 'Image'); - } elseif ($element instanceof PHPWord_Section_Object) { - $this->writeUnsupportedElement($objWriter, 'Object'); - } elseif ($element instanceof PHPWord_TOC) { - $this->writeUnsupportedElement($objWriter, 'TOC'); + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter); + } elseif ($element instanceof Link) { + $this->writeUnsupportedElement($xmlWriter, 'Link'); + } elseif ($element instanceof Title) { + $this->writeUnsupportedElement($xmlWriter, 'Title'); + } elseif ($element instanceof PageBreak) { + $this->writeUnsupportedElement($xmlWriter, 'Page Break'); + } elseif ($element instanceof Table) { + $this->writeUnsupportedElement($xmlWriter, 'Table'); + } elseif ($element instanceof ListItem) { + $this->writeUnsupportedElement($xmlWriter, 'List Item'); + } elseif ($element instanceof Image || + $element instanceof MemoryImage) { + $this->writeUnsupportedElement($xmlWriter, 'Image'); + } elseif ($element instanceof Object) { + $this->writeUnsupportedElement($xmlWriter, 'Object'); + } elseif ($element instanceof TOC) { + $this->writeUnsupportedElement($xmlWriter, 'TOC'); } else { - $this->writeUnsupportedElement($objWriter, 'Element'); + $this->writeUnsupportedElement($xmlWriter, 'Element'); } } if ($pSection == $countSections) { - $this->_writeEndSection($objWriter, $section); + $this->_writeEndSection($xmlWriter, $section); } else { - $this->_writeSection($objWriter, $section); + $this->_writeSection($xmlWriter, $section); } } } - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } /** * Write text * - * @param PHPWord_Shared_XMLWriter $objWriter - * @param PHPWord_Section_Text $text - * @param bool $withoutP + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Text $text + * @param bool $withoutP */ - protected function _writeText( - PHPWord_Shared_XMLWriter $objWriter = null, - PHPWord_Section_Text $text, - $withoutP = false - ) { + protected function _writeText(XMLWriter $xmlWriter = null, Text $text, $withoutP = false) + { $styleFont = $text->getFontStyle(); $styleParagraph = $text->getParagraphStyle(); // @todo Commented for TextRun. Should really checkout this value - // $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + // $SfIsObject = ($styleFont instanceof Font) ? true : false; $SfIsObject = false; if ($SfIsObject) { @@ -314,29 +328,29 @@ protected function _writeText( die('PHPWord : $SfIsObject wouldn\'t be an object'); } else { if (!$withoutP) { - $objWriter->startElement('text:p'); // text:p + $xmlWriter->startElement('text:p'); // text:p } if (empty($styleFont)) { if (empty($styleParagraph)) { - $objWriter->writeAttribute('text:style-name', 'P1'); + $xmlWriter->writeAttribute('text:style-name', 'P1'); } else { - $objWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); + $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); } - $objWriter->writeRaw($text->getText()); + $xmlWriter->writeRaw($text->getText()); } else { if (empty($styleParagraph)) { - $objWriter->writeAttribute('text:style-name', 'Standard'); + $xmlWriter->writeAttribute('text:style-name', 'Standard'); } else { - $objWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); + $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); } // text:span - $objWriter->startElement('text:span'); - $objWriter->writeAttribute('text:style-name', $styleFont); - $objWriter->writeRaw($text->getText()); - $objWriter->endElement(); + $xmlWriter->startElement('text:span'); + $xmlWriter->writeAttribute('text:style-name', $styleFont); + $xmlWriter->writeRaw($text->getText()); + $xmlWriter->endElement(); } if (!$withoutP) { - $objWriter->endElement(); // text:p + $xmlWriter->endElement(); // text:p } } } @@ -344,40 +358,40 @@ protected function _writeText( /** * Write TextRun section * - * @param PHPWord_Shared_XMLWriter $objWriter - * @param PHPWord_Section_TextRun $textrun - * @todo Enable all other section types + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\TextRun $textrun + * @todo Enable all other section types */ - protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) + protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) { $elements = $textrun->getElements(); - $objWriter->startElement('text:p'); + $xmlWriter->startElement('text:p'); if (count($elements) > 0) { foreach ($elements as $element) { - if ($element instanceof PHPWord_Section_Text) { - $this->_writeText($objWriter, $element, true); + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element, true); } } } - $objWriter->endElement(); + $xmlWriter->endElement(); } /** * Write TextBreak */ - protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) + protected function _writeTextBreak(XMLWriter $xmlWriter = null) { - $objWriter->startElement('text:p'); - $objWriter->writeAttribute('text:style-name', 'Standard'); - $objWriter->endElement(); + $xmlWriter->startElement('text:p'); + $xmlWriter->writeAttribute('text:style-name', 'Standard'); + $xmlWriter->endElement(); } // @codeCoverageIgnoreStart - private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null) + private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null) { } - private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null) + private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null) { } // @codeCoverageIgnoreEnd @@ -385,13 +399,13 @@ private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo /** * Write unsupported element * - * @param PHPWord_Shared_XMLWriter $objWriter - * @param string $element + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $element */ - private function writeUnsupportedElement($objWriter, $element) + private function writeUnsupportedElement($xmlWriter, $element) { - $objWriter->startElement('text:p'); - $objWriter->writeRaw("{$element}"); - $objWriter->endElement(); + $xmlWriter->startElement('text:p'); + $xmlWriter->writeRaw($element); + $xmlWriter->endElement(); } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Writer/ODText/Manifest.php b/Classes/PHPWord/Writer/ODText/Manifest.php index 89e802dc61..40401931fe 100755 --- a/Classes/PHPWord/Writer/ODText/Manifest.php +++ b/Classes/PHPWord/Writer/ODText/Manifest.php @@ -25,10 +25,12 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_ODText_Manifest - */ -class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart +namespace PhpOffice\PhpWord\Writer\ODText; + +use PhpOffice\PhpWord\Shared\File; +use PhpOffice\PhpWord\Shared\XMLWriter; + +class Manifest extends WriterPart { /** * Write Manifest file to XML format @@ -40,42 +42,42 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart public function writeManifest(PHPWord $pPHPWord = null) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8'); + $xmlWriter->startDocument('1.0', 'UTF-8'); // manifest:manifest - $objWriter->startElement('manifest:manifest'); - $objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'); - $objWriter->writeAttribute('manifest:version', '1.2'); + $xmlWriter->startElement('manifest:manifest'); + $xmlWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'); + $xmlWriter->writeAttribute('manifest:version', '1.2'); // manifest:file-entry - $objWriter->startElement('manifest:file-entry'); - $objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text'); - $objWriter->writeAttribute('manifest:version', '1.2'); - $objWriter->writeAttribute('manifest:full-path', '/'); - $objWriter->endElement(); + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text'); + $xmlWriter->writeAttribute('manifest:version', '1.2'); + $xmlWriter->writeAttribute('manifest:full-path', '/'); + $xmlWriter->endElement(); // manifest:file-entry - $objWriter->startElement('manifest:file-entry'); - $objWriter->writeAttribute('manifest:media-type', 'text/xml'); - $objWriter->writeAttribute('manifest:full-path', 'content.xml'); - $objWriter->endElement(); + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); + $xmlWriter->writeAttribute('manifest:full-path', 'content.xml'); + $xmlWriter->endElement(); // manifest:file-entry - $objWriter->startElement('manifest:file-entry'); - $objWriter->writeAttribute('manifest:media-type', 'text/xml'); - $objWriter->writeAttribute('manifest:full-path', 'meta.xml'); - $objWriter->endElement(); + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); + $xmlWriter->writeAttribute('manifest:full-path', 'meta.xml'); + $xmlWriter->endElement(); // manifest:file-entry - $objWriter->startElement('manifest:file-entry'); - $objWriter->writeAttribute('manifest:media-type', 'text/xml'); - $objWriter->writeAttribute('manifest:full-path', 'styles.xml'); - $objWriter->endElement(); + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); + $xmlWriter->writeAttribute('manifest:full-path', 'styles.xml'); + $xmlWriter->endElement(); // Not used yet. Legacy from PHPExcel // @codeCoverageIgnoreStart @@ -84,10 +86,10 @@ public function writeManifest(PHPWord $pPHPWord = null) $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension()); $mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath()); - $objWriter->startElement('manifest:file-entry'); - $objWriter->writeAttribute('manifest:media-type', $mimeType); - $objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); - $objWriter->endElement(); + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', $mimeType); + $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); + $xmlWriter->endElement(); } elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) { $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType()); $extension = explode('/', $extension); @@ -95,18 +97,18 @@ public function writeManifest(PHPWord $pPHPWord = null) $mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType(); - $objWriter->startElement('manifest:file-entry'); - $objWriter->writeAttribute('manifest:media-type', $mimeType); - $objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); - $objWriter->endElement(); + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', $mimeType); + $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); + $xmlWriter->endElement(); } } // @codeCoverageIgnoreEnd - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } @@ -119,7 +121,7 @@ public function writeManifest(PHPWord $pPHPWord = null) */ private function _getImageMimeType($pFile = '') { - if (PHPWord_Shared_File::file_exists($pFile)) { + if (File::file_exists($pFile)) { $image = getimagesize($pFile); return image_type_to_mime_type($image[2]); } else { diff --git a/Classes/PHPWord/Writer/ODText/Meta.php b/Classes/PHPWord/Writer/ODText/Meta.php index 5397861496..3d04594926 100755 --- a/Classes/PHPWord/Writer/ODText/Meta.php +++ b/Classes/PHPWord/Writer/ODText/Meta.php @@ -25,10 +25,11 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_ODText_Meta - */ -class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart +namespace PhpOffice\PhpWord\Writer\ODText; + +use PhpOffice\PhpWord\Shared\XMLWriter; + +class Meta extends WriterPart { /** * Write Meta file to XML format @@ -40,55 +41,55 @@ class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart public function writeMeta(PHPWord $pPHPWord = null) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8'); + $xmlWriter->startDocument('1.0', 'UTF-8'); // office:document-meta - $objWriter->startElement('office:document-meta'); - $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); - $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); - $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); - $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); - $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); - $objWriter->writeAttribute('office:version', '1.2'); + $xmlWriter->startElement('office:document-meta'); + $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); + $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); + $xmlWriter->writeAttribute('office:version', '1.2'); // office:meta - $objWriter->startElement('office:meta'); + $xmlWriter->startElement('office:meta'); // dc:creator - $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy()); + $xmlWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy()); // dc:date - $objWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getModified())); + $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getModified())); // dc:description - $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); + $xmlWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); // dc:subject - $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); + $xmlWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); // dc:title - $objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle()); + $xmlWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle()); // meta:creation-date - $objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getCreated())); + $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getCreated())); // meta:initial-creator - $objWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator()); + $xmlWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator()); // meta:keyword - $objWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords()); + $xmlWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords()); // @todo : Where these properties are written ? // $pPHPWord->getProperties()->getCategory() // $pPHPWord->getProperties()->getCompany() - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } } diff --git a/Classes/PHPWord/Writer/ODText/Mimetype.php b/Classes/PHPWord/Writer/ODText/Mimetype.php index af3b33485b..2c0f9a7612 100755 --- a/Classes/PHPWord/Writer/ODText/Mimetype.php +++ b/Classes/PHPWord/Writer/ODText/Mimetype.php @@ -25,10 +25,9 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_ODText_Mimetype - */ -class PHPWord_Writer_ODText_Mimetype extends PHPWord_Writer_ODText_WriterPart +namespace PhpOffice\PhpWord\Writer\ODText; + +class Mimetype extends WriterPart { /** * Write Mimetype to Text format diff --git a/Classes/PHPWord/Writer/ODText/Styles.php b/Classes/PHPWord/Writer/ODText/Styles.php index b5f87332d6..83ec054f54 100755 --- a/Classes/PHPWord/Writer/ODText/Styles.php +++ b/Classes/PHPWord/Writer/ODText/Styles.php @@ -25,10 +25,15 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_ODText_Styles - */ -class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart +namespace PhpOffice\PhpWord\Writer\ODText; + +use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\Style\TableFull; + +class Styles extends WriterPart { /** * Write Styles file to XML format @@ -40,228 +45,228 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart public function writeStyles(PHPWord $pPHPWord = null) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8'); + $xmlWriter->startDocument('1.0', 'UTF-8'); // Styles:Styles - $objWriter->startElement('office:document-styles'); - $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); - $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); - $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); - $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); - $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); - $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); - $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); - $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); - $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); - $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); - $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); - $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); - $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); - $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); - $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); - $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); - $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); - $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); - $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); - $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); - $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); - $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); - $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); - $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); - $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); - $objWriter->writeAttribute('office:version', '1.2'); + $xmlWriter->startElement('office:document-styles'); + $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); + $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); + $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); + $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); + $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); + $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); + $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); + $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); + $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); + $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); + $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); + $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); + $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); + $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); + $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); + $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); + $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); + $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); + $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); + $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); + $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); + $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); + $xmlWriter->writeAttribute('office:version', '1.2'); // office:font-face-decls - $objWriter->startElement('office:font-face-decls'); + $xmlWriter->startElement('office:font-face-decls'); $arrFonts = array(); - $styles = PHPWord_Style::getStyles(); + $styles = Style::getStyles(); $numFonts = 0; if (count($styles) > 0) { foreach ($styles as $styleName => $style) { - // PHPWord_Style_Font - if ($style instanceof PHPWord_Style_Font) { + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { $numFonts++; $name = $style->getName(); if (!in_array($name, $arrFonts)) { $arrFonts[] = $name; // style:font-face - $objWriter->startElement('style:font-face'); - $objWriter->writeAttribute('style:name', $name); - $objWriter->writeAttribute('svg:font-family', $name); - $objWriter->endElement(); + $xmlWriter->startElement('style:font-face'); + $xmlWriter->writeAttribute('style:name', $name); + $xmlWriter->writeAttribute('svg:font-family', $name); + $xmlWriter->endElement(); } } } } if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) { - $objWriter->startElement('style:font-face'); - $objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); - $objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); - $objWriter->endElement(); + $xmlWriter->startElement('style:font-face'); + $xmlWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); // office:styles - $objWriter->startElement('office:styles'); + $xmlWriter->startElement('office:styles'); // style:default-style - $objWriter->startElement('style:default-style'); - $objWriter->writeAttribute('style:family', 'paragraph'); + $xmlWriter->startElement('style:default-style'); + $xmlWriter->writeAttribute('style:family', 'paragraph'); // style:paragraph-properties - $objWriter->startElement('style:paragraph-properties'); - $objWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit'); - $objWriter->writeAttribute('style:text-autospace', 'ideograph-alpha'); - $objWriter->writeAttribute('style:punctuation-wrap', 'hanging'); - $objWriter->writeAttribute('style:line-break', 'strict'); - $objWriter->writeAttribute('style:tab-stop-distance', '1.249cm'); - $objWriter->writeAttribute('style:writing-mode', 'page'); - $objWriter->endElement(); + $xmlWriter->startElement('style:paragraph-properties'); + $xmlWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit'); + $xmlWriter->writeAttribute('style:text-autospace', 'ideograph-alpha'); + $xmlWriter->writeAttribute('style:punctuation-wrap', 'hanging'); + $xmlWriter->writeAttribute('style:line-break', 'strict'); + $xmlWriter->writeAttribute('style:tab-stop-distance', '1.249cm'); + $xmlWriter->writeAttribute('style:writing-mode', 'page'); + $xmlWriter->endElement(); // style:text-properties - $objWriter->startElement('style:text-properties'); - $objWriter->writeAttribute('style:use-window-font-color', 'true'); - $objWriter->writeAttribute('style:font-name', PHPWord::DEFAULT_FONT_NAME); - $objWriter->writeAttribute('fo:font-size', PHPWord::DEFAULT_FONT_SIZE . 'pt'); - $objWriter->writeAttribute('fo:language', 'fr'); - $objWriter->writeAttribute('fo:country', 'FR'); - $objWriter->writeAttribute('style:letter-kerning', 'true'); - $objWriter->writeAttribute('style:font-name-asian', PHPWord::DEFAULT_FONT_NAME . '2'); - $objWriter->writeAttribute('style:font-size-asian', PHPWord::DEFAULT_FONT_SIZE . 'pt'); - $objWriter->writeAttribute('style:language-asian', 'zh'); - $objWriter->writeAttribute('style:country-asian', 'CN'); - $objWriter->writeAttribute('style:font-name-complex', PHPWord::DEFAULT_FONT_NAME . '2'); - $objWriter->writeAttribute('style:font-size-complex', PHPWord::DEFAULT_FONT_SIZE . 'pt'); - $objWriter->writeAttribute('style:language-complex', 'hi'); - $objWriter->writeAttribute('style:country-complex', 'IN'); - $objWriter->writeAttribute('fo:hyphenate', 'false'); - $objWriter->writeAttribute('fo:hyphenation-remain-char-count', '2'); - $objWriter->writeAttribute('fo:hyphenation-push-char-count', '2'); - $objWriter->endElement(); + $xmlWriter->startElement('style:text-properties'); + $xmlWriter->writeAttribute('style:use-window-font-color', 'true'); + $xmlWriter->writeAttribute('style:font-name', PHPWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('fo:font-size', PHPWord::DEFAULT_FONT_SIZE . 'pt'); + $xmlWriter->writeAttribute('fo:language', 'fr'); + $xmlWriter->writeAttribute('fo:country', 'FR'); + $xmlWriter->writeAttribute('style:letter-kerning', 'true'); + $xmlWriter->writeAttribute('style:font-name-asian', PHPWord::DEFAULT_FONT_NAME . '2'); + $xmlWriter->writeAttribute('style:font-size-asian', PHPWord::DEFAULT_FONT_SIZE . 'pt'); + $xmlWriter->writeAttribute('style:language-asian', 'zh'); + $xmlWriter->writeAttribute('style:country-asian', 'CN'); + $xmlWriter->writeAttribute('style:font-name-complex', PHPWord::DEFAULT_FONT_NAME . '2'); + $xmlWriter->writeAttribute('style:font-size-complex', PHPWord::DEFAULT_FONT_SIZE . 'pt'); + $xmlWriter->writeAttribute('style:language-complex', 'hi'); + $xmlWriter->writeAttribute('style:country-complex', 'IN'); + $xmlWriter->writeAttribute('fo:hyphenate', 'false'); + $xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2'); + $xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2'); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); // Write Style Definitions - $styles = PHPWord_Style::getStyles(); + $styles = Style::getStyles(); if (count($styles) > 0) { foreach ($styles as $styleName => $style) { if (preg_match('#^T[0-9]+$#', $styleName) == 0 && preg_match('#^P[0-9]+$#', $styleName) == 0 ) { - // PHPWord_Style_Font - if ($style instanceof PHPWord_Style_Font) { + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { // style:style - $objWriter->startElement('style:style'); - $objWriter->writeAttribute('style:name', $styleName); - $objWriter->writeAttribute('style:family', 'text'); + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $styleName); + $xmlWriter->writeAttribute('style:family', 'text'); // style:text-properties - $objWriter->startElement('style:text-properties'); - $objWriter->writeAttribute('fo:font-size', ($style->getSize()) . 'pt'); - $objWriter->writeAttribute('style:font-size-asian', ($style->getSize()) . 'pt'); - $objWriter->writeAttribute('style:font-size-complex', ($style->getSize()) . 'pt'); + $xmlWriter->startElement('style:text-properties'); + $xmlWriter->writeAttribute('fo:font-size', ($style->getSize()) . 'pt'); + $xmlWriter->writeAttribute('style:font-size-asian', ($style->getSize()) . 'pt'); + $xmlWriter->writeAttribute('style:font-size-complex', ($style->getSize()) . 'pt'); if ($style->getItalic()) { - $objWriter->writeAttribute('fo:font-style', 'italic'); - $objWriter->writeAttribute('style:font-style-asian', 'italic'); - $objWriter->writeAttribute('style:font-style-complex', 'italic'); + $xmlWriter->writeAttribute('fo:font-style', 'italic'); + $xmlWriter->writeAttribute('style:font-style-asian', 'italic'); + $xmlWriter->writeAttribute('style:font-style-complex', 'italic'); } if ($style->getBold()) { - $objWriter->writeAttribute('fo:font-weight', 'bold'); - $objWriter->writeAttribute('style:font-weight-asian', 'bold'); + $xmlWriter->writeAttribute('fo:font-weight', 'bold'); + $xmlWriter->writeAttribute('style:font-weight-asian', 'bold'); } - $objWriter->endElement(); - $objWriter->endElement(); - } elseif ($style instanceof PHPWord_Style_Paragraph) { - // PHPWord_Style_Paragraph + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } elseif ($style instanceof Paragraph) { + // PhpOffice\PhpWord\Style\Paragraph // style:style - $objWriter->startElement('style:style'); - $objWriter->writeAttribute('style:name', $styleName); - $objWriter->writeAttribute('style:family', 'paragraph'); + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $styleName); + $xmlWriter->writeAttribute('style:family', 'paragraph'); //style:paragraph-properties - $objWriter->startElement('style:paragraph-properties'); - $objWriter->writeAttribute('fo:margin-top', ((is_null($style->getSpaceBefore())) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)) . 'cm'); - $objWriter->writeAttribute('fo:margin-bottom', ((is_null($style->getSpaceAfter())) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)) . 'cm'); - $objWriter->writeAttribute('fo:text-align', $style->getAlign()); - $objWriter->endElement(); + $xmlWriter->startElement('style:paragraph-properties'); + $xmlWriter->writeAttribute('fo:margin-top', ((is_null($style->getSpaceBefore())) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)) . 'cm'); + $xmlWriter->writeAttribute('fo:margin-bottom', ((is_null($style->getSpaceAfter())) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)) . 'cm'); + $xmlWriter->writeAttribute('fo:text-align', $style->getAlign()); + $xmlWriter->endElement(); - $objWriter->endElement(); - } elseif ($style instanceof PHPWord_Style_TableFull) { - // PHPWord_Style_TableFull + $xmlWriter->endElement(); + } elseif ($style instanceof TableFull) { + // PhpOffice\PhpWord\Style\TableFull } } } } - $objWriter->endElement(); + $xmlWriter->endElement(); // office:automatic-styles - $objWriter->startElement('office:automatic-styles'); + $xmlWriter->startElement('office:automatic-styles'); // style:page-layout - $objWriter->startElement('style:page-layout'); - $objWriter->writeAttribute('style:name', 'Mpm1'); + $xmlWriter->startElement('style:page-layout'); + $xmlWriter->writeAttribute('style:name', 'Mpm1'); // style:page-layout-properties - $objWriter->startElement('style:page-layout-properties'); - $objWriter->writeAttribute('fo:page-width', "21.001cm"); - $objWriter->writeAttribute('fo:page-height', '29.7cm'); - $objWriter->writeAttribute('style:num-format', '1'); - $objWriter->writeAttribute('style:print-orientation', 'portrait'); - $objWriter->writeAttribute('fo:margin-top', '2.501cm'); - $objWriter->writeAttribute('fo:margin-bottom', '2cm'); - $objWriter->writeAttribute('fo:margin-left', '2.501cm'); - $objWriter->writeAttribute('fo:margin-right', '2.501cm'); - $objWriter->writeAttribute('style:writing-mode', 'lr-tb'); - $objWriter->writeAttribute('style:layout-grid-color', '#c0c0c0'); - $objWriter->writeAttribute('style:layout-grid-lines', '25199'); - $objWriter->writeAttribute('style:layout-grid-base-height', '0.423cm'); - $objWriter->writeAttribute('style:layout-grid-ruby-height', '0cm'); - $objWriter->writeAttribute('style:layout-grid-mode', 'none'); - $objWriter->writeAttribute('style:layout-grid-ruby-below', 'false'); - $objWriter->writeAttribute('style:layout-grid-print', 'false'); - $objWriter->writeAttribute('style:layout-grid-display', 'false'); - $objWriter->writeAttribute('style:layout-grid-base-width', '0.37cm'); - $objWriter->writeAttribute('style:layout-grid-snap-to', 'true'); - $objWriter->writeAttribute('style:footnote-max-height', '0cm'); + $xmlWriter->startElement('style:page-layout-properties'); + $xmlWriter->writeAttribute('fo:page-width', "21.001cm"); + $xmlWriter->writeAttribute('fo:page-height', '29.7cm'); + $xmlWriter->writeAttribute('style:num-format', '1'); + $xmlWriter->writeAttribute('style:print-orientation', 'portrait'); + $xmlWriter->writeAttribute('fo:margin-top', '2.501cm'); + $xmlWriter->writeAttribute('fo:margin-bottom', '2cm'); + $xmlWriter->writeAttribute('fo:margin-left', '2.501cm'); + $xmlWriter->writeAttribute('fo:margin-right', '2.501cm'); + $xmlWriter->writeAttribute('style:writing-mode', 'lr-tb'); + $xmlWriter->writeAttribute('style:layout-grid-color', '#c0c0c0'); + $xmlWriter->writeAttribute('style:layout-grid-lines', '25199'); + $xmlWriter->writeAttribute('style:layout-grid-base-height', '0.423cm'); + $xmlWriter->writeAttribute('style:layout-grid-ruby-height', '0cm'); + $xmlWriter->writeAttribute('style:layout-grid-mode', 'none'); + $xmlWriter->writeAttribute('style:layout-grid-ruby-below', 'false'); + $xmlWriter->writeAttribute('style:layout-grid-print', 'false'); + $xmlWriter->writeAttribute('style:layout-grid-display', 'false'); + $xmlWriter->writeAttribute('style:layout-grid-base-width', '0.37cm'); + $xmlWriter->writeAttribute('style:layout-grid-snap-to', 'true'); + $xmlWriter->writeAttribute('style:footnote-max-height', '0cm'); //style:footnote-sep - $objWriter->startElement('style:footnote-sep'); - $objWriter->writeAttribute('style:width', '0.018cm'); - $objWriter->writeAttribute('style:line-style', 'solid'); - $objWriter->writeAttribute('style:adjustment', 'left'); - $objWriter->writeAttribute('style:rel-width', '25%'); - $objWriter->writeAttribute('style:color', '#000000'); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('style:footnote-sep'); + $xmlWriter->writeAttribute('style:width', '0.018cm'); + $xmlWriter->writeAttribute('style:line-style', 'solid'); + $xmlWriter->writeAttribute('style:adjustment', 'left'); + $xmlWriter->writeAttribute('style:rel-width', '25%'); + $xmlWriter->writeAttribute('style:color', '#000000'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); // style:header-style - $objWriter->startElement('style:header-style'); - $objWriter->endElement(); + $xmlWriter->startElement('style:header-style'); + $xmlWriter->endElement(); // style:footer-style - $objWriter->startElement('style:footer-style'); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('style:footer-style'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); // office:master-styles - $objWriter->startElement('office:master-styles'); + $xmlWriter->startElement('office:master-styles'); // style:master-page - $objWriter->startElement('style:master-page'); - $objWriter->writeAttribute('style:name', 'Standard'); - $objWriter->writeAttribute('style:page-layout-name', 'Mpm1'); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('style:master-page'); + $xmlWriter->writeAttribute('style:name', 'Standard'); + $xmlWriter->writeAttribute('style:page-layout-name', 'Mpm1'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } } diff --git a/Classes/PHPWord/Writer/ODText/WriterPart.php b/Classes/PHPWord/Writer/ODText/WriterPart.php index c65269a2c5..ccaecfa397 100755 --- a/Classes/PHPWord/Writer/ODText/WriterPart.php +++ b/Classes/PHPWord/Writer/ODText/WriterPart.php @@ -25,25 +25,26 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_ODText_WriterPart - */ -abstract class PHPWord_Writer_ODText_WriterPart +namespace PhpOffice\PhpWord\Writer\ODText; + +use PhpOffice\PhpWord\Writer\IWriter; + +abstract class WriterPart { /** * Parent IWriter object * - * @var PHPWord_Writer_IWriter + * @var PhpOffice\PhpWord\Writer\IWriter */ private $_parentWriter; /** * Set parent IWriter object * - * @param PHPWord_Writer_IWriter $pWriter + * @param PhpOffice\PhpWord\Writer\IWriter $pWriter * @throws Exception */ - public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) + public function setParentWriter(IWriter $pWriter = null) { $this->_parentWriter = $pWriter; } @@ -51,7 +52,7 @@ public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) /** * Get parent IWriter object * - * @return PHPWord_Writer_IWriter + * @return PhpOffice\PhpWord\Writer\IWriter * @throws Exception */ public function getParentWriter() @@ -59,7 +60,7 @@ public function getParentWriter() if (!is_null($this->_parentWriter)) { return $this->_parentWriter; } else { - throw new Exception("No parent PHPWord_Writer_IWriter assigned."); + throw new Exception("No parent IWriter assigned."); } } } From 51ced7db8e0d4bea4284af2c30597e3f349ed800 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 18 Mar 2014 17:26:03 +0400 Subject: [PATCH 03/15] https://github.com/PHPOffice/PHPWord/issues/58 Part III. --- Classes/PHPWord/Style.php | 4 +- Classes/PHPWord/Writer/ODText.php | 12 +- Classes/PHPWord/Writer/ODText/Manifest.php | 8 +- Classes/PHPWord/Writer/ODText/Meta.php | 28 +- Classes/PHPWord/Writer/ODText/Mimetype.php | 8 +- Classes/PHPWord/Writer/ODText/Styles.php | 8 +- Classes/PHPWord/Writer/RTF.php | 127 +-- Classes/PHPWord/Writer/Word2007.php | 58 +- Classes/PHPWord/Writer/Word2007/Base.php | 925 +++++++++--------- .../PHPWord/Writer/Word2007/ContentTypes.php | 101 +- Classes/PHPWord/Writer/Word2007/DocProps.php | 150 +-- Classes/PHPWord/Writer/Word2007/Document.php | 546 ++++++----- .../PHPWord/Writer/Word2007/DocumentRels.php | 72 +- Classes/PHPWord/Writer/Word2007/Footer.php | 77 +- Classes/PHPWord/Writer/Word2007/Footnotes.php | 68 +- .../PHPWord/Writer/Word2007/FootnotesRels.php | 37 +- Classes/PHPWord/Writer/Word2007/Header.php | 77 +- Classes/PHPWord/Writer/Word2007/Rels.php | 51 +- Classes/PHPWord/Writer/Word2007/Styles.php | 374 +++---- .../PHPWord/Writer/Word2007/WriterPart.php | 13 +- README.md | 12 +- Tests/PHPWord/AutoloaderTest.php | 2 +- Tests/PHPWord/DocumentPropertiesTest.php | 98 +- Tests/PHPWord/Exceptions/ExceptionTest.php | 4 +- .../Exceptions/InvalidImageExceptionTest.php | 4 +- .../Exceptions/InvalidStyleExceptionTest.php | 4 +- .../UnsupportedImageTypeExceptionTest.php | 4 +- Tests/PHPWord/IOFactoryTest.php | 34 +- Tests/PHPWord/MediaTest.php | 28 +- Tests/PHPWord/Reader/Word2007Test.php | 18 +- .../Section/Footer/PreserveTextTest.php | 19 +- Tests/PHPWord/Section/FooterTest.php | 46 +- Tests/PHPWord/Section/FootnoteTest.php | 29 +- Tests/PHPWord/Section/HeaderTest.php | 66 +- Tests/PHPWord/Section/ImageTest.php | 54 +- Tests/PHPWord/Section/LinkTest.php | 24 +- Tests/PHPWord/Section/ListItemTest.php | 22 +- Tests/PHPWord/Section/MemoryImageTest.php | 26 +- Tests/PHPWord/Section/ObjectTest.php | 26 +- Tests/PHPWord/Section/PageBreakTest.php | 8 +- Tests/PHPWord/Section/SettingsTest.php | 32 +- Tests/PHPWord/Section/Table/CellTest.php | 78 +- Tests/PHPWord/Section/Table/RowTest.php | 18 +- Tests/PHPWord/Section/TableTest.php | 24 +- Tests/PHPWord/Section/TextBreakTest.php | 28 +- Tests/PHPWord/Section/TextRunTest.php | 42 +- Tests/PHPWord/Section/TextTest.php | 22 +- Tests/PHPWord/Section/TitleTest.php | 16 +- Tests/PHPWord/SectionTest.php | 78 +- Tests/PHPWord/SettingsTest.php | 22 +- 50 files changed, 1835 insertions(+), 1797 deletions(-) diff --git a/Classes/PHPWord/Style.php b/Classes/PHPWord/Style.php index fdd2986239..a1f4535800 100755 --- a/Classes/PHPWord/Style.php +++ b/Classes/PHPWord/Style.php @@ -99,10 +99,10 @@ public static function addLinkStyle($styleName, $styles) * @param string $styleName * @param array $styles */ - public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null) + public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null) { if (!array_key_exists($styleName, self::$_styleElements)) { - $style = new TableFull($styleTable, $styleFirstRow, $styleLastRow); + $style = new TableFull($styleTable, $styleFirstRow); self::$_styleElements[$styleName] = $style; } diff --git a/Classes/PHPWord/Writer/ODText.php b/Classes/PHPWord/Writer/ODText.php index 10c47fb893..126446dbb7 100755 --- a/Classes/PHPWord/Writer/ODText.php +++ b/Classes/PHPWord/Writer/ODText.php @@ -72,12 +72,12 @@ class ODText implements IWriter private $_diskCachingDirectory; /** - * @param PHPWord $pPHPWord + * @param PHPWord $phpWord */ - public function __construct(PHPWord $pPHPWord = null) + public function __construct(PHPWord $phpWord = null) { // Assign PHPWord - $this->setPHPWord($pPHPWord); + $this->setPHPWord($phpWord); // Set up disk caching location $this->_diskCachingDirectory = './'; @@ -216,13 +216,13 @@ public function getPHPWord() /** * Get PHPWord object * - * @param PHPWord $pPHPWord PHPWord object + * @param PHPWord $phpWord PHPWord object * @throws Exception * @return PhpOffice\PhpWord\Writer\ODText */ - public function setPHPWord(PHPWord $pPHPWord = null) + public function setPHPWord(PHPWord $phpWord = null) { - $this->_document = $pPHPWord; + $this->_document = $phpWord; return $this; } diff --git a/Classes/PHPWord/Writer/ODText/Manifest.php b/Classes/PHPWord/Writer/ODText/Manifest.php index 40401931fe..b39662f0f8 100755 --- a/Classes/PHPWord/Writer/ODText/Manifest.php +++ b/Classes/PHPWord/Writer/ODText/Manifest.php @@ -35,11 +35,11 @@ class Manifest extends WriterPart /** * Write Manifest file to XML format * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception + * @param PHPWord $phpWord + * @return string XML Output + * @throws Exception */ - public function writeManifest(PHPWord $pPHPWord = null) + public function writeManifest(PHPWord $phpWord = null) { // Create XML writer $xmlWriter = null; diff --git a/Classes/PHPWord/Writer/ODText/Meta.php b/Classes/PHPWord/Writer/ODText/Meta.php index 3d04594926..96c0a15598 100755 --- a/Classes/PHPWord/Writer/ODText/Meta.php +++ b/Classes/PHPWord/Writer/ODText/Meta.php @@ -34,11 +34,11 @@ class Meta extends WriterPart /** * Write Meta file to XML format * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception + * @param PHPWord $phpWord + * @return string XML Output + * @throws Exception */ - public function writeMeta(PHPWord $pPHPWord = null) + public function writeMeta(PHPWord $phpWord = null) { // Create XML writer $xmlWriter = null; @@ -65,25 +65,25 @@ public function writeMeta(PHPWord $pPHPWord = null) $xmlWriter->startElement('office:meta'); // dc:creator - $xmlWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy()); + $xmlWriter->writeElement('dc:creator', $phpWord->getProperties()->getLastModifiedBy()); // dc:date - $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getModified())); + $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getProperties()->getModified())); // dc:description - $xmlWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); + $xmlWriter->writeElement('dc:description', $phpWord->getProperties()->getDescription()); // dc:subject - $xmlWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); + $xmlWriter->writeElement('dc:subject', $phpWord->getProperties()->getSubject()); // dc:title - $xmlWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle()); + $xmlWriter->writeElement('dc:title', $phpWord->getProperties()->getTitle()); // meta:creation-date - $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getCreated())); + $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getProperties()->getCreated())); // meta:initial-creator - $xmlWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator()); + $xmlWriter->writeElement('meta:initial-creator', $phpWord->getProperties()->getCreator()); // meta:keyword - $xmlWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords()); + $xmlWriter->writeElement('meta:keyword', $phpWord->getProperties()->getKeywords()); // @todo : Where these properties are written ? - // $pPHPWord->getProperties()->getCategory() - // $pPHPWord->getProperties()->getCompany() + // $phpWord->getProperties()->getCategory() + // $phpWord->getProperties()->getCompany() $xmlWriter->endElement(); diff --git a/Classes/PHPWord/Writer/ODText/Mimetype.php b/Classes/PHPWord/Writer/ODText/Mimetype.php index 2c0f9a7612..7f3d0e7755 100755 --- a/Classes/PHPWord/Writer/ODText/Mimetype.php +++ b/Classes/PHPWord/Writer/ODText/Mimetype.php @@ -32,11 +32,11 @@ class Mimetype extends WriterPart /** * Write Mimetype to Text format * - * @param PHPWord $pPHPWord - * @return string Text Output - * @throws Exception + * @param PHPWord $phpWord + * @return string Text Output + * @throws Exception */ - public function writeMimetype(PHPWord $pPHPWord = null) + public function writeMimetype(PHPWord $phpWord = null) { return 'application/vnd.oasis.opendocument.text'; diff --git a/Classes/PHPWord/Writer/ODText/Styles.php b/Classes/PHPWord/Writer/ODText/Styles.php index 83ec054f54..6c2fdb007a 100755 --- a/Classes/PHPWord/Writer/ODText/Styles.php +++ b/Classes/PHPWord/Writer/ODText/Styles.php @@ -38,11 +38,11 @@ class Styles extends WriterPart /** * Write Styles file to XML format * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception + * @param PHPWord $phpWord + * @return string XML Output + * @throws Exception */ - public function writeStyles(PHPWord $pPHPWord = null) + public function writeStyles(PHPWord $phpWord = null) { // Create XML writer $xmlWriter = null; diff --git a/Classes/PHPWord/Writer/RTF.php b/Classes/PHPWord/Writer/RTF.php index a090fb175c..6b5e1fe770 100755 --- a/Classes/PHPWord/Writer/RTF.php +++ b/Classes/PHPWord/Writer/RTF.php @@ -25,10 +25,27 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_RTF - */ -class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter +namespace PhpOffice\PhpWord\Writer; + +use PhpOffice\PhpWord\HashTable; +use PhpOffice\PhpWord\Section\Image; +use PhpOffice\PhpWord\Section\Link; +use PhpOffice\PhpWord\Section\ListItem; +use PhpOffice\PhpWord\Section\MemoryImage; +use PhpOffice\PhpWord\Section\Object; +use PhpOffice\PhpWord\Section\PageBreak; +use PhpOffice\PhpWord\Section\Table; +use PhpOffice\PhpWord\Section\Text; +use PhpOffice\PhpWord\Section\TextBreak; +use PhpOffice\PhpWord\Section\TextRun; +use PhpOffice\PhpWord\Section\Title; +use PhpOffice\PhpWord\Shared\Drawing; +use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\TOC; + +class RTF implements IWriter { /** * Private PHPWord @@ -40,7 +57,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter /** * Private unique PHPWord_Worksheet_BaseDrawing HashTable * - * @var PHPWord_HashTable + * @var PhpOffice\PhpWord\HashTable */ private $_drawingHashTable; @@ -49,17 +66,15 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter private $_lastParagraphStyle; /** - * Create a new PHPWord_Writer_ODText - * - * @param PHPWord $pPHPWord + * @param PHPWord $phpWord */ - public function __construct(PHPWord $pPHPWord = null) + public function __construct(PHPWord $phpWord = null) { // Assign PHPWord - $this->setPHPWord($pPHPWord); + $this->setPHPWord($phpWord); // Set HashTable variables - $this->_drawingHashTable = new PHPWord_HashTable(); + $this->_drawingHashTable = new HashTable(); } /** @@ -113,22 +128,20 @@ public function getPHPWord() } /** - * Get PHPWord object - * - * @param PHPWord $pPHPWord PHPWord object - * @throws Exception - * @return PHPWord_Writer_RTF + * @param PHPWord $phpWord PHPWord object + * @throws Exception + * @return PhpOffice\PhpWord\Writer\RTF */ - public function setPHPWord(PHPWord $pPHPWord = null) + public function setPHPWord(PHPWord $phpWord = null) { - $this->_document = $pPHPWord; + $this->_document = $phpWord; return $this; } /** * Get PHPWord_Worksheet_BaseDrawing HashTable * - * @return PHPWord_HashTable + * @return PhpOffice\PhpWord\HashTable */ public function getDrawingHashTable() { @@ -158,7 +171,7 @@ private function getData() // Set the color tbl group $sRTFContent .= '{\colortbl '; foreach ($this->_colorTable as $idx => $color) { - $arrColor = PHPWord_Shared_Drawing::htmlToRGB($color); + $arrColor = Drawing::htmlToRGB($color); $sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; } $sRTFContent .= ';}' . PHP_EOL; @@ -190,7 +203,7 @@ private function getData() private function getDataFont() { - $pPHPWord = $this->_document; + $phpWord = $this->_document; $arrFonts = array(); // Default font : PHPWord::DEFAULT_FONT_NAME @@ -198,12 +211,12 @@ private function getDataFont() // PHPWord object : $this->_document // Browse styles - $styles = PHPWord_Style::getStyles(); + $styles = Style::getStyles(); $numPStyles = 0; if (count($styles) > 0) { foreach ($styles as $styleName => $style) { - // PHPWord_Style_Font - if ($style instanceof PHPWord_Style_Font) { + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { if (in_array($style->getName(), $arrFonts) == false) { $arrFonts[] = $style->getName(); } @@ -212,7 +225,7 @@ private function getDataFont() } // Search all fonts used - $_sections = $pPHPWord->getSections(); + $_sections = $phpWord->getSections(); $countSections = count($_sections); if ($countSections > 0) { $pSection = 0; @@ -222,10 +235,10 @@ private function getDataFont() $_elements = $section->getElements(); foreach ($_elements as $element) { - if ($element instanceof PHPWord_Section_Text) { + if ($element instanceof Text) { $fStyle = $element->getFontStyle(); - if ($fStyle instanceof PHPWord_Style_Font) { + if ($fStyle instanceof Font) { if (in_array($fStyle->getName(), $arrFonts) == false) { $arrFonts[] = $fStyle->getName(); } @@ -240,18 +253,18 @@ private function getDataFont() private function getDataColor() { - $pPHPWord = $this->_document; + $phpWord = $this->_document; $arrColors = array(); // PHPWord object : $this->_document // Browse styles - $styles = PHPWord_Style::getStyles(); + $styles = Style::getStyles(); $numPStyles = 0; if (count($styles) > 0) { foreach ($styles as $styleName => $style) { - // PHPWord_Style_Font - if ($style instanceof PHPWord_Style_Font) { + // Font + if ($style instanceof Font) { $color = $style->getColor(); $fgcolor = $style->getFgColor(); if (in_array($color, $arrColors) == false && $color != PHPWord::DEFAULT_FONT_COLOR && !empty($color)) { @@ -265,7 +278,7 @@ private function getDataColor() } // Search all fonts used - $_sections = $pPHPWord->getSections(); + $_sections = $phpWord->getSections(); $countSections = count($_sections); if ($countSections > 0) { $pSection = 0; @@ -275,10 +288,10 @@ private function getDataColor() $_elements = $section->getElements(); foreach ($_elements as $element) { - if ($element instanceof PHPWord_Section_Text) { + if ($element instanceof Text) { $fStyle = $element->getFontStyle(); - if ($fStyle instanceof PHPWord_Style_Font) { + if ($fStyle instanceof Font) { if (in_array($fStyle->getColor(), $arrColors) == false) { $arrColors[] = $fStyle->getColor(); } @@ -296,10 +309,10 @@ private function getDataColor() private function getDataContent() { - $pPHPWord = $this->_document; + $phpWord = $this->_document; $sRTFBody = ''; - $_sections = $pPHPWord->getSections(); + $_sections = $phpWord->getSections(); $countSections = count($_sections); $pSection = 0; @@ -308,28 +321,28 @@ private function getDataContent() $pSection++; $_elements = $section->getElements(); foreach ($_elements as $element) { - if ($element instanceof PHPWord_Section_Text) { + if ($element instanceof Text) { $sRTFBody .= $this->getDataContentText($element); - } elseif ($element instanceof PHPWord_Section_TextBreak) { + } elseif ($element instanceof TextBreak) { $sRTFBody .= $this->getDataContentTextBreak(); - } elseif ($element instanceof PHPWord_Section_TextRun) { + } elseif ($element instanceof TextRun) { $sRTFBody .= $this->getDataContentTextRun($element); - } elseif ($element instanceof PHPWord_Section_Link) { + } elseif ($element instanceof Link) { $sRTFBody .= $this->getDataContentUnsupportedElement('Link'); - } elseif ($element instanceof PHPWord_Section_Title) { + } elseif ($element instanceof Title) { $sRTFBody .= $this->getDataContentUnsupportedElement('Title'); - } elseif ($element instanceof PHPWord_Section_PageBreak) { + } elseif ($element instanceof PageBreak) { $sRTFBody .= $this->getDataContentUnsupportedElement('Page Break'); - } elseif ($element instanceof PHPWord_Section_Table) { + } elseif ($element instanceof Table) { $sRTFBody .= $this->getDataContentUnsupportedElement('Table'); - } elseif ($element instanceof PHPWord_Section_ListItem) { + } elseif ($element instanceof ListItem) { $sRTFBody .= $this->getDataContentUnsupportedElement('List Item'); - } elseif ($element instanceof PHPWord_Section_Image || - $element instanceof PHPWord_Section_MemoryImage) { + } elseif ($element instanceof Image || + $element instanceof MemoryImage) { $sRTFBody .= $this->getDataContentUnsupportedElement('Image'); - } elseif ($element instanceof PHPWord_Section_Object) { + } elseif ($element instanceof Object) { $sRTFBody .= $this->getDataContentUnsupportedElement('Object'); - } elseif ($element instanceof PHPWord_TOC) { + } elseif ($element instanceof TOC) { $sRTFBody .= $this->getDataContentUnsupportedElement('TOC'); } else { $sRTFBody .= $this->getDataContentUnsupportedElement('Other'); @@ -343,20 +356,20 @@ private function getDataContent() /** * Get text */ - private function getDataContentText(PHPWord_Section_Text $text, $withoutP = false) + private function getDataContentText(Text $text, $withoutP = false) { $sRTFText = ''; $styleFont = $text->getFontStyle(); - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + $SfIsObject = ($styleFont instanceof Font) ? true : false; if (!$SfIsObject) { - $styleFont = PHPWord_Style::getStyle($styleFont); + $styleFont = Style::getStyle($styleFont); } $styleParagraph = $text->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; if (!$SpIsObject) { - $styleParagraph = PHPWord_Style::getStyle($styleParagraph); + $styleParagraph = Style::getStyle($styleParagraph); } if ($styleParagraph && !$withoutP) { @@ -378,7 +391,7 @@ private function getDataContentText(PHPWord_Section_Text $text, $withoutP = fals $this->_lastParagraphStyle = ''; } - if ($styleFont instanceof PHPWord_Style_Font) { + if ($styleFont instanceof Font) { if ($styleFont->getColor() != null) { $idxColor = array_search($styleFont->getColor(), $this->_colorTable); if ($idxColor !== false) { @@ -410,7 +423,7 @@ private function getDataContentText(PHPWord_Section_Text $text, $withoutP = fals } $sRTFText .= $text->getText(); - if ($styleFont instanceof PHPWord_Style_Font) { + if ($styleFont instanceof Font) { $sRTFText .= '\cf0'; $sRTFText .= '\f0'; @@ -434,14 +447,14 @@ private function getDataContentText(PHPWord_Section_Text $text, $withoutP = fals /** * Get text run content */ - private function getDataContentTextRun(PHPWord_Section_TextRun $textrun) + private function getDataContentTextRun(TextRun $textrun) { $sRTFText = ''; $elements = $textrun->getElements(); if (count($elements) > 0) { $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; foreach ($elements as $element) { - if ($element instanceof PHPWord_Section_Text) { + if ($element instanceof Text) { $sRTFText .= '{'; $sRTFText .= $this->getDataContentText($element, true); $sRTFText .= '}' . PHP_EOL; diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php index e62341bf9a..0aa8e05767 100755 --- a/Classes/PHPWord/Writer/Word2007.php +++ b/Classes/PHPWord/Writer/Word2007.php @@ -25,15 +25,23 @@ * @version 0.8.0 */ -use PhpOffice\PhpWord\Exceptions\InvalidImageException; -use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException; - -/** - * Class PHPWord_Writer_Word2007 - */ -class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter +namespace PhpOffice\PhpWord\Writer; + +use PhpOffice\PhpWord\Footnote; +use PhpOffice\PhpWord\Media; +use PhpOffice\PhpWord\Writer\Word2007\ContentTypes; +use PhpOffice\PhpWord\Writer\Word2007\DocProps; +use PhpOffice\PhpWord\Writer\Word2007\Document; +use PhpOffice\PhpWord\Writer\Word2007\DocumentRels; +use PhpOffice\PhpWord\Writer\Word2007\Footer; +use PhpOffice\PhpWord\Writer\Word2007\Footnotes; +use PhpOffice\PhpWord\Writer\Word2007\FootnotesRels; +use PhpOffice\PhpWord\Writer\Word2007\Header; +use PhpOffice\PhpWord\Writer\Word2007\Rels; +use PhpOffice\PhpWord\Writer\Word2007\Styles; + +class Word2007 implements IWriter { - private $_document; private $_writerParts; private $_diskCachingDirectory; @@ -47,16 +55,16 @@ public function __construct(PHPWord $PHPWord = null) $this->_diskCachingDirectory = './'; - $this->_writerParts['contenttypes'] = new PHPWord_Writer_Word2007_ContentTypes(); - $this->_writerParts['rels'] = new PHPWord_Writer_Word2007_Rels(); - $this->_writerParts['docprops'] = new PHPWord_Writer_Word2007_DocProps(); - $this->_writerParts['documentrels'] = new PHPWord_Writer_Word2007_DocumentRels(); - $this->_writerParts['document'] = new PHPWord_Writer_Word2007_Document(); - $this->_writerParts['styles'] = new PHPWord_Writer_Word2007_Styles(); - $this->_writerParts['header'] = new PHPWord_Writer_Word2007_Header(); - $this->_writerParts['footer'] = new PHPWord_Writer_Word2007_Footer(); - $this->_writerParts['footnotes'] = new PHPWord_Writer_Word2007_Footnotes(); - $this->_writerParts['footnotesrels'] = new PHPWord_Writer_Word2007_FootnotesRels(); + $this->_writerParts['contenttypes'] = new ContentTypes(); + $this->_writerParts['rels'] = new Rels(); + $this->_writerParts['docprops'] = new DocProps(); + $this->_writerParts['documentrels'] = new DocumentRels(); + $this->_writerParts['document'] = new Document(); + $this->_writerParts['styles'] = new Styles(); + $this->_writerParts['header'] = new Header(); + $this->_writerParts['footer'] = new Footer(); + $this->_writerParts['footnotes'] = new Footnotes(); + $this->_writerParts['footnotesrels'] = new FootnotesRels(); foreach ($this->_writerParts as $writer) { $writer->setParentWriter($this); @@ -88,7 +96,7 @@ public function save($pFilename = null) $sectionElements = array(); - $_secElements = PHPWord_Media::getSectionMediaElements(); + $_secElements = Media::getSectionMediaElements(); foreach ($_secElements as $element) { // loop through section media elements if ($element['type'] != 'hyperlink') { $this->_addFileToPackage($objZip, $element); @@ -96,7 +104,7 @@ public function save($pFilename = null) $sectionElements[] = $element; } - $_hdrElements = PHPWord_Media::getHeaderMediaElements(); + $_hdrElements = Media::getHeaderMediaElements(); foreach ($_hdrElements as $_headerFile => $_hdrMedia) { // loop through headers if (count($_hdrMedia) > 0) { $objZip->addFromString('word/_rels/' . $_headerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_hdrMedia)); @@ -106,7 +114,7 @@ public function save($pFilename = null) } } - $_ftrElements = PHPWord_Media::getFooterMediaElements(); + $_ftrElements = Media::getFooterMediaElements(); foreach ($_ftrElements as $_footerFile => $_ftrMedia) { // loop through footers if (count($_ftrMedia) > 0) { $objZip->addFromString('word/_rels/' . $_footerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_ftrMedia)); @@ -117,7 +125,7 @@ public function save($pFilename = null) } $footnoteLinks = array(); - $_footnoteElements = PHPWord_Footnote::getFootnoteLinkElements(); + $_footnoteElements = Footnote::getFootnoteLinkElements(); // loop through footnote link elements foreach ($_footnoteElements as $element) { $footnoteLinks[] = $element; @@ -125,7 +133,7 @@ public function save($pFilename = null) $_cHdrs = 0; $_cFtrs = 0; - $rID = PHPWord_Media::countSectionMediaElements() + 6; + $rID = Media::countSectionMediaElements() + 6; $_sections = $this->_document->getSections(); $footers = array(); @@ -150,8 +158,8 @@ public function save($pFilename = null) } } - if (PHPWord_Footnote::countFootnoteElements() > 0) { - $_allFootnotesCollection = PHPWord_Footnote::getFootnoteElements(); + if (Footnote::countFootnoteElements() > 0) { + $_allFootnotesCollection = Footnote::getFootnoteElements(); $_footnoteFile = 'footnotes.xml'; $sectionElements[] = array('target'=>$_footnoteFile, 'type'=>'footnotes', 'rID'=>++$rID); $objZip->addFromString('word/'.$_footnoteFile, $this->getWriterPart('footnotes')->writeFootnotes($_allFootnotesCollection)); diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php index e9249120e5..a02b008153 100755 --- a/Classes/PHPWord/Writer/Word2007/Base.php +++ b/Classes/PHPWord/Writer/Word2007/Base.php @@ -1,5 +1,4 @@ getFontStyle(); - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + $SfIsObject = ($styleFont instanceof Font) ? true : false; if (!$withoutP) { - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); $styleParagraph = $text->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; if ($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } $strText = htmlspecialchars($text->getText()); - $strText = PHPWord_Shared_String::ControlCharacterPHP2OOXML($strText); + $strText = String::ControlCharacterPHP2OOXML($strText); - $objWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); if ($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); + $this->_writeTextStyle($xmlWriter, $styleFont); } elseif (!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->startElement('w:t'); - $objWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text - $objWriter->writeRaw($strText); - $objWriter->endElement(); + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text + $xmlWriter->writeRaw($strText); + $xmlWriter->endElement(); - $objWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:r if (!$withoutP) { - $objWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } } - /** - * Write text run - */ - protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) + protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) { $elements = $textrun->getElements(); $styleParagraph = $textrun->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); if ($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } if (count($elements) > 0) { foreach ($elements as $element) { - if ($element instanceof PHPWord_Section_Text) { - $this->_writeText($objWriter, $element, true); - } elseif ($element instanceof PHPWord_Section_Link) { - $this->_writeLink($objWriter, $element, true); - } elseif ($element instanceof PHPWord_Section_Image) { - $this->_writeImage($objWriter, $element, true); - } elseif ($element instanceof PHPWord_Section_Footnote) { - $this->_writeFootnoteReference($objWriter, $element, true); - } elseif ($element instanceof PHPWord_Section_TextBreak) { - $objWriter->writeElement('w:br'); + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element, true); + } elseif ($element instanceof Link) { + $this->_writeLink($xmlWriter, $element, true); + } elseif ($element instanceof Image) { + $this->_writeImage($xmlWriter, $element, true); + } elseif ($element instanceof Footnote) { + $this->_writeFootnoteReference($xmlWriter, $element, true); + } elseif ($element instanceof TextBreak) { + $xmlWriter->writeElement('w:br'); } } } - $objWriter->endElement(); + $xmlWriter->endElement(); } /** - * Write paragraph style - * - * @param PHPWord_Shared_XMLWriter $objWriter - * @param PHPWord_Style_Paragraph $style - * @param bool $withoutPPR - * @return void + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Style\Paragraph $style + * @param bool $withoutPPR + * @return void */ protected function _writeParagraphStyle( - PHPWord_Shared_XMLWriter $objWriter = null, - PHPWord_Style_Paragraph $style, + XMLWriter $xmlWriter = null, + Paragraph $style, $withoutPPR = false ) { @@ -157,83 +164,80 @@ protected function _writeParagraphStyle( !is_null($tabs) || !is_null($widowControl) || !is_null($keepNext) || !is_null($keepLines) || !is_null($pageBreakBefore)) { if (!$withoutPPR) { - $objWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pPr'); } // Alignment if (!is_null($align)) { - $objWriter->startElement('w:jc'); - $objWriter->writeAttribute('w:val', $align); - $objWriter->endElement(); + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $align); + $xmlWriter->endElement(); } // Indentation if (!is_null($indent) || !is_null($hanging)) { - $objWriter->startElement('w:ind'); - $objWriter->writeAttribute('w:firstLine', 0); + $xmlWriter->startElement('w:ind'); + $xmlWriter->writeAttribute('w:firstLine', 0); if (!is_null($indent)) { - $objWriter->writeAttribute('w:left', $indent); + $xmlWriter->writeAttribute('w:left', $indent); } if (!is_null($hanging)) { - $objWriter->writeAttribute('w:hanging', $hanging); + $xmlWriter->writeAttribute('w:hanging', $hanging); } - $objWriter->endElement(); + $xmlWriter->endElement(); } // Spacing if (!is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($spacing)) { - $objWriter->startElement('w:spacing'); + $xmlWriter->startElement('w:spacing'); if (!is_null($spaceBefore)) { - $objWriter->writeAttribute('w:before', $spaceBefore); + $xmlWriter->writeAttribute('w:before', $spaceBefore); } if (!is_null($spaceAfter)) { - $objWriter->writeAttribute('w:after', $spaceAfter); + $xmlWriter->writeAttribute('w:after', $spaceAfter); } if (!is_null($spacing)) { - $objWriter->writeAttribute('w:line', $spacing); - $objWriter->writeAttribute('w:lineRule', 'auto'); + $xmlWriter->writeAttribute('w:line', $spacing); + $xmlWriter->writeAttribute('w:lineRule', 'auto'); } - $objWriter->endElement(); + $xmlWriter->endElement(); } // Pagination if (!$widowControl) { - $objWriter->startElement('w:widowControl'); - $objWriter->writeAttribute('w:val', '0'); - $objWriter->endElement(); + $xmlWriter->startElement('w:widowControl'); + $xmlWriter->writeAttribute('w:val', '0'); + $xmlWriter->endElement(); } if ($keepNext) { - $objWriter->startElement('w:keepNext'); - $objWriter->writeAttribute('w:val', '1'); - $objWriter->endElement(); + $xmlWriter->startElement('w:keepNext'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); } if ($keepLines) { - $objWriter->startElement('w:keepLines'); - $objWriter->writeAttribute('w:val', '1'); - $objWriter->endElement(); + $xmlWriter->startElement('w:keepLines'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); } if ($pageBreakBefore) { - $objWriter->startElement('w:pageBreakBefore'); - $objWriter->writeAttribute('w:val', '1'); - $objWriter->endElement(); + $xmlWriter->startElement('w:pageBreakBefore'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); } // Tabs if (!is_null($tabs)) { - $tabs->toXml($objWriter); + $tabs->toXml($xmlWriter); } if (!$withoutPPR) { - $objWriter->endElement(); // w:pPr + $xmlWriter->endElement(); // w:pPr } } } - /** - * Write link - */ - protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) + protected function _writeLink(XMLWriter $xmlWriter = null, Link $link, $withoutP = false) { $rID = $link->getRelationId(); $linkName = $link->getLinkName(); @@ -242,79 +246,76 @@ protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWor } $styleFont = $link->getFontStyle(); - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + $SfIsObject = ($styleFont instanceof Font) ? true : false; if (!$withoutP) { - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); $styleParagraph = $link->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; if ($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } - $objWriter->startElement('w:hyperlink'); - $objWriter->writeAttribute('r:id', 'rId' . $rID); - $objWriter->writeAttribute('w:history', '1'); + $xmlWriter->startElement('w:hyperlink'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rID); + $xmlWriter->writeAttribute('w:history', '1'); - $objWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); if ($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); + $this->_writeTextStyle($xmlWriter, $styleFont); } elseif (!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->startElement('w:t'); - $objWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text - $objWriter->writeRaw($linkName); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text + $xmlWriter->writeRaw($linkName); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); if (!$withoutP) { - $objWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } } - /** - * Write preserve text - */ - protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) + protected function _writePreserveText(XMLWriter $xmlWriter = null, PreserveText $textrun) { $styleFont = $textrun->getFontStyle(); $styleParagraph = $textrun->getParagraphStyle(); - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + $SfIsObject = ($styleFont instanceof Font) ? true : false; + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; $arrText = $textrun->getText(); if (!is_array($arrText)) { $arrText = array($arrText); } - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); if ($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } foreach ($arrText as $text) { @@ -322,72 +323,69 @@ protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null if (substr($text, 0, 1) == '{') { $text = substr($text, 1, -1); - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'begin'); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); if ($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); + $this->_writeTextStyle($xmlWriter, $styleFont); } elseif (!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->startElement('w:instrText'); - $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRaw($text); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'separate'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'end'); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'separate'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } else { $text = htmlspecialchars($text); - $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); + $text = String::ControlCharacterPHP2OOXML($text); - $objWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); if ($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); + $this->_writeTextStyle($xmlWriter, $styleFont); } elseif (!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->startElement('w:t'); - $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRaw($text); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } - $objWriter->endElement(); // p + $xmlWriter->endElement(); // p } - /** - * Write text style - */ - protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) + protected function _writeTextStyle(XMLWriter $xmlWriter = null, Font $style) { $font = $style->getName(); $bold = $style->getBold(); @@ -401,156 +399,151 @@ protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, P $subscript = $style->getSubScript(); $hint = $style->getHint(); - $objWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rPr'); // Font if ($font != PHPWord::DEFAULT_FONT_NAME) { - $objWriter->startElement('w:rFonts'); - $objWriter->writeAttribute('w:ascii', $font); - $objWriter->writeAttribute('w:hAnsi', $font); - $objWriter->writeAttribute('w:eastAsia', $font); - $objWriter->writeAttribute('w:cs', $font); + $xmlWriter->startElement('w:rFonts'); + $xmlWriter->writeAttribute('w:ascii', $font); + $xmlWriter->writeAttribute('w:hAnsi', $font); + $xmlWriter->writeAttribute('w:eastAsia', $font); + $xmlWriter->writeAttribute('w:cs', $font); //Font Content Type if ($hint != PHPWord::DEFAULT_FONT_CONTENT_TYPE) { - $objWriter->writeAttribute('w:hint', $hint); + $xmlWriter->writeAttribute('w:hint', $hint); } - $objWriter->endElement(); + $xmlWriter->endElement(); } // Color if ($color != PHPWord::DEFAULT_FONT_COLOR) { - $objWriter->startElement('w:color'); - $objWriter->writeAttribute('w:val', $color); - $objWriter->endElement(); + $xmlWriter->startElement('w:color'); + $xmlWriter->writeAttribute('w:val', $color); + $xmlWriter->endElement(); } // Size if ($size != PHPWord::DEFAULT_FONT_SIZE) { - $objWriter->startElement('w:sz'); - $objWriter->writeAttribute('w:val', $size * 2); - $objWriter->endElement(); - $objWriter->startElement('w:szCs'); - $objWriter->writeAttribute('w:val', $size * 2); - $objWriter->endElement(); + $xmlWriter->startElement('w:sz'); + $xmlWriter->writeAttribute('w:val', $size * 2); + $xmlWriter->endElement(); + $xmlWriter->startElement('w:szCs'); + $xmlWriter->writeAttribute('w:val', $size * 2); + $xmlWriter->endElement(); } // Bold if ($bold) { - $objWriter->writeElement('w:b', null); + $xmlWriter->writeElement('w:b', null); } // Italic if ($italic) { - $objWriter->writeElement('w:i', null); - $objWriter->writeElement('w:iCs', null); + $xmlWriter->writeElement('w:i', null); + $xmlWriter->writeElement('w:iCs', null); } // Underline if (!is_null($underline) && $underline != 'none') { - $objWriter->startElement('w:u'); - $objWriter->writeAttribute('w:val', $underline); - $objWriter->endElement(); + $xmlWriter->startElement('w:u'); + $xmlWriter->writeAttribute('w:val', $underline); + $xmlWriter->endElement(); } // Strikethrough if ($strikethrough) { - $objWriter->writeElement('w:strike', null); + $xmlWriter->writeElement('w:strike', null); } // Foreground-Color if (!is_null($fgColor)) { - $objWriter->startElement('w:highlight'); - $objWriter->writeAttribute('w:val', $fgColor); - $objWriter->endElement(); + $xmlWriter->startElement('w:highlight'); + $xmlWriter->writeAttribute('w:val', $fgColor); + $xmlWriter->endElement(); } // Superscript/subscript if ($superscript || $subscript) { - $objWriter->startElement('w:vertAlign'); - $objWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript'); - $objWriter->endElement(); + $xmlWriter->startElement('w:vertAlign'); + $xmlWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript'); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); } /** - * Write text break - * - * @param PHPWord_Shared_XMLWriter $objWriter - * @param PHPWord_Section_TextBreak $element + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\TextBreak $element */ - protected function _writeTextBreak($objWriter, $element = null) + protected function _writeTextBreak($xmlWriter, $element = null) { $hasStyle = false; if (!is_null($element)) { $fontStyle = $element->getFontStyle(); - $sfIsObject = ($fontStyle instanceof PHPWord_Style_Font) ? true : false; + $sfIsObject = ($fontStyle instanceof Font) ? true : false; $paragraphStyle = $element->getParagraphStyle(); - $spIsObject = ($paragraphStyle instanceof PHPWord_Style_Paragraph) ? true : false; + $spIsObject = ($paragraphStyle instanceof Paragraph) ? true : false; $hasStyle = !is_null($fontStyle) || !is_null($paragraphStyle); } if ($hasStyle) { // Paragraph style - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); if ($spIsObject) { - $this->_writeParagraphStyle($objWriter, $paragraphStyle); + $this->_writeParagraphStyle($xmlWriter, $paragraphStyle); } elseif (!$spIsObject && !is_null($paragraphStyle)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $paragraphStyle); - $objWriter->endElement(); // w:pStyle - $objWriter->endElement(); // w:pPr + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $paragraphStyle); + $xmlWriter->endElement(); // w:pStyle + $xmlWriter->endElement(); // w:pPr } // Font style if (!is_null($fontStyle)) { - $objWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pPr'); if ($sfIsObject) { - $this->_writeTextStyle($objWriter, $fontStyle); + $this->_writeTextStyle($xmlWriter, $fontStyle); } elseif (!$sfIsObject && !is_null($fontStyle)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $fontStyle); - $objWriter->endElement(); // w:rStyle - $objWriter->endElement(); // w:rPr + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $fontStyle); + $xmlWriter->endElement(); // w:rStyle + $xmlWriter->endElement(); // w:rPr } - $objWriter->endElement(); // w:pPr + $xmlWriter->endElement(); // w:pPr } - $objWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } else { // Null element. No paragraph nor font style - $objWriter->writeElement('w:p', null); + $xmlWriter->writeElement('w:p', null); } } - /** - * Write table - */ - protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) + protected function _writeTable(XMLWriter $xmlWriter = null, Table $table) { $_rows = $table->getRows(); $_cRows = count($_rows); if ($_cRows > 0) { - $objWriter->startElement('w:tbl'); + $xmlWriter->startElement('w:tbl'); $tblStyle = $table->getStyle(); $tblWidth = $table->getWidth(); - if ($tblStyle instanceof PHPWord_Style_Table) { - $this->_writeTableStyle($objWriter, $tblStyle); + if ($tblStyle instanceof PhpOffice\PhpWord\Style\Table) { + $this->_writeTableStyle($xmlWriter, $tblStyle); } else { if (!empty($tblStyle)) { - $objWriter->startElement('w:tblPr'); - $objWriter->startElement('w:tblStyle'); - $objWriter->writeAttribute('w:val', $tblStyle); - $objWriter->endElement(); + $xmlWriter->startElement('w:tblPr'); + $xmlWriter->startElement('w:tblStyle'); + $xmlWriter->writeAttribute('w:val', $tblStyle); + $xmlWriter->endElement(); if (!is_null($tblWidth)) { - $objWriter->startElement('w:tblW'); - $objWriter->writeAttribute('w:w', $tblWidth); - $objWriter->writeAttribute('w:type', 'pct'); - $objWriter->endElement(); + $xmlWriter->startElement('w:tblW'); + $xmlWriter->writeAttribute('w:w', $tblWidth); + $xmlWriter->writeAttribute('w:type', 'pct'); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); } } @@ -561,86 +554,85 @@ protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo $tblHeader = $rowStyle->getTblHeader(); $cantSplit = $rowStyle->getCantSplit(); - $objWriter->startElement('w:tr'); + $xmlWriter->startElement('w:tr'); if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) { - $objWriter->startElement('w:trPr'); + $xmlWriter->startElement('w:trPr'); if (!is_null($height)) { - $objWriter->startElement('w:trHeight'); - $objWriter->writeAttribute('w:val', $height); - $objWriter->endElement(); + $xmlWriter->startElement('w:trHeight'); + $xmlWriter->writeAttribute('w:val', $height); + $xmlWriter->endElement(); } if ($tblHeader) { - $objWriter->startElement('w:tblHeader'); - $objWriter->writeAttribute('w:val', '1'); - $objWriter->endElement(); + $xmlWriter->startElement('w:tblHeader'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); } if ($cantSplit) { - $objWriter->startElement('w:cantSplit'); - $objWriter->writeAttribute('w:val', '1'); - $objWriter->endElement(); + $xmlWriter->startElement('w:cantSplit'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); } foreach ($row->getCells() as $cell) { - $objWriter->startElement('w:tc'); + $xmlWriter->startElement('w:tc'); $cellStyle = $cell->getStyle(); $width = $cell->getWidth(); - $objWriter->startElement('w:tcPr'); - $objWriter->startElement('w:tcW'); - $objWriter->writeAttribute('w:w', $width); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); + $xmlWriter->startElement('w:tcPr'); + $xmlWriter->startElement('w:tcW'); + $xmlWriter->writeAttribute('w:w', $width); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); - if ($cellStyle instanceof PHPWord_Style_Cell) { - $this->_writeCellStyle($objWriter, $cellStyle); + if ($cellStyle instanceof Cell) { + $this->_writeCellStyle($xmlWriter, $cellStyle); } - $objWriter->endElement(); + $xmlWriter->endElement(); $_elements = $cell->getElements(); if (count($_elements) > 0) { foreach ($_elements as $element) { - if ($element instanceof PHPWord_Section_Text) { - $this->_writeText($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_TextRun) { - $this->_writeTextRun($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Link) { - $this->_writeLink($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_TextBreak) { - $this->_writeTextBreak($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_ListItem) { - $this->_writeListItem($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Image || - $element instanceof PHPWord_Section_MemoryImage + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof Link) { + $this->_writeLink($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter, $element); + } elseif ($element instanceof ListItem) { + $this->_writeListItem($xmlWriter, $element); + } elseif ($element instanceof Image || + $element instanceof MemoryImage ) { - $this->_writeImage($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Object) { - $this->_writeObject($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) { - $this->_writePreserveText($objWriter, $element); + $this->_writeImage($xmlWriter, $element); + } elseif ($element instanceof Object) { + $this->_writeObject($xmlWriter, $element); + } elseif ($element instanceof PreserveText) { + $this->_writePreserveText($xmlWriter, $element); } } } else { - $this->_writeTextBreak($objWriter); + $this->_writeTextBreak($xmlWriter); } - $objWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); } } - /** - * Write table style - */ - protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) - { + protected function _writeTableStyle( + XMLWriter $xmlWriter = null, + PhpOffice\PhpWord\Style\Table $style = null + ) { $margins = $style->getCellMargin(); $mTop = (!is_null($margins[0])) ? true : false; $mLeft = (!is_null($margins[1])) ? true : false; @@ -648,46 +640,43 @@ protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, $mBottom = (!is_null($margins[3])) ? true : false; if ($mTop || $mLeft || $mRight || $mBottom) { - $objWriter->startElement('w:tblPr'); - $objWriter->startElement('w:tblCellMar'); + $xmlWriter->startElement('w:tblPr'); + $xmlWriter->startElement('w:tblCellMar'); if ($mTop) { - $objWriter->startElement('w:top'); - $objWriter->writeAttribute('w:w', $margins[0]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:w', $margins[0]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); } if ($mLeft) { - $objWriter->startElement('w:left'); - $objWriter->writeAttribute('w:w', $margins[1]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:w', $margins[1]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); } if ($mRight) { - $objWriter->startElement('w:right'); - $objWriter->writeAttribute('w:w', $margins[2]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:w', $margins[2]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); } if ($mBottom) { - $objWriter->startElement('w:bottom'); - $objWriter->writeAttribute('w:w', $margins[3]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:w', $margins[3]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); } - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } - /** - * Write cell style - */ - protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Cell $style = null) + protected function _writeCellStyle(XMLWriter $xmlWriter = null, Cell $style = null) { $bgColor = $style->getBgColor(); $valign = $style->getVAlign(); @@ -705,96 +694,96 @@ protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, P if ($styles) { if (!is_null($textDir)) { - $objWriter->startElement('w:textDirection'); - $objWriter->writeAttribute('w:val', $textDir); - $objWriter->endElement(); + $xmlWriter->startElement('w:textDirection'); + $xmlWriter->writeAttribute('w:val', $textDir); + $xmlWriter->endElement(); } if (!is_null($bgColor)) { - $objWriter->startElement('w:shd'); - $objWriter->writeAttribute('w:val', 'clear'); - $objWriter->writeAttribute('w:color', 'auto'); - $objWriter->writeAttribute('w:fill', $bgColor); - $objWriter->endElement(); + $xmlWriter->startElement('w:shd'); + $xmlWriter->writeAttribute('w:val', 'clear'); + $xmlWriter->writeAttribute('w:color', 'auto'); + $xmlWriter->writeAttribute('w:fill', $bgColor); + $xmlWriter->endElement(); } if (!is_null($valign)) { - $objWriter->startElement('w:vAlign'); - $objWriter->writeAttribute('w:val', $valign); - $objWriter->endElement(); + $xmlWriter->startElement('w:vAlign'); + $xmlWriter->writeAttribute('w:val', $valign); + $xmlWriter->endElement(); } if ($borders) { $_defaultColor = $style->getDefaultBorderColor(); - $objWriter->startElement('w:tcBorders'); + $xmlWriter->startElement('w:tcBorders'); if ($bTop) { if (is_null($brdCol[0])) { $brdCol[0] = $_defaultColor; } - $objWriter->startElement('w:top'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[0]); - $objWriter->writeAttribute('w:color', $brdCol[0]); - $objWriter->endElement(); + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[0]); + $xmlWriter->writeAttribute('w:color', $brdCol[0]); + $xmlWriter->endElement(); } if ($bLeft) { if (is_null($brdCol[1])) { $brdCol[1] = $_defaultColor; } - $objWriter->startElement('w:left'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[1]); - $objWriter->writeAttribute('w:color', $brdCol[1]); - $objWriter->endElement(); + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[1]); + $xmlWriter->writeAttribute('w:color', $brdCol[1]); + $xmlWriter->endElement(); } if ($bRight) { if (is_null($brdCol[2])) { $brdCol[2] = $_defaultColor; } - $objWriter->startElement('w:right'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[2]); - $objWriter->writeAttribute('w:color', $brdCol[2]); - $objWriter->endElement(); + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[2]); + $xmlWriter->writeAttribute('w:color', $brdCol[2]); + $xmlWriter->endElement(); } if ($bBottom) { if (is_null($brdCol[3])) { $brdCol[3] = $_defaultColor; } - $objWriter->startElement('w:bottom'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[3]); - $objWriter->writeAttribute('w:color', $brdCol[3]); - $objWriter->endElement(); + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[3]); + $xmlWriter->writeAttribute('w:color', $brdCol[3]); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); } } $gridSpan = $style->getGridSpan(); if (!is_null($gridSpan)) { - $objWriter->startElement('w:gridSpan'); - $objWriter->writeAttribute('w:val', $gridSpan); - $objWriter->endElement(); + $xmlWriter->startElement('w:gridSpan'); + $xmlWriter->writeAttribute('w:val', $gridSpan); + $xmlWriter->endElement(); } $vMerge = $style->getVMerge(); if (!is_null($vMerge)) { - $objWriter->startElement('w:vMerge'); - $objWriter->writeAttribute('w:val', $vMerge); - $objWriter->endElement(); + $xmlWriter->startElement('w:vMerge'); + $xmlWriter->writeAttribute('w:val', $vMerge); + $xmlWriter->endElement(); } } /** - * @param \PHPWord_Shared_XMLWriter $objWriter - * @param \PHPWord_Section_Image|\PHPWord_Section_MemoryImage $image + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Image|PhpOffice\PhpWord\Section\MemoryImage $image */ - protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image, $withoutP = false) + protected function _writeImage(XMLWriter $xmlWriter = null, $image, $withoutP = false) { $rId = $image->getRelationId(); @@ -807,23 +796,23 @@ protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $imag $wrappingStyle = $style->getWrappingStyle(); if (!$withoutP) { - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); if (!is_null($align)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:jc'); - $objWriter->writeAttribute('w:val', $align); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $align); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } - $objWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); - $objWriter->startElement('w:pict'); + $xmlWriter->startElement('w:pict'); - $objWriter->startElement('v:shape'); - $objWriter->writeAttribute('type', '#_x0000_t75'); + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('type', '#_x0000_t75'); $imgStyle = ''; if (null !== $width) { @@ -840,41 +829,38 @@ protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $imag } switch ($wrappingStyle) { - case PHPWord_Style_Image::WRAPPING_STYLE_BEHIND: + case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND: $imgStyle .= 'position:absolute;z-index:-251658752;'; break; - case PHPWord_Style_Image::WRAPPING_STYLE_SQUARE: + case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE: $imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; break; - case PHPWord_Style_Image::WRAPPING_STYLE_TIGHT: + case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_TIGHT: $imgStyle .= 'position:absolute;z-index:251659264;mso-wrap-edited:f;mso-position-horizontal:absolute;mso-position-vertical:absolute'; break; - case PHPWord_Style_Image::WRAPPING_STYLE_INFRONT: + case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_INFRONT: $imgStyle .= 'position:absolute;zz-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; break; } - $objWriter->writeAttribute('style', $imgStyle); + $xmlWriter->writeAttribute('style', $imgStyle); - $objWriter->startElement('v:imagedata'); - $objWriter->writeAttribute('r:id', 'rId' . $rId); - $objWriter->writeAttribute('o:title', ''); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('v:imagedata'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->writeAttribute('o:title', ''); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); if (!$withoutP) { - $objWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } } - /** - * Write watermark - */ - protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) + protected function _writeWatermark(XMLWriter $xmlWriter = null, $image) { $rId = $image->getRelationId(); @@ -884,14 +870,14 @@ protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $ $marginLeft = $style->getMarginLeft(); $marginTop = $style->getMarginTop(); - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); - $objWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); - $objWriter->startElement('w:pict'); + $xmlWriter->startElement('w:pict'); - $objWriter->startElement('v:shape'); - $objWriter->writeAttribute('type', '#_x0000_t75'); + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('type', '#_x0000_t75'); $strStyle = 'position:absolute;'; $strStyle .= ' width:' . $width . 'px;'; @@ -903,123 +889,114 @@ protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $ $strStyle .= ' margin-left:' . $marginLeft . 'px;'; } - $objWriter->writeAttribute('style', $strStyle); + $xmlWriter->writeAttribute('style', $strStyle); - $objWriter->startElement('v:imagedata'); - $objWriter->writeAttribute('r:id', 'rId' . $rId); - $objWriter->writeAttribute('o:title', ''); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('v:imagedata'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->writeAttribute('o:title', ''); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); } - /** - * Write title - */ - protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) + protected function _writeTitle(XMLWriter $xmlWriter = null, Title $title) { $text = htmlspecialchars($title->getText()); - $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); + $text = String::ControlCharacterPHP2OOXML($text); $anchor = $title->getAnchor(); $bookmarkId = $title->getBookmarkId(); $style = $title->getStyle(); - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); if (!empty($style)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $style); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'end'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('w:bookmarkStart'); - $objWriter->writeAttribute('w:id', $bookmarkId); - $objWriter->writeAttribute('w:name', $anchor); - $objWriter->endElement(); - - $objWriter->startElement('w:r'); - $objWriter->startElement('w:t'); - $objWriter->writeRaw($text); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('w:bookmarkEnd'); - $objWriter->writeAttribute('w:id', $bookmarkId); - $objWriter->endElement(); - - $objWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $style); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:bookmarkStart'); + $xmlWriter->writeAttribute('w:id', $bookmarkId); + $xmlWriter->writeAttribute('w:name', $anchor); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:t'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:bookmarkEnd'); + $xmlWriter->writeAttribute('w:id', $bookmarkId); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); } - /** - * Write footnote - */ - protected function _writeFootnote(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote) + protected function _writeFootnote(XMLWriter $xmlWriter = null, Footnote $footnote) { - $objWriter->startElement('w:footnote'); - $objWriter->writeAttribute('w:id', $footnote->getReferenceId()); + $xmlWriter->startElement('w:footnote'); + $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId()); $styleParagraph = $footnote->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); if ($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } $elements = $footnote->getElements(); if (count($elements) > 0) { foreach ($elements as $element) { - if ($element instanceof PHPWord_Section_Text) { - $this->_writeText($objWriter, $element, true); - } elseif ($element instanceof PHPWord_Section_Link) { - $this->_writeLink($objWriter, $element, true); + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element, true); + } elseif ($element instanceof Link) { + $this->_writeLink($xmlWriter, $element, true); } } } - $objWriter->endElement(); // w:p - $objWriter->endElement(); // w:footnote + $xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:footnote } - /** - * Write footnote reference - */ - protected function _writeFootnoteReference(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote, $withoutP = false) + protected function _writeFootnoteReference(XMLWriter $xmlWriter = null, Footnote $footnote, $withoutP = false) { if (!$withoutP) { - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); } - $objWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); - $objWriter->startElement('w:footnoteReference'); - $objWriter->writeAttribute('w:id', $footnote->getReferenceId()); - $objWriter->endElement(); // w:footnoteReference + $xmlWriter->startElement('w:footnoteReference'); + $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId()); + $xmlWriter->endElement(); // w:footnoteReference - $objWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:r if (!$withoutP) { - $objWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } } } diff --git a/Classes/PHPWord/Writer/Word2007/ContentTypes.php b/Classes/PHPWord/Writer/Word2007/ContentTypes.php index 8a6e39ef85..27d3cefa6d 100755 --- a/Classes/PHPWord/Writer/Word2007/ContentTypes.php +++ b/Classes/PHPWord/Writer/Word2007/ContentTypes.php @@ -25,52 +25,53 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_Word2007_ContentTypes - */ -class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_WriterPart -{ +namespace PhpOffice\PhpWord\Writer\Word2007; +use PhpOffice\PhpWord\Shared\File; +use PhpOffice\PhpWord\Shared\XMLWriter; + +class ContentTypes extends WriterPart +{ public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); // Types - $objWriter->startElement('Types'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); + $xmlWriter->startElement('Types'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); // Rels $this->_writeDefaultContentType( - $objWriter, + $xmlWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml' ); // XML $this->_writeDefaultContentType( - $objWriter, + $xmlWriter, 'xml', 'application/xml' ); // Add media content-types foreach ($_imageTypes as $key => $value) { - $this->_writeDefaultContentType($objWriter, $key, $value); + $this->_writeDefaultContentType($xmlWriter, $key, $value); } // Add embedding content-types if (count($_objectTypes) > 0) { $this->_writeDefaultContentType( - $objWriter, + $xmlWriter, 'bin', 'application/vnd.openxmlformats-officedocument.oleObject' ); @@ -78,76 +79,76 @@ public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers // DocProps $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml' ); $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml' ); // Document $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/document.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml' ); // Styles $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/styles.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml' ); // Numbering $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/numbering.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml' ); // Settings $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/settings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml' ); // Theme1 $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml' ); // WebSettings $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/webSettings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml' ); // Font Table $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/fontTable.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml' ); // Footnotes $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/footnotes.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml' ); for ($i = 1; $i <= $_cHdrs; $i++) { $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/header' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml' ); @@ -156,7 +157,7 @@ public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers for ($i = 1; $i <= count($footers); $i++) { if (!is_null($footers[$i])) { $this->_writeOverrideContentType( - $objWriter, + $xmlWriter, '/word/footer' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml' ); @@ -164,10 +165,10 @@ public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers } - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } /** @@ -179,7 +180,7 @@ public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers */ private function _getImageMimeType($pFile = '') { - if (PHPWord_Shared_File::file_exists($pFile)) { + if (File::file_exists($pFile)) { $image = getimagesize($pFile); return image_type_to_mime_type($image[2]); } else { @@ -188,42 +189,38 @@ private function _getImageMimeType($pFile = '') } /** - * Write Default content type - * - * @param PHPWord_Shared_XMLWriter $objWriter XML Writer - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception */ - private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') + private function _writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') { if ($pPartname != '' && $pContentType != '') { // Write content type - $objWriter->startElement('Default'); - $objWriter->writeAttribute('Extension', $pPartname); - $objWriter->writeAttribute('ContentType', $pContentType); - $objWriter->endElement(); + $xmlWriter->startElement('Default'); + $xmlWriter->writeAttribute('Extension', $pPartname); + $xmlWriter->writeAttribute('ContentType', $pContentType); + $xmlWriter->endElement(); } else { throw new Exception("Invalid parameters passed."); } } /** - * Write Override content type - * - * @param PHPWord_Shared_XMLWriter $objWriter XML Writer - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception */ - private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') + private function _writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') { if ($pPartname != '' && $pContentType != '') { // Write content type - $objWriter->startElement('Override'); - $objWriter->writeAttribute('PartName', $pPartname); - $objWriter->writeAttribute('ContentType', $pContentType); - $objWriter->endElement(); + $xmlWriter->startElement('Override'); + $xmlWriter->writeAttribute('PartName', $pPartname); + $xmlWriter->writeAttribute('ContentType', $pContentType); + $xmlWriter->endElement(); } else { throw new Exception("Invalid parameters passed."); } diff --git a/Classes/PHPWord/Writer/Word2007/DocProps.php b/Classes/PHPWord/Writer/Word2007/DocProps.php index 2e8f8b5a63..05c2b8690c 100755 --- a/Classes/PHPWord/Writer/Word2007/DocProps.php +++ b/Classes/PHPWord/Writer/Word2007/DocProps.php @@ -25,161 +25,161 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_Word2007_DocProps - */ -class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPart -{ +namespace PhpOffice\PhpWord\Writer\Word2007; - public function writeDocPropsApp(PHPWord $pPHPWord = null) +use PhpOffice\PhpWord\Shared\XMLWriter; + +class DocProps extends WriterPart +{ + public function writeDocPropsApp(PHPWord $phpWord = null) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); // Properties - $objWriter->startElement('Properties'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); - $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); + $xmlWriter->startElement('Properties'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); + $xmlWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); // Application - $objWriter->writeElement('Application', 'Microsoft Office Word'); + $xmlWriter->writeElement('Application', 'Microsoft Office Word'); // ScaleCrop - $objWriter->writeElement('ScaleCrop', 'false'); + $xmlWriter->writeElement('ScaleCrop', 'false'); // HeadingPairs - $objWriter->startElement('HeadingPairs'); + $xmlWriter->startElement('HeadingPairs'); // Vector - $objWriter->startElement('vt:vector'); - $objWriter->writeAttribute('size', '4'); - $objWriter->writeAttribute('baseType', 'variant'); + $xmlWriter->startElement('vt:vector'); + $xmlWriter->writeAttribute('size', '4'); + $xmlWriter->writeAttribute('baseType', 'variant'); // Variant - $objWriter->startElement('vt:variant'); - $objWriter->writeElement('vt:lpstr', 'Theme'); - $objWriter->endElement(); + $xmlWriter->startElement('vt:variant'); + $xmlWriter->writeElement('vt:lpstr', 'Theme'); + $xmlWriter->endElement(); // Variant - $objWriter->startElement('vt:variant'); - $objWriter->writeElement('vt:i4', '1'); - $objWriter->endElement(); + $xmlWriter->startElement('vt:variant'); + $xmlWriter->writeElement('vt:i4', '1'); + $xmlWriter->endElement(); // Variant - $objWriter->startElement('vt:variant'); - $objWriter->writeElement('vt:lpstr', 'Slide Titles'); - $objWriter->endElement(); + $xmlWriter->startElement('vt:variant'); + $xmlWriter->writeElement('vt:lpstr', 'Slide Titles'); + $xmlWriter->endElement(); // Variant - $objWriter->startElement('vt:variant'); - $objWriter->writeElement('vt:i4', '1'); - $objWriter->endElement(); + $xmlWriter->startElement('vt:variant'); + $xmlWriter->writeElement('vt:i4', '1'); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); // TitlesOfParts - $objWriter->startElement('TitlesOfParts'); + $xmlWriter->startElement('TitlesOfParts'); // Vector - $objWriter->startElement('vt:vector'); - $objWriter->writeAttribute('size', '1'); - $objWriter->writeAttribute('baseType', 'lpstr'); + $xmlWriter->startElement('vt:vector'); + $xmlWriter->writeAttribute('size', '1'); + $xmlWriter->writeAttribute('baseType', 'lpstr'); - $objWriter->writeElement('vt:lpstr', 'Office Theme'); + $xmlWriter->writeElement('vt:lpstr', 'Office Theme'); - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); // Company - $objWriter->writeElement('Company', $pPHPWord->getProperties()->getCompany()); + $xmlWriter->writeElement('Company', $phpWord->getProperties()->getCompany()); // LinksUpToDate - $objWriter->writeElement('LinksUpToDate', 'false'); + $xmlWriter->writeElement('LinksUpToDate', 'false'); // SharedDoc - $objWriter->writeElement('SharedDoc', 'false'); + $xmlWriter->writeElement('SharedDoc', 'false'); // HyperlinksChanged - $objWriter->writeElement('HyperlinksChanged', 'false'); + $xmlWriter->writeElement('HyperlinksChanged', 'false'); // AppVersion - $objWriter->writeElement('AppVersion', '12.0000'); + $xmlWriter->writeElement('AppVersion', '12.0000'); - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } - public function writeDocPropsCore(PHPWord $pPHPWord = null) + public function writeDocPropsCore(PHPWord $phpWord = null) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); // cp:coreProperties - $objWriter->startElement('cp:coreProperties'); - $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); - $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); - $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); - $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); + $xmlWriter->startElement('cp:coreProperties'); + $xmlWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); + $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $xmlWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); + $xmlWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); + $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); // dc:creator - $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getCreator()); + $xmlWriter->writeElement('dc:creator', $phpWord->getProperties()->getCreator()); // cp:lastModifiedBy - $objWriter->writeElement('cp:lastModifiedBy', $pPHPWord->getProperties()->getLastModifiedBy()); + $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getProperties()->getLastModifiedBy()); // dcterms:created - $objWriter->startElement('dcterms:created'); - $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getCreated())); - $objWriter->endElement(); + $xmlWriter->startElement('dcterms:created'); + $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); + $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getProperties()->getCreated())); + $xmlWriter->endElement(); // dcterms:modified - $objWriter->startElement('dcterms:modified'); - $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getModified())); - $objWriter->endElement(); + $xmlWriter->startElement('dcterms:modified'); + $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); + $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getProperties()->getModified())); + $xmlWriter->endElement(); // dc:title - $objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle()); + $xmlWriter->writeElement('dc:title', $phpWord->getProperties()->getTitle()); // dc:description - $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); + $xmlWriter->writeElement('dc:description', $phpWord->getProperties()->getDescription()); // dc:subject - $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); + $xmlWriter->writeElement('dc:subject', $phpWord->getProperties()->getSubject()); // cp:keywords - $objWriter->writeElement('cp:keywords', $pPHPWord->getProperties()->getKeywords()); + $xmlWriter->writeElement('cp:keywords', $phpWord->getProperties()->getKeywords()); // cp:category - $objWriter->writeElement('cp:category', $pPHPWord->getProperties()->getCategory()); + $xmlWriter->writeElement('cp:category', $phpWord->getProperties()->getCategory()); - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } } diff --git a/Classes/PHPWord/Writer/Word2007/Document.php b/Classes/PHPWord/Writer/Word2007/Document.php index abdd92cc75..691e723e08 100755 --- a/Classes/PHPWord/Writer/Word2007/Document.php +++ b/Classes/PHPWord/Writer/Word2007/Document.php @@ -25,41 +25,55 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_Word2007_Document - */ -class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base +namespace PhpOffice\PhpWord\Writer\Word2007; + +use PhpOffice\PhpWord\Section\Footnote; +use PhpOffice\PhpWord\Section\Image; +use PhpOffice\PhpWord\Section\Link; +use PhpOffice\PhpWord\Section\ListItem; +use PhpOffice\PhpWord\Section\MemoryImage; +use PhpOffice\PhpWord\Section\Object; +use PhpOffice\PhpWord\Section\PageBreak; +use PhpOffice\PhpWord\Section\Table; +use PhpOffice\PhpWord\Section\Text; +use PhpOffice\PhpWord\Section\TextBreak; +use PhpOffice\PhpWord\Section\TextRun; +use PhpOffice\PhpWord\Section\Title; +use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\TOC; + +class Document extends Base { - - public function writeDocument(PHPWord $pPHPWord = null) + public function writeDocument(PHPWord $phpWord = null) { // Create XML writer - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); // w:document - $objWriter->startElement('w:document'); + $xmlWriter->startElement('w:document'); - $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); + $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); + $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); + $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); + $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - $objWriter->startElement('w:body'); + $xmlWriter->startElement('w:body'); - $_sections = $pPHPWord->getSections(); + $_sections = $phpWord->getSections(); $countSections = count($_sections); $pSection = 0; @@ -70,60 +84,60 @@ public function writeDocument(PHPWord $pPHPWord = null) $_elements = $section->getElements(); foreach ($_elements as $element) { - if ($element instanceof PHPWord_Section_Text) { - $this->_writeText($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_TextRun) { - $this->_writeTextRun($objWriter, $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_TextBreak) { - $this->_writeTextBreak($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 || - $element instanceof PHPWord_Section_MemoryImage + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof Link) { + $this->_writeLink($xmlWriter, $element); + } elseif ($element instanceof Title) { + $this->_writeTitle($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter, $element); + } elseif ($element instanceof PageBreak) { + $this->_writePageBreak($xmlWriter); + } elseif ($element instanceof Table) { + $this->_writeTable($xmlWriter, $element); + } elseif ($element instanceof ListItem) { + $this->_writeListItem($xmlWriter, $element); + } elseif ($element instanceof Image || + $element instanceof MemoryImage ) { - $this->_writeImage($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Object) { - $this->_writeObject($objWriter, $element); - } elseif ($element instanceof PHPWord_TOC) { - $this->_writeTOC($objWriter); - } elseif ($element instanceof PHPWord_Section_Footnote) { - $this->_writeFootnoteReference($objWriter, $element); + $this->_writeImage($xmlWriter, $element); + } elseif ($element instanceof Object) { + $this->_writeObject($xmlWriter, $element); + } elseif ($element instanceof TOC) { + $this->_writeTOC($xmlWriter); + } elseif ($element instanceof Footnote) { + $this->_writeFootnoteReference($xmlWriter, $element); } } if ($pSection == $countSections) { - $this->_writeEndSection($objWriter, $section); + $this->_writeEndSection($xmlWriter, $section); } else { - $this->_writeSection($objWriter, $section); + $this->_writeSection($xmlWriter, $section); } } } - $objWriter->endElement(); // End w:body - $objWriter->endElement(); // End w:document + $xmlWriter->endElement(); // End w:body + $xmlWriter->endElement(); // End w:document // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } - private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) + private function _writeSection(XMLWriter $xmlWriter = null, Section $section) { - $objWriter->startElement('w:p'); - $objWriter->startElement('w:pPr'); - $this->_writeEndSection($objWriter, $section, 3); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:pPr'); + $this->_writeEndSection($xmlWriter, $section, 3); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) + private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section) { $settings = $section->getSettings(); $_headers = $section->getHeaders(); @@ -146,167 +160,167 @@ private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PH $colsSpace = $settings->getColsSpace(); $breakType = $settings->getBreakType(); - $objWriter->startElement('w:sectPr'); + $xmlWriter->startElement('w:sectPr'); foreach ($_headers as &$_header) { $rId = $_header->getRelationId(); - $objWriter->startElement('w:headerReference'); - $objWriter->writeAttribute('w:type', $_header->getType()); - $objWriter->writeAttribute('r:id', 'rId' . $rId); - $objWriter->endElement(); + $xmlWriter->startElement('w:headerReference'); + $xmlWriter->writeAttribute('w:type', $_header->getType()); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->endElement(); } if ($section->hasDifferentFirstPage()) { - $objWriter->startElement('w:titlePg'); - $objWriter->endElement(); + $xmlWriter->startElement('w:titlePg'); + $xmlWriter->endElement(); } if (!is_null($breakType)) { - $objWriter->startElement('w:type'); - $objWriter->writeAttribute('w:val', $breakType); - $objWriter->endElement(); + $xmlWriter->startElement('w:type'); + $xmlWriter->writeAttribute('w:val', $breakType); + $xmlWriter->endElement(); } if (!is_null($_footer)) { $rId = $_footer->getRelationId(); - $objWriter->startElement('w:footerReference'); - $objWriter->writeAttribute('w:type', 'default'); - $objWriter->writeAttribute('r:id', 'rId' . $rId); - $objWriter->endElement(); + $xmlWriter->startElement('w:footerReference'); + $xmlWriter->writeAttribute('w:type', 'default'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->endElement(); } - $objWriter->startElement('w:pgSz'); - $objWriter->writeAttribute('w:w', $pgSzW); - $objWriter->writeAttribute('w:h', $pgSzH); + $xmlWriter->startElement('w:pgSz'); + $xmlWriter->writeAttribute('w:w', $pgSzW); + $xmlWriter->writeAttribute('w:h', $pgSzH); if (!is_null($orientation) && strtolower($orientation) != 'portrait') { - $objWriter->writeAttribute('w:orient', $orientation); + $xmlWriter->writeAttribute('w:orient', $orientation); } - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->startElement('w:pgMar'); - $objWriter->writeAttribute('w:top', $marginTop); - $objWriter->writeAttribute('w:right', $marginRight); - $objWriter->writeAttribute('w:bottom', $marginBottom); - $objWriter->writeAttribute('w:left', $marginLeft); - $objWriter->writeAttribute('w:header', $headerHeight); - $objWriter->writeAttribute('w:footer', $footerHeight); - $objWriter->writeAttribute('w:gutter', '0'); - $objWriter->endElement(); + $xmlWriter->startElement('w:pgMar'); + $xmlWriter->writeAttribute('w:top', $marginTop); + $xmlWriter->writeAttribute('w:right', $marginRight); + $xmlWriter->writeAttribute('w:bottom', $marginBottom); + $xmlWriter->writeAttribute('w:left', $marginLeft); + $xmlWriter->writeAttribute('w:header', $headerHeight); + $xmlWriter->writeAttribute('w:footer', $footerHeight); + $xmlWriter->writeAttribute('w:gutter', '0'); + $xmlWriter->endElement(); if (!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) { $borderColor = $settings->getBorderColor(); - $objWriter->startElement('w:pgBorders'); - $objWriter->writeAttribute('w:offsetFrom', 'page'); + $xmlWriter->startElement('w:pgBorders'); + $xmlWriter->writeAttribute('w:offsetFrom', 'page'); if (!is_null($borders[0])) { - $objWriter->startElement('w:top'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $borders[0]); - $objWriter->writeAttribute('w:space', '24'); - $objWriter->writeAttribute('w:color', $borderColor[0]); - $objWriter->endElement(); + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $borders[0]); + $xmlWriter->writeAttribute('w:space', '24'); + $xmlWriter->writeAttribute('w:color', $borderColor[0]); + $xmlWriter->endElement(); } if (!is_null($borders[1])) { - $objWriter->startElement('w:left'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $borders[1]); - $objWriter->writeAttribute('w:space', '24'); - $objWriter->writeAttribute('w:color', $borderColor[1]); - $objWriter->endElement(); + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $borders[1]); + $xmlWriter->writeAttribute('w:space', '24'); + $xmlWriter->writeAttribute('w:color', $borderColor[1]); + $xmlWriter->endElement(); } if (!is_null($borders[2])) { - $objWriter->startElement('w:right'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $borders[2]); - $objWriter->writeAttribute('w:space', '24'); - $objWriter->writeAttribute('w:color', $borderColor[2]); - $objWriter->endElement(); + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $borders[2]); + $xmlWriter->writeAttribute('w:space', '24'); + $xmlWriter->writeAttribute('w:color', $borderColor[2]); + $xmlWriter->endElement(); } if (!is_null($borders[3])) { - $objWriter->startElement('w:bottom'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $borders[3]); - $objWriter->writeAttribute('w:space', '24'); - $objWriter->writeAttribute('w:color', $borderColor[3]); - $objWriter->endElement(); + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $borders[3]); + $xmlWriter->writeAttribute('w:space', '24'); + $xmlWriter->writeAttribute('w:color', $borderColor[3]); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); } // Page numbering if (null !== $settings->getPageNumberingStart()) { - $objWriter->startElement('w:pgNumType'); - $objWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart()); - $objWriter->endElement(); + $xmlWriter->startElement('w:pgNumType'); + $xmlWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart()); + $xmlWriter->endElement(); } - $objWriter->startElement('w:cols'); - $objWriter->writeAttribute('w:num', $colsNum); - $objWriter->writeAttribute('w:space', $colsSpace); - $objWriter->endElement(); + $xmlWriter->startElement('w:cols'); + $xmlWriter->writeAttribute('w:num', $colsNum); + $xmlWriter->writeAttribute('w:space', $colsSpace); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); } - private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null) + private function _writePageBreak(XMLWriter $xmlWriter = null) { - $objWriter->startElement('w:p'); - $objWriter->startElement('w:r'); - $objWriter->startElement('w:br'); - $objWriter->writeAttribute('w:type', 'page'); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:br'); + $xmlWriter->writeAttribute('w:type', 'page'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - public function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem) + public function _writeListItem(XMLWriter $xmlWriter = null, ListItem $listItem) { $textObject = $listItem->getTextObject(); $text = $textObject->getText(); $styleParagraph = $textObject->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; $depth = $listItem->getDepth(); $listType = $listItem->getStyle()->getListType(); - $objWriter->startElement('w:p'); - $objWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:pPr'); if ($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph, true); + $this->_writeParagraphStyle($xmlWriter, $styleParagraph, true); } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); } - $objWriter->startElement('w:numPr'); + $xmlWriter->startElement('w:numPr'); - $objWriter->startElement('w:ilvl'); - $objWriter->writeAttribute('w:val', $depth); - $objWriter->endElement(); + $xmlWriter->startElement('w:ilvl'); + $xmlWriter->writeAttribute('w:val', $depth); + $xmlWriter->endElement(); - $objWriter->startElement('w:numId'); - $objWriter->writeAttribute('w:val', $listType); - $objWriter->endElement(); + $xmlWriter->startElement('w:numId'); + $xmlWriter->writeAttribute('w:val', $listType); + $xmlWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $this->_writeText($objWriter, $textObject, true); + $this->_writeText($xmlWriter, $textObject, true); - $objWriter->endElement(); + $xmlWriter->endElement(); } - protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object) + protected function _writeObject(XMLWriter $xmlWriter = null, Object $object) { $rIdObject = $object->getRelationId(); $rIdImage = $object->getImageRelationId(); @@ -320,172 +334,172 @@ protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPW $align = $style->getAlign(); - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); if (!is_null($align)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:jc'); - $objWriter->writeAttribute('w:val', $align); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $align); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); - $objWriter->startElement('w:object'); - $objWriter->writeAttribute('w:dxaOrig', '249'); - $objWriter->writeAttribute('w:dyaOrig', '160'); + $xmlWriter->startElement('w:object'); + $xmlWriter->writeAttribute('w:dxaOrig', '249'); + $xmlWriter->writeAttribute('w:dyaOrig', '160'); - $objWriter->startElement('v:shape'); - $objWriter->writeAttribute('id', $shapeId); - $objWriter->writeAttribute('type', '#_x0000_t75'); - $objWriter->writeAttribute('style', 'width:104px;height:67px'); - $objWriter->writeAttribute('o:ole', ''); + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('id', $shapeId); + $xmlWriter->writeAttribute('type', '#_x0000_t75'); + $xmlWriter->writeAttribute('style', 'width:104px;height:67px'); + $xmlWriter->writeAttribute('o:ole', ''); - $objWriter->startElement('v:imagedata'); - $objWriter->writeAttribute('r:id', 'rId' . $rIdImage); - $objWriter->writeAttribute('o:title', ''); - $objWriter->endElement(); + $xmlWriter->startElement('v:imagedata'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rIdImage); + $xmlWriter->writeAttribute('o:title', ''); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->startElement('o:OLEObject'); - $objWriter->writeAttribute('Type', 'Embed'); - $objWriter->writeAttribute('ProgID', 'Package'); - $objWriter->writeAttribute('ShapeID', $shapeId); - $objWriter->writeAttribute('DrawAspect', 'Icon'); - $objWriter->writeAttribute('ObjectID', '_' . $objectId); - $objWriter->writeAttribute('r:id', 'rId' . $rIdObject); - $objWriter->endElement(); + $xmlWriter->startElement('o:OLEObject'); + $xmlWriter->writeAttribute('Type', 'Embed'); + $xmlWriter->writeAttribute('ProgID', 'Package'); + $xmlWriter->writeAttribute('ShapeID', $shapeId); + $xmlWriter->writeAttribute('DrawAspect', 'Icon'); + $xmlWriter->writeAttribute('ObjectID', '_' . $objectId); + $xmlWriter->writeAttribute('r:id', 'rId' . $rIdObject); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:r - $objWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } - private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null) + private function _writeTOC(XMLWriter $xmlWriter = null) { - $titles = PHPWord_TOC::getTitles(); - $styleFont = PHPWord_TOC::getStyleFont(); + $titles = TOC::getTitles(); + $styleFont = TOC::getStyleFont(); - $styleTOC = PHPWord_TOC::getStyleTOC(); + $styleTOC = TOC::getStyleTOC(); $fIndent = $styleTOC->getIndent(); $tabLeader = $styleTOC->getTabLeader(); $tabPos = $styleTOC->getTabPos(); - $isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + $isObject = ($styleFont instanceof Font) ? true : false; for ($i = 0; $i < count($titles); $i++) { $title = $titles[$i]; $indent = ($title['depth'] - 1) * $fIndent; - $objWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); - $objWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pPr'); if ($isObject && !is_null($styleFont->getParagraphStyle())) { - $this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle()); + $this->_writeParagraphStyle($xmlWriter, $styleFont->getParagraphStyle()); } if ($indent > 0) { - $objWriter->startElement('w:ind'); - $objWriter->writeAttribute('w:left', $indent); - $objWriter->endElement(); + $xmlWriter->startElement('w:ind'); + $xmlWriter->writeAttribute('w:left', $indent); + $xmlWriter->endElement(); } if (!empty($styleFont) && !$isObject) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->startElement('w:tabs'); - $objWriter->startElement('w:tab'); - $objWriter->writeAttribute('w:val', 'right'); + $xmlWriter->startElement('w:tabs'); + $xmlWriter->startElement('w:tab'); + $xmlWriter->writeAttribute('w:val', 'right'); if (!empty($tabLeader)) { - $objWriter->writeAttribute('w:leader', $tabLeader); + $xmlWriter->writeAttribute('w:leader', $tabLeader); } - $objWriter->writeAttribute('w:pos', $tabPos); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->writeAttribute('w:pos', $tabPos); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); // w:pPr + $xmlWriter->endElement(); // w:pPr if ($i == 0) { - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'begin'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('w:r'); - $objWriter->startElement('w:instrText'); - $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRaw('TOC \o "1-9" \h \z \u'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'separate'); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw('TOC \o "1-9" \h \z \u'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'separate'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->startElement('w:hyperlink'); - $objWriter->writeAttribute('w:anchor', $title['anchor']); - $objWriter->writeAttribute('w:history', '1'); + $xmlWriter->startElement('w:hyperlink'); + $xmlWriter->writeAttribute('w:anchor', $title['anchor']); + $xmlWriter->writeAttribute('w:history', '1'); - $objWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); if ($isObject) { - $this->_writeTextStyle($objWriter, $styleFont); + $this->_writeTextStyle($xmlWriter, $styleFont); } - $objWriter->startElement('w:t'); - $objWriter->writeRaw($title['text']); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('w:r'); - $objWriter->writeElement('w:tab', null); - $objWriter->endElement(); - - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'begin'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('w:r'); - $objWriter->startElement('w:instrText'); - $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'end'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->endElement(); // w:hyperlink - - $objWriter->endElement(); // w:p + $xmlWriter->startElement('w:t'); + $xmlWriter->writeRaw($title['text']); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->writeElement('w:tab', null); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); // w:hyperlink + + $xmlWriter->endElement(); // w:p } - $objWriter->startElement('w:p'); - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'end'); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } diff --git a/Classes/PHPWord/Writer/Word2007/DocumentRels.php b/Classes/PHPWord/Writer/Word2007/DocumentRels.php index 9817a31fa9..d8e3396b6a 100755 --- a/Classes/PHPWord/Writer/Word2007/DocumentRels.php +++ b/Classes/PHPWord/Writer/Word2007/DocumentRels.php @@ -25,32 +25,32 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_Word2007_DocumentRels - */ -class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_WriterPart -{ +namespace PhpOffice\PhpWord\Writer\Word2007; +use PhpOffice\PhpWord\Shared\XMLWriter; + +class DocumentRels extends WriterPart +{ public function writeDocumentRels($_relsCollection) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); // Relationships - $objWriter->startElement('Relationships'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + $xmlWriter->startElement('Relationships'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // Relationship word/document.xml $this->_writeRelationship( - $objWriter, + $xmlWriter, 1, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', 'styles.xml' @@ -58,7 +58,7 @@ public function writeDocumentRels($_relsCollection) // Relationship word/numbering.xml $this->_writeRelationship( - $objWriter, + $xmlWriter, 2, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering', 'numbering.xml' @@ -66,7 +66,7 @@ public function writeDocumentRels($_relsCollection) // Relationship word/settings.xml $this->_writeRelationship( - $objWriter, + $xmlWriter, 3, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings', 'settings.xml' @@ -74,7 +74,7 @@ public function writeDocumentRels($_relsCollection) // Relationship word/settings.xml $this->_writeRelationship( - $objWriter, + $xmlWriter, 4, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', 'theme/theme1.xml' @@ -82,7 +82,7 @@ public function writeDocumentRels($_relsCollection) // Relationship word/settings.xml $this->_writeRelationship( - $objWriter, + $xmlWriter, 5, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings', 'webSettings.xml' @@ -90,7 +90,7 @@ public function writeDocumentRels($_relsCollection) // Relationship word/settings.xml $this->_writeRelationship( - $objWriter, + $xmlWriter, 6, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable', 'fontTable.xml' @@ -104,7 +104,7 @@ public function writeDocumentRels($_relsCollection) $targetMode = ($relationType == 'hyperlink') ? 'External' : ''; $this->_writeRelationship( - $objWriter, + $xmlWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName, @@ -113,28 +113,28 @@ public function writeDocumentRels($_relsCollection) } - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } public function writeHeaderFooterRels($_relsCollection) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); // Relationships - $objWriter->startElement('Relationships'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + $xmlWriter->startElement('Relationships'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // Relationships to Images / Embeddings / Headers / Footers foreach ($_relsCollection as $relation) { @@ -143,7 +143,7 @@ public function writeHeaderFooterRels($_relsCollection) $relationId = $relation['rID']; $this->_writeRelationship( - $objWriter, + $xmlWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName @@ -151,13 +151,13 @@ public function writeHeaderFooterRels($_relsCollection) } - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } - private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') + private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { if ($pType != '' && $pTarget != '') { if (strpos($pId, 'rId') === false) { @@ -165,16 +165,16 @@ private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, } // Write relationship - $objWriter->startElement('Relationship'); - $objWriter->writeAttribute('Id', $pId); - $objWriter->writeAttribute('Type', $pType); - $objWriter->writeAttribute('Target', $pTarget); + $xmlWriter->startElement('Relationship'); + $xmlWriter->writeAttribute('Id', $pId); + $xmlWriter->writeAttribute('Type', $pType); + $xmlWriter->writeAttribute('Target', $pTarget); if ($pTargetMode != '') { - $objWriter->writeAttribute('TargetMode', $pTargetMode); + $xmlWriter->writeAttribute('TargetMode', $pTargetMode); } - $objWriter->endElement(); + $xmlWriter->endElement(); } else { throw new Exception("Invalid parameters passed."); } diff --git a/Classes/PHPWord/Writer/Word2007/Footer.php b/Classes/PHPWord/Writer/Word2007/Footer.php index 6ee18d66c7..59c24638e7 100755 --- a/Classes/PHPWord/Writer/Word2007/Footer.php +++ b/Classes/PHPWord/Writer/Word2007/Footer.php @@ -25,59 +25,66 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_Word2007_Footer - */ -class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base -{ +namespace PhpOffice\PhpWord\Writer\Word2007; - public function writeFooter(PHPWord_Section_Footer $footer) +use PhpOffice\PhpWord\Section\Footer\PreserveText; +use PhpOffice\PhpWord\Section\Image; +use PhpOffice\PhpWord\Section\MemoryImage; +use PhpOffice\PhpWord\Section\Table; +use PhpOffice\PhpWord\Section\Text; +use PhpOffice\PhpWord\Section\TextBreak; +use PhpOffice\PhpWord\Section\TextRun; +use PhpOffice\PhpWord\Shared\XMLWriter; + +class Footer extends Base +{ + public function writeFooter(PhpOffice\PhpWord\Section\Footer $footer) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $objWriter->startElement('w:ftr'); - $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); + $xmlWriter->startElement('w:ftr'); + $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); + $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); + $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); + $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); $_elements = $footer->getElements(); foreach ($_elements as $element) { - if ($element instanceof PHPWord_Section_Text) { - $this->_writeText($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_TextRun) { - $this->_writeTextRun($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_TextBreak) { - $this->_writeTextBreak($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Table) { - $this->_writeTable($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Image || - $element instanceof PHPWord_Section_MemoryImage + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter, $element); + } elseif ($element instanceof Table) { + $this->_writeTable($xmlWriter, $element); + } elseif ($element instanceof Image || + $element instanceof MemoryImage ) { - $this->_writeImage($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) { - $this->_writePreserveText($objWriter, $element); + $this->_writeImage($xmlWriter, $element); + } elseif ($element instanceof PreserveText) { + $this->_writePreserveText($xmlWriter, $element); } } - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } } diff --git a/Classes/PHPWord/Writer/Word2007/Footnotes.php b/Classes/PHPWord/Writer/Word2007/Footnotes.php index 28d087c7d2..fae7641b00 100644 --- a/Classes/PHPWord/Writer/Word2007/Footnotes.php +++ b/Classes/PHPWord/Writer/Word2007/Footnotes.php @@ -25,59 +25,63 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord\Writer\Word2007; -class PHPWord_Writer_Word2007_Footnotes extends PHPWord_Writer_Word2007_Base +use PhpOffice\PhpWord\Section\Footnote; +use PhpOffice\PhpWord\Shared\XMLWriter; + +class Footnotes extends Base { public function writeFootnotes($allFootnotesCollection) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $objWriter->startElement('w:footnotes'); - $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + $xmlWriter->startElement('w:footnotes'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); // write separator and continuation separator - $objWriter->startElement('w:footnote'); - $objWriter->writeAttribute('w:id', 0); - $objWriter->writeAttribute('w:type', 'separator'); - $objWriter->startElement('w:p'); - $objWriter->startElement('w:r'); - $objWriter->startElement('w:separator'); - $objWriter->endElement(); // w:separator - $objWriter->endElement(); // w:r - $objWriter->endElement(); // w:p - $objWriter->endElement(); // w:footnote + $xmlWriter->startElement('w:footnote'); + $xmlWriter->writeAttribute('w:id', 0); + $xmlWriter->writeAttribute('w:type', 'separator'); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:separator'); + $xmlWriter->endElement(); // w:separator + $xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:footnote - $objWriter->startElement('w:footnote'); - $objWriter->writeAttribute('w:id', 1); - $objWriter->writeAttribute('w:type', 'continuationSeparator'); - $objWriter->startElement('w:p'); - $objWriter->startElement('w:r'); - $objWriter->startElement('w:continuationSeparator'); - $objWriter->endElement(); // w:continuationSeparator - $objWriter->endElement(); // w:r - $objWriter->endElement(); // w:p - $objWriter->endElement(); // w:footnote + $xmlWriter->startElement('w:footnote'); + $xmlWriter->writeAttribute('w:id', 1); + $xmlWriter->writeAttribute('w:type', 'continuationSeparator'); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:continuationSeparator'); + $xmlWriter->endElement(); // w:continuationSeparator + $xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:footnote foreach ($allFootnotesCollection as $footnote) { - if ($footnote instanceof PHPWord_Section_Footnote) { - $this->_writeFootnote($objWriter, $footnote); + if ($footnote instanceof Footnote) { + $this->_writeFootnote($xmlWriter, $footnote); } } - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } } diff --git a/Classes/PHPWord/Writer/Word2007/FootnotesRels.php b/Classes/PHPWord/Writer/Word2007/FootnotesRels.php index 0e562b593a..29b2e70159 100644 --- a/Classes/PHPWord/Writer/Word2007/FootnotesRels.php +++ b/Classes/PHPWord/Writer/Word2007/FootnotesRels.php @@ -25,25 +25,28 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord\Writer\Word2007; -class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_WriterPart +use PhpOffice\PhpWord\Shared\XMLWriter; + +class FootnotesRels extends WriterPart { public function writeFootnotesRels($_relsCollection) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); // Relationships - $objWriter->startElement('Relationships'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + $xmlWriter->startElement('Relationships'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // Relationships to Links foreach ($_relsCollection as $relation) { @@ -52,16 +55,16 @@ public function writeFootnotesRels($_relsCollection) $relationId = $relation['rID']; $targetMode = ($relationType == 'hyperlink') ? 'External' : ''; - $this->_writeRelationship($objWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName, $targetMode); + $this->_writeRelationship($xmlWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName, $targetMode); } - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } - private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') + private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { if ($pType != '' && $pTarget != '') { if (strpos($pId, 'rId') === false) { @@ -69,16 +72,16 @@ private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, } // Write relationship - $objWriter->startElement('Relationship'); - $objWriter->writeAttribute('Id', $pId); - $objWriter->writeAttribute('Type', $pType); - $objWriter->writeAttribute('Target', $pTarget); + $xmlWriter->startElement('Relationship'); + $xmlWriter->writeAttribute('Id', $pId); + $xmlWriter->writeAttribute('Type', $pType); + $xmlWriter->writeAttribute('Target', $pTarget); if ($pTargetMode != '') { - $objWriter->writeAttribute('TargetMode', $pTargetMode); + $xmlWriter->writeAttribute('TargetMode', $pTargetMode); } - $objWriter->endElement(); + $xmlWriter->endElement(); } else { throw new Exception("Invalid parameters passed."); } diff --git a/Classes/PHPWord/Writer/Word2007/Header.php b/Classes/PHPWord/Writer/Word2007/Header.php index 59eebd9178..23119378eb 100755 --- a/Classes/PHPWord/Writer/Word2007/Header.php +++ b/Classes/PHPWord/Writer/Word2007/Header.php @@ -25,63 +25,70 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_Word2007_Header - */ -class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base -{ +namespace PhpOffice\PhpWord\Writer\Word2007; - public function writeHeader(PHPWord_Section_Header $header) +use PhpOffice\PhpWord\Section\Footer\PreserveText; +use PhpOffice\PhpWord\Section\Image; +use PhpOffice\PhpWord\Section\MemoryImage; +use PhpOffice\PhpWord\Section\Table; +use PhpOffice\PhpWord\Section\Text; +use PhpOffice\PhpWord\Section\TextBreak; +use PhpOffice\PhpWord\Section\TextRun; +use PhpOffice\PhpWord\Shared\XMLWriter; + +class Header extends Base +{ + public function writeHeader(PhpOffice\PhpWord\Section\Header $header) { // Create XML writer if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $objWriter->startElement('w:hdr'); - $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); + $xmlWriter->startElement('w:hdr'); + $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); + $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); + $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); + $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); $_elements = $header->getElements(); foreach ($_elements as $element) { - if ($element instanceof PHPWord_Section_Text) { - $this->_writeText($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_TextRun) { - $this->_writeTextRun($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_TextBreak) { - $this->_writeTextBreak($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Table) { - $this->_writeTable($objWriter, $element); - } elseif ($element instanceof PHPWord_Section_Image || - $element instanceof PHPWord_Section_MemoryImage + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter, $element); + } elseif ($element instanceof Table) { + $this->_writeTable($xmlWriter, $element); + } elseif ($element instanceof Image || + $element instanceof MemoryImage ) { if (!$element->getIsWatermark()) { - $this->_writeImage($objWriter, $element); + $this->_writeImage($xmlWriter, $element); } else { - $this->_writeWatermark($objWriter, $element); + $this->_writeWatermark($xmlWriter, $element); } - } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) { - $this->_writePreserveText($objWriter, $element); + } elseif ($element instanceof PreserveText) { + $this->_writePreserveText($xmlWriter, $element); } } - $objWriter->endElement(); + $xmlWriter->endElement(); // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } } diff --git a/Classes/PHPWord/Writer/Word2007/Rels.php b/Classes/PHPWord/Writer/Word2007/Rels.php index 06eb59cc9f..5afd8bdc8e 100755 --- a/Classes/PHPWord/Writer/Word2007/Rels.php +++ b/Classes/PHPWord/Writer/Word2007/Rels.php @@ -25,34 +25,34 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_Word2007_Rels - */ -class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart -{ +namespace PhpOffice\PhpWord\Writer\Word2007; - public function writeRelationships(PHPWord $pPHPWord = null) +use PhpOffice\PhpWord\Shared\XMLWriter; + +class Rels extends WriterPart +{ + public function writeRelationships(PHPWord $phpWord = null) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); // Relationships - $objWriter->startElement('Relationships'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + $xmlWriter->startElement('Relationships'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $relationId = 1; // Relationship word/document.xml $this->_writeRelationship( - $objWriter, + $xmlWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', 'word/document.xml' @@ -60,7 +60,7 @@ public function writeRelationships(PHPWord $pPHPWord = null) // Relationship docProps/core.xml $this->_writeRelationship( - $objWriter, + $xmlWriter, ++$relationId, 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', 'docProps/core.xml' @@ -68,29 +68,28 @@ public function writeRelationships(PHPWord $pPHPWord = null) // Relationship docProps/app.xml $this->_writeRelationship( - $objWriter, + $xmlWriter, ++$relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', 'docProps/app.xml' ); - $objWriter->endElement(); + $xmlWriter->endElement(); - // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } /** * Write Override content type * - * @param PHPWord_Shared_XMLWriter $objWriter XML Writer + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param int $pId Relationship ID. rId will be prepended! * @param string $pType Relationship type * @param string $pTarget Relationship target * @param string $pTargetMode Relationship target mode * @throws Exception */ - private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') + private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { if ($pType != '' && $pTarget != '') { if (strpos($pId, 'rId') === false) { @@ -98,16 +97,16 @@ private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, } // Write relationship - $objWriter->startElement('Relationship'); - $objWriter->writeAttribute('Id', $pId); - $objWriter->writeAttribute('Type', $pType); - $objWriter->writeAttribute('Target', $pTarget); + $xmlWriter->startElement('Relationship'); + $xmlWriter->writeAttribute('Id', $pId); + $xmlWriter->writeAttribute('Type', $pType); + $xmlWriter->writeAttribute('Target', $pTarget); if ($pTargetMode != '') { - $objWriter->writeAttribute('TargetMode', $pTargetMode); + $xmlWriter->writeAttribute('TargetMode', $pTargetMode); } - $objWriter->endElement(); + $xmlWriter->endElement(); } else { throw new Exception("Invalid parameters passed."); } diff --git a/Classes/PHPWord/Writer/Word2007/Styles.php b/Classes/PHPWord/Writer/Word2007/Styles.php index 3724323e10..865e93cc0d 100755 --- a/Classes/PHPWord/Writer/Word2007/Styles.php +++ b/Classes/PHPWord/Writer/Word2007/Styles.php @@ -25,57 +25,61 @@ * @version 0.8.0 */ -/** - * Class PHPWord_Writer_Word2007_Styles - */ -class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base -{ +namespace PhpOffice\PhpWord\Writer\Word2007; +use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\Style\TableFull; + +class Styles extends Base +{ private $_document; - public function writeStyles(PHPWord $pPHPWord = null) + public function writeStyles(PHPWord $phpWord = null) { // Create XML writer - $objWriter = null; + $xmlWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } - $this->_document = $pPHPWord; + $this->_document = $phpWord; // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $objWriter->startElement('w:styles'); + $xmlWriter->startElement('w:styles'); - $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); // Write DocDefaults - $this->_writeDocDefaults($objWriter); + $this->_writeDocDefaults($xmlWriter); // Write Style Definitions - $styles = PHPWord_Style::getStyles(); + $styles = Style::getStyles(); // Write normal paragraph style $normalStyle = null; if (array_key_exists('Normal', $styles)) { $normalStyle = $styles['Normal']; } - $objWriter->startElement('w:style'); - $objWriter->writeAttribute('w:type', 'paragraph'); - $objWriter->writeAttribute('w:default', '1'); - $objWriter->writeAttribute('w:styleId', 'Normal'); - $objWriter->startElement('w:name'); - $objWriter->writeAttribute('w:val', 'Normal'); - $objWriter->endElement(); + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', 'paragraph'); + $xmlWriter->writeAttribute('w:default', '1'); + $xmlWriter->writeAttribute('w:styleId', 'Normal'); + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', 'Normal'); + $xmlWriter->endElement(); if (!is_null($normalStyle)) { - $this->_writeParagraphStyle($objWriter, $normalStyle); + $this->_writeParagraphStyle($xmlWriter, $normalStyle); } - $objWriter->endElement(); + $xmlWriter->endElement(); // Write other styles if (count($styles) > 0) { @@ -83,7 +87,7 @@ public function writeStyles(PHPWord $pPHPWord = null) if ($styleName == 'Normal') { continue; } - if ($style instanceof PHPWord_Style_Font) { + if ($style instanceof Font) { $paragraphStyle = $style->getParagraphStyle(); $styleType = $style->getStyleType(); @@ -94,94 +98,94 @@ public function writeStyles(PHPWord $pPHPWord = null) $type = 'paragraph'; } - $objWriter->startElement('w:style'); - $objWriter->writeAttribute('w:type', $type); + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', $type); if ($styleType == 'title') { $arrStyle = explode('_', $styleName); $styleId = 'Heading' . $arrStyle[1]; $styleName = 'heading ' . $arrStyle[1]; $styleLink = 'Heading' . $arrStyle[1] . 'Char'; - $objWriter->writeAttribute('w:styleId', $styleId); + $xmlWriter->writeAttribute('w:styleId', $styleId); - $objWriter->startElement('w:link'); - $objWriter->writeAttribute('w:val', $styleLink); - $objWriter->endElement(); + $xmlWriter->startElement('w:link'); + $xmlWriter->writeAttribute('w:val', $styleLink); + $xmlWriter->endElement(); } - $objWriter->startElement('w:name'); - $objWriter->writeAttribute('w:val', $styleName); - $objWriter->endElement(); + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $styleName); + $xmlWriter->endElement(); if (!is_null($paragraphStyle)) { // Point parent style to Normal - $objWriter->startElement('w:basedOn'); - $objWriter->writeAttribute('w:val', 'Normal'); - $objWriter->endElement(); - $this->_writeParagraphStyle($objWriter, $paragraphStyle); + $xmlWriter->startElement('w:basedOn'); + $xmlWriter->writeAttribute('w:val', 'Normal'); + $xmlWriter->endElement(); + $this->_writeParagraphStyle($xmlWriter, $paragraphStyle); } - $this->_writeTextStyle($objWriter, $style); + $this->_writeTextStyle($xmlWriter, $style); - $objWriter->endElement(); + $xmlWriter->endElement(); - } elseif ($style instanceof PHPWord_Style_Paragraph) { - $objWriter->startElement('w:style'); - $objWriter->writeAttribute('w:type', 'paragraph'); - $objWriter->writeAttribute('w:customStyle', '1'); - $objWriter->writeAttribute('w:styleId', $styleName); + } elseif ($style instanceof Paragraph) { + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', 'paragraph'); + $xmlWriter->writeAttribute('w:customStyle', '1'); + $xmlWriter->writeAttribute('w:styleId', $styleName); - $objWriter->startElement('w:name'); - $objWriter->writeAttribute('w:val', $styleName); - $objWriter->endElement(); + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $styleName); + $xmlWriter->endElement(); // Parent style $basedOn = $style->getBasedOn(); if (!is_null($basedOn)) { - $objWriter->startElement('w:basedOn'); - $objWriter->writeAttribute('w:val', $basedOn); - $objWriter->endElement(); + $xmlWriter->startElement('w:basedOn'); + $xmlWriter->writeAttribute('w:val', $basedOn); + $xmlWriter->endElement(); } // Next paragraph style $next = $style->getNext(); if (!is_null($next)) { - $objWriter->startElement('w:next'); - $objWriter->writeAttribute('w:val', $next); - $objWriter->endElement(); + $xmlWriter->startElement('w:next'); + $xmlWriter->writeAttribute('w:val', $next); + $xmlWriter->endElement(); } - $this->_writeParagraphStyle($objWriter, $style); - $objWriter->endElement(); + $this->_writeParagraphStyle($xmlWriter, $style); + $xmlWriter->endElement(); - } elseif ($style instanceof PHPWord_Style_TableFull) { - $objWriter->startElement('w:style'); - $objWriter->writeAttribute('w:type', 'table'); - $objWriter->writeAttribute('w:customStyle', '1'); - $objWriter->writeAttribute('w:styleId', $styleName); + } elseif ($style instanceof TableFull) { + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', 'table'); + $xmlWriter->writeAttribute('w:customStyle', '1'); + $xmlWriter->writeAttribute('w:styleId', $styleName); - $objWriter->startElement('w:name'); - $objWriter->writeAttribute('w:val', $styleName); - $objWriter->endElement(); + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $styleName); + $xmlWriter->endElement(); - $objWriter->startElement('w:uiPriority'); - $objWriter->writeAttribute('w:val', '99'); - $objWriter->endElement(); + $xmlWriter->startElement('w:uiPriority'); + $xmlWriter->writeAttribute('w:val', '99'); + $xmlWriter->endElement(); - $this->_writeFullTableStyle($objWriter, $style); + $this->_writeFullTableStyle($xmlWriter, $style); - $objWriter->endElement(); + $xmlWriter->endElement(); } } } - $objWriter->endElement(); // w:styles + $xmlWriter->endElement(); // w:styles // Return - return $objWriter->getData(); + return $xmlWriter->getData(); } - private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_TableFull $style) + private function _writeFullTableStyle(XMLWriter $xmlWriter = null, TableFull $style) { $brdSz = $style->getBorderSize(); @@ -203,106 +207,106 @@ private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null $mBottom = (!is_null($cellMargin[3])) ? true : false; $margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false; - $objWriter->startElement('w:tblPr'); + $xmlWriter->startElement('w:tblPr'); if ($margins) { - $objWriter->startElement('w:tblCellMar'); + $xmlWriter->startElement('w:tblCellMar'); if ($mTop) { echo $margins[0]; - $objWriter->startElement('w:top'); - $objWriter->writeAttribute('w:w', $cellMargin[0]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:w', $cellMargin[0]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); } if ($mLeft) { - $objWriter->startElement('w:left'); - $objWriter->writeAttribute('w:w', $cellMargin[1]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:w', $cellMargin[1]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); } if ($mRight) { - $objWriter->startElement('w:right'); - $objWriter->writeAttribute('w:w', $cellMargin[2]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:w', $cellMargin[2]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); } if ($mBottom) { - $objWriter->startElement('w:bottom'); - $objWriter->writeAttribute('w:w', $cellMargin[3]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:w', $cellMargin[3]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); } if ($borders) { - $objWriter->startElement('w:tblBorders'); + $xmlWriter->startElement('w:tblBorders'); if ($bTop) { - $objWriter->startElement('w:top'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[0]); - $objWriter->writeAttribute('w:color', $brdCol[0]); - $objWriter->endElement(); + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[0]); + $xmlWriter->writeAttribute('w:color', $brdCol[0]); + $xmlWriter->endElement(); } if ($bLeft) { - $objWriter->startElement('w:left'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[1]); - $objWriter->writeAttribute('w:color', $brdCol[1]); - $objWriter->endElement(); + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[1]); + $xmlWriter->writeAttribute('w:color', $brdCol[1]); + $xmlWriter->endElement(); } if ($bRight) { - $objWriter->startElement('w:right'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[2]); - $objWriter->writeAttribute('w:color', $brdCol[2]); - $objWriter->endElement(); + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[2]); + $xmlWriter->writeAttribute('w:color', $brdCol[2]); + $xmlWriter->endElement(); } if ($bBottom) { - $objWriter->startElement('w:bottom'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[3]); - $objWriter->writeAttribute('w:color', $brdCol[3]); - $objWriter->endElement(); + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[3]); + $xmlWriter->writeAttribute('w:color', $brdCol[3]); + $xmlWriter->endElement(); } if ($bInsH) { - $objWriter->startElement('w:insideH'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[4]); - $objWriter->writeAttribute('w:color', $brdCol[4]); - $objWriter->endElement(); + $xmlWriter->startElement('w:insideH'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[4]); + $xmlWriter->writeAttribute('w:color', $brdCol[4]); + $xmlWriter->endElement(); } if ($bInsV) { - $objWriter->startElement('w:insideV'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[5]); - $objWriter->writeAttribute('w:color', $brdCol[5]); - $objWriter->endElement(); + $xmlWriter->startElement('w:insideV'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[5]); + $xmlWriter->writeAttribute('w:color', $brdCol[5]); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); if (!is_null($bgColor)) { - $objWriter->startElement('w:tcPr'); - $objWriter->startElement('w:shd'); - $objWriter->writeAttribute('w:val', 'clear'); - $objWriter->writeAttribute('w:color', 'auto'); - $objWriter->writeAttribute('w:fill', $bgColor); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->startElement('w:tcPr'); + $xmlWriter->startElement('w:shd'); + $xmlWriter->writeAttribute('w:val', 'clear'); + $xmlWriter->writeAttribute('w:color', 'auto'); + $xmlWriter->writeAttribute('w:fill', $bgColor); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } // First Row $firstRow = $style->getFirstRow(); if (!is_null($firstRow)) { - $this->_writeRowStyle($objWriter, 'firstRow', $firstRow); + $this->_writeRowStyle($xmlWriter, 'firstRow', $firstRow); } } - private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_TableFull $style) + private function _writeRowStyle(XMLWriter $xmlWriter = null, $type, TableFull $style) { $brdSz = $style->getBorderSize(); $brdCol = $style->getBorderColor(); @@ -314,81 +318,81 @@ private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $typ $bBottom = (!is_null($brdSz[3])) ? true : false; $borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false; - $objWriter->startElement('w:tblStylePr'); - $objWriter->writeAttribute('w:type', $type); + $xmlWriter->startElement('w:tblStylePr'); + $xmlWriter->writeAttribute('w:type', $type); - $objWriter->startElement('w:tcPr'); + $xmlWriter->startElement('w:tcPr'); if (!is_null($bgColor)) { - $objWriter->startElement('w:shd'); - $objWriter->writeAttribute('w:val', 'clear'); - $objWriter->writeAttribute('w:color', 'auto'); - $objWriter->writeAttribute('w:fill', $bgColor); - $objWriter->endElement(); + $xmlWriter->startElement('w:shd'); + $xmlWriter->writeAttribute('w:val', 'clear'); + $xmlWriter->writeAttribute('w:color', 'auto'); + $xmlWriter->writeAttribute('w:fill', $bgColor); + $xmlWriter->endElement(); } - $objWriter->startElement('w:tcBorders'); + $xmlWriter->startElement('w:tcBorders'); if ($bTop) { - $objWriter->startElement('w:top'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[0]); - $objWriter->writeAttribute('w:color', $brdCol[0]); - $objWriter->endElement(); + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[0]); + $xmlWriter->writeAttribute('w:color', $brdCol[0]); + $xmlWriter->endElement(); } if ($bLeft) { - $objWriter->startElement('w:left'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[1]); - $objWriter->writeAttribute('w:color', $brdCol[1]); - $objWriter->endElement(); + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[1]); + $xmlWriter->writeAttribute('w:color', $brdCol[1]); + $xmlWriter->endElement(); } if ($bRight) { - $objWriter->startElement('w:right'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[2]); - $objWriter->writeAttribute('w:color', $brdCol[2]); - $objWriter->endElement(); + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[2]); + $xmlWriter->writeAttribute('w:color', $brdCol[2]); + $xmlWriter->endElement(); } if ($bBottom) { - $objWriter->startElement('w:bottom'); - $objWriter->writeAttribute('w:val', 'single'); - $objWriter->writeAttribute('w:sz', $brdSz[3]); - $objWriter->writeAttribute('w:color', $brdCol[3]); - $objWriter->endElement(); + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[3]); + $xmlWriter->writeAttribute('w:color', $brdCol[3]); + $xmlWriter->endElement(); } - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); } - private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null) + private function _writeDocDefaults(XMLWriter $xmlWriter = null) { $fontName = $this->_document->getDefaultFontName(); $fontSize = $this->_document->getDefaultFontSize(); - $objWriter->startElement('w:docDefaults'); - $objWriter->startElement('w:rPrDefault'); - $objWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:docDefaults'); + $xmlWriter->startElement('w:rPrDefault'); + $xmlWriter->startElement('w:rPr'); - $objWriter->startElement('w:rFonts'); - $objWriter->writeAttribute('w:ascii', $fontName); - $objWriter->writeAttribute('w:hAnsi', $fontName); - $objWriter->writeAttribute('w:eastAsia', $fontName); - $objWriter->writeAttribute('w:cs', $fontName); - $objWriter->endElement(); + $xmlWriter->startElement('w:rFonts'); + $xmlWriter->writeAttribute('w:ascii', $fontName); + $xmlWriter->writeAttribute('w:hAnsi', $fontName); + $xmlWriter->writeAttribute('w:eastAsia', $fontName); + $xmlWriter->writeAttribute('w:cs', $fontName); + $xmlWriter->endElement(); - $objWriter->startElement('w:sz'); - $objWriter->writeAttribute('w:val', $fontSize * 2); - $objWriter->endElement(); + $xmlWriter->startElement('w:sz'); + $xmlWriter->writeAttribute('w:val', $fontSize * 2); + $xmlWriter->endElement(); - $objWriter->startElement('w:szCs'); - $objWriter->writeAttribute('w:val', $fontSize * 2); - $objWriter->endElement(); + $xmlWriter->startElement('w:szCs'); + $xmlWriter->writeAttribute('w:val', $fontSize * 2); + $xmlWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } diff --git a/Classes/PHPWord/Writer/Word2007/WriterPart.php b/Classes/PHPWord/Writer/Word2007/WriterPart.php index cc004254f3..bdd551c2c6 100755 --- a/Classes/PHPWord/Writer/Word2007/WriterPart.php +++ b/Classes/PHPWord/Writer/Word2007/WriterPart.php @@ -25,14 +25,15 @@ * @version 0.8.0 */ -/** - * Abstract Class PHPWord_Writer_Word2007_WriterPart - */ -abstract class PHPWord_Writer_Word2007_WriterPart +namespace PhpOffice\PhpWord\Writer\Word2007; + +use PhpOffice\PhpWord\Writer\IWriter; + +abstract class WriterPart { private $_parentWriter; - public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) + public function setParentWriter(IWriter $pWriter = null) { $this->_parentWriter = $pWriter; } @@ -42,7 +43,7 @@ public function getParentWriter() if (!is_null($this->_parentWriter)) { return $this->_parentWriter; } else { - throw new Exception("No parent PHPWord_Writer_IWriter assigned."); + throw new Exception("No parent IWriter assigned."); } } } diff --git a/README.md b/README.md index d35603d048..925fac672a 100755 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ $section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle'); // You can also put the appended element to local object like this: -$fontStyle = new PHPWord_Style_Font(); +$fontStyle = new PhpOffice\PhpWord\Style\Font(); $fontStyle->setBold(true); $fontStyle->setName('Verdana'); $fontStyle->setSize(22); @@ -111,8 +111,8 @@ $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); // Finally, write the document: -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save('helloWorld.docx'); +$xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007'); +$xmlWriter->save('helloWorld.docx'); ``` @@ -125,15 +125,15 @@ You can use PHPWord helper functions to convert inches, centimeters, or points t ```php // Paragraph with 6 points space after $PHPWord->addParagraphStyle('My Style', array( - 'spaceAfter' => PHPWord_Shared_Font::pointSizeToTwips(6)) + 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6)) ); $section = $PHPWord->createSection(); $sectionStyle = $section->getSettings(); // half inch left margin -$sectionStyle->setMarginLeft(PHPWord_Shared_Font::inchSizeToTwips(.5)); +$sectionStyle->setMarginLeft(PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); // 2 cm right margin -$sectionStyle->setMarginRight(PHPWord_Shared_Font::centimeterSizeToTwips(2)); +$sectionStyle->setMarginRight(PhpOffice\PhpWord\Shared\Font::centimeterSizeToTwips(2)); ``` diff --git a/Tests/PHPWord/AutoloaderTest.php b/Tests/PHPWord/AutoloaderTest.php index 03e16db073..d33d8ab536 100644 --- a/Tests/PHPWord/AutoloaderTest.php +++ b/Tests/PHPWord/AutoloaderTest.php @@ -46,4 +46,4 @@ public function testAutoload() 'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException class' ); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/DocumentPropertiesTest.php b/Tests/PHPWord/DocumentPropertiesTest.php index f98a9907b2..250f1b3ede 100644 --- a/Tests/PHPWord/DocumentPropertiesTest.php +++ b/Tests/PHPWord/DocumentPropertiesTest.php @@ -1,20 +1,18 @@ setCreator(); $this->assertEquals('', $oProperties->getCreator()); @@ -24,7 +22,7 @@ public function testCreator() public function testLastModifiedBy() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setLastModifiedBy(); $this->assertEquals('', $oProperties->getLastModifiedBy()); @@ -34,7 +32,7 @@ public function testLastModifiedBy() public function testCreated() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setCreated(); $this->assertEquals(time(), $oProperties->getCreated()); @@ -45,7 +43,7 @@ public function testCreated() public function testModified() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setModified(); $this->assertEquals(time(), $oProperties->getModified()); @@ -56,7 +54,7 @@ public function testModified() public function testTitle() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setTitle(); $this->assertEquals('', $oProperties->getTitle()); @@ -66,7 +64,7 @@ public function testTitle() public function testDescription() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setDescription(); $this->assertEquals('', $oProperties->getDescription()); @@ -76,7 +74,7 @@ public function testDescription() public function testSubject() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setSubject(); $this->assertEquals('', $oProperties->getSubject()); @@ -86,7 +84,7 @@ public function testSubject() public function testKeywords() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setKeywords(); $this->assertEquals('', $oProperties->getKeywords()); @@ -96,7 +94,7 @@ public function testKeywords() public function testCategory() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setCategory(); $this->assertEquals('', $oProperties->getCategory()); @@ -106,7 +104,7 @@ public function testCategory() public function testCompany() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setCompany(); $this->assertEquals('', $oProperties->getCompany()); @@ -116,7 +114,7 @@ public function testCompany() public function testManager() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setManager(); $this->assertEquals('', $oProperties->getManager()); @@ -126,30 +124,30 @@ public function testManager() public function testCustomProperty() { - $oProperties = new PHPWord_DocumentProperties(); + $oProperties = new DocumentProperties(); $oProperties->setCustomProperty('key1', null); $oProperties->setCustomProperty('key2', true); $oProperties->setCustomProperty('key3', 3); $oProperties->setCustomProperty('key4', 4.4); $oProperties->setCustomProperty('key5', 'value5'); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_STRING, + DocumentProperties::PROPERTY_TYPE_STRING, $oProperties->getCustomPropertyType('key1') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_BOOLEAN, + DocumentProperties::PROPERTY_TYPE_BOOLEAN, $oProperties->getCustomPropertyType('key2') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_INTEGER, + DocumentProperties::PROPERTY_TYPE_INTEGER, $oProperties->getCustomPropertyType('key3') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_FLOAT, + DocumentProperties::PROPERTY_TYPE_FLOAT, $oProperties->getCustomPropertyType('key4') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_STRING, + DocumentProperties::PROPERTY_TYPE_STRING, $oProperties->getCustomPropertyType('key5') ); $this->assertEquals(null, $oProperties->getCustomPropertyType('key6')); @@ -172,50 +170,50 @@ public function testCustomProperty() public function testConvertProperty() { - $this->assertEquals('', PHPWord_DocumentProperties::convertProperty('a', 'empty')); - $this->assertEquals(null, PHPWord_DocumentProperties::convertProperty('a', 'null')); - $this->assertEquals(8, PHPWord_DocumentProperties::convertProperty('8', 'int')); - $this->assertEquals(8, PHPWord_DocumentProperties::convertProperty('8.3', 'uint')); - $this->assertEquals(8.3, PHPWord_DocumentProperties::convertProperty('8.3', 'decimal')); - $this->assertEquals('8.3', PHPWord_DocumentProperties::convertProperty('8.3', 'lpstr')); - $this->assertEquals(strtotime('10/11/2013'), PHPWord_DocumentProperties::convertProperty('10/11/2013', 'date')); - $this->assertEquals(true, PHPWord_DocumentProperties::convertProperty('true', 'bool')); - $this->assertEquals(false, PHPWord_DocumentProperties::convertProperty('1', 'bool')); - $this->assertEquals('1', PHPWord_DocumentProperties::convertProperty('1', 'array')); - $this->assertEquals('1', PHPWord_DocumentProperties::convertProperty('1', '')); + $this->assertEquals('', DocumentProperties::convertProperty('a', 'empty')); + $this->assertEquals(null, DocumentProperties::convertProperty('a', 'null')); + $this->assertEquals(8, DocumentProperties::convertProperty('8', 'int')); + $this->assertEquals(8, DocumentProperties::convertProperty('8.3', 'uint')); + $this->assertEquals(8.3, DocumentProperties::convertProperty('8.3', 'decimal')); + $this->assertEquals('8.3', DocumentProperties::convertProperty('8.3', 'lpstr')); + $this->assertEquals(strtotime('10/11/2013'), DocumentProperties::convertProperty('10/11/2013', 'date')); + $this->assertEquals(true, DocumentProperties::convertProperty('true', 'bool')); + $this->assertEquals(false, DocumentProperties::convertProperty('1', 'bool')); + $this->assertEquals('1', DocumentProperties::convertProperty('1', 'array')); + $this->assertEquals('1', DocumentProperties::convertProperty('1', '')); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_INTEGER, - PHPWord_DocumentProperties::convertPropertyType('int') + DocumentProperties::PROPERTY_TYPE_INTEGER, + DocumentProperties::convertPropertyType('int') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_INTEGER, - PHPWord_DocumentProperties::convertPropertyType('uint') + DocumentProperties::PROPERTY_TYPE_INTEGER, + DocumentProperties::convertPropertyType('uint') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_FLOAT, - PHPWord_DocumentProperties::convertPropertyType('decimal') + DocumentProperties::PROPERTY_TYPE_FLOAT, + DocumentProperties::convertPropertyType('decimal') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_STRING, - PHPWord_DocumentProperties::convertPropertyType('lpstr') + DocumentProperties::PROPERTY_TYPE_STRING, + DocumentProperties::convertPropertyType('lpstr') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_DATE, - PHPWord_DocumentProperties::convertPropertyType('date') + DocumentProperties::PROPERTY_TYPE_DATE, + DocumentProperties::convertPropertyType('date') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_BOOLEAN, - PHPWord_DocumentProperties::convertPropertyType('bool') + DocumentProperties::PROPERTY_TYPE_BOOLEAN, + DocumentProperties::convertPropertyType('bool') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_UNKNOWN, - PHPWord_DocumentProperties::convertPropertyType('array') + DocumentProperties::PROPERTY_TYPE_UNKNOWN, + DocumentProperties::convertPropertyType('array') ); $this->assertEquals( - PHPWord_DocumentProperties::PROPERTY_TYPE_UNKNOWN, - PHPWord_DocumentProperties::convertPropertyType('') + DocumentProperties::PROPERTY_TYPE_UNKNOWN, + DocumentProperties::convertPropertyType('') ); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Exceptions/ExceptionTest.php b/Tests/PHPWord/Exceptions/ExceptionTest.php index a403aa28e6..75a4e3c1ce 100644 --- a/Tests/PHPWord/Exceptions/ExceptionTest.php +++ b/Tests/PHPWord/Exceptions/ExceptionTest.php @@ -6,8 +6,8 @@ class ExceptionTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException \PhpOffice\PhpWord\Exceptions\Exception - * @covers \PhpOffice\PhpWord\Exceptions\Exception + * @expectedException PhpOffice\PhpWord\Exceptions\Exception + * @covers PhpOffice\PhpWord\Exceptions\Exception */ public function testThrowException() { diff --git a/Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php b/Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php index 44a24e05b3..7b2da2737d 100644 --- a/Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php +++ b/Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php @@ -6,8 +6,8 @@ class InvalidImageExceptionTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidImageException - * @covers \PhpOffice\PhpWord\Exceptions\InvalidImageException + * @expectedException PhpOffice\PhpWord\Exceptions\InvalidImageException + * @covers PhpOffice\PhpWord\Exceptions\InvalidImageException */ public function testThrowException() { diff --git a/Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php b/Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php index 2b0ed3af4f..b439a9705f 100644 --- a/Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php +++ b/Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php @@ -6,8 +6,8 @@ class InvalidStyleExceptionTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidStyleException - * @covers \PhpOffice\PhpWord\Exceptions\InvalidStyleException + * @expectedException PhpOffice\PhpWord\Exceptions\InvalidStyleException + * @covers PhpOffice\PhpWord\Exceptions\InvalidStyleException */ public function testThrowException() { diff --git a/Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php b/Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php index a93ec280b9..cafb38abd3 100644 --- a/Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php +++ b/Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php @@ -6,8 +6,8 @@ class UnsupportedImageTypeExceptionTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException - * @covers \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException + * @expectedException PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException + * @covers PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException */ public function testThrowException() { diff --git a/Tests/PHPWord/IOFactoryTest.php b/Tests/PHPWord/IOFactoryTest.php index 0ed6a06510..951497c6f5 100644 --- a/Tests/PHPWord/IOFactoryTest.php +++ b/Tests/PHPWord/IOFactoryTest.php @@ -2,13 +2,12 @@ namespace PHPWord\Tests; use PHPWord; -use PHPWord_IOFactory; -use PHPWord_Writer_Word2007; +use PhpOffice\PhpWord\IOFactory; +use PhpOffice\PhpWord\Writer\Word2007; use Exception; /** - * Class IOFactoryTest - * @package PHPWord\Tests + * @package PHPWord\Tests * @runTestsInSeparateProcesses */ class IOFactoryTest extends \PHPUnit_Framework_TestCase @@ -16,48 +15,45 @@ class IOFactoryTest extends \PHPUnit_Framework_TestCase public function testGetSearchLocations() { $this->assertAttributeEquals( - PHPWord_IOFactory::getSearchLocations(), + IOFactory::getSearchLocations(), '_searchLocations', - 'PHPWord_IOFactory' + 'PhpOffice\\PhpWord\\IOFactory' ); } public function testSetSearchLocationsWithArray() { - PHPWord_IOFactory::setSearchLocations(array()); - $this->assertAttributeEquals(array(), '_searchLocations', 'PHPWord_IOFactory'); + IOFactory::setSearchLocations(array()); + $this->assertAttributeEquals(array(), '_searchLocations', 'PhpOffice\\PhpWord\\IOFactory'); } public function testAddSearchLocation() { - PHPWord_IOFactory::setSearchLocations(array()); - PHPWord_IOFactory::addSearchLocation('type', 'location', 'classname'); + IOFactory::setSearchLocations(array()); + IOFactory::addSearchLocation('interface', 'classname'); $this->assertAttributeEquals( - array(array('type' => 'type', 'path' => 'location', 'class' => 'classname')), + array(array('interface' => 'interface', 'class' => 'classname')), '_searchLocations', - 'PHPWord_IOFactory' + 'PhpOffice\\PhpWord\\IOFactory' ); } /** - * @expectedException Exception + * @expectedException Exception * @expectedExceptionMessage No IWriter found for type */ public function testCreateWriterException() { $oPHPWord = new PHPWord(); - PHPWord_IOFactory::setSearchLocations(array()); - PHPWord_IOFactory::createWriter($oPHPWord); + IOFactory::setSearchLocations(array()); + IOFactory::createWriter($oPHPWord); } public function testCreateWriter() { $oPHPWord = new PHPWord(); - $this->assertEquals( - PHPWord_IOFactory::createWriter($oPHPWord, 'Word2007'), - new PHPWord_Writer_Word2007($oPHPWord) - ); + $this->assertEquals(IOFactory::createWriter($oPHPWord, 'Word2007'), new Word2007($oPHPWord)); } } \ No newline at end of file diff --git a/Tests/PHPWord/MediaTest.php b/Tests/PHPWord/MediaTest.php index b2ebd6ae89..6515e36b26 100644 --- a/Tests/PHPWord/MediaTest.php +++ b/Tests/PHPWord/MediaTest.php @@ -1,39 +1,47 @@ assertEquals(PHPWord_Media::getSectionMediaElements(), array()); + $this->assertEquals(Media::getSectionMediaElements(), array()); } public function testCountSectionMediaElementsWithNull() { - $this->assertEquals(PHPWord_Media::countSectionMediaElements(), 0); + $this->assertEquals(Media::countSectionMediaElements(), 0); } public function testGetHeaderMediaElements() { - $this->assertAttributeEquals(PHPWord_Media::getHeaderMediaElements(), '_headerMedia', 'PHPWord_Media'); + $this->assertAttributeEquals( + Media::getHeaderMediaElements(), + '_headerMedia', + 'PhpOffice\\PhpWord\\Media' + ); } public function testGetFooterMediaElements() { - $this->assertAttributeEquals(PHPWord_Media::getFooterMediaElements(), '_footerMedia', 'PHPWord_Media'); + $this->assertAttributeEquals( + Media::getFooterMediaElements(), + '_footerMedia', + 'PhpOffice\\PhpWord\\Media' + ); } /** * Todo: add memory image to this test * - * @covers PHPWord_Media::addSectionMediaElement + * @covers PhpOffice\PhpWord\Media::addSectionMediaElement */ public function testAddSectionMediaElement() { - $section = new PHPWord_Section(0); + $section = new Section(0); $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"); @@ -44,7 +52,7 @@ public function testAddSectionMediaElement() $elements = $section->getElements(); $this->assertEquals(6, count($elements)); foreach ($elements as $element) { - $this->assertInstanceOf('PHPWord_Section_Image', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element); } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Reader/Word2007Test.php b/Tests/PHPWord/Reader/Word2007Test.php index 6fb6684609..c85c99f732 100644 --- a/Tests/PHPWord/Reader/Word2007Test.php +++ b/Tests/PHPWord/Reader/Word2007Test.php @@ -1,12 +1,10 @@ assertTrue($object->canRead($file)); } @@ -46,10 +44,10 @@ public function testCanReadFailed() DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents') ); - $object = new PHPWord_Reader_Word2007; + $object = new Word2007; $file = $dir . DIRECTORY_SEPARATOR . 'foo.docx'; $this->assertFalse($object->canRead($file)); - $object = PHPWord_IOFactory::load($file); + $object = IOFactory::load($file); } /** @@ -62,7 +60,7 @@ public function testLoad() array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents') ); $file = $dir . DIRECTORY_SEPARATOR . 'reader.docx'; - $object = PHPWord_IOFactory::load($file); - $this->assertInstanceOf('PHPWord', $object); + $object = IOFactory::load($file); + $this->assertInstanceOf('PhpOffice\\PHPWord', $object); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/Footer/PreserveTextTest.php b/Tests/PHPWord/Section/Footer/PreserveTextTest.php index 61f84ee56a..5cf7ca163a 100644 --- a/Tests/PHPWord/Section/Footer/PreserveTextTest.php +++ b/Tests/PHPWord/Section/Footer/PreserveTextTest.php @@ -1,15 +1,15 @@ assertInstanceOf('PHPWord_Section_Footer_PreserveText', $oPreserveText); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $oPreserveText); $this->assertEquals($oPreserveText->getText(), null); $this->assertEquals($oPreserveText->getFontStyle(), null); $this->assertEquals($oPreserveText->getParagraphStyle(), null); @@ -17,7 +17,7 @@ public function testConstruct() public function testConstructWithString() { - $oPreserveText = new PHPWord_Section_Footer_PreserveText('text', 'styleFont', 'styleParagraph'); + $oPreserveText = new PreserveText('text', 'styleFont', 'styleParagraph'); $this->assertEquals($oPreserveText->getText(), 'text'); $this->assertEquals($oPreserveText->getFontStyle(), 'styleFont'); $this->assertEquals($oPreserveText->getParagraphStyle(), 'styleParagraph'); @@ -25,12 +25,15 @@ public function testConstructWithString() public function testConstructWithArray() { - $oPreserveText = new PHPWord_Section_Footer_PreserveText( + $oPreserveText = new PreserveText( 'text', array('align' => 'center'), array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600) ); - $this->assertInstanceOf('PHPWord_Style_Font', $oPreserveText->getFontStyle()); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oPreserveText->getParagraphStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oPreserveText->getFontStyle()); + $this->assertInstanceOf( + 'PhpOffice\\PhpWord\\Style\\Paragraph', + $oPreserveText->getParagraphStyle() + ); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/FooterTest.php b/Tests/PHPWord/Section/FooterTest.php index 10751d0e7e..9243998919 100644 --- a/Tests/PHPWord/Section/FooterTest.php +++ b/Tests/PHPWord/Section/FooterTest.php @@ -1,22 +1,22 @@ assertInstanceOf('PHPWord_Section_Footer', $oFooter); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer', $oFooter); $this->assertEquals($oFooter->getFooterCount(), $iVal); } public function testRelationID() { - $oFooter = new PHPWord_Section_Footer(0); + $oFooter = new Footer(0); $iVal = rand(1, 1000); $oFooter->setRelationId($iVal); @@ -25,27 +25,27 @@ public function testRelationID() public function testAddText() { - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $element = $oFooter->addText('text'); $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); } public function testAddTextNotUTF8() { - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $element = $oFooter->addText(utf8_decode('ééé')); $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); $this->assertEquals($element->getText(), 'ééé'); } public function testAddTextBreak() { - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $iVal = rand(1, 1000); $oFooter->addTextBreak($iVal); @@ -54,20 +54,20 @@ public function testAddTextBreak() public function testCreateTextRun() { - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $element = $oFooter->createTextRun(); $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_TextRun', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $element); } public function testAddTable() { - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $element = $oFooter->addTable(); $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Table', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table', $element); } public function testAddImage() @@ -76,47 +76,47 @@ public function testAddImage() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $element = $oFooter->addImage($src); $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element); } public function testAddMemoryImage() { - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $element = $oFooter->addMemoryImage( 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' ); $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element); } public function testAddPreserveText() { - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $element = $oFooter->addPreserveText('text'); $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element); } public function testAddPreserveTextNotUTF8() { - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $element = $oFooter->addPreserveText(utf8_decode('ééé')); $this->assertCount(1, $oFooter->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element); $this->assertEquals($element->getText(), 'ééé'); } public function testGetElements() { - $oFooter = new PHPWord_Section_Footer(1); + $oFooter = new Footer(1); $this->assertInternalType('array', $oFooter->getElements()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/FootnoteTest.php b/Tests/PHPWord/Section/FootnoteTest.php index bd991278ba..0b66ccf370 100644 --- a/Tests/PHPWord/Section/FootnoteTest.php +++ b/Tests/PHPWord/Section/FootnoteTest.php @@ -1,54 +1,57 @@ assertInstanceOf('PHPWord_Section_Footnote', $oFootnote); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footnote', $oFootnote); $this->assertCount(0, $oFootnote->getElements()); $this->assertEquals($oFootnote->getParagraphStyle(), null); } public function testConstructString() { - $oFootnote = new PHPWord_Section_Footnote('pStyle'); + $oFootnote = new Footnote('pStyle'); $this->assertEquals($oFootnote->getParagraphStyle(), 'pStyle'); } public function testConstructArray() { - $oFootnote = new PHPWord_Section_Footnote(array('spacing' => 100)); + $oFootnote = new Footnote(array('spacing' => 100)); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oFootnote->getParagraphStyle()); + $this->assertInstanceOf( + 'PhpOffice\\PhpWord\\Style\\Paragraph', + $oFootnote->getParagraphStyle() + ); } public function testAddText() { - $oFootnote = new PHPWord_Section_Footnote(); + $oFootnote = new Footnote(); $element = $oFootnote->addText('text'); $this->assertCount(1, $oFootnote->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); } public function testAddLink() { - $oFootnote = new PHPWord_Section_Footnote(); + $oFootnote = new Footnote(); $element = $oFootnote->addLink('http://www.google.fr'); $this->assertCount(1, $oFootnote->getElements()); - $this->assertInstanceOf('PHPWord_Section_Link', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $element); } public function testReferenceId() { - $oFootnote = new PHPWord_Section_Footnote(); + $oFootnote = new Footnote(); $iVal = rand(1, 1000); $oFootnote->setReferenceId($iVal); @@ -57,7 +60,7 @@ public function testReferenceId() public function testGetElements() { - $oFootnote = new PHPWord_Section_Footnote(); + $oFootnote = new Footnote(); $this->assertInternalType('array', $oFootnote->getElements()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/HeaderTest.php b/Tests/PHPWord/Section/HeaderTest.php index 527ad3ee4c..90b4322220 100644 --- a/Tests/PHPWord/Section/HeaderTest.php +++ b/Tests/PHPWord/Section/HeaderTest.php @@ -1,50 +1,50 @@ assertInstanceOf('PHPWord_Section_Header', $oHeader); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Header', $oHeader); $this->assertEquals($oHeader->getHeaderCount(), $iVal); - $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO); + $this->assertEquals($oHeader->getType(), Header::AUTO); } public function testAddText() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $element = $oHeader->addText('text'); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); $this->assertCount(1, $oHeader->getElements()); $this->assertEquals($element->getText(), 'text'); } public function testAddTextNotUTF8() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $element = $oHeader->addText(utf8_decode('ééé')); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); $this->assertCount(1, $oHeader->getElements()); $this->assertEquals($element->getText(), 'ééé'); } public function testAddTextBreak() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $oHeader->addTextBreak(); $this->assertCount(1, $oHeader->getElements()); } public function testAddTextBreakWithParams() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $iVal = rand(1, 1000); $oHeader->addTextBreak($iVal); $this->assertCount($iVal, $oHeader->getElements()); @@ -52,17 +52,17 @@ public function testAddTextBreakWithParams() public function testCreateTextRun() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $element = $oHeader->createTextRun(); - $this->assertInstanceOf('PHPWord_Section_TextRun', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $element); $this->assertCount(1, $oHeader->getElements()); } public function testAddTable() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $element = $oHeader->addTable(); - $this->assertInstanceOf('PHPWord_Section_Table', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table', $element); $this->assertCount(1, $oHeader->getElements()); } @@ -72,40 +72,40 @@ public function testAddImage() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $element = $oHeader->addImage($src); $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element); } public function testAddMemoryImage() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $element = $oHeader->addMemoryImage( 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' ); $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element); } public function testAddPreserveText() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $element = $oHeader->addPreserveText('text'); $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element); } public function testAddPreserveTextNotUTF8() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $element = $oHeader->addPreserveText(utf8_decode('ééé')); $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element); $this->assertEquals($element->getText(), 'ééé'); } @@ -115,23 +115,23 @@ public function testAddWatermark() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $element = $oHeader->addWatermark($src); $this->assertCount(1, $oHeader->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element); } public function testGetElements() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $this->assertInternalType('array', $oHeader->getElements()); } public function testRelationId() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $iVal = rand(1, 1000); $oHeader->setRelationId($iVal); @@ -140,26 +140,26 @@ public function testRelationId() public function testResetType() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $oHeader->firstPage(); $oHeader->resetType(); - $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO); + $this->assertEquals($oHeader->getType(), Header::AUTO); } public function testFirstPage() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $oHeader->firstPage(); - $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::FIRST); + $this->assertEquals($oHeader->getType(), Header::FIRST); } public function testEvenPage() { - $oHeader = new PHPWord_Section_Header(1); + $oHeader = new Header(1); $oHeader->evenPage(); - $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::EVEN); + $this->assertEquals($oHeader->getType(), Header::EVEN); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/ImageTest.php b/Tests/PHPWord/Section/ImageTest.php index 50cc4d2acc..4f4dbde828 100644 --- a/Tests/PHPWord/Section/ImageTest.php +++ b/Tests/PHPWord/Section/ImageTest.php @@ -1,9 +1,11 @@ assertInstanceOf('PHPWord_Section_Image', $oImage); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $oImage); $this->assertEquals($oImage->getSource(), $src); $this->assertEquals($oImage->getMediaId(), md5($src)); $this->assertEquals($oImage->getIsWatermark(), false); - $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle()); } public function testConstructWithStyle() @@ -27,59 +29,59 @@ public function testConstructWithStyle() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'firefox.png') ); - $oImage = new PHPWord_Section_Image( + $oImage = new Image( $src, array('width' => 210, 'height' => 210, 'align' => 'center', - 'wrappingStyle' => \PHPWord_Style_Image::WRAPPING_STYLE_BEHIND) + 'wrappingStyle' => PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND) ); - $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle()); } /** - * @covers PHPWord_Section_Image::__construct + * @covers ::__construct */ public function testValidImageTypes() { - new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg"); - new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg"); - new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif"); - new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png"); - new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp"); - new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif"); + new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg"); + new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg"); + new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif"); + new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png"); + new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp"); + new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif"); } /** - * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidImageException - * @covers PHPWord_Section_Image::__construct + * @expectedException PhpOffice\PhpWord\Exceptions\InvalidImageException + * @covers ::__construct */ public function testImageNotFound() { - new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/thisisnotarealimage"); + new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/thisisnotarealimage"); } /** - * @expectedException \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException - * @covers PHPWord_Section_Image::__construct + * @expectedException PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException + * @covers ::__construct */ public function testInvalidImageTypes() { - new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/alexz-johnson.pcx"); + new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/alexz-johnson.pcx"); } public function testStyle() { - $oImage = new PHPWord_Section_Image(\join( + $oImage = new Image(\join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ), array('width' => 210, 'height' => 210, 'align' => 'center')); - $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle()); } public function testRelationID() { - $oImage = new PHPWord_Section_Image(\join( + $oImage = new Image(\join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') )); @@ -91,7 +93,7 @@ public function testRelationID() public function testWatermark() { - $oImage = new PHPWord_Section_Image(\join( + $oImage = new Image(\join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') )); @@ -99,4 +101,4 @@ public function testWatermark() $oImage->setIsWatermark(true); $this->assertEquals($oImage->getIsWatermark(), true); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/LinkTest.php b/Tests/PHPWord/Section/LinkTest.php index 413b23fe95..5e93fc1e18 100644 --- a/Tests/PHPWord/Section/LinkTest.php +++ b/Tests/PHPWord/Section/LinkTest.php @@ -1,16 +1,16 @@ assertInstanceOf('PHPWord_Section_Link', $oLink); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $oLink); $this->assertEquals($oLink->getLinkSrc(), 'http://www.google.com'); $this->assertEquals($oLink->getLinkName(), null); $this->assertEquals($oLink->getFontStyle(), null); @@ -19,23 +19,23 @@ public function testConstructDefault() public function testConstructWithParamsArray() { - $oLink = new PHPWord_Section_Link( + $oLink = new Link( 'http://www.google.com', 'Search Engine', - array('color' => '0000FF', 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE), + array('color' => '0000FF', 'underline' => Font::UNDERLINE_SINGLE), array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600) ); - $this->assertInstanceOf('PHPWord_Section_Link', $oLink); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $oLink); $this->assertEquals($oLink->getLinkSrc(), 'http://www.google.com'); $this->assertEquals($oLink->getLinkName(), 'Search Engine'); - $this->assertInstanceOf('PHPWord_Style_Font', $oLink->getFontStyle()); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oLink->getParagraphStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oLink->getFontStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oLink->getParagraphStyle()); } public function testConstructWithParamsString() { - $oLink = new PHPWord_Section_Link('http://www.google.com', null, 'fontStyle', 'paragraphStyle'); + $oLink = new Link('http://www.google.com', null, 'fontStyle', 'paragraphStyle'); $this->assertEquals($oLink->getFontStyle(), 'fontStyle'); $this->assertEquals($oLink->getParagraphStyle(), 'paragraphStyle'); @@ -43,10 +43,10 @@ public function testConstructWithParamsString() public function testRelationId() { - $oLink = new PHPWord_Section_Link('http://www.google.com'); + $oLink = new Link('http://www.google.com'); $iVal = rand(1, 1000); $oLink->setRelationId($iVal); $this->assertEquals($oLink->getRelationId(), $iVal); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/ListItemTest.php b/Tests/PHPWord/Section/ListItemTest.php index a2a4d43832..2719c9be14 100644 --- a/Tests/PHPWord/Section/ListItemTest.php +++ b/Tests/PHPWord/Section/ListItemTest.php @@ -1,36 +1,38 @@ assertInstanceOf('PHPWord_Section_Text', $oListItem->getTextObject()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $oListItem->getTextObject()); } public function testStyle() { - $oListItem = new PHPWord_Section_ListItem( + $oListItem = new ListItem( 'text', 1, null, - array('listType' => PHPWord_Style_ListItem::TYPE_NUMBER) + array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER) ); - $this->assertInstanceOf('PHPWord_Style_ListItem', $oListItem->getStyle()); - $this->assertEquals($oListItem->getStyle()->getListType(), PHPWord_Style_ListItem::TYPE_NUMBER); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\ListItem', $oListItem->getStyle()); + $this->assertEquals( + $oListItem->getStyle()->getListType(), + PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER + ); } public function testDepth() { $iVal = rand(1, 1000); - $oListItem = new PHPWord_Section_ListItem('text', $iVal); + $oListItem = new ListItem('text', $iVal); $this->assertEquals($oListItem->getDepth(), $iVal); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/MemoryImageTest.php b/Tests/PHPWord/Section/MemoryImageTest.php index 3bfb39e358..d6fe8a458b 100644 --- a/Tests/PHPWord/Section/MemoryImageTest.php +++ b/Tests/PHPWord/Section/MemoryImageTest.php @@ -1,7 +1,7 @@ assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage); $this->assertEquals($oMemoryImage->getSource(), $src); $this->assertEquals($oMemoryImage->getMediaId(), md5($src)); $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefrompng'); @@ -28,9 +28,9 @@ public function testGIF() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'mario.gif') ); - $oMemoryImage = new PHPWord_Section_MemoryImage($src); + $oMemoryImage = new MemoryImage($src); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage); $this->assertEquals($oMemoryImage->getSource(), $src); $this->assertEquals($oMemoryImage->getMediaId(), md5($src)); $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromgif'); @@ -45,9 +45,9 @@ public function testJPG() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $oMemoryImage = new PHPWord_Section_MemoryImage($src); + $oMemoryImage = new MemoryImage($src); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage); $this->assertEquals($oMemoryImage->getSource(), $src); $this->assertEquals($oMemoryImage->getMediaId(), md5($src)); $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromjpeg'); @@ -58,12 +58,12 @@ public function testJPG() public function testBMP() { - $oMemoryImage = new PHPWord_Section_MemoryImage(\join( + $oMemoryImage = new MemoryImage(\join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'duke_nukem.bmp') )); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage); $this->assertEquals($oMemoryImage->getImageCreateFunction(), null); $this->assertEquals($oMemoryImage->getImageFunction(), null); $this->assertEquals($oMemoryImage->getImageExtension(), null); @@ -72,17 +72,17 @@ public function testBMP() public function testStyle() { - $oMemoryImage = new PHPWord_Section_MemoryImage(\join( + $oMemoryImage = new MemoryImage(\join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ), array('width' => 210, 'height' => 210, 'align' => 'center')); - $this->assertInstanceOf('PHPWord_Style_Image', $oMemoryImage->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oMemoryImage->getStyle()); } public function testRelationID() { - $oMemoryImage = new PHPWord_Section_MemoryImage(\join( + $oMemoryImage = new MemoryImage(\join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') )); @@ -91,4 +91,4 @@ public function testRelationID() $oMemoryImage->setRelationId($iVal); $this->assertEquals($oMemoryImage->getRelationId(), $iVal); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/ObjectTest.php b/Tests/PHPWord/Section/ObjectTest.php index b72f2484c8..df1c74611f 100644 --- a/Tests/PHPWord/Section/ObjectTest.php +++ b/Tests/PHPWord/Section/ObjectTest.php @@ -1,7 +1,7 @@ assertInstanceOf('PHPWord_Section_Object', $oObject); - $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $oObject); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oObject->getStyle()); $this->assertEquals($oObject->getSource(), $src); } @@ -24,9 +24,9 @@ public function testConstructWithNotSupportedFiles() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl') ); - $oObject = new PHPWord_Section_Object($src); + $oObject = new Object($src); - $this->assertInstanceOf('PHPWord_Section_Object', $oObject); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $oObject); $this->assertEquals($oObject->getSource(), null); $this->assertEquals($oObject->getStyle(), null); } @@ -37,10 +37,10 @@ public function testConstructWithSupportedFilesAndStyle() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') ); - $oObject = new PHPWord_Section_Object($src, array('width' => '230px')); + $oObject = new Object($src, array('width' => '230px')); - $this->assertInstanceOf('PHPWord_Section_Object', $oObject); - $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $oObject); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oObject->getStyle()); $this->assertEquals($oObject->getSource(), $src); } @@ -50,7 +50,7 @@ public function testRelationId() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') ); - $oObject = new PHPWord_Section_Object($src); + $oObject = new Object($src); $iVal = rand(1, 1000); $oObject->setRelationId($iVal); @@ -63,7 +63,7 @@ public function testImageRelationId() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') ); - $oObject = new PHPWord_Section_Object($src); + $oObject = new Object($src); $iVal = rand(1, 1000); $oObject->setImageRelationId($iVal); @@ -76,10 +76,10 @@ public function testObjectId() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') ); - $oObject = new PHPWord_Section_Object($src); + $oObject = new Object($src); $iVal = rand(1, 1000); $oObject->setObjectId($iVal); $this->assertEquals($oObject->getObjectId(), $iVal); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/PageBreakTest.php b/Tests/PHPWord/Section/PageBreakTest.php index 5efd0fe944..24bb835d2f 100644 --- a/Tests/PHPWord/Section/PageBreakTest.php +++ b/Tests/PHPWord/Section/PageBreakTest.php @@ -1,7 +1,7 @@ assertInstanceOf('PHPWord_Section_PageBreak', $oPageBreak); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\PageBreak', $oPageBreak); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/SettingsTest.php b/Tests/PHPWord/Section/SettingsTest.php index 92e8465434..4c4c557cb4 100644 --- a/Tests/PHPWord/Section/SettingsTest.php +++ b/Tests/PHPWord/Section/SettingsTest.php @@ -1,7 +1,7 @@ setSettingValue('_orientation', 'landscape'); $this->assertEquals('landscape', $oSettings->getOrientation()); @@ -46,7 +46,7 @@ public function testSettingValue() public function testMargin() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); $iVal = rand(1, 1000); $oSettings->setMarginTop($iVal); @@ -68,7 +68,7 @@ public function testMargin() public function testOrientationLandscape() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); $oSettings->setLandscape(); $this->assertEquals('landscape', $oSettings->getOrientation()); @@ -79,7 +79,7 @@ public function testOrientationLandscape() public function testOrientationPortrait() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); $oSettings->setPortrait(); $this->assertNull($oSettings->getOrientation()); @@ -90,7 +90,7 @@ public function testOrientationPortrait() public function testBorderSize() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); $iVal = rand(1, 1000); $oSettings->setBorderSize($iVal); @@ -120,7 +120,7 @@ public function testBorderSize() public function testBorderColor() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); $oSettings->setBorderColor('FF00AA'); $this->assertEquals(array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA'), $oSettings->getBorderColor()); @@ -145,7 +145,7 @@ public function testBorderColor() public function testNumberingStart() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); $this->assertNull($oSettings->getPageNumberingStart()); @@ -160,7 +160,7 @@ public function testNumberingStart() public function testHeader() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); $this->assertEquals(720, $oSettings->getHeaderHeight()); @@ -175,7 +175,7 @@ public function testHeader() public function testFooter() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); $this->assertEquals(720, $oSettings->getFooterHeight()); @@ -190,7 +190,7 @@ public function testFooter() public function testColumnsNum() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); // Default $this->assertEquals(1, $oSettings->getColsNum()); @@ -206,23 +206,23 @@ public function testColumnsNum() public function testColumnsSpace() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); // Default $this->assertEquals(720, $oSettings->getColsSpace()); $iVal = rand(1, 1000); - $this->assertInstanceOf('PHPWord_Section_Settings', $oSettings->setColsSpace($iVal)); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Settings', $oSettings->setColsSpace($iVal)); $this->assertEquals($iVal, $oSettings->getColsSpace()); - $this->assertInstanceOf('PHPWord_Section_Settings', $oSettings->setColsSpace()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Settings', $oSettings->setColsSpace()); $this->assertEquals(720, $oSettings->getColsSpace()); } public function testBreakType() { // Section Settings - $oSettings = new PHPWord_Section_Settings(); + $oSettings = new Settings(); $this->assertNull($oSettings->getBreakType()); @@ -232,4 +232,4 @@ public function testBreakType() $oSettings->setBreakType(); $this->assertNull($oSettings->getBreakType()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/Table/CellTest.php b/Tests/PHPWord/Section/Table/CellTest.php index 30a7fcdb7a..3eb2bf0490 100644 --- a/Tests/PHPWord/Section/Table/CellTest.php +++ b/Tests/PHPWord/Section/Table/CellTest.php @@ -1,67 +1,67 @@ assertInstanceOf('PHPWord_Section_Table_Cell', $oCell); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Cell', $oCell); $this->assertEquals($oCell->getWidth(), null); } public function testConstructWithStyleArray() { $iVal = rand(1, 1000); - $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, array('valign' => 'center')); + $oCell = new Cell('section', $iVal, null, array('valign' => 'center')); - $this->assertInstanceOf('PHPWord_Style_Cell', $oCell->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Cell', $oCell->getStyle()); $this->assertEquals($oCell->getWidth(), null); } public function testConstructWithStyleString() { $iVal = rand(1, 1000); - $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, 'cellStyle'); + $oCell = new Cell('section', $iVal, null, 'cellStyle'); $this->assertEquals($oCell->getStyle(), 'cellStyle'); } public function testAddText() { - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $element = $oCell->addText('text'); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); } public function testAddTextNotUTF8() { - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $element = $oCell->addText(utf8_decode('ééé')); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); $this->assertEquals($element->getText(), 'ééé'); } public function testAddLink() { - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $element = $oCell->addLink('http://www.google.fr', 'Nom'); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Link', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $element); } public function testAddTextBreak() { - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $oCell->addTextBreak(); $this->assertCount(1, $oCell->getElements()); @@ -69,21 +69,21 @@ public function testAddTextBreak() public function testAddListItem() { - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $element = $oCell->addListItem('text'); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_ListItem', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\ListItem', $element); $this->assertEquals($element->getTextObject()->getText(), 'text'); } public function testAddListItemNotUTF8() { - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $element = $oCell->addListItem(utf8_decode('ééé')); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_ListItem', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\ListItem', $element); $this->assertEquals($element->getTextObject()->getText(), 'ééé'); } @@ -93,11 +93,11 @@ public function testAddImageSection() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $element = $oCell->addImage($src); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element); } public function testAddImageHeader() @@ -106,11 +106,11 @@ public function testAddImageHeader() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $oCell = new PHPWord_Section_Table_Cell('header', 1); + $oCell = new Cell('header', 1); $element = $oCell->addImage($src); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element); } public function testAddImageFooter() @@ -119,44 +119,44 @@ public function testAddImageFooter() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $oCell = new PHPWord_Section_Table_Cell('footer', 1); + $oCell = new Cell('footer', 1); $element = $oCell->addImage($src); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Image', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element); } public function testAddMemoryImageSection() { - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $element = $oCell->addMemoryImage( 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' ); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element); } public function testAddMemoryImageHeader() { - $oCell = new PHPWord_Section_Table_Cell('header', 1); + $oCell = new Cell('header', 1); $element = $oCell->addMemoryImage( 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' ); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element); } public function testAddMemoryImageFooter() { - $oCell = new PHPWord_Section_Table_Cell('footer', 1); + $oCell = new Cell('footer', 1); $element = $oCell->addMemoryImage( 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' ); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element); } public function testAddObjectXLS() @@ -165,45 +165,45 @@ public function testAddObjectXLS() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') ); - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $element = $oCell->addObject($src); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Object', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $element); } public function testAddPreserveText() { - $oCell = new PHPWord_Section_Table_Cell('header', 1); + $oCell = new Cell('header', 1); $element = $oCell->addPreserveText('text'); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element); } public function testAddPreserveTextNotUTF8() { - $oCell = new PHPWord_Section_Table_Cell('header', 1); + $oCell = new Cell('header', 1); $element = $oCell->addPreserveText(utf8_decode('ééé')); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element); $this->assertEquals($element->getText(), 'ééé'); } public function testCreateTextRun() { - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $element = $oCell->createTextRun(); $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PHPWord_Section_TextRun', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $element); } public function testGetElements() { - $oCell = new PHPWord_Section_Table_Cell('section', 1); + $oCell = new Cell('section', 1); $this->assertInternalType('array', $oCell->getElements()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/Table/RowTest.php b/Tests/PHPWord/Section/Table/RowTest.php index e62a5bd926..8702a03891 100644 --- a/Tests/PHPWord/Section/Table/RowTest.php +++ b/Tests/PHPWord/Section/Table/RowTest.php @@ -1,27 +1,27 @@ assertInstanceOf('PHPWord_Section_Table_Row', $oRow); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Row', $oRow); $this->assertEquals($oRow->getHeight(), null); $this->assertInternalType('array', $oRow->getCells()); $this->assertCount(0, $oRow->getCells()); - $this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Row', $oRow->getStyle()); } public function testConstructWithParams() { $iVal = rand(1, 1000); $iVal2 = rand(1, 1000); - $oRow = new PHPWord_Section_Table_Row( + $oRow = new Row( 'section', $iVal, $iVal2, @@ -29,15 +29,15 @@ public function testConstructWithParams() ); $this->assertEquals($oRow->getHeight(), $iVal2); - $this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Row', $oRow->getStyle()); } public function testAddCell() { - $oRow = new PHPWord_Section_Table_Row('section', 1); + $oRow = new Row('section', 1); $element = $oRow->addCell(); - $this->assertInstanceOf('PHPWord_Section_Table_Cell', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Cell', $element); $this->assertCount(1, $oRow->getCells()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TableTest.php b/Tests/PHPWord/Section/TableTest.php index 167f1190f0..961031b5e2 100644 --- a/Tests/PHPWord/Section/TableTest.php +++ b/Tests/PHPWord/Section/TableTest.php @@ -1,15 +1,15 @@ assertInstanceOf('PHPWord_Section_Table', $oTable); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table', $oTable); $this->assertEquals($oTable->getStyle(), null); $this->assertEquals($oTable->getWidth(), null); $this->assertEquals($oTable->getRows(), array()); @@ -18,25 +18,25 @@ public function testConstruct() public function testStyleText() { - $oTable = new PHPWord_Section_Table('section', 1, 'tableStyle'); + $oTable = new Table('section', 1, 'tableStyle'); $this->assertEquals($oTable->getStyle(), 'tableStyle'); } public function testStyleArray() { - $oTable = new PHPWord_Section_Table( + $oTable = new Table( 'section', 1, array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80) ); - $this->assertInstanceOf('PHPWord_Style_Table', $oTable->getStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Table', $oTable->getStyle()); } public function testWidth() { - $oTable = new PHPWord_Section_Table('section', 1); + $oTable = new Table('section', 1); $iVal = rand(1, 1000); $oTable->setWidth($iVal); $this->assertEquals($oTable->getWidth(), $iVal); @@ -44,17 +44,17 @@ public function testWidth() public function testRow() { - $oTable = new PHPWord_Section_Table('section', 1); + $oTable = new Table('section', 1); $element = $oTable->addRow(); - $this->assertInstanceOf('PHPWord_Section_Table_Row', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Row', $element); $this->assertCount(1, $oTable->getRows()); } public function testCell() { - $oTable = new PHPWord_Section_Table('section', 1); + $oTable = new Table('section', 1); $oTable->addRow(); $element = $oTable->addCell(); - $this->assertInstanceOf('PHPWord_Section_Table_Cell', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Cell', $element); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TextBreakTest.php b/Tests/PHPWord/Section/TextBreakTest.php index 761c04a395..1d02c2f1d8 100644 --- a/Tests/PHPWord/Section/TextBreakTest.php +++ b/Tests/PHPWord/Section/TextBreakTest.php @@ -1,13 +1,13 @@ assertNull($object->getFontStyle()); $this->assertNull($object->getParagraphStyle()); } @@ -27,9 +27,9 @@ public function testConstruct() */ public function testConstructWithStyleObject() { - $fStyle = new PHPWord_Style_Font(); - $pStyle = new PHPWord_Style_Paragraph(); - $object = new PHPWord_Section_TextBreak($fStyle, $pStyle); + $fStyle = new Font(); + $pStyle = new Paragraph(); + $object = new TextBreak($fStyle, $pStyle); $this->assertEquals($fStyle, $object->getFontStyle()); $this->assertEquals($pStyle, $object->getParagraphStyle()); } @@ -41,9 +41,9 @@ public function testConstructWithStyleArray() { $fStyle = array('size' => 12); $pStyle = array('spacing' => 240); - $object = new PHPWord_Section_TextBreak($fStyle, $pStyle); - $this->assertInstanceOf('PHPWord_Style_Font', $object->getFontStyle()); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $object->getParagraphStyle()); + $object = new TextBreak($fStyle, $pStyle); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $object->getFontStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle()); } /** @@ -53,8 +53,8 @@ public function testConstructWithStyleName() { $fStyle = 'fStyle'; $pStyle = 'pStyle'; - $object = new PHPWord_Section_TextBreak($fStyle, $pStyle); + $object = new TextBreak($fStyle, $pStyle); $this->assertEquals($fStyle, $object->getFontStyle()); $this->assertEquals($pStyle, $object->getParagraphStyle()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TextRunTest.php b/Tests/PHPWord/Section/TextRunTest.php index 81402476d0..234e14acbc 100644 --- a/Tests/PHPWord/Section/TextRunTest.php +++ b/Tests/PHPWord/Section/TextRunTest.php @@ -1,73 +1,73 @@ assertInstanceOf('PHPWord_Section_TextRun', $oTextRun); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $oTextRun); $this->assertCount(0, $oTextRun->getElements()); $this->assertEquals($oTextRun->getParagraphStyle(), null); } public function testConstructString() { - $oTextRun = new PHPWord_Section_TextRun('pStyle'); + $oTextRun = new TextRun('pStyle'); - $this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $oTextRun); $this->assertCount(0, $oTextRun->getElements()); $this->assertEquals($oTextRun->getParagraphStyle(), 'pStyle'); } public function testConstructArray() { - $oTextRun = new PHPWord_Section_TextRun(array('spacing' => 100)); + $oTextRun = new TextRun(array('spacing' => 100)); - $this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $oTextRun); $this->assertCount(0, $oTextRun->getElements()); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oTextRun->getParagraphStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oTextRun->getParagraphStyle()); } public function testAddText() { - $oTextRun = new PHPWord_Section_TextRun(); + $oTextRun = new TextRun(); $element = $oTextRun->addText('text'); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); $this->assertCount(1, $oTextRun->getElements()); $this->assertEquals($element->getText(), 'text'); } public function testAddTextNotUTF8() { - $oTextRun = new PHPWord_Section_TextRun(); + $oTextRun = new TextRun(); $element = $oTextRun->addText(utf8_decode('ééé')); - $this->assertInstanceOf('PHPWord_Section_Text', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); $this->assertCount(1, $oTextRun->getElements()); $this->assertEquals($element->getText(), 'ééé'); } public function testAddLink() { - $oTextRun = new PHPWord_Section_TextRun(); + $oTextRun = new TextRun(); $element = $oTextRun->addLink('http://www.google.fr'); - $this->assertInstanceOf('PHPWord_Section_Link', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $element); $this->assertCount(1, $oTextRun->getElements()); $this->assertEquals($element->getLinkSrc(), 'http://www.google.fr'); } public function testAddLinkWithName() { - $oTextRun = new PHPWord_Section_TextRun(); + $oTextRun = new TextRun(); $element = $oTextRun->addLink('http://www.google.fr', utf8_decode('ééé')); - $this->assertInstanceOf('PHPWord_Section_Link', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $element); $this->assertCount(1, $oTextRun->getElements()); $this->assertEquals($element->getLinkSrc(), 'http://www.google.fr'); $this->assertEquals($element->getLinkName(), 'ééé'); @@ -79,19 +79,19 @@ public function testAddImage() \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $oTextRun = new PHPWord_Section_TextRun(); + $oTextRun = new TextRun(); $element = $oTextRun->addImage($src); - $this->assertInstanceOf('PHPWord_Section_Image', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element); $this->assertCount(1, $oTextRun->getElements()); } public function testCreateFootnote() { - $oTextRun = new PHPWord_Section_TextRun(); + $oTextRun = new TextRun(); $element = $oTextRun->createFootnote(); - $this->assertInstanceOf('PHPWord_Section_Footnote', $element); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footnote', $element); $this->assertCount(1, $oTextRun->getElements()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TextTest.php b/Tests/PHPWord/Section/TextTest.php index 1a33a730d7..0082e68ed3 100644 --- a/Tests/PHPWord/Section/TextTest.php +++ b/Tests/PHPWord/Section/TextTest.php @@ -1,42 +1,42 @@ assertInstanceOf('PHPWord_Section_Text', $oText); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $oText); $this->assertEquals(null, $oText->getText()); - $this->assertInstanceOf('PHPWord_Style_Font', $oText->getFontStyle()); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oText->getParagraphStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oText->getFontStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle()); } public function testText() { - $oText = new PHPWord_Section_Text('text'); + $oText = new Text('text'); $this->assertEquals($oText->getText(), 'text'); } public function testFont() { - $oText = new PHPWord_Section_Text('text', 'fontStyle'); + $oText = new Text('text', 'fontStyle'); $this->assertEquals($oText->getFontStyle(), 'fontStyle'); $oText->setFontStyle(array('bold' => true, 'italic' => true, 'size' => 16)); - $this->assertInstanceOf('PHPWord_Style_Font', $oText->getFontStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oText->getFontStyle()); } public function testParagraph() { - $oText = new PHPWord_Section_Text('text', 'fontStyle', 'paragraphStyle'); + $oText = new Text('text', 'fontStyle', 'paragraphStyle'); $this->assertEquals($oText->getParagraphStyle(), 'paragraphStyle'); $oText->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100)); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $oText->getParagraphStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Section/TitleTest.php b/Tests/PHPWord/Section/TitleTest.php index 97ce5de66c..a874c6a6c1 100644 --- a/Tests/PHPWord/Section/TitleTest.php +++ b/Tests/PHPWord/Section/TitleTest.php @@ -1,35 +1,35 @@ assertInstanceOf('PHPWord_Section_Title', $oTitle); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Title', $oTitle); $this->assertEquals($oTitle->getText(), 'text'); } public function testStyleNull() { - $oTitle = new PHPWord_Section_Title('text'); + $oTitle = new Title('text'); $this->assertEquals($oTitle->getStyle(), null); } public function testStyleNotNull() { - $oTitle = new PHPWord_Section_Title('text', 1, 'style'); + $oTitle = new Title('text', 1, 'style'); $this->assertEquals($oTitle->getStyle(), 'style'); } public function testAnchor() { - $oTitle = new PHPWord_Section_Title('text'); + $oTitle = new Title('text'); $iVal = rand(1, 1000); $oTitle->setAnchor($iVal); @@ -38,10 +38,10 @@ public function testAnchor() public function testBookmarkID() { - $oTitle = new PHPWord_Section_Title('text'); + $oTitle = new Title('text'); $iVal = rand(1, 1000); $oTitle->setBookmarkId($iVal); $this->assertEquals($oTitle->getBookmarkId(), $iVal); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/SectionTest.php b/Tests/PHPWord/SectionTest.php index ac540d06a8..559a345e64 100644 --- a/Tests/PHPWord/SectionTest.php +++ b/Tests/PHPWord/SectionTest.php @@ -1,78 +1,76 @@ assertAttributeEquals($oSection->getSettings(), '_settings', new PHPWord_Section(0)); + $oSection = new Section(0); + $this->assertAttributeEquals($oSection->getSettings(), '_settings', new Section(0)); } /** - * @covers PHPWord_Section::getElements + * @covers ::getElements */ public function testGetElements() { - $oSection = new PHPWord_Section(0); - $this->assertAttributeEquals($oSection->getElements(), '_elementCollection', new PHPWord_Section(0)); + $oSection = new Section(0); + $this->assertAttributeEquals($oSection->getElements(), '_elementCollection', new Section(0)); } /** - * @covers PHPWord_Section::getFooter + * @covers ::getFooter */ public function testGetFooter() { - $oSection = new PHPWord_Section(0); - $this->assertAttributeEquals($oSection->getFooter(), '_footer', new PHPWord_Section(0)); + $oSection = new Section(0); + $this->assertAttributeEquals($oSection->getFooter(), '_footer', new Section(0)); } /** - * @covers PHPWord_Section::getHeaders + * @covers ::getHeaders */ public function testGetHeaders() { - $oSection = new PHPWord_Section(0); - $this->assertAttributeEquals($oSection->getHeaders(), '_headers', new PHPWord_Section(0)); + $oSection = new Section(0); + $this->assertAttributeEquals($oSection->getHeaders(), '_headers', new Section(0)); } /** - * @covers PHPWord_Section::setSettings + * @covers ::setSettings */ public function testSetSettings() { $expected = 'landscape'; - $object = new PHPWord_Section(0); + $object = new 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 + * @covers ::addText + * @covers ::addLink + * @covers ::addTextBreak + * @covers ::addPageBreak + * @covers ::addTable + * @covers ::addListItem + * @covers ::addObject + * @covers ::addImage + * @covers ::addMemoryImage + * @covers ::addTOC + * @covers ::addTitle + * @covers ::createTextRun + * @covers ::createFootnote */ public function testAddElements() { @@ -86,7 +84,7 @@ public function testAddElements() ); $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif'; - $section = new PHPWord_Section(0); + $section = new Section(0); $section->addText(utf8_decode('ä')); $section->addLink(utf8_decode('http://äää.com'), utf8_decode('ä')); $section->addTextBreak(); @@ -103,8 +101,7 @@ public function testAddElements() $elementCollection = $section->getElements(); $elementType = 'Link'; - $objectType = "PHPWord_Section_{$elementType}"; - $this->assertInstanceOf($objectType, $elementCollection[1]); + $this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$elementType}", $elementCollection[1]); // $elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak', // 'Table', 'ListItem', 'Object', 'Image', 'MemoryImage', 'TOC', // 'Title', 'TextRun'); @@ -117,17 +114,16 @@ public function testAddElements() } /** - * @covers PHPWord_Section::createHeader - * @covers PHPWord_Section::createFooter + * @covers ::createHeader + * @covers ::createFooter */ public function testCreateHeaderFooter() { - $object = new PHPWord_Section(0); + $object = new Section(0); $elements = array('Header', 'Footer'); foreach ($elements as $element) { - $objectType = "PHPWord_Section_{$element}"; $method = "create{$element}"; - $this->assertInstanceOf($objectType, $object->$method()); + $this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$element}", $object->$method()); } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/SettingsTest.php b/Tests/PHPWord/SettingsTest.php index e61a212915..27194ca282 100644 --- a/Tests/PHPWord/SettingsTest.php +++ b/Tests/PHPWord/SettingsTest.php @@ -1,26 +1,24 @@ assertTrue(PHPWord_Settings::getCompatibility()); - $this->assertTrue(PHPWord_Settings::setCompatibility(false)); - $this->assertFalse(PHPWord_Settings::getCompatibility()); - $this->assertFalse(PHPWord_Settings::setCompatibility('Non boolean')); + $this->assertTrue(Settings::getCompatibility()); + $this->assertTrue(Settings::setCompatibility(false)); + $this->assertFalse(Settings::getCompatibility()); + $this->assertFalse(Settings::setCompatibility('Non boolean')); } -} +} \ No newline at end of file From 4e546d1a21a1c56d724ed7a67a8fe366428dad89 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 19 Mar 2014 11:04:48 +0400 Subject: [PATCH 04/15] https://github.com/PHPOffice/PHPWord/issues/58 - Part IV. --- Classes/PHPWord/Reader/AbstractReader.php | 12 +-- Tests/PHPWord/SectionTest.php | 3 +- Tests/PHPWord/Shared/DrawingTest.php | 24 +++-- Tests/PHPWord/Shared/FileTest.php | 34 ++----- Tests/PHPWord/Shared/FontTest.php | 20 ++-- Tests/PHPWord/Shared/StringTest.php | 24 +++-- Tests/PHPWord/Style/CellTest.php | 14 ++- Tests/PHPWord/Style/FontTest.php | 18 ++-- Tests/PHPWord/Style/ImageTest.php | 12 +-- Tests/PHPWord/Style/ListItemTest.php | 18 ++-- Tests/PHPWord/Style/ParagraphTest.php | 23 ++--- Tests/PHPWord/Style/RowTest.php | 8 +- Tests/PHPWord/Style/TOCTest.php | 14 ++- Tests/PHPWord/Style/TableFullTest.php | 18 ++-- Tests/PHPWord/Style/TableTest.php | 10 +- Tests/PHPWord/Style/TabsTest.php | 13 +-- Tests/PHPWord/StyleTest.php | 37 ++++--- Tests/PHPWord/TOCTest.php | 37 ++++--- Tests/PHPWord/TemplateTest.php | 10 +- Tests/PHPWord/Writer/ODText/ContentTest.php | 13 +-- Tests/PHPWord/Writer/ODTextTest.php | 65 ++++++------ Tests/PHPWord/Writer/RTFTest.php | 46 +++++---- Tests/PHPWord/Writer/Word2007/BaseTest.php | 36 ++++--- .../PHPWord/Writer/Word2007/DocumentTest.php | 15 ++- .../PHPWord/Writer/Word2007/FootnotesTest.php | 3 +- Tests/PHPWord/Writer/Word2007/StylesTest.php | 3 +- Tests/PHPWord/Writer/Word2007Test.php | 51 +++++----- Tests/PHPWordTest.php | 98 ++++++++----------- Tests/_inc/TestHelperDOCX.php | 5 +- samples/Sample_01_SimpleText.php | 6 +- samples/Sample_02_TabStops.php | 14 +-- samples/Sample_03_Sections.php | 4 +- samples/Sample_04_Textrun.php | 7 +- samples/Sample_05_Multicolumn.php | 4 +- samples/Sample_06_Footnote.php | 6 +- samples/Sample_08_ParagraphPagination.php | 6 +- samples/Sample_09_Tables.php | 6 +- samples/Sample_10_EastAsianFontStyle.php | 4 +- samples/Sample_11_ReadWord2007.php | 6 +- samples/Sample_12_HeaderFooter.php | 4 +- samples/Sample_13_Images.php | 4 +- samples/Sample_14_ListItem.php | 8 +- samples/Sample_15_Link.php | 6 +- samples/Sample_16_Object.php | 4 +- samples/Sample_17_TitleTOC.php | 4 +- samples/Sample_18_Watermark.php | 4 +- samples/Sample_19_TextBreak.php | 4 +- 47 files changed, 354 insertions(+), 431 deletions(-) diff --git a/Classes/PHPWord/Reader/AbstractReader.php b/Classes/PHPWord/Reader/AbstractReader.php index ba7f6565c1..4932d0547c 100644 --- a/Classes/PHPWord/Reader/AbstractReader.php +++ b/Classes/PHPWord/Reader/AbstractReader.php @@ -25,14 +25,14 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord\Reader; + use PhpOffice\PhpWord\Exceptions\Exception; /** - * PHPWord_Reader_Abstract - * - * @codeCoverageIgnore Abstract class + * @codeCoverageIgnore Abstract class */ -abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader +abstract class AbstractReader implements IReader { /** * Read data only? @@ -61,7 +61,7 @@ public function getReadDataOnly() * Set read data only * * @param bool $pValue - * @return PHPWord_Reader_IReader + * @return PhpOffice\PhpWord\Reader\IReader */ public function setReadDataOnly($pValue = true) { @@ -91,7 +91,7 @@ protected function openFile($pFilename) } /** - * Can the current PHPWord_Reader_IReader read the file? + * Can the current IReader read the file? * * @param string $pFilename * @return bool diff --git a/Tests/PHPWord/SectionTest.php b/Tests/PHPWord/SectionTest.php index 559a345e64..19a61c1ca0 100644 --- a/Tests/PHPWord/SectionTest.php +++ b/Tests/PHPWord/SectionTest.php @@ -107,8 +107,7 @@ public function testAddElements() // 'Title', 'TextRun'); // $i = 0; // foreach ($elementTypes as $elementType) { - // $objectType = "PHPWord_Section_{$elementType}"; - // $this->assertInstanceOf($objectType, $elementCollection[$i]); + // $this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$elementType}", $elementCollection[$i]); // $i++; // } } diff --git a/Tests/PHPWord/Shared/DrawingTest.php b/Tests/PHPWord/Shared/DrawingTest.php index 550ee67c6b..a49773d844 100644 --- a/Tests/PHPWord/Shared/DrawingTest.php +++ b/Tests/PHPWord/Shared/DrawingTest.php @@ -1,11 +1,9 @@ assertEquals(round($value * 9525), $result); - $result = PHPWord_Shared_Drawing::EMUToPixels($value); + $result = Drawing::EMUToPixels($value); $this->assertEquals(round($value / 9525), $result); - $result = PHPWord_Shared_Drawing::pixelsToPoints($value); + $result = Drawing::pixelsToPoints($value); $this->assertEquals($value * 0.67777777, $result); - $result = PHPWord_Shared_Drawing::pointsToPixels($value); + $result = Drawing::pointsToPixels($value); $this->assertEquals($value * 1.333333333, $result); - $result = PHPWord_Shared_Drawing::degreesToAngle($value); + $result = Drawing::degreesToAngle($value); $this->assertEquals((int)round($value * 60000), $result); - $result = PHPWord_Shared_Drawing::angleToDegrees($value); + $result = Drawing::angleToDegrees($value); $this->assertEquals(round($value / 60000), $result); - $result = PHPWord_Shared_Drawing::pixelsToCentimeters($value); + $result = Drawing::pixelsToCentimeters($value); $this->assertEquals($value * 0.028, $result); - $result = PHPWord_Shared_Drawing::centimetersToPixels($value); + $result = Drawing::centimetersToPixels($value); $this->assertEquals($value / 0.028, $result); } } @@ -59,8 +57,8 @@ public function testHtmlToRGB() $values[] = array('0F9D', false); // 4 characters // Conduct test foreach ($values as $value) { - $result = PHPWord_Shared_Drawing::htmlToRGB($value[0]); + $result = Drawing::htmlToRGB($value[0]); $this->assertEquals($value[1], $result); } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Shared/FileTest.php b/Tests/PHPWord/Shared/FileTest.php index a5ac348f67..6a62b10044 100644 --- a/Tests/PHPWord/Shared/FileTest.php +++ b/Tests/PHPWord/Shared/FileTest.php @@ -1,13 +1,11 @@ assertTrue(PHPWord_Shared_File::file_exists('blank.docx')); + $this->assertTrue(File::file_exists('blank.docx')); } /** * Test file_exists() */ public function testNoFileExists() { - $dir = join(DIRECTORY_SEPARATOR, array( - PHPWORD_TESTS_DIR_ROOT, - '_files', - 'templates' - )); + $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates')); chdir($dir); - $this->assertFalse(PHPWord_Shared_File::file_exists('404.docx')); + $this->assertFalse(File::file_exists('404.docx')); } /** @@ -44,14 +34,10 @@ public function testNoFileExists() */ public function testRealpath() { - $dir = join(DIRECTORY_SEPARATOR, array( - PHPWORD_TESTS_DIR_ROOT, - '_files', - 'templates' - )); + $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates')); chdir($dir); $file = 'blank.docx'; $expected = $dir . DIRECTORY_SEPARATOR . $file; - $this->assertEquals($expected, PHPWord_Shared_File::realpath($file)); + $this->assertEquals($expected, File::realpath($file)); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Shared/FontTest.php b/Tests/PHPWord/Shared/FontTest.php index 5a40e465c8..e87bda4587 100644 --- a/Tests/PHPWord/Shared/FontTest.php +++ b/Tests/PHPWord/Shared/FontTest.php @@ -2,11 +2,9 @@ namespace PHPWord\Tests\Shared; use PHPWord; -use PHPWord_Shared_Font; +use PhpOffice\PhpWord\Shared\Font; /** - * Class FontTest - * * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -21,25 +19,25 @@ public function testConversions() $original = 1; - $result = PHPWord_Shared_Font::fontSizeToPixels($original); + $result = Font::fontSizeToPixels($original); $this->assertEquals($original * 16 / 12, $result); - $result = PHPWord_Shared_Font::inchSizeToPixels($original); + $result = Font::inchSizeToPixels($original); $this->assertEquals($original * 96, $result); - $result = PHPWord_Shared_Font::centimeterSizeToPixels($original); + $result = Font::centimeterSizeToPixels($original); $this->assertEquals($original * 37.795275591, $result); - $result = PHPWord_Shared_Font::centimeterSizeToTwips($original); + $result = Font::centimeterSizeToTwips($original); $this->assertEquals($original * 565.217, $result); - $result = PHPWord_Shared_Font::inchSizeToTwips($original); + $result = Font::inchSizeToTwips($original); $this->assertEquals($original * 565.217 * 2.54, $result); - $result = PHPWord_Shared_Font::pixelSizeToTwips($original); + $result = Font::pixelSizeToTwips($original); $this->assertEquals($original * 565.217 / 37.795275591, $result); - $result = PHPWord_Shared_Font::pointSizeToTwips($original); + $result = Font::pointSizeToTwips($original); $this->assertEquals($original * 20, $result); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Shared/StringTest.php b/Tests/PHPWord/Shared/StringTest.php index 3698e2e0e1..d8918f555f 100644 --- a/Tests/PHPWord/Shared/StringTest.php +++ b/Tests/PHPWord/Shared/StringTest.php @@ -1,33 +1,31 @@ assertTrue(PHPWord_Shared_String::IsUTF8('')); - $this->assertTrue(PHPWord_Shared_String::IsUTF8('éééé')); - $this->assertFalse(PHPWord_Shared_String::IsUTF8(utf8_decode('éééé'))); + $this->assertTrue(String::IsUTF8('')); + $this->assertTrue(String::IsUTF8('éééé')); + $this->assertFalse(String::IsUTF8(utf8_decode('éééé'))); } public function testControlCharacterOOXML2PHP() { - $this->assertEquals('', PHPWord_Shared_String::ControlCharacterOOXML2PHP('')); - $this->assertEquals(chr(0x08), PHPWord_Shared_String::ControlCharacterOOXML2PHP('_x0008_')); + $this->assertEquals('', String::ControlCharacterOOXML2PHP('')); + $this->assertEquals(chr(0x08), String::ControlCharacterOOXML2PHP('_x0008_')); } public function testControlCharacterPHP2OOXML() { - $this->assertEquals('', PHPWord_Shared_String::ControlCharacterPHP2OOXML('')); - $this->assertEquals('_x0008_', PHPWord_Shared_String::ControlCharacterPHP2OOXML(chr(0x08))); + $this->assertEquals('', String::ControlCharacterPHP2OOXML('')); + $this->assertEquals('_x0008_', String::ControlCharacterPHP2OOXML(chr(0x08))); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/CellTest.php b/Tests/PHPWord/Style/CellTest.php index 0d47095128..8bf5c6a3be 100644 --- a/Tests/PHPWord/Style/CellTest.php +++ b/Tests/PHPWord/Style/CellTest.php @@ -1,11 +1,9 @@ 'left', - 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR, + 'textDirection' => Cell::TEXT_DIR_BTLR, 'bgColor' => 'FFFF00', 'borderTopSize' => 120, 'borderTopColor' => 'FFFF00', @@ -46,7 +44,7 @@ public function testSetGetNormal() */ public function testBorderColor() { - $object = new PHPWord_Style_Cell(); + $object = new Cell(); $default = '000000'; $value = 'FF0000'; @@ -66,11 +64,11 @@ public function testBorderColor() */ public function testBorderSize() { - $object = new PHPWord_Style_Cell(); + $object = new Cell(); $value = 120; $expected = array($value, $value, $value, $value); $object->setStyleValue('_borderSize', $value); $this->assertEquals($expected, $object->getBorderSize()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/FontTest.php b/Tests/PHPWord/Style/FontTest.php index 46cec029b2..7f317933ca 100644 --- a/Tests/PHPWord/Style/FontTest.php +++ b/Tests/PHPWord/Style/FontTest.php @@ -2,12 +2,10 @@ namespace PHPWord\Tests\Style; use PHPWord; -use PHPWord_Style_Font; +use PhpOffice\PhpWord\Style\Font; use PHPWord\Tests\TestHelperDOCX; /** - * Class FontTest - * * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -23,10 +21,10 @@ public function tearDown() */ public function testInitiation() { - $object = new PHPWord_Style_Font('text', array('align' => 'both')); + $object = new Font('text', array('align' => 'both')); $this->assertEquals('text', $object->getStyleType()); - $this->assertInstanceOf('PHPWord_Style_Paragraph', $object->getParagraphStyle()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle()); } /** @@ -34,7 +32,7 @@ public function testInitiation() */ public function testSetStyleValueWithNullOrEmpty() { - $object = new PHPWord_Style_Font(); + $object = new Font(); $attributes = array( 'name' => PHPWord::DEFAULT_FONT_NAME, @@ -43,7 +41,7 @@ public function testSetStyleValueWithNullOrEmpty() 'italic' => false, 'superScript' => false, 'subScript' => false, - 'underline' => PHPWord_Style_Font::UNDERLINE_NONE, + 'underline' => Font::UNDERLINE_NONE, 'strikethrough' => false, 'color' => PHPWord::DEFAULT_FONT_COLOR, 'fgColor' => null, @@ -62,7 +60,7 @@ public function testSetStyleValueWithNullOrEmpty() */ public function testSetStyleValueNormal() { - $object = new PHPWord_Style_Font(); + $object = new Font(); $attributes = array( 'name' => 'Times New Roman', @@ -71,7 +69,7 @@ public function testSetStyleValueNormal() 'italic' => true, 'superScript' => true, 'subScript' => true, - 'underline' => PHPWord_Style_Font::UNDERLINE_HEAVY, + 'underline' => Font::UNDERLINE_HEAVY, 'strikethrough' => true, 'color' => '999999', 'fgColor' => '999999', @@ -113,4 +111,4 @@ public function testLineHeight() $this->assertEquals(720, $lineHeight); $this->assertEquals('auto', $lineRule); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/ImageTest.php b/Tests/PHPWord/Style/ImageTest.php index 7e7b38881a..2ed15f4f56 100644 --- a/Tests/PHPWord/Style/ImageTest.php +++ b/Tests/PHPWord/Style/ImageTest.php @@ -1,11 +1,9 @@ 200, @@ -39,7 +37,7 @@ public function testSetGetNormal() */ public function testSetStyleValue() { - $object = new PHPWord_Style_Image(); + $object = new Image(); $properties = array( 'width' => 200, @@ -62,7 +60,7 @@ public function testSetStyleValue() */ public function testSetWrappingStyleException() { - $object = new PHPWord_Style_Image(); + $object = new Image(); $object->setWrappingStyle('foo'); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/ListItemTest.php b/Tests/PHPWord/Style/ListItemTest.php index 890f468347..afc9744d9a 100644 --- a/Tests/PHPWord/Style/ListItemTest.php +++ b/Tests/PHPWord/Style/ListItemTest.php @@ -1,11 +1,9 @@ assertEquals($value, $object->getListType()); } @@ -27,9 +25,9 @@ public function testConstruct() */ public function testSetStyleValue() { - $object = new PHPWord_Style_ListItem(); + $object = new ListItem(); - $value = PHPWord_Style_ListItem::TYPE_ALPHANUM; + $value = ListItem::TYPE_ALPHANUM; $object->setStyleValue('_listType', $value); $this->assertEquals($value, $object->getListType()); } @@ -39,10 +37,10 @@ public function testSetStyleValue() */ public function testListType() { - $object = new PHPWord_Style_ListItem(); + $object = new ListItem(); - $value = PHPWord_Style_ListItem::TYPE_ALPHANUM; + $value = ListItem::TYPE_ALPHANUM; $object->setListType($value); $this->assertEquals($value, $object->getListType()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/ParagraphTest.php b/Tests/PHPWord/Style/ParagraphTest.php index ff084a5716..d005078cbe 100644 --- a/Tests/PHPWord/Style/ParagraphTest.php +++ b/Tests/PHPWord/Style/ParagraphTest.php @@ -2,13 +2,11 @@ namespace PHPWord\Tests\Style; use PHPWord; -use PHPWord_Style_Paragraph; -use PHPWord_Style_Tab; +use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\Style\Tab; use PHPWord\Tests\TestHelperDOCX; /** - * Class ParagraphTest - * * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -24,7 +22,7 @@ public function tearDown() */ public function testSetStyleValueWithNullOrEmpty() { - $object = new PHPWord_Style_Paragraph(); + $object = new Paragraph(); $attributes = array( 'tabs' => null, @@ -47,7 +45,7 @@ public function testSetStyleValueWithNullOrEmpty() */ public function testSetStyleValueNormal() { - $object = new PHPWord_Style_Paragraph(); + $object = new Paragraph(); $attributes = array( 'align' => 'justify', @@ -84,12 +82,9 @@ public function testSetStyleValueNormal() */ public function testTabs() { - $object = new PHPWord_Style_Paragraph(); - $object->setTabs(array( - new PHPWord_Style_Tab('left', 1550), - new PHPWord_Style_Tab('right', 5300), - )); - $this->assertInstanceOf('PHPWord_Style_Tabs', $object->getTabs()); + $object = new Paragraph(); + $object->setTabs(array(new Tab('left', 1550), new Tab('right', 5300))); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Tabs', $object->getTabs()); } public function testLineHeight() @@ -128,8 +123,8 @@ public function testLineHeight() */ public function testLineHeightValidation() { - $object = new PHPWord_Style_Paragraph(); + $object = new Paragraph(); $object->setLineHeight('12.5pt'); $this->assertEquals(12.5, $object->getLineHeight()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/RowTest.php b/Tests/PHPWord/Style/RowTest.php index cbbecfbc09..97131509f3 100644 --- a/Tests/PHPWord/Style/RowTest.php +++ b/Tests/PHPWord/Style/RowTest.php @@ -1,11 +1,9 @@ true, @@ -37,4 +35,4 @@ public function testProperties() $this->assertEquals($expected, $object->$get()); } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/TOCTest.php b/Tests/PHPWord/Style/TOCTest.php index 4607ba37aa..3e34a82c46 100644 --- a/Tests/PHPWord/Style/TOCTest.php +++ b/Tests/PHPWord/Style/TOCTest.php @@ -1,13 +1,11 @@ 9062, - 'tabLeader' => PHPWord_Style_TOC::TABLEADER_DOT, + 'tabLeader' => TOC::TABLEADER_DOT, 'indent' => 200, ); foreach ($properties as $key => $value) { @@ -36,4 +34,4 @@ public function testProperties() $this->assertEquals(null, $object->$get()); } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/TableFullTest.php b/Tests/PHPWord/Style/TableFullTest.php index 7f7b77324b..6edc74c9cf 100644 --- a/Tests/PHPWord/Style/TableFullTest.php +++ b/Tests/PHPWord/Style/TableFullTest.php @@ -1,11 +1,9 @@ 'FF0000'); $styleFirstRow = array('borderBottomSize' => 3); - $object = new PHPWord_Style_TableFull($styleTable, $styleFirstRow); + $object = new TableFull($styleTable, $styleFirstRow); $this->assertEquals('FF0000', $object->getBgColor()); $firstRow = $object->getFirstRow(); - $this->assertInstanceOf('PHPWord_Style_TableFull', $firstRow); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TableFull', $firstRow); $this->assertEquals(3, $firstRow->getBorderBottomSize()); } @@ -37,7 +35,7 @@ public function testConstruct() */ public function testSetGetNormal() { - $object = new PHPWord_Style_TableFull(); + $object = new TableFull(); $attributes = array( 'bgColor' => 'FF0000', @@ -74,7 +72,7 @@ public function testSetGetNormal() */ public function testBorderColor() { - $object = new PHPWord_Style_TableFull(); + $object = new TableFull(); $parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV'); $value = 'FF0000'; @@ -96,7 +94,7 @@ public function testBorderColor() */ public function testBorderSize() { - $object = new PHPWord_Style_TableFull(); + $object = new TableFull(); $parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV'); $value = 4; @@ -118,7 +116,7 @@ public function testBorderSize() */ public function testCellMargin() { - $object = new PHPWord_Style_TableFull(); + $object = new TableFull(); $parts = array('Top', 'Left', 'Right', 'Bottom'); $value = 240; @@ -130,4 +128,4 @@ public function testCellMargin() } $this->assertEquals($values, $object->getCellMargin()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/TableTest.php b/Tests/PHPWord/Style/TableTest.php index 439aa5ae8b..1a2da78955 100644 --- a/Tests/PHPWord/Style/TableTest.php +++ b/Tests/PHPWord/Style/TableTest.php @@ -1,11 +1,9 @@ assertEquals($values, $object->getCellMargin()); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Style/TabsTest.php b/Tests/PHPWord/Style/TabsTest.php index 7579ae6de0..d6aa434206 100644 --- a/Tests/PHPWord/Style/TabsTest.php +++ b/Tests/PHPWord/Style/TabsTest.php @@ -2,13 +2,10 @@ namespace PHPWord\Tests\Style; use PHPWord; -use PHPWord_Style_Tab; -use PHPWord_Style_Tabs; +use PhpOffice\PhpWord\Style\Tab; use PHPWord\Tests\TestHelperDOCX; /** - * Class TabsTest - * * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -28,11 +25,7 @@ public function tearDown() public function testTabsStyle() { $PHPWord = new PHPWord(); - $PHPWord->addParagraphStyle('tabbed', array( - 'tabs' => array( - new PHPWord_Style_Tab('left', 1440, 'dot'), - ) - )); + $PHPWord->addParagraphStyle('tabbed', array('tabs' => array(new Tab('left', 1440, 'dot')))); $doc = TestHelperDOCX::getDocument($PHPWord); $file = 'word/styles.xml'; $path = '/w:styles/w:style[@w:styleId="tabbed"]/w:pPr/w:tabs/w:tab[1]'; @@ -41,4 +34,4 @@ public function testTabsStyle() $this->assertEquals(1440, $element->getAttribute('w:pos')); $this->assertEquals('dot', $element->getAttribute('w:leader')); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/StyleTest.php b/Tests/PHPWord/StyleTest.php index 9e442cb13e..bdca8ea746 100644 --- a/Tests/PHPWord/StyleTest.php +++ b/Tests/PHPWord/StyleTest.php @@ -1,22 +1,20 @@ '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); + Style::addParagraphStyle('Paragraph', $paragraph); + Style::addFontStyle('Font', $font); + Style::addLinkStyle('Link', $font); + Style::addTableStyle('Table', $table); + Style::addTitleStyle(1, $font); + Style::setDefaultParagraphStyle($paragraph); - $this->assertEquals($elementCount, count(PHPWord_Style::getStyles())); + $this->assertEquals($elementCount, count(Style::getStyles())); foreach ($styles as $name => $style) { - $expected = "PHPWord_Style_{$style}"; - $this->assertInstanceOf($expected, PHPWord_Style::getStyle($name)); + $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$style}", Style::getStyle($name)); } - $this->assertNull(PHPWord_Style::getStyle('Unknown')); + $this->assertNull(Style::getStyle('Unknown')); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/TOCTest.php b/Tests/PHPWord/TOCTest.php index d4503da5fd..9048d00978 100644 --- a/Tests/PHPWord/TOCTest.php +++ b/Tests/PHPWord/TOCTest.php @@ -1,38 +1,35 @@ 9062, - 'tabLeader' => PHPWord_Style_TOC::TABLEADER_DOT, + 'tabLeader' => PhpOffice\PhpWord\Style\TOC::TABLEADER_DOT, 'indent' => 200, ); - $object = new PHPWord_TOC( + $object = new TOC( array('size' => 11), array('tabPos' => $expected['tabPos']) ); $tocStyle = $object->getStyleTOC(); - $this->assertInstanceOf('PHPWord_Style_TOC', $tocStyle); - $this->assertInstanceOf('PHPWord_Style_Font', $object->getStyleFont()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TOC', $tocStyle); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $object->getStyleFont()); foreach ($expected as $key => $value) { $method = "get{$key}"; @@ -41,8 +38,8 @@ public function testConstruct() } /** - * @covers PHPWord_TOC::addTitle - * @covers PHPWord_TOC::getTitles + * @covers ::addTitle + * @covers ::getTitles */ public function testAddAndGetTitle() { @@ -56,20 +53,20 @@ public function testAddAndGetTitle() 'Heading 3' => 3, ); - // @covers PHPWord_TOC::addTitle + // @covers ::addTitle foreach ($titles as $text => $depth) { - $response = PHPWord_TOC::addTitle($text, $depth); + $response = TOC::addTitle($text, $depth); } $this->assertEquals($anchor, $response[0]); $this->assertEquals($bookmark, $response[1]); - // @covers PHPWord_TOC::getTitles + // @covers ::getTitles $i = 0; - $savedTitles = PHPWord_TOC::getTitles(); + $savedTitles = TOC::getTitles(); foreach ($titles as $text => $depth) { $this->assertEquals($text, $savedTitles[$i]['text']); $this->assertEquals($depth, $savedTitles[$i]['depth']); $i++; } } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PHPWord/TemplateTest.php index 872ab182e4..7c7417d5ac 100644 --- a/Tests/PHPWord/TemplateTest.php +++ b/Tests/PHPWord/TemplateTest.php @@ -1,11 +1,11 @@ load( \join( @@ -93,7 +93,7 @@ final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn) */ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() { - $template = new PHPWord_Template( + $template = new Template( \join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx') @@ -123,7 +123,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete */ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() { - $template = new PHPWord_Template( + $template = new Template( \join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'corrupted_main_document_part.docx') diff --git a/Tests/PHPWord/Writer/ODText/ContentTest.php b/Tests/PHPWord/Writer/ODText/ContentTest.php index 63b84d7553..31659d3287 100644 --- a/Tests/PHPWord/Writer/ODText/ContentTest.php +++ b/Tests/PHPWord/Writer/ODText/ContentTest.php @@ -2,14 +2,11 @@ namespace PHPWord\Tests\Writer\ODText; use PHPWord; -use PHPWord_Style; use PHPWord\Tests\TestHelperDOCX; /** - * Class ContentTest - * - * @package PHPWord\Tests - * @coversDefaultClass PHPWord_Writer_ODText_Content + * @package PHPWord\Tests + * @coversDefaultClass PhpOffice\PhpWord\Writer\ODText\Content * @runTestsInSeparateProcesses */ class ContentTest extends \PHPUnit_Framework_TestCase @@ -23,8 +20,8 @@ public function tearDown() } /** - * covers ::writeContent - * covers + * covers ::writeContent + * covers */ public function testWriteContent() { @@ -62,4 +59,4 @@ public function testWriteContent() $element = "/office:document-content/office:body/office:text/text:p"; $this->assertEquals($expected, $doc->getElement($element, 'content.xml')->nodeValue); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/ODTextTest.php b/Tests/PHPWord/Writer/ODTextTest.php index ef92d249fd..f1cc721370 100644 --- a/Tests/PHPWord/Writer/ODTextTest.php +++ b/Tests/PHPWord/Writer/ODTextTest.php @@ -1,14 +1,12 @@ assertInstanceOf('PHPWord', $object->getPHPWord()); - $this->assertInstanceOf("PHPWord_HashTable", $object->getDrawingHashTable()); + $this->assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable()); $this->assertEquals('./', $object->getDiskCachingDirectory()); - $writerParts = array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles'); - foreach ($writerParts as $part) { + foreach (array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles') as $part) { $this->assertInstanceOf( - "PHPWord_Writer_ODText_{$part}", + "PhpOffice\\PhpWord\\Writer\\ODText\\{$part}", $object->getWriterPart($part) ); $this->assertInstanceOf( - "PHPWord_Writer_ODText", + 'PhpOffice\\PhpWord\\Writer\\ODText', $object->getWriterPart($part)->getParentWriter() ); } } /** - * @covers ::getPHPWord - * @expectedException Exception - * @expectedExceptionMessage No PHPWord assigned. + * @covers ::getPHPWord + * @expectedException Exception + * @expectedExceptionMessage No PHPWord assigned. */ public function testConstructWithNull() { - $object = new PHPWord_Writer_ODText(); + $object = new ODText(); $object->getPHPWord(); } /** - * @covers ::save + * @covers ::save */ public function testSave() { @@ -84,7 +81,7 @@ public function testSave() $section = $phpWord->createSection(); $textrun = $section->createTextRun(); $textrun->addText('Test 3'); - $writer = new PHPWord_Writer_ODText($phpWord); + $writer = new ODText($phpWord); $writer->save($file); $this->assertTrue(file_exists($file)); @@ -93,53 +90,53 @@ public function testSave() } /** - * @covers ::save - * @todo Haven't got any method to test this + * @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 = new ODText($phpWord); $writer->save('php://output'); } /** - * @covers ::save - * @expectedException Exception - * @expectedExceptionMessage PHPWord object unassigned. + * @covers ::save + * @expectedException Exception + * @expectedExceptionMessage PHPWord object unassigned. */ public function testSaveException() { - $writer = new PHPWord_Writer_ODText(); + $writer = new ODText(); $writer->save(); } /** - * @covers ::getWriterPart + * @covers ::getWriterPart */ public function testGetWriterPartNull() { - $object = new PHPWord_Writer_ODText(); + $object = new ODText(); $this->assertNull($object->getWriterPart('foo')); } /** - * @covers ::setUseDiskCaching - * @covers ::getUseDiskCaching + * @covers ::setUseDiskCaching + * @covers ::getUseDiskCaching */ public function testSetGetUseDiskCaching() { - $object = new PHPWord_Writer_ODText(); + $object = new ODText(); $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); $this->assertTrue($object->getUseDiskCaching()); $this->assertEquals(PHPWORD_TESTS_DIR_ROOT, $object->getDiskCachingDirectory()); } /** - * @covers ::setUseDiskCaching - * @expectedException Exception + * @covers ::setUseDiskCaching + * @expectedException Exception */ public function testSetUseDiskCachingException() { @@ -148,7 +145,7 @@ public function testSetUseDiskCachingException() array(\PHPWORD_TESTS_DIR_ROOT, 'foo') ); - $object = new PHPWord_Writer_ODText($phpWord); + $object = new ODText($phpWord); $object->setUseDiskCaching(true, $dir); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/RTFTest.php b/Tests/PHPWord/Writer/RTFTest.php index d071def78f..6a7c078039 100644 --- a/Tests/PHPWord/Writer/RTFTest.php +++ b/Tests/PHPWord/Writer/RTFTest.php @@ -1,67 +1,65 @@ assertInstanceOf('PHPWord', $object->getPHPWord()); - $this->assertInstanceOf("PHPWord_HashTable", $object->getDrawingHashTable()); + $this->assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable()); } /** - * covers ::__construct - * @expectedException Exception - * @expectedExceptionMessage No PHPWord assigned. + * covers ::__construct + * @expectedException Exception + * @expectedExceptionMessage No PHPWord assigned. */ public function testConstructWithNull() { - $object = new PHPWord_Writer_RTF(); + $object = new RTF(); $object->getPHPWord(); } /** - * @covers ::save - * @todo Haven't got any method to test this + * @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 = new RTF($phpWord); $writer->save('php://output'); } /** - * @covers ::save - * @expectedException Exception - * @expectedExceptionMessage PHPWord object unassigned. + * @covers ::save + * @expectedException Exception + * @expectedExceptionMessage PHPWord object unassigned. */ public function testSaveException() { - $writer = new PHPWord_Writer_RTF(); + $writer = new RTF(); $writer->save(); } /** - * @covers ::save - * @covers :: + * @covers ::save + * @covers :: */ public function testSave() { @@ -97,11 +95,11 @@ public function testSave() $textrun = $section->createTextRun(); $textrun->addText('Test 3'); $textrun->addTextBreak(); - $writer = new PHPWord_Writer_RTF($phpWord); + $writer = new RTF($phpWord); $writer->save($file); $this->assertTrue(file_exists($file)); unlink($file); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007/BaseTest.php b/Tests/PHPWord/Writer/Word2007/BaseTest.php index fde6e30b20..c66ce9ce02 100644 --- a/Tests/PHPWord/Writer/Word2007/BaseTest.php +++ b/Tests/PHPWord/Writer/Word2007/BaseTest.php @@ -2,14 +2,11 @@ namespace PHPWord\Tests\Writer\Word2007; use PHPWord; -use PHPWord_Style; use PHPWord\Tests\TestHelperDOCX; /** - * Class BaseTest - * - * @package PHPWord\Tests - * @coversDefaultClass PHPWord_Writer_Word2007_Base + * @package PHPWord\Tests + * @coversDefaultClass PhpOffice\PhpWord\Writer\Word2007\Base * @runTestsInSeparateProcesses */ class BaseTest extends \PHPUnit_Framework_TestCase @@ -23,7 +20,7 @@ public function tearDown() } /** - * covers ::_writeText + * covers ::_writeText */ public function testWriteText() { @@ -44,7 +41,7 @@ public function testWriteText() } /** - * covers ::_writeTextRun + * covers ::_writeTextRun */ public function testWriteTextRun() { @@ -71,7 +68,7 @@ public function testWriteTextRun() } /** - * covers ::_writeLink + * covers ::_writeLink */ public function testWriteLink() { @@ -88,7 +85,7 @@ public function testWriteLink() } /** - * covers ::_writePreserveText + * covers ::_writePreserveText */ public function testWritePreserveText() { @@ -104,8 +101,9 @@ public function testWritePreserveText() $this->assertEquals('PAGE', $preserve->nodeValue); $this->assertEquals('preserve', $preserve->getAttribute('xml:space')); } + /** - * covers ::_writeTextBreak + * covers ::_writeTextBreak */ public function testWriteTextBreak() { @@ -130,7 +128,7 @@ public function testWriteTextBreak() } /** - * covers ::_writeParagraphStyle + * covers ::_writeParagraphStyle */ public function testWriteParagraphStyleAlign() { @@ -146,7 +144,7 @@ public function testWriteParagraphStyleAlign() } /** - * covers ::_writeParagraphStyle + * covers ::_writeParagraphStyle */ public function testWriteParagraphStylePagination() { @@ -176,7 +174,7 @@ public function testWriteParagraphStylePagination() } /** - * covers ::_writeTextStyle + * covers ::_writeTextStyle */ public function testWriteFontStyle() { @@ -208,7 +206,7 @@ public function testWriteFontStyle() } /** - * covers ::_writeTableStyle + * covers ::_writeTableStyle */ public function testWriteTableStyle() { @@ -266,7 +264,7 @@ public function testWriteTableStyle() } /** - * covers ::_writeCellStyle + * covers ::_writeCellStyle */ public function testWriteCellStyleCellGridSpan() { @@ -293,7 +291,7 @@ public function testWriteCellStyleCellGridSpan() } /** - * covers ::_writeImage + * covers ::_writeImage */ public function testWriteImagePosition() { @@ -318,7 +316,7 @@ public function testWriteImagePosition() } /** - * covers ::_writeWatermark + * covers ::_writeWatermark */ public function testWriteWatermark() { @@ -338,7 +336,7 @@ public function testWriteWatermark() } /** - * covers ::_writeTitle + * covers ::_writeTitle */ public function testWriteTitle() { @@ -352,4 +350,4 @@ public function testWriteTitle() $element = "/w:document/w:body/w:p/w:r/w:fldChar"; $this->assertEquals('end', $doc->getElementAttribute($element, 'w:fldCharType')); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007/DocumentTest.php b/Tests/PHPWord/Writer/Word2007/DocumentTest.php index fe854feebe..70a16dc007 100644 --- a/Tests/PHPWord/Writer/Word2007/DocumentTest.php +++ b/Tests/PHPWord/Writer/Word2007/DocumentTest.php @@ -2,12 +2,9 @@ namespace PHPWord\Tests\Writer\Word2007; use PHPWord; -use PHPWord_Writer_Word2007; -use PHPWord_Writer_Word2007_Document; use PHPWord\Tests\TestHelperDOCX; /** - * Class DocumentTest * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -34,11 +31,11 @@ public function testWriteEndSectionPageNumbering() } /** - * covers ::_writeTOC - * covers ::_writePageBreak - * covers ::_writeListItem - * covers ::_writeTitle - * covers ::_writeObject + * covers ::_writeTOC + * covers ::_writePageBreak + * covers ::_writeListItem + * covers ::_writeTitle + * covers ::_writeObject */ public function testElements() { @@ -84,4 +81,4 @@ public function testElements() $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/PHPWord/Writer/Word2007/FootnotesTest.php b/Tests/PHPWord/Writer/Word2007/FootnotesTest.php index ea49bd6726..5ad4b8c717 100644 --- a/Tests/PHPWord/Writer/Word2007/FootnotesTest.php +++ b/Tests/PHPWord/Writer/Word2007/FootnotesTest.php @@ -5,7 +5,6 @@ use PHPWord\Tests\TestHelperDOCX; /** - * Class PHPWord_Writer_Word2007_FootnotesTest * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -31,4 +30,4 @@ public function testWriteFootnotes() $this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:footnoteReference")); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007/StylesTest.php b/Tests/PHPWord/Writer/Word2007/StylesTest.php index bcdc4b815d..026b5eaaaa 100644 --- a/Tests/PHPWord/Writer/Word2007/StylesTest.php +++ b/Tests/PHPWord/Writer/Word2007/StylesTest.php @@ -5,7 +5,6 @@ use PHPWord\Tests\TestHelperDOCX; /** - * Class PHPWord_Writer_Word2007_StylesTest * @package PHPWord\Tests * @runTestsInSeparateProcesses */ @@ -68,4 +67,4 @@ public function testWriteStyles() $element = $doc->getElement($path, $file); $this->assertEquals('Normal', $element->getAttribute('w:val')); } -} +} \ No newline at end of file diff --git a/Tests/PHPWord/Writer/Word2007Test.php b/Tests/PHPWord/Writer/Word2007Test.php index 95abee8363..34e025d81a 100644 --- a/Tests/PHPWord/Writer/Word2007Test.php +++ b/Tests/PHPWord/Writer/Word2007Test.php @@ -1,15 +1,13 @@ assertInstanceOf( - "PHPWord_Writer_Word2007_{$part}", + "PhpOffice\\PhpWord\\Writer\\Word2007\\{$part}", $object->getWriterPart($part) ); $this->assertInstanceOf( - "PHPWord_Writer_Word2007", + 'PhpOffice\\PhpWord\\Writer\\Word2007', $object->getWriterPart($part)->getParentWriter() ); } } /** - * @covers ::save + * @covers ::save */ public function testSave() { @@ -57,7 +64,7 @@ public function testSave() $textrun = $section->createTextRun(); $textrun->addText('Test 3'); - $writer = new PHPWord_Writer_Word2007($phpWord); + $writer = new Word2007($phpWord); $file = \join( \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.docx') @@ -68,7 +75,7 @@ public function testSave() } /** - * @covers ::checkContentTypes + * @covers ::checkContentTypes */ public function testCheckContentTypes() { @@ -98,20 +105,20 @@ public function testCheckContentTypes() } /** - * @covers ::setUseDiskCaching - * @covers ::getUseDiskCaching + * @covers ::setUseDiskCaching + * @covers ::getUseDiskCaching */ public function testSetGetUseDiskCaching() { - $object = new PHPWord_Writer_Word2007(); + $object = new Word2007(); $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); $this->assertTrue($object->getUseDiskCaching()); } /** - * @covers ::setUseDiskCaching - * @expectedException Exception + * @covers ::setUseDiskCaching + * @expectedException Exception */ public function testSetUseDiskCachingException() { @@ -120,7 +127,7 @@ public function testSetUseDiskCachingException() array(\PHPWORD_TESTS_DIR_ROOT, 'foo') ); - $object = new PHPWord_Writer_Word2007(); + $object = new Word2007(); $object->setUseDiskCaching(true, $dir); } -} +} \ No newline at end of file diff --git a/Tests/PHPWordTest.php b/Tests/PHPWordTest.php index 15106af6bb..4ab63075a1 100644 --- a/Tests/PHPWordTest.php +++ b/Tests/PHPWordTest.php @@ -1,38 +1,33 @@ assertEquals( - new PHPWord_DocumentProperties(), - $object->getProperties() - ); + $this->assertEquals(new DocumentProperties(), $object->getProperties()); $this->assertEquals( PHPWord::DEFAULT_FONT_NAME, $object->getDefaultFontName() @@ -44,8 +39,8 @@ public function testConstruct() } /** - * @covers PHPWord::setProperties - * @covers PHPWord::getProperties + * @covers ::setProperties + * @covers ::getProperties */ public function testSetGetProperties() { @@ -58,20 +53,20 @@ public function testSetGetProperties() } /** - * @covers PHPWord::createSection - * @covers PHPWord::getSections + * @covers ::createSection + * @covers ::getSections */ public function testCreateGetSections() { $object = new PHPWord(); - $this->assertEquals(new PHPWord_Section(1), $object->createSection()); + $this->assertEquals(new Section(1), $object->createSection()); $object->createSection(); $this->assertEquals(2, count($object->getSections())); } /** - * @covers PHPWord::setDefaultFontName - * @covers PHPWord::getDefaultFontName + * @covers ::setDefaultFontName + * @covers ::getDefaultFontName */ public function testSetGetDefaultFontName() { @@ -86,8 +81,8 @@ public function testSetGetDefaultFontName() } /** - * @covers PHPWord::setDefaultFontSize - * @covers PHPWord::getDefaultFontSize + * @covers ::setDefaultFontSize + * @covers ::getDefaultFontSize */ public function testSetGetDefaultFontSize() { @@ -102,45 +97,42 @@ public function testSetGetDefaultFontSize() } /** - * @covers PHPWord::setDefaultParagraphStyle - * @covers PHPWord::loadTemplate + * @covers ::setDefaultParagraphStyle + * @covers ::loadTemplate */ public function testSetDefaultParagraphStyle() { $object = new PHPWord(); $object->setDefaultParagraphStyle(array()); - $this->assertInstanceOf( - 'PHPWord_Style_Paragraph', - PHPWord_Style::getStyle('Normal') - ); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', Style::getStyle('Normal')); } /** - * @covers PHPWord::addParagraphStyle - * @covers PHPWord::addFontStyle - * @covers PHPWord::addTableStyle - * @covers PHPWord::addLinkStyle + * @covers ::addParagraphStyle + * @covers ::addFontStyle + * @covers ::addTableStyle + * @covers ::addLinkStyle */ public function testAddStyles() { $object = new PHPWord(); - $styles = array('Paragraph' => 'Paragraph', 'Font' => 'Font', - 'Table' => 'TableFull', 'Link' => 'Font'); + $styles = array( + 'Paragraph' => 'Paragraph', + 'Font' => 'Font', + 'Table' => 'TableFull', + 'Link' => 'Font', + ); foreach ($styles as $key => $value) { $method = "add{$key}Style"; $styleId = "{$key} Style"; - $styleType = "PHPWord_Style_{$value}"; $object->$method($styleId, array()); - $this->assertInstanceOf( - $styleType, - PHPWord_Style::getStyle($styleId) - ); + $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$value}", Style::getStyle($styleId)); } } /** - * @covers PHPWord::addTitleStyle + * @covers ::addTitleStyle */ public function testAddTitleStyle() { @@ -148,14 +140,11 @@ public function testAddTitleStyle() $titleLevel = 1; $titleName = "Heading_{$titleLevel}"; $object->addTitleStyle($titleLevel, array()); - $this->assertInstanceOf( - 'PHPWord_Style_Font', - PHPWord_Style::getStyle($titleName) - ); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', Style::getStyle($titleName)); } /** - * @covers PHPWord::loadTemplate + * @covers ::loadTemplate */ public function testLoadTemplate() { @@ -164,15 +153,12 @@ public function testLoadTemplate() array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx') ); $object = new PHPWord(); - $this->assertInstanceOf( - 'PHPWord_Template', - $object->loadTemplate($file) - ); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Template', $object->loadTemplate($file)); } /** - * @covers PHPWord::loadTemplate - * @expectedException PHPWord_Exception + * @covers ::loadTemplate + * @expectedException PhpOffice\PhpWord\Exceptions\Exception */ public function testLoadTemplateException() { @@ -183,4 +169,4 @@ public function testLoadTemplateException() $object = new PHPWord(); $object->loadTemplate($file); } -} +} \ No newline at end of file diff --git a/Tests/_inc/TestHelperDOCX.php b/Tests/_inc/TestHelperDOCX.php index dec1f0776f..086a1227a3 100644 --- a/Tests/_inc/TestHelperDOCX.php +++ b/Tests/_inc/TestHelperDOCX.php @@ -2,6 +2,7 @@ namespace PHPWord\Tests; use PHPWord; +use PhpOffice\PhpWord\IOFactory; class TestHelperDOCX { @@ -19,8 +20,8 @@ public static function getDocument(PHPWord $PHPWord, $writer = 'Word2007') mkdir(sys_get_temp_dir() . '/PHPWord_Unit_Test/'); } - $objWriter = \PHPWord_IOFactory::createWriter($PHPWord, $writer); - $objWriter->save(self::$file); + $xmlWriter = IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save(self::$file); $zip = new \ZipArchive; $res = $zip->open(self::$file); diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index 10f129dbfa..f9e08794f1 100755 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -52,11 +52,11 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->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; +echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL; \ No newline at end of file diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index e9e2d84bcb..6bbbe0bb8a 100755 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -11,19 +11,19 @@ // Ads styles $PHPWord->addParagraphStyle('multipleTab', array( 'tabs' => array( - new PHPWord_Style_Tab('left', 1550), - new PHPWord_Style_Tab('center', 3200), - new PHPWord_Style_Tab('right', 5300) + new PhpOffice\PhpWord\Style\Tab('left', 1550), + new PhpOffice\PhpWord\Style\Tab('center', 3200), + new PhpOffice\PhpWord\Style\Tab('right', 5300) ) )); $PHPWord->addParagraphStyle('rightTab', array( 'tabs' => array( - new PHPWord_Style_Tab('right', 9090) + new PhpOffice\PhpWord\Style\Tab('right', 9090) ) )); $PHPWord->addParagraphStyle('centerTab', array( 'tabs' => array( - new PHPWord_Style_Tab('center', 4680) + new PhpOffice\PhpWord\Style\Tab('center', 4680) ) )); @@ -40,8 +40,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index 1e49629e9c..9c23e9815e 100755 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -33,8 +33,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php index b30db7a56f..64625ac512 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -8,12 +8,11 @@ echo date('H:i:s') , ' Create new PHPWord object' , EOL; $PHPWord = new PHPWord(); - // Ads styles $PHPWord->addParagraphStyle('pStyle', array('spacing'=>100)); $PHPWord->addFontStyle('BoldText', array('bold'=>true)); $PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080')); -$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE)); +$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); // New portrait section $section = $PHPWord->createSection(); @@ -40,8 +39,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php index 3877defeff..1fdae0cfb0 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -43,8 +43,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php index daaa6b4636..a0b3354575 100755 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -15,7 +15,7 @@ $PHPWord->addParagraphStyle('pStyle', array('spacing'=>100)); $PHPWord->addFontStyle('BoldText', array('bold'=>true)); $PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080')); -$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE)); +$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); // Add text elements $textrun = $section->createTextRun('pStyle'); @@ -41,8 +41,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index edd1992c43..c29c18a8e6 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -9,7 +9,7 @@ $PHPWord = new PHPWord(); $PHPWord->setDefaultParagraphStyle(array( 'align' => 'both', - 'spaceAfter' => PHPWord_Shared_Font::pointSizeToTwips(12), + 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12), 'spacing' => 120, )); @@ -53,8 +53,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index 96e411a020..338e1fa4b8 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -32,7 +32,7 @@ $styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80); $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF'); $styleCell = array('valign' => 'center'); -$styleCellBTLR = array('valign' => 'center', 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR); +$styleCellBTLR = array('valign' => 'center', 'textDirection' => PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR); $fontStyle = array('bold' => true, 'align' => 'center'); $PHPWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow); $table = $section->addTable('Fancy Table'); @@ -81,8 +81,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php index 8be721091c..f6227005b5 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -17,8 +17,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php index d96e92644c..e5a542531c 100644 --- a/samples/Sample_11_ReadWord2007.php +++ b/samples/Sample_11_ReadWord2007.php @@ -8,14 +8,14 @@ $name = basename(__FILE__, '.php'); $source = "resources/{$name}.docx"; echo date('H:i:s'), " Reading contents from `{$source}`", EOL; -$PHPWord = PHPWord_IOFactory::load($source); +$PHPWord = PhpOffice\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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index b0d0e13792..7cfbad8e5c 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -64,8 +64,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index 0f64cb7bb8..e5229c9082 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -32,8 +32,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index fa64878407..7624e15030 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -31,7 +31,7 @@ $section->addTextBreak(2); // Add listitem elements -$listStyle = array('listType'=>PHPWord_Style_ListItem::TYPE_NUMBER); +$listStyle = array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER); $section->addListItem('List Item 1', 0, null, $listStyle); $section->addListItem('List Item 2', 0, null, $listStyle); $section->addListItem('List Item 3', 0, null, $listStyle); @@ -40,7 +40,7 @@ // Add listitem elements $PHPWord->addFontStyle('myOwnStyle', array('color'=>'FF0000')); $PHPWord->addParagraphStyle('P-Style', array('spaceAfter'=>95)); -$listStyle = array('listType'=>PHPWord_Style_ListItem::TYPE_NUMBER_NESTED); +$listStyle = array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED); $section->addListItem('List Item 1', 0, 'myOwnStyle', $listStyle, 'P-Style'); $section->addListItem('List Item 2', 0, 'myOwnStyle', $listStyle, 'P-Style'); $section->addListItem('List Item 3', 1, 'myOwnStyle', $listStyle, 'P-Style'); @@ -56,8 +56,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php index ef631906d9..08ef742ac5 100644 --- a/samples/Sample_15_Link.php +++ b/samples/Sample_15_Link.php @@ -16,7 +16,7 @@ $section = $PHPWord->createSection(); // Add hyperlink elements -$section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE)); +$section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); $section->addTextBreak(2); $PHPWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000')); @@ -30,8 +30,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php index e04c49e54d..d1d18fb660 100644 --- a/samples/Sample_16_Object.php +++ b/samples/Sample_16_Object.php @@ -25,8 +25,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php index efa756e4df..0189bfce71 100644 --- a/samples/Sample_17_TitleTOC.php +++ b/samples/Sample_17_TitleTOC.php @@ -57,8 +57,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php index 8332bd0330..0619556775 100644 --- a/samples/Sample_18_Watermark.php +++ b/samples/Sample_18_Watermark.php @@ -26,8 +26,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php index 17299601c6..3863dfb94c 100644 --- a/samples/Sample_19_TextBreak.php +++ b/samples/Sample_19_TextBreak.php @@ -39,8 +39,8 @@ $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}"); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } From 32ed6a3b19d0b6b94fc8f5e12585aa6557dd166a Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 19 Mar 2014 18:00:19 +0400 Subject: [PATCH 05/15] https://github.com/PHPOffice/PHPWord/issues/58 - Part V (IOFactory). --- Classes/PHPWord/IOFactory.php | 137 +++++++------------------------- Tests/PHPWord/IOFactoryTest.php | 62 +++++++-------- Tests/_inc/TestHelperDOCX.php | 4 +- 3 files changed, 60 insertions(+), 143 deletions(-) diff --git a/Classes/PHPWord/IOFactory.php b/Classes/PHPWord/IOFactory.php index 9ffda349e4..aac25e280f 100755 --- a/Classes/PHPWord/IOFactory.php +++ b/Classes/PHPWord/IOFactory.php @@ -25,134 +25,55 @@ * @version 0.8.0 */ +namespace PhpOffice\PhpWord; + use PhpOffice\PhpWord\Exceptions\Exception; -/** - * Class PHPWord_IOFactory - */ -class PHPWord_IOFactory +abstract class IOFactory { /** - * Search locations - * - * @var array - */ - private static $_searchLocations = array( - array('type' => 'IWriter', 'path' => 'PHPWord/Writer/{0}.php', 'class' => 'PHPWord_Writer_{0}'), - array('type' => 'IReader', 'path' => 'PHPWord/Reader/{0}.php', 'class' => 'PHPWord_Reader_{0}' ), - ); - - /** - * Autoresolve classes - * - * @var array - */ - private static $_autoResolveClasses = array( - 'Serialized' - ); - - /** - * Private constructor for PHPWord_IOFactory - */ - private function __construct() - { - } - - /** - * Get search locations - * - * @return array - */ - public static function getSearchLocations() - { - return self::$_searchLocations; - } - - /** - * Set search locations - * - * @param array $value - * @throws Exception - */ - public static function setSearchLocations(array $value) - { - self::$_searchLocations = $value; - } - - /** - * Add search location - * - * @param string $type Example: IWriter - * @param string $location Example: PHPWord/Writer/{0}.php - * @param string $classname Example: PHPWord_Writer_{0} - */ - public static function addSearchLocation($type = '', $location = '', $classname = '') - { - self::$_searchLocations[] = array('type' => $type, 'path' => $location, 'class' => $classname); - } - - /** - * Create PHPWord_Writer_IWriter - * - * @param PHPWord $PHPWord - * @param string $writerType Example: Word2007 - * @return PHPWord_Writer_IWriter - * @throws Exception + * @param PHPWord $phpWord + * @param string $name + * @return PhpOffice\PhpWord\Writer\IWriter + * @throws PhpOffice\PhpWord\Exceptions\Exception */ - public static function createWriter(PHPWord $PHPWord, $writerType = '') + public static function createWriter(PHPWord $phpWord, $name) { - $searchType = 'IWriter'; + try { + $fqName = "PhpOffice\\PhpWord\\Writer\\{$name}"; - foreach (self::$_searchLocations as $searchLocation) { - if ($searchLocation['type'] == $searchType) { - $className = str_replace('{0}', $writerType, $searchLocation['class']); - $classFile = str_replace('{0}', $writerType, $searchLocation['path']); - - $instance = new $className($PHPWord); - if (!is_null($instance)) { - return $instance; - } - } + return new $fqName($phpWord); + } catch (\Exception $ex) { + throw new Exception("Could not instantiate \"{$name}\" class."); } - - throw new Exception("No $searchType found for type $writerType"); } /** - * Create PHPWord_Reader_IReader - * - * @param string $readerType Example: Word2007 - * @return PHPWord_Reader_IReader - * @throws Exception + * @param string $name + * @return PhpOffice\PhpWord\Reader\IReader + * @throws PhpOffice\PhpWord\Exceptions\Exception */ - public static function createReader($readerType = '') + public static function createReader($name) { - $searchType = 'IReader'; + try { + $fqName = "PhpOffice\\PhpWord\\Reader\\{$name}"; - foreach (self::$_searchLocations as $searchLocation) { - if ($searchLocation['type'] == $searchType) { - $className = str_replace('{0}', $readerType, $searchLocation['class']); - - $instance = new $className(); - if ($instance !== null) { - return $instance; - } - } + return new $fqName(); + } catch (\Exception $ex) { + throw new Exception("Could not instantiate \"{$name}\" class."); } - - throw new Exception("No $searchType found for type $readerType"); } /** - * Loads PHPWord from file + * Loads PhpWord from file * - * @param string $pFilename The name of the file - * @param string $readerType - * @return PHPWord + * @param string $filename The name of the file + * @param string $readerName + * @return PhpOffice\PHPWord */ - public static function load($pFilename, $readerType = 'Word2007') + public static function load($filename, $readerName = 'Word2007') { - $reader = self::createReader($readerType); - return $reader->load($pFilename); + $reader = self::createReader($readerName); + return $reader->load($filename); } } \ No newline at end of file diff --git a/Tests/PHPWord/IOFactoryTest.php b/Tests/PHPWord/IOFactoryTest.php index 951497c6f5..d4338fbaf9 100644 --- a/Tests/PHPWord/IOFactoryTest.php +++ b/Tests/PHPWord/IOFactoryTest.php @@ -1,59 +1,55 @@ assertAttributeEquals( - IOFactory::getSearchLocations(), - '_searchLocations', - 'PhpOffice\\PhpWord\\IOFactory' + $this->assertInstanceOf( + 'PhpOffice\\PhpWord\\Writer\\Word2007', + IOFactory::createWriter(new PHPWord(), 'Word2007') ); } - public function testSetSearchLocationsWithArray() + /** + * @covers ::createWriter + * @expectedException PhpOffice\PhpWord\Exceptions\Exception + * @expectedExceptionMessage Could not instantiate "Word2006" class. + */ + final public function testNonexistentWriterCanNotBeCreated() { - IOFactory::setSearchLocations(array()); - $this->assertAttributeEquals(array(), '_searchLocations', 'PhpOffice\\PhpWord\\IOFactory'); + IOFactory::createWriter(new PHPWord(), 'Word2006'); } - public function testAddSearchLocation() + /** + * @covers ::createReader + */ + final public function testExistingReaderCanBeCreated() { - IOFactory::setSearchLocations(array()); - IOFactory::addSearchLocation('interface', 'classname'); - $this->assertAttributeEquals( - array(array('interface' => 'interface', 'class' => 'classname')), - '_searchLocations', - 'PhpOffice\\PhpWord\\IOFactory' + $this->assertInstanceOf( + 'PhpOffice\\PhpWord\\Reader\\Word2007', + IOFactory::createReader('Word2007') ); } /** - * @expectedException Exception - * @expectedExceptionMessage No IWriter found for type + * @covers ::createReader + * @expectedException PhpOffice\PhpWord\Exceptions\Exception + * @expectedExceptionMessage Could not instantiate "Word2006" class. */ - public function testCreateWriterException() + final public function testNonexistentReaderCanNotBeCreated() { - $oPHPWord = new PHPWord(); - - IOFactory::setSearchLocations(array()); - IOFactory::createWriter($oPHPWord); - } - - public function testCreateWriter() - { - $oPHPWord = new PHPWord(); - - $this->assertEquals(IOFactory::createWriter($oPHPWord, 'Word2007'), new Word2007($oPHPWord)); + IOFactory::createReader('Word2006'); } } \ No newline at end of file diff --git a/Tests/_inc/TestHelperDOCX.php b/Tests/_inc/TestHelperDOCX.php index 086a1227a3..2897505086 100644 --- a/Tests/_inc/TestHelperDOCX.php +++ b/Tests/_inc/TestHelperDOCX.php @@ -13,14 +13,14 @@ class TestHelperDOCX * @param \PHPWord $PHPWord * @return \PHPWord\Tests\XmlDocument */ - public static function getDocument(PHPWord $PHPWord, $writer = 'Word2007') + public static function getDocument(PHPWord $PHPWord, $writerName = 'Word2007') { self::$file = tempnam(sys_get_temp_dir(), 'PHPWord'); if (!is_dir(sys_get_temp_dir() . '/PHPWord_Unit_Test/')) { mkdir(sys_get_temp_dir() . '/PHPWord_Unit_Test/'); } - $xmlWriter = IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = IOFactory::createWriter($PHPWord, $writerName); $xmlWriter->save(self::$file); $zip = new \ZipArchive; From 8267a9e12fbdc8d52c129feccb91c8fe25fcf1a8 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 20 Mar 2014 16:54:12 +0400 Subject: [PATCH 06/15] https://github.com/PHPOffice/PHPWord/issues/58 - Part VI (PhpWord). --- Classes/PHPWord.php | 132 ++++++------------ Classes/PHPWord/Autoloader.php | 10 +- Classes/PHPWord/DocumentProperties.php | 10 +- .../Exceptions/InvalidImageException.php | 2 +- .../Exceptions/InvalidStyleException.php | 2 +- .../UnsupportedImageTypeException.php | 2 +- Classes/PHPWord/Footnote.php | 10 +- Classes/PHPWord/HashTable.php | 10 +- Classes/PHPWord/IOFactory.php | 17 +-- Classes/PHPWord/Media.php | 10 +- Classes/PHPWord/Reader/AbstractReader.php | 10 +- Classes/PHPWord/Reader/IReader.php | 14 +- Classes/PHPWord/Reader/Word2007.php | 39 +++--- Classes/PHPWord/Section.php | 12 +- Classes/PHPWord/Section/Footer.php | 10 +- .../PHPWord/Section/Footer/PreserveText.php | 10 +- Classes/PHPWord/Section/Footnote.php | 10 +- Classes/PHPWord/Section/Header.php | 10 +- Classes/PHPWord/Section/Image.php | 10 +- Classes/PHPWord/Section/Link.php | 10 +- Classes/PHPWord/Section/ListItem.php | 10 +- Classes/PHPWord/Section/MemoryImage.php | 10 +- Classes/PHPWord/Section/Object.php | 10 +- Classes/PHPWord/Section/PageBreak.php | 10 +- Classes/PHPWord/Section/Settings.php | 10 +- Classes/PHPWord/Section/Table.php | 10 +- Classes/PHPWord/Section/Table/Cell.php | 12 +- Classes/PHPWord/Section/Table/Row.php | 10 +- Classes/PHPWord/Section/Text.php | 10 +- Classes/PHPWord/Section/TextBreak.php | 10 +- Classes/PHPWord/Section/TextRun.php | 10 +- Classes/PHPWord/Section/Title.php | 10 +- Classes/PHPWord/Settings.php | 10 +- Classes/PHPWord/Shared/Drawing.php | 10 +- Classes/PHPWord/Shared/File.php | 10 +- Classes/PHPWord/Shared/Font.php | 10 +- Classes/PHPWord/Shared/String.php | 10 +- Classes/PHPWord/Shared/XMLWriter.php | 10 +- Classes/PHPWord/Shared/ZipStreamWrapper.php | 10 +- Classes/PHPWord/Style.php | 10 +- Classes/PHPWord/Style/Cell.php | 10 +- Classes/PHPWord/Style/Font.php | 35 ++--- Classes/PHPWord/Style/Image.php | 10 +- Classes/PHPWord/Style/ListItem.php | 10 +- Classes/PHPWord/Style/Paragraph.php | 10 +- Classes/PHPWord/Style/Row.php | 10 +- Classes/PHPWord/Style/TOC.php | 10 +- Classes/PHPWord/Style/Tab.php | 10 +- Classes/PHPWord/Style/Table.php | 10 +- Classes/PHPWord/Style/TableFull.php | 10 +- Classes/PHPWord/Style/Tabs.php | 10 +- Classes/PHPWord/TOC.php | 10 +- Classes/PHPWord/Template.php | 10 +- Classes/PHPWord/Writer/IWriter.php | 16 +-- Classes/PHPWord/Writer/ODText.php | 68 ++++----- Classes/PHPWord/Writer/ODText/Content.php | 23 +-- Classes/PHPWord/Writer/ODText/Manifest.php | 15 +- Classes/PHPWord/Writer/ODText/Meta.php | 35 ++--- Classes/PHPWord/Writer/ODText/Mimetype.php | 16 ++- Classes/PHPWord/Writer/ODText/Styles.php | 33 ++--- Classes/PHPWord/Writer/ODText/WriterPart.php | 10 +- Classes/PHPWord/Writer/RTF.php | 77 +++++----- Classes/PHPWord/Writer/Word2007.php | 27 ++-- Classes/PHPWord/Writer/Word2007/Base.php | 19 +-- .../PHPWord/Writer/Word2007/ContentTypes.php | 10 +- Classes/PHPWord/Writer/Word2007/DocProps.php | 35 ++--- Classes/PHPWord/Writer/Word2007/Document.php | 13 +- .../PHPWord/Writer/Word2007/DocumentRels.php | 10 +- Classes/PHPWord/Writer/Word2007/Footer.php | 10 +- Classes/PHPWord/Writer/Word2007/Footnotes.php | 10 +- .../PHPWord/Writer/Word2007/FootnotesRels.php | 10 +- Classes/PHPWord/Writer/Word2007/Header.php | 10 +- Classes/PHPWord/Writer/Word2007/Rels.php | 13 +- Classes/PHPWord/Writer/Word2007/Styles.php | 13 +- .../PHPWord/Writer/Word2007/WriterPart.php | 10 +- README.md | 34 ++--- Tests/PHPWord/AutoloaderTest.php | 10 +- Tests/PHPWord/DocumentPropertiesTest.php | 4 +- Tests/PHPWord/Exceptions/ExceptionTest.php | 2 +- .../Exceptions/InvalidImageExceptionTest.php | 2 +- .../Exceptions/InvalidStyleExceptionTest.php | 2 +- .../UnsupportedImageTypeExceptionTest.php | 2 +- Tests/PHPWord/IOFactoryTest.php | 10 +- Tests/PHPWord/MediaTest.php | 2 +- Tests/PHPWord/Reader/Word2007Test.php | 6 +- .../Section/Footer/PreserveTextTest.php | 2 +- Tests/PHPWord/Section/FooterTest.php | 2 +- Tests/PHPWord/Section/FootnoteTest.php | 2 +- Tests/PHPWord/Section/HeaderTest.php | 2 +- Tests/PHPWord/Section/ImageTest.php | 2 +- Tests/PHPWord/Section/LinkTest.php | 2 +- Tests/PHPWord/Section/ListItemTest.php | 2 +- Tests/PHPWord/Section/MemoryImageTest.php | 2 +- Tests/PHPWord/Section/ObjectTest.php | 2 +- Tests/PHPWord/Section/PageBreakTest.php | 2 +- Tests/PHPWord/Section/SettingsTest.php | 2 +- Tests/PHPWord/Section/Table/CellTest.php | 2 +- Tests/PHPWord/Section/Table/RowTest.php | 2 +- Tests/PHPWord/Section/TableTest.php | 2 +- Tests/PHPWord/Section/TextBreakTest.php | 4 +- Tests/PHPWord/Section/TextRunTest.php | 2 +- Tests/PHPWord/Section/TextTest.php | 2 +- Tests/PHPWord/Section/TitleTest.php | 2 +- Tests/PHPWord/SectionTest.php | 6 +- Tests/PHPWord/SettingsTest.php | 4 +- Tests/PHPWord/Shared/DrawingTest.php | 4 +- Tests/PHPWord/Shared/FileTest.php | 4 +- Tests/PHPWord/Shared/FontTest.php | 8 +- Tests/PHPWord/Shared/StringTest.php | 4 +- Tests/PHPWord/Style/CellTest.php | 4 +- Tests/PHPWord/Style/FontTest.php | 22 +-- Tests/PHPWord/Style/ImageTest.php | 4 +- Tests/PHPWord/Style/ListItemTest.php | 4 +- Tests/PHPWord/Style/ParagraphTest.php | 16 +-- Tests/PHPWord/Style/RowTest.php | 4 +- Tests/PHPWord/Style/TOCTest.php | 4 +- Tests/PHPWord/Style/TableFullTest.php | 4 +- Tests/PHPWord/Style/TableTest.php | 4 +- Tests/PHPWord/Style/TabsTest.php | 14 +- Tests/PHPWord/StyleTest.php | 4 +- Tests/PHPWord/TOCTest.php | 4 +- Tests/PHPWord/TemplateTest.php | 8 +- Tests/PHPWord/Writer/ODText/ContentTest.php | 22 +-- Tests/PHPWord/Writer/ODTextTest.php | 24 ++-- Tests/PHPWord/Writer/RTFTest.php | 22 +-- Tests/PHPWord/Writer/Word2007/BaseTest.php | 100 ++++++------- .../PHPWord/Writer/Word2007/DocumentTest.php | 26 ++-- .../PHPWord/Writer/Word2007/FootnotesTest.php | 14 +- Tests/PHPWord/Writer/Word2007/StylesTest.php | 24 ++-- Tests/PHPWord/Writer/Word2007Test.php | 14 +- Tests/PHPWordTest.php | 114 +++++++-------- Tests/_inc/TestHelperDOCX.php | 26 ++-- Tests/_inc/XmlDocument.php | 2 +- Tests/bootstrap.php | 2 +- changelog.txt | 6 +- composer.json | 12 +- docs/Makefile | 8 +- docs/conf.py | 24 ++-- docs/index.rst | 4 +- docs/intro.rst | 6 +- docs/setup.rst | 2 +- phpunit.xml.dist | 4 +- samples/Sample_01_SimpleText.php | 18 +-- samples/Sample_02_TabStops.php | 16 +-- samples/Sample_03_Sections.php | 16 +-- samples/Sample_04_Textrun.php | 18 +-- samples/Sample_05_Multicolumn.php | 18 +-- samples/Sample_06_Footnote.php | 18 +-- samples/Sample_07_TemplateCloneRow.php | 8 +- samples/Sample_08_ParagraphPagination.php | 12 +- samples/Sample_09_Tables.php | 14 +- samples/Sample_10_EastAsianFontStyle.php | 10 +- samples/Sample_11_ReadWord2007.php | 6 +- samples/Sample_12_HeaderFooter.php | 14 +- samples/Sample_13_Images.php | 10 +- samples/Sample_14_ListItem.php | 14 +- samples/Sample_15_Link.php | 12 +- samples/Sample_16_Object.php | 10 +- samples/Sample_17_TitleTOC.php | 16 +-- samples/Sample_18_Watermark.php | 12 +- samples/Sample_19_TextBreak.php | 16 +-- 161 files changed, 1034 insertions(+), 1098 deletions(-) diff --git a/Classes/PHPWord.php b/Classes/PHPWord.php index edc4e93a55..c2986a70d4 100755 --- a/Classes/PHPWord.php +++ b/Classes/PHPWord.php @@ -1,8 +1,8 @@ _properties = new DocumentProperties(); - $this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME; - $this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE; + $this->_documentProperties = new DocumentProperties(); + $this->_defaultFontName = self::DEFAULT_FONT_NAME; + $this->_defaultFontSize = self::DEFAULT_FONT_SIZE; } /** - * Get properties * @return PhpOffice\PhpWord\DocumentProperties */ - public function getProperties() + public function getDocumentProperties() { - return $this->_properties; + return $this->_documentProperties; } /** - * Set properties - * - * @param PhpOffice\PhpWord\DocumentProperties $value - * @return PhpOffice\PHPWord + * @param PhpOffice\PhpWord\DocumentProperties $documentProperties + * @return PhpOffice\PhpWord */ - public function setProperties(DocumentProperties $value) + public function setDocumentProperties(DocumentProperties $documentProperties) { - $this->_properties = $value; + $this->_documentProperties = $documentProperties; + return $this; } /** - * Create a new Section - * - * @param PhpOffice\PhpWord\Section\Settings $settings + * @param PhpOffice\PhpWord\Section\Settings $settings * @return PhpOffice\PhpWord\Section */ public function createSection($settings = null) { - $sectionCount = $this->_countSections() + 1; + $section = new Section(\count($this->_sections) + 1, $settings); + $this->_sections[] = $section; - $section = new Section($sectionCount, $settings); - $this->_sectionCollection[] = $section; return $section; } /** - * Get default Font name * @return string */ public function getDefaultFontName() @@ -152,16 +122,14 @@ public function getDefaultFontName() } /** - * Set default Font name - * @param string $pValue + * @param string $fontName */ - public function setDefaultFontName($pValue) + public function setDefaultFontName($fontName) { - $this->_defaultFontName = $pValue; + $this->_defaultFontName = $fontName; } /** - * Get default Font size (in points) * @return string */ public function getDefaultFontSize() @@ -170,18 +138,17 @@ public function getDefaultFontSize() } /** - * Set default Font size (in points) - * @param int $pValue + * @param int $fontSize */ - public function setDefaultFontSize($pValue) + public function setDefaultFontSize($fontSize) { - $this->_defaultFontSize = $pValue; + $this->_defaultFontSize = $fontSize; } /** * Set default paragraph style definition to styles.xml * - * @param array $styles Paragraph style definition + * @param array $styles Paragraph style definition */ public function setDefaultParagraphStyle($styles) { @@ -244,35 +211,24 @@ public function addLinkStyle($styleName, $styles) } /** - * Get sections * @return PhpOffice\PhpWord\Section[] */ public function getSections() { - return $this->_sectionCollection; + return $this->_sections; } /** - * Load a Template File - * - * @param string $strFilename + * @param string $filename Fully qualified filename. * @return PhpOffice\PhpWord\Template - * @throws Exception + * @throws PhpOffice\PhpWord\Exceptions\Exception */ - public function loadTemplate($strFilename) + public function loadTemplate($filename) { - if (file_exists($strFilename)) { - return new Template($strFilename); + if (\file_exists($filename)) { + return new Template($filename); + } else { + throw new Exception("Template file {$filename} not found."); } - throw new Exception("Template file {$strFilename} not found."); } - - /** - * Get section count - * @return int - */ - private function _countSections() - { - return count($this->_sectionCollection); - } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Autoloader.php b/Classes/PHPWord/Autoloader.php index aa36efc88b..1a4aa3b3dc 100755 --- a/Classes/PHPWord/Autoloader.php +++ b/Classes/PHPWord/Autoloader.php @@ -1,8 +1,8 @@ open($pFilename) === true) { // check if it is an OOXML archive $rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels")); @@ -78,8 +79,6 @@ public function canRead($pFilename) } /** - * Get from zip archive - * * @param ZipArchive $archive * @param string $fileName * @param bool $removeNamespace @@ -108,10 +107,10 @@ public function getFromZipArchive($archive, $fileName = '', $removeNamespace = f } /** - * Loads PHPWord from file + * Loads PhpWord from file * * @param string $pFilename - * @return PHPWord|null + * @return PhpOffice\PhpWord|null */ public function load($pFilename) { @@ -121,8 +120,8 @@ public function load($pFilename) } // Initialisations - $word = new PHPWord; - $zip = new ZipArchive; + $word = new PhpWord(); + $zip = new ZipArchive(); $zip->open($pFilename); // Read properties and documents @@ -136,7 +135,7 @@ public function load($pFilename) $xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/"); $xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/"); $xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"); - $docProps = $word->getProperties(); + $docProps = $word->getDocumentProperties(); $docProps->setCreator((string)self::arrayItem($xmlCore->xpath("dc:creator"))); $docProps->setLastModifiedBy((string)self::arrayItem($xmlCore->xpath("cp:lastModifiedBy"))); $docProps->setCreated(strtotime(self::arrayItem($xmlCore->xpath("dcterms:created")))); @@ -152,7 +151,7 @@ public function load($pFilename) case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties": $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); if (is_object($xmlCore)) { - $docProps = $word->getProperties(); + $docProps = $word->getDocumentProperties(); if (isset($xmlCore->Company)) { $docProps->setCompany((string)$xmlCore->Company); } @@ -165,7 +164,7 @@ public function load($pFilename) case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); if (is_object($xmlCore)) { - $docProps = $word->getProperties(); + $docProps = $word->getDocumentProperties(); foreach ($xmlCore as $xmlProperty) { $cellDataOfficeAttributes = $xmlProperty->attributes(); if (isset($cellDataOfficeAttributes['name'])) { @@ -276,7 +275,7 @@ public function load($pFilename) * @param SimpleXMLElement $elm * @return array|string|null * - * @todo Implement gutter + * @todo Implement gutter */ private function loadSectionSettings($elm) { @@ -443,8 +442,6 @@ private function loadFontStyle($elm) } /** - * Get array item - * * @param array $array * @param mixed $key * @return mixed|null diff --git a/Classes/PHPWord/Section.php b/Classes/PHPWord/Section.php index 17887d6b04..0b12f9ef0f 100755 --- a/Classes/PHPWord/Section.php +++ b/Classes/PHPWord/Section.php @@ -1,8 +1,8 @@ _name = $pValue; return $this; @@ -258,10 +259,10 @@ public function getSize() * @param int|float $pValue * @return PhpOffice\PhpWord\Style\Font */ - public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE) + public function setSize($pValue = PhpWord::DEFAULT_FONT_SIZE) { if (!is_numeric($pValue)) { - $pValue = PHPWord::DEFAULT_FONT_SIZE; + $pValue = PhpWord::DEFAULT_FONT_SIZE; } $this->_size = $pValue; return $this; @@ -435,10 +436,10 @@ public function getColor() * @param string $pValue * @return PhpOffice\PhpWord\Style\Font */ - public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR) + public function setColor($pValue = PhpWord::DEFAULT_FONT_COLOR) { if (is_null($pValue) || $pValue == '') { - $pValue = PHPWord::DEFAULT_FONT_COLOR; + $pValue = PhpWord::DEFAULT_FONT_COLOR; } $this->_color = $pValue; return $this; @@ -532,10 +533,10 @@ public function getHint() * @param string $pValue * @return PhpOffice\PhpWord\Style\Font */ - public function setHint($pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE) + public function setHint($pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE) { if (is_null($pValue) || $pValue == '') { - $pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE; + $pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE; } $this->_hint = $pValue; return $this; diff --git a/Classes/PHPWord/Style/Image.php b/Classes/PHPWord/Style/Image.php index c78c6087b2..fbc074bea7 100755 --- a/Classes/PHPWord/Style/Image.php +++ b/Classes/PHPWord/Style/Image.php @@ -1,8 +1,8 @@ setPHPWord($phpWord); + // Assign PhpWord + $this->setPhpWord($phpWord); // Set up disk caching location $this->_diskCachingDirectory = './'; @@ -100,10 +95,10 @@ public function __construct(PHPWord $phpWord = null) } /** - * Save PHPWord to file + * Save PhpWord to file * - * @param string $pFileName - * @throws Exception + * @param string $pFileName + * @throws \Exception */ public function save($pFilename = null) { @@ -125,7 +120,7 @@ public function save($pFilename = null) // Try opening the ZIP file if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { - throw new Exception("Could not open " . $pFilename . " for writing."); + throw new \Exception("Could not open " . $pFilename . " for writing."); } } @@ -182,45 +177,40 @@ public function save($pFilename = null) // Close file if ($objZip->close() === false) { - throw new Exception("Could not close zip file $pFilename."); + throw new \Exception("Could not close zip file $pFilename."); } // If a temporary file was used, copy it to the correct file stream if ($originalFilename != $pFilename) { if (copy($pFilename, $originalFilename) === false) { - throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename."); } @unlink($pFilename); } } else { - throw new Exception("PHPWord object unassigned."); + throw new \Exception("PhpWord object unassigned."); } } /** - * Get PHPWord object - * - * @return PHPWord - * @throws Exception + * @return PhpOffice\PhpWord + * @throws \Exception */ - public function getPHPWord() + public function getPhpWord() { if (!is_null($this->_document)) { return $this->_document; } else { - throw new Exception("No PHPWord assigned."); + throw new \Exception("No PhpWord assigned."); } } /** - * Get PHPWord object - * - * @param PHPWord $phpWord PHPWord object - * @throws Exception + * @param PhpOffice\PhpWord $phpWord * @return PhpOffice\PhpWord\Writer\ODText */ - public function setPHPWord(PHPWord $phpWord = null) + public function setPhpWord(PhpWord $phpWord = null) { $this->_document = $phpWord; return $this; @@ -237,8 +227,6 @@ public function getDrawingHashTable() } /** - * Get writer part - * * @param string $pPartName Writer part name * @return PhpOffice\PhpWord\Writer\ODText\WriterPart */ @@ -266,7 +254,7 @@ public function getUseDiskCaching() * * @param boolean $pValue * @param string $pDirectory Disk caching directory - * @throws Exception Exception when directory does not exist + * @throws \Exception Exception when directory does not exist * @return PhpOffice\PhpWord\Writer\ODText */ public function setUseDiskCaching($pValue = false, $pDirectory = null) @@ -277,7 +265,7 @@ public function setUseDiskCaching($pValue = false, $pDirectory = null) if (is_dir($pDirectory)) { $this->_diskCachingDirectory = $pDirectory; } else { - throw new Exception("Directory does not exist: $pDirectory"); + throw new \Exception("Directory does not exist: $pDirectory"); } } @@ -285,12 +273,10 @@ public function setUseDiskCaching($pValue = false, $pDirectory = null) } /** - * Get disk caching directory - * * @return string */ public function getDiskCachingDirectory() { return $this->_diskCachingDirectory; } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PHPWord/Writer/ODText/Content.php index 5526d06c7f..d4f4d2ebf8 100755 --- a/Classes/PHPWord/Writer/ODText/Content.php +++ b/Classes/PHPWord/Writer/ODText/Content.php @@ -1,8 +1,8 @@ startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); - $xmlWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME); $xmlWriter->endElement(); } } @@ -325,7 +326,7 @@ protected function _writeText(XMLWriter $xmlWriter = null, Text $text, $withoutP if ($SfIsObject) { // Don't never be the case, because I browse all sections for cleaning all styles not declared - die('PHPWord : $SfIsObject wouldn\'t be an object'); + die('PhpWord : $SfIsObject wouldn\'t be an object'); } else { if (!$withoutP) { $xmlWriter->startElement('text:p'); // text:p diff --git a/Classes/PHPWord/Writer/ODText/Manifest.php b/Classes/PHPWord/Writer/ODText/Manifest.php index b39662f0f8..1169249d8e 100755 --- a/Classes/PHPWord/Writer/ODText/Manifest.php +++ b/Classes/PHPWord/Writer/ODText/Manifest.php @@ -1,8 +1,8 @@ startElement('office:meta'); // dc:creator - $xmlWriter->writeElement('dc:creator', $phpWord->getProperties()->getLastModifiedBy()); + $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getLastModifiedBy()); // dc:date - $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getProperties()->getModified())); + $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getModified())); // dc:description - $xmlWriter->writeElement('dc:description', $phpWord->getProperties()->getDescription()); + $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); // dc:subject - $xmlWriter->writeElement('dc:subject', $phpWord->getProperties()->getSubject()); + $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); // dc:title - $xmlWriter->writeElement('dc:title', $phpWord->getProperties()->getTitle()); + $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); // meta:creation-date - $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getProperties()->getCreated())); + $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getCreated())); // meta:initial-creator - $xmlWriter->writeElement('meta:initial-creator', $phpWord->getProperties()->getCreator()); + $xmlWriter->writeElement('meta:initial-creator', $phpWord->getDocumentProperties()->getCreator()); // meta:keyword - $xmlWriter->writeElement('meta:keyword', $phpWord->getProperties()->getKeywords()); + $xmlWriter->writeElement('meta:keyword', $phpWord->getDocumentProperties()->getKeywords()); // @todo : Where these properties are written ? - // $phpWord->getProperties()->getCategory() - // $phpWord->getProperties()->getCompany() + // $phpWord->getDocumentProperties()->getCategory() + // $phpWord->getDocumentProperties()->getCompany() $xmlWriter->endElement(); diff --git a/Classes/PHPWord/Writer/ODText/Mimetype.php b/Classes/PHPWord/Writer/ODText/Mimetype.php index 7f3d0e7755..570f1855d4 100755 --- a/Classes/PHPWord/Writer/ODText/Mimetype.php +++ b/Classes/PHPWord/Writer/ODText/Mimetype.php @@ -1,8 +1,8 @@ startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); - $xmlWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME); $xmlWriter->endElement(); } $xmlWriter->endElement(); @@ -137,17 +138,17 @@ public function writeStyles(PHPWord $phpWord = null) // style:text-properties $xmlWriter->startElement('style:text-properties'); $xmlWriter->writeAttribute('style:use-window-font-color', 'true'); - $xmlWriter->writeAttribute('style:font-name', PHPWord::DEFAULT_FONT_NAME); - $xmlWriter->writeAttribute('fo:font-size', PHPWord::DEFAULT_FONT_SIZE . 'pt'); + $xmlWriter->writeAttribute('style:font-name', PhpWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('fo:font-size', PhpWord::DEFAULT_FONT_SIZE . 'pt'); $xmlWriter->writeAttribute('fo:language', 'fr'); $xmlWriter->writeAttribute('fo:country', 'FR'); $xmlWriter->writeAttribute('style:letter-kerning', 'true'); - $xmlWriter->writeAttribute('style:font-name-asian', PHPWord::DEFAULT_FONT_NAME . '2'); - $xmlWriter->writeAttribute('style:font-size-asian', PHPWord::DEFAULT_FONT_SIZE . 'pt'); + $xmlWriter->writeAttribute('style:font-name-asian', PhpWord::DEFAULT_FONT_NAME . '2'); + $xmlWriter->writeAttribute('style:font-size-asian', PhpWord::DEFAULT_FONT_SIZE . 'pt'); $xmlWriter->writeAttribute('style:language-asian', 'zh'); $xmlWriter->writeAttribute('style:country-asian', 'CN'); - $xmlWriter->writeAttribute('style:font-name-complex', PHPWord::DEFAULT_FONT_NAME . '2'); - $xmlWriter->writeAttribute('style:font-size-complex', PHPWord::DEFAULT_FONT_SIZE . 'pt'); + $xmlWriter->writeAttribute('style:font-name-complex', PhpWord::DEFAULT_FONT_NAME . '2'); + $xmlWriter->writeAttribute('style:font-size-complex', PhpWord::DEFAULT_FONT_SIZE . 'pt'); $xmlWriter->writeAttribute('style:language-complex', 'hi'); $xmlWriter->writeAttribute('style:country-complex', 'IN'); $xmlWriter->writeAttribute('fo:hyphenate', 'false'); diff --git a/Classes/PHPWord/Writer/ODText/WriterPart.php b/Classes/PHPWord/Writer/ODText/WriterPart.php index ccaecfa397..06e4a404cc 100755 --- a/Classes/PHPWord/Writer/ODText/WriterPart.php +++ b/Classes/PHPWord/Writer/ODText/WriterPart.php @@ -1,8 +1,8 @@ setPHPWord($phpWord); + // Assign PhpWord + $this->setPhpWord($phpWord); // Set HashTable variables $this->_drawingHashTable = new HashTable(); } /** - * Save PHPWord to file + * Save PhpWord to file * - * @param string $pFileName - * @throws Exception + * @param string $pFileName + * @throws \Exception */ public function save($pFilename = null) { @@ -102,37 +103,35 @@ public function save($pFilename = null) // If a temporary file was used, copy it to the correct file stream if ($originalFilename != $pFilename) { if (copy($pFilename, $originalFilename) === false) { - throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename."); } @unlink($pFilename); } } else { - throw new Exception("PHPWord object unassigned."); + throw new \Exception("PhpWord object unassigned."); } } /** - * Get PHPWord object - * - * @return PHPWord - * @throws Exception + * @return PhpOffice\PhpWord + * @throws \Exception */ - public function getPHPWord() + public function getPhpWord() { if (!is_null($this->_document)) { return $this->_document; } else { - throw new Exception("No PHPWord assigned."); + throw new \Exception("No PhpWord assigned."); } } /** - * @param PHPWord $phpWord PHPWord object - * @throws Exception + * @param PhpOffice\PhpWord $phpWord + * @throws \Exception * @return PhpOffice\PhpWord\Writer\RTF */ - public function setPHPWord(PHPWord $phpWord = null) + public function setPhpWord(PhpWord $phpWord = null) { $this->_document = $phpWord; return $this; @@ -150,7 +149,7 @@ public function getDrawingHashTable() private function getData() { - // PHPWord object : $this->_document + // PhpWord object : $this->_document $this->_fontTable = $this->getDataFont(); $this->_colorTable = $this->getDataColor(); @@ -176,7 +175,7 @@ private function getData() } $sRTFContent .= ';}' . PHP_EOL; // Set the generator - $sRTFContent .= '{\*\generator PHPWord;}' . PHP_EOL; + $sRTFContent .= '{\*\generator PhpWord;}' . PHP_EOL; // Set the view mode of the document $sRTFContent .= '\viewkind4'; // Set the numberof bytes that follows a unicode character @@ -190,7 +189,7 @@ private function getData() // Point size (in half-points) above which to kern character pairs $sRTFContent .= '\kerning1'; // Set the font size in half-points - $sRTFContent .= '\fs' . (PHPWord::DEFAULT_FONT_SIZE * 2); + $sRTFContent .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); $sRTFContent .= PHP_EOL; // Body $sRTFContent .= $this->getDataContent(); @@ -206,9 +205,9 @@ private function getDataFont() $phpWord = $this->_document; $arrFonts = array(); - // Default font : PHPWord::DEFAULT_FONT_NAME - $arrFonts[] = PHPWord::DEFAULT_FONT_NAME; - // PHPWord object : $this->_document + // Default font : PhpWord::DEFAULT_FONT_NAME + $arrFonts[] = PhpWord::DEFAULT_FONT_NAME; + // PhpWord object : $this->_document // Browse styles $styles = Style::getStyles(); @@ -256,7 +255,7 @@ private function getDataColor() $phpWord = $this->_document; $arrColors = array(); - // PHPWord object : $this->_document + // PhpWord object : $this->_document // Browse styles $styles = Style::getStyles(); @@ -267,10 +266,10 @@ private function getDataColor() if ($style instanceof Font) { $color = $style->getColor(); $fgcolor = $style->getFgColor(); - if (in_array($color, $arrColors) == false && $color != PHPWord::DEFAULT_FONT_COLOR && !empty($color)) { + if (in_array($color, $arrColors) == false && $color != PhpWord::DEFAULT_FONT_COLOR && !empty($color)) { $arrColors[] = $color; } - if (in_array($fgcolor, $arrColors) == false && $fgcolor != PHPWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) { + if (in_array($fgcolor, $arrColors) == false && $fgcolor != PhpWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) { $arrColors[] = $fgcolor; } } @@ -353,9 +352,6 @@ private function getDataContent() return $sRTFBody; } - /** - * Get text - */ private function getDataContentText(Text $text, $withoutP = false) { $sRTFText = ''; @@ -434,7 +430,7 @@ private function getDataContentText(Text $text, $withoutP = false) $sRTFText .= '\i0'; } if ($styleFont->getSize()) { - $sRTFText .= '\fs' . (PHPWord::DEFAULT_FONT_SIZE * 2); + $sRTFText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); } } @@ -444,9 +440,6 @@ private function getDataContentText(Text $text, $withoutP = false) return $sRTFText; } - /** - * Get text run content - */ private function getDataContentTextRun(TextRun $textrun) { $sRTFText = ''; @@ -486,4 +479,4 @@ private function getDataContentUnsupportedElement($element) return $sRTFText; } -} +} \ No newline at end of file diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php index 0aa8e05767..7e356d973e 100755 --- a/Classes/PHPWord/Writer/Word2007.php +++ b/Classes/PHPWord/Writer/Word2007.php @@ -1,8 +1,8 @@ _document = $PHPWord; + $this->_document = $phpWord; $this->_diskCachingDirectory = './'; @@ -187,11 +188,11 @@ public function save($pFilename = null) $objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document)); // Write static files - $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/numbering.xml', 'word/numbering.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/settings.xml', 'word/settings.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml'); + $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/numbering.xml', 'word/numbering.xml'); + $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/settings.xml', 'word/settings.xml'); + $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml'); + $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml'); + $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml'); // Close file @@ -207,7 +208,7 @@ public function save($pFilename = null) @unlink($pFilename); } } else { - throw new Exception("PHPWord object unassigned."); + throw new Exception("PhpWord object unassigned."); } } diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php index a02b008153..902e8e49bb 100755 --- a/Classes/PHPWord/Writer/Word2007/Base.php +++ b/Classes/PHPWord/Writer/Word2007/Base.php @@ -1,8 +1,8 @@ startElement('w:rPr'); // Font - if ($font != PHPWord::DEFAULT_FONT_NAME) { + if ($font != PhpWord::DEFAULT_FONT_NAME) { $xmlWriter->startElement('w:rFonts'); $xmlWriter->writeAttribute('w:ascii', $font); $xmlWriter->writeAttribute('w:hAnsi', $font); $xmlWriter->writeAttribute('w:eastAsia', $font); $xmlWriter->writeAttribute('w:cs', $font); //Font Content Type - if ($hint != PHPWord::DEFAULT_FONT_CONTENT_TYPE) { + if ($hint != PhpWord::DEFAULT_FONT_CONTENT_TYPE) { $xmlWriter->writeAttribute('w:hint', $hint); } $xmlWriter->endElement(); @@ -417,14 +418,14 @@ protected function _writeTextStyle(XMLWriter $xmlWriter = null, Font $style) // Color - if ($color != PHPWord::DEFAULT_FONT_COLOR) { + if ($color != PhpWord::DEFAULT_FONT_COLOR) { $xmlWriter->startElement('w:color'); $xmlWriter->writeAttribute('w:val', $color); $xmlWriter->endElement(); } // Size - if ($size != PHPWord::DEFAULT_FONT_SIZE) { + if ($size != PhpWord::DEFAULT_FONT_SIZE) { $xmlWriter->startElement('w:sz'); $xmlWriter->writeAttribute('w:val', $size * 2); $xmlWriter->endElement(); diff --git a/Classes/PHPWord/Writer/Word2007/ContentTypes.php b/Classes/PHPWord/Writer/Word2007/ContentTypes.php index 27d3cefa6d..2d84070d01 100755 --- a/Classes/PHPWord/Writer/Word2007/ContentTypes.php +++ b/Classes/PHPWord/Writer/Word2007/ContentTypes.php @@ -1,8 +1,8 @@ endElement(); // Company - $xmlWriter->writeElement('Company', $phpWord->getProperties()->getCompany()); + $xmlWriter->writeElement('Company', $phpWord->getDocumentProperties()->getCompany()); // LinksUpToDate $xmlWriter->writeElement('LinksUpToDate', 'false'); @@ -123,7 +124,7 @@ public function writeDocPropsApp(PHPWord $phpWord = null) } - public function writeDocPropsCore(PHPWord $phpWord = null) + public function writeDocPropsCore(PhpWord $phpWord = null) { // Create XML writer $xmlWriter = null; @@ -145,37 +146,37 @@ public function writeDocPropsCore(PHPWord $phpWord = null) $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); // dc:creator - $xmlWriter->writeElement('dc:creator', $phpWord->getProperties()->getCreator()); + $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getCreator()); // cp:lastModifiedBy - $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getProperties()->getLastModifiedBy()); + $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getDocumentProperties()->getLastModifiedBy()); // dcterms:created $xmlWriter->startElement('dcterms:created'); $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getProperties()->getCreated())); + $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getCreated())); $xmlWriter->endElement(); // dcterms:modified $xmlWriter->startElement('dcterms:modified'); $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getProperties()->getModified())); + $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getModified())); $xmlWriter->endElement(); // dc:title - $xmlWriter->writeElement('dc:title', $phpWord->getProperties()->getTitle()); + $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); // dc:description - $xmlWriter->writeElement('dc:description', $phpWord->getProperties()->getDescription()); + $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); // dc:subject - $xmlWriter->writeElement('dc:subject', $phpWord->getProperties()->getSubject()); + $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); // cp:keywords - $xmlWriter->writeElement('cp:keywords', $phpWord->getProperties()->getKeywords()); + $xmlWriter->writeElement('cp:keywords', $phpWord->getDocumentProperties()->getKeywords()); // cp:category - $xmlWriter->writeElement('cp:category', $phpWord->getProperties()->getCategory()); + $xmlWriter->writeElement('cp:category', $phpWord->getDocumentProperties()->getCategory()); $xmlWriter->endElement(); diff --git a/Classes/PHPWord/Writer/Word2007/Document.php b/Classes/PHPWord/Writer/Word2007/Document.php index 691e723e08..f4cd15ea91 100755 --- a/Classes/PHPWord/Writer/Word2007/Document.php +++ b/Classes/PHPWord/Writer/Word2007/Document.php @@ -1,8 +1,8 @@ getParentWriter()->getUseDiskCaching()) { diff --git a/Classes/PHPWord/Writer/Word2007/DocumentRels.php b/Classes/PHPWord/Writer/Word2007/DocumentRels.php index d8e3396b6a..176dd05512 100755 --- a/Classes/PHPWord/Writer/Word2007/DocumentRels.php +++ b/Classes/PHPWord/Writer/Word2007/DocumentRels.php @@ -1,8 +1,8 @@ #### Basic usage -The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/). +The following is a basic example of the PhpWord library. More examples are provided in the [samples folder](samples/). ```php -$PHPWord = new PHPWord(); +$phpWord = new PhpOffice\PhpWord(); // Every element you want to append to the word document is placed in a section. // To create a basic section: -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); // After creating a section, you can append elements: $section->addText('Hello world!'); @@ -97,7 +97,7 @@ $section->addText('Hello world! I am formatted.', // If you often need the same style again you can create a user defined style // to the word document and give the addText function the name of the style: -$PHPWord->addFontStyle('myOwnStyle', +$phpWord->addFontStyle('myOwnStyle', array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232')); $section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle'); @@ -111,7 +111,7 @@ $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); // Finally, write the document: -$xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007'); +$xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $xmlWriter->save('helloWorld.docx'); ``` @@ -120,15 +120,15 @@ $xmlWriter->save('helloWorld.docx'); The base length unit in Open Office XML is twip. Twip means "TWentieth of an Inch Point", i.e. 1 twip = 1/1440 inch. -You can use PHPWord helper functions to convert inches, centimeters, or points to twips. +You can use PhpWord helper functions to convert inches, centimeters, or points to twips. ```php // Paragraph with 6 points space after -$PHPWord->addParagraphStyle('My Style', array( +$phpWord->addParagraphStyle('My Style', array( 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6)) ); -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); $sectionStyle = $section->getSettings(); // half inch left margin $sectionStyle->setMarginLeft(PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); @@ -142,7 +142,7 @@ $sectionStyle->setMarginRight(PhpOffice\PhpWord\Shared\Font::centimeterSizeToTwi Every visible element in word is placed inside of a section. To create a section, use the following code: ```php -$section = $PHPWord->createSection($sectionSettings); +$section = $phpWord->createSection($sectionSettings); ``` The `$sectionSettings` is an optional associative array that sets the section. Example: @@ -188,7 +188,7 @@ The following two settings are automatically set by the use of the `orientation` You can change a section page numbering. ```php -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); $section->getSettings()->setPageNumberingStart(1); ``` @@ -271,7 +271,7 @@ $cell->getStyle()->setGridSpan(5); You can add images easily using the following example. ```php -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); $section->addImage('mars.jpg'); ``` diff --git a/Tests/PHPWord/AutoloaderTest.php b/Tests/PHPWord/AutoloaderTest.php index d33d8ab536..cc244688df 100644 --- a/Tests/PHPWord/AutoloaderTest.php +++ b/Tests/PHPWord/AutoloaderTest.php @@ -1,5 +1,5 @@ assertNull( PHPWord_Autoloader::load('Foo'), - 'PHPWord_Autoloader::load() is trying to load classes outside of the PHPWord namespace' + 'PHPWord_Autoloader::load() is trying to load classes outside of the PhpWord namespace' ); $this->assertTrue( - PHPWord_Autoloader::load('PHPWord'), - 'PHPWord_Autoloader::load() failed to autoload the PHPWord class' + PHPWord_Autoloader::load('PhpWord'), + 'PHPWord_Autoloader::load() failed to autoload the PhpWord class' ); } @@ -36,7 +36,7 @@ public function testAutoload() 'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load classes ' . 'outside of the PhpOffice\\PhpWord namespace' ); - // TODO change this class to the main PHPWord class when it is namespaced + // TODO change this class to the main PhpWord class when it is namespaced Autoloader::autoload( 'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException' ); diff --git a/Tests/PHPWord/DocumentPropertiesTest.php b/Tests/PHPWord/DocumentPropertiesTest.php index 250f1b3ede..b8ad93743c 100644 --- a/Tests/PHPWord/DocumentPropertiesTest.php +++ b/Tests/PHPWord/DocumentPropertiesTest.php @@ -1,10 +1,10 @@ assertInstanceOf( 'PhpOffice\\PhpWord\\Writer\\Word2007', - IOFactory::createWriter(new PHPWord(), 'Word2007') + IOFactory::createWriter(new PhpWord(), 'Word2007') ); } @@ -29,7 +29,7 @@ final public function testExistingWriterCanBeCreated() */ final public function testNonexistentWriterCanNotBeCreated() { - IOFactory::createWriter(new PHPWord(), 'Word2006'); + IOFactory::createWriter(new PhpWord(), 'Word2006'); } /** diff --git a/Tests/PHPWord/MediaTest.php b/Tests/PHPWord/MediaTest.php index 6515e36b26..310a7a113f 100644 --- a/Tests/PHPWord/MediaTest.php +++ b/Tests/PHPWord/MediaTest.php @@ -1,5 +1,5 @@ assertInstanceOf('PhpOffice\\PHPWord', $object); + $this->assertInstanceOf('PhpOffice\\PhpWord', $object); } } \ No newline at end of file diff --git a/Tests/PHPWord/Section/Footer/PreserveTextTest.php b/Tests/PHPWord/Section/Footer/PreserveTextTest.php index 5cf7ca163a..3e355b4200 100644 --- a/Tests/PHPWord/Section/Footer/PreserveTextTest.php +++ b/Tests/PHPWord/Section/Footer/PreserveTextTest.php @@ -1,5 +1,5 @@ PHPWord::DEFAULT_FONT_NAME, - 'size' => PHPWord::DEFAULT_FONT_SIZE, + 'name' => PhpWord::DEFAULT_FONT_NAME, + 'size' => PhpWord::DEFAULT_FONT_SIZE, 'bold' => false, 'italic' => false, 'superScript' => false, 'subScript' => false, 'underline' => Font::UNDERLINE_NONE, 'strikethrough' => false, - 'color' => PHPWord::DEFAULT_FONT_COLOR, + 'color' => PhpWord::DEFAULT_FONT_COLOR, 'fgColor' => null, ); foreach ($attributes as $key => $default) { @@ -83,15 +83,15 @@ public function testSetStyleValueNormal() public function testLineHeight() { - $PHPWord = new PHPWord(); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); // Test style array $text = $section->addText('This is a test', array( 'line-height' => 2.0 )); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing'); $lineHeight = $element->getAttribute('w:line'); @@ -102,7 +102,7 @@ public function testLineHeight() // Test setter $text->getFontStyle()->setLineHeight(3.0); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing'); $lineHeight = $element->getAttribute('w:line'); diff --git a/Tests/PHPWord/Style/ImageTest.php b/Tests/PHPWord/Style/ImageTest.php index 2ed15f4f56..c06bba2e50 100644 --- a/Tests/PHPWord/Style/ImageTest.php +++ b/Tests/PHPWord/Style/ImageTest.php @@ -1,10 +1,10 @@ createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); // Test style array $text = $section->addText('This is a test', array(), array( 'line-height' => 2.0 )); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing'); $lineHeight = $element->getAttribute('w:line'); @@ -108,7 +108,7 @@ public function testLineHeight() // Test setter $text->getParagraphStyle()->setLineHeight(3.0); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing'); $lineHeight = $element->getAttribute('w:line'); diff --git a/Tests/PHPWord/Style/RowTest.php b/Tests/PHPWord/Style/RowTest.php index 97131509f3..ca5f6a637c 100644 --- a/Tests/PHPWord/Style/RowTest.php +++ b/Tests/PHPWord/Style/RowTest.php @@ -1,10 +1,10 @@ addParagraphStyle('tabbed', array('tabs' => array(new Tab('left', 1440, 'dot')))); - $doc = TestHelperDOCX::getDocument($PHPWord); + $phpWord = new PhpWord(); + $phpWord->addParagraphStyle('tabbed', array('tabs' => array(new Tab('left', 1440, 'dot')))); + $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/styles.xml'; $path = '/w:styles/w:style[@w:styleId="tabbed"]/w:pPr/w:tabs/w:tab[1]'; $element = $doc->getElement($path, $file); diff --git a/Tests/PHPWord/StyleTest.php b/Tests/PHPWord/StyleTest.php index bdca8ea746..226387d092 100644 --- a/Tests/PHPWord/StyleTest.php +++ b/Tests/PHPWord/StyleTest.php @@ -1,10 +1,10 @@ loadTemplate($template); + $phpWord = new PhpWord(); + $document = $phpWord->loadTemplate($template); $actualVar = $document->getVariables(); $document->cloneRow('userId', 1); $document->setValue('userId#1', 'Test'); diff --git a/Tests/PHPWord/Writer/ODText/ContentTest.php b/Tests/PHPWord/Writer/ODText/ContentTest.php index 31659d3287..7ebff7765a 100644 --- a/Tests/PHPWord/Writer/ODText/ContentTest.php +++ b/Tests/PHPWord/Writer/ODText/ContentTest.php @@ -1,11 +1,11 @@ setDefaultFontName('Verdana'); - $PHPWord->addFontStyle('Font', array('size' => 11)); - $PHPWord->addParagraphStyle('Paragraph', array('align' => 'center')); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $phpWord->setDefaultFontName('Verdana'); + $phpWord->addFontStyle('Font', array('size' => 11)); + $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); + $section = $phpWord->createSection(); $section->addText($expected); $section->addText('Test font style', 'Font'); $section->addText('Test paragraph style', null, 'Paragraph'); @@ -54,7 +54,7 @@ public function testWriteContent() $section->addTOC(); $textrun = $section->createTextRun(); $textrun->addText('Test text run'); - $doc = TestHelperDOCX::getDocument($PHPWord, 'ODText'); + $doc = TestHelperDOCX::getDocument($phpWord, 'ODText'); $element = "/office:document-content/office:body/office:text/text:p"; $this->assertEquals($expected, $doc->getElement($element, 'content.xml')->nodeValue); diff --git a/Tests/PHPWord/Writer/ODTextTest.php b/Tests/PHPWord/Writer/ODTextTest.php index f1cc721370..bbbfe990fd 100644 --- a/Tests/PHPWord/Writer/ODTextTest.php +++ b/Tests/PHPWord/Writer/ODTextTest.php @@ -1,11 +1,11 @@ assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord()); + $this->assertInstanceOf('PhpOffice\\PhpWord', $object->getPhpWord()); $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable()); $this->assertEquals('./', $object->getDiskCachingDirectory()); @@ -35,14 +35,14 @@ public function testConstruct() } /** - * @covers ::getPHPWord + * @covers ::getPhpWord * @expectedException Exception - * @expectedExceptionMessage No PHPWord assigned. + * @expectedExceptionMessage No PhpWord assigned. */ public function testConstructWithNull() { $object = new ODText(); - $object->getPHPWord(); + $object->getPhpWord(); } /** @@ -52,7 +52,7 @@ public function testSave() { $imageSrc = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PHPWord.png') + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PhpWord.png') ); $objectSrc = \join( \DIRECTORY_SEPARATOR, @@ -63,7 +63,7 @@ public function testSave() array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.odt') ); - $phpWord = new PHPWord(); + $phpWord = new PhpWord(); $phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $section = $phpWord->createSection(); @@ -95,7 +95,7 @@ public function testSave() */ public function testSavePhpOutput() { - $phpWord = new PHPWord(); + $phpWord = new PhpWord(); $section = $phpWord->createSection(); $section->addText('Test'); $writer = new ODText($phpWord); @@ -105,7 +105,7 @@ public function testSavePhpOutput() /** * @covers ::save * @expectedException Exception - * @expectedExceptionMessage PHPWord object unassigned. + * @expectedExceptionMessage PhpWord object unassigned. */ public function testSaveException() { diff --git a/Tests/PHPWord/Writer/RTFTest.php b/Tests/PHPWord/Writer/RTFTest.php index 6a7c078039..ecce87323f 100644 --- a/Tests/PHPWord/Writer/RTFTest.php +++ b/Tests/PHPWord/Writer/RTFTest.php @@ -1,11 +1,11 @@ assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord()); + $this->assertInstanceOf('PhpOffice\\PhpWord', $object->getPhpWord()); $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable()); } /** * covers ::__construct * @expectedException Exception - * @expectedExceptionMessage No PHPWord assigned. + * @expectedExceptionMessage No PhpWord assigned. */ public function testConstructWithNull() { $object = new RTF(); - $object->getPHPWord(); + $object->getPhpWord(); } /** @@ -39,7 +39,7 @@ public function testConstructWithNull() */ public function testSavePhpOutput() { - $phpWord = new PHPWord(); + $phpWord = new PhpWord(); $section = $phpWord->createSection(); $section->addText('Test'); $writer = new RTF($phpWord); @@ -49,7 +49,7 @@ public function testSavePhpOutput() /** * @covers ::save * @expectedException Exception - * @expectedExceptionMessage PHPWord object unassigned. + * @expectedExceptionMessage PhpWord object unassigned. */ public function testSaveException() { @@ -65,7 +65,7 @@ public function testSave() { $imageSrc = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PHPWord.png') + array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PhpWord.png') ); $objectSrc = \join( \DIRECTORY_SEPARATOR, @@ -76,7 +76,7 @@ public function testSave() array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.rtf') ); - $phpWord = new PHPWord(); + $phpWord = new PhpWord(); $phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $section = $phpWord->createSection(); diff --git a/Tests/PHPWord/Writer/Word2007/BaseTest.php b/Tests/PHPWord/Writer/Word2007/BaseTest.php index c66ce9ce02..c62ba3accb 100644 --- a/Tests/PHPWord/Writer/Word2007/BaseTest.php +++ b/Tests/PHPWord/Writer/Word2007/BaseTest.php @@ -1,11 +1,11 @@ addFontStyle($rStyle, array('bold' => true)); - $PHPWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120)); - $section = $PHPWord->createSection(); + $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); + $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')); @@ -52,16 +52,16 @@ public function testWriteTextRun() array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $PHPWord = new PHPWord(); - $PHPWord->addParagraphStyle($pStyle, $aStyle); - $section = $PHPWord->createSection('Test'); + $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); + $doc = TestHelperDOCX::getDocument($phpWord); $parent = "/w:document/w:body/w:p"; $this->assertTrue($doc->elementExists("{$parent}/w:pPr/w:pStyle[@w:val='{$pStyle}']")); @@ -72,13 +72,13 @@ public function testWriteTextRun() */ public function testWriteLink() { - $PHPWord = new PHPWord(); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); - $expected = 'PHPWord'; + $expected = 'PhpWord'; $section->addLink('http://github.com/phpoffice/phpword', $expected); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:p/w:hyperlink/w:r/w:t'); $this->assertEquals($expected, $element->nodeValue); @@ -89,13 +89,13 @@ public function testWriteLink() */ public function testWritePreserveText() { - $PHPWord = new PHPWord(); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); $footer = $section->createFooter(); $footer->addPreserveText('{PAGE}'); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $preserve = $doc->getElement("w:p/w:r[2]/w:instrText", 'word/footer1.xml'); $this->assertEquals('PAGE', $preserve->nodeValue); @@ -112,14 +112,14 @@ public function testWriteTextBreak() $fName = 'fStyle'; $pName = 'pStyle'; - $PHPWord = new PHPWord(); - $PHPWord->addFontStyle($fName, $fArray); - $PHPWord->addParagraphStyle($pName, $pArray); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $phpWord->addFontStyle($fName, $fArray); + $phpWord->addParagraphStyle($pName, $pArray); + $section = $phpWord->createSection(); $section->addTextBreak(); $section->addTextBreak(1, $fArray, $pArray); $section->addTextBreak(1, $fName, $pName); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:rPr/w:rStyle'); $this->assertEquals($fName, $element->getAttribute('w:val')); @@ -132,12 +132,12 @@ public function testWriteTextBreak() */ public function testWriteParagraphStyleAlign() { - $PHPWord = new PHPWord(); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); $section->addText('This is my text', null, array('align' => 'right')); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:jc'); $this->assertEquals('right', $element->getAttribute('w:val')); @@ -149,8 +149,8 @@ public function testWriteParagraphStyleAlign() public function testWriteParagraphStylePagination() { // Create the doc - $PHPWord = new PHPWord(); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); $attributes = array( 'widowControl' => false, 'keepNext' => true, @@ -160,7 +160,7 @@ public function testWriteParagraphStylePagination() foreach ($attributes as $attribute => $value) { $section->addText('Test', null, array($attribute => $value)); } - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); // Test the attributes $i = 0; @@ -178,7 +178,7 @@ public function testWriteParagraphStylePagination() */ public function testWriteFontStyle() { - $PHPWord = new PHPWord(); + $phpWord = new PhpWord(); $styles['name'] = 'Verdana'; $styles['size'] = 14; $styles['bold'] = true; @@ -189,9 +189,9 @@ public function testWriteFontStyle() $styles['color'] = 'FF0000'; $styles['fgColor'] = 'yellow'; - $section = $PHPWord->createSection(); + $section = $phpWord->createSection(); $section->addText('Test', $styles); - $doc = TestHelperDOCX::getDocument($PHPWord); + $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')); @@ -210,7 +210,7 @@ public function testWriteFontStyle() */ public function testWriteTableStyle() { - $PHPWord = new PHPWord(); + $phpWord = new PhpWord(); $tWidth = 120; $rHeight = 120; $cWidth = 120; @@ -232,7 +232,7 @@ public function testWriteTableStyle() $cStyles["borderLeftColor"] = 'FF0000'; $cStyles["borderRightColor"] = 'FF0000'; - $section = $PHPWord->createSection(); + $section = $phpWord->createSection(); $table = $section->addTable($tStyles); $table->setWidth = 100; $table->addRow($rHeight, $rStyles); @@ -244,7 +244,7 @@ public function testWriteTableStyle() $textrun = $cell->createTextRun(); $textrun->addText('Test'); - $doc = TestHelperDOCX::getDocument($PHPWord); + $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')); @@ -268,8 +268,8 @@ public function testWriteTableStyle() */ public function testWriteCellStyleCellGridSpan() { - $PHPWord = new PHPWord(); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); $table = $section->addTable(); @@ -284,7 +284,7 @@ public function testWriteCellStyleCellGridSpan() $table->addCell(40); $table->addCell(40); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan'); $this->assertEquals(5, $element->getAttribute('w:val')); @@ -295,8 +295,8 @@ public function testWriteCellStyleCellGridSpan() */ public function testWriteImagePosition() { - $PHPWord = new PHPWord(); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); $section->addImage( PHPWORD_TESTS_DIR_ROOT . '/_files/images/earth.jpg', array( @@ -306,7 +306,7 @@ public function testWriteImagePosition() ) ); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:p/w:r/w:pict/v:shape'); $style = $element->getAttribute('style'); @@ -325,11 +325,11 @@ public function testWriteWatermark() array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') ); - $PHPWord = new PHPWord(); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); $header = $section->createHeader(); $header->addWatermark($imageSrc); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement("/w:document/w:body/w:sectPr/w:headerReference"); $this->assertStringStartsWith("rId", $element->getAttribute('r:id')); @@ -340,10 +340,10 @@ public function testWriteWatermark() */ public function testWriteTitle() { - $PHPWord = new PHPWord(); - $PHPWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240)); - $PHPWord->createSection()->addTitle('Test', 1); - $doc = TestHelperDOCX::getDocument($PHPWord); + $phpWord = new PhpWord(); + $phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240)); + $phpWord->createSection()->addTitle('Test', 1); + $doc = TestHelperDOCX::getDocument($phpWord); $element = "/w:document/w:body/w:p/w:pPr/w:pStyle"; $this->assertEquals('Heading1', $doc->getElementAttribute($element, 'w:val')); diff --git a/Tests/PHPWord/Writer/Word2007/DocumentTest.php b/Tests/PHPWord/Writer/Word2007/DocumentTest.php index 70a16dc007..da54a7f4f1 100644 --- a/Tests/PHPWord/Writer/Word2007/DocumentTest.php +++ b/Tests/PHPWord/Writer/Word2007/DocumentTest.php @@ -1,11 +1,11 @@ createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); $section->getSettings()->setPageNumberingStart(2); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType'); $this->assertEquals(2, $element->getAttribute('w:start')); @@ -44,20 +44,20 @@ public function testElements() array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') ); - $PHPWord = new PHPWord(); - $PHPWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true)); - $PHPWord->addTitleStyle(2, array('color'=>'666666')); - $section = $PHPWord->createSection(); + $phpWord = new PhpWord(); + $phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true)); + $phpWord->addTitleStyle(2, array('color'=>'666666')); + $section = $phpWord->createSection(); $section->addTOC(); $section->addPageBreak(); $section->addTitle('Title 1', 1); $section->addListItem('List Item 1', 0); $section->addListItem('List Item 2', 0); $section->addListItem('List Item 3', 0); - $section = $PHPWord->createSection(); + $section = $phpWord->createSection(); $section->addTitle('Title 2', 2); $section->addObject($objectSrc); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); // TOC $element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:tabs/w:tab'); diff --git a/Tests/PHPWord/Writer/Word2007/FootnotesTest.php b/Tests/PHPWord/Writer/Word2007/FootnotesTest.php index 5ad4b8c717..18c9caecff 100644 --- a/Tests/PHPWord/Writer/Word2007/FootnotesTest.php +++ b/Tests/PHPWord/Writer/Word2007/FootnotesTest.php @@ -1,11 +1,11 @@ createSection(); + $phpWord = new PhpWord(); + $section = $phpWord->createSection(); $section->addText('Text'); $footnote = $section->createFootnote(); $footnote->addText('Footnote'); $footnote->addLink('http://google.com'); - $doc = TestHelperDOCX::getDocument($PHPWord); + $doc = TestHelperDOCX::getDocument($phpWord); $this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:footnoteReference")); } diff --git a/Tests/PHPWord/Writer/Word2007/StylesTest.php b/Tests/PHPWord/Writer/Word2007/StylesTest.php index 026b5eaaaa..e3c633a714 100644 --- a/Tests/PHPWord/Writer/Word2007/StylesTest.php +++ b/Tests/PHPWord/Writer/Word2007/StylesTest.php @@ -1,11 +1,11 @@ 'both'); $pBase = array('basedOn' => 'Normal'); @@ -42,13 +42,13 @@ public function testWriteStyles() 'borderInsideHSize' => 120, 'borderInsideVSize' => 120, ); - $PHPWord->setDefaultParagraphStyle($pStyle); - $PHPWord->addParagraphStyle('Base Style', $pBase); - $PHPWord->addParagraphStyle('New Style', $pNew); - $PHPWord->addFontStyle('New Style', $rStyle, $pStyle); - $PHPWord->addTableStyle('Table Style', $tStyle, $tStyle); - $PHPWord->addTitleStyle(1, $rStyle, $pStyle); - $doc = TestHelperDOCX::getDocument($PHPWord); + $phpWord->setDefaultParagraphStyle($pStyle); + $phpWord->addParagraphStyle('Base Style', $pBase); + $phpWord->addParagraphStyle('New Style', $pNew); + $phpWord->addFontStyle('New Style', $rStyle, $pStyle); + $phpWord->addTableStyle('Table Style', $tStyle, $tStyle); + $phpWord->addTitleStyle(1, $rStyle, $pStyle); + $doc = TestHelperDOCX::getDocument($phpWord); $file = 'word/styles.xml'; diff --git a/Tests/PHPWord/Writer/Word2007Test.php b/Tests/PHPWord/Writer/Word2007Test.php index 34e025d81a..1c04901d55 100644 --- a/Tests/PHPWord/Writer/Word2007Test.php +++ b/Tests/PHPWord/Writer/Word2007Test.php @@ -1,12 +1,12 @@ addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $section = $phpWord->createSection(); @@ -87,7 +87,7 @@ public function testCheckContentTypes() 'duke_nukem.bmp' => '5.bmp', 'angela_merkel.tif' => '6.tif', ); - $phpWord = new PHPWord(); + $phpWord = new PhpWord(); $section = $phpWord->createSection(); foreach ($images as $source => $target) { $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/{$source}"); diff --git a/Tests/PHPWordTest.php b/Tests/PHPWordTest.php index 4ab63075a1..ca0dded11b 100644 --- a/Tests/PHPWordTest.php +++ b/Tests/PHPWordTest.php @@ -1,55 +1,44 @@ assertEquals(new DocumentProperties(), $object->getProperties()); - $this->assertEquals( - PHPWord::DEFAULT_FONT_NAME, - $object->getDefaultFontName() - ); - $this->assertEquals( - PHPWord::DEFAULT_FONT_SIZE, - $object->getDefaultFontSize() - ); + $phpWord = new PhpWord(); + $this->assertEquals(new DocumentProperties(), $phpWord->getDocumentProperties()); + $this->assertEquals(PhpWord::DEFAULT_FONT_NAME, $phpWord->getDefaultFontName()); + $this->assertEquals(PhpWord::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize()); } /** - * @covers ::setProperties - * @covers ::getProperties + * @covers ::setDocumentProperties + * @covers ::getDocumentProperties */ - public function testSetGetProperties() + public function testSetGetDocumentProperties() { - $object = new PHPWord(); - $creator = 'PHPWord'; - $properties = $object->getProperties(); + $phpWord = new PhpWord(); + $creator = 'PhpWord'; + $properties = $phpWord->getDocumentProperties(); $properties->setCreator($creator); - $object->setProperties($properties); - $this->assertEquals($creator, $object->getProperties()->getCreator()); + $phpWord->setDocumentProperties($properties); + $this->assertEquals($creator, $phpWord->getDocumentProperties()->getCreator()); } /** @@ -58,10 +47,10 @@ public function testSetGetProperties() */ public function testCreateGetSections() { - $object = new PHPWord(); - $this->assertEquals(new Section(1), $object->createSection()); - $object->createSection(); - $this->assertEquals(2, count($object->getSections())); + $phpWord = new PhpWord(); + $this->assertEquals(new Section(1), $phpWord->createSection()); + $phpWord->createSection(); + $this->assertEquals(2, \count($phpWord->getSections())); } /** @@ -70,14 +59,11 @@ public function testCreateGetSections() */ public function testSetGetDefaultFontName() { - $object = new PHPWord(); + $phpWord = new PhpWord(); $fontName = 'Times New Roman'; - $this->assertEquals( - PHPWord::DEFAULT_FONT_NAME, - $object->getDefaultFontName() - ); - $object->setDefaultFontName($fontName); - $this->assertEquals($fontName, $object->getDefaultFontName()); + $this->assertEquals(PhpWord::DEFAULT_FONT_NAME, $phpWord->getDefaultFontName()); + $phpWord->setDefaultFontName($fontName); + $this->assertEquals($fontName, $phpWord->getDefaultFontName()); } /** @@ -86,14 +72,11 @@ public function testSetGetDefaultFontName() */ public function testSetGetDefaultFontSize() { - $object = new PHPWord(); + $phpWord = new PhpWord(); $fontSize = 16; - $this->assertEquals( - PHPWord::DEFAULT_FONT_SIZE, - $object->getDefaultFontSize() - ); - $object->setDefaultFontSize($fontSize); - $this->assertEquals($fontSize, $object->getDefaultFontSize()); + $this->assertEquals(PhpWord::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize()); + $phpWord->setDefaultFontSize($fontSize); + $this->assertEquals($fontSize, $phpWord->getDefaultFontSize()); } /** @@ -102,8 +85,8 @@ public function testSetGetDefaultFontSize() */ public function testSetDefaultParagraphStyle() { - $object = new PHPWord(); - $object->setDefaultParagraphStyle(array()); + $phpWord = new PhpWord(); + $phpWord->setDefaultParagraphStyle(array()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', Style::getStyle('Normal')); } @@ -115,17 +98,17 @@ public function testSetDefaultParagraphStyle() */ public function testAddStyles() { - $object = new PHPWord(); + $phpWord = new PhpWord(); $styles = array( 'Paragraph' => 'Paragraph', - 'Font' => 'Font', - 'Table' => 'TableFull', - 'Link' => 'Font', + 'Font' => 'Font', + 'Table' => 'TableFull', + 'Link' => 'Font', ); foreach ($styles as $key => $value) { $method = "add{$key}Style"; $styleId = "{$key} Style"; - $object->$method($styleId, array()); + $phpWord->$method($styleId, array()); $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$value}", Style::getStyle($styleId)); } @@ -136,10 +119,10 @@ public function testAddStyles() */ public function testAddTitleStyle() { - $object = new PHPWord(); + $phpWord = new PhpWord(); $titleLevel = 1; $titleName = "Heading_{$titleLevel}"; - $object->addTitleStyle($titleLevel, array()); + $phpWord->addTitleStyle($titleLevel, array()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', Style::getStyle($titleName)); } @@ -148,12 +131,15 @@ public function testAddTitleStyle() */ public function testLoadTemplate() { - $file = join( - DIRECTORY_SEPARATOR, + $templateFqfn = \join( + \DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx') ); - $object = new PHPWord(); - $this->assertInstanceOf('PhpOffice\\PhpWord\\Template', $object->loadTemplate($file)); + $phpWord = new PhpWord(); + $this->assertInstanceOf( + 'PhpOffice\\PhpWord\\Template', + $phpWord->loadTemplate($templateFqfn) + ); } /** @@ -162,11 +148,11 @@ public function testLoadTemplate() */ public function testLoadTemplateException() { - $file = join( - DIRECTORY_SEPARATOR, + $templateFqfn = \join( + \DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blanks.docx') ); - $object = new PHPWord(); - $object->loadTemplate($file); + $phpWord = new PhpWord(); + $phpWord->loadTemplate($templateFqfn); } } \ No newline at end of file diff --git a/Tests/_inc/TestHelperDOCX.php b/Tests/_inc/TestHelperDOCX.php index 2897505086..5345c4eb40 100644 --- a/Tests/_inc/TestHelperDOCX.php +++ b/Tests/_inc/TestHelperDOCX.php @@ -1,7 +1,7 @@ save(self::$file); $zip = new \ZipArchive; $res = $zip->open(self::$file); if ($res === true) { - $zip->extractTo(sys_get_temp_dir() . '/PHPWord_Unit_Test/'); + $zip->extractTo(sys_get_temp_dir() . '/PhpWord_Unit_Test/'); $zip->close(); } - return new XmlDocument(sys_get_temp_dir() . '/PHPWord_Unit_Test/'); + return new XmlDocument(sys_get_temp_dir() . '/PhpWord_Unit_Test/'); } public static function clear() @@ -38,8 +38,8 @@ public static function clear() if (file_exists(self::$file)) { unlink(self::$file); } - if (is_dir(sys_get_temp_dir() . '/PHPWord_Unit_Test/')) { - self::deleteDir(sys_get_temp_dir() . '/PHPWord_Unit_Test/'); + if (is_dir(sys_get_temp_dir() . '/PhpWord_Unit_Test/')) { + self::deleteDir(sys_get_temp_dir() . '/PhpWord_Unit_Test/'); } } diff --git a/Tests/_inc/XmlDocument.php b/Tests/_inc/XmlDocument.php index 4d3d00347d..3a6c182d4d 100644 --- a/Tests/_inc/XmlDocument.php +++ b/Tests/_inc/XmlDocument.php @@ -1,5 +1,5 @@ - - ./Tests/PHPWord/ + + ./Tests/PhpWord/ diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index f9e08794f1..a1aafea994 100755 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -2,20 +2,20 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +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)); +echo date('H:i:s') , " Create new PhpWord object" , EOL; +$phpWord = new PhpOffice\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(); +$section = $phpWord->createSection(); // Simple text -$section->addTitle('Welcome to PHPWord', 1); +$section->addTitle('Welcome to PhpWord', 1); $section->addText('Hello World!'); // Two text break @@ -52,7 +52,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index 6bbbe0bb8a..9d3ef32f8e 100755 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -2,33 +2,33 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PHPWord object' , EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s') , ' Create new PhpWord object' , EOL; +$phpWord = new PhpOffice\PhpWord(); // Ads styles -$PHPWord->addParagraphStyle('multipleTab', array( +$phpWord->addParagraphStyle('multipleTab', array( 'tabs' => array( new PhpOffice\PhpWord\Style\Tab('left', 1550), new PhpOffice\PhpWord\Style\Tab('center', 3200), new PhpOffice\PhpWord\Style\Tab('right', 5300) ) )); -$PHPWord->addParagraphStyle('rightTab', array( +$phpWord->addParagraphStyle('rightTab', array( 'tabs' => array( new PhpOffice\PhpWord\Style\Tab('right', 9090) ) )); -$PHPWord->addParagraphStyle('centerTab', array( +$phpWord->addParagraphStyle('centerTab', array( 'tabs' => array( new PhpOffice\PhpWord\Style\Tab('center', 4680) ) )); // New portrait section -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); // Add listitem elements $section->addText("Multiple Tabs:\tOne\tTwo\tThree", NULL, 'multipleTab'); @@ -40,7 +40,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index 9c23e9815e..542b2d5c73 100755 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -2,28 +2,28 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PHPWord object' , EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s') , ' Create new PhpWord object' , EOL; +$phpWord = new PhpOffice\PhpWord(); // New portrait section -$section = $PHPWord->createSection(array('borderColor' => '00FF00', 'borderSize' => 12)); +$section = $phpWord->createSection(array('borderColor' => '00FF00', 'borderSize' => 12)); $section->addText('I am placed on a default section.'); // New landscape section -$section = $PHPWord->createSection(array('orientation' => 'landscape')); +$section = $phpWord->createSection(array('orientation' => 'landscape')); $section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.'); $section->addPageBreak(); $section->addPageBreak(); // New portrait section -$section = $PHPWord->createSection(array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)); +$section = $phpWord->createSection(array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)); $section->addText('This section uses other margins.'); // New portrait section with Header & Footer -$section = $PHPWord->createSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50,)); +$section = $phpWord->createSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50,)); $section->addText('This section and we play with header/footer height.'); $section->createHeader()->addText('Header'); $section->createFooter()->addText('Footer'); @@ -33,7 +33,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php index 64625ac512..c7b8c354ad 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -2,20 +2,20 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PHPWord object' , EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s') , ' Create new PhpWord object' , EOL; +$phpWord = new PhpOffice\PhpWord(); // Ads styles -$PHPWord->addParagraphStyle('pStyle', array('spacing'=>100)); -$PHPWord->addFontStyle('BoldText', array('bold'=>true)); -$PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080')); -$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); +$phpWord->addParagraphStyle('pStyle', array('spacing'=>100)); +$phpWord->addFontStyle('BoldText', array('bold'=>true)); +$phpWord->addFontStyle('ColoredText', array('color'=>'FF8080')); +$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); // New portrait section -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); // Add text run $textrun = $section->createTextRun('pStyle'); @@ -39,7 +39,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php index 1fdae0cfb0..942d851de6 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -2,40 +2,40 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word Document -echo date('H:i:s') , " Create new PHPWord object" , EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s') , " Create new PhpWord object" , EOL; +$phpWord = new PhpOffice\PhpWord(); $filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . 'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' . 'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. ' . 'Suspendisse congue congue leo sed pellentesque.'; // Normal -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); $section->addText('Normal paragraph. ' . $filler); // Two columns -$section = $PHPWord->createSection(array( +$section = $phpWord->createSection(array( 'colsNum' => 2, 'colsSpace' => 1440, 'breakType' => 'continuous')); $section->addText('Three columns, one inch (1440 twips) spacing. ' . $filler); // Normal -$section = $PHPWord->createSection(array('breakType' => 'continuous')); +$section = $phpWord->createSection(array('breakType' => 'continuous')); $section->addText('Normal paragraph again. ' . $filler); // Three columns -$section = $PHPWord->createSection(array( +$section = $phpWord->createSection(array( 'colsNum' => 3, 'colsSpace' => 720, 'breakType' => 'continuous')); $section->addText('Three columns, half inch (720 twips) spacing. ' . $filler); // Normal -$section = $PHPWord->createSection(array('breakType' => 'continuous')); +$section = $phpWord->createSection(array('breakType' => 'continuous')); $section->addText('Normal paragraph again.'); // Save file @@ -43,7 +43,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php index a0b3354575..73555a4448 100755 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -2,20 +2,20 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word Document -echo date('H:i:s') , " Create new PHPWord object" , EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s') , " Create new PhpWord object" , EOL; +$phpWord = new PhpOffice\PhpWord(); // New portrait section -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); // Add style definitions -$PHPWord->addParagraphStyle('pStyle', array('spacing'=>100)); -$PHPWord->addFontStyle('BoldText', array('bold'=>true)); -$PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080')); -$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); +$phpWord->addParagraphStyle('pStyle', array('spacing'=>100)); +$phpWord->addFontStyle('BoldText', array('bold'=>true)); +$phpWord->addFontStyle('ColoredText', array('color'=>'FF8080')); +$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); // Add text elements $textrun = $section->createTextRun('pStyle'); @@ -41,7 +41,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php index f797b986e5..e41bffbdb9 100755 --- a/samples/Sample_07_TemplateCloneRow.php +++ b/samples/Sample_07_TemplateCloneRow.php @@ -2,13 +2,13 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s') , " Create new PHPWord object" , EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s') , " Create new PhpWord object" , EOL; +$phpWord = new PhpOffice\PhpWord(); -$document = $PHPWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx'); +$document = $phpWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx'); // Simple table $document->cloneRow('rowValue', 10); diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index c29c18a8e6..757a9aa732 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -2,19 +2,19 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s') , " Create new PHPWord object" , EOL; -$PHPWord = new PHPWord(); -$PHPWord->setDefaultParagraphStyle(array( +echo date('H:i:s') , " Create new PhpWord object" , EOL; +$phpWord = new PhpOffice\PhpWord(); +$phpWord->setDefaultParagraphStyle(array( 'align' => 'both', 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12), 'spacing' => 120, )); // Sample -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); $section->addText('Below are the samples on how to control your paragraph ' . 'pagination. See "Line and Page Break" tab on paragraph properties ' . @@ -53,7 +53,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index 338e1fa4b8..0750f35ed3 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -2,12 +2,12 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PHPWord object' , EOL; -$PHPWord = new PHPWord(); -$section = $PHPWord->createSection(); +echo date('H:i:s') , ' Create new PhpWord object' , EOL; +$phpWord = new PhpOffice\PhpWord(); +$section = $phpWord->createSection(); $header = array('size' => 16, 'bold' => true); // 1. Basic table @@ -34,7 +34,7 @@ $styleCell = array('valign' => 'center'); $styleCellBTLR = array('valign' => 'center', 'textDirection' => PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR); $fontStyle = array('bold' => true, 'align' => 'center'); -$PHPWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow); +$phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow); $table = $section->addTable('Fancy Table'); $table->addRow(900); $table->addCell(2000, $styleCell)->addText('Row 1', $fontStyle); @@ -64,7 +64,7 @@ $cellHCentered = array('align' => 'center'); $cellVCentered = array('valign' => 'center'); -$PHPWord->addTableStyle('Colspan Rowspan', $styleTable); +$phpWord->addTableStyle('Colspan Rowspan', $styleTable); $table = $section->addTable('Colspan Rowspan'); $table->addRow(); $table->addCell(2000, $cellRowSpan)->addText('A', null, $cellHCentered); @@ -81,7 +81,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php index f6227005b5..506406a156 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -2,12 +2,12 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PHPWord object' , EOL; -$PHPWord = new PHPWord(); -$section = $PHPWord->createSection(); +echo date('H:i:s') , ' Create new PhpWord object' , EOL; +$phpWord = new PhpOffice\PhpWord(); +$section = $phpWord->createSection(); $header = array('size' => 16, 'bold' => true); //1.Use EastAisa FontStyle $section->addText('中文楷体样式测试',array('name' => '楷体', 'size' => 16, 'color' => '1B2232')); @@ -17,7 +17,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php index e5a542531c..b5ff7cf011 100644 --- a/samples/Sample_11_ReadWord2007.php +++ b/samples/Sample_11_ReadWord2007.php @@ -2,19 +2,19 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +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 = PhpOffice\PhpWord\IOFactory::load($source); +$phpWord = PhpOffice\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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index 7cfbad8e5c..d410f76e78 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -2,14 +2,14 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s') , " Create new PHPWord object" , EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s') , " Create new PhpWord object" , EOL; +$phpWord = new PhpOffice\PhpWord(); // New portrait section -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); // Add first page header $header = $section->createHeader(); @@ -18,7 +18,7 @@ $table->addRow(); $table->addCell(4500)->addText('This is the header.'); $table->addCell(4500)->addImage( - 'resources/PHPWord.png', + 'resources/PhpWord.png', array('width' => 80, 'height' => 80, 'align' => 'right') ); @@ -49,7 +49,7 @@ $section->addText('Some text...'); // New portrait section -$section2 = $PHPWord->createSection(); +$section2 = $phpWord->createSection(); $sec2Header = $section2->createHeader(); $sec2Header->addText("All pages in Section 2 will Have this!"); @@ -64,7 +64,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index e5229c9082..f406f4c0d1 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -6,14 +6,14 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PHPWord object", EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s'), " Create new PhpWord object", EOL; +$phpWord = new PhpOffice\PhpWord(); // Begin code -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); $section->addText('Local image without any styles:'); $section->addImage('resources/_mars.jpg'); $section->addTextBreak(2); @@ -32,7 +32,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index 7624e15030..b587ec633d 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -6,14 +6,14 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PHPWord object", EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s'), " Create new PhpWord object", EOL; +$phpWord = new PhpOffice\PhpWord(); // Begin code -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); // Add listitem elements $section->addListItem('List Item 1', 0); @@ -38,8 +38,8 @@ $section->addTextBreak(2); // Add listitem elements -$PHPWord->addFontStyle('myOwnStyle', array('color'=>'FF0000')); -$PHPWord->addParagraphStyle('P-Style', array('spaceAfter'=>95)); +$phpWord->addFontStyle('myOwnStyle', array('color'=>'FF0000')); +$phpWord->addParagraphStyle('P-Style', array('spaceAfter'=>95)); $listStyle = array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED); $section->addListItem('List Item 1', 0, 'myOwnStyle', $listStyle, 'P-Style'); $section->addListItem('List Item 2', 0, 'myOwnStyle', $listStyle, 'P-Style'); @@ -56,7 +56,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php index 08ef742ac5..f0cc82d9b3 100644 --- a/samples/Sample_15_Link.php +++ b/samples/Sample_15_Link.php @@ -6,20 +6,20 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PHPWord object", EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s'), " Create new PhpWord object", EOL; +$phpWord = new PhpOffice\PhpWord(); // Begin code -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); // Add hyperlink elements $section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); $section->addTextBreak(2); -$PHPWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000')); +$phpWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000')); $section->addLink('http://www.bing.com', null, 'myOwnLinkStyle'); $section->addLink('http://www.yahoo.com', null, 'myOwnLinkStyle'); @@ -30,7 +30,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php index d1d18fb660..40dc8c6a9a 100644 --- a/samples/Sample_16_Object.php +++ b/samples/Sample_16_Object.php @@ -6,14 +6,14 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PHPWord object", EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s'), " Create new PhpWord object", EOL; +$phpWord = new PhpOffice\PhpWord(); // Begin code -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); $section->addText('You can open this OLE object by double clicking on the icon:'); $section->addTextBreak(2); $section->addObject('resources/_sheet.xls'); @@ -25,7 +25,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php index 0189bfce71..a083770b34 100644 --- a/samples/Sample_17_TitleTOC.php +++ b/samples/Sample_17_TitleTOC.php @@ -1,26 +1,26 @@ '); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PHPWord object", EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s'), " Create new PhpWord object", EOL; +$phpWord = new PhpOffice\PhpWord(); // Begin code -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); // Define the TOC font style $fontStyle = array('spaceAfter'=>60, 'size'=>12); // Add title styles -$PHPWord->addTitleStyle(1, array('size'=>20, 'color'=>'333333', 'bold'=>true)); -$PHPWord->addTitleStyle(2, array('size'=>16, 'color'=>'666666')); +$phpWord->addTitleStyle(1, array('size'=>20, 'color'=>'333333', 'bold'=>true)); +$phpWord->addTitleStyle(2, array('size'=>16, 'color'=>'666666')); // Add text elements $section->addText('Table of contents:'); @@ -57,7 +57,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php index 0619556775..6f5d1eee64 100644 --- a/samples/Sample_18_Watermark.php +++ b/samples/Sample_18_Watermark.php @@ -1,20 +1,20 @@ '); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PHPWord object", EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s'), " Create new PhpWord object", EOL; +$phpWord = new PhpOffice\PhpWord(); // Begin code -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); $header = $section->createHeader(); $header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55)); $section->addText('The header reference to the current section includes a watermark image.'); @@ -26,7 +26,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php index 3863dfb94c..145b830058 100644 --- a/samples/Sample_19_TextBreak.php +++ b/samples/Sample_19_TextBreak.php @@ -1,25 +1,25 @@ '); -require_once '../Classes/PHPWord.php'; +require_once '../Classes/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PHPWord object", EOL; -$PHPWord = new PHPWord(); +echo date('H:i:s'), " Create new PhpWord object", EOL; +$phpWord = new PhpOffice\PhpWord(); // Begin code $fontStyle = array('size' => 24); $paragraphStyle = array('spacing' => 240, 'size' => 24); -$PHPWord->addFontStyle('fontStyle', array('size' => 9)); -$PHPWord->addParagraphStyle('paragraphStyle', array('spacing' => 480)); +$phpWord->addFontStyle('fontStyle', array('size' => 9)); +$phpWord->addParagraphStyle('paragraphStyle', array('spacing' => 480)); $fontStyle = array('size' => 24); -$section = $PHPWord->createSection(); +$section = $phpWord->createSection(); $section->addText('Text break with no style:'); $section->addTextBreak(); $section->addText('Text break with defined font style:'); @@ -39,7 +39,7 @@ $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer); + $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); } From d51cb0ef3e0eea67b032d02b7ca2ab881d49975f Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 20 Mar 2014 17:17:43 +0400 Subject: [PATCH 07/15] https://github.com/PHPOffice/PHPWord/issues/58 - Part VII (supported PHP version). --- .travis.yml | 1 + README.md | 2 +- composer.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5613304904..2de1aa7cec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: php php: + - 5.3.3 - 5.3 - 5.4 - 5.5 diff --git a/README.md b/README.md index 399c845b0b..b46cd0f098 100755 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ __Want to contribute?__ Fork us! * ... and many more features on progress ## Requirements -* PHP 5.3+ +* PHP 5.3.3+ * PHP [Zip](http://php.net/manual/en/book.zip.php) extension * PHP [XML Parser](http://www.php.net/manual/en/xml.installation.php) extension diff --git a/composer.json b/composer.json index 7911e7aff9..b62a383460 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ } ], "require": { - "php": ">=5.3.0", + "php": ">=5.3.3", "ext-xml": "*", "ext-zip": "*" }, From 90a118852c464c4e63dfb86993e547f9229e7802 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 20 Mar 2014 17:22:47 +0400 Subject: [PATCH 08/15] https://github.com/PHPOffice/PHPWord/issues/58 - Part VI (lost changes). --- Classes/{PHPWord.php => PhpWord.php} | 0 Classes/{PHPWord => PhpWord}/Autoloader.php | 0 Classes/{PHPWord => PhpWord}/DocumentProperties.php | 0 .../{PHPWord => PhpWord}/Exceptions/Exception.php | 0 .../Exceptions/InvalidImageException.php | 0 .../Exceptions/InvalidStyleException.php | 0 .../Exceptions/UnsupportedImageTypeException.php | 0 Classes/{PHPWord => PhpWord}/Footnote.php | 0 Classes/{PHPWord => PhpWord}/HashTable.php | 0 Classes/{PHPWord => PhpWord}/IOFactory.php | 0 Classes/{PHPWord => PhpWord}/Media.php | 0 .../{PHPWord => PhpWord}/Reader/AbstractReader.php | 0 Classes/{PHPWord => PhpWord}/Reader/IReader.php | 0 Classes/{PHPWord => PhpWord}/Reader/Word2007.php | 0 Classes/{PHPWord => PhpWord}/Section.php | 0 Classes/{PHPWord => PhpWord}/Section/Footer.php | 0 .../Section/Footer/PreserveText.php | 0 Classes/{PHPWord => PhpWord}/Section/Footnote.php | 0 Classes/{PHPWord => PhpWord}/Section/Header.php | 0 Classes/{PHPWord => PhpWord}/Section/Image.php | 0 Classes/{PHPWord => PhpWord}/Section/Link.php | 0 Classes/{PHPWord => PhpWord}/Section/ListItem.php | 0 .../{PHPWord => PhpWord}/Section/MemoryImage.php | 0 Classes/{PHPWord => PhpWord}/Section/Object.php | 0 Classes/{PHPWord => PhpWord}/Section/PageBreak.php | 0 Classes/{PHPWord => PhpWord}/Section/Settings.php | 0 Classes/{PHPWord => PhpWord}/Section/Table.php | 0 Classes/{PHPWord => PhpWord}/Section/Table/Cell.php | 0 Classes/{PHPWord => PhpWord}/Section/Table/Row.php | 0 Classes/{PHPWord => PhpWord}/Section/Text.php | 0 Classes/{PHPWord => PhpWord}/Section/TextBreak.php | 0 Classes/{PHPWord => PhpWord}/Section/TextRun.php | 0 Classes/{PHPWord => PhpWord}/Section/Title.php | 0 Classes/{PHPWord => PhpWord}/Settings.php | 0 Classes/{PHPWord => PhpWord}/Shared/Drawing.php | 0 Classes/{PHPWord => PhpWord}/Shared/File.php | 0 Classes/{PHPWord => PhpWord}/Shared/Font.php | 0 Classes/{PHPWord => PhpWord}/Shared/String.php | 0 Classes/{PHPWord => PhpWord}/Shared/XMLWriter.php | 0 .../Shared/ZipStreamWrapper.php | 0 Classes/{PHPWord => PhpWord}/Style.php | 0 Classes/{PHPWord => PhpWord}/Style/Cell.php | 0 Classes/{PHPWord => PhpWord}/Style/Font.php | 0 Classes/{PHPWord => PhpWord}/Style/Image.php | 0 Classes/{PHPWord => PhpWord}/Style/ListItem.php | 0 Classes/{PHPWord => PhpWord}/Style/Paragraph.php | 0 Classes/{PHPWord => PhpWord}/Style/Row.php | 0 Classes/{PHPWord => PhpWord}/Style/TOC.php | 0 Classes/{PHPWord => PhpWord}/Style/Tab.php | 0 Classes/{PHPWord => PhpWord}/Style/Table.php | 0 Classes/{PHPWord => PhpWord}/Style/TableFull.php | 0 Classes/{PHPWord => PhpWord}/Style/Tabs.php | 0 Classes/{PHPWord => PhpWord}/TOC.php | 0 Classes/{PHPWord => PhpWord}/Template.php | 0 Classes/{PHPWord => PhpWord}/Writer/IWriter.php | 0 Classes/{PHPWord => PhpWord}/Writer/ODText.php | 0 .../{PHPWord => PhpWord}/Writer/ODText/Content.php | 0 .../{PHPWord => PhpWord}/Writer/ODText/Manifest.php | 0 Classes/{PHPWord => PhpWord}/Writer/ODText/Meta.php | 0 .../{PHPWord => PhpWord}/Writer/ODText/Mimetype.php | 0 .../{PHPWord => PhpWord}/Writer/ODText/Styles.php | 0 .../Writer/ODText/WriterPart.php | 0 Classes/{PHPWord => PhpWord}/Writer/RTF.php | 0 Classes/{PHPWord => PhpWord}/Writer/Word2007.php | 0 .../{PHPWord => PhpWord}/Writer/Word2007/Base.php | 0 .../Writer/Word2007/ContentTypes.php | 0 .../Writer/Word2007/DocProps.php | 0 .../Writer/Word2007/Document.php | 0 .../Writer/Word2007/DocumentRels.php | 0 .../{PHPWord => PhpWord}/Writer/Word2007/Footer.php | 0 .../Writer/Word2007/Footnotes.php | 0 .../Writer/Word2007/FootnotesRels.php | 0 .../{PHPWord => PhpWord}/Writer/Word2007/Header.php | 0 .../{PHPWord => PhpWord}/Writer/Word2007/Rels.php | 0 .../{PHPWord => PhpWord}/Writer/Word2007/Styles.php | 0 .../Writer/Word2007/WriterPart.php | 0 .../{PHPWord => PhpWord}/_staticDocParts/_doc.png | Bin .../{PHPWord => PhpWord}/_staticDocParts/_ppt.png | Bin .../{PHPWord => PhpWord}/_staticDocParts/_xls.png | Bin .../_staticDocParts/fontTable.xml | 0 .../_staticDocParts/numbering.xml | 0 .../_staticDocParts/settings.xml | 0 .../{PHPWord => PhpWord}/_staticDocParts/theme1.xml | 0 .../_staticDocParts/webSettings.xml | 0 Tests/{PHPWord => PhpWord}/AutoloaderTest.php | 0 .../{PHPWord => PhpWord}/DocumentPropertiesTest.php | 0 .../Exceptions/ExceptionTest.php | 0 .../Exceptions/InvalidImageExceptionTest.php | 0 .../Exceptions/InvalidStyleExceptionTest.php | 0 .../UnsupportedImageTypeExceptionTest.php | 0 Tests/{PHPWord => PhpWord}/IOFactoryTest.php | 0 Tests/{PHPWord => PhpWord}/MediaTest.php | 0 Tests/{PHPWord => PhpWord}/Reader/Word2007Test.php | 0 .../Section/Footer/PreserveTextTest.php | 0 Tests/{PHPWord => PhpWord}/Section/FooterTest.php | 0 Tests/{PHPWord => PhpWord}/Section/FootnoteTest.php | 0 Tests/{PHPWord => PhpWord}/Section/HeaderTest.php | 0 Tests/{PHPWord => PhpWord}/Section/ImageTest.php | 0 Tests/{PHPWord => PhpWord}/Section/LinkTest.php | 0 Tests/{PHPWord => PhpWord}/Section/ListItemTest.php | 0 .../Section/MemoryImageTest.php | 0 Tests/{PHPWord => PhpWord}/Section/ObjectTest.php | 0 .../{PHPWord => PhpWord}/Section/PageBreakTest.php | 0 Tests/{PHPWord => PhpWord}/Section/SettingsTest.php | 0 .../{PHPWord => PhpWord}/Section/Table/CellTest.php | 0 .../{PHPWord => PhpWord}/Section/Table/RowTest.php | 0 Tests/{PHPWord => PhpWord}/Section/TableTest.php | 0 .../{PHPWord => PhpWord}/Section/TextBreakTest.php | 0 Tests/{PHPWord => PhpWord}/Section/TextRunTest.php | 0 Tests/{PHPWord => PhpWord}/Section/TextTest.php | 0 Tests/{PHPWord => PhpWord}/Section/TitleTest.php | 0 Tests/{PHPWord => PhpWord}/SectionTest.php | 0 Tests/{PHPWord => PhpWord}/SettingsTest.php | 0 Tests/{PHPWord => PhpWord}/Shared/DrawingTest.php | 0 Tests/{PHPWord => PhpWord}/Shared/FileTest.php | 0 Tests/{PHPWord => PhpWord}/Shared/FontTest.php | 0 Tests/{PHPWord => PhpWord}/Shared/StringTest.php | 0 Tests/{PHPWord => PhpWord}/Style/CellTest.php | 0 Tests/{PHPWord => PhpWord}/Style/FontTest.php | 0 Tests/{PHPWord => PhpWord}/Style/ImageTest.php | 0 Tests/{PHPWord => PhpWord}/Style/ListItemTest.php | 0 Tests/{PHPWord => PhpWord}/Style/ParagraphTest.php | 0 Tests/{PHPWord => PhpWord}/Style/RowTest.php | 0 Tests/{PHPWord => PhpWord}/Style/TOCTest.php | 0 Tests/{PHPWord => PhpWord}/Style/TableFullTest.php | 0 Tests/{PHPWord => PhpWord}/Style/TableTest.php | 0 Tests/{PHPWord => PhpWord}/Style/TabsTest.php | 0 Tests/{PHPWord => PhpWord}/StyleTest.php | 0 Tests/{PHPWord => PhpWord}/TOCTest.php | 0 Tests/{PHPWord => PhpWord}/TemplateTest.php | 0 .../Writer/ODText/ContentTest.php | 0 Tests/{PHPWord => PhpWord}/Writer/ODTextTest.php | 0 Tests/{PHPWord => PhpWord}/Writer/RTFTest.php | 0 .../Writer/Word2007/BaseTest.php | 0 .../Writer/Word2007/DocumentTest.php | 0 .../Writer/Word2007/FootnotesTest.php | 0 .../Writer/Word2007/StylesTest.php | 0 Tests/{PHPWord => PhpWord}/Writer/Word2007Test.php | 0 Tests/{PHPWordTest.php => PhpWordTest.php} | 0 Tests/_files/images/{PHPWord.png => PhpWord.png} | Bin 140 files changed, 0 insertions(+), 0 deletions(-) rename Classes/{PHPWord.php => PhpWord.php} (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Autoloader.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/DocumentProperties.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Exceptions/Exception.php (100%) rename Classes/{PHPWord => PhpWord}/Exceptions/InvalidImageException.php (100%) rename Classes/{PHPWord => PhpWord}/Exceptions/InvalidStyleException.php (100%) rename Classes/{PHPWord => PhpWord}/Exceptions/UnsupportedImageTypeException.php (100%) rename Classes/{PHPWord => PhpWord}/Footnote.php (100%) rename Classes/{PHPWord => PhpWord}/HashTable.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/IOFactory.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Media.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Reader/AbstractReader.php (100%) rename Classes/{PHPWord => PhpWord}/Reader/IReader.php (100%) rename Classes/{PHPWord => PhpWord}/Reader/Word2007.php (100%) rename Classes/{PHPWord => PhpWord}/Section.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Footer.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Footer/PreserveText.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Footnote.php (100%) rename Classes/{PHPWord => PhpWord}/Section/Header.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Image.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Link.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/ListItem.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/MemoryImage.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Object.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/PageBreak.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Settings.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Table.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Table/Cell.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Table/Row.php (100%) rename Classes/{PHPWord => PhpWord}/Section/Text.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/TextBreak.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/TextRun.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Section/Title.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Settings.php (100%) rename Classes/{PHPWord => PhpWord}/Shared/Drawing.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Shared/File.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Shared/Font.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Shared/String.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Shared/XMLWriter.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Shared/ZipStreamWrapper.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/Cell.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/Font.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/Image.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/ListItem.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/Paragraph.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/Row.php (100%) rename Classes/{PHPWord => PhpWord}/Style/TOC.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/Tab.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/Table.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/TableFull.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Style/Tabs.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/TOC.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Template.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/IWriter.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/ODText.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/ODText/Content.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/ODText/Manifest.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/ODText/Meta.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/ODText/Mimetype.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/ODText/Styles.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/ODText/WriterPart.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/RTF.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/Base.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/ContentTypes.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/DocProps.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/Document.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/DocumentRels.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/Footer.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/Footnotes.php (100%) rename Classes/{PHPWord => PhpWord}/Writer/Word2007/FootnotesRels.php (100%) rename Classes/{PHPWord => PhpWord}/Writer/Word2007/Header.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/Rels.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/Styles.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/Writer/Word2007/WriterPart.php (100%) mode change 100755 => 100644 rename Classes/{PHPWord => PhpWord}/_staticDocParts/_doc.png (100%) rename Classes/{PHPWord => PhpWord}/_staticDocParts/_ppt.png (100%) rename Classes/{PHPWord => PhpWord}/_staticDocParts/_xls.png (100%) rename Classes/{PHPWord => PhpWord}/_staticDocParts/fontTable.xml (100%) rename Classes/{PHPWord => PhpWord}/_staticDocParts/numbering.xml (100%) rename Classes/{PHPWord => PhpWord}/_staticDocParts/settings.xml (100%) rename Classes/{PHPWord => PhpWord}/_staticDocParts/theme1.xml (100%) rename Classes/{PHPWord => PhpWord}/_staticDocParts/webSettings.xml (100%) rename Tests/{PHPWord => PhpWord}/AutoloaderTest.php (100%) rename Tests/{PHPWord => PhpWord}/DocumentPropertiesTest.php (100%) rename Tests/{PHPWord => PhpWord}/Exceptions/ExceptionTest.php (100%) rename Tests/{PHPWord => PhpWord}/Exceptions/InvalidImageExceptionTest.php (100%) rename Tests/{PHPWord => PhpWord}/Exceptions/InvalidStyleExceptionTest.php (100%) rename Tests/{PHPWord => PhpWord}/Exceptions/UnsupportedImageTypeExceptionTest.php (100%) rename Tests/{PHPWord => PhpWord}/IOFactoryTest.php (100%) rename Tests/{PHPWord => PhpWord}/MediaTest.php (100%) rename Tests/{PHPWord => PhpWord}/Reader/Word2007Test.php (100%) rename Tests/{PHPWord => PhpWord}/Section/Footer/PreserveTextTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/FooterTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/FootnoteTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/HeaderTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/ImageTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/LinkTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/ListItemTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/MemoryImageTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/ObjectTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/PageBreakTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/SettingsTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/Table/CellTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/Table/RowTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/TableTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/TextBreakTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/TextRunTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/TextTest.php (100%) rename Tests/{PHPWord => PhpWord}/Section/TitleTest.php (100%) rename Tests/{PHPWord => PhpWord}/SectionTest.php (100%) rename Tests/{PHPWord => PhpWord}/SettingsTest.php (100%) rename Tests/{PHPWord => PhpWord}/Shared/DrawingTest.php (100%) rename Tests/{PHPWord => PhpWord}/Shared/FileTest.php (100%) rename Tests/{PHPWord => PhpWord}/Shared/FontTest.php (100%) rename Tests/{PHPWord => PhpWord}/Shared/StringTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/CellTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/FontTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/ImageTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/ListItemTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/ParagraphTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/RowTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/TOCTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/TableFullTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/TableTest.php (100%) rename Tests/{PHPWord => PhpWord}/Style/TabsTest.php (100%) rename Tests/{PHPWord => PhpWord}/StyleTest.php (100%) rename Tests/{PHPWord => PhpWord}/TOCTest.php (100%) rename Tests/{PHPWord => PhpWord}/TemplateTest.php (100%) rename Tests/{PHPWord => PhpWord}/Writer/ODText/ContentTest.php (100%) rename Tests/{PHPWord => PhpWord}/Writer/ODTextTest.php (100%) rename Tests/{PHPWord => PhpWord}/Writer/RTFTest.php (100%) rename Tests/{PHPWord => PhpWord}/Writer/Word2007/BaseTest.php (100%) rename Tests/{PHPWord => PhpWord}/Writer/Word2007/DocumentTest.php (100%) rename Tests/{PHPWord => PhpWord}/Writer/Word2007/FootnotesTest.php (100%) rename Tests/{PHPWord => PhpWord}/Writer/Word2007/StylesTest.php (100%) rename Tests/{PHPWord => PhpWord}/Writer/Word2007Test.php (100%) rename Tests/{PHPWordTest.php => PhpWordTest.php} (100%) rename Tests/_files/images/{PHPWord.png => PhpWord.png} (100%) diff --git a/Classes/PHPWord.php b/Classes/PhpWord.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord.php rename to Classes/PhpWord.php diff --git a/Classes/PHPWord/Autoloader.php b/Classes/PhpWord/Autoloader.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Autoloader.php rename to Classes/PhpWord/Autoloader.php diff --git a/Classes/PHPWord/DocumentProperties.php b/Classes/PhpWord/DocumentProperties.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/DocumentProperties.php rename to Classes/PhpWord/DocumentProperties.php diff --git a/Classes/PHPWord/Exceptions/Exception.php b/Classes/PhpWord/Exceptions/Exception.php similarity index 100% rename from Classes/PHPWord/Exceptions/Exception.php rename to Classes/PhpWord/Exceptions/Exception.php diff --git a/Classes/PHPWord/Exceptions/InvalidImageException.php b/Classes/PhpWord/Exceptions/InvalidImageException.php similarity index 100% rename from Classes/PHPWord/Exceptions/InvalidImageException.php rename to Classes/PhpWord/Exceptions/InvalidImageException.php diff --git a/Classes/PHPWord/Exceptions/InvalidStyleException.php b/Classes/PhpWord/Exceptions/InvalidStyleException.php similarity index 100% rename from Classes/PHPWord/Exceptions/InvalidStyleException.php rename to Classes/PhpWord/Exceptions/InvalidStyleException.php diff --git a/Classes/PHPWord/Exceptions/UnsupportedImageTypeException.php b/Classes/PhpWord/Exceptions/UnsupportedImageTypeException.php similarity index 100% rename from Classes/PHPWord/Exceptions/UnsupportedImageTypeException.php rename to Classes/PhpWord/Exceptions/UnsupportedImageTypeException.php diff --git a/Classes/PHPWord/Footnote.php b/Classes/PhpWord/Footnote.php similarity index 100% rename from Classes/PHPWord/Footnote.php rename to Classes/PhpWord/Footnote.php diff --git a/Classes/PHPWord/HashTable.php b/Classes/PhpWord/HashTable.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/HashTable.php rename to Classes/PhpWord/HashTable.php diff --git a/Classes/PHPWord/IOFactory.php b/Classes/PhpWord/IOFactory.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/IOFactory.php rename to Classes/PhpWord/IOFactory.php diff --git a/Classes/PHPWord/Media.php b/Classes/PhpWord/Media.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Media.php rename to Classes/PhpWord/Media.php diff --git a/Classes/PHPWord/Reader/AbstractReader.php b/Classes/PhpWord/Reader/AbstractReader.php similarity index 100% rename from Classes/PHPWord/Reader/AbstractReader.php rename to Classes/PhpWord/Reader/AbstractReader.php diff --git a/Classes/PHPWord/Reader/IReader.php b/Classes/PhpWord/Reader/IReader.php similarity index 100% rename from Classes/PHPWord/Reader/IReader.php rename to Classes/PhpWord/Reader/IReader.php diff --git a/Classes/PHPWord/Reader/Word2007.php b/Classes/PhpWord/Reader/Word2007.php similarity index 100% rename from Classes/PHPWord/Reader/Word2007.php rename to Classes/PhpWord/Reader/Word2007.php diff --git a/Classes/PHPWord/Section.php b/Classes/PhpWord/Section.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section.php rename to Classes/PhpWord/Section.php diff --git a/Classes/PHPWord/Section/Footer.php b/Classes/PhpWord/Section/Footer.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Footer.php rename to Classes/PhpWord/Section/Footer.php diff --git a/Classes/PHPWord/Section/Footer/PreserveText.php b/Classes/PhpWord/Section/Footer/PreserveText.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Footer/PreserveText.php rename to Classes/PhpWord/Section/Footer/PreserveText.php diff --git a/Classes/PHPWord/Section/Footnote.php b/Classes/PhpWord/Section/Footnote.php similarity index 100% rename from Classes/PHPWord/Section/Footnote.php rename to Classes/PhpWord/Section/Footnote.php diff --git a/Classes/PHPWord/Section/Header.php b/Classes/PhpWord/Section/Header.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Header.php rename to Classes/PhpWord/Section/Header.php diff --git a/Classes/PHPWord/Section/Image.php b/Classes/PhpWord/Section/Image.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Image.php rename to Classes/PhpWord/Section/Image.php diff --git a/Classes/PHPWord/Section/Link.php b/Classes/PhpWord/Section/Link.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Link.php rename to Classes/PhpWord/Section/Link.php diff --git a/Classes/PHPWord/Section/ListItem.php b/Classes/PhpWord/Section/ListItem.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/ListItem.php rename to Classes/PhpWord/Section/ListItem.php diff --git a/Classes/PHPWord/Section/MemoryImage.php b/Classes/PhpWord/Section/MemoryImage.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/MemoryImage.php rename to Classes/PhpWord/Section/MemoryImage.php diff --git a/Classes/PHPWord/Section/Object.php b/Classes/PhpWord/Section/Object.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Object.php rename to Classes/PhpWord/Section/Object.php diff --git a/Classes/PHPWord/Section/PageBreak.php b/Classes/PhpWord/Section/PageBreak.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/PageBreak.php rename to Classes/PhpWord/Section/PageBreak.php diff --git a/Classes/PHPWord/Section/Settings.php b/Classes/PhpWord/Section/Settings.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Settings.php rename to Classes/PhpWord/Section/Settings.php diff --git a/Classes/PHPWord/Section/Table.php b/Classes/PhpWord/Section/Table.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Table.php rename to Classes/PhpWord/Section/Table.php diff --git a/Classes/PHPWord/Section/Table/Cell.php b/Classes/PhpWord/Section/Table/Cell.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Table/Cell.php rename to Classes/PhpWord/Section/Table/Cell.php diff --git a/Classes/PHPWord/Section/Table/Row.php b/Classes/PhpWord/Section/Table/Row.php similarity index 100% rename from Classes/PHPWord/Section/Table/Row.php rename to Classes/PhpWord/Section/Table/Row.php diff --git a/Classes/PHPWord/Section/Text.php b/Classes/PhpWord/Section/Text.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Text.php rename to Classes/PhpWord/Section/Text.php diff --git a/Classes/PHPWord/Section/TextBreak.php b/Classes/PhpWord/Section/TextBreak.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/TextBreak.php rename to Classes/PhpWord/Section/TextBreak.php diff --git a/Classes/PHPWord/Section/TextRun.php b/Classes/PhpWord/Section/TextRun.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/TextRun.php rename to Classes/PhpWord/Section/TextRun.php diff --git a/Classes/PHPWord/Section/Title.php b/Classes/PhpWord/Section/Title.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Section/Title.php rename to Classes/PhpWord/Section/Title.php diff --git a/Classes/PHPWord/Settings.php b/Classes/PhpWord/Settings.php similarity index 100% rename from Classes/PHPWord/Settings.php rename to Classes/PhpWord/Settings.php diff --git a/Classes/PHPWord/Shared/Drawing.php b/Classes/PhpWord/Shared/Drawing.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Shared/Drawing.php rename to Classes/PhpWord/Shared/Drawing.php diff --git a/Classes/PHPWord/Shared/File.php b/Classes/PhpWord/Shared/File.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Shared/File.php rename to Classes/PhpWord/Shared/File.php diff --git a/Classes/PHPWord/Shared/Font.php b/Classes/PhpWord/Shared/Font.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Shared/Font.php rename to Classes/PhpWord/Shared/Font.php diff --git a/Classes/PHPWord/Shared/String.php b/Classes/PhpWord/Shared/String.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Shared/String.php rename to Classes/PhpWord/Shared/String.php diff --git a/Classes/PHPWord/Shared/XMLWriter.php b/Classes/PhpWord/Shared/XMLWriter.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Shared/XMLWriter.php rename to Classes/PhpWord/Shared/XMLWriter.php diff --git a/Classes/PHPWord/Shared/ZipStreamWrapper.php b/Classes/PhpWord/Shared/ZipStreamWrapper.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Shared/ZipStreamWrapper.php rename to Classes/PhpWord/Shared/ZipStreamWrapper.php diff --git a/Classes/PHPWord/Style.php b/Classes/PhpWord/Style.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style.php rename to Classes/PhpWord/Style.php diff --git a/Classes/PHPWord/Style/Cell.php b/Classes/PhpWord/Style/Cell.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/Cell.php rename to Classes/PhpWord/Style/Cell.php diff --git a/Classes/PHPWord/Style/Font.php b/Classes/PhpWord/Style/Font.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/Font.php rename to Classes/PhpWord/Style/Font.php diff --git a/Classes/PHPWord/Style/Image.php b/Classes/PhpWord/Style/Image.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/Image.php rename to Classes/PhpWord/Style/Image.php diff --git a/Classes/PHPWord/Style/ListItem.php b/Classes/PhpWord/Style/ListItem.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/ListItem.php rename to Classes/PhpWord/Style/ListItem.php diff --git a/Classes/PHPWord/Style/Paragraph.php b/Classes/PhpWord/Style/Paragraph.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/Paragraph.php rename to Classes/PhpWord/Style/Paragraph.php diff --git a/Classes/PHPWord/Style/Row.php b/Classes/PhpWord/Style/Row.php similarity index 100% rename from Classes/PHPWord/Style/Row.php rename to Classes/PhpWord/Style/Row.php diff --git a/Classes/PHPWord/Style/TOC.php b/Classes/PhpWord/Style/TOC.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/TOC.php rename to Classes/PhpWord/Style/TOC.php diff --git a/Classes/PHPWord/Style/Tab.php b/Classes/PhpWord/Style/Tab.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/Tab.php rename to Classes/PhpWord/Style/Tab.php diff --git a/Classes/PHPWord/Style/Table.php b/Classes/PhpWord/Style/Table.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/Table.php rename to Classes/PhpWord/Style/Table.php diff --git a/Classes/PHPWord/Style/TableFull.php b/Classes/PhpWord/Style/TableFull.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/TableFull.php rename to Classes/PhpWord/Style/TableFull.php diff --git a/Classes/PHPWord/Style/Tabs.php b/Classes/PhpWord/Style/Tabs.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Style/Tabs.php rename to Classes/PhpWord/Style/Tabs.php diff --git a/Classes/PHPWord/TOC.php b/Classes/PhpWord/TOC.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/TOC.php rename to Classes/PhpWord/TOC.php diff --git a/Classes/PHPWord/Template.php b/Classes/PhpWord/Template.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Template.php rename to Classes/PhpWord/Template.php diff --git a/Classes/PHPWord/Writer/IWriter.php b/Classes/PhpWord/Writer/IWriter.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/IWriter.php rename to Classes/PhpWord/Writer/IWriter.php diff --git a/Classes/PHPWord/Writer/ODText.php b/Classes/PhpWord/Writer/ODText.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/ODText.php rename to Classes/PhpWord/Writer/ODText.php diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PhpWord/Writer/ODText/Content.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/ODText/Content.php rename to Classes/PhpWord/Writer/ODText/Content.php diff --git a/Classes/PHPWord/Writer/ODText/Manifest.php b/Classes/PhpWord/Writer/ODText/Manifest.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/ODText/Manifest.php rename to Classes/PhpWord/Writer/ODText/Manifest.php diff --git a/Classes/PHPWord/Writer/ODText/Meta.php b/Classes/PhpWord/Writer/ODText/Meta.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/ODText/Meta.php rename to Classes/PhpWord/Writer/ODText/Meta.php diff --git a/Classes/PHPWord/Writer/ODText/Mimetype.php b/Classes/PhpWord/Writer/ODText/Mimetype.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/ODText/Mimetype.php rename to Classes/PhpWord/Writer/ODText/Mimetype.php diff --git a/Classes/PHPWord/Writer/ODText/Styles.php b/Classes/PhpWord/Writer/ODText/Styles.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/ODText/Styles.php rename to Classes/PhpWord/Writer/ODText/Styles.php diff --git a/Classes/PHPWord/Writer/ODText/WriterPart.php b/Classes/PhpWord/Writer/ODText/WriterPart.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/ODText/WriterPart.php rename to Classes/PhpWord/Writer/ODText/WriterPart.php diff --git a/Classes/PHPWord/Writer/RTF.php b/Classes/PhpWord/Writer/RTF.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/RTF.php rename to Classes/PhpWord/Writer/RTF.php diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PhpWord/Writer/Word2007.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007.php rename to Classes/PhpWord/Writer/Word2007.php diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PhpWord/Writer/Word2007/Base.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/Base.php rename to Classes/PhpWord/Writer/Word2007/Base.php diff --git a/Classes/PHPWord/Writer/Word2007/ContentTypes.php b/Classes/PhpWord/Writer/Word2007/ContentTypes.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/ContentTypes.php rename to Classes/PhpWord/Writer/Word2007/ContentTypes.php diff --git a/Classes/PHPWord/Writer/Word2007/DocProps.php b/Classes/PhpWord/Writer/Word2007/DocProps.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/DocProps.php rename to Classes/PhpWord/Writer/Word2007/DocProps.php diff --git a/Classes/PHPWord/Writer/Word2007/Document.php b/Classes/PhpWord/Writer/Word2007/Document.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/Document.php rename to Classes/PhpWord/Writer/Word2007/Document.php diff --git a/Classes/PHPWord/Writer/Word2007/DocumentRels.php b/Classes/PhpWord/Writer/Word2007/DocumentRels.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/DocumentRels.php rename to Classes/PhpWord/Writer/Word2007/DocumentRels.php diff --git a/Classes/PHPWord/Writer/Word2007/Footer.php b/Classes/PhpWord/Writer/Word2007/Footer.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/Footer.php rename to Classes/PhpWord/Writer/Word2007/Footer.php diff --git a/Classes/PHPWord/Writer/Word2007/Footnotes.php b/Classes/PhpWord/Writer/Word2007/Footnotes.php similarity index 100% rename from Classes/PHPWord/Writer/Word2007/Footnotes.php rename to Classes/PhpWord/Writer/Word2007/Footnotes.php diff --git a/Classes/PHPWord/Writer/Word2007/FootnotesRels.php b/Classes/PhpWord/Writer/Word2007/FootnotesRels.php similarity index 100% rename from Classes/PHPWord/Writer/Word2007/FootnotesRels.php rename to Classes/PhpWord/Writer/Word2007/FootnotesRels.php diff --git a/Classes/PHPWord/Writer/Word2007/Header.php b/Classes/PhpWord/Writer/Word2007/Header.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/Header.php rename to Classes/PhpWord/Writer/Word2007/Header.php diff --git a/Classes/PHPWord/Writer/Word2007/Rels.php b/Classes/PhpWord/Writer/Word2007/Rels.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/Rels.php rename to Classes/PhpWord/Writer/Word2007/Rels.php diff --git a/Classes/PHPWord/Writer/Word2007/Styles.php b/Classes/PhpWord/Writer/Word2007/Styles.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/Styles.php rename to Classes/PhpWord/Writer/Word2007/Styles.php diff --git a/Classes/PHPWord/Writer/Word2007/WriterPart.php b/Classes/PhpWord/Writer/Word2007/WriterPart.php old mode 100755 new mode 100644 similarity index 100% rename from Classes/PHPWord/Writer/Word2007/WriterPart.php rename to Classes/PhpWord/Writer/Word2007/WriterPart.php diff --git a/Classes/PHPWord/_staticDocParts/_doc.png b/Classes/PhpWord/_staticDocParts/_doc.png similarity index 100% rename from Classes/PHPWord/_staticDocParts/_doc.png rename to Classes/PhpWord/_staticDocParts/_doc.png diff --git a/Classes/PHPWord/_staticDocParts/_ppt.png b/Classes/PhpWord/_staticDocParts/_ppt.png similarity index 100% rename from Classes/PHPWord/_staticDocParts/_ppt.png rename to Classes/PhpWord/_staticDocParts/_ppt.png diff --git a/Classes/PHPWord/_staticDocParts/_xls.png b/Classes/PhpWord/_staticDocParts/_xls.png similarity index 100% rename from Classes/PHPWord/_staticDocParts/_xls.png rename to Classes/PhpWord/_staticDocParts/_xls.png diff --git a/Classes/PHPWord/_staticDocParts/fontTable.xml b/Classes/PhpWord/_staticDocParts/fontTable.xml similarity index 100% rename from Classes/PHPWord/_staticDocParts/fontTable.xml rename to Classes/PhpWord/_staticDocParts/fontTable.xml diff --git a/Classes/PHPWord/_staticDocParts/numbering.xml b/Classes/PhpWord/_staticDocParts/numbering.xml similarity index 100% rename from Classes/PHPWord/_staticDocParts/numbering.xml rename to Classes/PhpWord/_staticDocParts/numbering.xml diff --git a/Classes/PHPWord/_staticDocParts/settings.xml b/Classes/PhpWord/_staticDocParts/settings.xml similarity index 100% rename from Classes/PHPWord/_staticDocParts/settings.xml rename to Classes/PhpWord/_staticDocParts/settings.xml diff --git a/Classes/PHPWord/_staticDocParts/theme1.xml b/Classes/PhpWord/_staticDocParts/theme1.xml similarity index 100% rename from Classes/PHPWord/_staticDocParts/theme1.xml rename to Classes/PhpWord/_staticDocParts/theme1.xml diff --git a/Classes/PHPWord/_staticDocParts/webSettings.xml b/Classes/PhpWord/_staticDocParts/webSettings.xml similarity index 100% rename from Classes/PHPWord/_staticDocParts/webSettings.xml rename to Classes/PhpWord/_staticDocParts/webSettings.xml diff --git a/Tests/PHPWord/AutoloaderTest.php b/Tests/PhpWord/AutoloaderTest.php similarity index 100% rename from Tests/PHPWord/AutoloaderTest.php rename to Tests/PhpWord/AutoloaderTest.php diff --git a/Tests/PHPWord/DocumentPropertiesTest.php b/Tests/PhpWord/DocumentPropertiesTest.php similarity index 100% rename from Tests/PHPWord/DocumentPropertiesTest.php rename to Tests/PhpWord/DocumentPropertiesTest.php diff --git a/Tests/PHPWord/Exceptions/ExceptionTest.php b/Tests/PhpWord/Exceptions/ExceptionTest.php similarity index 100% rename from Tests/PHPWord/Exceptions/ExceptionTest.php rename to Tests/PhpWord/Exceptions/ExceptionTest.php diff --git a/Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php b/Tests/PhpWord/Exceptions/InvalidImageExceptionTest.php similarity index 100% rename from Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php rename to Tests/PhpWord/Exceptions/InvalidImageExceptionTest.php diff --git a/Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php b/Tests/PhpWord/Exceptions/InvalidStyleExceptionTest.php similarity index 100% rename from Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php rename to Tests/PhpWord/Exceptions/InvalidStyleExceptionTest.php diff --git a/Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php b/Tests/PhpWord/Exceptions/UnsupportedImageTypeExceptionTest.php similarity index 100% rename from Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php rename to Tests/PhpWord/Exceptions/UnsupportedImageTypeExceptionTest.php diff --git a/Tests/PHPWord/IOFactoryTest.php b/Tests/PhpWord/IOFactoryTest.php similarity index 100% rename from Tests/PHPWord/IOFactoryTest.php rename to Tests/PhpWord/IOFactoryTest.php diff --git a/Tests/PHPWord/MediaTest.php b/Tests/PhpWord/MediaTest.php similarity index 100% rename from Tests/PHPWord/MediaTest.php rename to Tests/PhpWord/MediaTest.php diff --git a/Tests/PHPWord/Reader/Word2007Test.php b/Tests/PhpWord/Reader/Word2007Test.php similarity index 100% rename from Tests/PHPWord/Reader/Word2007Test.php rename to Tests/PhpWord/Reader/Word2007Test.php diff --git a/Tests/PHPWord/Section/Footer/PreserveTextTest.php b/Tests/PhpWord/Section/Footer/PreserveTextTest.php similarity index 100% rename from Tests/PHPWord/Section/Footer/PreserveTextTest.php rename to Tests/PhpWord/Section/Footer/PreserveTextTest.php diff --git a/Tests/PHPWord/Section/FooterTest.php b/Tests/PhpWord/Section/FooterTest.php similarity index 100% rename from Tests/PHPWord/Section/FooterTest.php rename to Tests/PhpWord/Section/FooterTest.php diff --git a/Tests/PHPWord/Section/FootnoteTest.php b/Tests/PhpWord/Section/FootnoteTest.php similarity index 100% rename from Tests/PHPWord/Section/FootnoteTest.php rename to Tests/PhpWord/Section/FootnoteTest.php diff --git a/Tests/PHPWord/Section/HeaderTest.php b/Tests/PhpWord/Section/HeaderTest.php similarity index 100% rename from Tests/PHPWord/Section/HeaderTest.php rename to Tests/PhpWord/Section/HeaderTest.php diff --git a/Tests/PHPWord/Section/ImageTest.php b/Tests/PhpWord/Section/ImageTest.php similarity index 100% rename from Tests/PHPWord/Section/ImageTest.php rename to Tests/PhpWord/Section/ImageTest.php diff --git a/Tests/PHPWord/Section/LinkTest.php b/Tests/PhpWord/Section/LinkTest.php similarity index 100% rename from Tests/PHPWord/Section/LinkTest.php rename to Tests/PhpWord/Section/LinkTest.php diff --git a/Tests/PHPWord/Section/ListItemTest.php b/Tests/PhpWord/Section/ListItemTest.php similarity index 100% rename from Tests/PHPWord/Section/ListItemTest.php rename to Tests/PhpWord/Section/ListItemTest.php diff --git a/Tests/PHPWord/Section/MemoryImageTest.php b/Tests/PhpWord/Section/MemoryImageTest.php similarity index 100% rename from Tests/PHPWord/Section/MemoryImageTest.php rename to Tests/PhpWord/Section/MemoryImageTest.php diff --git a/Tests/PHPWord/Section/ObjectTest.php b/Tests/PhpWord/Section/ObjectTest.php similarity index 100% rename from Tests/PHPWord/Section/ObjectTest.php rename to Tests/PhpWord/Section/ObjectTest.php diff --git a/Tests/PHPWord/Section/PageBreakTest.php b/Tests/PhpWord/Section/PageBreakTest.php similarity index 100% rename from Tests/PHPWord/Section/PageBreakTest.php rename to Tests/PhpWord/Section/PageBreakTest.php diff --git a/Tests/PHPWord/Section/SettingsTest.php b/Tests/PhpWord/Section/SettingsTest.php similarity index 100% rename from Tests/PHPWord/Section/SettingsTest.php rename to Tests/PhpWord/Section/SettingsTest.php diff --git a/Tests/PHPWord/Section/Table/CellTest.php b/Tests/PhpWord/Section/Table/CellTest.php similarity index 100% rename from Tests/PHPWord/Section/Table/CellTest.php rename to Tests/PhpWord/Section/Table/CellTest.php diff --git a/Tests/PHPWord/Section/Table/RowTest.php b/Tests/PhpWord/Section/Table/RowTest.php similarity index 100% rename from Tests/PHPWord/Section/Table/RowTest.php rename to Tests/PhpWord/Section/Table/RowTest.php diff --git a/Tests/PHPWord/Section/TableTest.php b/Tests/PhpWord/Section/TableTest.php similarity index 100% rename from Tests/PHPWord/Section/TableTest.php rename to Tests/PhpWord/Section/TableTest.php diff --git a/Tests/PHPWord/Section/TextBreakTest.php b/Tests/PhpWord/Section/TextBreakTest.php similarity index 100% rename from Tests/PHPWord/Section/TextBreakTest.php rename to Tests/PhpWord/Section/TextBreakTest.php diff --git a/Tests/PHPWord/Section/TextRunTest.php b/Tests/PhpWord/Section/TextRunTest.php similarity index 100% rename from Tests/PHPWord/Section/TextRunTest.php rename to Tests/PhpWord/Section/TextRunTest.php diff --git a/Tests/PHPWord/Section/TextTest.php b/Tests/PhpWord/Section/TextTest.php similarity index 100% rename from Tests/PHPWord/Section/TextTest.php rename to Tests/PhpWord/Section/TextTest.php diff --git a/Tests/PHPWord/Section/TitleTest.php b/Tests/PhpWord/Section/TitleTest.php similarity index 100% rename from Tests/PHPWord/Section/TitleTest.php rename to Tests/PhpWord/Section/TitleTest.php diff --git a/Tests/PHPWord/SectionTest.php b/Tests/PhpWord/SectionTest.php similarity index 100% rename from Tests/PHPWord/SectionTest.php rename to Tests/PhpWord/SectionTest.php diff --git a/Tests/PHPWord/SettingsTest.php b/Tests/PhpWord/SettingsTest.php similarity index 100% rename from Tests/PHPWord/SettingsTest.php rename to Tests/PhpWord/SettingsTest.php diff --git a/Tests/PHPWord/Shared/DrawingTest.php b/Tests/PhpWord/Shared/DrawingTest.php similarity index 100% rename from Tests/PHPWord/Shared/DrawingTest.php rename to Tests/PhpWord/Shared/DrawingTest.php diff --git a/Tests/PHPWord/Shared/FileTest.php b/Tests/PhpWord/Shared/FileTest.php similarity index 100% rename from Tests/PHPWord/Shared/FileTest.php rename to Tests/PhpWord/Shared/FileTest.php diff --git a/Tests/PHPWord/Shared/FontTest.php b/Tests/PhpWord/Shared/FontTest.php similarity index 100% rename from Tests/PHPWord/Shared/FontTest.php rename to Tests/PhpWord/Shared/FontTest.php diff --git a/Tests/PHPWord/Shared/StringTest.php b/Tests/PhpWord/Shared/StringTest.php similarity index 100% rename from Tests/PHPWord/Shared/StringTest.php rename to Tests/PhpWord/Shared/StringTest.php diff --git a/Tests/PHPWord/Style/CellTest.php b/Tests/PhpWord/Style/CellTest.php similarity index 100% rename from Tests/PHPWord/Style/CellTest.php rename to Tests/PhpWord/Style/CellTest.php diff --git a/Tests/PHPWord/Style/FontTest.php b/Tests/PhpWord/Style/FontTest.php similarity index 100% rename from Tests/PHPWord/Style/FontTest.php rename to Tests/PhpWord/Style/FontTest.php diff --git a/Tests/PHPWord/Style/ImageTest.php b/Tests/PhpWord/Style/ImageTest.php similarity index 100% rename from Tests/PHPWord/Style/ImageTest.php rename to Tests/PhpWord/Style/ImageTest.php diff --git a/Tests/PHPWord/Style/ListItemTest.php b/Tests/PhpWord/Style/ListItemTest.php similarity index 100% rename from Tests/PHPWord/Style/ListItemTest.php rename to Tests/PhpWord/Style/ListItemTest.php diff --git a/Tests/PHPWord/Style/ParagraphTest.php b/Tests/PhpWord/Style/ParagraphTest.php similarity index 100% rename from Tests/PHPWord/Style/ParagraphTest.php rename to Tests/PhpWord/Style/ParagraphTest.php diff --git a/Tests/PHPWord/Style/RowTest.php b/Tests/PhpWord/Style/RowTest.php similarity index 100% rename from Tests/PHPWord/Style/RowTest.php rename to Tests/PhpWord/Style/RowTest.php diff --git a/Tests/PHPWord/Style/TOCTest.php b/Tests/PhpWord/Style/TOCTest.php similarity index 100% rename from Tests/PHPWord/Style/TOCTest.php rename to Tests/PhpWord/Style/TOCTest.php diff --git a/Tests/PHPWord/Style/TableFullTest.php b/Tests/PhpWord/Style/TableFullTest.php similarity index 100% rename from Tests/PHPWord/Style/TableFullTest.php rename to Tests/PhpWord/Style/TableFullTest.php diff --git a/Tests/PHPWord/Style/TableTest.php b/Tests/PhpWord/Style/TableTest.php similarity index 100% rename from Tests/PHPWord/Style/TableTest.php rename to Tests/PhpWord/Style/TableTest.php diff --git a/Tests/PHPWord/Style/TabsTest.php b/Tests/PhpWord/Style/TabsTest.php similarity index 100% rename from Tests/PHPWord/Style/TabsTest.php rename to Tests/PhpWord/Style/TabsTest.php diff --git a/Tests/PHPWord/StyleTest.php b/Tests/PhpWord/StyleTest.php similarity index 100% rename from Tests/PHPWord/StyleTest.php rename to Tests/PhpWord/StyleTest.php diff --git a/Tests/PHPWord/TOCTest.php b/Tests/PhpWord/TOCTest.php similarity index 100% rename from Tests/PHPWord/TOCTest.php rename to Tests/PhpWord/TOCTest.php diff --git a/Tests/PHPWord/TemplateTest.php b/Tests/PhpWord/TemplateTest.php similarity index 100% rename from Tests/PHPWord/TemplateTest.php rename to Tests/PhpWord/TemplateTest.php diff --git a/Tests/PHPWord/Writer/ODText/ContentTest.php b/Tests/PhpWord/Writer/ODText/ContentTest.php similarity index 100% rename from Tests/PHPWord/Writer/ODText/ContentTest.php rename to Tests/PhpWord/Writer/ODText/ContentTest.php diff --git a/Tests/PHPWord/Writer/ODTextTest.php b/Tests/PhpWord/Writer/ODTextTest.php similarity index 100% rename from Tests/PHPWord/Writer/ODTextTest.php rename to Tests/PhpWord/Writer/ODTextTest.php diff --git a/Tests/PHPWord/Writer/RTFTest.php b/Tests/PhpWord/Writer/RTFTest.php similarity index 100% rename from Tests/PHPWord/Writer/RTFTest.php rename to Tests/PhpWord/Writer/RTFTest.php diff --git a/Tests/PHPWord/Writer/Word2007/BaseTest.php b/Tests/PhpWord/Writer/Word2007/BaseTest.php similarity index 100% rename from Tests/PHPWord/Writer/Word2007/BaseTest.php rename to Tests/PhpWord/Writer/Word2007/BaseTest.php diff --git a/Tests/PHPWord/Writer/Word2007/DocumentTest.php b/Tests/PhpWord/Writer/Word2007/DocumentTest.php similarity index 100% rename from Tests/PHPWord/Writer/Word2007/DocumentTest.php rename to Tests/PhpWord/Writer/Word2007/DocumentTest.php diff --git a/Tests/PHPWord/Writer/Word2007/FootnotesTest.php b/Tests/PhpWord/Writer/Word2007/FootnotesTest.php similarity index 100% rename from Tests/PHPWord/Writer/Word2007/FootnotesTest.php rename to Tests/PhpWord/Writer/Word2007/FootnotesTest.php diff --git a/Tests/PHPWord/Writer/Word2007/StylesTest.php b/Tests/PhpWord/Writer/Word2007/StylesTest.php similarity index 100% rename from Tests/PHPWord/Writer/Word2007/StylesTest.php rename to Tests/PhpWord/Writer/Word2007/StylesTest.php diff --git a/Tests/PHPWord/Writer/Word2007Test.php b/Tests/PhpWord/Writer/Word2007Test.php similarity index 100% rename from Tests/PHPWord/Writer/Word2007Test.php rename to Tests/PhpWord/Writer/Word2007Test.php diff --git a/Tests/PHPWordTest.php b/Tests/PhpWordTest.php similarity index 100% rename from Tests/PHPWordTest.php rename to Tests/PhpWordTest.php diff --git a/Tests/_files/images/PHPWord.png b/Tests/_files/images/PhpWord.png similarity index 100% rename from Tests/_files/images/PHPWord.png rename to Tests/_files/images/PhpWord.png From ab96c75b08c010dd6e824da1e3b9180257b55af5 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 22 Mar 2014 10:06:08 +0400 Subject: [PATCH 09/15] https://github.com/PHPOffice/PHPWord/issues/58 - Part VIII (Autoloader). --- README.md | 2 +- Tests/PhpWord/AutoloaderTest.php | 41 +- Tests/PhpWord/IOFactoryTest.php | 2 +- Tests/PhpWord/MediaTest.php | 12 +- Tests/PhpWord/Reader/Word2007Test.php | 8 +- Tests/PhpWord/Section/FooterTest.php | 2 +- Tests/PhpWord/Section/HeaderTest.php | 4 +- Tests/PhpWord/Section/ImageTest.php | 26 +- Tests/PhpWord/Section/MemoryImageTest.php | 12 +- Tests/PhpWord/Section/ObjectTest.php | 12 +- Tests/PhpWord/Section/Table/CellTest.php | 8 +- Tests/PhpWord/Section/TextRunTest.php | 2 +- Tests/PhpWord/SectionTest.php | 4 +- Tests/PhpWord/Shared/FileTest.php | 6 +- Tests/PhpWord/Shared/FontTest.php | 2 +- Tests/PhpWord/Style/FontTest.php | 2 +- Tests/PhpWord/Style/ParagraphTest.php | 2 +- Tests/PhpWord/Style/TabsTest.php | 2 +- Tests/PhpWord/TemplateTest.php | 18 +- Tests/PhpWord/Writer/ODText/ContentTest.php | 6 +- Tests/PhpWord/Writer/ODTextTest.php | 16 +- Tests/PhpWord/Writer/RTFTest.php | 10 +- Tests/PhpWord/Writer/Word2007/BaseTest.php | 8 +- .../PhpWord/Writer/Word2007/DocumentTest.php | 4 +- .../PhpWord/Writer/Word2007/FootnotesTest.php | 2 +- Tests/PhpWord/Writer/Word2007/StylesTest.php | 2 +- Tests/PhpWord/Writer/Word2007Test.php | 12 +- Tests/PhpWordTest.php | 6 +- Tests/_inc/TestHelperDOCX.php | 2 +- Tests/bootstrap.php | 17 +- changelog.txt | 2 +- composer.json | 4 +- phpunit.xml.dist | 6 +- samples/Sample_01_SimpleText.php | 2 +- samples/Sample_02_TabStops.php | 2 +- samples/Sample_03_Sections.php | 2 +- samples/Sample_04_Textrun.php | 2 +- samples/Sample_05_Multicolumn.php | 2 +- samples/Sample_06_Footnote.php | 2 +- samples/Sample_07_TemplateCloneRow.php | 2 +- samples/Sample_08_ParagraphPagination.php | 2 +- samples/Sample_09_Tables.php | 2 +- samples/Sample_10_EastAsianFontStyle.php | 2 +- samples/Sample_11_ReadWord2007.php | 2 +- samples/Sample_12_HeaderFooter.php | 2 +- samples/Sample_13_Images.php | 2 +- samples/Sample_14_ListItem.php | 2 +- samples/Sample_15_Link.php | 2 +- samples/Sample_16_Object.php | 2 +- samples/Sample_17_TitleTOC.php | 2 +- samples/Sample_18_Watermark.php | 2 +- samples/Sample_19_TextBreak.php | 2 +- src/Autoloader.php | 64 ++ src/DocumentProperties.php | 606 ++++++++++ src/Exceptions/Exception.php | 6 + src/Exceptions/InvalidImageException.php | 13 + src/Exceptions/InvalidStyleException.php | 15 + .../UnsupportedImageTypeException.php | 13 + src/Footnote.php | 124 ++ src/HashTable.php | 209 ++++ src/IOFactory.php | 80 ++ src/Media.php | 347 ++++++ src/PhpWord.php | 233 ++++ src/Reader/AbstractReader.php | 110 ++ src/Reader/IReader.php | 46 + src/Reader/Word2007.php | 452 ++++++++ src/Section.php | 453 ++++++++ src/Section/Footer.php | 217 ++++ src/Section/Footer/PreserveText.php | 130 +++ src/Section/Footnote.php | 151 +++ src/Section/Header.php | 299 +++++ src/Section/Image.php | 177 +++ src/Section/Link.php | 174 +++ src/Section/ListItem.php | 101 ++ src/Section/MemoryImage.php | 233 ++++ src/Section/Object.php | 179 +++ src/Section/PageBreak.php | 38 + src/Section/Settings.php | 728 ++++++++++++ src/Section/Table.php | 163 +++ src/Section/Table/Cell.php | 350 ++++++ src/Section/Table/Row.php | 139 +++ src/Section/Text.php | 154 +++ src/Section/TextBreak.php | 122 ++ src/Section/TextRun.php | 184 +++ src/Section/Title.php | 145 +++ src/Settings.php | 63 ++ src/Shared/Drawing.php | 162 +++ src/Shared/File.php | 76 ++ src/Shared/Font.php | 90 ++ src/Shared/String.php | 109 ++ src/Shared/XMLWriter.php | 155 +++ src/Shared/ZipStreamWrapper.php | 183 +++ src/Style.php | 161 +++ src/Style/Cell.php | 343 ++++++ src/Style/Font.php | 544 +++++++++ src/Style/Image.php | 175 +++ src/Style/ListItem.php | 80 ++ src/Style/Paragraph.php | 508 +++++++++ src/Style/Row.php | 88 ++ src/Style/TOC.php | 139 +++ src/Style/Tab.php | 146 +++ src/Style/Table.php | 94 ++ src/Style/TableFull.php | 443 ++++++++ src/Style/Tabs.php | 63 ++ src/TOC.php | 155 +++ src/Template.php | 292 +++++ src/Writer/IWriter.php | 39 + src/Writer/ODText.php | 282 +++++ src/Writer/ODText/Content.php | 412 +++++++ src/Writer/ODText/Manifest.php | 132 +++ src/Writer/ODText/Meta.php | 96 ++ src/Writer/ODText/Mimetype.php | 46 + src/Writer/ODText/Styles.php | 273 +++++ src/Writer/ODText/WriterPart.php | 66 ++ src/Writer/RTF.php | 482 ++++++++ src/Writer/Word2007.php | 301 +++++ src/Writer/Word2007/Base.php | 1003 +++++++++++++++++ src/Writer/Word2007/ContentTypes.php | 228 ++++ src/Writer/Word2007/DocProps.php | 186 +++ src/Writer/Word2007/Document.php | 506 +++++++++ src/Writer/Word2007/DocumentRels.php | 182 +++ src/Writer/Word2007/Footer.php | 90 ++ src/Writer/Word2007/Footnotes.php | 87 ++ src/Writer/Word2007/FootnotesRels.php | 89 ++ src/Writer/Word2007/Header.php | 94 ++ src/Writer/Word2007/Rels.php | 115 ++ src/Writer/Word2007/Styles.php | 399 +++++++ src/Writer/Word2007/WriterPart.php | 49 + src/_staticDocParts/_doc.png | Bin 0 -> 1157 bytes src/_staticDocParts/_ppt.png | Bin 0 -> 1886 bytes src/_staticDocParts/_xls.png | Bin 0 -> 1924 bytes src/_staticDocParts/fontTable.xml | 2 + src/_staticDocParts/numbering.xml | 2 + src/_staticDocParts/settings.xml | 48 + src/_staticDocParts/theme1.xml | 2 + src/_staticDocParts/webSettings.xml | 2 + 136 files changed, 15881 insertions(+), 158 deletions(-) create mode 100644 src/Autoloader.php create mode 100644 src/DocumentProperties.php create mode 100644 src/Exceptions/Exception.php create mode 100644 src/Exceptions/InvalidImageException.php create mode 100644 src/Exceptions/InvalidStyleException.php create mode 100644 src/Exceptions/UnsupportedImageTypeException.php create mode 100644 src/Footnote.php create mode 100644 src/HashTable.php create mode 100644 src/IOFactory.php create mode 100644 src/Media.php create mode 100644 src/PhpWord.php create mode 100644 src/Reader/AbstractReader.php create mode 100644 src/Reader/IReader.php create mode 100644 src/Reader/Word2007.php create mode 100644 src/Section.php create mode 100644 src/Section/Footer.php create mode 100644 src/Section/Footer/PreserveText.php create mode 100644 src/Section/Footnote.php create mode 100644 src/Section/Header.php create mode 100644 src/Section/Image.php create mode 100644 src/Section/Link.php create mode 100644 src/Section/ListItem.php create mode 100644 src/Section/MemoryImage.php create mode 100644 src/Section/Object.php create mode 100644 src/Section/PageBreak.php create mode 100644 src/Section/Settings.php create mode 100644 src/Section/Table.php create mode 100644 src/Section/Table/Cell.php create mode 100644 src/Section/Table/Row.php create mode 100644 src/Section/Text.php create mode 100644 src/Section/TextBreak.php create mode 100644 src/Section/TextRun.php create mode 100644 src/Section/Title.php create mode 100644 src/Settings.php create mode 100644 src/Shared/Drawing.php create mode 100644 src/Shared/File.php create mode 100644 src/Shared/Font.php create mode 100644 src/Shared/String.php create mode 100644 src/Shared/XMLWriter.php create mode 100644 src/Shared/ZipStreamWrapper.php create mode 100644 src/Style.php create mode 100644 src/Style/Cell.php create mode 100644 src/Style/Font.php create mode 100644 src/Style/Image.php create mode 100644 src/Style/ListItem.php create mode 100644 src/Style/Paragraph.php create mode 100644 src/Style/Row.php create mode 100644 src/Style/TOC.php create mode 100644 src/Style/Tab.php create mode 100644 src/Style/Table.php create mode 100644 src/Style/TableFull.php create mode 100644 src/Style/Tabs.php create mode 100644 src/TOC.php create mode 100644 src/Template.php create mode 100644 src/Writer/IWriter.php create mode 100644 src/Writer/ODText.php create mode 100644 src/Writer/ODText/Content.php create mode 100644 src/Writer/ODText/Manifest.php create mode 100644 src/Writer/ODText/Meta.php create mode 100644 src/Writer/ODText/Mimetype.php create mode 100644 src/Writer/ODText/Styles.php create mode 100644 src/Writer/ODText/WriterPart.php create mode 100644 src/Writer/RTF.php create mode 100644 src/Writer/Word2007.php create mode 100644 src/Writer/Word2007/Base.php create mode 100644 src/Writer/Word2007/ContentTypes.php create mode 100644 src/Writer/Word2007/DocProps.php create mode 100644 src/Writer/Word2007/Document.php create mode 100644 src/Writer/Word2007/DocumentRels.php create mode 100644 src/Writer/Word2007/Footer.php create mode 100644 src/Writer/Word2007/Footnotes.php create mode 100644 src/Writer/Word2007/FootnotesRels.php create mode 100644 src/Writer/Word2007/Header.php create mode 100644 src/Writer/Word2007/Rels.php create mode 100644 src/Writer/Word2007/Styles.php create mode 100644 src/Writer/Word2007/WriterPart.php create mode 100644 src/_staticDocParts/_doc.png create mode 100644 src/_staticDocParts/_ppt.png create mode 100644 src/_staticDocParts/_xls.png create mode 100644 src/_staticDocParts/fontTable.xml create mode 100644 src/_staticDocParts/numbering.xml create mode 100644 src/_staticDocParts/settings.xml create mode 100644 src/_staticDocParts/theme1.xml create mode 100644 src/_staticDocParts/webSettings.xml diff --git a/README.md b/README.md index b46cd0f098..e401de24f1 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PhpWord -[![Build Status](https://travis-ci.org/PHPOffice/PhpWord.png?branch=master)](https://travis-ci.org/PHPOffice/PhpWord) +[![Build Status](https://travis-ci.org/PhpOffice/PhpWord.png?branch=master)](https://travis-ci.org/PhpOffice/PhpWord) [![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword) [![Total Downloads](https://poser.pugx.org/phpoffice/phpword/downloads.png)](https://packagist.org/packages/phpoffice/phpword) [![Latest Unstable Version](https://poser.pugx.org/phpoffice/phpword/v/unstable.png)](https://packagist.org/packages/phpoffice/phpword) [![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword) __OpenXML - Read, Write and Create Word documents in PHP.__ diff --git a/Tests/PhpWord/AutoloaderTest.php b/Tests/PhpWord/AutoloaderTest.php index cc244688df..8c3d50f9eb 100644 --- a/Tests/PhpWord/AutoloaderTest.php +++ b/Tests/PhpWord/AutoloaderTest.php @@ -1,49 +1,36 @@ assertContains(array('PHPWord_Autoloader', 'load'), spl_autoload_functions()); - $this->assertContains(array('PHPWord_Autoloader', 'autoload'), spl_autoload_functions()); - } - - public function testAutoloadLegacy() - { - $this->assertNull( - PHPWord_Autoloader::load('Foo'), - 'PHPWord_Autoloader::load() is trying to load classes outside of the PhpWord namespace' - ); - $this->assertTrue( - PHPWord_Autoloader::load('PhpWord'), - 'PHPWord_Autoloader::load() failed to autoload the PhpWord class' + Autoloader::register(); + $this->assertContains( + array('PhpOffice\\PhpWord\\Autoloader', 'autoload'), + \spl_autoload_functions() ); } public function testAutoload() { - $declared = get_declared_classes(); - $declaredCount = count($declared); + $declared = \get_declared_classes(); + $declaredCount = \count($declared); Autoloader::autoload('Foo'); $this->assertEquals( $declaredCount, - count(get_declared_classes()), - 'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load classes ' . - 'outside of the PhpOffice\\PhpWord namespace' + \count(get_declared_classes()), + 'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load classes ' + . 'outside of the PhpOffice\\PhpWord namespace' ); // TODO change this class to the main PhpWord class when it is namespaced - Autoloader::autoload( - 'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException' - ); + Autoloader::autoload('PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException'); $this->assertTrue( - in_array('PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException', get_declared_classes()), - 'PhpOffice\\PhpWord\\Autoloader::autoload() failed to autoload the ' . - 'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException class' + \in_array('PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException', \get_declared_classes()), + 'PhpOffice\\PhpWord\\Autoloader::autoload() failed to autoload the ' + . 'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException class' ); } } \ No newline at end of file diff --git a/Tests/PhpWord/IOFactoryTest.php b/Tests/PhpWord/IOFactoryTest.php index c5d5aa75b5..d10bcfebe0 100644 --- a/Tests/PhpWord/IOFactoryTest.php +++ b/Tests/PhpWord/IOFactoryTest.php @@ -1,7 +1,7 @@ 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"); + $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/_files/images/mars_noext_jpg"); + $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/_files/images/mars.jpg"); + $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/_files/images/mario.gif"); + $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/_files/images/firefox.png"); + $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/_files/images/duke_nukem.bmp"); + $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/_files/images/angela_merkel.tif"); $elements = $section->getElements(); $this->assertEquals(6, count($elements)); diff --git a/Tests/PhpWord/Reader/Word2007Test.php b/Tests/PhpWord/Reader/Word2007Test.php index 53d10d0dd0..40219d340b 100644 --- a/Tests/PhpWord/Reader/Word2007Test.php +++ b/Tests/PhpWord/Reader/Word2007Test.php @@ -26,7 +26,7 @@ public function testCanRead() { $dir = join( DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents') ); $object = new Word2007; $file = $dir . DIRECTORY_SEPARATOR . 'reader.docx'; @@ -42,7 +42,7 @@ public function testCanReadFailed() { $dir = join( DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents') ); $object = new Word2007; $file = $dir . DIRECTORY_SEPARATOR . 'foo.docx'; @@ -57,10 +57,10 @@ public function testLoad() { $dir = join( DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents') ); $file = $dir . DIRECTORY_SEPARATOR . 'reader.docx'; $object = IOFactory::load($file); - $this->assertInstanceOf('PhpOffice\\PhpWord', $object); + $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object); } } \ No newline at end of file diff --git a/Tests/PhpWord/Section/FooterTest.php b/Tests/PhpWord/Section/FooterTest.php index 0052a6519f..9b6682e824 100644 --- a/Tests/PhpWord/Section/FooterTest.php +++ b/Tests/PhpWord/Section/FooterTest.php @@ -74,7 +74,7 @@ public function testAddImage() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $oFooter = new Footer(1); $element = $oFooter->addImage($src); diff --git a/Tests/PhpWord/Section/HeaderTest.php b/Tests/PhpWord/Section/HeaderTest.php index ee5a451252..270fd71cea 100644 --- a/Tests/PhpWord/Section/HeaderTest.php +++ b/Tests/PhpWord/Section/HeaderTest.php @@ -70,7 +70,7 @@ public function testAddImage() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $oHeader = new Header(1); $element = $oHeader->addImage($src); @@ -113,7 +113,7 @@ public function testAddWatermark() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $oHeader = new Header(1); $element = $oHeader->addWatermark($src); diff --git a/Tests/PhpWord/Section/ImageTest.php b/Tests/PhpWord/Section/ImageTest.php index 931dc8128b..4067f2183a 100644 --- a/Tests/PhpWord/Section/ImageTest.php +++ b/Tests/PhpWord/Section/ImageTest.php @@ -12,7 +12,7 @@ public function testConstruct() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'firefox.png') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'firefox.png') ); $oImage = new Image($src); @@ -27,7 +27,7 @@ public function testConstructWithStyle() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'firefox.png') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'firefox.png') ); $oImage = new Image( $src, @@ -43,12 +43,12 @@ public function testConstructWithStyle() */ public function testValidImageTypes() { - new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg"); - new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg"); - new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif"); - new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png"); - new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp"); - new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif"); + new Image(\PHPWORD_TESTS_BASE_DIR . "/_files/images/mars_noext_jpg"); + new Image(\PHPWORD_TESTS_BASE_DIR . "/_files/images/mars.jpg"); + new Image(\PHPWORD_TESTS_BASE_DIR . "/_files/images/mario.gif"); + new Image(\PHPWORD_TESTS_BASE_DIR . "/_files/images/firefox.png"); + new Image(\PHPWORD_TESTS_BASE_DIR . "/_files/images/duke_nukem.bmp"); + new Image(\PHPWORD_TESTS_BASE_DIR . "/_files/images/angela_merkel.tif"); } /** @@ -57,7 +57,7 @@ public function testValidImageTypes() */ public function testImageNotFound() { - new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/thisisnotarealimage"); + new Image(\PHPWORD_TESTS_BASE_DIR . "/_files/images/thisisnotarealimage"); } /** @@ -66,14 +66,14 @@ public function testImageNotFound() */ public function testInvalidImageTypes() { - new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/alexz-johnson.pcx"); + new Image(\PHPWORD_TESTS_BASE_DIR . "/_files/images/alexz-johnson.pcx"); } public function testStyle() { $oImage = new Image(\join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ), array('width' => 210, 'height' => 210, 'align' => 'center')); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle()); @@ -83,7 +83,7 @@ public function testRelationID() { $oImage = new Image(\join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') )); $iVal = rand(1, 1000); @@ -95,7 +95,7 @@ public function testWatermark() { $oImage = new Image(\join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') )); $oImage->setIsWatermark(true); diff --git a/Tests/PhpWord/Section/MemoryImageTest.php b/Tests/PhpWord/Section/MemoryImageTest.php index 8c28e0bf99..4476baddc6 100644 --- a/Tests/PhpWord/Section/MemoryImageTest.php +++ b/Tests/PhpWord/Section/MemoryImageTest.php @@ -9,7 +9,7 @@ public function testPNG() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'firefox.png') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'firefox.png') ); $oMemoryImage = new MemoryImage($src); @@ -26,7 +26,7 @@ public function testGIF() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'mario.gif') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'mario.gif') ); $oMemoryImage = new MemoryImage($src); @@ -43,7 +43,7 @@ public function testJPG() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $oMemoryImage = new MemoryImage($src); @@ -60,7 +60,7 @@ public function testBMP() { $oMemoryImage = new MemoryImage(\join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'duke_nukem.bmp') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'duke_nukem.bmp') )); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage); @@ -74,7 +74,7 @@ public function testStyle() { $oMemoryImage = new MemoryImage(\join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ), array('width' => 210, 'height' => 210, 'align' => 'center')); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oMemoryImage->getStyle()); @@ -84,7 +84,7 @@ public function testRelationID() { $oMemoryImage = new MemoryImage(\join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') )); $iVal = rand(1, 1000); diff --git a/Tests/PhpWord/Section/ObjectTest.php b/Tests/PhpWord/Section/ObjectTest.php index 467b76c90f..cae33458ea 100644 --- a/Tests/PhpWord/Section/ObjectTest.php +++ b/Tests/PhpWord/Section/ObjectTest.php @@ -9,7 +9,7 @@ public function testConstructWithSupportedFiles() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $oObject = new Object($src); @@ -22,7 +22,7 @@ public function testConstructWithNotSupportedFiles() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'xsl', 'passthrough.xsl') ); $oObject = new Object($src); @@ -35,7 +35,7 @@ public function testConstructWithSupportedFilesAndStyle() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $oObject = new Object($src, array('width' => '230px')); @@ -48,7 +48,7 @@ public function testRelationId() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $oObject = new Object($src); @@ -61,7 +61,7 @@ public function testImageRelationId() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $oObject = new Object($src); @@ -74,7 +74,7 @@ public function testObjectId() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $oObject = new Object($src); diff --git a/Tests/PhpWord/Section/Table/CellTest.php b/Tests/PhpWord/Section/Table/CellTest.php index b2e3937d10..a328a2a8e1 100644 --- a/Tests/PhpWord/Section/Table/CellTest.php +++ b/Tests/PhpWord/Section/Table/CellTest.php @@ -91,7 +91,7 @@ public function testAddImageSection() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $oCell = new Cell('section', 1); $element = $oCell->addImage($src); @@ -104,7 +104,7 @@ public function testAddImageHeader() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $oCell = new Cell('header', 1); $element = $oCell->addImage($src); @@ -117,7 +117,7 @@ public function testAddImageFooter() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $oCell = new Cell('footer', 1); $element = $oCell->addImage($src); @@ -163,7 +163,7 @@ public function testAddObjectXLS() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $oCell = new Cell('section', 1); $element = $oCell->addObject($src); diff --git a/Tests/PhpWord/Section/TextRunTest.php b/Tests/PhpWord/Section/TextRunTest.php index adf1ffbeb4..a5579cded3 100644 --- a/Tests/PhpWord/Section/TextRunTest.php +++ b/Tests/PhpWord/Section/TextRunTest.php @@ -77,7 +77,7 @@ public function testAddImage() { $src = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $oTextRun = new TextRun(); $element = $oTextRun->addImage($src); diff --git a/Tests/PhpWord/SectionTest.php b/Tests/PhpWord/SectionTest.php index 7982d4af02..dc90f808ab 100644 --- a/Tests/PhpWord/SectionTest.php +++ b/Tests/PhpWord/SectionTest.php @@ -76,11 +76,11 @@ public function testAddElements() { $objectSource = join( DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $imageSource = join( DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PhpWord.png') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'PhpWord.png') ); $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif'; diff --git a/Tests/PhpWord/Shared/FileTest.php b/Tests/PhpWord/Shared/FileTest.php index b02cb918d8..197a318e91 100644 --- a/Tests/PhpWord/Shared/FileTest.php +++ b/Tests/PhpWord/Shared/FileTest.php @@ -15,7 +15,7 @@ class FileTest extends \PHPUnit_Framework_TestCase */ public function testFileExists() { - $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates')); + $dir = join(DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates')); chdir($dir); $this->assertTrue(File::file_exists('blank.docx')); } @@ -24,7 +24,7 @@ public function testFileExists() */ public function testNoFileExists() { - $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates')); + $dir = join(DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates')); chdir($dir); $this->assertFalse(File::file_exists('404.docx')); } @@ -34,7 +34,7 @@ public function testNoFileExists() */ public function testRealpath() { - $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates')); + $dir = join(DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates')); chdir($dir); $file = 'blank.docx'; $expected = $dir . DIRECTORY_SEPARATOR . $file; diff --git a/Tests/PhpWord/Shared/FontTest.php b/Tests/PhpWord/Shared/FontTest.php index f437990094..0a662a3f8c 100644 --- a/Tests/PhpWord/Shared/FontTest.php +++ b/Tests/PhpWord/Shared/FontTest.php @@ -1,7 +1,7 @@ load( \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'remove_tables_by_needle.xsl') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'xsl', 'remove_tables_by_needle.xsl') ) ); foreach (array('${employee.', '${scoreboard.') as $needle) { @@ -65,7 +65,7 @@ final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn) { $expectedDocumentFqfn = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'without_table_macros.docx') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'without_table_macros.docx') ); $actualDocumentZip = new \ZipArchive(); @@ -96,7 +96,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete $template = new Template( \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates', 'blank.docx') ) ); @@ -104,7 +104,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete $xslDOMDocument->load( \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'xsl', 'passthrough.xsl') ) ); @@ -126,7 +126,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromT $template = new Template( \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'corrupted_main_document_part.docx') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates', 'corrupted_main_document_part.docx') ) ); @@ -134,7 +134,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromT $xslDOMDocument->load( \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'xsl', 'passthrough.xsl') ) ); @@ -155,7 +155,7 @@ public function testCloneRow() { $template = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-row.docx') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates', 'clone-row.docx') ); $expectedVar = array('tableHeader', 'userId', 'userName', 'userLocation'); $docName = 'clone-test-result.docx'; diff --git a/Tests/PhpWord/Writer/ODText/ContentTest.php b/Tests/PhpWord/Writer/ODText/ContentTest.php index 7ebff7765a..ce3a7b3b90 100644 --- a/Tests/PhpWord/Writer/ODText/ContentTest.php +++ b/Tests/PhpWord/Writer/ODText/ContentTest.php @@ -1,7 +1,7 @@ assertInstanceOf('PhpOffice\\PhpWord', $object->getPhpWord()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object->getPhpWord()); $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable()); $this->assertEquals('./', $object->getDiskCachingDirectory()); @@ -52,15 +52,15 @@ public function testSave() { $imageSrc = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PhpWord.png') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'PhpWord.png') ); $objectSrc = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $file = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.odt') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'temp.odt') ); $phpWord = new PhpWord(); @@ -129,9 +129,9 @@ public function testGetWriterPartNull() public function testSetGetUseDiskCaching() { $object = new ODText(); - $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); + $object->setUseDiskCaching(true, \PHPWORD_TESTS_BASE_DIR); $this->assertTrue($object->getUseDiskCaching()); - $this->assertEquals(PHPWORD_TESTS_DIR_ROOT, $object->getDiskCachingDirectory()); + $this->assertEquals(\PHPWORD_TESTS_BASE_DIR, $object->getDiskCachingDirectory()); } /** @@ -142,7 +142,7 @@ public function testSetUseDiskCachingException() { $dir = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, 'foo') + array(\PHPWORD_TESTS_BASE_DIR, 'foo') ); $object = new ODText($phpWord); diff --git a/Tests/PhpWord/Writer/RTFTest.php b/Tests/PhpWord/Writer/RTFTest.php index ecce87323f..3b6cb723de 100644 --- a/Tests/PhpWord/Writer/RTFTest.php +++ b/Tests/PhpWord/Writer/RTFTest.php @@ -1,7 +1,7 @@ assertInstanceOf('PhpOffice\\PhpWord', $object->getPhpWord()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object->getPhpWord()); $this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable()); } @@ -65,15 +65,15 @@ public function testSave() { $imageSrc = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PhpWord.png') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'PhpWord.png') ); $objectSrc = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $file = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.rtf') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'temp.rtf') ); $phpWord = new PhpWord(); diff --git a/Tests/PhpWord/Writer/Word2007/BaseTest.php b/Tests/PhpWord/Writer/Word2007/BaseTest.php index c62ba3accb..1d00e06ebd 100644 --- a/Tests/PhpWord/Writer/Word2007/BaseTest.php +++ b/Tests/PhpWord/Writer/Word2007/BaseTest.php @@ -1,7 +1,7 @@ 'justify', 'spaceBefore' => 120, 'spaceAfter' => 120); $imageSrc = join( DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $phpWord = new PhpWord(); @@ -298,7 +298,7 @@ public function testWriteImagePosition() $phpWord = new PhpWord(); $section = $phpWord->createSection(); $section->addImage( - PHPWORD_TESTS_DIR_ROOT . '/_files/images/earth.jpg', + \PHPWORD_TESTS_BASE_DIR . '/_files/images/earth.jpg', array( 'marginTop' => -1, 'marginLeft' => -1, @@ -322,7 +322,7 @@ public function testWriteWatermark() { $imageSrc = join( DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); $phpWord = new PhpWord(); diff --git a/Tests/PhpWord/Writer/Word2007/DocumentTest.php b/Tests/PhpWord/Writer/Word2007/DocumentTest.php index da54a7f4f1..056e7b55a3 100644 --- a/Tests/PhpWord/Writer/Word2007/DocumentTest.php +++ b/Tests/PhpWord/Writer/Word2007/DocumentTest.php @@ -1,7 +1,7 @@ save($file); $this->assertTrue(file_exists($file)); @@ -90,7 +90,7 @@ public function testCheckContentTypes() $phpWord = new PhpWord(); $section = $phpWord->createSection(); foreach ($images as $source => $target) { - $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/{$source}"); + $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/_files/images/{$source}"); } $doc = TestHelperDOCX::getDocument($phpWord); @@ -98,7 +98,7 @@ public function testCheckContentTypes() foreach ($images as $source => $target) { $this->assertFileEquals( - PHPWORD_TESTS_DIR_ROOT . "/_files/images/{$source}", + \PHPWORD_TESTS_BASE_DIR . "/_files/images/{$source}", $mediaPath . "/section_image{$target}" ); } @@ -111,7 +111,7 @@ public function testCheckContentTypes() public function testSetGetUseDiskCaching() { $object = new Word2007(); - $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); + $object->setUseDiskCaching(true, \PHPWORD_TESTS_BASE_DIR); $this->assertTrue($object->getUseDiskCaching()); } @@ -124,7 +124,7 @@ public function testSetUseDiskCachingException() { $dir = \join( \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_DIR_ROOT, 'foo') + array(\PHPWORD_TESTS_BASE_DIR, 'foo') ); $object = new Word2007(); diff --git a/Tests/PhpWordTest.php b/Tests/PhpWordTest.php index ca0dded11b..73841bd7a7 100644 --- a/Tests/PhpWordTest.php +++ b/Tests/PhpWordTest.php @@ -1,7 +1,7 @@ assertInstanceOf( @@ -150,7 +150,7 @@ public function testLoadTemplateException() { $templateFqfn = \join( \DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blanks.docx') + array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates', 'blanks.docx') ); $phpWord = new PhpWord(); $phpWord->loadTemplate($templateFqfn); diff --git a/Tests/_inc/TestHelperDOCX.php b/Tests/_inc/TestHelperDOCX.php index 5345c4eb40..0e63dcf8d0 100644 --- a/Tests/_inc/TestHelperDOCX.php +++ b/Tests/_inc/TestHelperDOCX.php @@ -1,7 +1,7 @@ - + ./Tests/PhpWord/ - ./Classes + ./src - + \ No newline at end of file diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index a1aafea994..34a93ecf94 100755 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word Document echo date('H:i:s') , " Create new PhpWord object" , EOL; diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index 9d3ef32f8e..5eef59a833 100755 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index 542b2d5c73..e066097c0d 100755 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php index c7b8c354ad..c0b6cf3ad7 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php index 942d851de6..2095f24a37 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word Document echo date('H:i:s') , " Create new PhpWord object" , EOL; diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php index 73555a4448..9fc2cc5723 100755 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word Document echo date('H:i:s') , " Create new PhpWord object" , EOL; diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php index e41bffbdb9..f2feb1558d 100755 --- a/samples/Sample_07_TemplateCloneRow.php +++ b/samples/Sample_07_TemplateCloneRow.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s') , " Create new PhpWord object" , EOL; diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index 757a9aa732..cb52f7f0f1 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s') , " Create new PhpWord object" , EOL; diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index 0750f35ed3..ec65e104e4 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php index 506406a156..e3d192605f 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; diff --git a/samples/Sample_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php index b5ff7cf011..3ba4905e52 100644 --- a/samples/Sample_11_ReadWord2007.php +++ b/samples/Sample_11_ReadWord2007.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // Read contents $name = basename(__FILE__, '.php'); diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index d410f76e78..86ff9190e0 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -2,7 +2,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s') , " Create new PhpWord object" , EOL; diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index f406f4c0d1..744b8b379f 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -6,7 +6,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index b587ec633d..78dca727bb 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -6,7 +6,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php index f0cc82d9b3..2907fc4ecd 100644 --- a/samples/Sample_15_Link.php +++ b/samples/Sample_15_Link.php @@ -6,7 +6,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php index 40dc8c6a9a..06206d9c8b 100644 --- a/samples/Sample_16_Object.php +++ b/samples/Sample_16_Object.php @@ -6,7 +6,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php index a083770b34..a3aa36c33d 100644 --- a/samples/Sample_17_TitleTOC.php +++ b/samples/Sample_17_TitleTOC.php @@ -6,7 +6,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php index 6f5d1eee64..667b7c65b6 100644 --- a/samples/Sample_18_Watermark.php +++ b/samples/Sample_18_Watermark.php @@ -6,7 +6,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php index 145b830058..78f689aa15 100644 --- a/samples/Sample_19_TextBreak.php +++ b/samples/Sample_19_TextBreak.php @@ -6,7 +6,7 @@ // Init error_reporting(E_ALL); define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); -require_once '../Classes/PhpWord.php'; +require_once '../src/PhpWord.php'; // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; diff --git a/src/Autoloader.php b/src/Autoloader.php new file mode 100644 index 0000000000..ca762c6ae5 --- /dev/null +++ b/src/Autoloader.php @@ -0,0 +1,64 @@ +_creator = ''; + $this->_lastModifiedBy = $this->_creator; + $this->_created = time(); + $this->_modified = time(); + $this->_title = ''; + $this->_subject = ''; + $this->_description = ''; + $this->_keywords = ''; + $this->_category = ''; + $this->_company = ''; + $this->_manager = ''; + } + + /** + * Get Creator + * + * @return string + */ + public function getCreator() + { + return $this->_creator; + } + + /** + * Set Creator + * + * @param string $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setCreator($pValue = '') + { + $this->_creator = $pValue; + return $this; + } + + /** + * Get Last Modified By + * + * @return string + */ + public function getLastModifiedBy() + { + return $this->_lastModifiedBy; + } + + /** + * Set Last Modified By + * + * @param string $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setLastModifiedBy($pValue = '') + { + $this->_lastModifiedBy = $pValue; + return $this; + } + + /** + * Get Created + * + * @return datetime + */ + public function getCreated() + { + return $this->_created; + } + + /** + * Set Created + * + * @param datetime $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setCreated($pValue = null) + { + if (is_null($pValue)) { + $pValue = time(); + } + $this->_created = $pValue; + return $this; + } + + /** + * Get Modified + * + * @return datetime + */ + public function getModified() + { + return $this->_modified; + } + + /** + * Set Modified + * + * @param datetime $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setModified($pValue = null) + { + if (is_null($pValue)) { + $pValue = time(); + } + $this->_modified = $pValue; + return $this; + } + + /** + * Get Title + * + * @return string + */ + public function getTitle() + { + return $this->_title; + } + + /** + * Set Title + * + * @param string $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setTitle($pValue = '') + { + $this->_title = $pValue; + return $this; + } + + /** + * Get Description + * + * @return string + */ + public function getDescription() + { + return $this->_description; + } + + /** + * Set Description + * + * @param string $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setDescription($pValue = '') + { + $this->_description = $pValue; + return $this; + } + + /** + * Get Subject + * + * @return string + */ + public function getSubject() + { + return $this->_subject; + } + + /** + * Set Subject + * + * @param string $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setSubject($pValue = '') + { + $this->_subject = $pValue; + return $this; + } + + /** + * Get Keywords + * + * @return string + */ + public function getKeywords() + { + return $this->_keywords; + } + + /** + * Set Keywords + * + * @param string $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setKeywords($pValue = '') + { + $this->_keywords = $pValue; + return $this; + } + + /** + * Get Category + * + * @return string + */ + public function getCategory() + { + return $this->_category; + } + + /** + * Set Category + * + * @param string $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setCategory($pValue = '') + { + $this->_category = $pValue; + return $this; + } + + /** + * Get Company + * + * @return string + */ + public function getCompany() + { + return $this->_company; + } + + /** + * Set Company + * + * @param string $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setCompany($pValue = '') + { + $this->_company = $pValue; + return $this; + } + + /** + * Get Manager + * + * @return string + */ + public function getManager() + { + return $this->_manager; + } + + /** + * Set Manager + * + * @param string $pValue + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setManager($pValue = '') + { + $this->_manager = $pValue; + return $this; + } + + /** + * Get a List of Custom Property Names + * + * @return array of string + */ + public function getCustomProperties() + { + return array_keys($this->_customProperties); + } + + /** + * Check if a Custom Property is defined + * + * @param string $propertyName + * @return boolean + */ + public function isCustomPropertySet($propertyName) + { + return isset($this->_customProperties[$propertyName]); + } + + /** + * Get a Custom Property Value + * + * @param string $propertyName + * @return string + */ + public function getCustomPropertyValue($propertyName) + { + if (isset($this->_customProperties[$propertyName])) { + return $this->_customProperties[$propertyName]['value']; + } + + } + + /** + * Get a Custom Property Type + * + * @param string $propertyName + * @return string + */ + public function getCustomPropertyType($propertyName) + { + if (isset($this->_customProperties[$propertyName])) { + return $this->_customProperties[$propertyName]['type']; + } + + } + + /** + * Set a Custom Property + * + * @param string $propertyName + * @param mixed $propertyValue + * @param string $propertyType + * 'i': Integer + * 'f': Floating Point + * 's': String + * 'd': Date/Time + * 'b': Boolean + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) + { + if (($propertyType === null) || (!in_array($propertyType, array( + self::PROPERTY_TYPE_INTEGER, + self::PROPERTY_TYPE_FLOAT, + self::PROPERTY_TYPE_STRING, + self::PROPERTY_TYPE_DATE, + self::PROPERTY_TYPE_BOOLEAN + )))) { + if ($propertyValue === null) { + $propertyType = self::PROPERTY_TYPE_STRING; + } elseif (is_float($propertyValue)) { + $propertyType = self::PROPERTY_TYPE_FLOAT; + } elseif (is_int($propertyValue)) { + $propertyType = self::PROPERTY_TYPE_INTEGER; + } elseif (is_bool($propertyValue)) { + $propertyType = self::PROPERTY_TYPE_BOOLEAN; + } else { + $propertyType = self::PROPERTY_TYPE_STRING; + } + } + + $this->_customProperties[$propertyName] = array( + 'value' => $propertyValue, + 'type' => $propertyType + ); + return $this; + } + + /** + * Convert document propery based on type + * + * @param mixed $propertyValue + * @param string $propertyType + * @return mixed + */ + public static function convertProperty($propertyValue, $propertyType) + { + switch ($propertyType) { + case 'empty': // Empty + return ''; + break; + case 'null': // Null + return null; + break; + case 'i1': // 1-Byte Signed Integer + case 'i2': // 2-Byte Signed Integer + case 'i4': // 4-Byte Signed Integer + case 'i8': // 8-Byte Signed Integer + case 'int': // Integer + return (int) $propertyValue; + break; + case 'ui1': // 1-Byte Unsigned Integer + case 'ui2': // 2-Byte Unsigned Integer + case 'ui4': // 4-Byte Unsigned Integer + case 'ui8': // 8-Byte Unsigned Integer + case 'uint': // Unsigned Integer + return abs((int) $propertyValue); + break; + case 'r4': // 4-Byte Real Number + case 'r8': // 8-Byte Real Number + case 'decimal': // Decimal + return (float) $propertyValue; + break; + case 'lpstr': // LPSTR + case 'lpwstr': // LPWSTR + case 'bstr': // Basic String + return $propertyValue; + break; + case 'date': // Date and Time + case 'filetime': // File Time + return strtotime($propertyValue); + break; + case 'bool': // Boolean + return ($propertyValue == 'true') ? true : false; + break; + case 'cy': // Currency + case 'error': // Error Status Code + case 'vector': // Vector + case 'array': // Array + case 'blob': // Binary Blob + case 'oblob': // Binary Blob Object + case 'stream': // Binary Stream + case 'ostream': // Binary Stream Object + case 'storage': // Binary Storage + case 'ostorage': // Binary Storage Object + case 'vstream': // Binary Versioned Stream + case 'clsid': // Class ID + case 'cf': // Clipboard Data + return $propertyValue; + break; + } + + return $propertyValue; + } + + /** + * Convert document property type + * + * @param string $propertyType + * @return mixed + */ + public static function convertPropertyType($propertyType) + { + switch ($propertyType) { + case 'i1': // 1-Byte Signed Integer + case 'i2': // 2-Byte Signed Integer + case 'i4': // 4-Byte Signed Integer + case 'i8': // 8-Byte Signed Integer + case 'int': // Integer + case 'ui1': // 1-Byte Unsigned Integer + case 'ui2': // 2-Byte Unsigned Integer + case 'ui4': // 4-Byte Unsigned Integer + case 'ui8': // 8-Byte Unsigned Integer + case 'uint': // Unsigned Integer + return self::PROPERTY_TYPE_INTEGER; + break; + case 'r4': // 4-Byte Real Number + case 'r8': // 8-Byte Real Number + case 'decimal': // Decimal + return self::PROPERTY_TYPE_FLOAT; + break; + case 'empty': // Empty + case 'null': // Null + case 'lpstr': // LPSTR + case 'lpwstr': // LPWSTR + case 'bstr': // Basic String + return self::PROPERTY_TYPE_STRING; + break; + case 'date': // Date and Time + case 'filetime': // File Time + return self::PROPERTY_TYPE_DATE; + break; + case 'bool': // Boolean + return self::PROPERTY_TYPE_BOOLEAN; + break; + case 'cy': // Currency + case 'error': // Error Status Code + case 'vector': // Vector + case 'array': // Array + case 'blob': // Binary Blob + case 'oblob': // Binary Blob Object + case 'stream': // Binary Stream + case 'ostream': // Binary Stream Object + case 'storage': // Binary Storage + case 'ostorage': // Binary Storage Object + case 'vstream': // Binary Versioned Stream + case 'clsid': // Class ID + case 'cf': // Clipboard Data + return self::PROPERTY_TYPE_UNKNOWN; + break; + } + return self::PROPERTY_TYPE_UNKNOWN; + } +} diff --git a/src/Exceptions/Exception.php b/src/Exceptions/Exception.php new file mode 100644 index 0000000000..72f5cfedc6 --- /dev/null +++ b/src/Exceptions/Exception.php @@ -0,0 +1,6 @@ +addFromSource($pSource); + } + } + + /** + * Add HashTable items from source + * + * @param PhpOffice\PhpWord\IComparable[] $pSource Source array to create HashTable from + * @throws Exception + */ + public function addFromSource($pSource = null) + { + // Check if an array was passed + if ($pSource == null) { + return; + } elseif (!is_array($pSource)) { + throw new Exception('Invalid array parameter passed.'); + } + + foreach ($pSource as $item) { + $this->add($item); + } + } + + /** + * Add HashTable item + * + * @param PhpOffice\PhpWord\IComparable $pSource Item to add + * @throws Exception + */ + public function add(IComparable $pSource = null) + { + // Determine hashcode + $hashCode = null; + $hashIndex = $pSource->getHashIndex(); + if (is_null($hashIndex)) { + $hashCode = $pSource->getHashCode(); + } elseif (isset ($this->_keyMap[$hashIndex])) { + $hashCode = $this->_keyMap[$hashIndex]; + } else { + $hashCode = $pSource->getHashCode(); + } + + // Add value + if (!isset($this->_items[$hashCode])) { + $this->_items[$hashCode] = $pSource; + $index = count($this->_items) - 1; + $this->_keyMap[$index] = $hashCode; + $pSource->setHashIndex($index); + } else { + $pSource->setHashIndex($this->_items[$hashCode]->getHashIndex()); + } + } + + /** + * Remove HashTable item + * + * @param PhpOffice\PhpWord\IComparable $pSource Item to remove + * @throws Exception + */ + public function remove(IComparable $pSource = null) + { + if (isset($this->_items[$pSource->getHashCode()])) { + unset($this->_items[$pSource->getHashCode()]); + + $deleteKey = -1; + foreach ($this->_keyMap as $key => $value) { + if ($deleteKey >= 0) { + $this->_keyMap[$key - 1] = $value; + } + + if ($value == $pSource->getHashCode()) { + $deleteKey = $key; + } + } + unset($this->_keyMap[count($this->_keyMap) - 1]); + } + } + + /** + * Clear HashTable + * + */ + public function clear() + { + $this->_items = array(); + $this->_keyMap = array(); + } + + /** + * @return int + */ + public function count() + { + return count($this->_items); + } + + /** + * @param string $pHashCode + * @return int Index + */ + public function getIndexForHashCode($pHashCode = '') + { + return array_search($pHashCode, $this->_keyMap); + } + + /** + * @param int $pIndex + * @return PhpOffice\PhpWord\IComparable + */ + public function getByIndex($pIndex = 0) + { + if (isset($this->_keyMap[$pIndex])) { + return $this->getByHashCode($this->_keyMap[$pIndex]); + } + + return null; + } + + /** + * @param string $pHashCode + * @return PhpOffice\PhpWord\IComparable + * + */ + public function getByHashCode($pHashCode = '') + { + if (isset($this->_items[$pHashCode])) { + return $this->_items[$pHashCode]; + } + + return null; + } + + /** + * @return PhpOffice\PhpWord\IComparable[] + */ + public function toArray() + { + return $this->_items; + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() + { + $vars = get_object_vars($this); + foreach ($vars as $key => $value) { + if (is_object($value)) { + $this->$key = clone $value; + } + } + } +} \ No newline at end of file diff --git a/src/IOFactory.php b/src/IOFactory.php new file mode 100644 index 0000000000..88810f79f0 --- /dev/null +++ b/src/IOFactory.php @@ -0,0 +1,80 @@ +load($filename); + } +} \ No newline at end of file diff --git a/src/Media.php b/src/Media.php new file mode 100644 index 0000000000..2656b3fdd0 --- /dev/null +++ b/src/Media.php @@ -0,0 +1,347 @@ + array(), + 'embeddings' => array(), + 'links' => array() + ); + + /** + * Header Media Elements + * + * @var array + */ + private static $_headerMedia = array(); + + /** + * Footer Media Elements + * + * @var array + */ + private static $_footerMedia = array(); + + /** + * ObjectID Counter + * + * @var int + */ + private static $_objectId = 1325353440; + + /** + * Add new Section Media Element + * + * @param string $src + * @param string $type + * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage + * @return mixed + */ + public static function addSectionMediaElement($src, $type, MemoryImage $memoryImage = null) + { + $mediaId = md5($src); + $key = ($type === 'image') ? 'images' : 'embeddings'; + + if (!array_key_exists($mediaId, self::$_sectionMedia[$key])) { + $cImg = self::countSectionMediaElements('images'); + $cObj = self::countSectionMediaElements('embeddings'); + $rID = self::countSectionMediaElements() + 7; + + $media = array(); + + $folder = null; + $file = null; + if ($type === 'image') { + $cImg++; + //Detect if it's a memory image first by php ext and second by regex + $isMemImage = false; + if (stripos(strrev($src), strrev('.php')) === 0) { + $isMemImage = true; + } + 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 = exif_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'; + } + } + + $folder = 'media'; + $file = $type . $cImg . '.' . strtolower($extension); + } elseif ($type === 'oleObject') { + $cObj++; + $folder = 'embedding'; + $file = $type . $cObj . '.bin'; + } + + $media['source'] = $src; + $media['target'] = "$folder/section_$file"; + $media['type'] = $type; + $media['rID'] = $rID; + + self::$_sectionMedia[$key][$mediaId] = $media; + + if ($type === 'oleObject') { + return array($rID, ++self::$_objectId); + } + + return $rID; + } + + if ($type === 'oleObject') { + $rID = self::$_sectionMedia[$key][$mediaId]['rID']; + return array($rID, ++self::$_objectId); + } + return self::$_sectionMedia[$key][$mediaId]['rID']; + } + + /** + * Add new Section Link Element + * + * @param string $linkSrc + * @return mixed + */ + public static function addSectionLinkElement($linkSrc) + { + $rID = self::countSectionMediaElements() + 7; + + $link = array(); + $link['target'] = $linkSrc; + $link['rID'] = $rID; + $link['type'] = 'hyperlink'; + + self::$_sectionMedia['links'][] = $link; + + return $rID; + } + + /** + * Get Section Media Elements + * + * @param string $key + * @return array + */ + public static function getSectionMediaElements($key = null) + { + if (!is_null($key)) { + return self::$_sectionMedia[$key]; + } + + $arrImages = self::$_sectionMedia['images']; + $arrObjects = self::$_sectionMedia['embeddings']; + $arrLinks = self::$_sectionMedia['links']; + return array_merge($arrImages, $arrObjects, $arrLinks); + } + + /** + * Get Section Media Elements Count + * + * @param string $key + * @return int + */ + public static function countSectionMediaElements($key = null) + { + if (!is_null($key)) { + return count(self::$_sectionMedia[$key]); + } + + $cImages = count(self::$_sectionMedia['images']); + $cObjects = count(self::$_sectionMedia['embeddings']); + $cLinks = count(self::$_sectionMedia['links']); + return ($cImages + $cObjects + $cLinks); + } + + /** + * Add new Header Media Element + * + * @param int $headerCount + * @param string $src + * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage + * @return int + */ + public static function addHeaderMediaElement($headerCount, $src, MemoryImage $memoryImage = null) + { + $mediaId = md5($src); + $key = 'header' . $headerCount; + + if (!array_key_exists($key, self::$_headerMedia)) { + self::$_headerMedia[$key] = array(); + } + + if (!array_key_exists($mediaId, self::$_headerMedia[$key])) { + $cImg = self::countHeaderMediaElements($key); + $rID = $cImg + 1; + + $cImg++; + $inf = pathinfo($src); + $isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false; + + $media = array(); + if ($isMemImage) { + $ext = $memoryImage->getImageExtension(); + $media['isMemImage'] = true; + $media['createfunction'] = $memoryImage->getImageCreateFunction(); + $media['imagefunction'] = $memoryImage->getImageFunction(); + } else { + $ext = $inf['extension']; + if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg + $ext = 'jpg'; + } + } + $file = 'image' . $cImg . '.' . strtolower($ext); + + $media['source'] = $src; + $media['target'] = 'media/' . $key . '_' . $file; + $media['type'] = 'image'; + $media['rID'] = $rID; + + self::$_headerMedia[$key][$mediaId] = $media; + + return $rID; + } + return self::$_headerMedia[$key][$mediaId]['rID']; + } + + /** + * Get Header Media Elements Count + * + * @param string $key + * @return int + */ + public static function countHeaderMediaElements($key) + { + return count(self::$_headerMedia[$key]); + } + + /** + * Get Header Media Elements + * + * @return int + */ + public static function getHeaderMediaElements() + { + return self::$_headerMedia; + } + + /** + * Add new Footer Media Element + * + * @param int $footerCount + * @param string $src + * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage + * @return int + */ + public static function addFooterMediaElement($footerCount, $src, MemoryImage $memoryImage = null) + { + $mediaId = md5($src); + $key = 'footer' . $footerCount; + + if (!array_key_exists($key, self::$_footerMedia)) { + self::$_footerMedia[$key] = array(); + } + + if (!array_key_exists($mediaId, self::$_footerMedia[$key])) { + $cImg = self::countFooterMediaElements($key); + $rID = $cImg + 1; + + $cImg++; + $inf = pathinfo($src); + $isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false; + + $media = array(); + if ($isMemImage) { + $ext = $memoryImage->getImageExtension(); + $media['isMemImage'] = true; + $media['createfunction'] = $memoryImage->getImageCreateFunction(); + $media['imagefunction'] = $memoryImage->getImageFunction(); + } else { + $ext = $inf['extension']; + if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg + $ext = 'jpg'; + } + } + $file = 'image' . $cImg . '.' . strtolower($ext); + + $media['source'] = $src; + $media['target'] = 'media/' . $key . '_' . $file; + $media['type'] = 'image'; + $media['rID'] = $rID; + + self::$_footerMedia[$key][$mediaId] = $media; + + return $rID; + } + return self::$_footerMedia[$key][$mediaId]['rID']; + } + + /** + * Get Footer Media Elements Count + * + * @param string $key + * @return int + */ + public static function countFooterMediaElements($key) + { + return count(self::$_footerMedia[$key]); + } + + /** + * Get Footer Media Elements + * + * @return int + */ + public static function getFooterMediaElements() + { + return self::$_footerMedia; + } +} diff --git a/src/PhpWord.php b/src/PhpWord.php new file mode 100644 index 0000000000..e08ec04132 --- /dev/null +++ b/src/PhpWord.php @@ -0,0 +1,233 @@ +_documentProperties = new DocumentProperties(); + $this->_defaultFontName = self::DEFAULT_FONT_NAME; + $this->_defaultFontSize = self::DEFAULT_FONT_SIZE; + } + + /** + * @return PhpOffice\PhpWord\DocumentProperties + */ + public function getDocumentProperties() + { + return $this->_documentProperties; + } + + /** + * @param PhpOffice\PhpWord\DocumentProperties $documentProperties + * @return PhpOffice\PhpWord + */ + public function setDocumentProperties(DocumentProperties $documentProperties) + { + $this->_documentProperties = $documentProperties; + + return $this; + } + + /** + * @param PhpOffice\PhpWord\Section\Settings $settings + * @return PhpOffice\PhpWord\Section + */ + public function createSection($settings = null) + { + $section = new Section(\count($this->_sections) + 1, $settings); + $this->_sections[] = $section; + + return $section; + } + + /** + * @return string + */ + public function getDefaultFontName() + { + return $this->_defaultFontName; + } + + /** + * @param string $fontName + */ + public function setDefaultFontName($fontName) + { + $this->_defaultFontName = $fontName; + } + + /** + * @return string + */ + public function getDefaultFontSize() + { + return $this->_defaultFontSize; + } + + /** + * @param int $fontSize + */ + public function setDefaultFontSize($fontSize) + { + $this->_defaultFontSize = $fontSize; + } + + /** + * Set default paragraph style definition to styles.xml + * + * @param array $styles Paragraph style definition + */ + public function setDefaultParagraphStyle($styles) + { + Style::setDefaultParagraphStyle($styles); + } + + /** + * Adds a paragraph style definition to styles.xml + * + * @param $styleName string + * @param $styles array + */ + public function addParagraphStyle($styleName, $styles) + { + Style::addParagraphStyle($styleName, $styles); + } + + /** + * Adds a font style definition to styles.xml + * + * @param $styleName string + * @param $styles array + */ + public function addFontStyle($styleName, $styleFont, $styleParagraph = null) + { + Style::addFontStyle($styleName, $styleFont, $styleParagraph); + } + + /** + * Adds a table style definition to styles.xml + * + * @param $styleName string + * @param $styles array + */ + public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) + { + Style::addTableStyle($styleName, $styleTable, $styleFirstRow); + } + + /** + * Adds a heading style definition to styles.xml + * + * @param $titleCount int + * @param $styles array + */ + public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) + { + Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); + } + + /** + * Adds a hyperlink style to styles.xml + * + * @param $styleName string + * @param $styles array + */ + public function addLinkStyle($styleName, $styles) + { + Style::addLinkStyle($styleName, $styles); + } + + /** + * @return PhpOffice\PhpWord\Section[] + */ + public function getSections() + { + return $this->_sections; + } + + /** + * @param string $filename Fully qualified filename. + * @return PhpOffice\PhpWord\Template + * @throws PhpOffice\PhpWord\Exceptions\Exception + */ + public function loadTemplate($filename) + { + if (\file_exists($filename)) { + return new Template($filename); + } else { + throw new Exception("Template file {$filename} not found."); + } + } +} \ No newline at end of file diff --git a/src/Reader/AbstractReader.php b/src/Reader/AbstractReader.php new file mode 100644 index 0000000000..f92980cb8e --- /dev/null +++ b/src/Reader/AbstractReader.php @@ -0,0 +1,110 @@ +readDataOnly; + return true; + } + + /** + * Set read data only + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Reader\IReader + */ + public function setReadDataOnly($pValue = true) + { + $this->readDataOnly = $pValue; + return $this; + } + + /** + * Open file for reading + * + * @param string $pFilename + * @return resource + * @throws Exception + */ + protected function openFile($pFilename) + { + // Check if file exists + if (!file_exists($pFilename) || !is_readable($pFilename)) { + throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + // Open file + $this->fileHandle = fopen($pFilename, 'r'); + if ($this->fileHandle === false) { + throw new Exception("Could not open file " . $pFilename . " for reading."); + } + } + + /** + * Can the current IReader read the file? + * + * @param string $pFilename + * @return bool + */ + public function canRead($pFilename) + { + // Check if file exists + try { + $this->openFile($pFilename); + } catch (Exception $e) { + return false; + } + fclose($this->fileHandle); + return true; + } +} \ No newline at end of file diff --git a/src/Reader/IReader.php b/src/Reader/IReader.php new file mode 100644 index 0000000000..94db13e576 --- /dev/null +++ b/src/Reader/IReader.php @@ -0,0 +1,46 @@ +open($pFilename) === true) { + // check if it is an OOXML archive + $rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels")); + if ($rels !== false) { + foreach ($rels->Relationship as $rel) { + switch ($rel["Type"]) { + case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": + if (basename($rel["Target"]) == 'document.xml') { + $return = true; + } + break; + + } + } + } + $zip->close(); + } + + return $return; + } + + /** + * @param ZipArchive $archive + * @param string $fileName + * @param bool $removeNamespace + * @return mixed + */ + public function getFromZipArchive($archive, $fileName = '', $removeNamespace = false) + { + // Root-relative paths + if (strpos($fileName, '//') !== false) { + $fileName = substr($fileName, strpos($fileName, '//') + 1); + } + $fileName = File::realpath($fileName); + + // Apache POI fixes + $contents = $archive->getFromName($fileName); + if ($contents === false) { + $contents = $archive->getFromName(substr($fileName, 1)); + } + + // Remove namespaces from elements and attributes name + if ($removeNamespace) { + $contents = preg_replace('~(canRead($pFilename)) { + return null; + } + + // Initialisations + $word = new PhpWord(); + $zip = new ZipArchive(); + $zip->open($pFilename); + + // Read properties and documents + $rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels")); + foreach ($rels->Relationship as $rel) { + switch ($rel["Type"]) { + // Core properties + case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties": + $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); + if (is_object($xmlCore)) { + $xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/"); + $xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/"); + $xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"); + $docProps = $word->getDocumentProperties(); + $docProps->setCreator((string)self::arrayItem($xmlCore->xpath("dc:creator"))); + $docProps->setLastModifiedBy((string)self::arrayItem($xmlCore->xpath("cp:lastModifiedBy"))); + $docProps->setCreated(strtotime(self::arrayItem($xmlCore->xpath("dcterms:created")))); + $docProps->setModified(strtotime(self::arrayItem($xmlCore->xpath("dcterms:modified")))); + $docProps->setTitle((string)self::arrayItem($xmlCore->xpath("dc:title"))); + $docProps->setDescription((string)self::arrayItem($xmlCore->xpath("dc:description"))); + $docProps->setSubject((string)self::arrayItem($xmlCore->xpath("dc:subject"))); + $docProps->setKeywords((string)self::arrayItem($xmlCore->xpath("cp:keywords"))); + $docProps->setCategory((string)self::arrayItem($xmlCore->xpath("cp:category"))); + } + break; + // Extended properties + case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties": + $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); + if (is_object($xmlCore)) { + $docProps = $word->getDocumentProperties(); + if (isset($xmlCore->Company)) { + $docProps->setCompany((string)$xmlCore->Company); + } + if (isset($xmlCore->Manager)) { + $docProps->setManager((string)$xmlCore->Manager); + } + } + break; + // Custom properties + case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": + $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); + if (is_object($xmlCore)) { + $docProps = $word->getDocumentProperties(); + foreach ($xmlCore as $xmlProperty) { + $cellDataOfficeAttributes = $xmlProperty->attributes(); + if (isset($cellDataOfficeAttributes['name'])) { + $propertyName = (string)$cellDataOfficeAttributes['name']; + $cellDataOfficeChildren = $xmlProperty->children("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"); + $attributeType = $cellDataOfficeChildren->getName(); + $attributeValue = (string)$cellDataOfficeChildren->{$attributeType}; + $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType); + $attributeType = DocumentProperties::convertPropertyType($attributeType); + $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); + } + } + } + break; + // Document + case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": + $dir = dirname($rel["Target"]); + $archive = "$dir/_rels/" . basename($rel["Target"]) . ".rels"; + $relsDoc = simplexml_load_string($this->getFromZipArchive($zip, $archive)); + $relsDoc->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); + $xpath = self::arrayItem( + $relsDoc->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']") + ); + $xmlDoc = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}", true)); + if (is_object($xmlDoc)) { + $section = $word->createSection(); + + foreach ($xmlDoc->body->children() as $elm) { + $elmName = $elm->getName(); + if ($elmName == 'p') { // Paragraph/section + // Create new section if section setting found + if ($elm->pPr->sectPr) { + $section->setSettings($this->loadSectionSettings($elm->pPr)); + $section = $word->createSection(); + continue; + } + // Has w:r? It's either text or textrun + if ($elm->r) { + // w:r = 1? It's a plain paragraph + if (count($elm->r) == 1) { + $section->addText( + $elm->r->t, + $this->loadFontStyle($elm->r) + ); + // w:r more than 1? It's a textrun + } else { + $textRun = $section->createTextRun(); + foreach ($elm->r as $r) { + $textRun->addText( + $r->t, + $this->loadFontStyle($r) + ); + } + } + // No, it's a textbreak + } else { + $section->addTextBreak(); + } + } elseif ($elmName == 'sectPr') { + // Last section setting + $section->setSettings($this->loadSectionSettings($xmlDoc->body)); + } + } + } + break; + } + } + + // Read styles + $docRels = simplexml_load_string($this->getFromZipArchive($zip, "word/_rels/document.xml.rels")); + foreach ($docRels->Relationship as $rel) { + switch ($rel["Type"]) { + case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles": + $xmlStyle = simplexml_load_string($this->getFromZipArchive($zip, "word/{$rel['Target']}", true)); + if (is_object($xmlStyle)) { + foreach ($xmlStyle->children() as $elm) { + if ($elm->getName() != 'style') { + continue; + } + $pStyle = null; + $fStyle = null; + $hasParagraphStyle = isset($elm->pPr); + $hasFontStyle = isset($elm->rPr); + $styleName = (string)$elm->name['val']; + if ($hasParagraphStyle) { + $pStyle = $this->loadParagraphStyle($elm); + if (!$hasFontStyle) { + $word->addParagraphStyle($styleName, $pStyle); + } + } + if ($hasFontStyle) { + $fStyle = $this->loadFontStyle($elm); + $word->addFontStyle($styleName, $fStyle, $pStyle); + } + } + } + break; + } + } + $zip->close(); + + return $word; + } + + /** + * Load section settings from SimpleXMLElement + * + * @param SimpleXMLElement $elm + * @return array|string|null + * + * @todo Implement gutter + */ + private function loadSectionSettings($elm) + { + if ($xml = $elm->sectPr) { + $setting = array(); + if ($xml->type) { + $setting['breakType'] = (string)$xml->type['val']; + } + if ($xml->pgSz) { + if (isset($xml->pgSz['w'])) { + $setting['pageSizeW'] = (int)$xml->pgSz['w']; + } + if (isset($xml->pgSz['h'])) { + $setting['pageSizeH'] = (int)$xml->pgSz['h']; + } + if (isset($xml->pgSz['orient'])) { + $setting['orientation'] = (string)$xml->pgSz['orient']; + } + } + if ($xml->pgMar) { + if (isset($xml->pgMar['top'])) { + $setting['topMargin'] = (int)$xml->pgMar['top']; + } + if (isset($xml->pgMar['left'])) { + $setting['leftMargin'] = (int)$xml->pgMar['left']; + } + if (isset($xml->pgMar['bottom'])) { + $setting['bottomMargin'] = (int)$xml->pgMar['bottom']; + } + if (isset($xml->pgMar['right'])) { + $setting['rightMargin'] = (int)$xml->pgMar['right']; + } + if (isset($xml->pgMar['header'])) { + $setting['headerHeight'] = (int)$xml->pgMar['header']; + } + if (isset($xml->pgMar['footer'])) { + $setting['footerHeight'] = (int)$xml->pgMar['footer']; + } + if (isset($xml->pgMar['gutter'])) { + // $setting['gutter'] = (int)$xml->pgMar['gutter']; + } + } + if ($xml->cols) { + if (isset($xml->cols['num'])) { + $setting['colsNum'] = (int)$xml->cols['num']; + } + if (isset($xml->cols['space'])) { + $setting['colsSpace'] = (int)$xml->cols['space']; + } + } + return $setting; + } + return null; + } + + /** + * Load paragraph style from SimpleXMLElement + * + * @param SimpleXMLElement $elm + * @return array|string|null + */ + private function loadParagraphStyle($elm) + { + if ($xml = $elm->pPr) { + if ($xml->pStyle) { + return (string)$xml->pStyle['val']; + } + $style = array(); + if ($xml->jc) { + $style['align'] = (string)$xml->jc['val']; + } + if ($xml->ind) { + if (isset($xml->ind->left)) { + $style['indent'] = (int)$xml->ind->left; + } + if (isset($xml->ind->hanging)) { + $style['hanging'] = (int)$xml->ind->hanging; + } + if (isset($xml->ind->line)) { + $style['spacing'] = (int)$xml->ind->line; + } + } + if ($xml->spacing) { + if (isset($xml->spacing['after'])) { + $style['spaceAfter'] = (int)$xml->spacing['after']; + } + if (isset($xml->spacing['before'])) { + $style['spaceBefore'] = (int)$xml->spacing['before']; + } + if (isset($xml->spacing['line'])) { + $style['spacing'] = (int)$xml->spacing['line']; + } + } + if ($xml->basedOn) { + $style['basedOn'] = (string)$xml->basedOn['val']; + } + if ($xml->next) { + $style['next'] = (string)$xml->next['val']; + } + if ($xml->widowControl) { + $style['widowControl'] = false; + } + if ($xml->keepNext) { + $style['keepNext'] = true; + } + if ($xml->keepLines) { + $style['keepLines'] = true; + } + if ($xml->pageBreakBefore) { + $style['pageBreakBefore'] = true; + } + return $style; + } + return null; + } + + /** + * Load font style from SimpleXMLElement + * + * @param SimpleXMLElement $elm + * @return array|string|null + */ + private function loadFontStyle($elm) + { + if ($xml = $elm->rPr) { + if ($xml->rStyle) { + return (string)$xml->rStyle['val']; + } + $style = array(); + if ($xml->rFonts) { + $style['name'] = (string)$xml->rFonts['ascii']; + } + if ($xml->sz) { + $style['size'] = (int)$xml->sz['val'] / 2; + } + if ($xml->color) { + $style['color'] = (string)$xml->color['val']; + } + if ($xml->b) { + $style['bold'] = true; + } + if ($xml->i) { + $style['italic'] = true; + } + if ($xml->u) { + $style['underline'] = (string)$xml->u['val']; + } + if ($xml->strike) { + $style['strikethrough'] = true; + } + if ($xml->highlight) { + $style['fgColor'] = (string)$xml->highlight['val']; + } + if ($xml->vertAlign) { + if ($xml->vertAlign['val'] == 'superscript') { + $style['superScript'] = true; + } else { + $style['subScript'] = true; + } + } + return $style; + } + return null; + } + + /** + * @param array $array + * @param mixed $key + * @return mixed|null + */ + private static function arrayItem($array, $key = 0) + { + return (isset($array[$key]) ? $array[$key] : null); + } +} \ No newline at end of file diff --git a/src/Section.php b/src/Section.php new file mode 100644 index 0000000000..cfcb6bc931 --- /dev/null +++ b/src/Section.php @@ -0,0 +1,453 @@ +_sectionCount = $sectionCount; + $this->_settings = new Settings(); + $this->setSettings($settings); + } + + /** + * Set Section Settings + * + * @param array $settings + */ + public function setSettings($settings = null) + { + if (!is_null($settings) && is_array($settings)) { + foreach ($settings as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_settings->setSettingValue($key, $value); + } + } + } + + /** + * Get Section Settings + * + * @return PhpOffice\PhpWord\Section\Settings + */ + public function getSettings() + { + return $this->_settings; + } + + /** + * Add a Text Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new Text($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\Link + */ + public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) + { + if (!String::IsUTF8($linkSrc)) { + $linkSrc = utf8_encode($linkSrc); + } + if (!is_null($linkName)) { + if (!String::IsUTF8($linkName)) { + $linkName = utf8_encode($linkName); + } + } + + $link = new Link($linkSrc, $linkName, $styleFont, $styleParagraph); + $rID = Media::addSectionLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } + + /** + * Add a TextBreak Element + * + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + */ + public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); + } + } + + /** + * Add a PageBreak Element + */ + public function addPageBreak() + { + $this->_elementCollection[] = new PageBreak(); + } + + /** + * Add a Table Element + * + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Table + */ + public function addTable($style = null) + { + $table = new Table('section', $this->_sectionCount, $style); + $this->_elementCollection[] = $table; + return $table; + } + + /** + * Add a ListItem Element + * + * @param string $text + * @param int $depth + * @param mixed $styleFont + * @param mixed $styleList + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\ListItem + */ + public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $listItem = new ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); + $this->_elementCollection[] = $listItem; + return $listItem; + } + + /** + * Add a OLE-Object Element + * + * @param string $src + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Object + * @throws Exception + */ + public function addObject($src, $style = null) + { + $object = new Object($src, $style); + + if (!is_null($object->getSource())) { + $inf = pathinfo($src); + $ext = $inf['extension']; + if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { + $ext = substr($ext, 0, -1); + } + + $iconSrc = \PHPWORD_BASE_DIR . '_staticDocParts/'; + if (!file_exists($iconSrc . '_' . $ext . '.png')) { + $iconSrc = $iconSrc . '_default.png'; + } else { + $iconSrc .= '_' . $ext . '.png'; + } + + $rIDimg = Media::addSectionMediaElement($iconSrc, 'image'); + $data = Media::addSectionMediaElement($src, 'oleObject'); + $rID = $data[0]; + $objectId = $data[1]; + + $object->setRelationId($rID); + $object->setObjectId($objectId); + $object->setImageRelationId($rIDimg); + + $this->_elementCollection[] = $object; + return $object; + } + throw new Exception('Source does not exist or unsupported object type.'); + } + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Image + * @throws Exception + */ + public function addImage($src, $style = null) + { + $image = new Image($src, $style); + + if (!is_null($image->getSource())) { + $rID = Media::addSectionMediaElement($src, 'image'); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } + throw new Exception('Source does not exist or unsupported image type.'); + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PhpOffice\PhpWord\Section\MemoryImage + * @throws Exception + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + $rID = Media::addSectionMediaElement($link, 'image', $memoryImage); + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } + throw new Exception('Unsupported image type.'); + } + + /** + * Add a Table-of-Contents Element + * + * @param mixed $styleFont + * @param mixed $styleTOC + * @return PhpOffice\PhpWord\TOC + */ + public function addTOC($styleFont = null, $styleTOC = null) + { + $toc = new TOC($styleFont, $styleTOC); + $this->_elementCollection[] = $toc; + return $toc; + } + + /** + * Add a Title Element + * + * @param string $text + * @param int $depth + * @return PhpOffice\PhpWord\Section\Title + */ + public function addTitle($text, $depth = 1) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $styles = Style::getStyles(); + if (array_key_exists('Heading_' . $depth, $styles)) { + $style = 'Heading' . $depth; + } else { + $style = null; + } + + $title = new Title($text, $depth, $style); + + $data = TOC::addTitle($text, $depth); + $anchor = $data[0]; + $bookmarkId = $data[1]; + + $title->setAnchor($anchor); + $title->setBookmarkId($bookmarkId); + + $this->_elementCollection[] = $title; + return $title; + } + + /** + * Create a new TextRun + * + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Get all Elements + * + * @return array + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Create a new Header + * + * @return PhpOffice\PhpWord\Section\Header + */ + public function createHeader() + { + $header = new Header($this->_sectionCount); + $this->_headers[] = $header; + return $header; + } + + /** + * Get Headers + * + * @return array + */ + public function getHeaders() + { + return $this->_headers; + } + + /** + * Is there a header for this section that is for the first page only? + * + * If any of the Header instances have a type of Header::FIRST then this method returns true. + * False otherwise. + * + * @return Boolean + */ + public function hasDifferentFirstPage() + { + $value = array_filter($this->_headers, function (Header &$header) { + return $header->getType() == Header::FIRST; + }); + return count($value) > 0; + } + + /** + * Create a new Footer + * + * @return PhpOffice\PhpWord\Section\Footer + */ + public function createFooter() + { + $footer = new Footer($this->_sectionCount); + $this->_footer = $footer; + return $footer; + } + + /** + * Get Footer + * + * @return PhpOffice\PhpWord\Section\Footer + */ + public function getFooter() + { + return $this->_footer; + } + + /** + * Create a new Footnote Element + * + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\Footnote + */ + public function createFootnote($styleParagraph = null) + { + $footnote = new Footnote($styleParagraph); + $refID = Footnote::addFootnoteElement($footnote); + $footnote->setReferenceId($refID); + $this->_elementCollection[] = $footnote; + return $footnote; + } +} \ No newline at end of file diff --git a/src/Section/Footer.php b/src/Section/Footer.php new file mode 100644 index 0000000000..8c88bd846a --- /dev/null +++ b/src/Section/Footer.php @@ -0,0 +1,217 @@ +_footerCount = $sectionCount; + } + + /** + * Add a Text Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new Text($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add TextBreak + * + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + */ + public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); + } + } + + /** + * Create a new TextRun + * + * @return PhpOffice\PhpWord\Section\TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Add a Table Element + * + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Table + */ + public function addTable($style = null) + { + $table = new Table('footer', $this->_footerCount, $style); + $this->_elementCollection[] = $table; + return $table; + } + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return Image + */ + public function addImage($src, $style = null) + { + $image = new Image($src, $style); + + if (!is_null($image->getSource())) { + $rID = Media::addFooterMediaElement($this->_footerCount, $src); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + throw new Exception('Src does not exist or invalid image type.'); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PhpOffice\PhpWord\Section\MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + $rID = Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + throw new Exception('Unsupported image type.'); + } + } + + /** + * Add a PreserveText Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\Footer\PreserveText + */ + public function addPreserveText($text, $styleFont = null, $styleParagraph = null) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $ptext = new PreserveText($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $ptext; + return $ptext; + } + + /** + * Get Footer Relation ID + */ + public function getRelationId() + { + return $this->_rId; + } + + /** + * Set Footer Relation ID + * + * @param int $rId + */ + public function setRelationId($rId) + { + $this->_rId = $rId; + } + + /** + * Get all Footer Elements + * @return array + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Footer Count + */ + public function getFooterCount() + { + return $this->_footerCount; + } +} diff --git a/src/Section/Footer/PreserveText.php b/src/Section/Footer/PreserveText.php new file mode 100644 index 0000000000..fa9f8a8617 --- /dev/null +++ b/src/Section/Footer/PreserveText.php @@ -0,0 +1,130 @@ +_styleFont = new Font('text'); + + foreach ($styleFont as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_styleFont->setStyleValue($key, $value); + } + } else { + $this->_styleFont = $styleFont; + } + + // Set paragraph style + if (is_array($styleParagraph)) { + $this->_styleParagraph = new Paragraph(); + + foreach ($styleParagraph as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_styleParagraph->setStyleValue($key, $value); + } + } else { + $this->_styleParagraph = $styleParagraph; + } + + $matches = preg_split('/({.*?})/', $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + if (isset($matches[0])) { + $this->_text = $matches[0]; + } + + return $this; + } + + /** + * Get Text style + * + * @return PhpOffice\PhpWord\Style\Font + */ + public function getFontStyle() + { + return $this->_styleFont; + } + + /** + * Get Paragraph style + * + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function getParagraphStyle() + { + return $this->_styleParagraph; + } + + /** + * Get Text content + * + * @return string + */ + public function getText() + { + return $this->_text; + } +} diff --git a/src/Section/Footnote.php b/src/Section/Footnote.php new file mode 100644 index 0000000000..e5b6e6d814 --- /dev/null +++ b/src/Section/Footnote.php @@ -0,0 +1,151 @@ +_elementCollection = array(); + + // Set paragraph style + if (is_array($styleParagraph)) { + $this->_styleParagraph = new Paragraph(); + + foreach ($styleParagraph as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_styleParagraph->setStyleValue($key, $value); + } + } else { + $this->_styleParagraph = $styleParagraph; + } + } + + + /** + * Add a Text Element + * + * @var string $text + * @var mixed $styleFont + * @return PhpOffice\PhpWord\Section\Text + */ + public function addText($text = null, $styleFont = null) + { + $givenText = $text; + $text = new Text($givenText, $styleFont); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $styleFont + * @return PhpOffice\PhpWord\Section\Link + */ + public function addLink($linkSrc, $linkName = null, $styleFont = null) + { + + $link = new Link($linkSrc, $linkName, $styleFont); + $rID = PhpOffice\PhpWord\Footnote::addFootnoteLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } + + /** + * Get Footnote content + * + * @return array + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Paragraph style + * + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function getParagraphStyle() + { + return $this->_styleParagraph; + } + + /** + * Get Footnote Reference ID + * + * @return int + */ + public function getReferenceId() + { + return $this->_refId; + } + + /** + * Set Footnote Reference ID + * + * @param int $refId + */ + public function setReferenceId($refId) + { + $this->_refId = $refId; + } +} diff --git a/src/Section/Header.php b/src/Section/Header.php new file mode 100644 index 0000000000..6067945b1a --- /dev/null +++ b/src/Section/Header.php @@ -0,0 +1,299 @@ +_headerCount = $sectionCount; + } + + /** + * Add a Text Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new Text($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add TextBreak + * + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + */ + public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); + } + } + + /** + * Create a new TextRun + * + * @return PhpOffice\PhpWord\Section\TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Add a Table Element + * + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Table + */ + public function addTable($style = null) + { + $table = new Table('header', $this->_headerCount, $style); + $this->_elementCollection[] = $table; + return $table; + } + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Image + */ + public function addImage($src, $style = null) + { + $image = new Image($src, $style); + + if (!is_null($image->getSource())) { + $rID = Media::addHeaderMediaElement($this->_headerCount, $src); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + throw new Exception('Src does not exist or invalid image type.'); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PhpOffice\PhpWord\Section\MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + $rID = Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + throw new Exception('Unsupported image type.'); + } + } + + /** + * Add a PreserveText Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\Footer\PreserveText + */ + public function addPreserveText($text, $styleFont = null, $styleParagraph = null) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $ptext = new PreserveText($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $ptext; + return $ptext; + } + + /** + * Add a Watermark Element + * + * @param string $src + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Image + */ + public function addWatermark($src, $style = null) + { + $image = new Image($src, $style, true); + + if (!is_null($image->getSource())) { + $rID = Media::addHeaderMediaElement($this->_headerCount, $src); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + throw new Exception('Src does not exist or invalid image type.'); + } + } + + /** + * Get Header Relation ID + */ + public function getRelationId() + { + return $this->_rId; + } + + /** + * Set Header Relation ID + * + * @param int $rId + */ + public function setRelationId($rId) + { + $this->_rId = $rId; + } + + /** + * Get all Header Elements + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Header Count + */ + public function getHeaderCount() + { + return $this->_headerCount; + } + + /** + * Get Header Type + */ + public function getType() + { + return $this->_type; + } + + /** + * Reset back to default + */ + public function resetType() + { + return $this->_type = self::AUTO; + } + + /** + * First page only header + */ + public function firstPage() + { + return $this->_type = self::FIRST; + } + + /** + * Even numbered Pages only + */ + public function evenPage() + { + return $this->_type = self::EVEN; + } +} diff --git a/src/Section/Image.php b/src/Section/Image.php new file mode 100644 index 0000000000..8762e8ca90 --- /dev/null +++ b/src/Section/Image.php @@ -0,0 +1,177 @@ +_src = $src; + $this->_isWatermark = $isWatermark; + $this->_style = new PhpOffice\PhpWord\Style\Image(); + + if (!is_null($style) && is_array($style)) { + foreach ($style as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_style->setStyleValue($key, $value); + } + } + + if (isset($style['wrappingStyle'])) { + $this->_style->setWrappingStyle($style['wrappingStyle']); + } + + if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { + $imgData = getimagesize($this->_src); + $this->_style->setWidth($imgData[0]); + $this->_style->setHeight($imgData[1]); + } + } + + /** + * Get Image style + * + * @return PhpOffice\PhpWord\Style\Image + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Get Image Relation ID + * + * @return int + */ + public function getRelationId() + { + return $this->_rId; + } + + /** + * Set Image Relation ID + * + * @param int $rId + */ + public function setRelationId($rId) + { + $this->_rId = $rId; + } + + /** + * Get Image Source + * + * @return string + */ + public function getSource() + { + return $this->_src; + } + + /** + * Get Image Media ID + * + * @return string + */ + public function getMediaId() + { + return md5($this->_src); + } + + /** + * Get IsWatermark + * + * @return int + */ + public function getIsWatermark() + { + return $this->_isWatermark; + } + + /** + * Set IsWatermark + * + * @param bool $pValue + */ + public function setIsWatermark($pValue) + { + $this->_isWatermark = $pValue; + } +} diff --git a/src/Section/Link.php b/src/Section/Link.php new file mode 100644 index 0000000000..5c3cc9fedd --- /dev/null +++ b/src/Section/Link.php @@ -0,0 +1,174 @@ +_linkSrc = $linkSrc; + $this->_linkName = $linkName; + + // Set font style + if (is_array($styleFont)) { + $this->_styleFont = new Font('text'); + + foreach ($styleFont as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_styleFont->setStyleValue($key, $value); + } + } else { + $this->_styleFont = $styleFont; + } + + // Set paragraph style + if (is_array($styleParagraph)) { + $this->_styleParagraph = new Paragraph(); + + foreach ($styleParagraph as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_styleParagraph->setStyleValue($key, $value); + } + } else { + $this->_styleParagraph = $styleParagraph; + } + + return $this; + } + + /** + * Get Link Relation ID + * + * @return int + */ + public function getRelationId() + { + return $this->_rId; + } + + /** + * Set Link Relation ID + * + * @param int $rId + */ + public function setRelationId($rId) + { + $this->_rId = $rId; + } + + /** + * Get Link source + * + * @return string + */ + public function getLinkSrc() + { + return $this->_linkSrc; + } + + /** + * Get Link name + * + * @return string + */ + public function getLinkName() + { + return $this->_linkName; + } + + /** + * Get Text style + * + * @return PhpOffice\PhpWord\Style\Font + */ + public function getFontStyle() + { + return $this->_styleFont; + } + + /** + * Get Paragraph style + * + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function getParagraphStyle() + { + return $this->_styleParagraph; + } +} diff --git a/src/Section/ListItem.php b/src/Section/ListItem.php new file mode 100644 index 0000000000..2aaf4c34dd --- /dev/null +++ b/src/Section/ListItem.php @@ -0,0 +1,101 @@ +_style = new PhpOffice\PhpWord\Style\ListItem(); + $this->_textObject = new Text($text, $styleFont, $styleParagraph); + $this->_depth = $depth; + + if (!is_null($styleList) && is_array($styleList)) { + foreach ($styleList as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_style->setStyleValue($key, $value); + } + } + } + + /** + * Get ListItem style + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Get ListItem TextRun + */ + public function getTextObject() + { + return $this->_textObject; + } + + /** + * Get ListItem depth + */ + public function getDepth() + { + return $this->_depth; + } +} diff --git a/src/Section/MemoryImage.php b/src/Section/MemoryImage.php new file mode 100644 index 0000000000..4d81ee87bd --- /dev/null +++ b/src/Section/MemoryImage.php @@ -0,0 +1,233 @@ +_imageType = $imgData['mime']; + + $_supportedImageTypes = array('image/jpeg', 'image/gif', 'image/png'); + + if (in_array($this->_imageType, $_supportedImageTypes)) { + $this->_src = $src; + $this->_style = new Image(); + + if (!is_null($style) && is_array($style)) { + foreach ($style as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_style->setStyleValue($key, $value); + } + } + + if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { + $this->_style->setWidth($imgData[0]); + $this->_style->setHeight($imgData[1]); + } + + $this->_setFunctions(); + } + } + + /** + * Set Functions + */ + private function _setFunctions() + { + switch ($this->_imageType) { + case 'image/png': + $this->_imageCreateFunc = 'imagecreatefrompng'; + $this->_imageFunc = 'imagepng'; + $this->_imageExtension = 'png'; + break; + case 'image/gif': + $this->_imageCreateFunc = 'imagecreatefromgif'; + $this->_imageFunc = 'imagegif'; + $this->_imageExtension = 'gif'; + break; + case 'image/jpeg': + case 'image/jpg': + $this->_imageCreateFunc = 'imagecreatefromjpeg'; + $this->_imageFunc = 'imagejpeg'; + $this->_imageExtension = 'jpg'; + break; + } + } + + /** + * Get Image style + * + * @return PhpOffice\PhpWord\Style\Image + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Get Image Relation ID + * + * @return int + */ + public function getRelationId() + { + return $this->_rId; + } + + /** + * Set Image Relation ID + * + * @param int $rId + */ + public function setRelationId($rId) + { + $this->_rId = $rId; + } + + /** + * Get Image Source + * + * @return string + */ + public function getSource() + { + return $this->_src; + } + + /** + * Get Image Media ID + * + * @return string + */ + public function getMediaId() + { + return md5($this->_src); + } + + /** + * Get Image Type + * + * @return string + */ + public function getImageType() + { + return $this->_imageType; + } + + /** + * Get Image Create Function + * + * @return string + */ + public function getImageCreateFunction() + { + return $this->_imageCreateFunc; + } + + /** + * Get Image Function + * + * @return string + */ + public function getImageFunction() + { + return $this->_imageFunc; + } + + /** + * Get Image Extension + * + * @return string + */ + public function getImageExtension() + { + return $this->_imageExtension; + } +} diff --git a/src/Section/Object.php b/src/Section/Object.php new file mode 100644 index 0000000000..2569478a8c --- /dev/null +++ b/src/Section/Object.php @@ -0,0 +1,179 @@ +_src = $src; + $this->_style = new Image(); + + if (!is_null($style) && is_array($style)) { + foreach ($style as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_style->setStyleValue($key, $value); + } + } + + return $this; + } else { + return false; + } + } + + /** + * Get Image style + * + * @return PhpOffice\PhpWord\Style\Image + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Get Source + * + * @return string + */ + public function getSource() + { + return $this->_src; + } + + /** + * Get Object Relation ID + * + * @return int + */ + public function getRelationId() + { + return $this->_rId; + } + + /** + * Set Object Relation ID + * + * @param int $rId + */ + public function setRelationId($rId) + { + $this->_rId = $rId; + } + + /** + * Get Image Relation ID + * + * @return int + */ + public function getImageRelationId() + { + return $this->_rIdImg; + } + + /** + * Set Image Relation ID + * + * @param int $rId + */ + public function setImageRelationId($rId) + { + $this->_rIdImg = $rId; + } + + /** + * Get Object ID + * + * @return int + */ + public function getObjectId() + { + return $this->_objId; + } + + /** + * Set Object ID + * + * @param int $objId + */ + public function setObjectId($objId) + { + $this->_objId = $objId; + } +} diff --git a/src/Section/PageBreak.php b/src/Section/PageBreak.php new file mode 100644 index 0000000000..ebf7f31ff3 --- /dev/null +++ b/src/Section/PageBreak.php @@ -0,0 +1,38 @@ +_orientation = null; + $this->_marginTop = 1418; + $this->_marginLeft = 1418; + $this->_marginRight = 1418; + $this->_marginBottom = 1134; + $this->_pageSizeW = $this->_defaultPageSizeW; + $this->_pageSizeH = $this->_defaultPageSizeH; + $this->_borderTopSize = null; + $this->_borderTopColor = null; + $this->_borderLeftSize = null; + $this->_borderLeftColor = null; + $this->_borderRightSize = null; + $this->_borderRightColor = null; + $this->_borderBottomSize = null; + $this->_borderBottomColor = null; + $this->headerHeight = 720; // set default header and footer to 720 twips (.5 inches) + $this->footerHeight = 720; + $this->_colsNum = 1; + $this->_colsSpace = 720; + $this->_breakType = null; + } + + /** + * Set Setting Value + * + * @param string $key + * @param string $value + */ + public function setSettingValue($key, $value) + { + if ($key == '_orientation' && $value == 'landscape') { + $this->setLandscape(); + } elseif ($key == '_orientation' && is_null($value)) { + $this->setPortrait(); + } elseif ($key == '_borderSize') { + $this->setBorderSize($value); + } elseif ($key == '_borderColor') { + $this->setBorderColor($value); + } else { + $this->$key = $value; + } + } + + /** + * Get Margin Top + * + * @return int + */ + public function getMarginTop() + { + return $this->_marginTop; + } + + /** + * Set Margin Top + * + * @param int $pValue + */ + public function setMarginTop($pValue = '') + { + $this->_marginTop = $pValue; + return $this; + } + + /** + * Get Margin Left + * + * @return int + */ + public function getMarginLeft() + { + return $this->_marginLeft; + } + + /** + * Set Margin Left + * + * @param int $pValue + */ + public function setMarginLeft($pValue = '') + { + $this->_marginLeft = $pValue; + return $this; + } + + /** + * Get Margin Right + * + * @return int + */ + public function getMarginRight() + { + return $this->_marginRight; + } + + /** + * Set Margin Right + * + * @param int $pValue + */ + public function setMarginRight($pValue = '') + { + $this->_marginRight = $pValue; + return $this; + } + + /** + * Get Margin Bottom + * + * @return int + */ + public function getMarginBottom() + { + return $this->_marginBottom; + } + + /** + * Set Margin Bottom + * + * @param int $pValue + */ + public function setMarginBottom($pValue = '') + { + $this->_marginBottom = $pValue; + return $this; + } + + /** + * Set Landscape Orientation + */ + public function setLandscape() + { + $this->_orientation = 'landscape'; + $this->_pageSizeW = $this->_defaultPageSizeH; + $this->_pageSizeH = $this->_defaultPageSizeW; + } + + /** + * Set Portrait Orientation + */ + public function setPortrait() + { + $this->_orientation = null; + $this->_pageSizeW = $this->_defaultPageSizeW; + $this->_pageSizeH = $this->_defaultPageSizeH; + } + + /** + * Get Page Size Width + * + * @return int + */ + public function getPageSizeW() + { + return $this->_pageSizeW; + } + + /** + * Get Page Size Height + * + * @return int + */ + public function getPageSizeH() + { + return $this->_pageSizeH; + } + + /** + * Get Page Orientation + * + * @return string + */ + public function getOrientation() + { + return $this->_orientation; + } + + /** + * Set Border Size + * + * @param int $pValue + */ + public function setBorderSize($pValue = null) + { + $this->_borderTopSize = $pValue; + $this->_borderLeftSize = $pValue; + $this->_borderRightSize = $pValue; + $this->_borderBottomSize = $pValue; + } + + /** + * Get Border Size + * + * @return array + */ + public function getBorderSize() + { + $t = $this->getBorderTopSize(); + $l = $this->getBorderLeftSize(); + $r = $this->getBorderRightSize(); + $b = $this->getBorderBottomSize(); + + return array($t, $l, $r, $b); + } + + /** + * Set Border Color + * + * @param string $pValue + */ + public function setBorderColor($pValue = null) + { + $this->_borderTopColor = $pValue; + $this->_borderLeftColor = $pValue; + $this->_borderRightColor = $pValue; + $this->_borderBottomColor = $pValue; + } + + /** + * Get Border Color + * + * @return array + */ + public function getBorderColor() + { + $t = $this->getBorderTopColor(); + $l = $this->getBorderLeftColor(); + $r = $this->getBorderRightColor(); + $b = $this->getBorderBottomColor(); + + 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 + * + * @return int + */ + 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 + * + * @return string + */ + 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 + * + * @return int + */ + 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 + * + * @return string + */ + 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 + * + * @return int + */ + 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 + * + * @return string + */ + 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 + * + * @return int + */ + 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 + * + * @return string + */ + public function getBorderBottomColor() + { + return $this->_borderBottomColor; + } + + /** + * @param null|int $pageNumberingStart + * @return $this + */ + public function setPageNumberingStart($pageNumberingStart = null) + { + $this->pageNumberingStart = $pageNumberingStart; + return $this; + } + + /** + * @return null|int + */ + public function getPageNumberingStart() + { + return $this->pageNumberingStart; + } + + /** + * Get Header Height + * + * @return int + */ + public function getHeaderHeight() + { + return $this->headerHeight; + } + + /** + * Set Header Height + * + * @param int $pValue + */ + public function setHeaderHeight($pValue = '') + { + if (!is_numeric($pValue)) { + $pValue = 720; + } + $this->headerHeight = $pValue; + return $this; + } + + /** + * Get Footer Height + * + * @return int + */ + public function getFooterHeight() + { + return $this->footerHeight; + } + + /** + * Set Footer Height + * + * @param int $pValue + */ + public function setFooterHeight($pValue = '') + { + if (!is_numeric($pValue)) { + $pValue = 720; + } + $this->footerHeight = $pValue; + return $this; + } + + /** + * Set Section Columns Count + * + * @param int $pValue + */ + public function setColsNum($pValue = '') + { + if (!is_numeric($pValue)) { + $pValue = 1; + } + $this->_colsNum = $pValue; + return $this; + } + + /** + * Get Section Columns Count + * + * @return int + */ + public function getColsNum() + { + return $this->_colsNum; + } + + /** + * Set Section Space Between Columns + * + * @param int $pValue + */ + public function setColsSpace($pValue = '') + { + if (!is_numeric($pValue)) { + $pValue = 720; + } + $this->_colsSpace = $pValue; + return $this; + } + + /** + * Get Section Space Between Columns + * + * @return int + */ + public function getColsSpace() + { + return $this->_colsSpace; + } + + /** + * Set Break Type + * + * @param string $pValue + */ + public function setBreakType($pValue = null) + { + $this->_breakType = $pValue; + return $this; + } + + /** + * Get Break Type + * + * @return string + */ + public function getBreakType() + { + return $this->_breakType; + } +} diff --git a/src/Section/Table.php b/src/Section/Table.php new file mode 100644 index 0000000000..a06b41acca --- /dev/null +++ b/src/Section/Table.php @@ -0,0 +1,163 @@ +_insideOf = $insideOf; + $this->_pCount = $pCount; + + if (!is_null($style)) { + if (is_array($style)) { + $this->_style = new PhpOffice\PhpWord\Style\Table(); + + foreach ($style as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_style->setStyleValue($key, $value); + } + } else { + $this->_style = $style; + } + } + } + + /** + * Add a row + * + * @param int $height + */ + public function addRow($height = null, $style = null) + { + $row = new Row($this->_insideOf, $this->_pCount, $height, $style); + $this->_rows[] = $row; + return $row; + } + + /** + * Add a cell + * + * @param int $width + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Table\Cell + */ + public function addCell($width = null, $style = null) + { + $i = count($this->_rows) - 1; + $cell = $this->_rows[$i]->addCell($width, $style); + return $cell; + } + + /** + * Get all rows + * + * @return array + */ + public function getRows() + { + return $this->_rows; + } + + /** + * Get table style + * + * @return PhpOffice\PhpWord\Style\Table + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Set table width + * + * @var int $width + */ + public function setWidth($width) + { + $this->_width = $width; + } + + /** + * Get table width + * + * @return int + */ + public function getWidth() + { + return $this->_width; + } +} diff --git a/src/Section/Table/Cell.php b/src/Section/Table/Cell.php new file mode 100644 index 0000000000..0088ceb00e --- /dev/null +++ b/src/Section/Table/Cell.php @@ -0,0 +1,350 @@ +_insideOf = $insideOf; + $this->_pCount = $pCount; + $this->_width = $width; + $this->_style = new PhpOffice\PhpWord\Style\Cell(); + + if (!is_null($style)) { + if (is_array($style)) { + foreach ($style as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_style->setStyleValue($key, $value); + } + } else { + $this->_style = $style; + } + } + } + + /** + * Add a Text Element + * + * @param string $text + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new Text($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Link + */ + public function addLink($linkSrc, $linkName = null, $style = null) + { + if ($this->_insideOf == 'section') { + if (!String::IsUTF8($linkSrc)) { + $linkSrc = utf8_encode($linkSrc); + } + if (!is_null($linkName)) { + if (!String::IsUTF8($linkName)) { + $linkName = utf8_encode($linkName); + } + } + + $link = new Link($linkSrc, $linkName, $style); + $rID = Media::addSectionLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } else { + throw new Exception('Unsupported Link header / footer reference'); + return false; + } + } + + /** + * Add TextBreak + * + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + */ + public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); + } + } + + /** + * Add a ListItem Element + * + * @param string $text + * @param int $depth + * @param mixed $styleText + * @param mixed $styleList + * @return PhpOffice\PhpWord\Section\ListItem + */ + public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $listItem = new ListItem($text, $depth, $styleText, $styleList); + $this->_elementCollection[] = $listItem; + return $listItem; + } + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Image + */ + public function addImage($src, $style = null) + { + $image = new Image($src, $style); + + if (!is_null($image->getSource())) { + if ($this->_insideOf == 'section') { + $rID = Media::addSectionMediaElement($src, 'image'); + } elseif ($this->_insideOf == 'header') { + $rID = Media::addHeaderMediaElement($this->_pCount, $src); + } elseif ($this->_insideOf == 'footer') { + $rID = Media::addFooterMediaElement($this->_pCount, $src); + } + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + throw new Exception('Source does not exist or unsupported image type.'); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PhpOffice\PhpWord\Section\MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + if ($this->_insideOf == 'section') { + $rID = Media::addSectionMediaElement($link, 'image', $memoryImage); + } elseif ($this->_insideOf == 'header') { + $rID = Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); + } elseif ($this->_insideOf == 'footer') { + $rID = Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); + } + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + throw new Exception('Unsupported image type.'); + } + } + + /** + * Add a OLE-Object Element + * + * @param string $src + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Object + */ + public function addObject($src, $style = null) + { + $object = new Object($src, $style); + + if (!is_null($object->getSource())) { + $inf = pathinfo($src); + $ext = $inf['extension']; + if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { + $ext = substr($ext, 0, -1); + } + + $iconSrc = \PHPWORD_BASE_DIR . '_staticDocParts/'; + if (!file_exists($iconSrc . '_' . $ext . '.png')) { + $iconSrc = $iconSrc . '_default.png'; + } else { + $iconSrc .= '_' . $ext . '.png'; + } + + $rIDimg = Media::addSectionMediaElement($iconSrc, 'image'); + $data = Media::addSectionMediaElement($src, 'oleObject'); + $rID = $data[0]; + $objectId = $data[1]; + + $object->setRelationId($rID); + $object->setObjectId($objectId); + $object->setImageRelationId($rIDimg); + + $this->_elementCollection[] = $object; + return $object; + } else { + throw new Exception('Source does not exist or unsupported object type.'); + } + } + + /** + * Add a PreserveText Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PhpOffice\PhpWord\Section\Footer\PreserveText + */ + public function addPreserveText($text, $styleFont = null, $styleParagraph = null) + { + if ($this->_insideOf == 'footer' || $this->_insideOf == 'header') { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $ptext = new PreserveText($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $ptext; + return $ptext; + } else { + throw new Exception('addPreserveText only supported in footer/header.'); + } + } + + /** + * Create a new TextRun + * + * @return PhpOffice\PhpWord\Section\TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Get all Elements + * + * @return array + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Cell Style + * + * @return PhpOffice\PhpWord\Style\Cell + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Get Cell width + * + * @return int + */ + public function getWidth() + { + return $this->_width; + } +} diff --git a/src/Section/Table/Row.php b/src/Section/Table/Row.php new file mode 100644 index 0000000000..de9822b34f --- /dev/null +++ b/src/Section/Table/Row.php @@ -0,0 +1,139 @@ +_insideOf = $insideOf; + $this->_pCount = $pCount; + $this->_height = $height; + $this->_style = new PhpOffice\PhpWord\Style\Row(); + + if (!is_null($style)) { + if (is_array($style)) { + + foreach ($style as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_style->setStyleValue($key, $value); + } + } + } + } + + /** + * Add a cell + * + * @param int $width + * @param mixed $style + * @return PhpOffice\PhpWord\Section\Table\Cell + */ + public function addCell($width = null, $style = null) + { + $cell = new Cell($this->_insideOf, $this->_pCount, $width, $style); + $this->_cells[] = $cell; + return $cell; + } + + /** + * Get all cells + * + * @return array + */ + public function getCells() + { + return $this->_cells; + } + + /** + * Get row style + * + * @return PhpOffice\PhpWord\Style\Row + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Get row height + * + * @return int + */ + public function getHeight() + { + return $this->_height; + } +} diff --git a/src/Section/Text.php b/src/Section/Text.php new file mode 100644 index 0000000000..3e51bc8679 --- /dev/null +++ b/src/Section/Text.php @@ -0,0 +1,154 @@ +setText($text); + $paragraphStyle = $this->setParagraphStyle($paragraphStyle); + $this->setFontStyle($fontStyle, $paragraphStyle); + } + + /** + * Set Text style + * + * @param null|array|PhpOffice\PhpWord\Style\Font $style + * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @return PhpOffice\PhpWord\Style\Font + */ + public function setFontStyle($style = null, $paragraphStyle = null) + { + if ($style instanceof Font) { + $this->fontStyle = $style; + $this->setParagraphStyle($paragraphStyle); + } elseif (is_array($style)) { + $this->fontStyle = new Font('text', $paragraphStyle); + $this->fontStyle->setArrayStyle($style); + } elseif (null === $style) { + $this->fontStyle = new Font('text', $paragraphStyle); + } else { + $this->fontStyle = $style; + $this->setParagraphStyle($paragraphStyle); + } + return $this->fontStyle; + } + + /** + * Get Text style + * + * @return PhpOffice\PhpWord\Style\Font + */ + public function getFontStyle() + { + return $this->fontStyle; + } + + /** + * Set Paragraph style + * + * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style + * @return null|PhpOffice\PhpWord\Style\Paragraph + */ + public function setParagraphStyle($style = null) + { + if (is_array($style)) { + $this->paragraphStyle = new Paragraph; + $this->paragraphStyle->setArrayStyle($style); + } elseif ($style instanceof Paragraph) { + $this->paragraphStyle = $style; + } elseif (null === $style) { + $this->paragraphStyle = new Paragraph; + } else { + $this->paragraphStyle = $style; + } + return $this->paragraphStyle; + } + + /** + * Get Paragraph style + * + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function getParagraphStyle() + { + return $this->paragraphStyle; + } + + /** + * @param string $text + * @return $this + */ + public function setText($text) + { + $this->text = $text; + return $this; + } + + /** + * Get Text content + * + * @return string + */ + public function getText() + { + return $this->text; + } +} diff --git a/src/Section/TextBreak.php b/src/Section/TextBreak.php new file mode 100644 index 0000000000..cd296c745a --- /dev/null +++ b/src/Section/TextBreak.php @@ -0,0 +1,122 @@ +setParagraphStyle($paragraphStyle); + } + if (!is_null($fontStyle)) { + $this->setFontStyle($fontStyle, $paragraphStyle); + } + } + + /** + * Set Text style + * + * @param null|array|PhpOffice\PhpWord\Style\Font $style + * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @return PhpOffice\PhpWord\Style\Font + */ + public function setFontStyle($style = null, $paragraphStyle = null) + { + if ($style instanceof Font) { + $this->fontStyle = $style; + $this->setParagraphStyle($paragraphStyle); + } elseif (is_array($style)) { + $this->fontStyle = new Font('text', $paragraphStyle); + $this->fontStyle->setArrayStyle($style); + } else { + $this->fontStyle = $style; + $this->setParagraphStyle($paragraphStyle); + } + return $this->fontStyle; + } + + /** + * Get Text style + * + * @return PhpOffice\PhpWord\Style\Font + */ + public function getFontStyle() + { + return $this->fontStyle; + } + + /** + * Set Paragraph style + * + * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style + * @return null|PhpOffice\PhpWord\Style\Paragraph + */ + public function setParagraphStyle($style = null) + { + if (is_array($style)) { + $this->paragraphStyle = new Paragraph; + $this->paragraphStyle->setArrayStyle($style); + } elseif ($style instanceof Paragraph) { + $this->paragraphStyle = $style; + } else { + $this->paragraphStyle = $style; + } + return $this->paragraphStyle; + } + + /** + * Get Paragraph style + * + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function getParagraphStyle() + { + return $this->paragraphStyle; + } +} \ No newline at end of file diff --git a/src/Section/TextRun.php b/src/Section/TextRun.php new file mode 100644 index 0000000000..4cee06d60e --- /dev/null +++ b/src/Section/TextRun.php @@ -0,0 +1,184 @@ +_elementCollection = array(); + + // Set paragraph style + if (is_array($styleParagraph)) { + $this->_styleParagraph = new Paragraph(); + + foreach ($styleParagraph as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_styleParagraph->setStyleValue($key, $value); + } + } else { + $this->_styleParagraph = $styleParagraph; + } + } + + + /** + * Add a Text Element + * + * @var string $text + * @var mixed $styleFont + * @return PhpOffice\PhpWord\Section\Text + */ + public function addText($text = null, $styleFont = null) + { + if (!String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new Text($text, $styleFont); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $styleFont + * @return PhpOffice\PhpWord\Section\Link + */ + public function addLink($linkSrc, $linkName = null, $styleFont = null) + { + $linkSrc = utf8_encode($linkSrc); + if (!is_null($linkName)) { + $linkName = utf8_encode($linkName); + } + + $link = new Link($linkSrc, $linkName, $styleFont); + $rID = Media::addSectionLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } + + /** + * Add a Image Element + * + * @param string $imageSrc + * @param mixed $styleFont + * @return PhpOffice\PhpWord\Section\Image + */ + public function addImage($imageSrc, $style = null) + { + $image = new Image($imageSrc, $style); + + if (!is_null($image->getSource())) { + $rID = Media::addSectionMediaElement($imageSrc, 'image'); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + throw new Exception('Source does not exist or unsupported image type.'); + } + } + + /** + * Add TextBreak + * + * @param int $count + * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + */ + public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); + } + } + + /** + * Create a new Footnote Element + * + * @param string $text + * @return PhpOffice\PhpWord\Section\Footnote + */ + public function createFootnote($styleParagraph = null) + { + $footnote = new PhpOffice\PhpWord\Section\Footnote($styleParagraph); + $refID = PhpOffice\PhpWord\Footnote::addFootnoteElement($footnote); + $footnote->setReferenceId($refID); + $this->_elementCollection[] = $footnote; + return $footnote; + } + + /** + * Get TextRun content + * + * @return string + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Paragraph style + * + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function getParagraphStyle() + { + return $this->_styleParagraph; + } +} \ No newline at end of file diff --git a/src/Section/Title.php b/src/Section/Title.php new file mode 100644 index 0000000000..fdc31ac885 --- /dev/null +++ b/src/Section/Title.php @@ -0,0 +1,145 @@ +_style = $style; + } + + $this->_text = $text; + $this->_depth = $depth; + + return $this; + } + + /** + * Set Anchor + * + * @var int $anchor + */ + public function setAnchor($anchor) + { + $this->_anchor = $anchor; + } + + /** + * Get Anchor + * + * @return int + */ + public function getAnchor() + { + return $this->_anchor; + } + + /** + * Set Bookmark ID + * + * @var int $bookmarkId + */ + public function setBookmarkId($bookmarkId) + { + $this->_bookmarkId = $bookmarkId; + } + + /** + * Get Anchor + * + * @return int + */ + public function getBookmarkId() + { + return $this->_bookmarkId; + } + + /** + * Get Title Text content + * + * @return string + */ + public function getText() + { + return $this->_text; + } + + /** + * Get Title style + * + * @return string + */ + public function getStyle() + { + return $this->_style; + } +} diff --git a/src/Settings.php b/src/Settings.php new file mode 100644 index 0000000000..8eb3a60f9a --- /dev/null +++ b/src/Settings.php @@ -0,0 +1,63 @@ + 0) { + unset($pathArray[$i]); + unset($pathArray[$i - 1]); + break; + } + } + } + $returnValue = implode('/', $pathArray); + } + + // Return + return $returnValue; + } +} diff --git a/src/Shared/Font.php b/src/Shared/Font.php new file mode 100644 index 0000000000..adee50ada4 --- /dev/null +++ b/src/Shared/Font.php @@ -0,0 +1,90 @@ +) + * element or in the shared string element. + * + * @param string $value Value to unescape + * @return string + */ + public static function ControlCharacterOOXML2PHP($value = '') + { + if (empty(self::$_controlCharacters)) { + self::_buildControlCharacters(); + } + + return str_replace(array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value); + } + + /** + * Convert from PHP control character to OpenXML escaped control character + * + * Excel 2007 team: + * ---------------- + * That's correct, control characters are stored directly in the shared-strings table. + * We do encode characters that cannot be represented in XML using the following escape sequence: + * _xHHHH_ where H represents a hexadecimal character in the character's value... + * So you could end up with something like _x0008_ in a string (either in a cell value () + * element or in the shared string element. + * + * @param string $value Value to escape + * @return string + */ + public static function ControlCharacterPHP2OOXML($value = '') + { + if (empty(self::$_controlCharacters)) { + self::_buildControlCharacters(); + } + + return str_replace(array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value); + } + + /** + * Check if a string contains UTF-8 data + * + * @param string $value + * @return boolean + */ + public static function IsUTF8($value = '') + { + return $value === '' || preg_match('/^./su', $value) === 1; + } +} diff --git a/src/Shared/XMLWriter.php b/src/Shared/XMLWriter.php new file mode 100644 index 0000000000..2334997fa0 --- /dev/null +++ b/src/Shared/XMLWriter.php @@ -0,0 +1,155 @@ +_xmlWriter = new XMLWriter(); + + // Open temporary storage + if ($pTemporaryStorage == self::STORAGE_MEMORY) { + $this->_xmlWriter->openMemory(); + } else { + // Create temporary filename + $this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml'); + + // Open storage + if ($this->_xmlWriter->openUri($this->_tempFileName) === false) { + // Fallback to memory... + $this->_xmlWriter->openMemory(); + } + } + + // Set xml Compatibility + $compatibility = Settings::getCompatibility(); + if ($compatibility) { + $this->_xmlWriter->setIndent(false); + $this->_xmlWriter->setIndentString(''); + } else { + $this->_xmlWriter->setIndent(true); + $this->_xmlWriter->setIndentString(' '); + } + } + + /** + * Destructor + */ + public function __destruct() + { + // Desctruct XMLWriter + unset($this->_xmlWriter); + + // Unlink temporary files + if ($this->_tempFileName != '') { + @unlink($this->_tempFileName); + } + } + + /** + * Get written data + * + * @return $data + */ + public function getData() + { + if ($this->_tempFileName == '') { + return $this->_xmlWriter->outputMemory(true); + } else { + $this->_xmlWriter->flush(); + return file_get_contents($this->_tempFileName); + } + } + + /** + * Catch function calls (and pass them to internal XMLWriter) + * + * @param unknown_type $function + * @param unknown_type $args + */ + public function __call($function, $args) + { + try { + @call_user_func_array(array($this->_xmlWriter, $function), $args); + } catch (Exception $ex) { + // Do nothing! + } + } + + /** + * Fallback method for writeRaw, introduced in PHP 5.2 + * + * @param string $text + * @return string + */ + public function writeRaw($text) + { + if (isset($this->_xmlWriter) && is_object($this->_xmlWriter) && (method_exists($this->_xmlWriter, 'writeRaw'))) { + return $this->_xmlWriter->writeRaw($text); + } + + return $this->text($text); + } +} diff --git a/src/Shared/ZipStreamWrapper.php b/src/Shared/ZipStreamWrapper.php new file mode 100644 index 0000000000..4a8bac6c3f --- /dev/null +++ b/src/Shared/ZipStreamWrapper.php @@ -0,0 +1,183 @@ +_archive = new ZipArchive(); + $this->_archive->open($url['host']); + + $this->_fileNameInArchive = $url['fragment']; + $this->_position = 0; + $this->_data = $this->_archive->getFromName($this->_fileNameInArchive); + + return true; + } + + /** + * Stat stream + */ + public function stream_stat() + { + return $this->_archive->statName($this->_fileNameInArchive); + } + + /** + * Read stream + */ + public function stream_read($count) + { + $ret = substr($this->_data, $this->_position, $count); + $this->_position += strlen($ret); + return $ret; + } + + /** + * Tell stream + */ + public function stream_tell() + { + return $this->_position; + } + + /** + * EOF stream + */ + public function stream_eof() + { + return $this->_position >= strlen($this->_data); + } + + /** + * Seek stream + */ + public function stream_seek($offset, $whence) + { + switch ($whence) { + case SEEK_SET: + if ($offset < strlen($this->_data) && $offset >= 0) { + $this->_position = $offset; + return true; + } else { + return false; + } + break; + + case SEEK_CUR: + if ($offset >= 0) { + $this->_position += $offset; + return true; + } else { + return false; + } + break; + + case SEEK_END: + if (strlen($this->_data) + $offset >= 0) { + $this->_position = strlen($this->_data) + $offset; + return true; + } else { + return false; + } + break; + + default: + return false; + } + } +} \ No newline at end of file diff --git a/src/Style.php b/src/Style.php new file mode 100644 index 0000000000..387dc468d1 --- /dev/null +++ b/src/Style.php @@ -0,0 +1,161 @@ + $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $style->setStyleValue($key, $value); + } + + self::$_styleElements[$styleName] = $style; + } + } + + /** + * @param string $styleName + * @param array $styleFont + * @param array $styleParagraph + */ + public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) + { + if (!array_key_exists($styleName, self::$_styleElements)) { + $font = new Font('text', $styleParagraph); + foreach ($styleFont as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $font->setStyleValue($key, $value); + } + self::$_styleElements[$styleName] = $font; + } + } + + /** + * @param string $styleName + * @param array $styles + */ + public static function addLinkStyle($styleName, $styles) + { + if (!array_key_exists($styleName, self::$_styleElements)) { + $style = new Font('link'); + foreach ($styles as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $style->setStyleValue($key, $value); + } + + self::$_styleElements[$styleName] = $style; + } + } + + /** + * @param string $styleName + * @param array $styles + */ + public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null) + { + if (!array_key_exists($styleName, self::$_styleElements)) { + $style = new TableFull($styleTable, $styleFirstRow); + + self::$_styleElements[$styleName] = $style; + } + } + + /** + * @param string $styleName + * @param array $styleFont + * @param array $styleParagraph + */ + public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) + { + $styleName = 'Heading_' . $titleCount; + if (!array_key_exists($styleName, self::$_styleElements)) { + $font = new Font('title', $styleParagraph); + foreach ($styleFont as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $font->setStyleValue($key, $value); + } + + self::$_styleElements[$styleName] = $font; + } + } + + /** + * @param array $styles Paragraph style definition + */ + public static function setDefaultParagraphStyle($styles) + { + self::addParagraphStyle('Normal', $styles); + } + + /** + * Get all styles + * + * @return PhpOffice\PhpWord\Style\Font[] + */ + public static function getStyles() + { + return self::$_styleElements; + } + + /** + * @param string + */ + public static function getStyle($styleName) + { + if (array_key_exists($styleName, self::$_styleElements)) { + return self::$_styleElements[$styleName]; + } else { + return null; + } + } +} \ No newline at end of file diff --git a/src/Style/Cell.php b/src/Style/Cell.php new file mode 100644 index 0000000000..23cd0c07d2 --- /dev/null +++ b/src/Style/Cell.php @@ -0,0 +1,343 @@ +_valign = null; + $this->_textDirection = null; + $this->_bgColor = null; + $this->_borderTopSize = null; + $this->_borderTopColor = null; + $this->_borderLeftSize = null; + $this->_borderLeftColor = null; + $this->_borderRightSize = null; + $this->_borderRightColor = null; + $this->_borderBottomSize = null; + $this->_borderBottomColor = null; + $this->_defaultBorderColor = '000000'; + } + + /** + * Set style value + * + * @var string $key + * @var mixed $value + */ + public function setStyleValue($key, $value) + { + if ($key == '_borderSize') { + $this->setBorderSize($value); + } elseif ($key == '_borderColor') { + $this->setBorderColor($value); + } else { + $this->$key = $value; + } + } + + public function getVAlign() + { + return $this->_valign; + } + + public function setVAlign($pValue = null) + { + $this->_valign = $pValue; + } + + public function getTextDirection() + { + return $this->_textDirection; + } + + public function setTextDirection($pValue = null) + { + $this->_textDirection = $pValue; + } + + public function getBgColor() + { + return $this->_bgColor; + } + + public function setBgColor($pValue = null) + { + $this->_bgColor = $pValue; + } + + public function setBorderSize($pValue = null) + { + $this->_borderTopSize = $pValue; + $this->_borderLeftSize = $pValue; + $this->_borderRightSize = $pValue; + $this->_borderBottomSize = $pValue; + } + + public function getBorderSize() + { + $t = $this->getBorderTopSize(); + $l = $this->getBorderLeftSize(); + $r = $this->getBorderRightSize(); + $b = $this->getBorderBottomSize(); + + return array($t, $l, $r, $b); + } + + public function setBorderColor($pValue = null) + { + $this->_borderTopColor = $pValue; + $this->_borderLeftColor = $pValue; + $this->_borderRightColor = $pValue; + $this->_borderBottomColor = $pValue; + } + + public function getBorderColor() + { + $t = $this->getBorderTopColor(); + $l = $this->getBorderLeftColor(); + $r = $this->getBorderRightColor(); + $b = $this->getBorderBottomColor(); + + return array($t, $l, $r, $b); + } + + public function setBorderTopSize($pValue = null) + { + $this->_borderTopSize = $pValue; + } + + public function getBorderTopSize() + { + return $this->_borderTopSize; + } + + public function setBorderTopColor($pValue = null) + { + $this->_borderTopColor = $pValue; + } + + public function getBorderTopColor() + { + return $this->_borderTopColor; + } + + public function setBorderLeftSize($pValue = null) + { + $this->_borderLeftSize = $pValue; + } + + public function getBorderLeftSize() + { + return $this->_borderLeftSize; + } + + public function setBorderLeftColor($pValue = null) + { + $this->_borderLeftColor = $pValue; + } + + public function getBorderLeftColor() + { + return $this->_borderLeftColor; + } + + public function setBorderRightSize($pValue = null) + { + $this->_borderRightSize = $pValue; + } + + public function getBorderRightSize() + { + return $this->_borderRightSize; + } + + public function setBorderRightColor($pValue = null) + { + $this->_borderRightColor = $pValue; + } + + public function getBorderRightColor() + { + return $this->_borderRightColor; + } + + + public function setBorderBottomSize($pValue = null) + { + $this->_borderBottomSize = $pValue; + } + + public function getBorderBottomSize() + { + return $this->_borderBottomSize; + } + + public function setBorderBottomColor($pValue = null) + { + $this->_borderBottomColor = $pValue; + } + + public function getBorderBottomColor() + { + return $this->_borderBottomColor; + } + + public function getDefaultBorderColor() + { + return $this->_defaultBorderColor; + } + + public function setGridSpan($pValue = null) + { + $this->_gridSpan = $pValue; + } + + public function getGridSpan() + { + return $this->_gridSpan; + } + + public function setVMerge($pValue = null) + { + $this->_vMerge = $pValue; + } + + public function getVMerge() + { + return $this->_vMerge; + } +} diff --git a/src/Style/Font.php b/src/Style/Font.php new file mode 100644 index 0000000000..7551200b95 --- /dev/null +++ b/src/Style/Font.php @@ -0,0 +1,544 @@ +_type = $type; + + if ($paragraphStyle instanceof Paragraph) { + $this->_paragraphStyle = $paragraphStyle; + } elseif (is_array($paragraphStyle)) { + $this->_paragraphStyle = new Paragraph; + $this->_paragraphStyle->setArrayStyle($paragraphStyle); + } else { + $this->_paragraphStyle = $paragraphStyle; + } + } + + /** + * @param array $style + * @return $this + */ + public function setArrayStyle(array $style = array()) + { + foreach ($style as $key => $value) { + if ($key === 'line-height') { + $this->setLineHeight($value); + null; + } elseif (substr($key, 0, 1) !== '_') { + $key = '_' . $key; + } + $this->setStyleValue($key, $value); + } + + return $this; + } + + /** + * Set style value + * + * @param string $key + * @param mixed $value + */ + public function setStyleValue($key, $value) + { + $method = 'set' . substr($key, 1); + if (method_exists($this, $method)) { + $this->$method($value); + } + } + + /** + * Get font name + * + * @return bool + */ + public function getName() + { + return $this->_name; + } + + /** + * Set font name + * + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setName($pValue = PhpWord::DEFAULT_FONT_NAME) + { + if (is_null($pValue) || $pValue == '') { + $pValue = PhpWord::DEFAULT_FONT_NAME; + } + $this->_name = $pValue; + return $this; + } + + + /** + * Get font size + * + * @return int|float + */ + public function getSize() + { + return $this->_size; + } + + /** + * Set font size + * + * @param int|float $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setSize($pValue = PhpWord::DEFAULT_FONT_SIZE) + { + if (!is_numeric($pValue)) { + $pValue = PhpWord::DEFAULT_FONT_SIZE; + } + $this->_size = $pValue; + return $this; + } + + /** + * Get bold + * + * @return bool + */ + public function getBold() + { + return $this->_bold; + } + + /** + * Set bold + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setBold($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_bold = $pValue; + return $this; + } + + /** + * Get italics + * + * @return bool + */ + public function getItalic() + { + return $this->_italic; + } + + /** + * Set italics + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setItalic($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_italic = $pValue; + return $this; + } + + /** + * Get superscript + * + * @return bool + */ + public function getSuperScript() + { + return $this->_superScript; + } + + /** + * Set superscript + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setSuperScript($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_superScript = $pValue; + $this->_subScript = !$pValue; + return $this; + } + + /** + * Get superscript + * + * @return bool + */ + public function getSubScript() + { + return $this->_subScript; + } + + /** + * Set subscript + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setSubScript($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_subScript = $pValue; + $this->_superScript = !$pValue; + return $this; + } + + /** + * Get underline + * + * @return string + */ + public function getUnderline() + { + return $this->_underline; + } + + /** + * Set underline + * + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setUnderline($pValue = self::UNDERLINE_NONE) + { + if ($pValue == '') { + $pValue = self::UNDERLINE_NONE; + } + $this->_underline = $pValue; + return $this; + } + + /** + * Get strikethrough + * + * @return bool + */ + public function getStrikethrough() + { + return $this->_strikethrough; + } + + /** + * Set strikethrough + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setStrikethrough($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_strikethrough = $pValue; + return $this; + } + + /** + * Get font color + * + * @return string + */ + public function getColor() + { + return $this->_color; + } + + /** + * Set font color + * + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setColor($pValue = PhpWord::DEFAULT_FONT_COLOR) + { + if (is_null($pValue) || $pValue == '') { + $pValue = PhpWord::DEFAULT_FONT_COLOR; + } + $this->_color = $pValue; + return $this; + } + + /** + * Get foreground/highlight color + * + * @return bool + */ + public function getFgColor() + { + return $this->_fgColor; + } + + /** + * Set foreground/highlight color + * + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setFgColor($pValue = null) + { + $this->_fgColor = $pValue; + return $this; + } + + /** + * Get style type + * + * @return string + */ + public function getStyleType() + { + return $this->_type; + } + + /** + * Get paragraph style + * + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function getParagraphStyle() + { + return $this->_paragraphStyle; + } + + /** + * Set the line height + * + * @param int|float|string $lineHeight + * @return $this + * @throws InvalidStyleException + */ + public function setLineHeight($lineHeight) + { + if (is_string($lineHeight)) { + $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); + } + + if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) { + throw new InvalidStyleException('Line height must be a valid number'); + } + + $this->lineHeight = $lineHeight; + $this->getParagraphStyle()->setLineHeight($lineHeight); + return $this; + } + + /** + * @return int|float + */ + public function getLineHeight() + { + return $this->lineHeight; + } + + /** + * Get Font Content Type + * + * @return bool + */ + public function getHint() + { + return $this->_hint; + } + + /** + * Set Font Content Type + * + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Font + */ + public function setHint($pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE) + { + if (is_null($pValue) || $pValue == '') { + $pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE; + } + $this->_hint = $pValue; + return $this; + } +} diff --git a/src/Style/Image.php b/src/Style/Image.php new file mode 100644 index 0000000000..fbc074bea7 --- /dev/null +++ b/src/Style/Image.php @@ -0,0 +1,175 @@ +_width = null; + $this->_height = null; + $this->_align = null; + $this->_marginTop = null; + $this->_marginLeft = null; + $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); + } + + public function setStyleValue($key, $value) + { + $this->$key = $value; + } + + public function getWidth() + { + return $this->_width; + } + + public function setWidth($pValue = null) + { + $this->_width = $pValue; + } + + public function getHeight() + { + return $this->_height; + } + + public function setHeight($pValue = null) + { + $this->_height = $pValue; + } + + public function getAlign() + { + return $this->_align; + } + + public function setAlign($pValue = null) + { + $this->_align = $pValue; + } + + /** + * Get Margin Top + * + * @return int + */ + public function getMarginTop() + { + return $this->_marginTop; + } + + /** + * Set Margin Top + * + * @param int $pValue + * @return $this + */ + public function setMarginTop($pValue = null) + { + $this->_marginTop = $pValue; + return $this; + } + + /** + * Get Margin Left + * + * @return int + */ + public function getMarginLeft() + { + return $this->_marginLeft; + } + + /** + * Set Margin Left + * + * @param int $pValue + * @return $this + */ + public function setMarginLeft($pValue = null) + { + $this->_marginLeft = $pValue; + return $this; + } + + /** + * @param string $wrappingStyle + * @throws InvalidArgumentException + * @return $this + */ + public function setWrappingStyle($wrappingStyle) + { + switch ($wrappingStyle) { + case self::WRAPPING_STYLE_BEHIND: + case self::WRAPPING_STYLE_INFRONT: + case self::WRAPPING_STYLE_INLINE: + case self::WRAPPING_STYLE_SQUARE: + case self::WRAPPING_STYLE_TIGHT: + $this->wrappingStyle = $wrappingStyle; + break; + default: + throw new InvalidArgumentException('Wrapping style does not exists'); + break; + } + return $this; + } + + /** + * @return string + */ + public function getWrappingStyle() + { + return $this->wrappingStyle; + } +} diff --git a/src/Style/ListItem.php b/src/Style/ListItem.php new file mode 100644 index 0000000000..458e08e8a0 --- /dev/null +++ b/src/Style/ListItem.php @@ -0,0 +1,80 @@ +_listType = self::TYPE_BULLET_FILLED; + } + + /** + * Set style value + * + * @param string $key + * @param string $value + */ + public function setStyleValue($key, $value) + { + $this->$key = $value; + } + + /** + * Set List Type + * + * @param int $pValue + */ + public function setListType($pValue = self::TYPE_BULLET_FILLED) + { + $this->_listType = $pValue; + } + + /** + * Get List Type + */ + public function getListType() + { + return $this->_listType; + } +} diff --git a/src/Style/Paragraph.php b/src/Style/Paragraph.php new file mode 100644 index 0000000000..87827448ea --- /dev/null +++ b/src/Style/Paragraph.php @@ -0,0 +1,508 @@ + $value) { + if ($key === 'line-height') { + null; + } elseif (substr($key, 0, 1) !== '_') { + $key = '_' . $key; + } + $this->setStyleValue($key, $value); + } + + return $this; + } + + /** + * Set Style value + * + * @param string $key + * @param mixed $value + */ + public function setStyleValue($key, $value) + { + if ($key == '_indent' || $key == '_hanging') { + $value = $value * 720; + } elseif ($key == '_spacing') { + $value += 240; // because line height of 1 matches 240 twips + } elseif ($key === 'line-height') { + $this->setLineHeight($value); + return; + } + $this->$key = $value; + $method = 'set' . substr($key, 1); + if (method_exists($this, $method)) { + $this->$method($value); + } + } + + /** + * Get Paragraph Alignment + * + * @return string + */ + public function getAlign() + { + return $this->_align; + } + + /** + * Set Paragraph Alignment + * + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setAlign($pValue = null) + { + if (strtolower($pValue) == 'justify') { + // justify becames both + $pValue = 'both'; + } + $this->_align = $pValue; + return $this; + } + + /** + * Get Space before Paragraph + * + * @return string + */ + public function getSpaceBefore() + { + return $this->_spaceBefore; + } + + /** + * Set Space before Paragraph + * + * @param int $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setSpaceBefore($pValue = null) + { + $this->_spaceBefore = $pValue; + return $this; + } + + /** + * Get Space after Paragraph + * + * @return string + */ + public function getSpaceAfter() + { + return $this->_spaceAfter; + } + + /** + * Set Space after Paragraph + * + * @param int $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setSpaceAfter($pValue = null) + { + $this->_spaceAfter = $pValue; + return $this; + } + + /** + * Get Spacing between breaks + * + * @return int + */ + public function getSpacing() + { + return $this->_spacing; + } + + /** + * Set Spacing between breaks + * + * @param int $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setSpacing($pValue = null) + { + $this->_spacing = $pValue; + return $this; + } + + /** + * Get indentation + * + * @return int + */ + public function getIndent() + { + return $this->_indent; + } + + /** + * Set indentation + * + * @param int $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setIndent($pValue = null) + { + $this->_indent = $pValue; + return $this; + } + + /** + * Get hanging + * + * @return int + */ + public function getHanging() + { + return $this->_hanging; + } + + /** + * Set hanging + * + * @param int $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setHanging($pValue = null) + { + $this->_hanging = $pValue; + return $this; + } + + /** + * Get tabs + * + * @return PhpOffice\PhpWord\Style\Tabs + */ + public function getTabs() + { + return $this->_tabs; + } + + /* + * Set tabs + * + * @param array $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setTabs($pValue = null) + { + if (is_array($pValue)) { + $this->_tabs = new Tabs($pValue); + } + return $this; + } + + /** + * Get parent style ID + * + * @return string + */ + public function getBasedOn() + { + return $this->_basedOn; + } + + /** + * Set parent style ID + * + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setBasedOn($pValue = 'Normal') + { + $this->_basedOn = $pValue; + return $this; + } + + /** + * Get style for next paragraph + * + * @return string + */ + public function getNext() + { + return $this->_next; + } + + /** + * Set style for next paragraph + * + * @param string $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setNext($pValue = null) + { + $this->_next = $pValue; + return $this; + } + + /** + * Get allow first/last line to display on a separate page setting + * + * @return bool + */ + public function getWidowControl() + { + return $this->_widowControl; + } + + /** + * Set keep paragraph with next paragraph setting + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setWidowControl($pValue = true) + { + if (!is_bool($pValue)) { + $pValue = true; + } + $this->_widowControl = $pValue; + return $this; + } + + /** + * Get keep paragraph with next paragraph setting + * + * @return bool + */ + public function getKeepNext() + { + return $this->_keepNext; + } + + /** + * Set keep paragraph with next paragraph setting + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setKeepNext($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_keepNext = $pValue; + return $this; + } + + /** + * Get keep all lines on one page setting + * + * @return bool + */ + public function getKeepLines() + { + return $this->_keepLines; + } + + /** + * Set keep all lines on one page setting + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setKeepLines($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_keepLines = $pValue; + return $this; + } + + /** + * Get start paragraph on next page setting + * + * @return bool + */ + public function getPageBreakBefore() + { + return $this->_pageBreakBefore; + } + + /** + * Set start paragraph on next page setting + * + * @param bool $pValue + * @return PhpOffice\PhpWord\Style\Paragraph + */ + public function setPageBreakBefore($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_pageBreakBefore = $pValue; + return $this; + } + + /** + * Set the line height + * + * @param int|float|string $lineHeight + * @return $this + * @throws InvalidStyleException + */ + public function setLineHeight($lineHeight) + { + if (is_string($lineHeight)) { + $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); + } + + if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) { + throw new InvalidStyleException('Line height must be a valid number'); + } + + $this->lineHeight = $lineHeight; + $this->setSpacing($lineHeight * self::LINE_HEIGHT); + return $this; + } + + /** + * @return int|float + */ + public function getLineHeight() + { + return $this->lineHeight; + } +} diff --git a/src/Style/Row.php b/src/Style/Row.php new file mode 100644 index 0000000000..5431dd201d --- /dev/null +++ b/src/Style/Row.php @@ -0,0 +1,88 @@ +$key = $value; + } + + public function setTblHeader($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_tblHeader = $pValue; + return $this; + } + + public function getTblHeader() + { + return $this->_tblHeader; + } + + public function setCantSplit($pValue = false) + { + if (!is_bool($pValue)) { + $pValue = false; + } + $this->_cantSplit = $pValue; + return $this; + } + + public function getCantSplit() + { + return $this->_cantSplit; + } +} diff --git a/src/Style/TOC.php b/src/Style/TOC.php new file mode 100644 index 0000000000..b7da10595c --- /dev/null +++ b/src/Style/TOC.php @@ -0,0 +1,139 @@ +_tabPos = 9062; + $this->_tabLeader = self::TABLEADER_DOT; + $this->_indent = 200; + } + + /** + * Get Tab Position + * + * @return int + */ + public function getTabPos() + { + return $this->_tabPos; + } + + /** + * Set Tab Position + * + * @param int $pValue + */ + public function setTabPos($pValue) + { + $this->_tabPos = $pValue; + } + + /** + * Get Tab Leader + * + * @return string + */ + public function getTabLeader() + { + return $this->_tabLeader; + } + + /** + * Set Tab Leader + * + * @param string $pValue + */ + public function setTabLeader($pValue = self::TABLEADER_DOT) + { + $this->_tabLeader = $pValue; + } + + /** + * Get Indent + * + * @return int + */ + public function getIndent() + { + return $this->_indent; + } + + /** + * Set Indent + * + * @param string $pValue + */ + public function setIndent($pValue) + { + $this->_indent = $pValue; + } + + /** + * Set style value + * + * @param string $key + * @param string $value + */ + public function setStyleValue($key, $value) + { + $this->$key = $value; + } +} diff --git a/src/Style/Tab.php b/src/Style/Tab.php new file mode 100644 index 0000000000..b9d949e904 --- /dev/null +++ b/src/Style/Tab.php @@ -0,0 +1,146 @@ +_val = (self::isStopType($val)) ? $val : 'clear'; + + // Default to 0 if the position is non-numeric + $this->_position = (is_numeric($position)) ? intval($position) : 0; + + // Default to NULL if no tab leader + $this->_leader = (self::isLeaderType($leader)) ? $leader : null; + } + + /** + * Creates the XML DOM for the instance of Tab. + * + * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter + */ + public function toXml(XMLWriter &$xmlWriter = null) + { + if (isset($xmlWriter)) { + $xmlWriter->startElement("w:tab"); + $xmlWriter->writeAttribute("w:val", $this->_val); + if (!is_null($this->_leader)) { + $xmlWriter->writeAttribute("w:leader", $this->_leader); + } + $xmlWriter->writeAttribute("w:pos", $this->_position); + $xmlWriter->endElement(); + } + } + + /** + * Test if attribute is a valid stop type. + * + * @param string $attribute + * @return bool True if it is; false otherwise. + */ + private static function isStopType($attribute) + { + return in_array($attribute, self::$_possibleStopTypes); + } + + /** + * Test if attribute is a valid leader type. + * + * @param string $attribute + * @return bool True if it is; false otherwise. + */ + private static function isLeaderType($attribute) + { + return in_array($attribute, self::$_possibleLeaders); + } +} diff --git a/src/Style/Table.php b/src/Style/Table.php new file mode 100644 index 0000000000..4de5660567 --- /dev/null +++ b/src/Style/Table.php @@ -0,0 +1,94 @@ +_cellMarginTop = null; + $this->_cellMarginLeft = null; + $this->_cellMarginRight = null; + $this->_cellMarginBottom = null; + } + + public function setStyleValue($key, $value) + { + $this->$key = $value; + } + + public function setCellMarginTop($pValue = null) + { + $this->_cellMarginTop = $pValue; + } + + public function getCellMarginTop() + { + return $this->_cellMarginTop; + } + + public function setCellMarginLeft($pValue = null) + { + $this->_cellMarginLeft = $pValue; + } + + public function getCellMarginLeft() + { + return $this->_cellMarginLeft; + } + + public function setCellMarginRight($pValue = null) + { + $this->_cellMarginRight = $pValue; + } + + public function getCellMarginRight() + { + return $this->_cellMarginRight; + } + + public function setCellMarginBottom($pValue = null) + { + $this->_cellMarginBottom = $pValue; + } + + public function getCellMarginBottom() + { + return $this->_cellMarginBottom; + } + + public function getCellMargin() + { + return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); + } +} diff --git a/src/Style/TableFull.php b/src/Style/TableFull.php new file mode 100644 index 0000000000..5ca7561b23 --- /dev/null +++ b/src/Style/TableFull.php @@ -0,0 +1,443 @@ +_firstRow = clone $this; + + unset($this->_firstRow->_firstRow); + unset($this->_firstRow->_cellMarginBottom); + unset($this->_firstRow->_cellMarginTop); + unset($this->_firstRow->_cellMarginLeft); + unset($this->_firstRow->_cellMarginRight); + unset($this->_firstRow->_borderInsideVColor); + unset($this->_firstRow->_borderInsideVSize); + unset($this->_firstRow->_borderInsideHColor); + unset($this->_firstRow->_borderInsideHSize); + foreach ($styleFirstRow as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + + $this->_firstRow->setStyleValue($key, $value); + } + } + + if (!is_null($styleTable) && is_array($styleTable)) { + foreach ($styleTable as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->setStyleValue($key, $value); + } + } + } + + /** + * @param string $key + * @param mixed $value + */ + public function setStyleValue($key, $value) + { + if ($key == '_borderSize') { + $this->setBorderSize($value); + } elseif ($key == '_borderColor') { + $this->setBorderColor($value); + } elseif ($key == '_cellMargin') { + $this->setCellMargin($value); + } else { + $this->$key = $value; + } + } + + /** + * Get First Row Style + * + * @return PhpOffice\PhpWord\Style\TableFull + */ + public function getFirstRow() + { + return $this->_firstRow; + } + + /** + * Get Last Row Style + * + * @return PhpOffice\PhpWord\Style\TableFull + */ + public function getLastRow() + { + return $this->_lastRow; + } + + public function getBgColor() + { + return $this->_bgColor; + } + + public function setBgColor($pValue = null) + { + $this->_bgColor = $pValue; + } + + /** + * Set TLRBVH Border Size + * + * @param int $pValue Border size in eighths of a point (1/8 point) + */ + public function setBorderSize($pValue = null) + { + $this->_borderTopSize = $pValue; + $this->_borderLeftSize = $pValue; + $this->_borderRightSize = $pValue; + $this->_borderBottomSize = $pValue; + $this->_borderInsideHSize = $pValue; + $this->_borderInsideVSize = $pValue; + } + + /** + * Get TLRBVH Border Size + * + * @return array + */ + public function getBorderSize() + { + $t = $this->getBorderTopSize(); + $l = $this->getBorderLeftSize(); + $r = $this->getBorderRightSize(); + $b = $this->getBorderBottomSize(); + $h = $this->getBorderInsideHSize(); + $v = $this->getBorderInsideVSize(); + + return array($t, $l, $r, $b, $h, $v); + } + + /** + * Set TLRBVH Border Color + */ + public function setBorderColor($pValue = null) + { + $this->_borderTopColor = $pValue; + $this->_borderLeftColor = $pValue; + $this->_borderRightColor = $pValue; + $this->_borderBottomColor = $pValue; + $this->_borderInsideHColor = $pValue; + $this->_borderInsideVColor = $pValue; + } + + /** + * Get TLRB Border Color + * + * @return array + */ + public function getBorderColor() + { + $t = $this->getBorderTopColor(); + $l = $this->getBorderLeftColor(); + $r = $this->getBorderRightColor(); + $b = $this->getBorderBottomColor(); + $h = $this->getBorderInsideHColor(); + $v = $this->getBorderInsideVColor(); + + return array($t, $l, $r, $b, $h, $v); + } + + public function setBorderTopSize($pValue = null) + { + $this->_borderTopSize = $pValue; + } + + public function getBorderTopSize() + { + return $this->_borderTopSize; + } + + public function setBorderTopColor($pValue = null) + { + $this->_borderTopColor = $pValue; + } + + public function getBorderTopColor() + { + return $this->_borderTopColor; + } + + public function setBorderLeftSize($pValue = null) + { + $this->_borderLeftSize = $pValue; + } + + public function getBorderLeftSize() + { + return $this->_borderLeftSize; + } + + public function setBorderLeftColor($pValue = null) + { + $this->_borderLeftColor = $pValue; + } + + public function getBorderLeftColor() + { + return $this->_borderLeftColor; + } + + public function setBorderRightSize($pValue = null) + { + $this->_borderRightSize = $pValue; + } + + public function getBorderRightSize() + { + return $this->_borderRightSize; + } + + public function setBorderRightColor($pValue = null) + { + $this->_borderRightColor = $pValue; + } + + public function getBorderRightColor() + { + return $this->_borderRightColor; + } + + public function setBorderBottomSize($pValue = null) + { + $this->_borderBottomSize = $pValue; + } + + public function getBorderBottomSize() + { + return $this->_borderBottomSize; + } + + public function setBorderBottomColor($pValue = null) + { + $this->_borderBottomColor = $pValue; + } + + public function getBorderBottomColor() + { + return $this->_borderBottomColor; + } + + public function setBorderInsideHColor($pValue = null) + { + $this->_borderInsideHColor = $pValue; + } + + public function getBorderInsideHColor() + { + return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null; + } + + public function setBorderInsideVColor($pValue = null) + { + $this->_borderInsideVColor = $pValue; + } + + public function getBorderInsideVColor() + { + return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null; + } + + public function setBorderInsideHSize($pValue = null) + { + $this->_borderInsideHSize = $pValue; + } + + public function getBorderInsideHSize() + { + return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null; + } + + public function setBorderInsideVSize($pValue = null) + { + $this->_borderInsideVSize = $pValue; + } + + public function getBorderInsideVSize() + { + return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null; + } + + public function setCellMarginTop($pValue = null) + { + $this->_cellMarginTop = $pValue; + } + + public function getCellMarginTop() + { + return $this->_cellMarginTop; + } + + public function setCellMarginLeft($pValue = null) + { + $this->_cellMarginLeft = $pValue; + } + + public function getCellMarginLeft() + { + return $this->_cellMarginLeft; + } + + public function setCellMarginRight($pValue = null) + { + $this->_cellMarginRight = $pValue; + } + + public function getCellMarginRight() + { + return $this->_cellMarginRight; + } + + public function setCellMarginBottom($pValue = null) + { + $this->_cellMarginBottom = $pValue; + } + + public function getCellMarginBottom() + { + return $this->_cellMarginBottom; + } + + /** + * Set TLRB cell margin + * + * @param int $pValue Margin in twips + */ + public function setCellMargin($pValue = null) + { + $this->_cellMarginTop = $pValue; + $this->_cellMarginLeft = $pValue; + $this->_cellMarginRight = $pValue; + $this->_cellMarginBottom = $pValue; + } + + public function getCellMargin() + { + return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); + } +} \ No newline at end of file diff --git a/src/Style/Tabs.php b/src/Style/Tabs.php new file mode 100644 index 0000000000..45fdb5682d --- /dev/null +++ b/src/Style/Tabs.php @@ -0,0 +1,63 @@ +_tabs = $tabs; + } + + /** + * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter + */ + public function toXml(XMLWriter &$xmlWriter = null) + { + if (isset($xmlWriter)) { + $xmlWriter->startElement("w:tabs"); + foreach ($this->_tabs as &$tab) { + $tab->toXml($xmlWriter); + } + $xmlWriter->endElement(); + } + } +} diff --git a/src/TOC.php b/src/TOC.php new file mode 100644 index 0000000000..932e54be3b --- /dev/null +++ b/src/TOC.php @@ -0,0 +1,155 @@ + $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + self::$_styleTOC->setStyleValue($key, $value); + } + } + + if (!is_null($styleFont)) { + if (is_array($styleFont)) { + self::$_styleFont = new Font(); + + foreach ($styleFont as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + self::$_styleFont->setStyleValue($key, $value); + } + } else { + self::$_styleFont = $styleFont; + } + } + } + + /** + * Add a Title + * + * @return array + */ + public static function addTitle($text, $depth = 0) + { + $anchor = '_Toc' . ++self::$_anchor; + $bookmarkId = self::$_bookmarkId++; + + $title = array(); + $title['text'] = $text; + $title['depth'] = $depth; + $title['anchor'] = $anchor; + $title['bookmarkId'] = $bookmarkId; + + self::$_titles[] = $title; + + return array($anchor, $bookmarkId); + } + + /** + * Get all titles + * + * @return array + */ + public static function getTitles() + { + return self::$_titles; + } + + /** + * Get TOC Style + * + * @return PhpOffice\PhpWord\Style\TOC + */ + public static function getStyleTOC() + { + return self::$_styleTOC; + } + + /** + * Get Font Style + * + * @return PhpOffice\PhpWord\Style\Font + */ + public static function getStyleFont() + { + return self::$_styleFont; + } +} diff --git a/src/Template.php b/src/Template.php new file mode 100644 index 0000000000..f934257ec5 --- /dev/null +++ b/src/Template.php @@ -0,0 +1,292 @@ +_tempFileName = tempnam(sys_get_temp_dir(), ''); + if ($this->_tempFileName === false) { + throw new Exception('Could not create temporary file with unique name in the default temporary directory.'); + } + + // Copy the source File to the temp File + if (!copy($strFilename, $this->_tempFileName)) { + throw new Exception("Could not copy the template from {$strFilename} to {$this->_tempFileName}."); + } + + $this->_objZip = new ZipArchive(); + $this->_objZip->open($this->_tempFileName); + + $this->_documentXML = $this->_objZip->getFromName('word/document.xml'); + } + + /** + * Applies XSL style sheet to template's parts + * + * @param DOMDocument $xslDOMDocument + * @param array $xslOptions + * @param string $xslOptionsURI + * @throws Exception + */ + public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') + { + $processor = new XSLTProcessor(); + + $processor->importStylesheet($xslDOMDocument); + + if ($processor->setParameter($xslOptionsURI, $xslOptions) === false) { + throw new Exception('Could not set values for the given XSL style sheet parameters.'); + } + + $xmlDOMDocument = new DOMDocument(); + if ($xmlDOMDocument->loadXML($this->_documentXML) === false) { + throw new Exception('Could not load XML from the given template.'); + } + + $xmlTransformed = $processor->transformToXml($xmlDOMDocument); + if ($xmlTransformed === false) { + throw new Exception('Could not transform the given XML document.'); + } + + $this->_documentXML = $xmlTransformed; + } + + /** + * Set a Template value + * + * @param mixed $search + * @param mixed $replace + * @param integer $limit + */ + public function setValue($search, $replace, $limit = -1) + { + $pattern = '|\$\{([^\}]+)\}|U'; + preg_match_all($pattern, $this->_documentXML, $matches); + foreach ($matches[0] as $value) { + $valueCleaned = preg_replace('/<[^>]+>/', '', $value); + $valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned); + $this->_documentXML = str_replace($value, $valueCleaned, $this->_documentXML); + } + + if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { + $search = '${' . $search . '}'; + } + + if (!is_array($replace)) { + if (!String::IsUTF8($replace)) { + $replace = utf8_encode($replace); + } + $replace = htmlspecialchars($replace); + } else { + foreach ($replace as $key => $value) { + $replace[$key] = htmlspecialchars($value); + } + } + + $regExpDelim = '/'; + $escapedSearch = preg_quote($search, $regExpDelim); + $this->_documentXML = preg_replace("{$regExpDelim}{$escapedSearch}{$regExpDelim}u", $replace, $this->_documentXML, $limit); + } + + /** + * Returns array of all variables in template + */ + public function getVariables() + { + preg_match_all('/\$\{(.*?)}/i', $this->_documentXML, $matches); + return $matches[1]; + } + + /** + * Find the start position of the nearest table row before $offset + * + * @param int $offset + * @return int + * @throws Exception + */ + private function _findRowStart($offset) + { + $rowStart = strrpos($this->_documentXML, "_documentXML) - $offset) * -1)); + if (!$rowStart) { + $rowStart = strrpos($this->_documentXML, "", ((strlen($this->_documentXML) - $offset) * -1)); + } + if (!$rowStart) { + throw new Exception("Can not find the start position of the row to clone."); + } + return $rowStart; + } + + /** + * Find the end position of the nearest table row after $offset + * + * @param int $offset + * @return int + */ + private function _findRowEnd($offset) + { + $rowEnd = strpos($this->_documentXML, "", $offset) + 7; + return $rowEnd; + } + + /** + * Get a slice of a string + * + * @param int $startPosition + * @param int $endPosition + * @return string + */ + private function _getSlice($startPosition, $endPosition = 0) + { + if (!$endPosition) { + $endPosition = strlen($this->_documentXML); + } + return substr($this->_documentXML, $startPosition, ($endPosition - $startPosition)); + } + + /** + * Clone a table row in a template document + * + * @param string $search + * @param int $numberOfClones + * @throws Exception + */ + public function cloneRow($search, $numberOfClones) + { + if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { + $search = '${' . $search . '}'; + } + + $tagPos = strpos($this->_documentXML, $search); + if (!$tagPos) { + throw new Exception("Can not clone row, template variable not found or variable contains markup."); + } + + $rowStart = $this->_findRowStart($tagPos); + $rowEnd = $this->_findRowEnd($tagPos); + $xmlRow = $this->_getSlice($rowStart, $rowEnd); + + // Check if there's a cell spanning multiple rows. + if (preg_match('##', $xmlRow)) { + $extraRowStart = $rowEnd; + $extraRowEnd = $rowEnd; + while (true) { + $extraRowStart = $this->_findRowStart($extraRowEnd + 1); + $extraRowEnd = $this->_findRowEnd($extraRowEnd + 1); + + // If extraRowEnd is lower then 7, there was no next row found. + if ($extraRowEnd < 7) { + break; + } + + // If tmpXmlRow doesn't contain continue, this row is no longer part of the spanned row. + $tmpXmlRow = $this->_getSlice($extraRowStart, $extraRowEnd); + if (!preg_match('##', $tmpXmlRow) && !preg_match('##', $tmpXmlRow)) { + break; + } + // This row was a spanned row, update $rowEnd and search for the next row. + $rowEnd = $extraRowEnd; + } + $xmlRow = $this->_getSlice($rowStart, $rowEnd); + } + + $result = $this->_getSlice(0, $rowStart); + for ($i = 1; $i <= $numberOfClones; $i++) { + $result .= preg_replace('/\$\{(.*?)\}/', '\${\\1#' . $i . '}', $xmlRow); + } + $result .= $this->_getSlice($rowEnd); + + $this->_documentXML = $result; + } + + /** + * Save Template + * + * @return string + * @throws Exception + */ + public function save() + { + $this->_objZip->addFromString('word/document.xml', $this->_documentXML); + + // Close zip file + if ($this->_objZip->close() === false) { + throw new Exception('Could not close zip file.'); + } + + return $this->_tempFileName; + } + + /** + * Save Template As... + * + * @param string $strFilename + */ + public function saveAs($strFilename) + { + $tempFilename = $this->save(); + + if (file_exists($strFilename)) { + unlink($strFilename); + } + + rename($tempFilename, $strFilename); + } +} \ No newline at end of file diff --git a/src/Writer/IWriter.php b/src/Writer/IWriter.php new file mode 100644 index 0000000000..98c15704fe --- /dev/null +++ b/src/Writer/IWriter.php @@ -0,0 +1,39 @@ +setPhpWord($phpWord); + + // Set up disk caching location + $this->_diskCachingDirectory = './'; + + // Initialise writer parts + $this->_writerParts['content'] = new Content(); + $this->_writerParts['manifest'] = new Manifest(); + $this->_writerParts['meta'] = new Meta(); + $this->_writerParts['mimetype'] = new Mimetype(); + $this->_writerParts['styles'] = new Styles(); + + + // Assign parent IWriter + foreach ($this->_writerParts as $writer) { + $writer->setParentWriter($this); + } + + // Set HashTable variables + $this->_drawingHashTable = new HashTable(); + } + + /** + * Save PhpWord to file + * + * @param string $pFileName + * @throws \Exception + */ + public function save($pFilename = null) + { + if (!is_null($this->_document)) { + // If $pFilename is php://output or php://stdout, make it a temporary file... + $originalFilename = $pFilename; + if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + $pFilename = @tempnam('./', 'phppttmp'); + if ($pFilename == '') { + $pFilename = $originalFilename; + } + } + + // Create drawing dictionary + + // Create new ZIP file and open it for writing + $objZip = new ZipArchive(); + + // Try opening the ZIP file + if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { + if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { + throw new \Exception("Could not open " . $pFilename . " for writing."); + } + } + + // Add mimetype to ZIP file + //@todo Not in ZIPARCHIVE::CM_STORE mode + $objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype($this->_document)); + + // Add content.xml to ZIP file + $objZip->addFromString('content.xml', $this->getWriterPart('content')->writeContent($this->_document)); + + // Add meta.xml to ZIP file + $objZip->addFromString('meta.xml', $this->getWriterPart('meta')->writeMeta($this->_document)); + + // Add styles.xml to ZIP file + $objZip->addFromString('styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document)); + + // Add META-INF/manifest.xml + $objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('manifest')->writeManifest($this->_document)); + + // Add media. Has not used yet. Legacy from PHPExcel. + // @codeCoverageIgnoreStart + for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) { + if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) { + $imageContents = null; + $imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath(); + + if (strpos($imagePath, 'zip://') !== false) { + $imagePath = substr($imagePath, 6); + $imagePathSplitted = explode('#', $imagePath); + + $imageZip = new ZipArchive(); + $imageZip->open($imagePathSplitted[0]); + $imageContents = $imageZip->getFromName($imagePathSplitted[1]); + $imageZip->close(); + unset($imageZip); + } else { + $imageContents = file_get_contents($imagePath); + } + + $objZip->addFromString('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); + } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) { + ob_start(); + call_user_func( + $this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(), + $this->getDrawingHashTable()->getByIndex($i)->getImageResource() + ); + $imageContents = ob_get_contents(); + ob_end_clean(); + + $objZip->addFromString('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); + } + } + // @codeCoverageIgnoreEnd + + // Close file + if ($objZip->close() === false) { + throw new \Exception("Could not close zip file $pFilename."); + } + + // If a temporary file was used, copy it to the correct file stream + if ($originalFilename != $pFilename) { + if (copy($pFilename, $originalFilename) === false) { + throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + } + @unlink($pFilename); + } + + } else { + throw new \Exception("PhpWord object unassigned."); + } + } + + /** + * @return PhpOffice\PhpWord + * @throws \Exception + */ + public function getPhpWord() + { + if (!is_null($this->_document)) { + return $this->_document; + } else { + throw new \Exception("No PhpWord assigned."); + } + } + + /** + * @param PhpOffice\PhpWord $phpWord + * @return PhpOffice\PhpWord\Writer\ODText + */ + public function setPhpWord(PhpWord $phpWord = null) + { + $this->_document = $phpWord; + return $this; + } + + /** + * Get PHPWord_Worksheet_BaseDrawing HashTable + * + * @return PhpOffice\PhpWord\HashTable + */ + public function getDrawingHashTable() + { + return $this->_drawingHashTable; + } + + /** + * @param string $pPartName Writer part name + * @return PhpOffice\PhpWord\Writer\ODText\WriterPart + */ + public function getWriterPart($pPartName = '') + { + if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { + return $this->_writerParts[strtolower($pPartName)]; + } else { + return null; + } + } + + /** + * Get use disk caching where possible? + * + * @return boolean + */ + public function getUseDiskCaching() + { + return $this->_useDiskCaching; + } + + /** + * Set use disk caching where possible? + * + * @param boolean $pValue + * @param string $pDirectory Disk caching directory + * @throws \Exception Exception when directory does not exist + * @return PhpOffice\PhpWord\Writer\ODText + */ + public function setUseDiskCaching($pValue = false, $pDirectory = null) + { + $this->_useDiskCaching = $pValue; + + if (!is_null($pDirectory)) { + if (is_dir($pDirectory)) { + $this->_diskCachingDirectory = $pDirectory; + } else { + throw new \Exception("Directory does not exist: $pDirectory"); + } + } + + return $this; + } + + /** + * @return string + */ + public function getDiskCachingDirectory() + { + return $this->_diskCachingDirectory; + } +} \ No newline at end of file diff --git a/src/Writer/ODText/Content.php b/src/Writer/ODText/Content.php new file mode 100644 index 0000000000..c809708f07 --- /dev/null +++ b/src/Writer/ODText/Content.php @@ -0,0 +1,412 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8'); + + // office:document-content + $xmlWriter->startElement('office:document-content'); + $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); + $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); + $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); + $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); + $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); + $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); + $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); + $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); + $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); + $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); + $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); + $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); + $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); + $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); + $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); + $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); + $xmlWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms'); + $xmlWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); + $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); + $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); + $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); + $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); + $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); + $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); + $xmlWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0'); + $xmlWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0'); + $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); + $xmlWriter->writeAttribute('office:version', '1.2'); + + // We firstly search all fonts used + $_sections = $phpWord->getSections(); + $countSections = count($_sections); + if ($countSections > 0) { + $pSection = 0; + $numPStyles = 0; + $numFStyles = 0; + + foreach ($_sections as $section) { + $pSection++; + $_elements = $section->getElements(); + + foreach ($_elements as $element) { + if ($element instanceof Text) { + $fStyle = $element->getFontStyle(); + $pStyle = $element->getParagraphStyle(); + + if ($fStyle instanceof Font) { + $numFStyles++; + + $arrStyle = array( + 'color' => $fStyle->getColor(), + 'name' => $fStyle->getName() + ); + $phpWord->addFontStyle('T' . $numFStyles, $arrStyle); + $element->setFontStyle('T' . $numFStyles); + } elseif ($pStyle instanceof Paragraph) { + $numPStyles++; + + $phpWord->addParagraphStyle('P' . $numPStyles, array()); + $element->setParagraphStyle('P' . $numPStyles); + } + } + } + } + } + + // office:font-face-decls + $xmlWriter->startElement('office:font-face-decls'); + $arrFonts = array(); + + $styles = Style::getStyles(); + $numFonts = 0; + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { + $numFonts++; + $name = $style->getName(); + if (!in_array($name, $arrFonts)) { + $arrFonts[] = $name; + + // style:font-face + $xmlWriter->startElement('style:font-face'); + $xmlWriter->writeAttribute('style:name', $name); + $xmlWriter->writeAttribute('svg:font-family', $name); + $xmlWriter->endElement(); + } + } + } + if (!in_array(PhpWord::DEFAULT_FONT_NAME, $arrFonts)) { + $xmlWriter->startElement('style:font-face'); + $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME); + $xmlWriter->endElement(); + } + } + $xmlWriter->endElement(); + + $xmlWriter->startElement('office:automatic-styles'); + $styles = Style::getStyles(); + $numPStyles = 0; + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + if (preg_match('#^T[0-9]+$#', $styleName) != 0 + || preg_match('#^P[0-9]+$#', $styleName) != 0 + ) { + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $styleName); + $xmlWriter->writeAttribute('style:family', 'text'); + // style:text-properties + $xmlWriter->startElement('style:text-properties'); + $xmlWriter->writeAttribute('fo:color', '#' . $style->getColor()); + $xmlWriter->writeAttribute('style:font-name', $style->getName()); + $xmlWriter->writeAttribute('style:font-name-complex', $style->getName()); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + if ($style instanceof Paragraph) { + $numPStyles++; + // style:style + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $styleName); + $xmlWriter->writeAttribute('style:family', 'paragraph'); + $xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); + $xmlWriter->writeAttribute('style:master-page-name', 'Standard'); + // style:paragraph-properties + $xmlWriter->startElement('style:paragraph-properties'); + $xmlWriter->writeAttribute('style:page-number', 'auto'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + } + } + + if ($numPStyles == 0) { + // style:style + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', 'P1'); + $xmlWriter->writeAttribute('style:family', 'paragraph'); + $xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); + $xmlWriter->writeAttribute('style:master-page-name', 'Standard'); + // style:paragraph-properties + $xmlWriter->startElement('style:paragraph-properties'); + $xmlWriter->writeAttribute('style:page-number', 'auto'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + } + $xmlWriter->endElement(); + + // office:body + $xmlWriter->startElement('office:body'); + // office:text + $xmlWriter->startElement('office:text'); + // text:sequence-decls + $xmlWriter->startElement('text:sequence-decls'); + // text:sequence-decl + $xmlWriter->startElement('text:sequence-decl'); + $xmlWriter->writeAttribute('text:display-outline-level', 0); + $xmlWriter->writeAttribute('text:name', 'Illustration'); + $xmlWriter->endElement(); + // text:sequence-decl + $xmlWriter->startElement('text:sequence-decl'); + $xmlWriter->writeAttribute('text:display-outline-level', 0); + $xmlWriter->writeAttribute('text:name', 'Table'); + $xmlWriter->endElement(); + // text:sequence-decl + $xmlWriter->startElement('text:sequence-decl'); + $xmlWriter->writeAttribute('text:display-outline-level', 0); + $xmlWriter->writeAttribute('text:name', 'Text'); + $xmlWriter->endElement(); + // text:sequence-decl + $xmlWriter->startElement('text:sequence-decl'); + $xmlWriter->writeAttribute('text:display-outline-level', 0); + $xmlWriter->writeAttribute('text:name', 'Drawing'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $_sections = $phpWord->getSections(); + $countSections = count($_sections); + $pSection = 0; + + if ($countSections > 0) { + foreach ($_sections as $section) { + $pSection++; + + $_elements = $section->getElements(); + + foreach ($_elements as $element) { + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter); + } elseif ($element instanceof Link) { + $this->writeUnsupportedElement($xmlWriter, 'Link'); + } elseif ($element instanceof Title) { + $this->writeUnsupportedElement($xmlWriter, 'Title'); + } elseif ($element instanceof PageBreak) { + $this->writeUnsupportedElement($xmlWriter, 'Page Break'); + } elseif ($element instanceof Table) { + $this->writeUnsupportedElement($xmlWriter, 'Table'); + } elseif ($element instanceof ListItem) { + $this->writeUnsupportedElement($xmlWriter, 'List Item'); + } elseif ($element instanceof Image || + $element instanceof MemoryImage) { + $this->writeUnsupportedElement($xmlWriter, 'Image'); + } elseif ($element instanceof Object) { + $this->writeUnsupportedElement($xmlWriter, 'Object'); + } elseif ($element instanceof TOC) { + $this->writeUnsupportedElement($xmlWriter, 'TOC'); + } else { + $this->writeUnsupportedElement($xmlWriter, 'Element'); + } + } + + if ($pSection == $countSections) { + $this->_writeEndSection($xmlWriter, $section); + } else { + $this->_writeSection($xmlWriter, $section); + } + } + } + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } + + /** + * Write text + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Text $text + * @param bool $withoutP + */ + protected function _writeText(XMLWriter $xmlWriter = null, Text $text, $withoutP = false) + { + $styleFont = $text->getFontStyle(); + $styleParagraph = $text->getParagraphStyle(); + + // @todo Commented for TextRun. Should really checkout this value + // $SfIsObject = ($styleFont instanceof Font) ? true : false; + $SfIsObject = false; + + if ($SfIsObject) { + // Don't never be the case, because I browse all sections for cleaning all styles not declared + die('PhpWord : $SfIsObject wouldn\'t be an object'); + } else { + if (!$withoutP) { + $xmlWriter->startElement('text:p'); // text:p + } + if (empty($styleFont)) { + if (empty($styleParagraph)) { + $xmlWriter->writeAttribute('text:style-name', 'P1'); + } else { + $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); + } + $xmlWriter->writeRaw($text->getText()); + } else { + if (empty($styleParagraph)) { + $xmlWriter->writeAttribute('text:style-name', 'Standard'); + } else { + $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); + } + // text:span + $xmlWriter->startElement('text:span'); + $xmlWriter->writeAttribute('text:style-name', $styleFont); + $xmlWriter->writeRaw($text->getText()); + $xmlWriter->endElement(); + } + if (!$withoutP) { + $xmlWriter->endElement(); // text:p + } + } + } + + /** + * Write TextRun section + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\TextRun $textrun + * @todo Enable all other section types + */ + protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) + { + $elements = $textrun->getElements(); + $xmlWriter->startElement('text:p'); + if (count($elements) > 0) { + foreach ($elements as $element) { + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element, true); + } + } + } + $xmlWriter->endElement(); + } + + /** + * Write TextBreak + */ + protected function _writeTextBreak(XMLWriter $xmlWriter = null) + { + $xmlWriter->startElement('text:p'); + $xmlWriter->writeAttribute('text:style-name', 'Standard'); + $xmlWriter->endElement(); + } + + // @codeCoverageIgnoreStart + private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null) + { + } + + private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null) + { + } + // @codeCoverageIgnoreEnd + + /** + * Write unsupported element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $element + */ + private function writeUnsupportedElement($xmlWriter, $element) + { + $xmlWriter->startElement('text:p'); + $xmlWriter->writeRaw($element); + $xmlWriter->endElement(); + } +} \ No newline at end of file diff --git a/src/Writer/ODText/Manifest.php b/src/Writer/ODText/Manifest.php new file mode 100644 index 0000000000..f27f135059 --- /dev/null +++ b/src/Writer/ODText/Manifest.php @@ -0,0 +1,132 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8'); + + // manifest:manifest + $xmlWriter->startElement('manifest:manifest'); + $xmlWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'); + $xmlWriter->writeAttribute('manifest:version', '1.2'); + + // manifest:file-entry + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text'); + $xmlWriter->writeAttribute('manifest:version', '1.2'); + $xmlWriter->writeAttribute('manifest:full-path', '/'); + $xmlWriter->endElement(); + // manifest:file-entry + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); + $xmlWriter->writeAttribute('manifest:full-path', 'content.xml'); + $xmlWriter->endElement(); + // manifest:file-entry + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); + $xmlWriter->writeAttribute('manifest:full-path', 'meta.xml'); + $xmlWriter->endElement(); + // manifest:file-entry + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); + $xmlWriter->writeAttribute('manifest:full-path', 'styles.xml'); + $xmlWriter->endElement(); + + // Not used yet. Legacy from PHPExcel + // @codeCoverageIgnoreStart + for ($i = 0; $i < $this->getParentWriter()->getDrawingHashTable()->count(); ++$i) { + if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) { + $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension()); + $mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath()); + + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', $mimeType); + $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); + $xmlWriter->endElement(); + } elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) { + $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType()); + $extension = explode('/', $extension); + $extension = $extension[1]; + + $mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType(); + + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', $mimeType); + $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); + $xmlWriter->endElement(); + } + } + // @codeCoverageIgnoreEnd + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } + + + /** + * Get image mime type + * + * @param string $pFile Filename + * @return string Mime Type + * @throws Exception + */ + private function _getImageMimeType($pFile = '') + { + if (File::file_exists($pFile)) { + $image = getimagesize($pFile); + return image_type_to_mime_type($image[2]); + } else { + throw new Exception("File $pFile does not exist"); + } + } +} diff --git a/src/Writer/ODText/Meta.php b/src/Writer/ODText/Meta.php new file mode 100644 index 0000000000..1b30efa394 --- /dev/null +++ b/src/Writer/ODText/Meta.php @@ -0,0 +1,96 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8'); + + // office:document-meta + $xmlWriter->startElement('office:document-meta'); + $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); + $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); + $xmlWriter->writeAttribute('office:version', '1.2'); + + // office:meta + $xmlWriter->startElement('office:meta'); + + // dc:creator + $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getLastModifiedBy()); + // dc:date + $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getModified())); + // dc:description + $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); + // dc:subject + $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); + // dc:title + $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); + // meta:creation-date + $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getCreated())); + // meta:initial-creator + $xmlWriter->writeElement('meta:initial-creator', $phpWord->getDocumentProperties()->getCreator()); + // meta:keyword + $xmlWriter->writeElement('meta:keyword', $phpWord->getDocumentProperties()->getKeywords()); + + // @todo : Where these properties are written ? + // $phpWord->getDocumentProperties()->getCategory() + // $phpWord->getDocumentProperties()->getCompany() + + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } +} diff --git a/src/Writer/ODText/Mimetype.php b/src/Writer/ODText/Mimetype.php new file mode 100644 index 0000000000..59386d5ac6 --- /dev/null +++ b/src/Writer/ODText/Mimetype.php @@ -0,0 +1,46 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8'); + + // Styles:Styles + $xmlWriter->startElement('office:document-styles'); + $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); + $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); + $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); + $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); + $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); + $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); + $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); + $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); + $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); + $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); + $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); + $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); + $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); + $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); + $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); + $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); + $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); + $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); + $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); + $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); + $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); + $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); + $xmlWriter->writeAttribute('office:version', '1.2'); + + + // office:font-face-decls + $xmlWriter->startElement('office:font-face-decls'); + $arrFonts = array(); + $styles = Style::getStyles(); + $numFonts = 0; + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { + $numFonts++; + $name = $style->getName(); + if (!in_array($name, $arrFonts)) { + $arrFonts[] = $name; + + // style:font-face + $xmlWriter->startElement('style:font-face'); + $xmlWriter->writeAttribute('style:name', $name); + $xmlWriter->writeAttribute('svg:font-family', $name); + $xmlWriter->endElement(); + } + } + } + } + if (!in_array(PhpWord::DEFAULT_FONT_NAME, $arrFonts)) { + $xmlWriter->startElement('style:font-face'); + $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME); + $xmlWriter->endElement(); + } + $xmlWriter->endElement(); + + // office:styles + $xmlWriter->startElement('office:styles'); + + // style:default-style + $xmlWriter->startElement('style:default-style'); + $xmlWriter->writeAttribute('style:family', 'paragraph'); + + // style:paragraph-properties + $xmlWriter->startElement('style:paragraph-properties'); + $xmlWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit'); + $xmlWriter->writeAttribute('style:text-autospace', 'ideograph-alpha'); + $xmlWriter->writeAttribute('style:punctuation-wrap', 'hanging'); + $xmlWriter->writeAttribute('style:line-break', 'strict'); + $xmlWriter->writeAttribute('style:tab-stop-distance', '1.249cm'); + $xmlWriter->writeAttribute('style:writing-mode', 'page'); + $xmlWriter->endElement(); + + // style:text-properties + $xmlWriter->startElement('style:text-properties'); + $xmlWriter->writeAttribute('style:use-window-font-color', 'true'); + $xmlWriter->writeAttribute('style:font-name', PhpWord::DEFAULT_FONT_NAME); + $xmlWriter->writeAttribute('fo:font-size', PhpWord::DEFAULT_FONT_SIZE . 'pt'); + $xmlWriter->writeAttribute('fo:language', 'fr'); + $xmlWriter->writeAttribute('fo:country', 'FR'); + $xmlWriter->writeAttribute('style:letter-kerning', 'true'); + $xmlWriter->writeAttribute('style:font-name-asian', PhpWord::DEFAULT_FONT_NAME . '2'); + $xmlWriter->writeAttribute('style:font-size-asian', PhpWord::DEFAULT_FONT_SIZE . 'pt'); + $xmlWriter->writeAttribute('style:language-asian', 'zh'); + $xmlWriter->writeAttribute('style:country-asian', 'CN'); + $xmlWriter->writeAttribute('style:font-name-complex', PhpWord::DEFAULT_FONT_NAME . '2'); + $xmlWriter->writeAttribute('style:font-size-complex', PhpWord::DEFAULT_FONT_SIZE . 'pt'); + $xmlWriter->writeAttribute('style:language-complex', 'hi'); + $xmlWriter->writeAttribute('style:country-complex', 'IN'); + $xmlWriter->writeAttribute('fo:hyphenate', 'false'); + $xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2'); + $xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2'); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + // Write Style Definitions + $styles = Style::getStyles(); + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + if (preg_match('#^T[0-9]+$#', $styleName) == 0 + && preg_match('#^P[0-9]+$#', $styleName) == 0 + ) { + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { + // style:style + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $styleName); + $xmlWriter->writeAttribute('style:family', 'text'); + + // style:text-properties + $xmlWriter->startElement('style:text-properties'); + $xmlWriter->writeAttribute('fo:font-size', ($style->getSize()) . 'pt'); + $xmlWriter->writeAttribute('style:font-size-asian', ($style->getSize()) . 'pt'); + $xmlWriter->writeAttribute('style:font-size-complex', ($style->getSize()) . 'pt'); + if ($style->getItalic()) { + $xmlWriter->writeAttribute('fo:font-style', 'italic'); + $xmlWriter->writeAttribute('style:font-style-asian', 'italic'); + $xmlWriter->writeAttribute('style:font-style-complex', 'italic'); + } + if ($style->getBold()) { + $xmlWriter->writeAttribute('fo:font-weight', 'bold'); + $xmlWriter->writeAttribute('style:font-weight-asian', 'bold'); + } + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } elseif ($style instanceof Paragraph) { + // PhpOffice\PhpWord\Style\Paragraph + // style:style + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $styleName); + $xmlWriter->writeAttribute('style:family', 'paragraph'); + + //style:paragraph-properties + $xmlWriter->startElement('style:paragraph-properties'); + $xmlWriter->writeAttribute('fo:margin-top', ((is_null($style->getSpaceBefore())) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)) . 'cm'); + $xmlWriter->writeAttribute('fo:margin-bottom', ((is_null($style->getSpaceAfter())) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)) . 'cm'); + $xmlWriter->writeAttribute('fo:text-align', $style->getAlign()); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + } elseif ($style instanceof TableFull) { + // PhpOffice\PhpWord\Style\TableFull + } + } + } + } + $xmlWriter->endElement(); + + // office:automatic-styles + $xmlWriter->startElement('office:automatic-styles'); + // style:page-layout + $xmlWriter->startElement('style:page-layout'); + $xmlWriter->writeAttribute('style:name', 'Mpm1'); + // style:page-layout-properties + $xmlWriter->startElement('style:page-layout-properties'); + $xmlWriter->writeAttribute('fo:page-width', "21.001cm"); + $xmlWriter->writeAttribute('fo:page-height', '29.7cm'); + $xmlWriter->writeAttribute('style:num-format', '1'); + $xmlWriter->writeAttribute('style:print-orientation', 'portrait'); + $xmlWriter->writeAttribute('fo:margin-top', '2.501cm'); + $xmlWriter->writeAttribute('fo:margin-bottom', '2cm'); + $xmlWriter->writeAttribute('fo:margin-left', '2.501cm'); + $xmlWriter->writeAttribute('fo:margin-right', '2.501cm'); + $xmlWriter->writeAttribute('style:writing-mode', 'lr-tb'); + $xmlWriter->writeAttribute('style:layout-grid-color', '#c0c0c0'); + $xmlWriter->writeAttribute('style:layout-grid-lines', '25199'); + $xmlWriter->writeAttribute('style:layout-grid-base-height', '0.423cm'); + $xmlWriter->writeAttribute('style:layout-grid-ruby-height', '0cm'); + $xmlWriter->writeAttribute('style:layout-grid-mode', 'none'); + $xmlWriter->writeAttribute('style:layout-grid-ruby-below', 'false'); + $xmlWriter->writeAttribute('style:layout-grid-print', 'false'); + $xmlWriter->writeAttribute('style:layout-grid-display', 'false'); + $xmlWriter->writeAttribute('style:layout-grid-base-width', '0.37cm'); + $xmlWriter->writeAttribute('style:layout-grid-snap-to', 'true'); + $xmlWriter->writeAttribute('style:footnote-max-height', '0cm'); + //style:footnote-sep + $xmlWriter->startElement('style:footnote-sep'); + $xmlWriter->writeAttribute('style:width', '0.018cm'); + $xmlWriter->writeAttribute('style:line-style', 'solid'); + $xmlWriter->writeAttribute('style:adjustment', 'left'); + $xmlWriter->writeAttribute('style:rel-width', '25%'); + $xmlWriter->writeAttribute('style:color', '#000000'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + // style:header-style + $xmlWriter->startElement('style:header-style'); + $xmlWriter->endElement(); + // style:footer-style + $xmlWriter->startElement('style:footer-style'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + // office:master-styles + $xmlWriter->startElement('office:master-styles'); + // style:master-page + $xmlWriter->startElement('style:master-page'); + $xmlWriter->writeAttribute('style:name', 'Standard'); + $xmlWriter->writeAttribute('style:page-layout-name', 'Mpm1'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } +} diff --git a/src/Writer/ODText/WriterPart.php b/src/Writer/ODText/WriterPart.php new file mode 100644 index 0000000000..06e4a404cc --- /dev/null +++ b/src/Writer/ODText/WriterPart.php @@ -0,0 +1,66 @@ +_parentWriter = $pWriter; + } + + /** + * Get parent IWriter object + * + * @return PhpOffice\PhpWord\Writer\IWriter + * @throws Exception + */ + public function getParentWriter() + { + if (!is_null($this->_parentWriter)) { + return $this->_parentWriter; + } else { + throw new Exception("No parent IWriter assigned."); + } + } +} diff --git a/src/Writer/RTF.php b/src/Writer/RTF.php new file mode 100644 index 0000000000..57c17fdb4b --- /dev/null +++ b/src/Writer/RTF.php @@ -0,0 +1,482 @@ +setPhpWord($phpWord); + + // Set HashTable variables + $this->_drawingHashTable = new HashTable(); + } + + /** + * Save PhpWord to file + * + * @param string $pFileName + * @throws \Exception + */ + public function save($pFilename = null) + { + if (!is_null($this->_document)) { + // If $pFilename is php://output or php://stdout, make it a temporary file... + $originalFilename = $pFilename; + if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + $pFilename = @tempnam('./', 'phppttmp'); + if ($pFilename == '') { + $pFilename = $originalFilename; + } + } + + $hFile = fopen($pFilename, 'w') or die("can't open file"); + fwrite($hFile, $this->getData()); + fclose($hFile); + + // If a temporary file was used, copy it to the correct file stream + if ($originalFilename != $pFilename) { + if (copy($pFilename, $originalFilename) === false) { + throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + } + @unlink($pFilename); + } + + } else { + throw new \Exception("PhpWord object unassigned."); + } + } + + /** + * @return PhpOffice\PhpWord + * @throws \Exception + */ + public function getPhpWord() + { + if (!is_null($this->_document)) { + return $this->_document; + } else { + throw new \Exception("No PhpWord assigned."); + } + } + + /** + * @param PhpOffice\PhpWord $phpWord + * @throws \Exception + * @return PhpOffice\PhpWord\Writer\RTF + */ + public function setPhpWord(PhpWord $phpWord = null) + { + $this->_document = $phpWord; + return $this; + } + + /** + * Get PHPWord_Worksheet_BaseDrawing HashTable + * + * @return PhpOffice\PhpWord\HashTable + */ + public function getDrawingHashTable() + { + return $this->_drawingHashTable; + } + + private function getData() + { + // PhpWord object : $this->_document + $this->_fontTable = $this->getDataFont(); + $this->_colorTable = $this->getDataColor(); + + $sRTFContent = '{\rtf1'; + // Set the default character set + $sRTFContent .= '\ansi\ansicpg1252'; + // Set the default font (the first one) + $sRTFContent .= '\deff0'; + // Set the default tab size (720 twips) + $sRTFContent .= '\deftab720'; + $sRTFContent .= PHP_EOL; + // Set the font tbl group + $sRTFContent .= '{\fonttbl'; + foreach ($this->_fontTable as $idx => $font) { + $sRTFContent .= '{\f' . $idx . '\fnil\fcharset0 ' . $font . ';}'; + } + $sRTFContent .= '}' . PHP_EOL; + // Set the color tbl group + $sRTFContent .= '{\colortbl '; + foreach ($this->_colorTable as $idx => $color) { + $arrColor = Drawing::htmlToRGB($color); + $sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; + } + $sRTFContent .= ';}' . PHP_EOL; + // Set the generator + $sRTFContent .= '{\*\generator PhpWord;}' . PHP_EOL; + // Set the view mode of the document + $sRTFContent .= '\viewkind4'; + // Set the numberof bytes that follows a unicode character + $sRTFContent .= '\uc1'; + // Resets to default paragraph properties. + $sRTFContent .= '\pard'; + // No widow/orphan control + $sRTFContent .= '\nowidctlpar'; + // Applies a language to a text run (1036 : French (France)) + $sRTFContent .= '\lang1036'; + // Point size (in half-points) above which to kern character pairs + $sRTFContent .= '\kerning1'; + // Set the font size in half-points + $sRTFContent .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); + $sRTFContent .= PHP_EOL; + // Body + $sRTFContent .= $this->getDataContent(); + + + $sRTFContent .= '}'; + + return $sRTFContent; + } + + private function getDataFont() + { + $phpWord = $this->_document; + + $arrFonts = array(); + // Default font : PhpWord::DEFAULT_FONT_NAME + $arrFonts[] = PhpWord::DEFAULT_FONT_NAME; + // PhpWord object : $this->_document + + // Browse styles + $styles = Style::getStyles(); + $numPStyles = 0; + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + // PhpOffice\PhpWord\Style\Font + if ($style instanceof Font) { + if (in_array($style->getName(), $arrFonts) == false) { + $arrFonts[] = $style->getName(); + } + } + } + } + + // Search all fonts used + $_sections = $phpWord->getSections(); + $countSections = count($_sections); + if ($countSections > 0) { + $pSection = 0; + + foreach ($_sections as $section) { + $pSection++; + $_elements = $section->getElements(); + + foreach ($_elements as $element) { + if ($element instanceof Text) { + $fStyle = $element->getFontStyle(); + + if ($fStyle instanceof Font) { + if (in_array($fStyle->getName(), $arrFonts) == false) { + $arrFonts[] = $fStyle->getName(); + } + } + } + } + } + } + + return $arrFonts; + } + + private function getDataColor() + { + $phpWord = $this->_document; + + $arrColors = array(); + // PhpWord object : $this->_document + + // Browse styles + $styles = Style::getStyles(); + $numPStyles = 0; + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + // Font + if ($style instanceof Font) { + $color = $style->getColor(); + $fgcolor = $style->getFgColor(); + if (in_array($color, $arrColors) == false && $color != PhpWord::DEFAULT_FONT_COLOR && !empty($color)) { + $arrColors[] = $color; + } + if (in_array($fgcolor, $arrColors) == false && $fgcolor != PhpWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) { + $arrColors[] = $fgcolor; + } + } + } + } + + // Search all fonts used + $_sections = $phpWord->getSections(); + $countSections = count($_sections); + if ($countSections > 0) { + $pSection = 0; + + foreach ($_sections as $section) { + $pSection++; + $_elements = $section->getElements(); + + foreach ($_elements as $element) { + if ($element instanceof Text) { + $fStyle = $element->getFontStyle(); + + if ($fStyle instanceof Font) { + if (in_array($fStyle->getColor(), $arrColors) == false) { + $arrColors[] = $fStyle->getColor(); + } + if (in_array($fStyle->getFgColor(), $arrColors) == false) { + $arrColors[] = $fStyle->getFgColor(); + } + } + } + } + } + } + + return $arrColors; + } + + private function getDataContent() + { + $phpWord = $this->_document; + $sRTFBody = ''; + + $_sections = $phpWord->getSections(); + $countSections = count($_sections); + $pSection = 0; + + if ($countSections > 0) { + foreach ($_sections as $section) { + $pSection++; + $_elements = $section->getElements(); + foreach ($_elements as $element) { + if ($element instanceof Text) { + $sRTFBody .= $this->getDataContentText($element); + } elseif ($element instanceof TextBreak) { + $sRTFBody .= $this->getDataContentTextBreak(); + } elseif ($element instanceof TextRun) { + $sRTFBody .= $this->getDataContentTextRun($element); + } elseif ($element instanceof Link) { + $sRTFBody .= $this->getDataContentUnsupportedElement('Link'); + } elseif ($element instanceof Title) { + $sRTFBody .= $this->getDataContentUnsupportedElement('Title'); + } elseif ($element instanceof PageBreak) { + $sRTFBody .= $this->getDataContentUnsupportedElement('Page Break'); + } elseif ($element instanceof Table) { + $sRTFBody .= $this->getDataContentUnsupportedElement('Table'); + } elseif ($element instanceof ListItem) { + $sRTFBody .= $this->getDataContentUnsupportedElement('List Item'); + } elseif ($element instanceof Image || + $element instanceof MemoryImage) { + $sRTFBody .= $this->getDataContentUnsupportedElement('Image'); + } elseif ($element instanceof Object) { + $sRTFBody .= $this->getDataContentUnsupportedElement('Object'); + } elseif ($element instanceof TOC) { + $sRTFBody .= $this->getDataContentUnsupportedElement('TOC'); + } else { + $sRTFBody .= $this->getDataContentUnsupportedElement('Other'); + } + } + } + } + return $sRTFBody; + } + + private function getDataContentText(Text $text, $withoutP = false) + { + $sRTFText = ''; + + $styleFont = $text->getFontStyle(); + $SfIsObject = ($styleFont instanceof Font) ? true : false; + if (!$SfIsObject) { + $styleFont = Style::getStyle($styleFont); + } + + $styleParagraph = $text->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; + if (!$SpIsObject) { + $styleParagraph = Style::getStyle($styleParagraph); + } + + if ($styleParagraph && !$withoutP) { + if ($this->_lastParagraphStyle != $text->getParagraphStyle()) { + $sRTFText .= '\pard\nowidctlpar'; + if ($styleParagraph->getSpaceAfter() != null) { + $sRTFText .= '\sa' . $styleParagraph->getSpaceAfter(); + } + if ($styleParagraph->getAlign() != null) { + if ($styleParagraph->getAlign() == 'center') { + $sRTFText .= '\qc'; + } + } + $this->_lastParagraphStyle = $text->getParagraphStyle(); + } else { + $this->_lastParagraphStyle = ''; + } + } else { + $this->_lastParagraphStyle = ''; + } + + if ($styleFont instanceof Font) { + if ($styleFont->getColor() != null) { + $idxColor = array_search($styleFont->getColor(), $this->_colorTable); + if ($idxColor !== false) { + $sRTFText .= '\cf' . ($idxColor + 1); + } + } else { + $sRTFText .= '\cf0'; + } + if ($styleFont->getName() != null) { + $idxFont = array_search($styleFont->getName(), $this->_fontTable); + if ($idxFont !== false) { + $sRTFText .= '\f' . $idxFont; + } + } else { + $sRTFText .= '\f0'; + } + if ($styleFont->getBold()) { + $sRTFText .= '\b'; + } + if ($styleFont->getBold()) { + $sRTFText .= '\i'; + } + if ($styleFont->getSize()) { + $sRTFText .= '\fs' . ($styleFont->getSize() * 2); + } + } + if ($this->_lastParagraphStyle != '' || $styleFont) { + $sRTFText .= ' '; + } + $sRTFText .= $text->getText(); + + if ($styleFont instanceof Font) { + $sRTFText .= '\cf0'; + $sRTFText .= '\f0'; + + if ($styleFont->getBold()) { + $sRTFText .= '\b0'; + } + if ($styleFont->getItalic()) { + $sRTFText .= '\i0'; + } + if ($styleFont->getSize()) { + $sRTFText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); + } + } + + if (!$withoutP) { + $sRTFText .= '\par' . PHP_EOL; + } + return $sRTFText; + } + + private function getDataContentTextRun(TextRun $textrun) + { + $sRTFText = ''; + $elements = $textrun->getElements(); + if (count($elements) > 0) { + $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; + foreach ($elements as $element) { + if ($element instanceof Text) { + $sRTFText .= '{'; + $sRTFText .= $this->getDataContentText($element, true); + $sRTFText .= '}' . PHP_EOL; + } + } + $sRTFText .= '\par' . PHP_EOL; + } + return $sRTFText; + } + + private function getDataContentTextBreak() + { + $this->_lastParagraphStyle = ''; + + return '\par' . PHP_EOL; + } + + /** + * Write unsupported element + * + * @param string $element + */ + private function getDataContentUnsupportedElement($element) + { + $sRTFText = ''; + $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; + $sRTFText .= "{$element}"; + $sRTFText .= '\par' . PHP_EOL; + + return $sRTFText; + } +} \ No newline at end of file diff --git a/src/Writer/Word2007.php b/src/Writer/Word2007.php new file mode 100644 index 0000000000..be14287083 --- /dev/null +++ b/src/Writer/Word2007.php @@ -0,0 +1,301 @@ +_document = $phpWord; + + $this->_diskCachingDirectory = './'; + + $this->_writerParts['contenttypes'] = new ContentTypes(); + $this->_writerParts['rels'] = new Rels(); + $this->_writerParts['docprops'] = new DocProps(); + $this->_writerParts['documentrels'] = new DocumentRels(); + $this->_writerParts['document'] = new Document(); + $this->_writerParts['styles'] = new Styles(); + $this->_writerParts['header'] = new Header(); + $this->_writerParts['footer'] = new Footer(); + $this->_writerParts['footnotes'] = new Footnotes(); + $this->_writerParts['footnotesrels'] = new FootnotesRels(); + + foreach ($this->_writerParts as $writer) { + $writer->setParentWriter($this); + } + } + + public function save($pFilename = null) + { + if (!is_null($this->_document)) { + + // If $pFilename is php://output or php://stdout, make it a temporary file... + $originalFilename = $pFilename; + if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + $pFilename = @tempnam('./', 'phppttmp'); + if ($pFilename == '') { + $pFilename = $originalFilename; + } + } + + // Create new ZIP file and open it for writing + $objZip = new ZipArchive(); + + // Try opening the ZIP file + if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { + if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { + throw new Exception("Could not open " . $pFilename . " for writing."); + } + } + + + $sectionElements = array(); + $_secElements = Media::getSectionMediaElements(); + foreach ($_secElements as $element) { // loop through section media elements + if ($element['type'] != 'hyperlink') { + $this->_addFileToPackage($objZip, $element); + } + $sectionElements[] = $element; + } + + $_hdrElements = Media::getHeaderMediaElements(); + foreach ($_hdrElements as $_headerFile => $_hdrMedia) { // loop through headers + if (count($_hdrMedia) > 0) { + $objZip->addFromString('word/_rels/' . $_headerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_hdrMedia)); + foreach ($_hdrMedia as $element) { // loop through header media elements + $this->_addFileToPackage($objZip, $element); + } + } + } + + $_ftrElements = Media::getFooterMediaElements(); + foreach ($_ftrElements as $_footerFile => $_ftrMedia) { // loop through footers + if (count($_ftrMedia) > 0) { + $objZip->addFromString('word/_rels/' . $_footerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_ftrMedia)); + foreach ($_ftrMedia as $element) { // loop through footers media elements + $this->_addFileToPackage($objZip, $element); + } + } + } + + $footnoteLinks = array(); + $_footnoteElements = Footnote::getFootnoteLinkElements(); + // loop through footnote link elements + foreach ($_footnoteElements as $element) { + $footnoteLinks[] = $element; + } + + $_cHdrs = 0; + $_cFtrs = 0; + $rID = Media::countSectionMediaElements() + 6; + $_sections = $this->_document->getSections(); + + $footers = array(); + foreach ($_sections as $section) { + $_headers = $section->getHeaders(); + foreach ($_headers as $index => &$_header) { + $_cHdrs++; + $_header->setRelationId(++$rID); + $_headerFile = 'header' . $_cHdrs . '.xml'; + $sectionElements[] = array('target' => $_headerFile, 'type' => 'header', 'rID' => $rID); + $objZip->addFromString('word/' . $_headerFile, $this->getWriterPart('header')->writeHeader($_header)); + } + + $_footer = $section->getFooter(); + $footers[++$_cFtrs] = $_footer; + if (!is_null($_footer)) { + $_footer->setRelationId(++$rID); + $_footerCount = $_footer->getFooterCount(); + $_footerFile = 'footer' . $_footerCount . '.xml'; + $sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID); + $objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer)); + } + } + + if (Footnote::countFootnoteElements() > 0) { + $_allFootnotesCollection = Footnote::getFootnoteElements(); + $_footnoteFile = 'footnotes.xml'; + $sectionElements[] = array('target'=>$_footnoteFile, 'type'=>'footnotes', 'rID'=>++$rID); + $objZip->addFromString('word/'.$_footnoteFile, $this->getWriterPart('footnotes')->writeFootnotes($_allFootnotesCollection)); + if (count($footnoteLinks) > 0) { + $objZip->addFromString('word/_rels/footnotes.xml.rels', $this->getWriterPart('footnotesrels')->writeFootnotesRels($footnoteLinks)); + } + } + + // build docx file + // Write dynamic files + $objZip->addFromString( + '[Content_Types].xml', + $this->getWriterPart('contenttypes')->writeContentTypes( + $this->_imageTypes, + $this->_objectTypes, + $_cHdrs, + $footers + ) + ); + $objZip->addFromString('_rels/.rels', $this->getWriterPart('rels')->writeRelationships($this->_document)); + $objZip->addFromString('docProps/app.xml', $this->getWriterPart('docprops')->writeDocPropsApp($this->_document)); + $objZip->addFromString('docProps/core.xml', $this->getWriterPart('docprops')->writeDocPropsCore($this->_document)); + $objZip->addFromString('word/document.xml', $this->getWriterPart('document')->writeDocument($this->_document)); + $objZip->addFromString('word/_rels/document.xml.rels', $this->getWriterPart('documentrels')->writeDocumentRels($sectionElements)); + $objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document)); + + // Write static files + $objZip->addFile(\PHPWORD_BASE_DIR . '_staticDocParts/numbering.xml', 'word/numbering.xml'); + $objZip->addFile(\PHPWORD_BASE_DIR . '_staticDocParts/settings.xml', 'word/settings.xml'); + $objZip->addFile(\PHPWORD_BASE_DIR . '_staticDocParts/theme1.xml', 'word/theme/theme1.xml'); + $objZip->addFile(\PHPWORD_BASE_DIR . '_staticDocParts/webSettings.xml', 'word/webSettings.xml'); + $objZip->addFile(\PHPWORD_BASE_DIR . '_staticDocParts/fontTable.xml', 'word/fontTable.xml'); + + + // Close file + if ($objZip->close() === false) { + throw new Exception("Could not close zip file $pFilename."); + } + + // If a temporary file was used, copy it to the correct file stream + if ($originalFilename != $pFilename) { + if (copy($pFilename, $originalFilename) === false) { + throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + } + @unlink($pFilename); + } + } else { + throw new Exception("PhpWord object unassigned."); + } + } + + /** + * @param string $src + */ + private function checkContentTypes($src) + { + $extension = null; + if (stripos(strrev($src), strrev('.php')) === 0) { + $extension = 'php'; + } else { + $imageType = exif_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'; + } + } + + if (isset($extension)) { + $imageData = getimagesize($src); + $imageType = image_type_to_mime_type($imageData[2]); + $imageExtension = str_replace('.', '', image_type_to_extension($imageData[2])); + if ($imageExtension === 'jpeg') { + $imageExtension = 'jpg'; + } + if (!in_array($imageType, $this->_imageTypes)) { + $this->_imageTypes[$imageExtension] = $imageType; + } + } else { + if (!in_array($extension, $this->_objectTypes)) { + $this->_objectTypes[] = $extension; + } + } + } + + public function getWriterPart($pPartName = '') + { + if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { + return $this->_writerParts[strtolower($pPartName)]; + } else { + return null; + } + } + + public function getUseDiskCaching() + { + return $this->_useDiskCaching; + } + + public function setUseDiskCaching($pValue = false, $pDirectory = null) + { + $this->_useDiskCaching = $pValue; + + if (!is_null($pDirectory)) { + if (is_dir($pDirectory)) { + $this->_diskCachingDirectory = $pDirectory; + } else { + throw new Exception("Directory does not exist: $pDirectory"); + } + } + + return $this; + } + + private function _addFileToPackage($objZip, $element) + { + if (isset($element['isMemImage']) && $element['isMemImage']) { + $image = call_user_func($element['createfunction'], $element['source']); + ob_start(); + call_user_func($element['imagefunction'], $image); + $imageContents = ob_get_contents(); + ob_end_clean(); + $objZip->addFromString('word/' . $element['target'], $imageContents); + imagedestroy($image); + + $this->checkContentTypes($element['source']); + } else { + $objZip->addFile($element['source'], 'word/' . $element['target']); + $this->checkContentTypes($element['source']); + } + } +} diff --git a/src/Writer/Word2007/Base.php b/src/Writer/Word2007/Base.php new file mode 100644 index 0000000000..f0029fc499 --- /dev/null +++ b/src/Writer/Word2007/Base.php @@ -0,0 +1,1003 @@ +getFontStyle(); + + $SfIsObject = ($styleFont instanceof Font) ? true : false; + + if (!$withoutP) { + $xmlWriter->startElement('w:p'); + + $styleParagraph = $text->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; + + if ($SpIsObject) { + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + } + + $strText = htmlspecialchars($text->getText()); + $strText = String::ControlCharacterPHP2OOXML($strText); + + $xmlWriter->startElement('w:r'); + + if ($SfIsObject) { + $this->_writeTextStyle($xmlWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text + $xmlWriter->writeRaw($strText); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); // w:r + + if (!$withoutP) { + $xmlWriter->endElement(); // w:p + } + } + + protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) + { + $elements = $textrun->getElements(); + $styleParagraph = $textrun->getParagraphStyle(); + + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; + + $xmlWriter->startElement('w:p'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + if (count($elements) > 0) { + foreach ($elements as $element) { + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element, true); + } elseif ($element instanceof Link) { + $this->_writeLink($xmlWriter, $element, true); + } elseif ($element instanceof Image) { + $this->_writeImage($xmlWriter, $element, true); + } elseif ($element instanceof Footnote) { + $this->_writeFootnoteReference($xmlWriter, $element, true); + } elseif ($element instanceof TextBreak) { + $xmlWriter->writeElement('w:br'); + } + } + } + + $xmlWriter->endElement(); + } + + /** + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Style\Paragraph $style + * @param bool $withoutPPR + * @return void + */ + protected function _writeParagraphStyle( + XMLWriter $xmlWriter = null, + Paragraph $style, + $withoutPPR = false + ) { + + $align = $style->getAlign(); + $spacing = $style->getSpacing(); + $spaceBefore = $style->getSpaceBefore(); + $spaceAfter = $style->getSpaceAfter(); + $indent = $style->getIndent(); + $hanging = $style->getHanging(); + $tabs = $style->getTabs(); + $widowControl = $style->getWidowControl(); + $keepNext = $style->getKeepNext(); + $keepLines = $style->getKeepLines(); + $pageBreakBefore = $style->getPageBreakBefore(); + + if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || + !is_null($spaceAfter) || !is_null($indent) || !is_null($hanging) || + !is_null($tabs) || !is_null($widowControl) || !is_null($keepNext) || + !is_null($keepLines) || !is_null($pageBreakBefore)) { + if (!$withoutPPR) { + $xmlWriter->startElement('w:pPr'); + } + + // Alignment + if (!is_null($align)) { + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $align); + $xmlWriter->endElement(); + } + + // Indentation + if (!is_null($indent) || !is_null($hanging)) { + $xmlWriter->startElement('w:ind'); + $xmlWriter->writeAttribute('w:firstLine', 0); + if (!is_null($indent)) { + $xmlWriter->writeAttribute('w:left', $indent); + } + if (!is_null($hanging)) { + $xmlWriter->writeAttribute('w:hanging', $hanging); + } + $xmlWriter->endElement(); + } + + // Spacing + if (!is_null($spaceBefore) || !is_null($spaceAfter) || + !is_null($spacing)) { + $xmlWriter->startElement('w:spacing'); + if (!is_null($spaceBefore)) { + $xmlWriter->writeAttribute('w:before', $spaceBefore); + } + if (!is_null($spaceAfter)) { + $xmlWriter->writeAttribute('w:after', $spaceAfter); + } + if (!is_null($spacing)) { + $xmlWriter->writeAttribute('w:line', $spacing); + $xmlWriter->writeAttribute('w:lineRule', 'auto'); + } + $xmlWriter->endElement(); + } + + // Pagination + if (!$widowControl) { + $xmlWriter->startElement('w:widowControl'); + $xmlWriter->writeAttribute('w:val', '0'); + $xmlWriter->endElement(); + } + if ($keepNext) { + $xmlWriter->startElement('w:keepNext'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); + } + if ($keepLines) { + $xmlWriter->startElement('w:keepLines'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); + } + if ($pageBreakBefore) { + $xmlWriter->startElement('w:pageBreakBefore'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); + } + + // Tabs + if (!is_null($tabs)) { + $tabs->toXml($xmlWriter); + } + + if (!$withoutPPR) { + $xmlWriter->endElement(); // w:pPr + } + } + } + + protected function _writeLink(XMLWriter $xmlWriter = null, Link $link, $withoutP = false) + { + $rID = $link->getRelationId(); + $linkName = $link->getLinkName(); + if (is_null($linkName)) { + $linkName = $link->getLinkSrc(); + } + + $styleFont = $link->getFontStyle(); + $SfIsObject = ($styleFont instanceof Font) ? true : false; + + if (!$withoutP) { + $xmlWriter->startElement('w:p'); + + $styleParagraph = $link->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; + + if ($SpIsObject) { + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + } + + $xmlWriter->startElement('w:hyperlink'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rID); + $xmlWriter->writeAttribute('w:history', '1'); + + $xmlWriter->startElement('w:r'); + if ($SfIsObject) { + $this->_writeTextStyle($xmlWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text + $xmlWriter->writeRaw($linkName); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + if (!$withoutP) { + $xmlWriter->endElement(); // w:p + } + } + + protected function _writePreserveText(XMLWriter $xmlWriter = null, PreserveText $textrun) + { + $styleFont = $textrun->getFontStyle(); + $styleParagraph = $textrun->getParagraphStyle(); + + $SfIsObject = ($styleFont instanceof Font) ? true : false; + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; + + $arrText = $textrun->getText(); + if (!is_array($arrText)) { + $arrText = array($arrText); + } + + $xmlWriter->startElement('w:p'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + foreach ($arrText as $text) { + + if (substr($text, 0, 1) == '{') { + $text = substr($text, 1, -1); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + + if ($SfIsObject) { + $this->_writeTextStyle($xmlWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'separate'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } else { + $text = htmlspecialchars($text); + $text = String::ControlCharacterPHP2OOXML($text); + + $xmlWriter->startElement('w:r'); + + if ($SfIsObject) { + $this->_writeTextStyle($xmlWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + } + + $xmlWriter->endElement(); // p + } + + protected function _writeTextStyle(XMLWriter $xmlWriter = null, Font $style) + { + $font = $style->getName(); + $bold = $style->getBold(); + $italic = $style->getItalic(); + $color = $style->getColor(); + $size = $style->getSize(); + $fgColor = $style->getFgColor(); + $strikethrough = $style->getStrikethrough(); + $underline = $style->getUnderline(); + $superscript = $style->getSuperScript(); + $subscript = $style->getSubScript(); + $hint = $style->getHint(); + + $xmlWriter->startElement('w:rPr'); + + // Font + if ($font != PhpWord::DEFAULT_FONT_NAME) { + $xmlWriter->startElement('w:rFonts'); + $xmlWriter->writeAttribute('w:ascii', $font); + $xmlWriter->writeAttribute('w:hAnsi', $font); + $xmlWriter->writeAttribute('w:eastAsia', $font); + $xmlWriter->writeAttribute('w:cs', $font); + //Font Content Type + if ($hint != PhpWord::DEFAULT_FONT_CONTENT_TYPE) { + $xmlWriter->writeAttribute('w:hint', $hint); + } + $xmlWriter->endElement(); + } + + + // Color + if ($color != PhpWord::DEFAULT_FONT_COLOR) { + $xmlWriter->startElement('w:color'); + $xmlWriter->writeAttribute('w:val', $color); + $xmlWriter->endElement(); + } + + // Size + if ($size != PhpWord::DEFAULT_FONT_SIZE) { + $xmlWriter->startElement('w:sz'); + $xmlWriter->writeAttribute('w:val', $size * 2); + $xmlWriter->endElement(); + $xmlWriter->startElement('w:szCs'); + $xmlWriter->writeAttribute('w:val', $size * 2); + $xmlWriter->endElement(); + } + + // Bold + if ($bold) { + $xmlWriter->writeElement('w:b', null); + } + + // Italic + if ($italic) { + $xmlWriter->writeElement('w:i', null); + $xmlWriter->writeElement('w:iCs', null); + } + + // Underline + if (!is_null($underline) && $underline != 'none') { + $xmlWriter->startElement('w:u'); + $xmlWriter->writeAttribute('w:val', $underline); + $xmlWriter->endElement(); + } + + // Strikethrough + if ($strikethrough) { + $xmlWriter->writeElement('w:strike', null); + } + + // Foreground-Color + if (!is_null($fgColor)) { + $xmlWriter->startElement('w:highlight'); + $xmlWriter->writeAttribute('w:val', $fgColor); + $xmlWriter->endElement(); + } + + // Superscript/subscript + if ($superscript || $subscript) { + $xmlWriter->startElement('w:vertAlign'); + $xmlWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript'); + $xmlWriter->endElement(); + } + + $xmlWriter->endElement(); + } + + /** + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\TextBreak $element + */ + protected function _writeTextBreak($xmlWriter, $element = null) + { + $hasStyle = false; + if (!is_null($element)) { + $fontStyle = $element->getFontStyle(); + $sfIsObject = ($fontStyle instanceof Font) ? true : false; + $paragraphStyle = $element->getParagraphStyle(); + $spIsObject = ($paragraphStyle instanceof Paragraph) ? true : false; + $hasStyle = !is_null($fontStyle) || !is_null($paragraphStyle); + } + if ($hasStyle) { + // Paragraph style + $xmlWriter->startElement('w:p'); + if ($spIsObject) { + $this->_writeParagraphStyle($xmlWriter, $paragraphStyle); + } elseif (!$spIsObject && !is_null($paragraphStyle)) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $paragraphStyle); + $xmlWriter->endElement(); // w:pStyle + $xmlWriter->endElement(); // w:pPr + } + // Font style + if (!is_null($fontStyle)) { + $xmlWriter->startElement('w:pPr'); + if ($sfIsObject) { + $this->_writeTextStyle($xmlWriter, $fontStyle); + } elseif (!$sfIsObject && !is_null($fontStyle)) { + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $fontStyle); + $xmlWriter->endElement(); // w:rStyle + $xmlWriter->endElement(); // w:rPr + } + $xmlWriter->endElement(); // w:pPr + } + $xmlWriter->endElement(); // w:p + } else { + // Null element. No paragraph nor font style + $xmlWriter->writeElement('w:p', null); + } + } + + protected function _writeTable(XMLWriter $xmlWriter = null, Table $table) + { + $_rows = $table->getRows(); + $_cRows = count($_rows); + + if ($_cRows > 0) { + $xmlWriter->startElement('w:tbl'); + $tblStyle = $table->getStyle(); + $tblWidth = $table->getWidth(); + if ($tblStyle instanceof PhpOffice\PhpWord\Style\Table) { + $this->_writeTableStyle($xmlWriter, $tblStyle); + } else { + if (!empty($tblStyle)) { + $xmlWriter->startElement('w:tblPr'); + $xmlWriter->startElement('w:tblStyle'); + $xmlWriter->writeAttribute('w:val', $tblStyle); + $xmlWriter->endElement(); + if (!is_null($tblWidth)) { + $xmlWriter->startElement('w:tblW'); + $xmlWriter->writeAttribute('w:w', $tblWidth); + $xmlWriter->writeAttribute('w:type', 'pct'); + $xmlWriter->endElement(); + } + $xmlWriter->endElement(); + } + } + + for ($i = 0; $i < $_cRows; $i++) { + $row = $_rows[$i]; + $height = $row->getHeight(); + $rowStyle = $row->getStyle(); + $tblHeader = $rowStyle->getTblHeader(); + $cantSplit = $rowStyle->getCantSplit(); + + $xmlWriter->startElement('w:tr'); + + if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) { + $xmlWriter->startElement('w:trPr'); + if (!is_null($height)) { + $xmlWriter->startElement('w:trHeight'); + $xmlWriter->writeAttribute('w:val', $height); + $xmlWriter->endElement(); + } + if ($tblHeader) { + $xmlWriter->startElement('w:tblHeader'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); + } + if ($cantSplit) { + $xmlWriter->startElement('w:cantSplit'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); + } + $xmlWriter->endElement(); + } + + foreach ($row->getCells() as $cell) { + $xmlWriter->startElement('w:tc'); + + $cellStyle = $cell->getStyle(); + $width = $cell->getWidth(); + + $xmlWriter->startElement('w:tcPr'); + $xmlWriter->startElement('w:tcW'); + $xmlWriter->writeAttribute('w:w', $width); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); + + if ($cellStyle instanceof Cell) { + $this->_writeCellStyle($xmlWriter, $cellStyle); + } + + $xmlWriter->endElement(); + + $_elements = $cell->getElements(); + if (count($_elements) > 0) { + foreach ($_elements as $element) { + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof Link) { + $this->_writeLink($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter, $element); + } elseif ($element instanceof ListItem) { + $this->_writeListItem($xmlWriter, $element); + } elseif ($element instanceof Image || + $element instanceof MemoryImage + ) { + $this->_writeImage($xmlWriter, $element); + } elseif ($element instanceof Object) { + $this->_writeObject($xmlWriter, $element); + } elseif ($element instanceof PreserveText) { + $this->_writePreserveText($xmlWriter, $element); + } + } + } else { + $this->_writeTextBreak($xmlWriter); + } + + $xmlWriter->endElement(); + } + $xmlWriter->endElement(); + } + $xmlWriter->endElement(); + } + } + + protected function _writeTableStyle( + XMLWriter $xmlWriter = null, + PhpOffice\PhpWord\Style\Table $style = null + ) { + $margins = $style->getCellMargin(); + $mTop = (!is_null($margins[0])) ? true : false; + $mLeft = (!is_null($margins[1])) ? true : false; + $mRight = (!is_null($margins[2])) ? true : false; + $mBottom = (!is_null($margins[3])) ? true : false; + + if ($mTop || $mLeft || $mRight || $mBottom) { + $xmlWriter->startElement('w:tblPr'); + $xmlWriter->startElement('w:tblCellMar'); + + if ($mTop) { + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:w', $margins[0]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); + } + + if ($mLeft) { + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:w', $margins[1]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); + } + + if ($mRight) { + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:w', $margins[2]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); + } + + if ($mBottom) { + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:w', $margins[3]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); + } + + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + } + + protected function _writeCellStyle(XMLWriter $xmlWriter = null, Cell $style = null) + { + $bgColor = $style->getBgColor(); + $valign = $style->getVAlign(); + $textDir = $style->getTextDirection(); + $brdSz = $style->getBorderSize(); + $brdCol = $style->getBorderColor(); + + $bTop = (!is_null($brdSz[0])) ? true : false; + $bLeft = (!is_null($brdSz[1])) ? true : false; + $bRight = (!is_null($brdSz[2])) ? true : false; + $bBottom = (!is_null($brdSz[3])) ? true : false; + $borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false; + + $styles = (!is_null($bgColor) || !is_null($valign) || !is_null($textDir) || $borders) ? true : false; + + if ($styles) { + if (!is_null($textDir)) { + $xmlWriter->startElement('w:textDirection'); + $xmlWriter->writeAttribute('w:val', $textDir); + $xmlWriter->endElement(); + } + + if (!is_null($bgColor)) { + $xmlWriter->startElement('w:shd'); + $xmlWriter->writeAttribute('w:val', 'clear'); + $xmlWriter->writeAttribute('w:color', 'auto'); + $xmlWriter->writeAttribute('w:fill', $bgColor); + $xmlWriter->endElement(); + } + + if (!is_null($valign)) { + $xmlWriter->startElement('w:vAlign'); + $xmlWriter->writeAttribute('w:val', $valign); + $xmlWriter->endElement(); + } + + if ($borders) { + $_defaultColor = $style->getDefaultBorderColor(); + + $xmlWriter->startElement('w:tcBorders'); + if ($bTop) { + if (is_null($brdCol[0])) { + $brdCol[0] = $_defaultColor; + } + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[0]); + $xmlWriter->writeAttribute('w:color', $brdCol[0]); + $xmlWriter->endElement(); + } + + if ($bLeft) { + if (is_null($brdCol[1])) { + $brdCol[1] = $_defaultColor; + } + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[1]); + $xmlWriter->writeAttribute('w:color', $brdCol[1]); + $xmlWriter->endElement(); + } + + if ($bRight) { + if (is_null($brdCol[2])) { + $brdCol[2] = $_defaultColor; + } + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[2]); + $xmlWriter->writeAttribute('w:color', $brdCol[2]); + $xmlWriter->endElement(); + } + + if ($bBottom) { + if (is_null($brdCol[3])) { + $brdCol[3] = $_defaultColor; + } + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[3]); + $xmlWriter->writeAttribute('w:color', $brdCol[3]); + $xmlWriter->endElement(); + } + + $xmlWriter->endElement(); + } + } + $gridSpan = $style->getGridSpan(); + if (!is_null($gridSpan)) { + $xmlWriter->startElement('w:gridSpan'); + $xmlWriter->writeAttribute('w:val', $gridSpan); + $xmlWriter->endElement(); + } + + $vMerge = $style->getVMerge(); + if (!is_null($vMerge)) { + $xmlWriter->startElement('w:vMerge'); + $xmlWriter->writeAttribute('w:val', $vMerge); + $xmlWriter->endElement(); + } + } + + /** + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Image|PhpOffice\PhpWord\Section\MemoryImage $image + */ + protected function _writeImage(XMLWriter $xmlWriter = null, $image, $withoutP = false) + { + $rId = $image->getRelationId(); + + $style = $image->getStyle(); + $width = $style->getWidth(); + $height = $style->getHeight(); + $align = $style->getAlign(); + $marginTop = $style->getMarginTop(); + $marginLeft = $style->getMarginLeft(); + $wrappingStyle = $style->getWrappingStyle(); + + if (!$withoutP) { + $xmlWriter->startElement('w:p'); + + if (!is_null($align)) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $align); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + } + + $xmlWriter->startElement('w:r'); + + $xmlWriter->startElement('w:pict'); + + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('type', '#_x0000_t75'); + + $imgStyle = ''; + if (null !== $width) { + $imgStyle .= 'width:' . $width . 'px;'; + } + if (null !== $height) { + $imgStyle .= 'height:' . $height . 'px;'; + } + if (null !== $marginTop) { + $imgStyle .= 'margin-top:' . $marginTop . 'in;'; + } + if (null !== $marginLeft) { + $imgStyle .= 'margin-left:' . $marginLeft . 'in;'; + } + + switch ($wrappingStyle) { + case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND: + $imgStyle .= 'position:absolute;z-index:-251658752;'; + break; + case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE: + $imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; + break; + case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_TIGHT: + $imgStyle .= 'position:absolute;z-index:251659264;mso-wrap-edited:f;mso-position-horizontal:absolute;mso-position-vertical:absolute'; + break; + case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_INFRONT: + $imgStyle .= 'position:absolute;zz-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; + break; + } + + $xmlWriter->writeAttribute('style', $imgStyle); + + $xmlWriter->startElement('v:imagedata'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->writeAttribute('o:title', ''); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + if (!$withoutP) { + $xmlWriter->endElement(); // w:p + } + } + + protected function _writeWatermark(XMLWriter $xmlWriter = null, $image) + { + $rId = $image->getRelationId(); + + $style = $image->getStyle(); + $width = $style->getWidth(); + $height = $style->getHeight(); + $marginLeft = $style->getMarginLeft(); + $marginTop = $style->getMarginTop(); + + $xmlWriter->startElement('w:p'); + + $xmlWriter->startElement('w:r'); + + $xmlWriter->startElement('w:pict'); + + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('type', '#_x0000_t75'); + + $strStyle = 'position:absolute;'; + $strStyle .= ' width:' . $width . 'px;'; + $strStyle .= ' height:' . $height . 'px;'; + if (!is_null($marginTop)) { + $strStyle .= ' margin-top:' . $marginTop . 'px;'; + } + if (!is_null($marginLeft)) { + $strStyle .= ' margin-left:' . $marginLeft . 'px;'; + } + + $xmlWriter->writeAttribute('style', $strStyle); + + $xmlWriter->startElement('v:imagedata'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->writeAttribute('o:title', ''); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + } + + protected function _writeTitle(XMLWriter $xmlWriter = null, Title $title) + { + $text = htmlspecialchars($title->getText()); + $text = String::ControlCharacterPHP2OOXML($text); + $anchor = $title->getAnchor(); + $bookmarkId = $title->getBookmarkId(); + $style = $title->getStyle(); + + $xmlWriter->startElement('w:p'); + + if (!empty($style)) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $style); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:bookmarkStart'); + $xmlWriter->writeAttribute('w:id', $bookmarkId); + $xmlWriter->writeAttribute('w:name', $anchor); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:t'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:bookmarkEnd'); + $xmlWriter->writeAttribute('w:id', $bookmarkId); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + } + + protected function _writeFootnote(XMLWriter $xmlWriter = null, Footnote $footnote) + { + $xmlWriter->startElement('w:footnote'); + $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId()); + + $styleParagraph = $footnote->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; + + $xmlWriter->startElement('w:p'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($xmlWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $elements = $footnote->getElements(); + if (count($elements) > 0) { + foreach ($elements as $element) { + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element, true); + } elseif ($element instanceof Link) { + $this->_writeLink($xmlWriter, $element, true); + } + } + } + + $xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:footnote + } + + protected function _writeFootnoteReference(XMLWriter $xmlWriter = null, Footnote $footnote, $withoutP = false) + { + if (!$withoutP) { + $xmlWriter->startElement('w:p'); + } + + $xmlWriter->startElement('w:r'); + + $xmlWriter->startElement('w:footnoteReference'); + $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId()); + $xmlWriter->endElement(); // w:footnoteReference + + $xmlWriter->endElement(); // w:r + + if (!$withoutP) { + $xmlWriter->endElement(); // w:p + } + } +} diff --git a/src/Writer/Word2007/ContentTypes.php b/src/Writer/Word2007/ContentTypes.php new file mode 100644 index 0000000000..2d84070d01 --- /dev/null +++ b/src/Writer/Word2007/ContentTypes.php @@ -0,0 +1,228 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Types + $xmlWriter->startElement('Types'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); + + // Rels + $this->_writeDefaultContentType( + $xmlWriter, + 'rels', + 'application/vnd.openxmlformats-package.relationships+xml' + ); + + // XML + $this->_writeDefaultContentType( + $xmlWriter, + 'xml', + 'application/xml' + ); + + // Add media content-types + foreach ($_imageTypes as $key => $value) { + $this->_writeDefaultContentType($xmlWriter, $key, $value); + } + + // Add embedding content-types + if (count($_objectTypes) > 0) { + $this->_writeDefaultContentType( + $xmlWriter, + 'bin', + 'application/vnd.openxmlformats-officedocument.oleObject' + ); + } + + // DocProps + $this->_writeOverrideContentType( + $xmlWriter, + '/docProps/app.xml', + 'application/vnd.openxmlformats-officedocument.extended-properties+xml' + ); + + $this->_writeOverrideContentType( + $xmlWriter, + '/docProps/core.xml', + 'application/vnd.openxmlformats-package.core-properties+xml' + ); + + // Document + $this->_writeOverrideContentType( + $xmlWriter, + '/word/document.xml', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml' + ); + + // Styles + $this->_writeOverrideContentType( + $xmlWriter, + '/word/styles.xml', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml' + ); + + // Numbering + $this->_writeOverrideContentType( + $xmlWriter, + '/word/numbering.xml', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml' + ); + + // Settings + $this->_writeOverrideContentType( + $xmlWriter, + '/word/settings.xml', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml' + ); + + // Theme1 + $this->_writeOverrideContentType( + $xmlWriter, + '/word/theme/theme1.xml', + 'application/vnd.openxmlformats-officedocument.theme+xml' + ); + + // WebSettings + $this->_writeOverrideContentType( + $xmlWriter, + '/word/webSettings.xml', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml' + ); + + // Font Table + $this->_writeOverrideContentType( + $xmlWriter, + '/word/fontTable.xml', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml' + ); + + // Footnotes + $this->_writeOverrideContentType( + $xmlWriter, + '/word/footnotes.xml', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml' + ); + + for ($i = 1; $i <= $_cHdrs; $i++) { + $this->_writeOverrideContentType( + $xmlWriter, + '/word/header' . $i . '.xml', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml' + ); + } + + for ($i = 1; $i <= count($footers); $i++) { + if (!is_null($footers[$i])) { + $this->_writeOverrideContentType( + $xmlWriter, + '/word/footer' . $i . '.xml', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml' + ); + } + } + + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } + + /** + * Get image mime type + * + * @param string $pFile Filename + * @return string Mime Type + * @throws Exception + */ + private function _getImageMimeType($pFile = '') + { + if (File::file_exists($pFile)) { + $image = getimagesize($pFile); + return image_type_to_mime_type($image[2]); + } else { + throw new Exception("File $pFile does not exist"); + } + } + + /** + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception + */ + private function _writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') + { + if ($pPartname != '' && $pContentType != '') { + // Write content type + $xmlWriter->startElement('Default'); + $xmlWriter->writeAttribute('Extension', $pPartname); + $xmlWriter->writeAttribute('ContentType', $pContentType); + $xmlWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } + + /** + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception + */ + private function _writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') + { + if ($pPartname != '' && $pContentType != '') { + // Write content type + $xmlWriter->startElement('Override'); + $xmlWriter->writeAttribute('PartName', $pPartname); + $xmlWriter->writeAttribute('ContentType', $pContentType); + $xmlWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } +} diff --git a/src/Writer/Word2007/DocProps.php b/src/Writer/Word2007/DocProps.php new file mode 100644 index 0000000000..98a5abb871 --- /dev/null +++ b/src/Writer/Word2007/DocProps.php @@ -0,0 +1,186 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Properties + $xmlWriter->startElement('Properties'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); + $xmlWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); + + // Application + $xmlWriter->writeElement('Application', 'Microsoft Office Word'); + + // ScaleCrop + $xmlWriter->writeElement('ScaleCrop', 'false'); + + // HeadingPairs + $xmlWriter->startElement('HeadingPairs'); + + // Vector + $xmlWriter->startElement('vt:vector'); + $xmlWriter->writeAttribute('size', '4'); + $xmlWriter->writeAttribute('baseType', 'variant'); + + // Variant + $xmlWriter->startElement('vt:variant'); + $xmlWriter->writeElement('vt:lpstr', 'Theme'); + $xmlWriter->endElement(); + + // Variant + $xmlWriter->startElement('vt:variant'); + $xmlWriter->writeElement('vt:i4', '1'); + $xmlWriter->endElement(); + + // Variant + $xmlWriter->startElement('vt:variant'); + $xmlWriter->writeElement('vt:lpstr', 'Slide Titles'); + $xmlWriter->endElement(); + + // Variant + $xmlWriter->startElement('vt:variant'); + $xmlWriter->writeElement('vt:i4', '1'); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + // TitlesOfParts + $xmlWriter->startElement('TitlesOfParts'); + + // Vector + $xmlWriter->startElement('vt:vector'); + $xmlWriter->writeAttribute('size', '1'); + $xmlWriter->writeAttribute('baseType', 'lpstr'); + + $xmlWriter->writeElement('vt:lpstr', 'Office Theme'); + + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + // Company + $xmlWriter->writeElement('Company', $phpWord->getDocumentProperties()->getCompany()); + + // LinksUpToDate + $xmlWriter->writeElement('LinksUpToDate', 'false'); + + // SharedDoc + $xmlWriter->writeElement('SharedDoc', 'false'); + + // HyperlinksChanged + $xmlWriter->writeElement('HyperlinksChanged', 'false'); + + // AppVersion + $xmlWriter->writeElement('AppVersion', '12.0000'); + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } + + + public function writeDocPropsCore(PhpWord $phpWord = null) + { + // Create XML writer + $xmlWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // cp:coreProperties + $xmlWriter->startElement('cp:coreProperties'); + $xmlWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); + $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $xmlWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); + $xmlWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); + $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); + + // dc:creator + $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getCreator()); + + // cp:lastModifiedBy + $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getDocumentProperties()->getLastModifiedBy()); + + // dcterms:created + $xmlWriter->startElement('dcterms:created'); + $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); + $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getCreated())); + $xmlWriter->endElement(); + + // dcterms:modified + $xmlWriter->startElement('dcterms:modified'); + $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); + $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getModified())); + $xmlWriter->endElement(); + + // dc:title + $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); + + // dc:description + $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); + + // dc:subject + $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); + + // cp:keywords + $xmlWriter->writeElement('cp:keywords', $phpWord->getDocumentProperties()->getKeywords()); + + // cp:category + $xmlWriter->writeElement('cp:category', $phpWord->getDocumentProperties()->getCategory()); + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } +} diff --git a/src/Writer/Word2007/Document.php b/src/Writer/Word2007/Document.php new file mode 100644 index 0000000000..f865c41c47 --- /dev/null +++ b/src/Writer/Word2007/Document.php @@ -0,0 +1,506 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // w:document + $xmlWriter->startElement('w:document'); + + $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); + $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); + $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); + $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); + + $xmlWriter->startElement('w:body'); + + $_sections = $phpWord->getSections(); + $countSections = count($_sections); + $pSection = 0; + + if ($countSections > 0) { + foreach ($_sections as $section) { + $pSection++; + + $_elements = $section->getElements(); + + foreach ($_elements as $element) { + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof Link) { + $this->_writeLink($xmlWriter, $element); + } elseif ($element instanceof Title) { + $this->_writeTitle($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter, $element); + } elseif ($element instanceof PageBreak) { + $this->_writePageBreak($xmlWriter); + } elseif ($element instanceof Table) { + $this->_writeTable($xmlWriter, $element); + } elseif ($element instanceof ListItem) { + $this->_writeListItem($xmlWriter, $element); + } elseif ($element instanceof Image || + $element instanceof MemoryImage + ) { + $this->_writeImage($xmlWriter, $element); + } elseif ($element instanceof Object) { + $this->_writeObject($xmlWriter, $element); + } elseif ($element instanceof TOC) { + $this->_writeTOC($xmlWriter); + } elseif ($element instanceof Footnote) { + $this->_writeFootnoteReference($xmlWriter, $element); + } + } + + if ($pSection == $countSections) { + $this->_writeEndSection($xmlWriter, $section); + } else { + $this->_writeSection($xmlWriter, $section); + } + } + } + + $xmlWriter->endElement(); // End w:body + $xmlWriter->endElement(); // End w:document + + // Return + return $xmlWriter->getData(); + } + + private function _writeSection(XMLWriter $xmlWriter = null, Section $section) + { + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:pPr'); + $this->_writeEndSection($xmlWriter, $section, 3); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section) + { + $settings = $section->getSettings(); + $_headers = $section->getHeaders(); + $_footer = $section->getFooter(); + $pgSzW = $settings->getPageSizeW(); + $pgSzH = $settings->getPageSizeH(); + $orientation = $settings->getOrientation(); + + $marginTop = $settings->getMarginTop(); + $marginLeft = $settings->getMarginLeft(); + $marginRight = $settings->getMarginRight(); + $marginBottom = $settings->getMarginBottom(); + + $headerHeight = $settings->getHeaderHeight(); + $footerHeight = $settings->getFooterHeight(); + + $borders = $settings->getBorderSize(); + + $colsNum = $settings->getColsNum(); + $colsSpace = $settings->getColsSpace(); + $breakType = $settings->getBreakType(); + + $xmlWriter->startElement('w:sectPr'); + + foreach ($_headers as &$_header) { + $rId = $_header->getRelationId(); + $xmlWriter->startElement('w:headerReference'); + $xmlWriter->writeAttribute('w:type', $_header->getType()); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->endElement(); + } + + if ($section->hasDifferentFirstPage()) { + $xmlWriter->startElement('w:titlePg'); + $xmlWriter->endElement(); + } + + if (!is_null($breakType)) { + $xmlWriter->startElement('w:type'); + $xmlWriter->writeAttribute('w:val', $breakType); + $xmlWriter->endElement(); + } + + if (!is_null($_footer)) { + $rId = $_footer->getRelationId(); + $xmlWriter->startElement('w:footerReference'); + $xmlWriter->writeAttribute('w:type', 'default'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:pgSz'); + $xmlWriter->writeAttribute('w:w', $pgSzW); + $xmlWriter->writeAttribute('w:h', $pgSzH); + + if (!is_null($orientation) && strtolower($orientation) != 'portrait') { + $xmlWriter->writeAttribute('w:orient', $orientation); + } + + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:pgMar'); + $xmlWriter->writeAttribute('w:top', $marginTop); + $xmlWriter->writeAttribute('w:right', $marginRight); + $xmlWriter->writeAttribute('w:bottom', $marginBottom); + $xmlWriter->writeAttribute('w:left', $marginLeft); + $xmlWriter->writeAttribute('w:header', $headerHeight); + $xmlWriter->writeAttribute('w:footer', $footerHeight); + $xmlWriter->writeAttribute('w:gutter', '0'); + $xmlWriter->endElement(); + + + if (!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) { + $borderColor = $settings->getBorderColor(); + + $xmlWriter->startElement('w:pgBorders'); + $xmlWriter->writeAttribute('w:offsetFrom', 'page'); + + if (!is_null($borders[0])) { + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $borders[0]); + $xmlWriter->writeAttribute('w:space', '24'); + $xmlWriter->writeAttribute('w:color', $borderColor[0]); + $xmlWriter->endElement(); + } + + if (!is_null($borders[1])) { + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $borders[1]); + $xmlWriter->writeAttribute('w:space', '24'); + $xmlWriter->writeAttribute('w:color', $borderColor[1]); + $xmlWriter->endElement(); + } + + if (!is_null($borders[2])) { + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $borders[2]); + $xmlWriter->writeAttribute('w:space', '24'); + $xmlWriter->writeAttribute('w:color', $borderColor[2]); + $xmlWriter->endElement(); + } + + if (!is_null($borders[3])) { + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $borders[3]); + $xmlWriter->writeAttribute('w:space', '24'); + $xmlWriter->writeAttribute('w:color', $borderColor[3]); + $xmlWriter->endElement(); + } + $xmlWriter->endElement(); + } + + // Page numbering + if (null !== $settings->getPageNumberingStart()) { + $xmlWriter->startElement('w:pgNumType'); + $xmlWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart()); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:cols'); + $xmlWriter->writeAttribute('w:num', $colsNum); + $xmlWriter->writeAttribute('w:space', $colsSpace); + $xmlWriter->endElement(); + + + $xmlWriter->endElement(); + } + + private function _writePageBreak(XMLWriter $xmlWriter = null) + { + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:br'); + $xmlWriter->writeAttribute('w:type', 'page'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + public function _writeListItem(XMLWriter $xmlWriter = null, ListItem $listItem) + { + $textObject = $listItem->getTextObject(); + $text = $textObject->getText(); + $styleParagraph = $textObject->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; + + $depth = $listItem->getDepth(); + $listType = $listItem->getStyle()->getListType(); + + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:pPr'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($xmlWriter, $styleParagraph, true); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleParagraph); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:numPr'); + + $xmlWriter->startElement('w:ilvl'); + $xmlWriter->writeAttribute('w:val', $depth); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:numId'); + $xmlWriter->writeAttribute('w:val', $listType); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $this->_writeText($xmlWriter, $textObject, true); + + $xmlWriter->endElement(); + } + + protected function _writeObject(XMLWriter $xmlWriter = null, Object $object) + { + $rIdObject = $object->getRelationId(); + $rIdImage = $object->getImageRelationId(); + $shapeId = md5($rIdObject . '_' . $rIdImage); + + $objectId = $object->getObjectId(); + + $style = $object->getStyle(); + $width = $style->getWidth(); + $height = $style->getHeight(); + $align = $style->getAlign(); + + + $xmlWriter->startElement('w:p'); + + if (!is_null($align)) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $align); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:r'); + + $xmlWriter->startElement('w:object'); + $xmlWriter->writeAttribute('w:dxaOrig', '249'); + $xmlWriter->writeAttribute('w:dyaOrig', '160'); + + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('id', $shapeId); + $xmlWriter->writeAttribute('type', '#_x0000_t75'); + $xmlWriter->writeAttribute('style', 'width:104px;height:67px'); + $xmlWriter->writeAttribute('o:ole', ''); + + $xmlWriter->startElement('v:imagedata'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rIdImage); + $xmlWriter->writeAttribute('o:title', ''); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + $xmlWriter->startElement('o:OLEObject'); + $xmlWriter->writeAttribute('Type', 'Embed'); + $xmlWriter->writeAttribute('ProgID', 'Package'); + $xmlWriter->writeAttribute('ShapeID', $shapeId); + $xmlWriter->writeAttribute('DrawAspect', 'Icon'); + $xmlWriter->writeAttribute('ObjectID', '_' . $objectId); + $xmlWriter->writeAttribute('r:id', 'rId' . $rIdObject); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + $xmlWriter->endElement(); // w:r + + $xmlWriter->endElement(); // w:p + } + + private function _writeTOC(XMLWriter $xmlWriter = null) + { + $titles = TOC::getTitles(); + $styleFont = TOC::getStyleFont(); + + $styleTOC = TOC::getStyleTOC(); + $fIndent = $styleTOC->getIndent(); + $tabLeader = $styleTOC->getTabLeader(); + $tabPos = $styleTOC->getTabPos(); + + $isObject = ($styleFont instanceof Font) ? true : false; + + for ($i = 0; $i < count($titles); $i++) { + $title = $titles[$i]; + $indent = ($title['depth'] - 1) * $fIndent; + + $xmlWriter->startElement('w:p'); + + $xmlWriter->startElement('w:pPr'); + + if ($isObject && !is_null($styleFont->getParagraphStyle())) { + $this->_writeParagraphStyle($xmlWriter, $styleFont->getParagraphStyle()); + } + + if ($indent > 0) { + $xmlWriter->startElement('w:ind'); + $xmlWriter->writeAttribute('w:left', $indent); + $xmlWriter->endElement(); + } + + if (!empty($styleFont) && !$isObject) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $styleFont); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:tabs'); + $xmlWriter->startElement('w:tab'); + $xmlWriter->writeAttribute('w:val', 'right'); + if (!empty($tabLeader)) { + $xmlWriter->writeAttribute('w:leader', $tabLeader); + } + $xmlWriter->writeAttribute('w:pos', $tabPos); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); // w:pPr + + + if ($i == 0) { + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw('TOC \o "1-9" \h \z \u'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'separate'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:hyperlink'); + $xmlWriter->writeAttribute('w:anchor', $title['anchor']); + $xmlWriter->writeAttribute('w:history', '1'); + + $xmlWriter->startElement('w:r'); + + if ($isObject) { + $this->_writeTextStyle($xmlWriter, $styleFont); + } + + $xmlWriter->startElement('w:t'); + $xmlWriter->writeRaw($title['text']); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->writeElement('w:tab', null); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); // w:hyperlink + + $xmlWriter->endElement(); // w:p + } + + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } +} diff --git a/src/Writer/Word2007/DocumentRels.php b/src/Writer/Word2007/DocumentRels.php new file mode 100644 index 0000000000..176dd05512 --- /dev/null +++ b/src/Writer/Word2007/DocumentRels.php @@ -0,0 +1,182 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Relationships + $xmlWriter->startElement('Relationships'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + // Relationship word/document.xml + $this->_writeRelationship( + $xmlWriter, + 1, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + 'styles.xml' + ); + + // Relationship word/numbering.xml + $this->_writeRelationship( + $xmlWriter, + 2, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering', + 'numbering.xml' + ); + + // Relationship word/settings.xml + $this->_writeRelationship( + $xmlWriter, + 3, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings', + 'settings.xml' + ); + + // Relationship word/settings.xml + $this->_writeRelationship( + $xmlWriter, + 4, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + 'theme/theme1.xml' + ); + + // Relationship word/settings.xml + $this->_writeRelationship( + $xmlWriter, + 5, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings', + 'webSettings.xml' + ); + + // Relationship word/settings.xml + $this->_writeRelationship( + $xmlWriter, + 6, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable', + 'fontTable.xml' + ); + + // Relationships to Images / Embeddings / Headers / Footers + foreach ($_relsCollection as $relation) { + $relationType = $relation['type']; + $relationName = $relation['target']; + $relationId = $relation['rID']; + $targetMode = ($relationType == 'hyperlink') ? 'External' : ''; + + $this->_writeRelationship( + $xmlWriter, + $relationId, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, + $relationName, + $targetMode + ); + } + + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } + + public function writeHeaderFooterRels($_relsCollection) + { + // Create XML writer + $xmlWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Relationships + $xmlWriter->startElement('Relationships'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + // Relationships to Images / Embeddings / Headers / Footers + foreach ($_relsCollection as $relation) { + $relationType = $relation['type']; + $relationName = $relation['target']; + $relationId = $relation['rID']; + + $this->_writeRelationship( + $xmlWriter, + $relationId, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, + $relationName + ); + } + + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } + + private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') + { + if ($pType != '' && $pTarget != '') { + if (strpos($pId, 'rId') === false) { + $pId = 'rId' . $pId; + } + + // Write relationship + $xmlWriter->startElement('Relationship'); + $xmlWriter->writeAttribute('Id', $pId); + $xmlWriter->writeAttribute('Type', $pType); + $xmlWriter->writeAttribute('Target', $pTarget); + + if ($pTargetMode != '') { + $xmlWriter->writeAttribute('TargetMode', $pTargetMode); + } + + $xmlWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } +} diff --git a/src/Writer/Word2007/Footer.php b/src/Writer/Word2007/Footer.php new file mode 100644 index 0000000000..f3ef2a1fb4 --- /dev/null +++ b/src/Writer/Word2007/Footer.php @@ -0,0 +1,90 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + $xmlWriter->startElement('w:ftr'); + $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); + $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); + $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); + $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); + + $_elements = $footer->getElements(); + + foreach ($_elements as $element) { + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter, $element); + } elseif ($element instanceof Table) { + $this->_writeTable($xmlWriter, $element); + } elseif ($element instanceof Image || + $element instanceof MemoryImage + ) { + $this->_writeImage($xmlWriter, $element); + } elseif ($element instanceof PreserveText) { + $this->_writePreserveText($xmlWriter, $element); + } + } + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } +} diff --git a/src/Writer/Word2007/Footnotes.php b/src/Writer/Word2007/Footnotes.php new file mode 100644 index 0000000000..d467859f90 --- /dev/null +++ b/src/Writer/Word2007/Footnotes.php @@ -0,0 +1,87 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + $xmlWriter->startElement('w:footnotes'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + + // write separator and continuation separator + $xmlWriter->startElement('w:footnote'); + $xmlWriter->writeAttribute('w:id', 0); + $xmlWriter->writeAttribute('w:type', 'separator'); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:separator'); + $xmlWriter->endElement(); // w:separator + $xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:footnote + + $xmlWriter->startElement('w:footnote'); + $xmlWriter->writeAttribute('w:id', 1); + $xmlWriter->writeAttribute('w:type', 'continuationSeparator'); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:continuationSeparator'); + $xmlWriter->endElement(); // w:continuationSeparator + $xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:footnote + + + foreach ($allFootnotesCollection as $footnote) { + if ($footnote instanceof Footnote) { + $this->_writeFootnote($xmlWriter, $footnote); + } + } + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } +} diff --git a/src/Writer/Word2007/FootnotesRels.php b/src/Writer/Word2007/FootnotesRels.php new file mode 100644 index 0000000000..b181987676 --- /dev/null +++ b/src/Writer/Word2007/FootnotesRels.php @@ -0,0 +1,89 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Relationships + $xmlWriter->startElement('Relationships'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + // Relationships to Links + foreach ($_relsCollection as $relation) { + $relationType = $relation['type']; + $relationName = $relation['target']; + $relationId = $relation['rID']; + $targetMode = ($relationType == 'hyperlink') ? 'External' : ''; + + $this->_writeRelationship($xmlWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName, $targetMode); + } + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } + + private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') + { + if ($pType != '' && $pTarget != '') { + if (strpos($pId, 'rId') === false) { + $pId = 'rId' . $pId; + } + + // Write relationship + $xmlWriter->startElement('Relationship'); + $xmlWriter->writeAttribute('Id', $pId); + $xmlWriter->writeAttribute('Type', $pType); + $xmlWriter->writeAttribute('Target', $pTarget); + + if ($pTargetMode != '') { + $xmlWriter->writeAttribute('TargetMode', $pTargetMode); + } + + $xmlWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } +} diff --git a/src/Writer/Word2007/Header.php b/src/Writer/Word2007/Header.php new file mode 100644 index 0000000000..aef2c38a7c --- /dev/null +++ b/src/Writer/Word2007/Header.php @@ -0,0 +1,94 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + $xmlWriter->startElement('w:hdr'); + $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); + $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); + $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); + $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); + + + $_elements = $header->getElements(); + + foreach ($_elements as $element) { + if ($element instanceof Text) { + $this->_writeText($xmlWriter, $element); + } elseif ($element instanceof TextRun) { + $this->_writeTextRun($xmlWriter, $element); + } elseif ($element instanceof TextBreak) { + $this->_writeTextBreak($xmlWriter, $element); + } elseif ($element instanceof Table) { + $this->_writeTable($xmlWriter, $element); + } elseif ($element instanceof Image || + $element instanceof MemoryImage + ) { + if (!$element->getIsWatermark()) { + $this->_writeImage($xmlWriter, $element); + } else { + $this->_writeWatermark($xmlWriter, $element); + } + } elseif ($element instanceof PreserveText) { + $this->_writePreserveText($xmlWriter, $element); + } + } + + $xmlWriter->endElement(); + + // Return + return $xmlWriter->getData(); + } +} diff --git a/src/Writer/Word2007/Rels.php b/src/Writer/Word2007/Rels.php new file mode 100644 index 0000000000..09de0e63fb --- /dev/null +++ b/src/Writer/Word2007/Rels.php @@ -0,0 +1,115 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Relationships + $xmlWriter->startElement('Relationships'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + $relationId = 1; + + // Relationship word/document.xml + $this->_writeRelationship( + $xmlWriter, + $relationId, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + 'word/document.xml' + ); + + // Relationship docProps/core.xml + $this->_writeRelationship( + $xmlWriter, + ++$relationId, + 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + 'docProps/core.xml' + ); + + // Relationship docProps/app.xml + $this->_writeRelationship( + $xmlWriter, + ++$relationId, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + 'docProps/app.xml' + ); + + $xmlWriter->endElement(); + + return $xmlWriter->getData(); + } + + /** + * Write Override content type + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param int $pId Relationship ID. rId will be prepended! + * @param string $pType Relationship type + * @param string $pTarget Relationship target + * @param string $pTargetMode Relationship target mode + * @throws Exception + */ + private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') + { + if ($pType != '' && $pTarget != '') { + if (strpos($pId, 'rId') === false) { + $pId = 'rId' . $pId; + } + + // Write relationship + $xmlWriter->startElement('Relationship'); + $xmlWriter->writeAttribute('Id', $pId); + $xmlWriter->writeAttribute('Type', $pType); + $xmlWriter->writeAttribute('Target', $pTarget); + + if ($pTargetMode != '') { + $xmlWriter->writeAttribute('TargetMode', $pTargetMode); + } + + $xmlWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } +} diff --git a/src/Writer/Word2007/Styles.php b/src/Writer/Word2007/Styles.php new file mode 100644 index 0000000000..81ee36ef2a --- /dev/null +++ b/src/Writer/Word2007/Styles.php @@ -0,0 +1,399 @@ +getParentWriter()->getUseDiskCaching()) { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); + } + + $this->_document = $phpWord; + + // XML header + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + + $xmlWriter->startElement('w:styles'); + + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + + // Write DocDefaults + $this->_writeDocDefaults($xmlWriter); + + + // Write Style Definitions + $styles = Style::getStyles(); + + // Write normal paragraph style + $normalStyle = null; + if (array_key_exists('Normal', $styles)) { + $normalStyle = $styles['Normal']; + } + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', 'paragraph'); + $xmlWriter->writeAttribute('w:default', '1'); + $xmlWriter->writeAttribute('w:styleId', 'Normal'); + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', 'Normal'); + $xmlWriter->endElement(); + if (!is_null($normalStyle)) { + $this->_writeParagraphStyle($xmlWriter, $normalStyle); + } + $xmlWriter->endElement(); + + // Write other styles + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + if ($styleName == 'Normal') { + continue; + } + if ($style instanceof Font) { + + $paragraphStyle = $style->getParagraphStyle(); + $styleType = $style->getStyleType(); + + $type = ($styleType == 'title') ? 'paragraph' : 'character'; + + if (!is_null($paragraphStyle)) { + $type = 'paragraph'; + } + + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', $type); + + if ($styleType == 'title') { + $arrStyle = explode('_', $styleName); + $styleId = 'Heading' . $arrStyle[1]; + $styleName = 'heading ' . $arrStyle[1]; + $styleLink = 'Heading' . $arrStyle[1] . 'Char'; + $xmlWriter->writeAttribute('w:styleId', $styleId); + + $xmlWriter->startElement('w:link'); + $xmlWriter->writeAttribute('w:val', $styleLink); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $styleName); + $xmlWriter->endElement(); + + if (!is_null($paragraphStyle)) { + // Point parent style to Normal + $xmlWriter->startElement('w:basedOn'); + $xmlWriter->writeAttribute('w:val', 'Normal'); + $xmlWriter->endElement(); + $this->_writeParagraphStyle($xmlWriter, $paragraphStyle); + } + + $this->_writeTextStyle($xmlWriter, $style); + + $xmlWriter->endElement(); + + } elseif ($style instanceof Paragraph) { + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', 'paragraph'); + $xmlWriter->writeAttribute('w:customStyle', '1'); + $xmlWriter->writeAttribute('w:styleId', $styleName); + + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $styleName); + $xmlWriter->endElement(); + + // Parent style + $basedOn = $style->getBasedOn(); + if (!is_null($basedOn)) { + $xmlWriter->startElement('w:basedOn'); + $xmlWriter->writeAttribute('w:val', $basedOn); + $xmlWriter->endElement(); + } + + // Next paragraph style + $next = $style->getNext(); + if (!is_null($next)) { + $xmlWriter->startElement('w:next'); + $xmlWriter->writeAttribute('w:val', $next); + $xmlWriter->endElement(); + } + + $this->_writeParagraphStyle($xmlWriter, $style); + $xmlWriter->endElement(); + + } elseif ($style instanceof TableFull) { + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', 'table'); + $xmlWriter->writeAttribute('w:customStyle', '1'); + $xmlWriter->writeAttribute('w:styleId', $styleName); + + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $styleName); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:uiPriority'); + $xmlWriter->writeAttribute('w:val', '99'); + $xmlWriter->endElement(); + + $this->_writeFullTableStyle($xmlWriter, $style); + + $xmlWriter->endElement(); + } + } + } + + $xmlWriter->endElement(); // w:styles + + // Return + return $xmlWriter->getData(); + } + + private function _writeFullTableStyle(XMLWriter $xmlWriter = null, TableFull $style) + { + + $brdSz = $style->getBorderSize(); + $brdCol = $style->getBorderColor(); + $bgColor = $style->getBgColor(); + $cellMargin = $style->getCellMargin(); + + $bTop = (!is_null($brdSz[0])) ? true : false; + $bLeft = (!is_null($brdSz[1])) ? true : false; + $bRight = (!is_null($brdSz[2])) ? true : false; + $bBottom = (!is_null($brdSz[3])) ? true : false; + $bInsH = (!is_null($brdSz[4])) ? true : false; + $bInsV = (!is_null($brdSz[5])) ? true : false; + $borders = ($bTop || $bLeft || $bRight || $bBottom || $bInsH || $bInsV) ? true : false; + + $mTop = (!is_null($cellMargin[0])) ? true : false; + $mLeft = (!is_null($cellMargin[1])) ? true : false; + $mRight = (!is_null($cellMargin[2])) ? true : false; + $mBottom = (!is_null($cellMargin[3])) ? true : false; + $margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false; + + $xmlWriter->startElement('w:tblPr'); + + if ($margins) { + $xmlWriter->startElement('w:tblCellMar'); + if ($mTop) { + echo $margins[0]; + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:w', $cellMargin[0]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); + } + if ($mLeft) { + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:w', $cellMargin[1]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); + } + if ($mRight) { + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:w', $cellMargin[2]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); + } + if ($mBottom) { + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:w', $cellMargin[3]); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); + } + $xmlWriter->endElement(); + } + + if ($borders) { + $xmlWriter->startElement('w:tblBorders'); + if ($bTop) { + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[0]); + $xmlWriter->writeAttribute('w:color', $brdCol[0]); + $xmlWriter->endElement(); + } + if ($bLeft) { + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[1]); + $xmlWriter->writeAttribute('w:color', $brdCol[1]); + $xmlWriter->endElement(); + } + if ($bRight) { + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[2]); + $xmlWriter->writeAttribute('w:color', $brdCol[2]); + $xmlWriter->endElement(); + } + if ($bBottom) { + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[3]); + $xmlWriter->writeAttribute('w:color', $brdCol[3]); + $xmlWriter->endElement(); + } + if ($bInsH) { + $xmlWriter->startElement('w:insideH'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[4]); + $xmlWriter->writeAttribute('w:color', $brdCol[4]); + $xmlWriter->endElement(); + } + if ($bInsV) { + $xmlWriter->startElement('w:insideV'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[5]); + $xmlWriter->writeAttribute('w:color', $brdCol[5]); + $xmlWriter->endElement(); + } + $xmlWriter->endElement(); + } + + $xmlWriter->endElement(); + + if (!is_null($bgColor)) { + $xmlWriter->startElement('w:tcPr'); + $xmlWriter->startElement('w:shd'); + $xmlWriter->writeAttribute('w:val', 'clear'); + $xmlWriter->writeAttribute('w:color', 'auto'); + $xmlWriter->writeAttribute('w:fill', $bgColor); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } + + + // First Row + $firstRow = $style->getFirstRow(); + if (!is_null($firstRow)) { + $this->_writeRowStyle($xmlWriter, 'firstRow', $firstRow); + } + } + + private function _writeRowStyle(XMLWriter $xmlWriter = null, $type, TableFull $style) + { + $brdSz = $style->getBorderSize(); + $brdCol = $style->getBorderColor(); + $bgColor = $style->getBgColor(); + + $bTop = (!is_null($brdSz[0])) ? true : false; + $bLeft = (!is_null($brdSz[1])) ? true : false; + $bRight = (!is_null($brdSz[2])) ? true : false; + $bBottom = (!is_null($brdSz[3])) ? true : false; + $borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false; + + $xmlWriter->startElement('w:tblStylePr'); + $xmlWriter->writeAttribute('w:type', $type); + + $xmlWriter->startElement('w:tcPr'); + if (!is_null($bgColor)) { + $xmlWriter->startElement('w:shd'); + $xmlWriter->writeAttribute('w:val', 'clear'); + $xmlWriter->writeAttribute('w:color', 'auto'); + $xmlWriter->writeAttribute('w:fill', $bgColor); + $xmlWriter->endElement(); + } + + $xmlWriter->startElement('w:tcBorders'); + if ($bTop) { + $xmlWriter->startElement('w:top'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[0]); + $xmlWriter->writeAttribute('w:color', $brdCol[0]); + $xmlWriter->endElement(); + } + if ($bLeft) { + $xmlWriter->startElement('w:left'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[1]); + $xmlWriter->writeAttribute('w:color', $brdCol[1]); + $xmlWriter->endElement(); + } + if ($bRight) { + $xmlWriter->startElement('w:right'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[2]); + $xmlWriter->writeAttribute('w:color', $brdCol[2]); + $xmlWriter->endElement(); + } + if ($bBottom) { + $xmlWriter->startElement('w:bottom'); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $brdSz[3]); + $xmlWriter->writeAttribute('w:color', $brdCol[3]); + $xmlWriter->endElement(); + } + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + } + + + private function _writeDocDefaults(XMLWriter $xmlWriter = null) + { + $fontName = $this->_document->getDefaultFontName(); + $fontSize = $this->_document->getDefaultFontSize(); + + $xmlWriter->startElement('w:docDefaults'); + $xmlWriter->startElement('w:rPrDefault'); + $xmlWriter->startElement('w:rPr'); + + $xmlWriter->startElement('w:rFonts'); + $xmlWriter->writeAttribute('w:ascii', $fontName); + $xmlWriter->writeAttribute('w:hAnsi', $fontName); + $xmlWriter->writeAttribute('w:eastAsia', $fontName); + $xmlWriter->writeAttribute('w:cs', $fontName); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:sz'); + $xmlWriter->writeAttribute('w:val', $fontSize * 2); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:szCs'); + $xmlWriter->writeAttribute('w:val', $fontSize * 2); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + } +} diff --git a/src/Writer/Word2007/WriterPart.php b/src/Writer/Word2007/WriterPart.php new file mode 100644 index 0000000000..bb8fefc334 --- /dev/null +++ b/src/Writer/Word2007/WriterPart.php @@ -0,0 +1,49 @@ +_parentWriter = $pWriter; + } + + public function getParentWriter() + { + if (!is_null($this->_parentWriter)) { + return $this->_parentWriter; + } else { + throw new Exception("No parent IWriter assigned."); + } + } +} diff --git a/src/_staticDocParts/_doc.png b/src/_staticDocParts/_doc.png new file mode 100644 index 0000000000000000000000000000000000000000..3128a803b4eb829a6eb098e3736366ebfb43cef7 GIT binary patch literal 1157 zcmV;01bX|4P)0{{R3N2#!80000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUzQ&3D)MgRZ*0002t=Ji~3tGCGXHb!Y? zeY1m{+VJxFdy&6FRe$>X{`>s?{r>+{Y@~07x=L=rNOQ~tHG)iIn>S#t05NwhRIBRl z_y8eM=}aaf{Nayy{$g%gNH>D_Nxe|Nj6SMq`QM_4oXlvF-Hs`~3a>MO=(m zebHZq-6cqOIAXL%cG+c!+caRpt-8>Qq}@YlxrwFeQFh7zC0adWzw-3@6+2aCiq(6U z*cLo)c8Z+V-0DANw4k@}J5qNCJBTk)k0wisIcT_&qqQhfpZNLxF#dt- z_uX#SR(tRN|I)^<+{jmyZq)XA`T5O~lY>H!qAd!i^Y)K@VAX7ctD^`7k~{HkL|E zAcb-R(47;o6|y+{sa3R45JD71HAGR@7vpf|$v;_R?$z8jK%$t8Ml}-0yi}1Q1F|SK z>Z~0Q98y&Cl7CKr6~(_~;5#16{y257P9lZUBVG(^>rst~(_T%ivv^?lCYIT4yT77^ z)ChzyJzC`31&XQ%S!RV-Lf38D9_VwF;tOQ)LP?kSQAWz_(zH8`7OM2129Hy^qE>1t zp4+>Q)8P#jEhHPzBAFC z$Yh$WTgOFYr;tLvG7i5N_^adN!t%;?=Im@Oe(SghA7bbT?|%RImsdW~ba9tV${^%My7w!<$0EU(Az z^f?eP@4dSVdY3S_00XAk8zV43K27RFz3TvAz70U;N&WN8ohL$rgS!8>vW(~d29G>vf?KbCZ<^iBfdBg+S#J!O^9loZ)5&~}hRr$*06U-Xms&}joSa@!{{$ES XtjuZObd?ae00000NkvXXu0mjf9*{Wp literal 0 HcmV?d00001 diff --git a/src/_staticDocParts/_ppt.png b/src/_staticDocParts/_ppt.png new file mode 100644 index 0000000000000000000000000000000000000000..3e925f50199cf96e881dee05455b410fcc282731 GIT binary patch literal 1886 zcmV-k2ch_hP)0{{R3N2#!80000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#08mU+MgHT}{J4`=3l5Y_PyNxl|M>L& z>*4*!s;emi|Mc&CLQc?fRsZbb{J)<5-p=8CT>QYHHw6p-`uOdVZSI#@{@cm__VezG zROXUu|K{0_NlpLgx#W&%(_<;@mTfg0dJ4Of%qf{&CtBn2Az3Gi<++`{M z@8$pg{n&6(xit#IJ`S!*HfRwK>6LD)MKZ!+NXteO_MdtG_3-`6v63|{{JWURYEJ+E z|C~@yg+@-gRzT&1V*SLX{lcWydRzYK-~Z#&?PVta`S$(Hv;Xqz|Lx?(WlQ0SX5)ch z%49h1gh&77*#G0y{@23&*24YNzHSu}f<#T}i)Ztib@G^V!CpnYTSM-VN&VHq?t@d_ zhGW@(UEX?FkvTHfZcof_QqyNic|uV1oOiNPG~9Mp)oV@ZVI$sG9@tVF&q)=&It(oY z3$-!_u`UH*4h;YR0RQ~@|Nj24UPJ%!>i_of|K-=AMl$`+xBukU|LNWT|Nj5{``KzP z|LEMaPB{OsasTMHyj&^KWk>ppOXPGr{FGAYr-uIF((r97uSPiMoOjG&DdTN0w^Tm= z)S~~`rsaG_|K_stbTapTKIf!@^LaPtpnU(xlmE_}sZ}ekSS$ajXyt)V|Dj>!k7NJ+ z{Qtaz{h3+oVkG96aKUq0|K6(jg+>3vi{*t?<%(SYw|V~L*5hd{|K--?a5db5VB~l~ z{m!-jsB(`icXt#Q<8O7fe0 z>4|RQfMn!@Vg1dtfJ9FI=-vM5-7>lgfdBvl^hrcPRCwBA@TL=B7`15BqEU;6n?-Ur zPg#0w=i)_cR`1@jZ}R$$TW3z+ zwS48WIiZ?Vw#e1BEImU*SlA-%mH%&k{(_3$LkkWlsH&b(NujPq$I@G^&A`mo53HP5*tFh>CbB4~T2b4g=$#qL*0aD& zYauap#o+yXO3B>{R}_7YJ5bf4yv1^xH?Q#4(K&bT?wubR*MENg#eedTrB$R)HFYgI zyhymeWtI0MV3xfd^yC&W!vgcGyJaMg;R)(ml)naO(L4~VKg=y6@;?KglKD|RSspgS znkK4R6tvpn#ii|_7`nvDsmi7`TQrHqon4m4h*`U-m6{ek*`0PtNW$BjrLC~=u_q)c z=&{c?GGeZ!u8+94yb{vip88wupG#HOANGfAj))J=aOb`_@s{qO6(E-P~p75+g=g#dw5jHU;B{x(q8qJ_JPo~bWrftCu1 z;H2QmXxh`m)gVY!i;S07s<$6dP*AY6l$D)tU@%o)e%)GA(}V=BM(SELY328bc2!j? z#Yi4DBctAl=OraO5B4M^gp@W4_EFO!`(-8Vs#g>hd4Trxg6xU!>;%~pQp!Ohscg!!W`DC<4e9 z!9|f&BKfGfxf$6XP>7@$jfpCU;v<~$49GExZc#HvSQ2j$LN5^(VZ=0PKJq4D5jt-6 z#ui83-q_qiAdb8-a|3D`!VNvsF={;)Es6|8EB7gt` Y0LsdDm^Yzu*8l(j07*qoM6N<$f~$WKuK)l5 literal 0 HcmV?d00001 diff --git a/src/_staticDocParts/_xls.png b/src/_staticDocParts/_xls.png new file mode 100644 index 0000000000000000000000000000000000000000..a7d7697fc5666629b9d8bb3090339c5f557536b5 GIT binary patch literal 1924 zcmV-~2YdL5P)0{{R3N2#!80000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#08mU+MKVMjJ8dS}_T8hyou0{*wA87C zmvPhL)a~~1NrWgzm_<~EN>Exj*6P;k^5g?(0%wzE$L6|btYq}{@H&V*R)JDem^j_+ z;>+g3+2z`es)5Pf!teX;s?(l1cNJY^MNEetb|F z_5Ar)lT>TAX7ly=6eI}5-n?LlN-8xJ@Ksom<`OJX!7Iw5nmXINZ8)#lgP=-T-H z_fm^EUusEIeL9cJfqS}c&f3#-onmB;QswdHe5GrFyn9TKLm_Ygc$Zv6j3xT{`dgzx z;O*m`(U@PDSx1sKc(!zQvvlh6>Iz~6PMKF?s#O2~`;w@1e7bvKqEmjTX;z;-=k4a& z?b+$--CLwo|N8!Ro@n~~`IEVge6er&`t^IJaay2A=JD!;vT}&5f>o(hcD7nJZy3+& z&incPkj05>m01d66;+~A_WbpAy=rooZu9!^aGPIMrcG?9V|KD^<>%t!=iGXtWI=r* z+Uebp!i8g+UrTU2ZM0tg{``WidE)Qh|NsALY*rsA4BP3`Rbf2m^Y8lq{NL^0BrFsz zK_+IZUg7fMXp&Vrf*=+h3?(%XH%=e`007+T+u`r#=kMd?_T%mE>WjU8fV_6~{qXMc z=|E;C$l=An>%iCV*Uje0&g;L}?cCq&+TP~k{rdIh_~LT9Wa<6v8z2+Z-`8QGTl)0( zZK6;O+D8ZtY>$yY?;iD|Nj42rdl6+k>n z^yc*EnZuFR=H>nU|IzHp{Qv)dlxP3_|9Ze^ki3Ea{QWLJ81wk}?EUrj_w;3;C`$@AU0!xN!LV?n)1(VE_OG8c9S!RCwBAm`NwVFly1LMWYtc$)al+ z8QJI0_xEQ9^%n(ob~XhEFV)xAH`V9%^HcgmO^c@Q-1$ag>kd6VJ!4kZ$FeLeFF&f8 z1eA8)?oL}tRUcJbT(z_;DRFePoGx{>TI$jzYwMHNZ133EBA-yzqPONh9n)W@f0~wF zmj1M(qxf5yy71;3!khUvYh+Q^N9Gcz?#}%4cK(m~#hRL5bacLa;V?^n@q5Wy(->-7 z%j~;YnH-Y*OzAsyEh?8NF`It7XYsB0$u~P>4(PQDOb)iS zwPniH$XR)pnihrXo%T)=eC*Wd6eb|~El^;8z()6bqAAZbmPtiiLyWo>1+iBDpRe5DkAjF zzC2$lThz%~?H&E?fbtzKJ*UOpLRq5C(kg~)d&R}&eLhpwq9)dAow7~eWa{sS8><~l zyLWGjvyo9R@Aiqa6bz_q(c|jYXpZPTT3!6%vKw2vx@uCU*ama&dF30mg1Q#PN$r*4 zP`2PINJ(JLY_aJ|OPL}XY`ZH@p2|L2dgr+CS7qMR(y0afTya$u_qba46(*eF<@Jp+ zplUu^>U3O3XAaj?lK`O>{)D*O4i4c7&34R^_Otw`>!aYt<6p#6-7_GGt9`?2H92t5>h~^78a# zx3@Utae=x%@~eHfe*OB~+}yQm7r3}g^zxFFWcOmXueS$UL`@&1o4U8Z;CnO!2zKY? z@q&RTyQk_7Rr$K*RP~W*caf5kk_Hg@LV$;dhrEZ!TzQ@?)V0X(=(!jm$jK2C6Z26} zP~ha8FhLFo>gpn>YmvrEFkk?I&ju?%VD@a?g$H$kkeU_&n~rbMh5mqvKSVb1M>}Gp z7L8g&GmBP%0ah7=3MB3-9I6OggwtI}Ca=P+kW`DHMnN6F3SlywTs0Fe3iIPCIFke) zt%4W^MKB84A}sQ&NbwOgj#i + \ No newline at end of file diff --git a/src/_staticDocParts/numbering.xml b/src/_staticDocParts/numbering.xml new file mode 100644 index 0000000000..ac229f400e --- /dev/null +++ b/src/_staticDocParts/numbering.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/_staticDocParts/settings.xml b/src/_staticDocParts/settings.xml new file mode 100644 index 0000000000..5eb2289137 --- /dev/null +++ b/src/_staticDocParts/settings.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/_staticDocParts/theme1.xml b/src/_staticDocParts/theme1.xml new file mode 100644 index 0000000000..4fab507b66 --- /dev/null +++ b/src/_staticDocParts/theme1.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/_staticDocParts/webSettings.xml b/src/_staticDocParts/webSettings.xml new file mode 100644 index 0000000000..72d2830728 --- /dev/null +++ b/src/_staticDocParts/webSettings.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file From 667d0aaad12ea0594e7c56b9b1a0af22dc6ca019 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 22 Mar 2014 10:08:04 +0400 Subject: [PATCH 10/15] https://github.com/PHPOffice/PHPWord/issues/58 - Part VIII (Autoloader). --- Classes/PhpWord.php | 234 ---- Classes/PhpWord/Autoloader.php | 85 -- Classes/PhpWord/DocumentProperties.php | 606 ---------- Classes/PhpWord/Exceptions/Exception.php | 6 - .../Exceptions/InvalidImageException.php | 13 - .../Exceptions/InvalidStyleException.php | 15 - .../UnsupportedImageTypeException.php | 13 - Classes/PhpWord/Footnote.php | 124 -- Classes/PhpWord/HashTable.php | 209 ---- Classes/PhpWord/IOFactory.php | 80 -- Classes/PhpWord/Media.php | 347 ------ Classes/PhpWord/Reader/AbstractReader.php | 110 -- Classes/PhpWord/Reader/IReader.php | 46 - Classes/PhpWord/Reader/Word2007.php | 453 -------- Classes/PhpWord/Section.php | 453 -------- Classes/PhpWord/Section/Footer.php | 217 ---- .../PhpWord/Section/Footer/PreserveText.php | 130 --- Classes/PhpWord/Section/Footnote.php | 151 --- Classes/PhpWord/Section/Header.php | 299 ----- Classes/PhpWord/Section/Image.php | 177 --- Classes/PhpWord/Section/Link.php | 174 --- Classes/PhpWord/Section/ListItem.php | 101 -- Classes/PhpWord/Section/MemoryImage.php | 233 ---- Classes/PhpWord/Section/Object.php | 179 --- Classes/PhpWord/Section/PageBreak.php | 38 - Classes/PhpWord/Section/Settings.php | 728 ------------ Classes/PhpWord/Section/Table.php | 163 --- Classes/PhpWord/Section/Table/Cell.php | 350 ------ Classes/PhpWord/Section/Table/Row.php | 139 --- Classes/PhpWord/Section/Text.php | 154 --- Classes/PhpWord/Section/TextBreak.php | 122 -- Classes/PhpWord/Section/TextRun.php | 184 --- Classes/PhpWord/Section/Title.php | 145 --- Classes/PhpWord/Settings.php | 63 -- Classes/PhpWord/Shared/Drawing.php | 162 --- Classes/PhpWord/Shared/File.php | 76 -- Classes/PhpWord/Shared/Font.php | 90 -- Classes/PhpWord/Shared/String.php | 109 -- Classes/PhpWord/Shared/XMLWriter.php | 155 --- Classes/PhpWord/Shared/ZipStreamWrapper.php | 183 --- Classes/PhpWord/Style.php | 161 --- Classes/PhpWord/Style/Cell.php | 343 ------ Classes/PhpWord/Style/Font.php | 544 --------- Classes/PhpWord/Style/Image.php | 175 --- Classes/PhpWord/Style/ListItem.php | 80 -- Classes/PhpWord/Style/Paragraph.php | 508 --------- Classes/PhpWord/Style/Row.php | 88 -- Classes/PhpWord/Style/TOC.php | 139 --- Classes/PhpWord/Style/Tab.php | 146 --- Classes/PhpWord/Style/Table.php | 94 -- Classes/PhpWord/Style/TableFull.php | 443 -------- Classes/PhpWord/Style/Tabs.php | 63 -- Classes/PhpWord/TOC.php | 155 --- Classes/PhpWord/Template.php | 292 ----- Classes/PhpWord/Writer/IWriter.php | 39 - Classes/PhpWord/Writer/ODText.php | 282 ----- Classes/PhpWord/Writer/ODText/Content.php | 412 ------- Classes/PhpWord/Writer/ODText/Manifest.php | 132 --- Classes/PhpWord/Writer/ODText/Meta.php | 96 -- Classes/PhpWord/Writer/ODText/Mimetype.php | 46 - Classes/PhpWord/Writer/ODText/Styles.php | 273 ----- Classes/PhpWord/Writer/ODText/WriterPart.php | 66 -- Classes/PhpWord/Writer/RTF.php | 482 -------- Classes/PhpWord/Writer/Word2007.php | 301 ----- Classes/PhpWord/Writer/Word2007/Base.php | 1003 ----------------- .../PhpWord/Writer/Word2007/ContentTypes.php | 228 ---- Classes/PhpWord/Writer/Word2007/DocProps.php | 186 --- Classes/PhpWord/Writer/Word2007/Document.php | 506 --------- .../PhpWord/Writer/Word2007/DocumentRels.php | 182 --- Classes/PhpWord/Writer/Word2007/Footer.php | 90 -- Classes/PhpWord/Writer/Word2007/Footnotes.php | 87 -- .../PhpWord/Writer/Word2007/FootnotesRels.php | 89 -- Classes/PhpWord/Writer/Word2007/Header.php | 94 -- Classes/PhpWord/Writer/Word2007/Rels.php | 115 -- Classes/PhpWord/Writer/Word2007/Styles.php | 399 ------- .../PhpWord/Writer/Word2007/WriterPart.php | 49 - Classes/PhpWord/_staticDocParts/_doc.png | Bin 1157 -> 0 bytes Classes/PhpWord/_staticDocParts/_ppt.png | Bin 1886 -> 0 bytes Classes/PhpWord/_staticDocParts/_xls.png | Bin 1924 -> 0 bytes Classes/PhpWord/_staticDocParts/fontTable.xml | 2 - Classes/PhpWord/_staticDocParts/numbering.xml | 2 - Classes/PhpWord/_staticDocParts/settings.xml | 48 - Classes/PhpWord/_staticDocParts/theme1.xml | 2 - .../PhpWord/_staticDocParts/webSettings.xml | 2 - src/Exceptions/Exception.php | 0 85 files changed, 15760 deletions(-) delete mode 100644 Classes/PhpWord.php delete mode 100644 Classes/PhpWord/Autoloader.php delete mode 100644 Classes/PhpWord/DocumentProperties.php delete mode 100755 Classes/PhpWord/Exceptions/Exception.php delete mode 100644 Classes/PhpWord/Exceptions/InvalidImageException.php delete mode 100644 Classes/PhpWord/Exceptions/InvalidStyleException.php delete mode 100644 Classes/PhpWord/Exceptions/UnsupportedImageTypeException.php delete mode 100644 Classes/PhpWord/Footnote.php delete mode 100644 Classes/PhpWord/HashTable.php delete mode 100644 Classes/PhpWord/IOFactory.php delete mode 100644 Classes/PhpWord/Media.php delete mode 100644 Classes/PhpWord/Reader/AbstractReader.php delete mode 100644 Classes/PhpWord/Reader/IReader.php delete mode 100644 Classes/PhpWord/Reader/Word2007.php delete mode 100644 Classes/PhpWord/Section.php delete mode 100644 Classes/PhpWord/Section/Footer.php delete mode 100644 Classes/PhpWord/Section/Footer/PreserveText.php delete mode 100644 Classes/PhpWord/Section/Footnote.php delete mode 100644 Classes/PhpWord/Section/Header.php delete mode 100644 Classes/PhpWord/Section/Image.php delete mode 100644 Classes/PhpWord/Section/Link.php delete mode 100644 Classes/PhpWord/Section/ListItem.php delete mode 100644 Classes/PhpWord/Section/MemoryImage.php delete mode 100644 Classes/PhpWord/Section/Object.php delete mode 100644 Classes/PhpWord/Section/PageBreak.php delete mode 100644 Classes/PhpWord/Section/Settings.php delete mode 100644 Classes/PhpWord/Section/Table.php delete mode 100644 Classes/PhpWord/Section/Table/Cell.php delete mode 100644 Classes/PhpWord/Section/Table/Row.php delete mode 100644 Classes/PhpWord/Section/Text.php delete mode 100644 Classes/PhpWord/Section/TextBreak.php delete mode 100644 Classes/PhpWord/Section/TextRun.php delete mode 100644 Classes/PhpWord/Section/Title.php delete mode 100644 Classes/PhpWord/Settings.php delete mode 100644 Classes/PhpWord/Shared/Drawing.php delete mode 100644 Classes/PhpWord/Shared/File.php delete mode 100644 Classes/PhpWord/Shared/Font.php delete mode 100644 Classes/PhpWord/Shared/String.php delete mode 100644 Classes/PhpWord/Shared/XMLWriter.php delete mode 100644 Classes/PhpWord/Shared/ZipStreamWrapper.php delete mode 100644 Classes/PhpWord/Style.php delete mode 100644 Classes/PhpWord/Style/Cell.php delete mode 100644 Classes/PhpWord/Style/Font.php delete mode 100644 Classes/PhpWord/Style/Image.php delete mode 100644 Classes/PhpWord/Style/ListItem.php delete mode 100644 Classes/PhpWord/Style/Paragraph.php delete mode 100644 Classes/PhpWord/Style/Row.php delete mode 100644 Classes/PhpWord/Style/TOC.php delete mode 100644 Classes/PhpWord/Style/Tab.php delete mode 100644 Classes/PhpWord/Style/Table.php delete mode 100644 Classes/PhpWord/Style/TableFull.php delete mode 100644 Classes/PhpWord/Style/Tabs.php delete mode 100644 Classes/PhpWord/TOC.php delete mode 100644 Classes/PhpWord/Template.php delete mode 100644 Classes/PhpWord/Writer/IWriter.php delete mode 100644 Classes/PhpWord/Writer/ODText.php delete mode 100644 Classes/PhpWord/Writer/ODText/Content.php delete mode 100644 Classes/PhpWord/Writer/ODText/Manifest.php delete mode 100644 Classes/PhpWord/Writer/ODText/Meta.php delete mode 100644 Classes/PhpWord/Writer/ODText/Mimetype.php delete mode 100644 Classes/PhpWord/Writer/ODText/Styles.php delete mode 100644 Classes/PhpWord/Writer/ODText/WriterPart.php delete mode 100644 Classes/PhpWord/Writer/RTF.php delete mode 100644 Classes/PhpWord/Writer/Word2007.php delete mode 100644 Classes/PhpWord/Writer/Word2007/Base.php delete mode 100644 Classes/PhpWord/Writer/Word2007/ContentTypes.php delete mode 100644 Classes/PhpWord/Writer/Word2007/DocProps.php delete mode 100644 Classes/PhpWord/Writer/Word2007/Document.php delete mode 100644 Classes/PhpWord/Writer/Word2007/DocumentRels.php delete mode 100644 Classes/PhpWord/Writer/Word2007/Footer.php delete mode 100644 Classes/PhpWord/Writer/Word2007/Footnotes.php delete mode 100644 Classes/PhpWord/Writer/Word2007/FootnotesRels.php delete mode 100644 Classes/PhpWord/Writer/Word2007/Header.php delete mode 100644 Classes/PhpWord/Writer/Word2007/Rels.php delete mode 100644 Classes/PhpWord/Writer/Word2007/Styles.php delete mode 100644 Classes/PhpWord/Writer/Word2007/WriterPart.php delete mode 100644 Classes/PhpWord/_staticDocParts/_doc.png delete mode 100644 Classes/PhpWord/_staticDocParts/_ppt.png delete mode 100644 Classes/PhpWord/_staticDocParts/_xls.png delete mode 100644 Classes/PhpWord/_staticDocParts/fontTable.xml delete mode 100644 Classes/PhpWord/_staticDocParts/numbering.xml delete mode 100644 Classes/PhpWord/_staticDocParts/settings.xml delete mode 100644 Classes/PhpWord/_staticDocParts/theme1.xml delete mode 100644 Classes/PhpWord/_staticDocParts/webSettings.xml mode change 100644 => 100755 src/Exceptions/Exception.php diff --git a/Classes/PhpWord.php b/Classes/PhpWord.php deleted file mode 100644 index c2986a70d4..0000000000 --- a/Classes/PhpWord.php +++ /dev/null @@ -1,234 +0,0 @@ -_documentProperties = new DocumentProperties(); - $this->_defaultFontName = self::DEFAULT_FONT_NAME; - $this->_defaultFontSize = self::DEFAULT_FONT_SIZE; - } - - /** - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function getDocumentProperties() - { - return $this->_documentProperties; - } - - /** - * @param PhpOffice\PhpWord\DocumentProperties $documentProperties - * @return PhpOffice\PhpWord - */ - public function setDocumentProperties(DocumentProperties $documentProperties) - { - $this->_documentProperties = $documentProperties; - - return $this; - } - - /** - * @param PhpOffice\PhpWord\Section\Settings $settings - * @return PhpOffice\PhpWord\Section - */ - public function createSection($settings = null) - { - $section = new Section(\count($this->_sections) + 1, $settings); - $this->_sections[] = $section; - - return $section; - } - - /** - * @return string - */ - public function getDefaultFontName() - { - return $this->_defaultFontName; - } - - /** - * @param string $fontName - */ - public function setDefaultFontName($fontName) - { - $this->_defaultFontName = $fontName; - } - - /** - * @return string - */ - public function getDefaultFontSize() - { - return $this->_defaultFontSize; - } - - /** - * @param int $fontSize - */ - public function setDefaultFontSize($fontSize) - { - $this->_defaultFontSize = $fontSize; - } - - /** - * Set default paragraph style definition to styles.xml - * - * @param array $styles Paragraph style definition - */ - public function setDefaultParagraphStyle($styles) - { - Style::setDefaultParagraphStyle($styles); - } - - /** - * Adds a paragraph style definition to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addParagraphStyle($styleName, $styles) - { - Style::addParagraphStyle($styleName, $styles); - } - - /** - * Adds a font style definition to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addFontStyle($styleName, $styleFont, $styleParagraph = null) - { - Style::addFontStyle($styleName, $styleFont, $styleParagraph); - } - - /** - * Adds a table style definition to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) - { - Style::addTableStyle($styleName, $styleTable, $styleFirstRow); - } - - /** - * Adds a heading style definition to styles.xml - * - * @param $titleCount int - * @param $styles array - */ - public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) - { - Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); - } - - /** - * Adds a hyperlink style to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addLinkStyle($styleName, $styles) - { - Style::addLinkStyle($styleName, $styles); - } - - /** - * @return PhpOffice\PhpWord\Section[] - */ - public function getSections() - { - return $this->_sections; - } - - /** - * @param string $filename Fully qualified filename. - * @return PhpOffice\PhpWord\Template - * @throws PhpOffice\PhpWord\Exceptions\Exception - */ - public function loadTemplate($filename) - { - if (\file_exists($filename)) { - return new Template($filename); - } else { - throw new Exception("Template file {$filename} not found."); - } - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Autoloader.php b/Classes/PhpWord/Autoloader.php deleted file mode 100644 index 1a4aa3b3dc..0000000000 --- a/Classes/PhpWord/Autoloader.php +++ /dev/null @@ -1,85 +0,0 @@ -_creator = ''; - $this->_lastModifiedBy = $this->_creator; - $this->_created = time(); - $this->_modified = time(); - $this->_title = ''; - $this->_subject = ''; - $this->_description = ''; - $this->_keywords = ''; - $this->_category = ''; - $this->_company = ''; - $this->_manager = ''; - } - - /** - * Get Creator - * - * @return string - */ - public function getCreator() - { - return $this->_creator; - } - - /** - * Set Creator - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCreator($pValue = '') - { - $this->_creator = $pValue; - return $this; - } - - /** - * Get Last Modified By - * - * @return string - */ - public function getLastModifiedBy() - { - return $this->_lastModifiedBy; - } - - /** - * Set Last Modified By - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setLastModifiedBy($pValue = '') - { - $this->_lastModifiedBy = $pValue; - return $this; - } - - /** - * Get Created - * - * @return datetime - */ - public function getCreated() - { - return $this->_created; - } - - /** - * Set Created - * - * @param datetime $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCreated($pValue = null) - { - if (is_null($pValue)) { - $pValue = time(); - } - $this->_created = $pValue; - return $this; - } - - /** - * Get Modified - * - * @return datetime - */ - public function getModified() - { - return $this->_modified; - } - - /** - * Set Modified - * - * @param datetime $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setModified($pValue = null) - { - if (is_null($pValue)) { - $pValue = time(); - } - $this->_modified = $pValue; - return $this; - } - - /** - * Get Title - * - * @return string - */ - public function getTitle() - { - return $this->_title; - } - - /** - * Set Title - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setTitle($pValue = '') - { - $this->_title = $pValue; - return $this; - } - - /** - * Get Description - * - * @return string - */ - public function getDescription() - { - return $this->_description; - } - - /** - * Set Description - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setDescription($pValue = '') - { - $this->_description = $pValue; - return $this; - } - - /** - * Get Subject - * - * @return string - */ - public function getSubject() - { - return $this->_subject; - } - - /** - * Set Subject - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setSubject($pValue = '') - { - $this->_subject = $pValue; - return $this; - } - - /** - * Get Keywords - * - * @return string - */ - public function getKeywords() - { - return $this->_keywords; - } - - /** - * Set Keywords - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setKeywords($pValue = '') - { - $this->_keywords = $pValue; - return $this; - } - - /** - * Get Category - * - * @return string - */ - public function getCategory() - { - return $this->_category; - } - - /** - * Set Category - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCategory($pValue = '') - { - $this->_category = $pValue; - return $this; - } - - /** - * Get Company - * - * @return string - */ - public function getCompany() - { - return $this->_company; - } - - /** - * Set Company - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCompany($pValue = '') - { - $this->_company = $pValue; - return $this; - } - - /** - * Get Manager - * - * @return string - */ - public function getManager() - { - return $this->_manager; - } - - /** - * Set Manager - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setManager($pValue = '') - { - $this->_manager = $pValue; - return $this; - } - - /** - * Get a List of Custom Property Names - * - * @return array of string - */ - public function getCustomProperties() - { - return array_keys($this->_customProperties); - } - - /** - * Check if a Custom Property is defined - * - * @param string $propertyName - * @return boolean - */ - public function isCustomPropertySet($propertyName) - { - return isset($this->_customProperties[$propertyName]); - } - - /** - * Get a Custom Property Value - * - * @param string $propertyName - * @return string - */ - public function getCustomPropertyValue($propertyName) - { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['value']; - } - - } - - /** - * Get a Custom Property Type - * - * @param string $propertyName - * @return string - */ - public function getCustomPropertyType($propertyName) - { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['type']; - } - - } - - /** - * Set a Custom Property - * - * @param string $propertyName - * @param mixed $propertyValue - * @param string $propertyType - * 'i': Integer - * 'f': Floating Point - * 's': String - * 'd': Date/Time - * 'b': Boolean - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) - { - if (($propertyType === null) || (!in_array($propertyType, array( - self::PROPERTY_TYPE_INTEGER, - self::PROPERTY_TYPE_FLOAT, - self::PROPERTY_TYPE_STRING, - self::PROPERTY_TYPE_DATE, - self::PROPERTY_TYPE_BOOLEAN - )))) { - if ($propertyValue === null) { - $propertyType = self::PROPERTY_TYPE_STRING; - } elseif (is_float($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_FLOAT; - } elseif (is_int($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_INTEGER; - } elseif (is_bool($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_BOOLEAN; - } else { - $propertyType = self::PROPERTY_TYPE_STRING; - } - } - - $this->_customProperties[$propertyName] = array( - 'value' => $propertyValue, - 'type' => $propertyType - ); - return $this; - } - - /** - * Convert document propery based on type - * - * @param mixed $propertyValue - * @param string $propertyType - * @return mixed - */ - public static function convertProperty($propertyValue, $propertyType) - { - switch ($propertyType) { - case 'empty': // Empty - return ''; - break; - case 'null': // Null - return null; - break; - case 'i1': // 1-Byte Signed Integer - case 'i2': // 2-Byte Signed Integer - case 'i4': // 4-Byte Signed Integer - case 'i8': // 8-Byte Signed Integer - case 'int': // Integer - return (int) $propertyValue; - break; - case 'ui1': // 1-Byte Unsigned Integer - case 'ui2': // 2-Byte Unsigned Integer - case 'ui4': // 4-Byte Unsigned Integer - case 'ui8': // 8-Byte Unsigned Integer - case 'uint': // Unsigned Integer - return abs((int) $propertyValue); - break; - case 'r4': // 4-Byte Real Number - case 'r8': // 8-Byte Real Number - case 'decimal': // Decimal - return (float) $propertyValue; - break; - case 'lpstr': // LPSTR - case 'lpwstr': // LPWSTR - case 'bstr': // Basic String - return $propertyValue; - break; - case 'date': // Date and Time - case 'filetime': // File Time - return strtotime($propertyValue); - break; - case 'bool': // Boolean - return ($propertyValue == 'true') ? true : false; - break; - case 'cy': // Currency - case 'error': // Error Status Code - case 'vector': // Vector - case 'array': // Array - case 'blob': // Binary Blob - case 'oblob': // Binary Blob Object - case 'stream': // Binary Stream - case 'ostream': // Binary Stream Object - case 'storage': // Binary Storage - case 'ostorage': // Binary Storage Object - case 'vstream': // Binary Versioned Stream - case 'clsid': // Class ID - case 'cf': // Clipboard Data - return $propertyValue; - break; - } - - return $propertyValue; - } - - /** - * Convert document property type - * - * @param string $propertyType - * @return mixed - */ - public static function convertPropertyType($propertyType) - { - switch ($propertyType) { - case 'i1': // 1-Byte Signed Integer - case 'i2': // 2-Byte Signed Integer - case 'i4': // 4-Byte Signed Integer - case 'i8': // 8-Byte Signed Integer - case 'int': // Integer - case 'ui1': // 1-Byte Unsigned Integer - case 'ui2': // 2-Byte Unsigned Integer - case 'ui4': // 4-Byte Unsigned Integer - case 'ui8': // 8-Byte Unsigned Integer - case 'uint': // Unsigned Integer - return self::PROPERTY_TYPE_INTEGER; - break; - case 'r4': // 4-Byte Real Number - case 'r8': // 8-Byte Real Number - case 'decimal': // Decimal - return self::PROPERTY_TYPE_FLOAT; - break; - case 'empty': // Empty - case 'null': // Null - case 'lpstr': // LPSTR - case 'lpwstr': // LPWSTR - case 'bstr': // Basic String - return self::PROPERTY_TYPE_STRING; - break; - case 'date': // Date and Time - case 'filetime': // File Time - return self::PROPERTY_TYPE_DATE; - break; - case 'bool': // Boolean - return self::PROPERTY_TYPE_BOOLEAN; - break; - case 'cy': // Currency - case 'error': // Error Status Code - case 'vector': // Vector - case 'array': // Array - case 'blob': // Binary Blob - case 'oblob': // Binary Blob Object - case 'stream': // Binary Stream - case 'ostream': // Binary Stream Object - case 'storage': // Binary Storage - case 'ostorage': // Binary Storage Object - case 'vstream': // Binary Versioned Stream - case 'clsid': // Class ID - case 'cf': // Clipboard Data - return self::PROPERTY_TYPE_UNKNOWN; - break; - } - return self::PROPERTY_TYPE_UNKNOWN; - } -} diff --git a/Classes/PhpWord/Exceptions/Exception.php b/Classes/PhpWord/Exceptions/Exception.php deleted file mode 100755 index 72f5cfedc6..0000000000 --- a/Classes/PhpWord/Exceptions/Exception.php +++ /dev/null @@ -1,6 +0,0 @@ -addFromSource($pSource); - } - } - - /** - * Add HashTable items from source - * - * @param PhpOffice\PhpWord\IComparable[] $pSource Source array to create HashTable from - * @throws Exception - */ - public function addFromSource($pSource = null) - { - // Check if an array was passed - if ($pSource == null) { - return; - } elseif (!is_array($pSource)) { - throw new Exception('Invalid array parameter passed.'); - } - - foreach ($pSource as $item) { - $this->add($item); - } - } - - /** - * Add HashTable item - * - * @param PhpOffice\PhpWord\IComparable $pSource Item to add - * @throws Exception - */ - public function add(IComparable $pSource = null) - { - // Determine hashcode - $hashCode = null; - $hashIndex = $pSource->getHashIndex(); - if (is_null($hashIndex)) { - $hashCode = $pSource->getHashCode(); - } elseif (isset ($this->_keyMap[$hashIndex])) { - $hashCode = $this->_keyMap[$hashIndex]; - } else { - $hashCode = $pSource->getHashCode(); - } - - // Add value - if (!isset($this->_items[$hashCode])) { - $this->_items[$hashCode] = $pSource; - $index = count($this->_items) - 1; - $this->_keyMap[$index] = $hashCode; - $pSource->setHashIndex($index); - } else { - $pSource->setHashIndex($this->_items[$hashCode]->getHashIndex()); - } - } - - /** - * Remove HashTable item - * - * @param PhpOffice\PhpWord\IComparable $pSource Item to remove - * @throws Exception - */ - public function remove(IComparable $pSource = null) - { - if (isset($this->_items[$pSource->getHashCode()])) { - unset($this->_items[$pSource->getHashCode()]); - - $deleteKey = -1; - foreach ($this->_keyMap as $key => $value) { - if ($deleteKey >= 0) { - $this->_keyMap[$key - 1] = $value; - } - - if ($value == $pSource->getHashCode()) { - $deleteKey = $key; - } - } - unset($this->_keyMap[count($this->_keyMap) - 1]); - } - } - - /** - * Clear HashTable - * - */ - public function clear() - { - $this->_items = array(); - $this->_keyMap = array(); - } - - /** - * @return int - */ - public function count() - { - return count($this->_items); - } - - /** - * @param string $pHashCode - * @return int Index - */ - public function getIndexForHashCode($pHashCode = '') - { - return array_search($pHashCode, $this->_keyMap); - } - - /** - * @param int $pIndex - * @return PhpOffice\PhpWord\IComparable - */ - public function getByIndex($pIndex = 0) - { - if (isset($this->_keyMap[$pIndex])) { - return $this->getByHashCode($this->_keyMap[$pIndex]); - } - - return null; - } - - /** - * @param string $pHashCode - * @return PhpOffice\PhpWord\IComparable - * - */ - public function getByHashCode($pHashCode = '') - { - if (isset($this->_items[$pHashCode])) { - return $this->_items[$pHashCode]; - } - - return null; - } - - /** - * @return PhpOffice\PhpWord\IComparable[] - */ - public function toArray() - { - return $this->_items; - } - - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() - { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if (is_object($value)) { - $this->$key = clone $value; - } - } - } -} \ No newline at end of file diff --git a/Classes/PhpWord/IOFactory.php b/Classes/PhpWord/IOFactory.php deleted file mode 100644 index c62804b6f1..0000000000 --- a/Classes/PhpWord/IOFactory.php +++ /dev/null @@ -1,80 +0,0 @@ -load($filename); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Media.php b/Classes/PhpWord/Media.php deleted file mode 100644 index 2656b3fdd0..0000000000 --- a/Classes/PhpWord/Media.php +++ /dev/null @@ -1,347 +0,0 @@ - array(), - 'embeddings' => array(), - 'links' => array() - ); - - /** - * Header Media Elements - * - * @var array - */ - private static $_headerMedia = array(); - - /** - * Footer Media Elements - * - * @var array - */ - private static $_footerMedia = array(); - - /** - * ObjectID Counter - * - * @var int - */ - private static $_objectId = 1325353440; - - /** - * Add new Section Media Element - * - * @param string $src - * @param string $type - * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage - * @return mixed - */ - public static function addSectionMediaElement($src, $type, MemoryImage $memoryImage = null) - { - $mediaId = md5($src); - $key = ($type === 'image') ? 'images' : 'embeddings'; - - if (!array_key_exists($mediaId, self::$_sectionMedia[$key])) { - $cImg = self::countSectionMediaElements('images'); - $cObj = self::countSectionMediaElements('embeddings'); - $rID = self::countSectionMediaElements() + 7; - - $media = array(); - - $folder = null; - $file = null; - if ($type === 'image') { - $cImg++; - //Detect if it's a memory image first by php ext and second by regex - $isMemImage = false; - if (stripos(strrev($src), strrev('.php')) === 0) { - $isMemImage = true; - } - 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 = exif_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'; - } - } - - $folder = 'media'; - $file = $type . $cImg . '.' . strtolower($extension); - } elseif ($type === 'oleObject') { - $cObj++; - $folder = 'embedding'; - $file = $type . $cObj . '.bin'; - } - - $media['source'] = $src; - $media['target'] = "$folder/section_$file"; - $media['type'] = $type; - $media['rID'] = $rID; - - self::$_sectionMedia[$key][$mediaId] = $media; - - if ($type === 'oleObject') { - return array($rID, ++self::$_objectId); - } - - return $rID; - } - - if ($type === 'oleObject') { - $rID = self::$_sectionMedia[$key][$mediaId]['rID']; - return array($rID, ++self::$_objectId); - } - return self::$_sectionMedia[$key][$mediaId]['rID']; - } - - /** - * Add new Section Link Element - * - * @param string $linkSrc - * @return mixed - */ - public static function addSectionLinkElement($linkSrc) - { - $rID = self::countSectionMediaElements() + 7; - - $link = array(); - $link['target'] = $linkSrc; - $link['rID'] = $rID; - $link['type'] = 'hyperlink'; - - self::$_sectionMedia['links'][] = $link; - - return $rID; - } - - /** - * Get Section Media Elements - * - * @param string $key - * @return array - */ - public static function getSectionMediaElements($key = null) - { - if (!is_null($key)) { - return self::$_sectionMedia[$key]; - } - - $arrImages = self::$_sectionMedia['images']; - $arrObjects = self::$_sectionMedia['embeddings']; - $arrLinks = self::$_sectionMedia['links']; - return array_merge($arrImages, $arrObjects, $arrLinks); - } - - /** - * Get Section Media Elements Count - * - * @param string $key - * @return int - */ - public static function countSectionMediaElements($key = null) - { - if (!is_null($key)) { - return count(self::$_sectionMedia[$key]); - } - - $cImages = count(self::$_sectionMedia['images']); - $cObjects = count(self::$_sectionMedia['embeddings']); - $cLinks = count(self::$_sectionMedia['links']); - return ($cImages + $cObjects + $cLinks); - } - - /** - * Add new Header Media Element - * - * @param int $headerCount - * @param string $src - * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage - * @return int - */ - public static function addHeaderMediaElement($headerCount, $src, MemoryImage $memoryImage = null) - { - $mediaId = md5($src); - $key = 'header' . $headerCount; - - if (!array_key_exists($key, self::$_headerMedia)) { - self::$_headerMedia[$key] = array(); - } - - if (!array_key_exists($mediaId, self::$_headerMedia[$key])) { - $cImg = self::countHeaderMediaElements($key); - $rID = $cImg + 1; - - $cImg++; - $inf = pathinfo($src); - $isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false; - - $media = array(); - if ($isMemImage) { - $ext = $memoryImage->getImageExtension(); - $media['isMemImage'] = true; - $media['createfunction'] = $memoryImage->getImageCreateFunction(); - $media['imagefunction'] = $memoryImage->getImageFunction(); - } else { - $ext = $inf['extension']; - if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg - $ext = 'jpg'; - } - } - $file = 'image' . $cImg . '.' . strtolower($ext); - - $media['source'] = $src; - $media['target'] = 'media/' . $key . '_' . $file; - $media['type'] = 'image'; - $media['rID'] = $rID; - - self::$_headerMedia[$key][$mediaId] = $media; - - return $rID; - } - return self::$_headerMedia[$key][$mediaId]['rID']; - } - - /** - * Get Header Media Elements Count - * - * @param string $key - * @return int - */ - public static function countHeaderMediaElements($key) - { - return count(self::$_headerMedia[$key]); - } - - /** - * Get Header Media Elements - * - * @return int - */ - public static function getHeaderMediaElements() - { - return self::$_headerMedia; - } - - /** - * Add new Footer Media Element - * - * @param int $footerCount - * @param string $src - * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage - * @return int - */ - public static function addFooterMediaElement($footerCount, $src, MemoryImage $memoryImage = null) - { - $mediaId = md5($src); - $key = 'footer' . $footerCount; - - if (!array_key_exists($key, self::$_footerMedia)) { - self::$_footerMedia[$key] = array(); - } - - if (!array_key_exists($mediaId, self::$_footerMedia[$key])) { - $cImg = self::countFooterMediaElements($key); - $rID = $cImg + 1; - - $cImg++; - $inf = pathinfo($src); - $isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false; - - $media = array(); - if ($isMemImage) { - $ext = $memoryImage->getImageExtension(); - $media['isMemImage'] = true; - $media['createfunction'] = $memoryImage->getImageCreateFunction(); - $media['imagefunction'] = $memoryImage->getImageFunction(); - } else { - $ext = $inf['extension']; - if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg - $ext = 'jpg'; - } - } - $file = 'image' . $cImg . '.' . strtolower($ext); - - $media['source'] = $src; - $media['target'] = 'media/' . $key . '_' . $file; - $media['type'] = 'image'; - $media['rID'] = $rID; - - self::$_footerMedia[$key][$mediaId] = $media; - - return $rID; - } - return self::$_footerMedia[$key][$mediaId]['rID']; - } - - /** - * Get Footer Media Elements Count - * - * @param string $key - * @return int - */ - public static function countFooterMediaElements($key) - { - return count(self::$_footerMedia[$key]); - } - - /** - * Get Footer Media Elements - * - * @return int - */ - public static function getFooterMediaElements() - { - return self::$_footerMedia; - } -} diff --git a/Classes/PhpWord/Reader/AbstractReader.php b/Classes/PhpWord/Reader/AbstractReader.php deleted file mode 100644 index f92980cb8e..0000000000 --- a/Classes/PhpWord/Reader/AbstractReader.php +++ /dev/null @@ -1,110 +0,0 @@ -readDataOnly; - return true; - } - - /** - * Set read data only - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Reader\IReader - */ - public function setReadDataOnly($pValue = true) - { - $this->readDataOnly = $pValue; - return $this; - } - - /** - * Open file for reading - * - * @param string $pFilename - * @return resource - * @throws Exception - */ - protected function openFile($pFilename) - { - // Check if file exists - if (!file_exists($pFilename) || !is_readable($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - // Open file - $this->fileHandle = fopen($pFilename, 'r'); - if ($this->fileHandle === false) { - throw new Exception("Could not open file " . $pFilename . " for reading."); - } - } - - /** - * Can the current IReader read the file? - * - * @param string $pFilename - * @return bool - */ - public function canRead($pFilename) - { - // Check if file exists - try { - $this->openFile($pFilename); - } catch (Exception $e) { - return false; - } - fclose($this->fileHandle); - return true; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Reader/IReader.php b/Classes/PhpWord/Reader/IReader.php deleted file mode 100644 index 94db13e576..0000000000 --- a/Classes/PhpWord/Reader/IReader.php +++ /dev/null @@ -1,46 +0,0 @@ -open($pFilename) === true) { - // check if it is an OOXML archive - $rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels")); - if ($rels !== false) { - foreach ($rels->Relationship as $rel) { - switch ($rel["Type"]) { - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": - if (basename($rel["Target"]) == 'document.xml') { - $return = true; - } - break; - - } - } - } - $zip->close(); - } - - return $return; - } - - /** - * @param ZipArchive $archive - * @param string $fileName - * @param bool $removeNamespace - * @return mixed - */ - public function getFromZipArchive($archive, $fileName = '', $removeNamespace = false) - { - // Root-relative paths - if (strpos($fileName, '//') !== false) { - $fileName = substr($fileName, strpos($fileName, '//') + 1); - } - $fileName = File::realpath($fileName); - - // Apache POI fixes - $contents = $archive->getFromName($fileName); - if ($contents === false) { - $contents = $archive->getFromName(substr($fileName, 1)); - } - - // Remove namespaces from elements and attributes name - if ($removeNamespace) { - $contents = preg_replace('~(canRead($pFilename)) { - return null; - } - - // Initialisations - $word = new PhpWord(); - $zip = new ZipArchive(); - $zip->open($pFilename); - - // Read properties and documents - $rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels")); - foreach ($rels->Relationship as $rel) { - switch ($rel["Type"]) { - // Core properties - case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties": - $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); - if (is_object($xmlCore)) { - $xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/"); - $xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/"); - $xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"); - $docProps = $word->getDocumentProperties(); - $docProps->setCreator((string)self::arrayItem($xmlCore->xpath("dc:creator"))); - $docProps->setLastModifiedBy((string)self::arrayItem($xmlCore->xpath("cp:lastModifiedBy"))); - $docProps->setCreated(strtotime(self::arrayItem($xmlCore->xpath("dcterms:created")))); - $docProps->setModified(strtotime(self::arrayItem($xmlCore->xpath("dcterms:modified")))); - $docProps->setTitle((string)self::arrayItem($xmlCore->xpath("dc:title"))); - $docProps->setDescription((string)self::arrayItem($xmlCore->xpath("dc:description"))); - $docProps->setSubject((string)self::arrayItem($xmlCore->xpath("dc:subject"))); - $docProps->setKeywords((string)self::arrayItem($xmlCore->xpath("cp:keywords"))); - $docProps->setCategory((string)self::arrayItem($xmlCore->xpath("cp:category"))); - } - break; - // Extended properties - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties": - $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); - if (is_object($xmlCore)) { - $docProps = $word->getDocumentProperties(); - if (isset($xmlCore->Company)) { - $docProps->setCompany((string)$xmlCore->Company); - } - if (isset($xmlCore->Manager)) { - $docProps->setManager((string)$xmlCore->Manager); - } - } - break; - // Custom properties - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": - $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); - if (is_object($xmlCore)) { - $docProps = $word->getDocumentProperties(); - foreach ($xmlCore as $xmlProperty) { - $cellDataOfficeAttributes = $xmlProperty->attributes(); - if (isset($cellDataOfficeAttributes['name'])) { - $propertyName = (string)$cellDataOfficeAttributes['name']; - $cellDataOfficeChildren = $xmlProperty->children("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"); - $attributeType = $cellDataOfficeChildren->getName(); - $attributeValue = (string)$cellDataOfficeChildren->{$attributeType}; - $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType); - $attributeType = DocumentProperties::convertPropertyType($attributeType); - $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); - } - } - } - break; - // Document - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": - $dir = dirname($rel["Target"]); - $archive = "$dir/_rels/" . basename($rel["Target"]) . ".rels"; - $relsDoc = simplexml_load_string($this->getFromZipArchive($zip, $archive)); - $relsDoc->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); - $xpath = self::arrayItem( - $relsDoc->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']") - ); - $xmlDoc = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}", true)); - if (is_object($xmlDoc)) { - $section = $word->createSection(); - - foreach ($xmlDoc->body->children() as $elm) { - $elmName = $elm->getName(); - if ($elmName == 'p') { // Paragraph/section - // Create new section if section setting found - if ($elm->pPr->sectPr) { - $section->setSettings($this->loadSectionSettings($elm->pPr)); - $section = $word->createSection(); - continue; - } - // Has w:r? It's either text or textrun - if ($elm->r) { - // w:r = 1? It's a plain paragraph - if (count($elm->r) == 1) { - $section->addText( - $elm->r->t, - $this->loadFontStyle($elm->r) - ); - // w:r more than 1? It's a textrun - } else { - $textRun = $section->createTextRun(); - foreach ($elm->r as $r) { - $textRun->addText( - $r->t, - $this->loadFontStyle($r) - ); - } - } - // No, it's a textbreak - } else { - $section->addTextBreak(); - } - } elseif ($elmName == 'sectPr') { - // Last section setting - $section->setSettings($this->loadSectionSettings($xmlDoc->body)); - } - } - } - break; - } - } - - // Read styles - $docRels = simplexml_load_string($this->getFromZipArchive($zip, "word/_rels/document.xml.rels")); - foreach ($docRels->Relationship as $rel) { - switch ($rel["Type"]) { - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles": - $xmlStyle = simplexml_load_string($this->getFromZipArchive($zip, "word/{$rel['Target']}", true)); - if (is_object($xmlStyle)) { - foreach ($xmlStyle->children() as $elm) { - if ($elm->getName() != 'style') { - continue; - } - $pStyle = null; - $fStyle = null; - $hasParagraphStyle = isset($elm->pPr); - $hasFontStyle = isset($elm->rPr); - $styleName = (string)$elm->name['val']; - if ($hasParagraphStyle) { - $pStyle = $this->loadParagraphStyle($elm); - if (!$hasFontStyle) { - $word->addParagraphStyle($styleName, $pStyle); - } - } - if ($hasFontStyle) { - $fStyle = $this->loadFontStyle($elm); - $word->addFontStyle($styleName, $fStyle, $pStyle); - } - } - } - break; - } - } - $zip->close(); - - return $word; - } - - /** - * Load section settings from SimpleXMLElement - * - * @param SimpleXMLElement $elm - * @return array|string|null - * - * @todo Implement gutter - */ - private function loadSectionSettings($elm) - { - if ($xml = $elm->sectPr) { - $setting = array(); - if ($xml->type) { - $setting['breakType'] = (string)$xml->type['val']; - } - if ($xml->pgSz) { - if (isset($xml->pgSz['w'])) { - $setting['pageSizeW'] = (int)$xml->pgSz['w']; - } - if (isset($xml->pgSz['h'])) { - $setting['pageSizeH'] = (int)$xml->pgSz['h']; - } - if (isset($xml->pgSz['orient'])) { - $setting['orientation'] = (string)$xml->pgSz['orient']; - } - } - if ($xml->pgMar) { - if (isset($xml->pgMar['top'])) { - $setting['topMargin'] = (int)$xml->pgMar['top']; - } - if (isset($xml->pgMar['left'])) { - $setting['leftMargin'] = (int)$xml->pgMar['left']; - } - if (isset($xml->pgMar['bottom'])) { - $setting['bottomMargin'] = (int)$xml->pgMar['bottom']; - } - if (isset($xml->pgMar['right'])) { - $setting['rightMargin'] = (int)$xml->pgMar['right']; - } - if (isset($xml->pgMar['header'])) { - $setting['headerHeight'] = (int)$xml->pgMar['header']; - } - if (isset($xml->pgMar['footer'])) { - $setting['footerHeight'] = (int)$xml->pgMar['footer']; - } - if (isset($xml->pgMar['gutter'])) { - // $setting['gutter'] = (int)$xml->pgMar['gutter']; - } - } - if ($xml->cols) { - if (isset($xml->cols['num'])) { - $setting['colsNum'] = (int)$xml->cols['num']; - } - if (isset($xml->cols['space'])) { - $setting['colsSpace'] = (int)$xml->cols['space']; - } - } - return $setting; - } - return null; - } - - /** - * Load paragraph style from SimpleXMLElement - * - * @param SimpleXMLElement $elm - * @return array|string|null - */ - private function loadParagraphStyle($elm) - { - if ($xml = $elm->pPr) { - if ($xml->pStyle) { - return (string)$xml->pStyle['val']; - } - $style = array(); - if ($xml->jc) { - $style['align'] = (string)$xml->jc['val']; - } - if ($xml->ind) { - if (isset($xml->ind->left)) { - $style['indent'] = (int)$xml->ind->left; - } - if (isset($xml->ind->hanging)) { - $style['hanging'] = (int)$xml->ind->hanging; - } - if (isset($xml->ind->line)) { - $style['spacing'] = (int)$xml->ind->line; - } - } - if ($xml->spacing) { - if (isset($xml->spacing['after'])) { - $style['spaceAfter'] = (int)$xml->spacing['after']; - } - if (isset($xml->spacing['before'])) { - $style['spaceBefore'] = (int)$xml->spacing['before']; - } - if (isset($xml->spacing['line'])) { - $style['spacing'] = (int)$xml->spacing['line']; - } - } - if ($xml->basedOn) { - $style['basedOn'] = (string)$xml->basedOn['val']; - } - if ($xml->next) { - $style['next'] = (string)$xml->next['val']; - } - if ($xml->widowControl) { - $style['widowControl'] = false; - } - if ($xml->keepNext) { - $style['keepNext'] = true; - } - if ($xml->keepLines) { - $style['keepLines'] = true; - } - if ($xml->pageBreakBefore) { - $style['pageBreakBefore'] = true; - } - return $style; - } - return null; - } - - /** - * Load font style from SimpleXMLElement - * - * @param SimpleXMLElement $elm - * @return array|string|null - */ - private function loadFontStyle($elm) - { - if ($xml = $elm->rPr) { - if ($xml->rStyle) { - return (string)$xml->rStyle['val']; - } - $style = array(); - if ($xml->rFonts) { - $style['name'] = (string)$xml->rFonts['ascii']; - } - if ($xml->sz) { - $style['size'] = (int)$xml->sz['val'] / 2; - } - if ($xml->color) { - $style['color'] = (string)$xml->color['val']; - } - if ($xml->b) { - $style['bold'] = true; - } - if ($xml->i) { - $style['italic'] = true; - } - if ($xml->u) { - $style['underline'] = (string)$xml->u['val']; - } - if ($xml->strike) { - $style['strikethrough'] = true; - } - if ($xml->highlight) { - $style['fgColor'] = (string)$xml->highlight['val']; - } - if ($xml->vertAlign) { - if ($xml->vertAlign['val'] == 'superscript') { - $style['superScript'] = true; - } else { - $style['subScript'] = true; - } - } - return $style; - } - return null; - } - - /** - * @param array $array - * @param mixed $key - * @return mixed|null - */ - private static function arrayItem($array, $key = 0) - { - return (isset($array[$key]) ? $array[$key] : null); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Section.php b/Classes/PhpWord/Section.php deleted file mode 100644 index 0b12f9ef0f..0000000000 --- a/Classes/PhpWord/Section.php +++ /dev/null @@ -1,453 +0,0 @@ -_sectionCount = $sectionCount; - $this->_settings = new Settings(); - $this->setSettings($settings); - } - - /** - * Set Section Settings - * - * @param array $settings - */ - public function setSettings($settings = null) - { - if (!is_null($settings) && is_array($settings)) { - foreach ($settings as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_settings->setSettingValue($key, $value); - } - } - } - - /** - * Get Section Settings - * - * @return PhpOffice\PhpWord\Section\Settings - */ - public function getSettings() - { - return $this->_settings; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Link - */ - public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($linkSrc)) { - $linkSrc = utf8_encode($linkSrc); - } - if (!is_null($linkName)) { - if (!String::IsUTF8($linkName)) { - $linkName = utf8_encode($linkName); - } - } - - $link = new Link($linkSrc, $linkName, $styleFont, $styleParagraph); - $rID = Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Add a TextBreak Element - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Add a PageBreak Element - */ - public function addPageBreak() - { - $this->_elementCollection[] = new PageBreak(); - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table - */ - public function addTable($style = null) - { - $table = new Table('section', $this->_sectionCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a ListItem Element - * - * @param string $text - * @param int $depth - * @param mixed $styleFont - * @param mixed $styleList - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\ListItem - */ - public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $listItem = new ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); - $this->_elementCollection[] = $listItem; - return $listItem; - } - - /** - * Add a OLE-Object Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Object - * @throws Exception - */ - public function addObject($src, $style = null) - { - $object = new Object($src, $style); - - if (!is_null($object->getSource())) { - $inf = pathinfo($src); - $ext = $inf['extension']; - if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { - $ext = substr($ext, 0, -1); - } - - $iconSrc = PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/'; - if (!file_exists($iconSrc . '_' . $ext . '.png')) { - $iconSrc = $iconSrc . '_default.png'; - } else { - $iconSrc .= '_' . $ext . '.png'; - } - - $rIDimg = Media::addSectionMediaElement($iconSrc, 'image'); - $data = Media::addSectionMediaElement($src, 'oleObject'); - $rID = $data[0]; - $objectId = $data[1]; - - $object->setRelationId($rID); - $object->setObjectId($objectId); - $object->setImageRelationId($rIDimg); - - $this->_elementCollection[] = $object; - return $object; - } - throw new Exception('Source does not exist or unsupported object type.'); - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image - * @throws Exception - */ - public function addImage($src, $style = null) - { - $image = new Image($src, $style); - - if (!is_null($image->getSource())) { - $rID = Media::addSectionMediaElement($src, 'image'); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } - throw new Exception('Source does not exist or unsupported image type.'); - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage - * @throws Exception - */ - public function addMemoryImage($link, $style = null) - { - $memoryImage = new MemoryImage($link, $style); - if (!is_null($memoryImage->getSource())) { - $rID = Media::addSectionMediaElement($link, 'image', $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } - throw new Exception('Unsupported image type.'); - } - - /** - * Add a Table-of-Contents Element - * - * @param mixed $styleFont - * @param mixed $styleTOC - * @return PhpOffice\PhpWord\TOC - */ - public function addTOC($styleFont = null, $styleTOC = null) - { - $toc = new TOC($styleFont, $styleTOC); - $this->_elementCollection[] = $toc; - return $toc; - } - - /** - * Add a Title Element - * - * @param string $text - * @param int $depth - * @return PhpOffice\PhpWord\Section\Title - */ - public function addTitle($text, $depth = 1) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $styles = Style::getStyles(); - if (array_key_exists('Heading_' . $depth, $styles)) { - $style = 'Heading' . $depth; - } else { - $style = null; - } - - $title = new Title($text, $depth, $style); - - $data = TOC::addTitle($text, $depth); - $anchor = $data[0]; - $bookmarkId = $data[1]; - - $title->setAnchor($anchor); - $title->setBookmarkId($bookmarkId); - - $this->_elementCollection[] = $title; - return $title; - } - - /** - * Create a new TextRun - * - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\TextRun - */ - public function createTextRun($styleParagraph = null) - { - $textRun = new TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Get all Elements - * - * @return array - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Create a new Header - * - * @return PhpOffice\PhpWord\Section\Header - */ - public function createHeader() - { - $header = new Header($this->_sectionCount); - $this->_headers[] = $header; - return $header; - } - - /** - * Get Headers - * - * @return array - */ - public function getHeaders() - { - return $this->_headers; - } - - /** - * Is there a header for this section that is for the first page only? - * - * If any of the Header instances have a type of Header::FIRST then this method returns true. - * False otherwise. - * - * @return Boolean - */ - public function hasDifferentFirstPage() - { - $value = array_filter($this->_headers, function (Header &$header) { - return $header->getType() == Header::FIRST; - }); - return count($value) > 0; - } - - /** - * Create a new Footer - * - * @return PhpOffice\PhpWord\Section\Footer - */ - public function createFooter() - { - $footer = new Footer($this->_sectionCount); - $this->_footer = $footer; - return $footer; - } - - /** - * Get Footer - * - * @return PhpOffice\PhpWord\Section\Footer - */ - public function getFooter() - { - return $this->_footer; - } - - /** - * Create a new Footnote Element - * - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footnote - */ - public function createFootnote($styleParagraph = null) - { - $footnote = new Footnote($styleParagraph); - $refID = Footnote::addFootnoteElement($footnote); - $footnote->setReferenceId($refID); - $this->_elementCollection[] = $footnote; - return $footnote; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Section/Footer.php b/Classes/PhpWord/Section/Footer.php deleted file mode 100644 index 8c88bd846a..0000000000 --- a/Classes/PhpWord/Section/Footer.php +++ /dev/null @@ -1,217 +0,0 @@ -_footerCount = $sectionCount; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add TextBreak - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Create a new TextRun - * - * @return PhpOffice\PhpWord\Section\TextRun - */ - public function createTextRun($styleParagraph = null) - { - $textRun = new TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table - */ - public function addTable($style = null) - { - $table = new Table('footer', $this->_footerCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return Image - */ - public function addImage($src, $style = null) - { - $image = new Image($src, $style); - - if (!is_null($image->getSource())) { - $rID = Media::addFooterMediaElement($this->_footerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Src does not exist or invalid image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage - */ - public function addMemoryImage($link, $style = null) - { - $memoryImage = new MemoryImage($link, $style); - if (!is_null($memoryImage->getSource())) { - $rID = Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - throw new Exception('Unsupported image type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footer\PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $ptext = new PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } - - /** - * Get Footer Relation ID - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Footer Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get all Footer Elements - * @return array - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Footer Count - */ - public function getFooterCount() - { - return $this->_footerCount; - } -} diff --git a/Classes/PhpWord/Section/Footer/PreserveText.php b/Classes/PhpWord/Section/Footer/PreserveText.php deleted file mode 100644 index fa9f8a8617..0000000000 --- a/Classes/PhpWord/Section/Footer/PreserveText.php +++ /dev/null @@ -1,130 +0,0 @@ -_styleFont = new Font('text'); - - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleFont->setStyleValue($key, $value); - } - } else { - $this->_styleFont = $styleFont; - } - - // Set paragraph style - if (is_array($styleParagraph)) { - $this->_styleParagraph = new Paragraph(); - - foreach ($styleParagraph as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - - $matches = preg_split('/({.*?})/', $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - if (isset($matches[0])) { - $this->_text = $matches[0]; - } - - return $this; - } - - /** - * Get Text style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public function getFontStyle() - { - return $this->_styleFont; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_styleParagraph; - } - - /** - * Get Text content - * - * @return string - */ - public function getText() - { - return $this->_text; - } -} diff --git a/Classes/PhpWord/Section/Footnote.php b/Classes/PhpWord/Section/Footnote.php deleted file mode 100644 index e5b6e6d814..0000000000 --- a/Classes/PhpWord/Section/Footnote.php +++ /dev/null @@ -1,151 +0,0 @@ -_elementCollection = array(); - - // Set paragraph style - if (is_array($styleParagraph)) { - $this->_styleParagraph = new Paragraph(); - - foreach ($styleParagraph as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - } - - - /** - * Add a Text Element - * - * @var string $text - * @var mixed $styleFont - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text = null, $styleFont = null) - { - $givenText = $text; - $text = new Text($givenText, $styleFont); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $styleFont - * @return PhpOffice\PhpWord\Section\Link - */ - public function addLink($linkSrc, $linkName = null, $styleFont = null) - { - - $link = new Link($linkSrc, $linkName, $styleFont); - $rID = PhpOffice\PhpWord\Footnote::addFootnoteLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Get Footnote content - * - * @return array - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_styleParagraph; - } - - /** - * Get Footnote Reference ID - * - * @return int - */ - public function getReferenceId() - { - return $this->_refId; - } - - /** - * Set Footnote Reference ID - * - * @param int $refId - */ - public function setReferenceId($refId) - { - $this->_refId = $refId; - } -} diff --git a/Classes/PhpWord/Section/Header.php b/Classes/PhpWord/Section/Header.php deleted file mode 100644 index 6067945b1a..0000000000 --- a/Classes/PhpWord/Section/Header.php +++ /dev/null @@ -1,299 +0,0 @@ -_headerCount = $sectionCount; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add TextBreak - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Create a new TextRun - * - * @return PhpOffice\PhpWord\Section\TextRun - */ - public function createTextRun($styleParagraph = null) - { - $textRun = new TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table - */ - public function addTable($style = null) - { - $table = new Table('header', $this->_headerCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image - */ - public function addImage($src, $style = null) - { - $image = new Image($src, $style); - - if (!is_null($image->getSource())) { - $rID = Media::addHeaderMediaElement($this->_headerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Src does not exist or invalid image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage - */ - public function addMemoryImage($link, $style = null) - { - $memoryImage = new MemoryImage($link, $style); - if (!is_null($memoryImage->getSource())) { - $rID = Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - throw new Exception('Unsupported image type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footer\PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $ptext = new PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } - - /** - * Add a Watermark Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image - */ - public function addWatermark($src, $style = null) - { - $image = new Image($src, $style, true); - - if (!is_null($image->getSource())) { - $rID = Media::addHeaderMediaElement($this->_headerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Src does not exist or invalid image type.'); - } - } - - /** - * Get Header Relation ID - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Header Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get all Header Elements - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Header Count - */ - public function getHeaderCount() - { - return $this->_headerCount; - } - - /** - * Get Header Type - */ - public function getType() - { - return $this->_type; - } - - /** - * Reset back to default - */ - public function resetType() - { - return $this->_type = self::AUTO; - } - - /** - * First page only header - */ - public function firstPage() - { - return $this->_type = self::FIRST; - } - - /** - * Even numbered Pages only - */ - public function evenPage() - { - return $this->_type = self::EVEN; - } -} diff --git a/Classes/PhpWord/Section/Image.php b/Classes/PhpWord/Section/Image.php deleted file mode 100644 index 8762e8ca90..0000000000 --- a/Classes/PhpWord/Section/Image.php +++ /dev/null @@ -1,177 +0,0 @@ -_src = $src; - $this->_isWatermark = $isWatermark; - $this->_style = new PhpOffice\PhpWord\Style\Image(); - - if (!is_null($style) && is_array($style)) { - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - - if (isset($style['wrappingStyle'])) { - $this->_style->setWrappingStyle($style['wrappingStyle']); - } - - if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { - $imgData = getimagesize($this->_src); - $this->_style->setWidth($imgData[0]); - $this->_style->setHeight($imgData[1]); - } - } - - /** - * Get Image style - * - * @return PhpOffice\PhpWord\Style\Image - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get Image Relation ID - * - * @return int - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Image Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get Image Source - * - * @return string - */ - public function getSource() - { - return $this->_src; - } - - /** - * Get Image Media ID - * - * @return string - */ - public function getMediaId() - { - return md5($this->_src); - } - - /** - * Get IsWatermark - * - * @return int - */ - public function getIsWatermark() - { - return $this->_isWatermark; - } - - /** - * Set IsWatermark - * - * @param bool $pValue - */ - public function setIsWatermark($pValue) - { - $this->_isWatermark = $pValue; - } -} diff --git a/Classes/PhpWord/Section/Link.php b/Classes/PhpWord/Section/Link.php deleted file mode 100644 index 5c3cc9fedd..0000000000 --- a/Classes/PhpWord/Section/Link.php +++ /dev/null @@ -1,174 +0,0 @@ -_linkSrc = $linkSrc; - $this->_linkName = $linkName; - - // Set font style - if (is_array($styleFont)) { - $this->_styleFont = new Font('text'); - - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleFont->setStyleValue($key, $value); - } - } else { - $this->_styleFont = $styleFont; - } - - // Set paragraph style - if (is_array($styleParagraph)) { - $this->_styleParagraph = new Paragraph(); - - foreach ($styleParagraph as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - - return $this; - } - - /** - * Get Link Relation ID - * - * @return int - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Link Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get Link source - * - * @return string - */ - public function getLinkSrc() - { - return $this->_linkSrc; - } - - /** - * Get Link name - * - * @return string - */ - public function getLinkName() - { - return $this->_linkName; - } - - /** - * Get Text style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public function getFontStyle() - { - return $this->_styleFont; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_styleParagraph; - } -} diff --git a/Classes/PhpWord/Section/ListItem.php b/Classes/PhpWord/Section/ListItem.php deleted file mode 100644 index 2aaf4c34dd..0000000000 --- a/Classes/PhpWord/Section/ListItem.php +++ /dev/null @@ -1,101 +0,0 @@ -_style = new PhpOffice\PhpWord\Style\ListItem(); - $this->_textObject = new Text($text, $styleFont, $styleParagraph); - $this->_depth = $depth; - - if (!is_null($styleList) && is_array($styleList)) { - foreach ($styleList as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - } - - /** - * Get ListItem style - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get ListItem TextRun - */ - public function getTextObject() - { - return $this->_textObject; - } - - /** - * Get ListItem depth - */ - public function getDepth() - { - return $this->_depth; - } -} diff --git a/Classes/PhpWord/Section/MemoryImage.php b/Classes/PhpWord/Section/MemoryImage.php deleted file mode 100644 index 4d81ee87bd..0000000000 --- a/Classes/PhpWord/Section/MemoryImage.php +++ /dev/null @@ -1,233 +0,0 @@ -_imageType = $imgData['mime']; - - $_supportedImageTypes = array('image/jpeg', 'image/gif', 'image/png'); - - if (in_array($this->_imageType, $_supportedImageTypes)) { - $this->_src = $src; - $this->_style = new Image(); - - if (!is_null($style) && is_array($style)) { - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - - if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { - $this->_style->setWidth($imgData[0]); - $this->_style->setHeight($imgData[1]); - } - - $this->_setFunctions(); - } - } - - /** - * Set Functions - */ - private function _setFunctions() - { - switch ($this->_imageType) { - case 'image/png': - $this->_imageCreateFunc = 'imagecreatefrompng'; - $this->_imageFunc = 'imagepng'; - $this->_imageExtension = 'png'; - break; - case 'image/gif': - $this->_imageCreateFunc = 'imagecreatefromgif'; - $this->_imageFunc = 'imagegif'; - $this->_imageExtension = 'gif'; - break; - case 'image/jpeg': - case 'image/jpg': - $this->_imageCreateFunc = 'imagecreatefromjpeg'; - $this->_imageFunc = 'imagejpeg'; - $this->_imageExtension = 'jpg'; - break; - } - } - - /** - * Get Image style - * - * @return PhpOffice\PhpWord\Style\Image - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get Image Relation ID - * - * @return int - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Image Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get Image Source - * - * @return string - */ - public function getSource() - { - return $this->_src; - } - - /** - * Get Image Media ID - * - * @return string - */ - public function getMediaId() - { - return md5($this->_src); - } - - /** - * Get Image Type - * - * @return string - */ - public function getImageType() - { - return $this->_imageType; - } - - /** - * Get Image Create Function - * - * @return string - */ - public function getImageCreateFunction() - { - return $this->_imageCreateFunc; - } - - /** - * Get Image Function - * - * @return string - */ - public function getImageFunction() - { - return $this->_imageFunc; - } - - /** - * Get Image Extension - * - * @return string - */ - public function getImageExtension() - { - return $this->_imageExtension; - } -} diff --git a/Classes/PhpWord/Section/Object.php b/Classes/PhpWord/Section/Object.php deleted file mode 100644 index 2569478a8c..0000000000 --- a/Classes/PhpWord/Section/Object.php +++ /dev/null @@ -1,179 +0,0 @@ -_src = $src; - $this->_style = new Image(); - - if (!is_null($style) && is_array($style)) { - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - - return $this; - } else { - return false; - } - } - - /** - * Get Image style - * - * @return PhpOffice\PhpWord\Style\Image - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get Source - * - * @return string - */ - public function getSource() - { - return $this->_src; - } - - /** - * Get Object Relation ID - * - * @return int - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Object Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get Image Relation ID - * - * @return int - */ - public function getImageRelationId() - { - return $this->_rIdImg; - } - - /** - * Set Image Relation ID - * - * @param int $rId - */ - public function setImageRelationId($rId) - { - $this->_rIdImg = $rId; - } - - /** - * Get Object ID - * - * @return int - */ - public function getObjectId() - { - return $this->_objId; - } - - /** - * Set Object ID - * - * @param int $objId - */ - public function setObjectId($objId) - { - $this->_objId = $objId; - } -} diff --git a/Classes/PhpWord/Section/PageBreak.php b/Classes/PhpWord/Section/PageBreak.php deleted file mode 100644 index ebf7f31ff3..0000000000 --- a/Classes/PhpWord/Section/PageBreak.php +++ /dev/null @@ -1,38 +0,0 @@ -_orientation = null; - $this->_marginTop = 1418; - $this->_marginLeft = 1418; - $this->_marginRight = 1418; - $this->_marginBottom = 1134; - $this->_pageSizeW = $this->_defaultPageSizeW; - $this->_pageSizeH = $this->_defaultPageSizeH; - $this->_borderTopSize = null; - $this->_borderTopColor = null; - $this->_borderLeftSize = null; - $this->_borderLeftColor = null; - $this->_borderRightSize = null; - $this->_borderRightColor = null; - $this->_borderBottomSize = null; - $this->_borderBottomColor = null; - $this->headerHeight = 720; // set default header and footer to 720 twips (.5 inches) - $this->footerHeight = 720; - $this->_colsNum = 1; - $this->_colsSpace = 720; - $this->_breakType = null; - } - - /** - * Set Setting Value - * - * @param string $key - * @param string $value - */ - public function setSettingValue($key, $value) - { - if ($key == '_orientation' && $value == 'landscape') { - $this->setLandscape(); - } elseif ($key == '_orientation' && is_null($value)) { - $this->setPortrait(); - } elseif ($key == '_borderSize') { - $this->setBorderSize($value); - } elseif ($key == '_borderColor') { - $this->setBorderColor($value); - } else { - $this->$key = $value; - } - } - - /** - * Get Margin Top - * - * @return int - */ - public function getMarginTop() - { - return $this->_marginTop; - } - - /** - * Set Margin Top - * - * @param int $pValue - */ - public function setMarginTop($pValue = '') - { - $this->_marginTop = $pValue; - return $this; - } - - /** - * Get Margin Left - * - * @return int - */ - public function getMarginLeft() - { - return $this->_marginLeft; - } - - /** - * Set Margin Left - * - * @param int $pValue - */ - public function setMarginLeft($pValue = '') - { - $this->_marginLeft = $pValue; - return $this; - } - - /** - * Get Margin Right - * - * @return int - */ - public function getMarginRight() - { - return $this->_marginRight; - } - - /** - * Set Margin Right - * - * @param int $pValue - */ - public function setMarginRight($pValue = '') - { - $this->_marginRight = $pValue; - return $this; - } - - /** - * Get Margin Bottom - * - * @return int - */ - public function getMarginBottom() - { - return $this->_marginBottom; - } - - /** - * Set Margin Bottom - * - * @param int $pValue - */ - public function setMarginBottom($pValue = '') - { - $this->_marginBottom = $pValue; - return $this; - } - - /** - * Set Landscape Orientation - */ - public function setLandscape() - { - $this->_orientation = 'landscape'; - $this->_pageSizeW = $this->_defaultPageSizeH; - $this->_pageSizeH = $this->_defaultPageSizeW; - } - - /** - * Set Portrait Orientation - */ - public function setPortrait() - { - $this->_orientation = null; - $this->_pageSizeW = $this->_defaultPageSizeW; - $this->_pageSizeH = $this->_defaultPageSizeH; - } - - /** - * Get Page Size Width - * - * @return int - */ - public function getPageSizeW() - { - return $this->_pageSizeW; - } - - /** - * Get Page Size Height - * - * @return int - */ - public function getPageSizeH() - { - return $this->_pageSizeH; - } - - /** - * Get Page Orientation - * - * @return string - */ - public function getOrientation() - { - return $this->_orientation; - } - - /** - * Set Border Size - * - * @param int $pValue - */ - public function setBorderSize($pValue = null) - { - $this->_borderTopSize = $pValue; - $this->_borderLeftSize = $pValue; - $this->_borderRightSize = $pValue; - $this->_borderBottomSize = $pValue; - } - - /** - * Get Border Size - * - * @return array - */ - public function getBorderSize() - { - $t = $this->getBorderTopSize(); - $l = $this->getBorderLeftSize(); - $r = $this->getBorderRightSize(); - $b = $this->getBorderBottomSize(); - - return array($t, $l, $r, $b); - } - - /** - * Set Border Color - * - * @param string $pValue - */ - public function setBorderColor($pValue = null) - { - $this->_borderTopColor = $pValue; - $this->_borderLeftColor = $pValue; - $this->_borderRightColor = $pValue; - $this->_borderBottomColor = $pValue; - } - - /** - * Get Border Color - * - * @return array - */ - public function getBorderColor() - { - $t = $this->getBorderTopColor(); - $l = $this->getBorderLeftColor(); - $r = $this->getBorderRightColor(); - $b = $this->getBorderBottomColor(); - - 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 - * - * @return int - */ - 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 - * - * @return string - */ - 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 - * - * @return int - */ - 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 - * - * @return string - */ - 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 - * - * @return int - */ - 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 - * - * @return string - */ - 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 - * - * @return int - */ - 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 - * - * @return string - */ - public function getBorderBottomColor() - { - return $this->_borderBottomColor; - } - - /** - * @param null|int $pageNumberingStart - * @return $this - */ - public function setPageNumberingStart($pageNumberingStart = null) - { - $this->pageNumberingStart = $pageNumberingStart; - return $this; - } - - /** - * @return null|int - */ - public function getPageNumberingStart() - { - return $this->pageNumberingStart; - } - - /** - * Get Header Height - * - * @return int - */ - public function getHeaderHeight() - { - return $this->headerHeight; - } - - /** - * Set Header Height - * - * @param int $pValue - */ - public function setHeaderHeight($pValue = '') - { - if (!is_numeric($pValue)) { - $pValue = 720; - } - $this->headerHeight = $pValue; - return $this; - } - - /** - * Get Footer Height - * - * @return int - */ - public function getFooterHeight() - { - return $this->footerHeight; - } - - /** - * Set Footer Height - * - * @param int $pValue - */ - public function setFooterHeight($pValue = '') - { - if (!is_numeric($pValue)) { - $pValue = 720; - } - $this->footerHeight = $pValue; - return $this; - } - - /** - * Set Section Columns Count - * - * @param int $pValue - */ - public function setColsNum($pValue = '') - { - if (!is_numeric($pValue)) { - $pValue = 1; - } - $this->_colsNum = $pValue; - return $this; - } - - /** - * Get Section Columns Count - * - * @return int - */ - public function getColsNum() - { - return $this->_colsNum; - } - - /** - * Set Section Space Between Columns - * - * @param int $pValue - */ - public function setColsSpace($pValue = '') - { - if (!is_numeric($pValue)) { - $pValue = 720; - } - $this->_colsSpace = $pValue; - return $this; - } - - /** - * Get Section Space Between Columns - * - * @return int - */ - public function getColsSpace() - { - return $this->_colsSpace; - } - - /** - * Set Break Type - * - * @param string $pValue - */ - public function setBreakType($pValue = null) - { - $this->_breakType = $pValue; - return $this; - } - - /** - * Get Break Type - * - * @return string - */ - public function getBreakType() - { - return $this->_breakType; - } -} diff --git a/Classes/PhpWord/Section/Table.php b/Classes/PhpWord/Section/Table.php deleted file mode 100644 index a06b41acca..0000000000 --- a/Classes/PhpWord/Section/Table.php +++ /dev/null @@ -1,163 +0,0 @@ -_insideOf = $insideOf; - $this->_pCount = $pCount; - - if (!is_null($style)) { - if (is_array($style)) { - $this->_style = new PhpOffice\PhpWord\Style\Table(); - - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } else { - $this->_style = $style; - } - } - } - - /** - * Add a row - * - * @param int $height - */ - public function addRow($height = null, $style = null) - { - $row = new Row($this->_insideOf, $this->_pCount, $height, $style); - $this->_rows[] = $row; - return $row; - } - - /** - * Add a cell - * - * @param int $width - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table\Cell - */ - public function addCell($width = null, $style = null) - { - $i = count($this->_rows) - 1; - $cell = $this->_rows[$i]->addCell($width, $style); - return $cell; - } - - /** - * Get all rows - * - * @return array - */ - public function getRows() - { - return $this->_rows; - } - - /** - * Get table style - * - * @return PhpOffice\PhpWord\Style\Table - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Set table width - * - * @var int $width - */ - public function setWidth($width) - { - $this->_width = $width; - } - - /** - * Get table width - * - * @return int - */ - public function getWidth() - { - return $this->_width; - } -} diff --git a/Classes/PhpWord/Section/Table/Cell.php b/Classes/PhpWord/Section/Table/Cell.php deleted file mode 100644 index b0f646b46c..0000000000 --- a/Classes/PhpWord/Section/Table/Cell.php +++ /dev/null @@ -1,350 +0,0 @@ -_insideOf = $insideOf; - $this->_pCount = $pCount; - $this->_width = $width; - $this->_style = new PhpOffice\PhpWord\Style\Cell(); - - if (!is_null($style)) { - if (is_array($style)) { - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } else { - $this->_style = $style; - } - } - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Link - */ - public function addLink($linkSrc, $linkName = null, $style = null) - { - if ($this->_insideOf == 'section') { - if (!String::IsUTF8($linkSrc)) { - $linkSrc = utf8_encode($linkSrc); - } - if (!is_null($linkName)) { - if (!String::IsUTF8($linkName)) { - $linkName = utf8_encode($linkName); - } - } - - $link = new Link($linkSrc, $linkName, $style); - $rID = Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } else { - throw new Exception('Unsupported Link header / footer reference'); - return false; - } - } - - /** - * Add TextBreak - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Add a ListItem Element - * - * @param string $text - * @param int $depth - * @param mixed $styleText - * @param mixed $styleList - * @return PhpOffice\PhpWord\Section\ListItem - */ - public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $listItem = new ListItem($text, $depth, $styleText, $styleList); - $this->_elementCollection[] = $listItem; - return $listItem; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image - */ - public function addImage($src, $style = null) - { - $image = new Image($src, $style); - - if (!is_null($image->getSource())) { - if ($this->_insideOf == 'section') { - $rID = Media::addSectionMediaElement($src, 'image'); - } elseif ($this->_insideOf == 'header') { - $rID = Media::addHeaderMediaElement($this->_pCount, $src); - } elseif ($this->_insideOf == 'footer') { - $rID = Media::addFooterMediaElement($this->_pCount, $src); - } - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Source does not exist or unsupported image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage - */ - public function addMemoryImage($link, $style = null) - { - $memoryImage = new MemoryImage($link, $style); - if (!is_null($memoryImage->getSource())) { - if ($this->_insideOf == 'section') { - $rID = Media::addSectionMediaElement($link, 'image', $memoryImage); - } elseif ($this->_insideOf == 'header') { - $rID = Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); - } elseif ($this->_insideOf == 'footer') { - $rID = Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); - } - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - throw new Exception('Unsupported image type.'); - } - } - - /** - * Add a OLE-Object Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Object - */ - public function addObject($src, $style = null) - { - $object = new Object($src, $style); - - if (!is_null($object->getSource())) { - $inf = pathinfo($src); - $ext = $inf['extension']; - if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { - $ext = substr($ext, 0, -1); - } - - $iconSrc = PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/'; - if (!file_exists($iconSrc . '_' . $ext . '.png')) { - $iconSrc = $iconSrc . '_default.png'; - } else { - $iconSrc .= '_' . $ext . '.png'; - } - - $rIDimg = Media::addSectionMediaElement($iconSrc, 'image'); - $data = Media::addSectionMediaElement($src, 'oleObject'); - $rID = $data[0]; - $objectId = $data[1]; - - $object->setRelationId($rID); - $object->setObjectId($objectId); - $object->setImageRelationId($rIDimg); - - $this->_elementCollection[] = $object; - return $object; - } else { - throw new Exception('Source does not exist or unsupported object type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footer\PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) - { - if ($this->_insideOf == 'footer' || $this->_insideOf == 'header') { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $ptext = new PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } else { - throw new Exception('addPreserveText only supported in footer/header.'); - } - } - - /** - * Create a new TextRun - * - * @return PhpOffice\PhpWord\Section\TextRun - */ - public function createTextRun($styleParagraph = null) - { - $textRun = new TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Get all Elements - * - * @return array - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Cell Style - * - * @return PhpOffice\PhpWord\Style\Cell - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get Cell width - * - * @return int - */ - public function getWidth() - { - return $this->_width; - } -} diff --git a/Classes/PhpWord/Section/Table/Row.php b/Classes/PhpWord/Section/Table/Row.php deleted file mode 100644 index de9822b34f..0000000000 --- a/Classes/PhpWord/Section/Table/Row.php +++ /dev/null @@ -1,139 +0,0 @@ -_insideOf = $insideOf; - $this->_pCount = $pCount; - $this->_height = $height; - $this->_style = new PhpOffice\PhpWord\Style\Row(); - - if (!is_null($style)) { - if (is_array($style)) { - - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - } - } - - /** - * Add a cell - * - * @param int $width - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table\Cell - */ - public function addCell($width = null, $style = null) - { - $cell = new Cell($this->_insideOf, $this->_pCount, $width, $style); - $this->_cells[] = $cell; - return $cell; - } - - /** - * Get all cells - * - * @return array - */ - public function getCells() - { - return $this->_cells; - } - - /** - * Get row style - * - * @return PhpOffice\PhpWord\Style\Row - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get row height - * - * @return int - */ - public function getHeight() - { - return $this->_height; - } -} diff --git a/Classes/PhpWord/Section/Text.php b/Classes/PhpWord/Section/Text.php deleted file mode 100644 index 3e51bc8679..0000000000 --- a/Classes/PhpWord/Section/Text.php +++ /dev/null @@ -1,154 +0,0 @@ -setText($text); - $paragraphStyle = $this->setParagraphStyle($paragraphStyle); - $this->setFontStyle($fontStyle, $paragraphStyle); - } - - /** - * Set Text style - * - * @param null|array|PhpOffice\PhpWord\Style\Font $style - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - * @return PhpOffice\PhpWord\Style\Font - */ - public function setFontStyle($style = null, $paragraphStyle = null) - { - if ($style instanceof Font) { - $this->fontStyle = $style; - $this->setParagraphStyle($paragraphStyle); - } elseif (is_array($style)) { - $this->fontStyle = new Font('text', $paragraphStyle); - $this->fontStyle->setArrayStyle($style); - } elseif (null === $style) { - $this->fontStyle = new Font('text', $paragraphStyle); - } else { - $this->fontStyle = $style; - $this->setParagraphStyle($paragraphStyle); - } - return $this->fontStyle; - } - - /** - * Get Text style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public function getFontStyle() - { - return $this->fontStyle; - } - - /** - * Set Paragraph style - * - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style - * @return null|PhpOffice\PhpWord\Style\Paragraph - */ - public function setParagraphStyle($style = null) - { - if (is_array($style)) { - $this->paragraphStyle = new Paragraph; - $this->paragraphStyle->setArrayStyle($style); - } elseif ($style instanceof Paragraph) { - $this->paragraphStyle = $style; - } elseif (null === $style) { - $this->paragraphStyle = new Paragraph; - } else { - $this->paragraphStyle = $style; - } - return $this->paragraphStyle; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->paragraphStyle; - } - - /** - * @param string $text - * @return $this - */ - public function setText($text) - { - $this->text = $text; - return $this; - } - - /** - * Get Text content - * - * @return string - */ - public function getText() - { - return $this->text; - } -} diff --git a/Classes/PhpWord/Section/TextBreak.php b/Classes/PhpWord/Section/TextBreak.php deleted file mode 100644 index cd296c745a..0000000000 --- a/Classes/PhpWord/Section/TextBreak.php +++ /dev/null @@ -1,122 +0,0 @@ -setParagraphStyle($paragraphStyle); - } - if (!is_null($fontStyle)) { - $this->setFontStyle($fontStyle, $paragraphStyle); - } - } - - /** - * Set Text style - * - * @param null|array|PhpOffice\PhpWord\Style\Font $style - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - * @return PhpOffice\PhpWord\Style\Font - */ - public function setFontStyle($style = null, $paragraphStyle = null) - { - if ($style instanceof Font) { - $this->fontStyle = $style; - $this->setParagraphStyle($paragraphStyle); - } elseif (is_array($style)) { - $this->fontStyle = new Font('text', $paragraphStyle); - $this->fontStyle->setArrayStyle($style); - } else { - $this->fontStyle = $style; - $this->setParagraphStyle($paragraphStyle); - } - return $this->fontStyle; - } - - /** - * Get Text style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public function getFontStyle() - { - return $this->fontStyle; - } - - /** - * Set Paragraph style - * - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style - * @return null|PhpOffice\PhpWord\Style\Paragraph - */ - public function setParagraphStyle($style = null) - { - if (is_array($style)) { - $this->paragraphStyle = new Paragraph; - $this->paragraphStyle->setArrayStyle($style); - } elseif ($style instanceof Paragraph) { - $this->paragraphStyle = $style; - } else { - $this->paragraphStyle = $style; - } - return $this->paragraphStyle; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->paragraphStyle; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Section/TextRun.php b/Classes/PhpWord/Section/TextRun.php deleted file mode 100644 index 4cee06d60e..0000000000 --- a/Classes/PhpWord/Section/TextRun.php +++ /dev/null @@ -1,184 +0,0 @@ -_elementCollection = array(); - - // Set paragraph style - if (is_array($styleParagraph)) { - $this->_styleParagraph = new Paragraph(); - - foreach ($styleParagraph as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - } - - - /** - * Add a Text Element - * - * @var string $text - * @var mixed $styleFont - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text = null, $styleFont = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $styleFont - * @return PhpOffice\PhpWord\Section\Link - */ - public function addLink($linkSrc, $linkName = null, $styleFont = null) - { - $linkSrc = utf8_encode($linkSrc); - if (!is_null($linkName)) { - $linkName = utf8_encode($linkName); - } - - $link = new Link($linkSrc, $linkName, $styleFont); - $rID = Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Add a Image Element - * - * @param string $imageSrc - * @param mixed $styleFont - * @return PhpOffice\PhpWord\Section\Image - */ - public function addImage($imageSrc, $style = null) - { - $image = new Image($imageSrc, $style); - - if (!is_null($image->getSource())) { - $rID = Media::addSectionMediaElement($imageSrc, 'image'); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Source does not exist or unsupported image type.'); - } - } - - /** - * Add TextBreak - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Create a new Footnote Element - * - * @param string $text - * @return PhpOffice\PhpWord\Section\Footnote - */ - public function createFootnote($styleParagraph = null) - { - $footnote = new PhpOffice\PhpWord\Section\Footnote($styleParagraph); - $refID = PhpOffice\PhpWord\Footnote::addFootnoteElement($footnote); - $footnote->setReferenceId($refID); - $this->_elementCollection[] = $footnote; - return $footnote; - } - - /** - * Get TextRun content - * - * @return string - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_styleParagraph; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Section/Title.php b/Classes/PhpWord/Section/Title.php deleted file mode 100644 index fdc31ac885..0000000000 --- a/Classes/PhpWord/Section/Title.php +++ /dev/null @@ -1,145 +0,0 @@ -_style = $style; - } - - $this->_text = $text; - $this->_depth = $depth; - - return $this; - } - - /** - * Set Anchor - * - * @var int $anchor - */ - public function setAnchor($anchor) - { - $this->_anchor = $anchor; - } - - /** - * Get Anchor - * - * @return int - */ - public function getAnchor() - { - return $this->_anchor; - } - - /** - * Set Bookmark ID - * - * @var int $bookmarkId - */ - public function setBookmarkId($bookmarkId) - { - $this->_bookmarkId = $bookmarkId; - } - - /** - * Get Anchor - * - * @return int - */ - public function getBookmarkId() - { - return $this->_bookmarkId; - } - - /** - * Get Title Text content - * - * @return string - */ - public function getText() - { - return $this->_text; - } - - /** - * Get Title style - * - * @return string - */ - public function getStyle() - { - return $this->_style; - } -} diff --git a/Classes/PhpWord/Settings.php b/Classes/PhpWord/Settings.php deleted file mode 100644 index 8eb3a60f9a..0000000000 --- a/Classes/PhpWord/Settings.php +++ /dev/null @@ -1,63 +0,0 @@ - 0) { - unset($pathArray[$i]); - unset($pathArray[$i - 1]); - break; - } - } - } - $returnValue = implode('/', $pathArray); - } - - // Return - return $returnValue; - } -} diff --git a/Classes/PhpWord/Shared/Font.php b/Classes/PhpWord/Shared/Font.php deleted file mode 100644 index adee50ada4..0000000000 --- a/Classes/PhpWord/Shared/Font.php +++ /dev/null @@ -1,90 +0,0 @@ -) - * element or in the shared string element. - * - * @param string $value Value to unescape - * @return string - */ - public static function ControlCharacterOOXML2PHP($value = '') - { - if (empty(self::$_controlCharacters)) { - self::_buildControlCharacters(); - } - - return str_replace(array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value); - } - - /** - * Convert from PHP control character to OpenXML escaped control character - * - * Excel 2007 team: - * ---------------- - * That's correct, control characters are stored directly in the shared-strings table. - * We do encode characters that cannot be represented in XML using the following escape sequence: - * _xHHHH_ where H represents a hexadecimal character in the character's value... - * So you could end up with something like _x0008_ in a string (either in a cell value () - * element or in the shared string element. - * - * @param string $value Value to escape - * @return string - */ - public static function ControlCharacterPHP2OOXML($value = '') - { - if (empty(self::$_controlCharacters)) { - self::_buildControlCharacters(); - } - - return str_replace(array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value); - } - - /** - * Check if a string contains UTF-8 data - * - * @param string $value - * @return boolean - */ - public static function IsUTF8($value = '') - { - return $value === '' || preg_match('/^./su', $value) === 1; - } -} diff --git a/Classes/PhpWord/Shared/XMLWriter.php b/Classes/PhpWord/Shared/XMLWriter.php deleted file mode 100644 index 2334997fa0..0000000000 --- a/Classes/PhpWord/Shared/XMLWriter.php +++ /dev/null @@ -1,155 +0,0 @@ -_xmlWriter = new XMLWriter(); - - // Open temporary storage - if ($pTemporaryStorage == self::STORAGE_MEMORY) { - $this->_xmlWriter->openMemory(); - } else { - // Create temporary filename - $this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml'); - - // Open storage - if ($this->_xmlWriter->openUri($this->_tempFileName) === false) { - // Fallback to memory... - $this->_xmlWriter->openMemory(); - } - } - - // Set xml Compatibility - $compatibility = Settings::getCompatibility(); - if ($compatibility) { - $this->_xmlWriter->setIndent(false); - $this->_xmlWriter->setIndentString(''); - } else { - $this->_xmlWriter->setIndent(true); - $this->_xmlWriter->setIndentString(' '); - } - } - - /** - * Destructor - */ - public function __destruct() - { - // Desctruct XMLWriter - unset($this->_xmlWriter); - - // Unlink temporary files - if ($this->_tempFileName != '') { - @unlink($this->_tempFileName); - } - } - - /** - * Get written data - * - * @return $data - */ - public function getData() - { - if ($this->_tempFileName == '') { - return $this->_xmlWriter->outputMemory(true); - } else { - $this->_xmlWriter->flush(); - return file_get_contents($this->_tempFileName); - } - } - - /** - * Catch function calls (and pass them to internal XMLWriter) - * - * @param unknown_type $function - * @param unknown_type $args - */ - public function __call($function, $args) - { - try { - @call_user_func_array(array($this->_xmlWriter, $function), $args); - } catch (Exception $ex) { - // Do nothing! - } - } - - /** - * Fallback method for writeRaw, introduced in PHP 5.2 - * - * @param string $text - * @return string - */ - public function writeRaw($text) - { - if (isset($this->_xmlWriter) && is_object($this->_xmlWriter) && (method_exists($this->_xmlWriter, 'writeRaw'))) { - return $this->_xmlWriter->writeRaw($text); - } - - return $this->text($text); - } -} diff --git a/Classes/PhpWord/Shared/ZipStreamWrapper.php b/Classes/PhpWord/Shared/ZipStreamWrapper.php deleted file mode 100644 index 4a8bac6c3f..0000000000 --- a/Classes/PhpWord/Shared/ZipStreamWrapper.php +++ /dev/null @@ -1,183 +0,0 @@ -_archive = new ZipArchive(); - $this->_archive->open($url['host']); - - $this->_fileNameInArchive = $url['fragment']; - $this->_position = 0; - $this->_data = $this->_archive->getFromName($this->_fileNameInArchive); - - return true; - } - - /** - * Stat stream - */ - public function stream_stat() - { - return $this->_archive->statName($this->_fileNameInArchive); - } - - /** - * Read stream - */ - public function stream_read($count) - { - $ret = substr($this->_data, $this->_position, $count); - $this->_position += strlen($ret); - return $ret; - } - - /** - * Tell stream - */ - public function stream_tell() - { - return $this->_position; - } - - /** - * EOF stream - */ - public function stream_eof() - { - return $this->_position >= strlen($this->_data); - } - - /** - * Seek stream - */ - public function stream_seek($offset, $whence) - { - switch ($whence) { - case SEEK_SET: - if ($offset < strlen($this->_data) && $offset >= 0) { - $this->_position = $offset; - return true; - } else { - return false; - } - break; - - case SEEK_CUR: - if ($offset >= 0) { - $this->_position += $offset; - return true; - } else { - return false; - } - break; - - case SEEK_END: - if (strlen($this->_data) + $offset >= 0) { - $this->_position = strlen($this->_data) + $offset; - return true; - } else { - return false; - } - break; - - default: - return false; - } - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Style.php b/Classes/PhpWord/Style.php deleted file mode 100644 index 387dc468d1..0000000000 --- a/Classes/PhpWord/Style.php +++ /dev/null @@ -1,161 +0,0 @@ - $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $style->setStyleValue($key, $value); - } - - self::$_styleElements[$styleName] = $style; - } - } - - /** - * @param string $styleName - * @param array $styleFont - * @param array $styleParagraph - */ - public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) - { - if (!array_key_exists($styleName, self::$_styleElements)) { - $font = new Font('text', $styleParagraph); - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $font->setStyleValue($key, $value); - } - self::$_styleElements[$styleName] = $font; - } - } - - /** - * @param string $styleName - * @param array $styles - */ - public static function addLinkStyle($styleName, $styles) - { - if (!array_key_exists($styleName, self::$_styleElements)) { - $style = new Font('link'); - foreach ($styles as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $style->setStyleValue($key, $value); - } - - self::$_styleElements[$styleName] = $style; - } - } - - /** - * @param string $styleName - * @param array $styles - */ - public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null) - { - if (!array_key_exists($styleName, self::$_styleElements)) { - $style = new TableFull($styleTable, $styleFirstRow); - - self::$_styleElements[$styleName] = $style; - } - } - - /** - * @param string $styleName - * @param array $styleFont - * @param array $styleParagraph - */ - public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) - { - $styleName = 'Heading_' . $titleCount; - if (!array_key_exists($styleName, self::$_styleElements)) { - $font = new Font('title', $styleParagraph); - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $font->setStyleValue($key, $value); - } - - self::$_styleElements[$styleName] = $font; - } - } - - /** - * @param array $styles Paragraph style definition - */ - public static function setDefaultParagraphStyle($styles) - { - self::addParagraphStyle('Normal', $styles); - } - - /** - * Get all styles - * - * @return PhpOffice\PhpWord\Style\Font[] - */ - public static function getStyles() - { - return self::$_styleElements; - } - - /** - * @param string - */ - public static function getStyle($styleName) - { - if (array_key_exists($styleName, self::$_styleElements)) { - return self::$_styleElements[$styleName]; - } else { - return null; - } - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Style/Cell.php b/Classes/PhpWord/Style/Cell.php deleted file mode 100644 index 23cd0c07d2..0000000000 --- a/Classes/PhpWord/Style/Cell.php +++ /dev/null @@ -1,343 +0,0 @@ -_valign = null; - $this->_textDirection = null; - $this->_bgColor = null; - $this->_borderTopSize = null; - $this->_borderTopColor = null; - $this->_borderLeftSize = null; - $this->_borderLeftColor = null; - $this->_borderRightSize = null; - $this->_borderRightColor = null; - $this->_borderBottomSize = null; - $this->_borderBottomColor = null; - $this->_defaultBorderColor = '000000'; - } - - /** - * Set style value - * - * @var string $key - * @var mixed $value - */ - public function setStyleValue($key, $value) - { - if ($key == '_borderSize') { - $this->setBorderSize($value); - } elseif ($key == '_borderColor') { - $this->setBorderColor($value); - } else { - $this->$key = $value; - } - } - - public function getVAlign() - { - return $this->_valign; - } - - public function setVAlign($pValue = null) - { - $this->_valign = $pValue; - } - - public function getTextDirection() - { - return $this->_textDirection; - } - - public function setTextDirection($pValue = null) - { - $this->_textDirection = $pValue; - } - - public function getBgColor() - { - return $this->_bgColor; - } - - public function setBgColor($pValue = null) - { - $this->_bgColor = $pValue; - } - - public function setBorderSize($pValue = null) - { - $this->_borderTopSize = $pValue; - $this->_borderLeftSize = $pValue; - $this->_borderRightSize = $pValue; - $this->_borderBottomSize = $pValue; - } - - public function getBorderSize() - { - $t = $this->getBorderTopSize(); - $l = $this->getBorderLeftSize(); - $r = $this->getBorderRightSize(); - $b = $this->getBorderBottomSize(); - - return array($t, $l, $r, $b); - } - - public function setBorderColor($pValue = null) - { - $this->_borderTopColor = $pValue; - $this->_borderLeftColor = $pValue; - $this->_borderRightColor = $pValue; - $this->_borderBottomColor = $pValue; - } - - public function getBorderColor() - { - $t = $this->getBorderTopColor(); - $l = $this->getBorderLeftColor(); - $r = $this->getBorderRightColor(); - $b = $this->getBorderBottomColor(); - - return array($t, $l, $r, $b); - } - - public function setBorderTopSize($pValue = null) - { - $this->_borderTopSize = $pValue; - } - - public function getBorderTopSize() - { - return $this->_borderTopSize; - } - - public function setBorderTopColor($pValue = null) - { - $this->_borderTopColor = $pValue; - } - - public function getBorderTopColor() - { - return $this->_borderTopColor; - } - - public function setBorderLeftSize($pValue = null) - { - $this->_borderLeftSize = $pValue; - } - - public function getBorderLeftSize() - { - return $this->_borderLeftSize; - } - - public function setBorderLeftColor($pValue = null) - { - $this->_borderLeftColor = $pValue; - } - - public function getBorderLeftColor() - { - return $this->_borderLeftColor; - } - - public function setBorderRightSize($pValue = null) - { - $this->_borderRightSize = $pValue; - } - - public function getBorderRightSize() - { - return $this->_borderRightSize; - } - - public function setBorderRightColor($pValue = null) - { - $this->_borderRightColor = $pValue; - } - - public function getBorderRightColor() - { - return $this->_borderRightColor; - } - - - public function setBorderBottomSize($pValue = null) - { - $this->_borderBottomSize = $pValue; - } - - public function getBorderBottomSize() - { - return $this->_borderBottomSize; - } - - public function setBorderBottomColor($pValue = null) - { - $this->_borderBottomColor = $pValue; - } - - public function getBorderBottomColor() - { - return $this->_borderBottomColor; - } - - public function getDefaultBorderColor() - { - return $this->_defaultBorderColor; - } - - public function setGridSpan($pValue = null) - { - $this->_gridSpan = $pValue; - } - - public function getGridSpan() - { - return $this->_gridSpan; - } - - public function setVMerge($pValue = null) - { - $this->_vMerge = $pValue; - } - - public function getVMerge() - { - return $this->_vMerge; - } -} diff --git a/Classes/PhpWord/Style/Font.php b/Classes/PhpWord/Style/Font.php deleted file mode 100644 index 213a10cbb5..0000000000 --- a/Classes/PhpWord/Style/Font.php +++ /dev/null @@ -1,544 +0,0 @@ -_type = $type; - - if ($paragraphStyle instanceof Paragraph) { - $this->_paragraphStyle = $paragraphStyle; - } elseif (is_array($paragraphStyle)) { - $this->_paragraphStyle = new Paragraph; - $this->_paragraphStyle->setArrayStyle($paragraphStyle); - } else { - $this->_paragraphStyle = $paragraphStyle; - } - } - - /** - * @param array $style - * @return $this - */ - public function setArrayStyle(array $style = array()) - { - foreach ($style as $key => $value) { - if ($key === 'line-height') { - $this->setLineHeight($value); - null; - } elseif (substr($key, 0, 1) !== '_') { - $key = '_' . $key; - } - $this->setStyleValue($key, $value); - } - - return $this; - } - - /** - * Set style value - * - * @param string $key - * @param mixed $value - */ - public function setStyleValue($key, $value) - { - $method = 'set' . substr($key, 1); - if (method_exists($this, $method)) { - $this->$method($value); - } - } - - /** - * Get font name - * - * @return bool - */ - public function getName() - { - return $this->_name; - } - - /** - * Set font name - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setName($pValue = PhpWord::DEFAULT_FONT_NAME) - { - if (is_null($pValue) || $pValue == '') { - $pValue = PhpWord::DEFAULT_FONT_NAME; - } - $this->_name = $pValue; - return $this; - } - - - /** - * Get font size - * - * @return int|float - */ - public function getSize() - { - return $this->_size; - } - - /** - * Set font size - * - * @param int|float $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setSize($pValue = PhpWord::DEFAULT_FONT_SIZE) - { - if (!is_numeric($pValue)) { - $pValue = PhpWord::DEFAULT_FONT_SIZE; - } - $this->_size = $pValue; - return $this; - } - - /** - * Get bold - * - * @return bool - */ - public function getBold() - { - return $this->_bold; - } - - /** - * Set bold - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setBold($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_bold = $pValue; - return $this; - } - - /** - * Get italics - * - * @return bool - */ - public function getItalic() - { - return $this->_italic; - } - - /** - * Set italics - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setItalic($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_italic = $pValue; - return $this; - } - - /** - * Get superscript - * - * @return bool - */ - public function getSuperScript() - { - return $this->_superScript; - } - - /** - * Set superscript - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setSuperScript($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_superScript = $pValue; - $this->_subScript = !$pValue; - return $this; - } - - /** - * Get superscript - * - * @return bool - */ - public function getSubScript() - { - return $this->_subScript; - } - - /** - * Set subscript - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setSubScript($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_subScript = $pValue; - $this->_superScript = !$pValue; - return $this; - } - - /** - * Get underline - * - * @return string - */ - public function getUnderline() - { - return $this->_underline; - } - - /** - * Set underline - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setUnderline($pValue = self::UNDERLINE_NONE) - { - if ($pValue == '') { - $pValue = self::UNDERLINE_NONE; - } - $this->_underline = $pValue; - return $this; - } - - /** - * Get strikethrough - * - * @return bool - */ - public function getStrikethrough() - { - return $this->_strikethrough; - } - - /** - * Set strikethrough - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setStrikethrough($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_strikethrough = $pValue; - return $this; - } - - /** - * Get font color - * - * @return string - */ - public function getColor() - { - return $this->_color; - } - - /** - * Set font color - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setColor($pValue = PhpWord::DEFAULT_FONT_COLOR) - { - if (is_null($pValue) || $pValue == '') { - $pValue = PhpWord::DEFAULT_FONT_COLOR; - } - $this->_color = $pValue; - return $this; - } - - /** - * Get foreground/highlight color - * - * @return bool - */ - public function getFgColor() - { - return $this->_fgColor; - } - - /** - * Set foreground/highlight color - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setFgColor($pValue = null) - { - $this->_fgColor = $pValue; - return $this; - } - - /** - * Get style type - * - * @return string - */ - public function getStyleType() - { - return $this->_type; - } - - /** - * Get paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_paragraphStyle; - } - - /** - * Set the line height - * - * @param int|float|string $lineHeight - * @return $this - * @throws InvalidStyleException - */ - public function setLineHeight($lineHeight) - { - if (is_string($lineHeight)) { - $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); - } - - if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) { - throw new InvalidStyleException('Line height must be a valid number'); - } - - $this->lineHeight = $lineHeight; - $this->getParagraphStyle()->setLineHeight($lineHeight); - return $this; - } - - /** - * @return int|float - */ - public function getLineHeight() - { - return $this->lineHeight; - } - - /** - * Get Font Content Type - * - * @return bool - */ - public function getHint() - { - return $this->_hint; - } - - /** - * Set Font Content Type - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setHint($pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE) - { - if (is_null($pValue) || $pValue == '') { - $pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE; - } - $this->_hint = $pValue; - return $this; - } -} diff --git a/Classes/PhpWord/Style/Image.php b/Classes/PhpWord/Style/Image.php deleted file mode 100644 index fbc074bea7..0000000000 --- a/Classes/PhpWord/Style/Image.php +++ /dev/null @@ -1,175 +0,0 @@ -_width = null; - $this->_height = null; - $this->_align = null; - $this->_marginTop = null; - $this->_marginLeft = null; - $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); - } - - public function setStyleValue($key, $value) - { - $this->$key = $value; - } - - public function getWidth() - { - return $this->_width; - } - - public function setWidth($pValue = null) - { - $this->_width = $pValue; - } - - public function getHeight() - { - return $this->_height; - } - - public function setHeight($pValue = null) - { - $this->_height = $pValue; - } - - public function getAlign() - { - return $this->_align; - } - - public function setAlign($pValue = null) - { - $this->_align = $pValue; - } - - /** - * Get Margin Top - * - * @return int - */ - public function getMarginTop() - { - return $this->_marginTop; - } - - /** - * Set Margin Top - * - * @param int $pValue - * @return $this - */ - public function setMarginTop($pValue = null) - { - $this->_marginTop = $pValue; - return $this; - } - - /** - * Get Margin Left - * - * @return int - */ - public function getMarginLeft() - { - return $this->_marginLeft; - } - - /** - * Set Margin Left - * - * @param int $pValue - * @return $this - */ - public function setMarginLeft($pValue = null) - { - $this->_marginLeft = $pValue; - return $this; - } - - /** - * @param string $wrappingStyle - * @throws InvalidArgumentException - * @return $this - */ - public function setWrappingStyle($wrappingStyle) - { - switch ($wrappingStyle) { - case self::WRAPPING_STYLE_BEHIND: - case self::WRAPPING_STYLE_INFRONT: - case self::WRAPPING_STYLE_INLINE: - case self::WRAPPING_STYLE_SQUARE: - case self::WRAPPING_STYLE_TIGHT: - $this->wrappingStyle = $wrappingStyle; - break; - default: - throw new InvalidArgumentException('Wrapping style does not exists'); - break; - } - return $this; - } - - /** - * @return string - */ - public function getWrappingStyle() - { - return $this->wrappingStyle; - } -} diff --git a/Classes/PhpWord/Style/ListItem.php b/Classes/PhpWord/Style/ListItem.php deleted file mode 100644 index 458e08e8a0..0000000000 --- a/Classes/PhpWord/Style/ListItem.php +++ /dev/null @@ -1,80 +0,0 @@ -_listType = self::TYPE_BULLET_FILLED; - } - - /** - * Set style value - * - * @param string $key - * @param string $value - */ - public function setStyleValue($key, $value) - { - $this->$key = $value; - } - - /** - * Set List Type - * - * @param int $pValue - */ - public function setListType($pValue = self::TYPE_BULLET_FILLED) - { - $this->_listType = $pValue; - } - - /** - * Get List Type - */ - public function getListType() - { - return $this->_listType; - } -} diff --git a/Classes/PhpWord/Style/Paragraph.php b/Classes/PhpWord/Style/Paragraph.php deleted file mode 100644 index 87827448ea..0000000000 --- a/Classes/PhpWord/Style/Paragraph.php +++ /dev/null @@ -1,508 +0,0 @@ - $value) { - if ($key === 'line-height') { - null; - } elseif (substr($key, 0, 1) !== '_') { - $key = '_' . $key; - } - $this->setStyleValue($key, $value); - } - - return $this; - } - - /** - * Set Style value - * - * @param string $key - * @param mixed $value - */ - public function setStyleValue($key, $value) - { - if ($key == '_indent' || $key == '_hanging') { - $value = $value * 720; - } elseif ($key == '_spacing') { - $value += 240; // because line height of 1 matches 240 twips - } elseif ($key === 'line-height') { - $this->setLineHeight($value); - return; - } - $this->$key = $value; - $method = 'set' . substr($key, 1); - if (method_exists($this, $method)) { - $this->$method($value); - } - } - - /** - * Get Paragraph Alignment - * - * @return string - */ - public function getAlign() - { - return $this->_align; - } - - /** - * Set Paragraph Alignment - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setAlign($pValue = null) - { - if (strtolower($pValue) == 'justify') { - // justify becames both - $pValue = 'both'; - } - $this->_align = $pValue; - return $this; - } - - /** - * Get Space before Paragraph - * - * @return string - */ - public function getSpaceBefore() - { - return $this->_spaceBefore; - } - - /** - * Set Space before Paragraph - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setSpaceBefore($pValue = null) - { - $this->_spaceBefore = $pValue; - return $this; - } - - /** - * Get Space after Paragraph - * - * @return string - */ - public function getSpaceAfter() - { - return $this->_spaceAfter; - } - - /** - * Set Space after Paragraph - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setSpaceAfter($pValue = null) - { - $this->_spaceAfter = $pValue; - return $this; - } - - /** - * Get Spacing between breaks - * - * @return int - */ - public function getSpacing() - { - return $this->_spacing; - } - - /** - * Set Spacing between breaks - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setSpacing($pValue = null) - { - $this->_spacing = $pValue; - return $this; - } - - /** - * Get indentation - * - * @return int - */ - public function getIndent() - { - return $this->_indent; - } - - /** - * Set indentation - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setIndent($pValue = null) - { - $this->_indent = $pValue; - return $this; - } - - /** - * Get hanging - * - * @return int - */ - public function getHanging() - { - return $this->_hanging; - } - - /** - * Set hanging - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setHanging($pValue = null) - { - $this->_hanging = $pValue; - return $this; - } - - /** - * Get tabs - * - * @return PhpOffice\PhpWord\Style\Tabs - */ - public function getTabs() - { - return $this->_tabs; - } - - /* - * Set tabs - * - * @param array $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setTabs($pValue = null) - { - if (is_array($pValue)) { - $this->_tabs = new Tabs($pValue); - } - return $this; - } - - /** - * Get parent style ID - * - * @return string - */ - public function getBasedOn() - { - return $this->_basedOn; - } - - /** - * Set parent style ID - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setBasedOn($pValue = 'Normal') - { - $this->_basedOn = $pValue; - return $this; - } - - /** - * Get style for next paragraph - * - * @return string - */ - public function getNext() - { - return $this->_next; - } - - /** - * Set style for next paragraph - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setNext($pValue = null) - { - $this->_next = $pValue; - return $this; - } - - /** - * Get allow first/last line to display on a separate page setting - * - * @return bool - */ - public function getWidowControl() - { - return $this->_widowControl; - } - - /** - * Set keep paragraph with next paragraph setting - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setWidowControl($pValue = true) - { - if (!is_bool($pValue)) { - $pValue = true; - } - $this->_widowControl = $pValue; - return $this; - } - - /** - * Get keep paragraph with next paragraph setting - * - * @return bool - */ - public function getKeepNext() - { - return $this->_keepNext; - } - - /** - * Set keep paragraph with next paragraph setting - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setKeepNext($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_keepNext = $pValue; - return $this; - } - - /** - * Get keep all lines on one page setting - * - * @return bool - */ - public function getKeepLines() - { - return $this->_keepLines; - } - - /** - * Set keep all lines on one page setting - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setKeepLines($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_keepLines = $pValue; - return $this; - } - - /** - * Get start paragraph on next page setting - * - * @return bool - */ - public function getPageBreakBefore() - { - return $this->_pageBreakBefore; - } - - /** - * Set start paragraph on next page setting - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setPageBreakBefore($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_pageBreakBefore = $pValue; - return $this; - } - - /** - * Set the line height - * - * @param int|float|string $lineHeight - * @return $this - * @throws InvalidStyleException - */ - public function setLineHeight($lineHeight) - { - if (is_string($lineHeight)) { - $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); - } - - if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) { - throw new InvalidStyleException('Line height must be a valid number'); - } - - $this->lineHeight = $lineHeight; - $this->setSpacing($lineHeight * self::LINE_HEIGHT); - return $this; - } - - /** - * @return int|float - */ - public function getLineHeight() - { - return $this->lineHeight; - } -} diff --git a/Classes/PhpWord/Style/Row.php b/Classes/PhpWord/Style/Row.php deleted file mode 100644 index 5431dd201d..0000000000 --- a/Classes/PhpWord/Style/Row.php +++ /dev/null @@ -1,88 +0,0 @@ -$key = $value; - } - - public function setTblHeader($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_tblHeader = $pValue; - return $this; - } - - public function getTblHeader() - { - return $this->_tblHeader; - } - - public function setCantSplit($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_cantSplit = $pValue; - return $this; - } - - public function getCantSplit() - { - return $this->_cantSplit; - } -} diff --git a/Classes/PhpWord/Style/TOC.php b/Classes/PhpWord/Style/TOC.php deleted file mode 100644 index b7da10595c..0000000000 --- a/Classes/PhpWord/Style/TOC.php +++ /dev/null @@ -1,139 +0,0 @@ -_tabPos = 9062; - $this->_tabLeader = self::TABLEADER_DOT; - $this->_indent = 200; - } - - /** - * Get Tab Position - * - * @return int - */ - public function getTabPos() - { - return $this->_tabPos; - } - - /** - * Set Tab Position - * - * @param int $pValue - */ - public function setTabPos($pValue) - { - $this->_tabPos = $pValue; - } - - /** - * Get Tab Leader - * - * @return string - */ - public function getTabLeader() - { - return $this->_tabLeader; - } - - /** - * Set Tab Leader - * - * @param string $pValue - */ - public function setTabLeader($pValue = self::TABLEADER_DOT) - { - $this->_tabLeader = $pValue; - } - - /** - * Get Indent - * - * @return int - */ - public function getIndent() - { - return $this->_indent; - } - - /** - * Set Indent - * - * @param string $pValue - */ - public function setIndent($pValue) - { - $this->_indent = $pValue; - } - - /** - * Set style value - * - * @param string $key - * @param string $value - */ - public function setStyleValue($key, $value) - { - $this->$key = $value; - } -} diff --git a/Classes/PhpWord/Style/Tab.php b/Classes/PhpWord/Style/Tab.php deleted file mode 100644 index b9d949e904..0000000000 --- a/Classes/PhpWord/Style/Tab.php +++ /dev/null @@ -1,146 +0,0 @@ -_val = (self::isStopType($val)) ? $val : 'clear'; - - // Default to 0 if the position is non-numeric - $this->_position = (is_numeric($position)) ? intval($position) : 0; - - // Default to NULL if no tab leader - $this->_leader = (self::isLeaderType($leader)) ? $leader : null; - } - - /** - * Creates the XML DOM for the instance of Tab. - * - * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter - */ - public function toXml(XMLWriter &$xmlWriter = null) - { - if (isset($xmlWriter)) { - $xmlWriter->startElement("w:tab"); - $xmlWriter->writeAttribute("w:val", $this->_val); - if (!is_null($this->_leader)) { - $xmlWriter->writeAttribute("w:leader", $this->_leader); - } - $xmlWriter->writeAttribute("w:pos", $this->_position); - $xmlWriter->endElement(); - } - } - - /** - * Test if attribute is a valid stop type. - * - * @param string $attribute - * @return bool True if it is; false otherwise. - */ - private static function isStopType($attribute) - { - return in_array($attribute, self::$_possibleStopTypes); - } - - /** - * Test if attribute is a valid leader type. - * - * @param string $attribute - * @return bool True if it is; false otherwise. - */ - private static function isLeaderType($attribute) - { - return in_array($attribute, self::$_possibleLeaders); - } -} diff --git a/Classes/PhpWord/Style/Table.php b/Classes/PhpWord/Style/Table.php deleted file mode 100644 index 4de5660567..0000000000 --- a/Classes/PhpWord/Style/Table.php +++ /dev/null @@ -1,94 +0,0 @@ -_cellMarginTop = null; - $this->_cellMarginLeft = null; - $this->_cellMarginRight = null; - $this->_cellMarginBottom = null; - } - - public function setStyleValue($key, $value) - { - $this->$key = $value; - } - - public function setCellMarginTop($pValue = null) - { - $this->_cellMarginTop = $pValue; - } - - public function getCellMarginTop() - { - return $this->_cellMarginTop; - } - - public function setCellMarginLeft($pValue = null) - { - $this->_cellMarginLeft = $pValue; - } - - public function getCellMarginLeft() - { - return $this->_cellMarginLeft; - } - - public function setCellMarginRight($pValue = null) - { - $this->_cellMarginRight = $pValue; - } - - public function getCellMarginRight() - { - return $this->_cellMarginRight; - } - - public function setCellMarginBottom($pValue = null) - { - $this->_cellMarginBottom = $pValue; - } - - public function getCellMarginBottom() - { - return $this->_cellMarginBottom; - } - - 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 deleted file mode 100644 index 5ca7561b23..0000000000 --- a/Classes/PhpWord/Style/TableFull.php +++ /dev/null @@ -1,443 +0,0 @@ -_firstRow = clone $this; - - unset($this->_firstRow->_firstRow); - unset($this->_firstRow->_cellMarginBottom); - unset($this->_firstRow->_cellMarginTop); - unset($this->_firstRow->_cellMarginLeft); - unset($this->_firstRow->_cellMarginRight); - unset($this->_firstRow->_borderInsideVColor); - unset($this->_firstRow->_borderInsideVSize); - unset($this->_firstRow->_borderInsideHColor); - unset($this->_firstRow->_borderInsideHSize); - foreach ($styleFirstRow as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - - $this->_firstRow->setStyleValue($key, $value); - } - } - - if (!is_null($styleTable) && is_array($styleTable)) { - foreach ($styleTable as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->setStyleValue($key, $value); - } - } - } - - /** - * @param string $key - * @param mixed $value - */ - public function setStyleValue($key, $value) - { - if ($key == '_borderSize') { - $this->setBorderSize($value); - } elseif ($key == '_borderColor') { - $this->setBorderColor($value); - } elseif ($key == '_cellMargin') { - $this->setCellMargin($value); - } else { - $this->$key = $value; - } - } - - /** - * Get First Row Style - * - * @return PhpOffice\PhpWord\Style\TableFull - */ - public function getFirstRow() - { - return $this->_firstRow; - } - - /** - * Get Last Row Style - * - * @return PhpOffice\PhpWord\Style\TableFull - */ - public function getLastRow() - { - return $this->_lastRow; - } - - public function getBgColor() - { - return $this->_bgColor; - } - - public function setBgColor($pValue = null) - { - $this->_bgColor = $pValue; - } - - /** - * Set TLRBVH Border Size - * - * @param int $pValue Border size in eighths of a point (1/8 point) - */ - public function setBorderSize($pValue = null) - { - $this->_borderTopSize = $pValue; - $this->_borderLeftSize = $pValue; - $this->_borderRightSize = $pValue; - $this->_borderBottomSize = $pValue; - $this->_borderInsideHSize = $pValue; - $this->_borderInsideVSize = $pValue; - } - - /** - * Get TLRBVH Border Size - * - * @return array - */ - public function getBorderSize() - { - $t = $this->getBorderTopSize(); - $l = $this->getBorderLeftSize(); - $r = $this->getBorderRightSize(); - $b = $this->getBorderBottomSize(); - $h = $this->getBorderInsideHSize(); - $v = $this->getBorderInsideVSize(); - - return array($t, $l, $r, $b, $h, $v); - } - - /** - * Set TLRBVH Border Color - */ - public function setBorderColor($pValue = null) - { - $this->_borderTopColor = $pValue; - $this->_borderLeftColor = $pValue; - $this->_borderRightColor = $pValue; - $this->_borderBottomColor = $pValue; - $this->_borderInsideHColor = $pValue; - $this->_borderInsideVColor = $pValue; - } - - /** - * Get TLRB Border Color - * - * @return array - */ - public function getBorderColor() - { - $t = $this->getBorderTopColor(); - $l = $this->getBorderLeftColor(); - $r = $this->getBorderRightColor(); - $b = $this->getBorderBottomColor(); - $h = $this->getBorderInsideHColor(); - $v = $this->getBorderInsideVColor(); - - return array($t, $l, $r, $b, $h, $v); - } - - public function setBorderTopSize($pValue = null) - { - $this->_borderTopSize = $pValue; - } - - public function getBorderTopSize() - { - return $this->_borderTopSize; - } - - public function setBorderTopColor($pValue = null) - { - $this->_borderTopColor = $pValue; - } - - public function getBorderTopColor() - { - return $this->_borderTopColor; - } - - public function setBorderLeftSize($pValue = null) - { - $this->_borderLeftSize = $pValue; - } - - public function getBorderLeftSize() - { - return $this->_borderLeftSize; - } - - public function setBorderLeftColor($pValue = null) - { - $this->_borderLeftColor = $pValue; - } - - public function getBorderLeftColor() - { - return $this->_borderLeftColor; - } - - public function setBorderRightSize($pValue = null) - { - $this->_borderRightSize = $pValue; - } - - public function getBorderRightSize() - { - return $this->_borderRightSize; - } - - public function setBorderRightColor($pValue = null) - { - $this->_borderRightColor = $pValue; - } - - public function getBorderRightColor() - { - return $this->_borderRightColor; - } - - public function setBorderBottomSize($pValue = null) - { - $this->_borderBottomSize = $pValue; - } - - public function getBorderBottomSize() - { - return $this->_borderBottomSize; - } - - public function setBorderBottomColor($pValue = null) - { - $this->_borderBottomColor = $pValue; - } - - public function getBorderBottomColor() - { - return $this->_borderBottomColor; - } - - public function setBorderInsideHColor($pValue = null) - { - $this->_borderInsideHColor = $pValue; - } - - public function getBorderInsideHColor() - { - return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null; - } - - public function setBorderInsideVColor($pValue = null) - { - $this->_borderInsideVColor = $pValue; - } - - public function getBorderInsideVColor() - { - return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null; - } - - public function setBorderInsideHSize($pValue = null) - { - $this->_borderInsideHSize = $pValue; - } - - public function getBorderInsideHSize() - { - return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null; - } - - public function setBorderInsideVSize($pValue = null) - { - $this->_borderInsideVSize = $pValue; - } - - public function getBorderInsideVSize() - { - return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null; - } - - public function setCellMarginTop($pValue = null) - { - $this->_cellMarginTop = $pValue; - } - - public function getCellMarginTop() - { - return $this->_cellMarginTop; - } - - public function setCellMarginLeft($pValue = null) - { - $this->_cellMarginLeft = $pValue; - } - - public function getCellMarginLeft() - { - return $this->_cellMarginLeft; - } - - public function setCellMarginRight($pValue = null) - { - $this->_cellMarginRight = $pValue; - } - - public function getCellMarginRight() - { - return $this->_cellMarginRight; - } - - public function setCellMarginBottom($pValue = null) - { - $this->_cellMarginBottom = $pValue; - } - - public function getCellMarginBottom() - { - return $this->_cellMarginBottom; - } - - /** - * Set TLRB cell margin - * - * @param int $pValue Margin in twips - */ - public function setCellMargin($pValue = null) - { - $this->_cellMarginTop = $pValue; - $this->_cellMarginLeft = $pValue; - $this->_cellMarginRight = $pValue; - $this->_cellMarginBottom = $pValue; - } - - public function getCellMargin() - { - return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Style/Tabs.php b/Classes/PhpWord/Style/Tabs.php deleted file mode 100644 index 45fdb5682d..0000000000 --- a/Classes/PhpWord/Style/Tabs.php +++ /dev/null @@ -1,63 +0,0 @@ -_tabs = $tabs; - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter - */ - public function toXml(XMLWriter &$xmlWriter = null) - { - if (isset($xmlWriter)) { - $xmlWriter->startElement("w:tabs"); - foreach ($this->_tabs as &$tab) { - $tab->toXml($xmlWriter); - } - $xmlWriter->endElement(); - } - } -} diff --git a/Classes/PhpWord/TOC.php b/Classes/PhpWord/TOC.php deleted file mode 100644 index 932e54be3b..0000000000 --- a/Classes/PhpWord/TOC.php +++ /dev/null @@ -1,155 +0,0 @@ - $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - self::$_styleTOC->setStyleValue($key, $value); - } - } - - if (!is_null($styleFont)) { - if (is_array($styleFont)) { - self::$_styleFont = new Font(); - - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - self::$_styleFont->setStyleValue($key, $value); - } - } else { - self::$_styleFont = $styleFont; - } - } - } - - /** - * Add a Title - * - * @return array - */ - public static function addTitle($text, $depth = 0) - { - $anchor = '_Toc' . ++self::$_anchor; - $bookmarkId = self::$_bookmarkId++; - - $title = array(); - $title['text'] = $text; - $title['depth'] = $depth; - $title['anchor'] = $anchor; - $title['bookmarkId'] = $bookmarkId; - - self::$_titles[] = $title; - - return array($anchor, $bookmarkId); - } - - /** - * Get all titles - * - * @return array - */ - public static function getTitles() - { - return self::$_titles; - } - - /** - * Get TOC Style - * - * @return PhpOffice\PhpWord\Style\TOC - */ - public static function getStyleTOC() - { - return self::$_styleTOC; - } - - /** - * Get Font Style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public static function getStyleFont() - { - return self::$_styleFont; - } -} diff --git a/Classes/PhpWord/Template.php b/Classes/PhpWord/Template.php deleted file mode 100644 index f934257ec5..0000000000 --- a/Classes/PhpWord/Template.php +++ /dev/null @@ -1,292 +0,0 @@ -_tempFileName = tempnam(sys_get_temp_dir(), ''); - if ($this->_tempFileName === false) { - throw new Exception('Could not create temporary file with unique name in the default temporary directory.'); - } - - // Copy the source File to the temp File - if (!copy($strFilename, $this->_tempFileName)) { - throw new Exception("Could not copy the template from {$strFilename} to {$this->_tempFileName}."); - } - - $this->_objZip = new ZipArchive(); - $this->_objZip->open($this->_tempFileName); - - $this->_documentXML = $this->_objZip->getFromName('word/document.xml'); - } - - /** - * Applies XSL style sheet to template's parts - * - * @param DOMDocument $xslDOMDocument - * @param array $xslOptions - * @param string $xslOptionsURI - * @throws Exception - */ - public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') - { - $processor = new XSLTProcessor(); - - $processor->importStylesheet($xslDOMDocument); - - if ($processor->setParameter($xslOptionsURI, $xslOptions) === false) { - throw new Exception('Could not set values for the given XSL style sheet parameters.'); - } - - $xmlDOMDocument = new DOMDocument(); - if ($xmlDOMDocument->loadXML($this->_documentXML) === false) { - throw new Exception('Could not load XML from the given template.'); - } - - $xmlTransformed = $processor->transformToXml($xmlDOMDocument); - if ($xmlTransformed === false) { - throw new Exception('Could not transform the given XML document.'); - } - - $this->_documentXML = $xmlTransformed; - } - - /** - * Set a Template value - * - * @param mixed $search - * @param mixed $replace - * @param integer $limit - */ - public function setValue($search, $replace, $limit = -1) - { - $pattern = '|\$\{([^\}]+)\}|U'; - preg_match_all($pattern, $this->_documentXML, $matches); - foreach ($matches[0] as $value) { - $valueCleaned = preg_replace('/<[^>]+>/', '', $value); - $valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned); - $this->_documentXML = str_replace($value, $valueCleaned, $this->_documentXML); - } - - if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { - $search = '${' . $search . '}'; - } - - if (!is_array($replace)) { - if (!String::IsUTF8($replace)) { - $replace = utf8_encode($replace); - } - $replace = htmlspecialchars($replace); - } else { - foreach ($replace as $key => $value) { - $replace[$key] = htmlspecialchars($value); - } - } - - $regExpDelim = '/'; - $escapedSearch = preg_quote($search, $regExpDelim); - $this->_documentXML = preg_replace("{$regExpDelim}{$escapedSearch}{$regExpDelim}u", $replace, $this->_documentXML, $limit); - } - - /** - * Returns array of all variables in template - */ - public function getVariables() - { - preg_match_all('/\$\{(.*?)}/i', $this->_documentXML, $matches); - return $matches[1]; - } - - /** - * Find the start position of the nearest table row before $offset - * - * @param int $offset - * @return int - * @throws Exception - */ - private function _findRowStart($offset) - { - $rowStart = strrpos($this->_documentXML, "_documentXML) - $offset) * -1)); - if (!$rowStart) { - $rowStart = strrpos($this->_documentXML, "", ((strlen($this->_documentXML) - $offset) * -1)); - } - if (!$rowStart) { - throw new Exception("Can not find the start position of the row to clone."); - } - return $rowStart; - } - - /** - * Find the end position of the nearest table row after $offset - * - * @param int $offset - * @return int - */ - private function _findRowEnd($offset) - { - $rowEnd = strpos($this->_documentXML, "", $offset) + 7; - return $rowEnd; - } - - /** - * Get a slice of a string - * - * @param int $startPosition - * @param int $endPosition - * @return string - */ - private function _getSlice($startPosition, $endPosition = 0) - { - if (!$endPosition) { - $endPosition = strlen($this->_documentXML); - } - return substr($this->_documentXML, $startPosition, ($endPosition - $startPosition)); - } - - /** - * Clone a table row in a template document - * - * @param string $search - * @param int $numberOfClones - * @throws Exception - */ - public function cloneRow($search, $numberOfClones) - { - if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { - $search = '${' . $search . '}'; - } - - $tagPos = strpos($this->_documentXML, $search); - if (!$tagPos) { - throw new Exception("Can not clone row, template variable not found or variable contains markup."); - } - - $rowStart = $this->_findRowStart($tagPos); - $rowEnd = $this->_findRowEnd($tagPos); - $xmlRow = $this->_getSlice($rowStart, $rowEnd); - - // Check if there's a cell spanning multiple rows. - if (preg_match('##', $xmlRow)) { - $extraRowStart = $rowEnd; - $extraRowEnd = $rowEnd; - while (true) { - $extraRowStart = $this->_findRowStart($extraRowEnd + 1); - $extraRowEnd = $this->_findRowEnd($extraRowEnd + 1); - - // If extraRowEnd is lower then 7, there was no next row found. - if ($extraRowEnd < 7) { - break; - } - - // If tmpXmlRow doesn't contain continue, this row is no longer part of the spanned row. - $tmpXmlRow = $this->_getSlice($extraRowStart, $extraRowEnd); - if (!preg_match('##', $tmpXmlRow) && !preg_match('##', $tmpXmlRow)) { - break; - } - // This row was a spanned row, update $rowEnd and search for the next row. - $rowEnd = $extraRowEnd; - } - $xmlRow = $this->_getSlice($rowStart, $rowEnd); - } - - $result = $this->_getSlice(0, $rowStart); - for ($i = 1; $i <= $numberOfClones; $i++) { - $result .= preg_replace('/\$\{(.*?)\}/', '\${\\1#' . $i . '}', $xmlRow); - } - $result .= $this->_getSlice($rowEnd); - - $this->_documentXML = $result; - } - - /** - * Save Template - * - * @return string - * @throws Exception - */ - public function save() - { - $this->_objZip->addFromString('word/document.xml', $this->_documentXML); - - // Close zip file - if ($this->_objZip->close() === false) { - throw new Exception('Could not close zip file.'); - } - - return $this->_tempFileName; - } - - /** - * Save Template As... - * - * @param string $strFilename - */ - public function saveAs($strFilename) - { - $tempFilename = $this->save(); - - if (file_exists($strFilename)) { - unlink($strFilename); - } - - rename($tempFilename, $strFilename); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Writer/IWriter.php b/Classes/PhpWord/Writer/IWriter.php deleted file mode 100644 index 98c15704fe..0000000000 --- a/Classes/PhpWord/Writer/IWriter.php +++ /dev/null @@ -1,39 +0,0 @@ -setPhpWord($phpWord); - - // Set up disk caching location - $this->_diskCachingDirectory = './'; - - // Initialise writer parts - $this->_writerParts['content'] = new Content(); - $this->_writerParts['manifest'] = new Manifest(); - $this->_writerParts['meta'] = new Meta(); - $this->_writerParts['mimetype'] = new Mimetype(); - $this->_writerParts['styles'] = new Styles(); - - - // Assign parent IWriter - foreach ($this->_writerParts as $writer) { - $writer->setParentWriter($this); - } - - // Set HashTable variables - $this->_drawingHashTable = new HashTable(); - } - - /** - * Save PhpWord to file - * - * @param string $pFileName - * @throws \Exception - */ - public function save($pFilename = null) - { - if (!is_null($this->_document)) { - // If $pFilename is php://output or php://stdout, make it a temporary file... - $originalFilename = $pFilename; - if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { - $pFilename = @tempnam('./', 'phppttmp'); - if ($pFilename == '') { - $pFilename = $originalFilename; - } - } - - // Create drawing dictionary - - // Create new ZIP file and open it for writing - $objZip = new ZipArchive(); - - // Try opening the ZIP file - if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { - if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { - throw new \Exception("Could not open " . $pFilename . " for writing."); - } - } - - // Add mimetype to ZIP file - //@todo Not in ZIPARCHIVE::CM_STORE mode - $objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype($this->_document)); - - // Add content.xml to ZIP file - $objZip->addFromString('content.xml', $this->getWriterPart('content')->writeContent($this->_document)); - - // Add meta.xml to ZIP file - $objZip->addFromString('meta.xml', $this->getWriterPart('meta')->writeMeta($this->_document)); - - // Add styles.xml to ZIP file - $objZip->addFromString('styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document)); - - // Add META-INF/manifest.xml - $objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('manifest')->writeManifest($this->_document)); - - // Add media. Has not used yet. Legacy from PHPExcel. - // @codeCoverageIgnoreStart - for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) { - if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) { - $imageContents = null; - $imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath(); - - if (strpos($imagePath, 'zip://') !== false) { - $imagePath = substr($imagePath, 6); - $imagePathSplitted = explode('#', $imagePath); - - $imageZip = new ZipArchive(); - $imageZip->open($imagePathSplitted[0]); - $imageContents = $imageZip->getFromName($imagePathSplitted[1]); - $imageZip->close(); - unset($imageZip); - } else { - $imageContents = file_get_contents($imagePath); - } - - $objZip->addFromString('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); - } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) { - ob_start(); - call_user_func( - $this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(), - $this->getDrawingHashTable()->getByIndex($i)->getImageResource() - ); - $imageContents = ob_get_contents(); - ob_end_clean(); - - $objZip->addFromString('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); - } - } - // @codeCoverageIgnoreEnd - - // Close file - if ($objZip->close() === false) { - throw new \Exception("Could not close zip file $pFilename."); - } - - // If a temporary file was used, copy it to the correct file stream - if ($originalFilename != $pFilename) { - if (copy($pFilename, $originalFilename) === false) { - throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename."); - } - @unlink($pFilename); - } - - } else { - throw new \Exception("PhpWord object unassigned."); - } - } - - /** - * @return PhpOffice\PhpWord - * @throws \Exception - */ - public function getPhpWord() - { - if (!is_null($this->_document)) { - return $this->_document; - } else { - throw new \Exception("No PhpWord assigned."); - } - } - - /** - * @param PhpOffice\PhpWord $phpWord - * @return PhpOffice\PhpWord\Writer\ODText - */ - public function setPhpWord(PhpWord $phpWord = null) - { - $this->_document = $phpWord; - return $this; - } - - /** - * Get PHPWord_Worksheet_BaseDrawing HashTable - * - * @return PhpOffice\PhpWord\HashTable - */ - public function getDrawingHashTable() - { - return $this->_drawingHashTable; - } - - /** - * @param string $pPartName Writer part name - * @return PhpOffice\PhpWord\Writer\ODText\WriterPart - */ - public function getWriterPart($pPartName = '') - { - if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { - return $this->_writerParts[strtolower($pPartName)]; - } else { - return null; - } - } - - /** - * Get use disk caching where possible? - * - * @return boolean - */ - public function getUseDiskCaching() - { - return $this->_useDiskCaching; - } - - /** - * Set use disk caching where possible? - * - * @param boolean $pValue - * @param string $pDirectory Disk caching directory - * @throws \Exception Exception when directory does not exist - * @return PhpOffice\PhpWord\Writer\ODText - */ - public function setUseDiskCaching($pValue = false, $pDirectory = null) - { - $this->_useDiskCaching = $pValue; - - if (!is_null($pDirectory)) { - if (is_dir($pDirectory)) { - $this->_diskCachingDirectory = $pDirectory; - } else { - throw new \Exception("Directory does not exist: $pDirectory"); - } - } - - return $this; - } - - /** - * @return string - */ - public function getDiskCachingDirectory() - { - return $this->_diskCachingDirectory; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Writer/ODText/Content.php b/Classes/PhpWord/Writer/ODText/Content.php deleted file mode 100644 index d4f4d2ebf8..0000000000 --- a/Classes/PhpWord/Writer/ODText/Content.php +++ /dev/null @@ -1,412 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8'); - - // office:document-content - $xmlWriter->startElement('office:document-content'); - $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); - $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); - $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); - $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); - $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); - $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); - $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); - $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); - $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); - $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); - $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); - $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); - $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); - $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); - $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); - $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); - $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); - $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); - $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); - $xmlWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms'); - $xmlWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); - $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); - $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); - $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); - $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); - $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); - $xmlWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0'); - $xmlWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0'); - $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); - $xmlWriter->writeAttribute('office:version', '1.2'); - - // We firstly search all fonts used - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - if ($countSections > 0) { - $pSection = 0; - $numPStyles = 0; - $numFStyles = 0; - - foreach ($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $fStyle = $element->getFontStyle(); - $pStyle = $element->getParagraphStyle(); - - if ($fStyle instanceof Font) { - $numFStyles++; - - $arrStyle = array( - 'color' => $fStyle->getColor(), - 'name' => $fStyle->getName() - ); - $phpWord->addFontStyle('T' . $numFStyles, $arrStyle); - $element->setFontStyle('T' . $numFStyles); - } elseif ($pStyle instanceof Paragraph) { - $numPStyles++; - - $phpWord->addParagraphStyle('P' . $numPStyles, array()); - $element->setParagraphStyle('P' . $numPStyles); - } - } - } - } - } - - // office:font-face-decls - $xmlWriter->startElement('office:font-face-decls'); - $arrFonts = array(); - - $styles = Style::getStyles(); - $numFonts = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - $numFonts++; - $name = $style->getName(); - if (!in_array($name, $arrFonts)) { - $arrFonts[] = $name; - - // style:font-face - $xmlWriter->startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', $name); - $xmlWriter->writeAttribute('svg:font-family', $name); - $xmlWriter->endElement(); - } - } - } - if (!in_array(PhpWord::DEFAULT_FONT_NAME, $arrFonts)) { - $xmlWriter->startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->endElement(); - } - } - $xmlWriter->endElement(); - - $xmlWriter->startElement('office:automatic-styles'); - $styles = Style::getStyles(); - $numPStyles = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - if (preg_match('#^T[0-9]+$#', $styleName) != 0 - || preg_match('#^P[0-9]+$#', $styleName) != 0 - ) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', $styleName); - $xmlWriter->writeAttribute('style:family', 'text'); - // style:text-properties - $xmlWriter->startElement('style:text-properties'); - $xmlWriter->writeAttribute('fo:color', '#' . $style->getColor()); - $xmlWriter->writeAttribute('style:font-name', $style->getName()); - $xmlWriter->writeAttribute('style:font-name-complex', $style->getName()); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - if ($style instanceof Paragraph) { - $numPStyles++; - // style:style - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', $styleName); - $xmlWriter->writeAttribute('style:family', 'paragraph'); - $xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); - $xmlWriter->writeAttribute('style:master-page-name', 'Standard'); - // style:paragraph-properties - $xmlWriter->startElement('style:paragraph-properties'); - $xmlWriter->writeAttribute('style:page-number', 'auto'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - } - - if ($numPStyles == 0) { - // style:style - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', 'P1'); - $xmlWriter->writeAttribute('style:family', 'paragraph'); - $xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); - $xmlWriter->writeAttribute('style:master-page-name', 'Standard'); - // style:paragraph-properties - $xmlWriter->startElement('style:paragraph-properties'); - $xmlWriter->writeAttribute('style:page-number', 'auto'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - $xmlWriter->endElement(); - - // office:body - $xmlWriter->startElement('office:body'); - // office:text - $xmlWriter->startElement('office:text'); - // text:sequence-decls - $xmlWriter->startElement('text:sequence-decls'); - // text:sequence-decl - $xmlWriter->startElement('text:sequence-decl'); - $xmlWriter->writeAttribute('text:display-outline-level', 0); - $xmlWriter->writeAttribute('text:name', 'Illustration'); - $xmlWriter->endElement(); - // text:sequence-decl - $xmlWriter->startElement('text:sequence-decl'); - $xmlWriter->writeAttribute('text:display-outline-level', 0); - $xmlWriter->writeAttribute('text:name', 'Table'); - $xmlWriter->endElement(); - // text:sequence-decl - $xmlWriter->startElement('text:sequence-decl'); - $xmlWriter->writeAttribute('text:display-outline-level', 0); - $xmlWriter->writeAttribute('text:name', 'Text'); - $xmlWriter->endElement(); - // text:sequence-decl - $xmlWriter->startElement('text:sequence-decl'); - $xmlWriter->writeAttribute('text:display-outline-level', 0); - $xmlWriter->writeAttribute('text:name', 'Drawing'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if ($countSections > 0) { - foreach ($_sections as $section) { - $pSection++; - - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter); - } elseif ($element instanceof Link) { - $this->writeUnsupportedElement($xmlWriter, 'Link'); - } elseif ($element instanceof Title) { - $this->writeUnsupportedElement($xmlWriter, 'Title'); - } elseif ($element instanceof PageBreak) { - $this->writeUnsupportedElement($xmlWriter, 'Page Break'); - } elseif ($element instanceof Table) { - $this->writeUnsupportedElement($xmlWriter, 'Table'); - } elseif ($element instanceof ListItem) { - $this->writeUnsupportedElement($xmlWriter, 'List Item'); - } elseif ($element instanceof Image || - $element instanceof MemoryImage) { - $this->writeUnsupportedElement($xmlWriter, 'Image'); - } elseif ($element instanceof Object) { - $this->writeUnsupportedElement($xmlWriter, 'Object'); - } elseif ($element instanceof TOC) { - $this->writeUnsupportedElement($xmlWriter, 'TOC'); - } else { - $this->writeUnsupportedElement($xmlWriter, 'Element'); - } - } - - if ($pSection == $countSections) { - $this->_writeEndSection($xmlWriter, $section); - } else { - $this->_writeSection($xmlWriter, $section); - } - } - } - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - /** - * Write text - * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\Text $text - * @param bool $withoutP - */ - protected function _writeText(XMLWriter $xmlWriter = null, Text $text, $withoutP = false) - { - $styleFont = $text->getFontStyle(); - $styleParagraph = $text->getParagraphStyle(); - - // @todo Commented for TextRun. Should really checkout this value - // $SfIsObject = ($styleFont instanceof Font) ? true : false; - $SfIsObject = false; - - if ($SfIsObject) { - // Don't never be the case, because I browse all sections for cleaning all styles not declared - die('PhpWord : $SfIsObject wouldn\'t be an object'); - } else { - if (!$withoutP) { - $xmlWriter->startElement('text:p'); // text:p - } - if (empty($styleFont)) { - if (empty($styleParagraph)) { - $xmlWriter->writeAttribute('text:style-name', 'P1'); - } else { - $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); - } - $xmlWriter->writeRaw($text->getText()); - } else { - if (empty($styleParagraph)) { - $xmlWriter->writeAttribute('text:style-name', 'Standard'); - } else { - $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); - } - // text:span - $xmlWriter->startElement('text:span'); - $xmlWriter->writeAttribute('text:style-name', $styleFont); - $xmlWriter->writeRaw($text->getText()); - $xmlWriter->endElement(); - } - if (!$withoutP) { - $xmlWriter->endElement(); // text:p - } - } - } - - /** - * Write TextRun section - * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\TextRun $textrun - * @todo Enable all other section types - */ - protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) - { - $elements = $textrun->getElements(); - $xmlWriter->startElement('text:p'); - if (count($elements) > 0) { - foreach ($elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element, true); - } - } - } - $xmlWriter->endElement(); - } - - /** - * Write TextBreak - */ - protected function _writeTextBreak(XMLWriter $xmlWriter = null) - { - $xmlWriter->startElement('text:p'); - $xmlWriter->writeAttribute('text:style-name', 'Standard'); - $xmlWriter->endElement(); - } - - // @codeCoverageIgnoreStart - private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null) - { - } - - private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null) - { - } - // @codeCoverageIgnoreEnd - - /** - * Write unsupported element - * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param string $element - */ - private function writeUnsupportedElement($xmlWriter, $element) - { - $xmlWriter->startElement('text:p'); - $xmlWriter->writeRaw($element); - $xmlWriter->endElement(); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Writer/ODText/Manifest.php b/Classes/PhpWord/Writer/ODText/Manifest.php deleted file mode 100644 index 1169249d8e..0000000000 --- a/Classes/PhpWord/Writer/ODText/Manifest.php +++ /dev/null @@ -1,132 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8'); - - // manifest:manifest - $xmlWriter->startElement('manifest:manifest'); - $xmlWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'); - $xmlWriter->writeAttribute('manifest:version', '1.2'); - - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text'); - $xmlWriter->writeAttribute('manifest:version', '1.2'); - $xmlWriter->writeAttribute('manifest:full-path', '/'); - $xmlWriter->endElement(); - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); - $xmlWriter->writeAttribute('manifest:full-path', 'content.xml'); - $xmlWriter->endElement(); - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); - $xmlWriter->writeAttribute('manifest:full-path', 'meta.xml'); - $xmlWriter->endElement(); - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); - $xmlWriter->writeAttribute('manifest:full-path', 'styles.xml'); - $xmlWriter->endElement(); - - // Not used yet. Legacy from PHPExcel - // @codeCoverageIgnoreStart - for ($i = 0; $i < $this->getParentWriter()->getDrawingHashTable()->count(); ++$i) { - if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) { - $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension()); - $mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath()); - - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', $mimeType); - $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); - $xmlWriter->endElement(); - } elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) { - $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType()); - $extension = explode('/', $extension); - $extension = $extension[1]; - - $mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType(); - - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', $mimeType); - $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); - $xmlWriter->endElement(); - } - } - // @codeCoverageIgnoreEnd - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - - /** - * Get image mime type - * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception - */ - private function _getImageMimeType($pFile = '') - { - if (File::file_exists($pFile)) { - $image = getimagesize($pFile); - return image_type_to_mime_type($image[2]); - } else { - throw new Exception("File $pFile does not exist"); - } - } -} diff --git a/Classes/PhpWord/Writer/ODText/Meta.php b/Classes/PhpWord/Writer/ODText/Meta.php deleted file mode 100644 index 135f2ff7ea..0000000000 --- a/Classes/PhpWord/Writer/ODText/Meta.php +++ /dev/null @@ -1,96 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8'); - - // office:document-meta - $xmlWriter->startElement('office:document-meta'); - $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); - $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); - $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); - $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); - $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); - $xmlWriter->writeAttribute('office:version', '1.2'); - - // office:meta - $xmlWriter->startElement('office:meta'); - - // dc:creator - $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getLastModifiedBy()); - // dc:date - $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getModified())); - // dc:description - $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); - // dc:subject - $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); - // dc:title - $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); - // meta:creation-date - $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getCreated())); - // meta:initial-creator - $xmlWriter->writeElement('meta:initial-creator', $phpWord->getDocumentProperties()->getCreator()); - // meta:keyword - $xmlWriter->writeElement('meta:keyword', $phpWord->getDocumentProperties()->getKeywords()); - - // @todo : Where these properties are written ? - // $phpWord->getDocumentProperties()->getCategory() - // $phpWord->getDocumentProperties()->getCompany() - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/ODText/Mimetype.php b/Classes/PhpWord/Writer/ODText/Mimetype.php deleted file mode 100644 index 570f1855d4..0000000000 --- a/Classes/PhpWord/Writer/ODText/Mimetype.php +++ /dev/null @@ -1,46 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8'); - - // Styles:Styles - $xmlWriter->startElement('office:document-styles'); - $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); - $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); - $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); - $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); - $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); - $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); - $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); - $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); - $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); - $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); - $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); - $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); - $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); - $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); - $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); - $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); - $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); - $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); - $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); - $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); - $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); - $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); - $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); - $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); - $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); - $xmlWriter->writeAttribute('office:version', '1.2'); - - - // office:font-face-decls - $xmlWriter->startElement('office:font-face-decls'); - $arrFonts = array(); - $styles = Style::getStyles(); - $numFonts = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - $numFonts++; - $name = $style->getName(); - if (!in_array($name, $arrFonts)) { - $arrFonts[] = $name; - - // style:font-face - $xmlWriter->startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', $name); - $xmlWriter->writeAttribute('svg:font-family', $name); - $xmlWriter->endElement(); - } - } - } - } - if (!in_array(PhpWord::DEFAULT_FONT_NAME, $arrFonts)) { - $xmlWriter->startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - - // office:styles - $xmlWriter->startElement('office:styles'); - - // style:default-style - $xmlWriter->startElement('style:default-style'); - $xmlWriter->writeAttribute('style:family', 'paragraph'); - - // style:paragraph-properties - $xmlWriter->startElement('style:paragraph-properties'); - $xmlWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit'); - $xmlWriter->writeAttribute('style:text-autospace', 'ideograph-alpha'); - $xmlWriter->writeAttribute('style:punctuation-wrap', 'hanging'); - $xmlWriter->writeAttribute('style:line-break', 'strict'); - $xmlWriter->writeAttribute('style:tab-stop-distance', '1.249cm'); - $xmlWriter->writeAttribute('style:writing-mode', 'page'); - $xmlWriter->endElement(); - - // style:text-properties - $xmlWriter->startElement('style:text-properties'); - $xmlWriter->writeAttribute('style:use-window-font-color', 'true'); - $xmlWriter->writeAttribute('style:font-name', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->writeAttribute('fo:font-size', PhpWord::DEFAULT_FONT_SIZE . 'pt'); - $xmlWriter->writeAttribute('fo:language', 'fr'); - $xmlWriter->writeAttribute('fo:country', 'FR'); - $xmlWriter->writeAttribute('style:letter-kerning', 'true'); - $xmlWriter->writeAttribute('style:font-name-asian', PhpWord::DEFAULT_FONT_NAME . '2'); - $xmlWriter->writeAttribute('style:font-size-asian', PhpWord::DEFAULT_FONT_SIZE . 'pt'); - $xmlWriter->writeAttribute('style:language-asian', 'zh'); - $xmlWriter->writeAttribute('style:country-asian', 'CN'); - $xmlWriter->writeAttribute('style:font-name-complex', PhpWord::DEFAULT_FONT_NAME . '2'); - $xmlWriter->writeAttribute('style:font-size-complex', PhpWord::DEFAULT_FONT_SIZE . 'pt'); - $xmlWriter->writeAttribute('style:language-complex', 'hi'); - $xmlWriter->writeAttribute('style:country-complex', 'IN'); - $xmlWriter->writeAttribute('fo:hyphenate', 'false'); - $xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2'); - $xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2'); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // Write Style Definitions - $styles = Style::getStyles(); - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - if (preg_match('#^T[0-9]+$#', $styleName) == 0 - && preg_match('#^P[0-9]+$#', $styleName) == 0 - ) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - // style:style - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', $styleName); - $xmlWriter->writeAttribute('style:family', 'text'); - - // style:text-properties - $xmlWriter->startElement('style:text-properties'); - $xmlWriter->writeAttribute('fo:font-size', ($style->getSize()) . 'pt'); - $xmlWriter->writeAttribute('style:font-size-asian', ($style->getSize()) . 'pt'); - $xmlWriter->writeAttribute('style:font-size-complex', ($style->getSize()) . 'pt'); - if ($style->getItalic()) { - $xmlWriter->writeAttribute('fo:font-style', 'italic'); - $xmlWriter->writeAttribute('style:font-style-asian', 'italic'); - $xmlWriter->writeAttribute('style:font-style-complex', 'italic'); - } - if ($style->getBold()) { - $xmlWriter->writeAttribute('fo:font-weight', 'bold'); - $xmlWriter->writeAttribute('style:font-weight-asian', 'bold'); - } - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } elseif ($style instanceof Paragraph) { - // PhpOffice\PhpWord\Style\Paragraph - // style:style - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', $styleName); - $xmlWriter->writeAttribute('style:family', 'paragraph'); - - //style:paragraph-properties - $xmlWriter->startElement('style:paragraph-properties'); - $xmlWriter->writeAttribute('fo:margin-top', ((is_null($style->getSpaceBefore())) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)) . 'cm'); - $xmlWriter->writeAttribute('fo:margin-bottom', ((is_null($style->getSpaceAfter())) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)) . 'cm'); - $xmlWriter->writeAttribute('fo:text-align', $style->getAlign()); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - } elseif ($style instanceof TableFull) { - // PhpOffice\PhpWord\Style\TableFull - } - } - } - } - $xmlWriter->endElement(); - - // office:automatic-styles - $xmlWriter->startElement('office:automatic-styles'); - // style:page-layout - $xmlWriter->startElement('style:page-layout'); - $xmlWriter->writeAttribute('style:name', 'Mpm1'); - // style:page-layout-properties - $xmlWriter->startElement('style:page-layout-properties'); - $xmlWriter->writeAttribute('fo:page-width', "21.001cm"); - $xmlWriter->writeAttribute('fo:page-height', '29.7cm'); - $xmlWriter->writeAttribute('style:num-format', '1'); - $xmlWriter->writeAttribute('style:print-orientation', 'portrait'); - $xmlWriter->writeAttribute('fo:margin-top', '2.501cm'); - $xmlWriter->writeAttribute('fo:margin-bottom', '2cm'); - $xmlWriter->writeAttribute('fo:margin-left', '2.501cm'); - $xmlWriter->writeAttribute('fo:margin-right', '2.501cm'); - $xmlWriter->writeAttribute('style:writing-mode', 'lr-tb'); - $xmlWriter->writeAttribute('style:layout-grid-color', '#c0c0c0'); - $xmlWriter->writeAttribute('style:layout-grid-lines', '25199'); - $xmlWriter->writeAttribute('style:layout-grid-base-height', '0.423cm'); - $xmlWriter->writeAttribute('style:layout-grid-ruby-height', '0cm'); - $xmlWriter->writeAttribute('style:layout-grid-mode', 'none'); - $xmlWriter->writeAttribute('style:layout-grid-ruby-below', 'false'); - $xmlWriter->writeAttribute('style:layout-grid-print', 'false'); - $xmlWriter->writeAttribute('style:layout-grid-display', 'false'); - $xmlWriter->writeAttribute('style:layout-grid-base-width', '0.37cm'); - $xmlWriter->writeAttribute('style:layout-grid-snap-to', 'true'); - $xmlWriter->writeAttribute('style:footnote-max-height', '0cm'); - //style:footnote-sep - $xmlWriter->startElement('style:footnote-sep'); - $xmlWriter->writeAttribute('style:width', '0.018cm'); - $xmlWriter->writeAttribute('style:line-style', 'solid'); - $xmlWriter->writeAttribute('style:adjustment', 'left'); - $xmlWriter->writeAttribute('style:rel-width', '25%'); - $xmlWriter->writeAttribute('style:color', '#000000'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - // style:header-style - $xmlWriter->startElement('style:header-style'); - $xmlWriter->endElement(); - // style:footer-style - $xmlWriter->startElement('style:footer-style'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - // office:master-styles - $xmlWriter->startElement('office:master-styles'); - // style:master-page - $xmlWriter->startElement('style:master-page'); - $xmlWriter->writeAttribute('style:name', 'Standard'); - $xmlWriter->writeAttribute('style:page-layout-name', 'Mpm1'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/ODText/WriterPart.php b/Classes/PhpWord/Writer/ODText/WriterPart.php deleted file mode 100644 index 06e4a404cc..0000000000 --- a/Classes/PhpWord/Writer/ODText/WriterPart.php +++ /dev/null @@ -1,66 +0,0 @@ -_parentWriter = $pWriter; - } - - /** - * Get parent IWriter object - * - * @return PhpOffice\PhpWord\Writer\IWriter - * @throws Exception - */ - public function getParentWriter() - { - if (!is_null($this->_parentWriter)) { - return $this->_parentWriter; - } else { - throw new Exception("No parent IWriter assigned."); - } - } -} diff --git a/Classes/PhpWord/Writer/RTF.php b/Classes/PhpWord/Writer/RTF.php deleted file mode 100644 index c4dabe96f0..0000000000 --- a/Classes/PhpWord/Writer/RTF.php +++ /dev/null @@ -1,482 +0,0 @@ -setPhpWord($phpWord); - - // Set HashTable variables - $this->_drawingHashTable = new HashTable(); - } - - /** - * Save PhpWord to file - * - * @param string $pFileName - * @throws \Exception - */ - public function save($pFilename = null) - { - if (!is_null($this->_document)) { - // If $pFilename is php://output or php://stdout, make it a temporary file... - $originalFilename = $pFilename; - if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { - $pFilename = @tempnam('./', 'phppttmp'); - if ($pFilename == '') { - $pFilename = $originalFilename; - } - } - - $hFile = fopen($pFilename, 'w') or die("can't open file"); - fwrite($hFile, $this->getData()); - fclose($hFile); - - // If a temporary file was used, copy it to the correct file stream - if ($originalFilename != $pFilename) { - if (copy($pFilename, $originalFilename) === false) { - throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename."); - } - @unlink($pFilename); - } - - } else { - throw new \Exception("PhpWord object unassigned."); - } - } - - /** - * @return PhpOffice\PhpWord - * @throws \Exception - */ - public function getPhpWord() - { - if (!is_null($this->_document)) { - return $this->_document; - } else { - throw new \Exception("No PhpWord assigned."); - } - } - - /** - * @param PhpOffice\PhpWord $phpWord - * @throws \Exception - * @return PhpOffice\PhpWord\Writer\RTF - */ - public function setPhpWord(PhpWord $phpWord = null) - { - $this->_document = $phpWord; - return $this; - } - - /** - * Get PHPWord_Worksheet_BaseDrawing HashTable - * - * @return PhpOffice\PhpWord\HashTable - */ - public function getDrawingHashTable() - { - return $this->_drawingHashTable; - } - - private function getData() - { - // PhpWord object : $this->_document - $this->_fontTable = $this->getDataFont(); - $this->_colorTable = $this->getDataColor(); - - $sRTFContent = '{\rtf1'; - // Set the default character set - $sRTFContent .= '\ansi\ansicpg1252'; - // Set the default font (the first one) - $sRTFContent .= '\deff0'; - // Set the default tab size (720 twips) - $sRTFContent .= '\deftab720'; - $sRTFContent .= PHP_EOL; - // Set the font tbl group - $sRTFContent .= '{\fonttbl'; - foreach ($this->_fontTable as $idx => $font) { - $sRTFContent .= '{\f' . $idx . '\fnil\fcharset0 ' . $font . ';}'; - } - $sRTFContent .= '}' . PHP_EOL; - // Set the color tbl group - $sRTFContent .= '{\colortbl '; - foreach ($this->_colorTable as $idx => $color) { - $arrColor = Drawing::htmlToRGB($color); - $sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; - } - $sRTFContent .= ';}' . PHP_EOL; - // Set the generator - $sRTFContent .= '{\*\generator PhpWord;}' . PHP_EOL; - // Set the view mode of the document - $sRTFContent .= '\viewkind4'; - // Set the numberof bytes that follows a unicode character - $sRTFContent .= '\uc1'; - // Resets to default paragraph properties. - $sRTFContent .= '\pard'; - // No widow/orphan control - $sRTFContent .= '\nowidctlpar'; - // Applies a language to a text run (1036 : French (France)) - $sRTFContent .= '\lang1036'; - // Point size (in half-points) above which to kern character pairs - $sRTFContent .= '\kerning1'; - // Set the font size in half-points - $sRTFContent .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); - $sRTFContent .= PHP_EOL; - // Body - $sRTFContent .= $this->getDataContent(); - - - $sRTFContent .= '}'; - - return $sRTFContent; - } - - private function getDataFont() - { - $phpWord = $this->_document; - - $arrFonts = array(); - // Default font : PhpWord::DEFAULT_FONT_NAME - $arrFonts[] = PhpWord::DEFAULT_FONT_NAME; - // PhpWord object : $this->_document - - // Browse styles - $styles = Style::getStyles(); - $numPStyles = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - if (in_array($style->getName(), $arrFonts) == false) { - $arrFonts[] = $style->getName(); - } - } - } - } - - // Search all fonts used - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - if ($countSections > 0) { - $pSection = 0; - - foreach ($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $fStyle = $element->getFontStyle(); - - if ($fStyle instanceof Font) { - if (in_array($fStyle->getName(), $arrFonts) == false) { - $arrFonts[] = $fStyle->getName(); - } - } - } - } - } - } - - return $arrFonts; - } - - private function getDataColor() - { - $phpWord = $this->_document; - - $arrColors = array(); - // PhpWord object : $this->_document - - // Browse styles - $styles = Style::getStyles(); - $numPStyles = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - // Font - if ($style instanceof Font) { - $color = $style->getColor(); - $fgcolor = $style->getFgColor(); - if (in_array($color, $arrColors) == false && $color != PhpWord::DEFAULT_FONT_COLOR && !empty($color)) { - $arrColors[] = $color; - } - if (in_array($fgcolor, $arrColors) == false && $fgcolor != PhpWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) { - $arrColors[] = $fgcolor; - } - } - } - } - - // Search all fonts used - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - if ($countSections > 0) { - $pSection = 0; - - foreach ($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $fStyle = $element->getFontStyle(); - - if ($fStyle instanceof Font) { - if (in_array($fStyle->getColor(), $arrColors) == false) { - $arrColors[] = $fStyle->getColor(); - } - if (in_array($fStyle->getFgColor(), $arrColors) == false) { - $arrColors[] = $fStyle->getFgColor(); - } - } - } - } - } - } - - return $arrColors; - } - - private function getDataContent() - { - $phpWord = $this->_document; - $sRTFBody = ''; - - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if ($countSections > 0) { - foreach ($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - foreach ($_elements as $element) { - if ($element instanceof Text) { - $sRTFBody .= $this->getDataContentText($element); - } elseif ($element instanceof TextBreak) { - $sRTFBody .= $this->getDataContentTextBreak(); - } elseif ($element instanceof TextRun) { - $sRTFBody .= $this->getDataContentTextRun($element); - } elseif ($element instanceof Link) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Link'); - } elseif ($element instanceof Title) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Title'); - } elseif ($element instanceof PageBreak) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Page Break'); - } elseif ($element instanceof Table) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Table'); - } elseif ($element instanceof ListItem) { - $sRTFBody .= $this->getDataContentUnsupportedElement('List Item'); - } elseif ($element instanceof Image || - $element instanceof MemoryImage) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Image'); - } elseif ($element instanceof Object) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Object'); - } elseif ($element instanceof TOC) { - $sRTFBody .= $this->getDataContentUnsupportedElement('TOC'); - } else { - $sRTFBody .= $this->getDataContentUnsupportedElement('Other'); - } - } - } - } - return $sRTFBody; - } - - private function getDataContentText(Text $text, $withoutP = false) - { - $sRTFText = ''; - - $styleFont = $text->getFontStyle(); - $SfIsObject = ($styleFont instanceof Font) ? true : false; - if (!$SfIsObject) { - $styleFont = Style::getStyle($styleFont); - } - - $styleParagraph = $text->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - if (!$SpIsObject) { - $styleParagraph = Style::getStyle($styleParagraph); - } - - if ($styleParagraph && !$withoutP) { - if ($this->_lastParagraphStyle != $text->getParagraphStyle()) { - $sRTFText .= '\pard\nowidctlpar'; - if ($styleParagraph->getSpaceAfter() != null) { - $sRTFText .= '\sa' . $styleParagraph->getSpaceAfter(); - } - if ($styleParagraph->getAlign() != null) { - if ($styleParagraph->getAlign() == 'center') { - $sRTFText .= '\qc'; - } - } - $this->_lastParagraphStyle = $text->getParagraphStyle(); - } else { - $this->_lastParagraphStyle = ''; - } - } else { - $this->_lastParagraphStyle = ''; - } - - if ($styleFont instanceof Font) { - if ($styleFont->getColor() != null) { - $idxColor = array_search($styleFont->getColor(), $this->_colorTable); - if ($idxColor !== false) { - $sRTFText .= '\cf' . ($idxColor + 1); - } - } else { - $sRTFText .= '\cf0'; - } - if ($styleFont->getName() != null) { - $idxFont = array_search($styleFont->getName(), $this->_fontTable); - if ($idxFont !== false) { - $sRTFText .= '\f' . $idxFont; - } - } else { - $sRTFText .= '\f0'; - } - if ($styleFont->getBold()) { - $sRTFText .= '\b'; - } - if ($styleFont->getBold()) { - $sRTFText .= '\i'; - } - if ($styleFont->getSize()) { - $sRTFText .= '\fs' . ($styleFont->getSize() * 2); - } - } - if ($this->_lastParagraphStyle != '' || $styleFont) { - $sRTFText .= ' '; - } - $sRTFText .= $text->getText(); - - if ($styleFont instanceof Font) { - $sRTFText .= '\cf0'; - $sRTFText .= '\f0'; - - if ($styleFont->getBold()) { - $sRTFText .= '\b0'; - } - if ($styleFont->getItalic()) { - $sRTFText .= '\i0'; - } - if ($styleFont->getSize()) { - $sRTFText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); - } - } - - if (!$withoutP) { - $sRTFText .= '\par' . PHP_EOL; - } - return $sRTFText; - } - - private function getDataContentTextRun(TextRun $textrun) - { - $sRTFText = ''; - $elements = $textrun->getElements(); - if (count($elements) > 0) { - $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; - foreach ($elements as $element) { - if ($element instanceof Text) { - $sRTFText .= '{'; - $sRTFText .= $this->getDataContentText($element, true); - $sRTFText .= '}' . PHP_EOL; - } - } - $sRTFText .= '\par' . PHP_EOL; - } - return $sRTFText; - } - - private function getDataContentTextBreak() - { - $this->_lastParagraphStyle = ''; - - return '\par' . PHP_EOL; - } - - /** - * Write unsupported element - * - * @param string $element - */ - private function getDataContentUnsupportedElement($element) - { - $sRTFText = ''; - $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; - $sRTFText .= "{$element}"; - $sRTFText .= '\par' . PHP_EOL; - - return $sRTFText; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Writer/Word2007.php b/Classes/PhpWord/Writer/Word2007.php deleted file mode 100644 index 7e356d973e..0000000000 --- a/Classes/PhpWord/Writer/Word2007.php +++ /dev/null @@ -1,301 +0,0 @@ -_document = $phpWord; - - $this->_diskCachingDirectory = './'; - - $this->_writerParts['contenttypes'] = new ContentTypes(); - $this->_writerParts['rels'] = new Rels(); - $this->_writerParts['docprops'] = new DocProps(); - $this->_writerParts['documentrels'] = new DocumentRels(); - $this->_writerParts['document'] = new Document(); - $this->_writerParts['styles'] = new Styles(); - $this->_writerParts['header'] = new Header(); - $this->_writerParts['footer'] = new Footer(); - $this->_writerParts['footnotes'] = new Footnotes(); - $this->_writerParts['footnotesrels'] = new FootnotesRels(); - - foreach ($this->_writerParts as $writer) { - $writer->setParentWriter($this); - } - } - - public function save($pFilename = null) - { - if (!is_null($this->_document)) { - - // If $pFilename is php://output or php://stdout, make it a temporary file... - $originalFilename = $pFilename; - if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { - $pFilename = @tempnam('./', 'phppttmp'); - if ($pFilename == '') { - $pFilename = $originalFilename; - } - } - - // Create new ZIP file and open it for writing - $objZip = new ZipArchive(); - - // Try opening the ZIP file - if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { - if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { - throw new Exception("Could not open " . $pFilename . " for writing."); - } - } - - - $sectionElements = array(); - $_secElements = Media::getSectionMediaElements(); - foreach ($_secElements as $element) { // loop through section media elements - if ($element['type'] != 'hyperlink') { - $this->_addFileToPackage($objZip, $element); - } - $sectionElements[] = $element; - } - - $_hdrElements = Media::getHeaderMediaElements(); - foreach ($_hdrElements as $_headerFile => $_hdrMedia) { // loop through headers - if (count($_hdrMedia) > 0) { - $objZip->addFromString('word/_rels/' . $_headerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_hdrMedia)); - foreach ($_hdrMedia as $element) { // loop through header media elements - $this->_addFileToPackage($objZip, $element); - } - } - } - - $_ftrElements = Media::getFooterMediaElements(); - foreach ($_ftrElements as $_footerFile => $_ftrMedia) { // loop through footers - if (count($_ftrMedia) > 0) { - $objZip->addFromString('word/_rels/' . $_footerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_ftrMedia)); - foreach ($_ftrMedia as $element) { // loop through footers media elements - $this->_addFileToPackage($objZip, $element); - } - } - } - - $footnoteLinks = array(); - $_footnoteElements = Footnote::getFootnoteLinkElements(); - // loop through footnote link elements - foreach ($_footnoteElements as $element) { - $footnoteLinks[] = $element; - } - - $_cHdrs = 0; - $_cFtrs = 0; - $rID = Media::countSectionMediaElements() + 6; - $_sections = $this->_document->getSections(); - - $footers = array(); - foreach ($_sections as $section) { - $_headers = $section->getHeaders(); - foreach ($_headers as $index => &$_header) { - $_cHdrs++; - $_header->setRelationId(++$rID); - $_headerFile = 'header' . $_cHdrs . '.xml'; - $sectionElements[] = array('target' => $_headerFile, 'type' => 'header', 'rID' => $rID); - $objZip->addFromString('word/' . $_headerFile, $this->getWriterPart('header')->writeHeader($_header)); - } - - $_footer = $section->getFooter(); - $footers[++$_cFtrs] = $_footer; - if (!is_null($_footer)) { - $_footer->setRelationId(++$rID); - $_footerCount = $_footer->getFooterCount(); - $_footerFile = 'footer' . $_footerCount . '.xml'; - $sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID); - $objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer)); - } - } - - if (Footnote::countFootnoteElements() > 0) { - $_allFootnotesCollection = Footnote::getFootnoteElements(); - $_footnoteFile = 'footnotes.xml'; - $sectionElements[] = array('target'=>$_footnoteFile, 'type'=>'footnotes', 'rID'=>++$rID); - $objZip->addFromString('word/'.$_footnoteFile, $this->getWriterPart('footnotes')->writeFootnotes($_allFootnotesCollection)); - if (count($footnoteLinks) > 0) { - $objZip->addFromString('word/_rels/footnotes.xml.rels', $this->getWriterPart('footnotesrels')->writeFootnotesRels($footnoteLinks)); - } - } - - // build docx file - // Write dynamic files - $objZip->addFromString( - '[Content_Types].xml', - $this->getWriterPart('contenttypes')->writeContentTypes( - $this->_imageTypes, - $this->_objectTypes, - $_cHdrs, - $footers - ) - ); - $objZip->addFromString('_rels/.rels', $this->getWriterPart('rels')->writeRelationships($this->_document)); - $objZip->addFromString('docProps/app.xml', $this->getWriterPart('docprops')->writeDocPropsApp($this->_document)); - $objZip->addFromString('docProps/core.xml', $this->getWriterPart('docprops')->writeDocPropsCore($this->_document)); - $objZip->addFromString('word/document.xml', $this->getWriterPart('document')->writeDocument($this->_document)); - $objZip->addFromString('word/_rels/document.xml.rels', $this->getWriterPart('documentrels')->writeDocumentRels($sectionElements)); - $objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document)); - - // Write static files - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/numbering.xml', 'word/numbering.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/settings.xml', 'word/settings.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml'); - - - // Close file - if ($objZip->close() === false) { - throw new Exception("Could not close zip file $pFilename."); - } - - // If a temporary file was used, copy it to the correct file stream - if ($originalFilename != $pFilename) { - if (copy($pFilename, $originalFilename) === false) { - throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename."); - } - @unlink($pFilename); - } - } else { - throw new Exception("PhpWord object unassigned."); - } - } - - /** - * @param string $src - */ - private function checkContentTypes($src) - { - $extension = null; - if (stripos(strrev($src), strrev('.php')) === 0) { - $extension = 'php'; - } else { - $imageType = exif_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'; - } - } - - if (isset($extension)) { - $imageData = getimagesize($src); - $imageType = image_type_to_mime_type($imageData[2]); - $imageExtension = str_replace('.', '', image_type_to_extension($imageData[2])); - if ($imageExtension === 'jpeg') { - $imageExtension = 'jpg'; - } - if (!in_array($imageType, $this->_imageTypes)) { - $this->_imageTypes[$imageExtension] = $imageType; - } - } else { - if (!in_array($extension, $this->_objectTypes)) { - $this->_objectTypes[] = $extension; - } - } - } - - public function getWriterPart($pPartName = '') - { - if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { - return $this->_writerParts[strtolower($pPartName)]; - } else { - return null; - } - } - - public function getUseDiskCaching() - { - return $this->_useDiskCaching; - } - - public function setUseDiskCaching($pValue = false, $pDirectory = null) - { - $this->_useDiskCaching = $pValue; - - if (!is_null($pDirectory)) { - if (is_dir($pDirectory)) { - $this->_diskCachingDirectory = $pDirectory; - } else { - throw new Exception("Directory does not exist: $pDirectory"); - } - } - - return $this; - } - - private function _addFileToPackage($objZip, $element) - { - if (isset($element['isMemImage']) && $element['isMemImage']) { - $image = call_user_func($element['createfunction'], $element['source']); - ob_start(); - call_user_func($element['imagefunction'], $image); - $imageContents = ob_get_contents(); - ob_end_clean(); - $objZip->addFromString('word/' . $element['target'], $imageContents); - imagedestroy($image); - - $this->checkContentTypes($element['source']); - } else { - $objZip->addFile($element['source'], 'word/' . $element['target']); - $this->checkContentTypes($element['source']); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Base.php b/Classes/PhpWord/Writer/Word2007/Base.php deleted file mode 100644 index 902e8e49bb..0000000000 --- a/Classes/PhpWord/Writer/Word2007/Base.php +++ /dev/null @@ -1,1003 +0,0 @@ -getFontStyle(); - - $SfIsObject = ($styleFont instanceof Font) ? true : false; - - if (!$withoutP) { - $xmlWriter->startElement('w:p'); - - $styleParagraph = $text->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - $strText = htmlspecialchars($text->getText()); - $strText = String::ControlCharacterPHP2OOXML($strText); - - $xmlWriter->startElement('w:r'); - - if ($SfIsObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } elseif (!$SfIsObject && !is_null($styleFont)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:t'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text - $xmlWriter->writeRaw($strText); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); // w:r - - if (!$withoutP) { - $xmlWriter->endElement(); // w:p - } - } - - protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) - { - $elements = $textrun->getElements(); - $styleParagraph = $textrun->getParagraphStyle(); - - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - $xmlWriter->startElement('w:p'); - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - if (count($elements) > 0) { - foreach ($elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element, true); - } elseif ($element instanceof Link) { - $this->_writeLink($xmlWriter, $element, true); - } elseif ($element instanceof Image) { - $this->_writeImage($xmlWriter, $element, true); - } elseif ($element instanceof Footnote) { - $this->_writeFootnoteReference($xmlWriter, $element, true); - } elseif ($element instanceof TextBreak) { - $xmlWriter->writeElement('w:br'); - } - } - } - - $xmlWriter->endElement(); - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Style\Paragraph $style - * @param bool $withoutPPR - * @return void - */ - protected function _writeParagraphStyle( - XMLWriter $xmlWriter = null, - Paragraph $style, - $withoutPPR = false - ) { - - $align = $style->getAlign(); - $spacing = $style->getSpacing(); - $spaceBefore = $style->getSpaceBefore(); - $spaceAfter = $style->getSpaceAfter(); - $indent = $style->getIndent(); - $hanging = $style->getHanging(); - $tabs = $style->getTabs(); - $widowControl = $style->getWidowControl(); - $keepNext = $style->getKeepNext(); - $keepLines = $style->getKeepLines(); - $pageBreakBefore = $style->getPageBreakBefore(); - - if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || - !is_null($spaceAfter) || !is_null($indent) || !is_null($hanging) || - !is_null($tabs) || !is_null($widowControl) || !is_null($keepNext) || - !is_null($keepLines) || !is_null($pageBreakBefore)) { - if (!$withoutPPR) { - $xmlWriter->startElement('w:pPr'); - } - - // Alignment - if (!is_null($align)) { - $xmlWriter->startElement('w:jc'); - $xmlWriter->writeAttribute('w:val', $align); - $xmlWriter->endElement(); - } - - // Indentation - if (!is_null($indent) || !is_null($hanging)) { - $xmlWriter->startElement('w:ind'); - $xmlWriter->writeAttribute('w:firstLine', 0); - if (!is_null($indent)) { - $xmlWriter->writeAttribute('w:left', $indent); - } - if (!is_null($hanging)) { - $xmlWriter->writeAttribute('w:hanging', $hanging); - } - $xmlWriter->endElement(); - } - - // Spacing - if (!is_null($spaceBefore) || !is_null($spaceAfter) || - !is_null($spacing)) { - $xmlWriter->startElement('w:spacing'); - if (!is_null($spaceBefore)) { - $xmlWriter->writeAttribute('w:before', $spaceBefore); - } - if (!is_null($spaceAfter)) { - $xmlWriter->writeAttribute('w:after', $spaceAfter); - } - if (!is_null($spacing)) { - $xmlWriter->writeAttribute('w:line', $spacing); - $xmlWriter->writeAttribute('w:lineRule', 'auto'); - } - $xmlWriter->endElement(); - } - - // Pagination - if (!$widowControl) { - $xmlWriter->startElement('w:widowControl'); - $xmlWriter->writeAttribute('w:val', '0'); - $xmlWriter->endElement(); - } - if ($keepNext) { - $xmlWriter->startElement('w:keepNext'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - if ($keepLines) { - $xmlWriter->startElement('w:keepLines'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - if ($pageBreakBefore) { - $xmlWriter->startElement('w:pageBreakBefore'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - - // Tabs - if (!is_null($tabs)) { - $tabs->toXml($xmlWriter); - } - - if (!$withoutPPR) { - $xmlWriter->endElement(); // w:pPr - } - } - } - - protected function _writeLink(XMLWriter $xmlWriter = null, Link $link, $withoutP = false) - { - $rID = $link->getRelationId(); - $linkName = $link->getLinkName(); - if (is_null($linkName)) { - $linkName = $link->getLinkSrc(); - } - - $styleFont = $link->getFontStyle(); - $SfIsObject = ($styleFont instanceof Font) ? true : false; - - if (!$withoutP) { - $xmlWriter->startElement('w:p'); - - $styleParagraph = $link->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - $xmlWriter->startElement('w:hyperlink'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rID); - $xmlWriter->writeAttribute('w:history', '1'); - - $xmlWriter->startElement('w:r'); - if ($SfIsObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } elseif (!$SfIsObject && !is_null($styleFont)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:t'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text - $xmlWriter->writeRaw($linkName); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - if (!$withoutP) { - $xmlWriter->endElement(); // w:p - } - } - - protected function _writePreserveText(XMLWriter $xmlWriter = null, PreserveText $textrun) - { - $styleFont = $textrun->getFontStyle(); - $styleParagraph = $textrun->getParagraphStyle(); - - $SfIsObject = ($styleFont instanceof Font) ? true : false; - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - $arrText = $textrun->getText(); - if (!is_array($arrText)) { - $arrText = array($arrText); - } - - $xmlWriter->startElement('w:p'); - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - foreach ($arrText as $text) { - - if (substr($text, 0, 1) == '{') { - $text = substr($text, 1, -1); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - - if ($SfIsObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } elseif (!$SfIsObject && !is_null($styleFont)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:instrText'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw($text); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'separate'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'end'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } else { - $text = htmlspecialchars($text); - $text = String::ControlCharacterPHP2OOXML($text); - - $xmlWriter->startElement('w:r'); - - if ($SfIsObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } elseif (!$SfIsObject && !is_null($styleFont)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:t'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw($text); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - $xmlWriter->endElement(); // p - } - - protected function _writeTextStyle(XMLWriter $xmlWriter = null, Font $style) - { - $font = $style->getName(); - $bold = $style->getBold(); - $italic = $style->getItalic(); - $color = $style->getColor(); - $size = $style->getSize(); - $fgColor = $style->getFgColor(); - $strikethrough = $style->getStrikethrough(); - $underline = $style->getUnderline(); - $superscript = $style->getSuperScript(); - $subscript = $style->getSubScript(); - $hint = $style->getHint(); - - $xmlWriter->startElement('w:rPr'); - - // Font - if ($font != PhpWord::DEFAULT_FONT_NAME) { - $xmlWriter->startElement('w:rFonts'); - $xmlWriter->writeAttribute('w:ascii', $font); - $xmlWriter->writeAttribute('w:hAnsi', $font); - $xmlWriter->writeAttribute('w:eastAsia', $font); - $xmlWriter->writeAttribute('w:cs', $font); - //Font Content Type - if ($hint != PhpWord::DEFAULT_FONT_CONTENT_TYPE) { - $xmlWriter->writeAttribute('w:hint', $hint); - } - $xmlWriter->endElement(); - } - - - // Color - if ($color != PhpWord::DEFAULT_FONT_COLOR) { - $xmlWriter->startElement('w:color'); - $xmlWriter->writeAttribute('w:val', $color); - $xmlWriter->endElement(); - } - - // Size - if ($size != PhpWord::DEFAULT_FONT_SIZE) { - $xmlWriter->startElement('w:sz'); - $xmlWriter->writeAttribute('w:val', $size * 2); - $xmlWriter->endElement(); - $xmlWriter->startElement('w:szCs'); - $xmlWriter->writeAttribute('w:val', $size * 2); - $xmlWriter->endElement(); - } - - // Bold - if ($bold) { - $xmlWriter->writeElement('w:b', null); - } - - // Italic - if ($italic) { - $xmlWriter->writeElement('w:i', null); - $xmlWriter->writeElement('w:iCs', null); - } - - // Underline - if (!is_null($underline) && $underline != 'none') { - $xmlWriter->startElement('w:u'); - $xmlWriter->writeAttribute('w:val', $underline); - $xmlWriter->endElement(); - } - - // Strikethrough - if ($strikethrough) { - $xmlWriter->writeElement('w:strike', null); - } - - // Foreground-Color - if (!is_null($fgColor)) { - $xmlWriter->startElement('w:highlight'); - $xmlWriter->writeAttribute('w:val', $fgColor); - $xmlWriter->endElement(); - } - - // Superscript/subscript - if ($superscript || $subscript) { - $xmlWriter->startElement('w:vertAlign'); - $xmlWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript'); - $xmlWriter->endElement(); - } - - $xmlWriter->endElement(); - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\TextBreak $element - */ - protected function _writeTextBreak($xmlWriter, $element = null) - { - $hasStyle = false; - if (!is_null($element)) { - $fontStyle = $element->getFontStyle(); - $sfIsObject = ($fontStyle instanceof Font) ? true : false; - $paragraphStyle = $element->getParagraphStyle(); - $spIsObject = ($paragraphStyle instanceof Paragraph) ? true : false; - $hasStyle = !is_null($fontStyle) || !is_null($paragraphStyle); - } - if ($hasStyle) { - // Paragraph style - $xmlWriter->startElement('w:p'); - if ($spIsObject) { - $this->_writeParagraphStyle($xmlWriter, $paragraphStyle); - } elseif (!$spIsObject && !is_null($paragraphStyle)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $paragraphStyle); - $xmlWriter->endElement(); // w:pStyle - $xmlWriter->endElement(); // w:pPr - } - // Font style - if (!is_null($fontStyle)) { - $xmlWriter->startElement('w:pPr'); - if ($sfIsObject) { - $this->_writeTextStyle($xmlWriter, $fontStyle); - } elseif (!$sfIsObject && !is_null($fontStyle)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $fontStyle); - $xmlWriter->endElement(); // w:rStyle - $xmlWriter->endElement(); // w:rPr - } - $xmlWriter->endElement(); // w:pPr - } - $xmlWriter->endElement(); // w:p - } else { - // Null element. No paragraph nor font style - $xmlWriter->writeElement('w:p', null); - } - } - - protected function _writeTable(XMLWriter $xmlWriter = null, Table $table) - { - $_rows = $table->getRows(); - $_cRows = count($_rows); - - if ($_cRows > 0) { - $xmlWriter->startElement('w:tbl'); - $tblStyle = $table->getStyle(); - $tblWidth = $table->getWidth(); - if ($tblStyle instanceof PhpOffice\PhpWord\Style\Table) { - $this->_writeTableStyle($xmlWriter, $tblStyle); - } else { - if (!empty($tblStyle)) { - $xmlWriter->startElement('w:tblPr'); - $xmlWriter->startElement('w:tblStyle'); - $xmlWriter->writeAttribute('w:val', $tblStyle); - $xmlWriter->endElement(); - if (!is_null($tblWidth)) { - $xmlWriter->startElement('w:tblW'); - $xmlWriter->writeAttribute('w:w', $tblWidth); - $xmlWriter->writeAttribute('w:type', 'pct'); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - } - - for ($i = 0; $i < $_cRows; $i++) { - $row = $_rows[$i]; - $height = $row->getHeight(); - $rowStyle = $row->getStyle(); - $tblHeader = $rowStyle->getTblHeader(); - $cantSplit = $rowStyle->getCantSplit(); - - $xmlWriter->startElement('w:tr'); - - if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) { - $xmlWriter->startElement('w:trPr'); - if (!is_null($height)) { - $xmlWriter->startElement('w:trHeight'); - $xmlWriter->writeAttribute('w:val', $height); - $xmlWriter->endElement(); - } - if ($tblHeader) { - $xmlWriter->startElement('w:tblHeader'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - if ($cantSplit) { - $xmlWriter->startElement('w:cantSplit'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - - foreach ($row->getCells() as $cell) { - $xmlWriter->startElement('w:tc'); - - $cellStyle = $cell->getStyle(); - $width = $cell->getWidth(); - - $xmlWriter->startElement('w:tcPr'); - $xmlWriter->startElement('w:tcW'); - $xmlWriter->writeAttribute('w:w', $width); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - - if ($cellStyle instanceof Cell) { - $this->_writeCellStyle($xmlWriter, $cellStyle); - } - - $xmlWriter->endElement(); - - $_elements = $cell->getElements(); - if (count($_elements) > 0) { - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof Link) { - $this->_writeLink($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter, $element); - } elseif ($element instanceof ListItem) { - $this->_writeListItem($xmlWriter, $element); - } elseif ($element instanceof Image || - $element instanceof MemoryImage - ) { - $this->_writeImage($xmlWriter, $element); - } elseif ($element instanceof Object) { - $this->_writeObject($xmlWriter, $element); - } elseif ($element instanceof PreserveText) { - $this->_writePreserveText($xmlWriter, $element); - } - } - } else { - $this->_writeTextBreak($xmlWriter); - } - - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - } - - protected function _writeTableStyle( - XMLWriter $xmlWriter = null, - PhpOffice\PhpWord\Style\Table $style = null - ) { - $margins = $style->getCellMargin(); - $mTop = (!is_null($margins[0])) ? true : false; - $mLeft = (!is_null($margins[1])) ? true : false; - $mRight = (!is_null($margins[2])) ? true : false; - $mBottom = (!is_null($margins[3])) ? true : false; - - if ($mTop || $mLeft || $mRight || $mBottom) { - $xmlWriter->startElement('w:tblPr'); - $xmlWriter->startElement('w:tblCellMar'); - - if ($mTop) { - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:w', $margins[0]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - - if ($mLeft) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:w', $margins[1]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - - if ($mRight) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:w', $margins[2]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - - if ($mBottom) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:w', $margins[3]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - protected function _writeCellStyle(XMLWriter $xmlWriter = null, Cell $style = null) - { - $bgColor = $style->getBgColor(); - $valign = $style->getVAlign(); - $textDir = $style->getTextDirection(); - $brdSz = $style->getBorderSize(); - $brdCol = $style->getBorderColor(); - - $bTop = (!is_null($brdSz[0])) ? true : false; - $bLeft = (!is_null($brdSz[1])) ? true : false; - $bRight = (!is_null($brdSz[2])) ? true : false; - $bBottom = (!is_null($brdSz[3])) ? true : false; - $borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false; - - $styles = (!is_null($bgColor) || !is_null($valign) || !is_null($textDir) || $borders) ? true : false; - - if ($styles) { - if (!is_null($textDir)) { - $xmlWriter->startElement('w:textDirection'); - $xmlWriter->writeAttribute('w:val', $textDir); - $xmlWriter->endElement(); - } - - if (!is_null($bgColor)) { - $xmlWriter->startElement('w:shd'); - $xmlWriter->writeAttribute('w:val', 'clear'); - $xmlWriter->writeAttribute('w:color', 'auto'); - $xmlWriter->writeAttribute('w:fill', $bgColor); - $xmlWriter->endElement(); - } - - if (!is_null($valign)) { - $xmlWriter->startElement('w:vAlign'); - $xmlWriter->writeAttribute('w:val', $valign); - $xmlWriter->endElement(); - } - - if ($borders) { - $_defaultColor = $style->getDefaultBorderColor(); - - $xmlWriter->startElement('w:tcBorders'); - if ($bTop) { - if (is_null($brdCol[0])) { - $brdCol[0] = $_defaultColor; - } - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[0]); - $xmlWriter->writeAttribute('w:color', $brdCol[0]); - $xmlWriter->endElement(); - } - - if ($bLeft) { - if (is_null($brdCol[1])) { - $brdCol[1] = $_defaultColor; - } - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[1]); - $xmlWriter->writeAttribute('w:color', $brdCol[1]); - $xmlWriter->endElement(); - } - - if ($bRight) { - if (is_null($brdCol[2])) { - $brdCol[2] = $_defaultColor; - } - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[2]); - $xmlWriter->writeAttribute('w:color', $brdCol[2]); - $xmlWriter->endElement(); - } - - if ($bBottom) { - if (is_null($brdCol[3])) { - $brdCol[3] = $_defaultColor; - } - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[3]); - $xmlWriter->writeAttribute('w:color', $brdCol[3]); - $xmlWriter->endElement(); - } - - $xmlWriter->endElement(); - } - } - $gridSpan = $style->getGridSpan(); - if (!is_null($gridSpan)) { - $xmlWriter->startElement('w:gridSpan'); - $xmlWriter->writeAttribute('w:val', $gridSpan); - $xmlWriter->endElement(); - } - - $vMerge = $style->getVMerge(); - if (!is_null($vMerge)) { - $xmlWriter->startElement('w:vMerge'); - $xmlWriter->writeAttribute('w:val', $vMerge); - $xmlWriter->endElement(); - } - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\Image|PhpOffice\PhpWord\Section\MemoryImage $image - */ - protected function _writeImage(XMLWriter $xmlWriter = null, $image, $withoutP = false) - { - $rId = $image->getRelationId(); - - $style = $image->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $align = $style->getAlign(); - $marginTop = $style->getMarginTop(); - $marginLeft = $style->getMarginLeft(); - $wrappingStyle = $style->getWrappingStyle(); - - if (!$withoutP) { - $xmlWriter->startElement('w:p'); - - if (!is_null($align)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:jc'); - $xmlWriter->writeAttribute('w:val', $align); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - $xmlWriter->startElement('w:r'); - - $xmlWriter->startElement('w:pict'); - - $xmlWriter->startElement('v:shape'); - $xmlWriter->writeAttribute('type', '#_x0000_t75'); - - $imgStyle = ''; - if (null !== $width) { - $imgStyle .= 'width:' . $width . 'px;'; - } - if (null !== $height) { - $imgStyle .= 'height:' . $height . 'px;'; - } - if (null !== $marginTop) { - $imgStyle .= 'margin-top:' . $marginTop . 'in;'; - } - if (null !== $marginLeft) { - $imgStyle .= 'margin-left:' . $marginLeft . 'in;'; - } - - switch ($wrappingStyle) { - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND: - $imgStyle .= 'position:absolute;z-index:-251658752;'; - break; - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE: - $imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; - break; - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_TIGHT: - $imgStyle .= 'position:absolute;z-index:251659264;mso-wrap-edited:f;mso-position-horizontal:absolute;mso-position-vertical:absolute'; - break; - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_INFRONT: - $imgStyle .= 'position:absolute;zz-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; - break; - } - - $xmlWriter->writeAttribute('style', $imgStyle); - - $xmlWriter->startElement('v:imagedata'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $xmlWriter->writeAttribute('o:title', ''); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - if (!$withoutP) { - $xmlWriter->endElement(); // w:p - } - } - - protected function _writeWatermark(XMLWriter $xmlWriter = null, $image) - { - $rId = $image->getRelationId(); - - $style = $image->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $marginLeft = $style->getMarginLeft(); - $marginTop = $style->getMarginTop(); - - $xmlWriter->startElement('w:p'); - - $xmlWriter->startElement('w:r'); - - $xmlWriter->startElement('w:pict'); - - $xmlWriter->startElement('v:shape'); - $xmlWriter->writeAttribute('type', '#_x0000_t75'); - - $strStyle = 'position:absolute;'; - $strStyle .= ' width:' . $width . 'px;'; - $strStyle .= ' height:' . $height . 'px;'; - if (!is_null($marginTop)) { - $strStyle .= ' margin-top:' . $marginTop . 'px;'; - } - if (!is_null($marginLeft)) { - $strStyle .= ' margin-left:' . $marginLeft . 'px;'; - } - - $xmlWriter->writeAttribute('style', $strStyle); - - $xmlWriter->startElement('v:imagedata'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $xmlWriter->writeAttribute('o:title', ''); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - } - - protected function _writeTitle(XMLWriter $xmlWriter = null, Title $title) - { - $text = htmlspecialchars($title->getText()); - $text = String::ControlCharacterPHP2OOXML($text); - $anchor = $title->getAnchor(); - $bookmarkId = $title->getBookmarkId(); - $style = $title->getStyle(); - - $xmlWriter->startElement('w:p'); - - if (!empty($style)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $style); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'end'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:bookmarkStart'); - $xmlWriter->writeAttribute('w:id', $bookmarkId); - $xmlWriter->writeAttribute('w:name', $anchor); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:t'); - $xmlWriter->writeRaw($text); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:bookmarkEnd'); - $xmlWriter->writeAttribute('w:id', $bookmarkId); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - } - - protected function _writeFootnote(XMLWriter $xmlWriter = null, Footnote $footnote) - { - $xmlWriter->startElement('w:footnote'); - $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId()); - - $styleParagraph = $footnote->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - $xmlWriter->startElement('w:p'); - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $elements = $footnote->getElements(); - if (count($elements) > 0) { - foreach ($elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element, true); - } elseif ($element instanceof Link) { - $this->_writeLink($xmlWriter, $element, true); - } - } - } - - $xmlWriter->endElement(); // w:p - $xmlWriter->endElement(); // w:footnote - } - - protected function _writeFootnoteReference(XMLWriter $xmlWriter = null, Footnote $footnote, $withoutP = false) - { - if (!$withoutP) { - $xmlWriter->startElement('w:p'); - } - - $xmlWriter->startElement('w:r'); - - $xmlWriter->startElement('w:footnoteReference'); - $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId()); - $xmlWriter->endElement(); // w:footnoteReference - - $xmlWriter->endElement(); // w:r - - if (!$withoutP) { - $xmlWriter->endElement(); // w:p - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/ContentTypes.php b/Classes/PhpWord/Writer/Word2007/ContentTypes.php deleted file mode 100644 index 2d84070d01..0000000000 --- a/Classes/PhpWord/Writer/Word2007/ContentTypes.php +++ /dev/null @@ -1,228 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Types - $xmlWriter->startElement('Types'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); - - // Rels - $this->_writeDefaultContentType( - $xmlWriter, - 'rels', - 'application/vnd.openxmlformats-package.relationships+xml' - ); - - // XML - $this->_writeDefaultContentType( - $xmlWriter, - 'xml', - 'application/xml' - ); - - // Add media content-types - foreach ($_imageTypes as $key => $value) { - $this->_writeDefaultContentType($xmlWriter, $key, $value); - } - - // Add embedding content-types - if (count($_objectTypes) > 0) { - $this->_writeDefaultContentType( - $xmlWriter, - 'bin', - 'application/vnd.openxmlformats-officedocument.oleObject' - ); - } - - // DocProps - $this->_writeOverrideContentType( - $xmlWriter, - '/docProps/app.xml', - 'application/vnd.openxmlformats-officedocument.extended-properties+xml' - ); - - $this->_writeOverrideContentType( - $xmlWriter, - '/docProps/core.xml', - 'application/vnd.openxmlformats-package.core-properties+xml' - ); - - // Document - $this->_writeOverrideContentType( - $xmlWriter, - '/word/document.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml' - ); - - // Styles - $this->_writeOverrideContentType( - $xmlWriter, - '/word/styles.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml' - ); - - // Numbering - $this->_writeOverrideContentType( - $xmlWriter, - '/word/numbering.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml' - ); - - // Settings - $this->_writeOverrideContentType( - $xmlWriter, - '/word/settings.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml' - ); - - // Theme1 - $this->_writeOverrideContentType( - $xmlWriter, - '/word/theme/theme1.xml', - 'application/vnd.openxmlformats-officedocument.theme+xml' - ); - - // WebSettings - $this->_writeOverrideContentType( - $xmlWriter, - '/word/webSettings.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml' - ); - - // Font Table - $this->_writeOverrideContentType( - $xmlWriter, - '/word/fontTable.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml' - ); - - // Footnotes - $this->_writeOverrideContentType( - $xmlWriter, - '/word/footnotes.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml' - ); - - for ($i = 1; $i <= $_cHdrs; $i++) { - $this->_writeOverrideContentType( - $xmlWriter, - '/word/header' . $i . '.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml' - ); - } - - for ($i = 1; $i <= count($footers); $i++) { - if (!is_null($footers[$i])) { - $this->_writeOverrideContentType( - $xmlWriter, - '/word/footer' . $i . '.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml' - ); - } - } - - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - /** - * Get image mime type - * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception - */ - private function _getImageMimeType($pFile = '') - { - if (File::file_exists($pFile)) { - $image = getimagesize($pFile); - return image_type_to_mime_type($image[2]); - } else { - throw new Exception("File $pFile does not exist"); - } - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception - */ - private function _writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') - { - if ($pPartname != '' && $pContentType != '') { - // Write content type - $xmlWriter->startElement('Default'); - $xmlWriter->writeAttribute('Extension', $pPartname); - $xmlWriter->writeAttribute('ContentType', $pContentType); - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception - */ - private function _writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') - { - if ($pPartname != '' && $pContentType != '') { - // Write content type - $xmlWriter->startElement('Override'); - $xmlWriter->writeAttribute('PartName', $pPartname); - $xmlWriter->writeAttribute('ContentType', $pContentType); - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/DocProps.php b/Classes/PhpWord/Writer/Word2007/DocProps.php deleted file mode 100644 index edf397ee52..0000000000 --- a/Classes/PhpWord/Writer/Word2007/DocProps.php +++ /dev/null @@ -1,186 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Properties - $xmlWriter->startElement('Properties'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); - $xmlWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); - - // Application - $xmlWriter->writeElement('Application', 'Microsoft Office Word'); - - // ScaleCrop - $xmlWriter->writeElement('ScaleCrop', 'false'); - - // HeadingPairs - $xmlWriter->startElement('HeadingPairs'); - - // Vector - $xmlWriter->startElement('vt:vector'); - $xmlWriter->writeAttribute('size', '4'); - $xmlWriter->writeAttribute('baseType', 'variant'); - - // Variant - $xmlWriter->startElement('vt:variant'); - $xmlWriter->writeElement('vt:lpstr', 'Theme'); - $xmlWriter->endElement(); - - // Variant - $xmlWriter->startElement('vt:variant'); - $xmlWriter->writeElement('vt:i4', '1'); - $xmlWriter->endElement(); - - // Variant - $xmlWriter->startElement('vt:variant'); - $xmlWriter->writeElement('vt:lpstr', 'Slide Titles'); - $xmlWriter->endElement(); - - // Variant - $xmlWriter->startElement('vt:variant'); - $xmlWriter->writeElement('vt:i4', '1'); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // TitlesOfParts - $xmlWriter->startElement('TitlesOfParts'); - - // Vector - $xmlWriter->startElement('vt:vector'); - $xmlWriter->writeAttribute('size', '1'); - $xmlWriter->writeAttribute('baseType', 'lpstr'); - - $xmlWriter->writeElement('vt:lpstr', 'Office Theme'); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // Company - $xmlWriter->writeElement('Company', $phpWord->getDocumentProperties()->getCompany()); - - // LinksUpToDate - $xmlWriter->writeElement('LinksUpToDate', 'false'); - - // SharedDoc - $xmlWriter->writeElement('SharedDoc', 'false'); - - // HyperlinksChanged - $xmlWriter->writeElement('HyperlinksChanged', 'false'); - - // AppVersion - $xmlWriter->writeElement('AppVersion', '12.0000'); - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - - public function writeDocPropsCore(PhpWord $phpWord = null) - { - // Create XML writer - $xmlWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // cp:coreProperties - $xmlWriter->startElement('cp:coreProperties'); - $xmlWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); - $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $xmlWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); - $xmlWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); - $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - - // dc:creator - $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getCreator()); - - // cp:lastModifiedBy - $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getDocumentProperties()->getLastModifiedBy()); - - // dcterms:created - $xmlWriter->startElement('dcterms:created'); - $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getCreated())); - $xmlWriter->endElement(); - - // dcterms:modified - $xmlWriter->startElement('dcterms:modified'); - $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getModified())); - $xmlWriter->endElement(); - - // dc:title - $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); - - // dc:description - $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); - - // dc:subject - $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); - - // cp:keywords - $xmlWriter->writeElement('cp:keywords', $phpWord->getDocumentProperties()->getKeywords()); - - // cp:category - $xmlWriter->writeElement('cp:category', $phpWord->getDocumentProperties()->getCategory()); - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Document.php b/Classes/PhpWord/Writer/Word2007/Document.php deleted file mode 100644 index f4cd15ea91..0000000000 --- a/Classes/PhpWord/Writer/Word2007/Document.php +++ /dev/null @@ -1,506 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // w:document - $xmlWriter->startElement('w:document'); - - $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - - $xmlWriter->startElement('w:body'); - - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if ($countSections > 0) { - foreach ($_sections as $section) { - $pSection++; - - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof Link) { - $this->_writeLink($xmlWriter, $element); - } elseif ($element instanceof Title) { - $this->_writeTitle($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter, $element); - } elseif ($element instanceof PageBreak) { - $this->_writePageBreak($xmlWriter); - } elseif ($element instanceof Table) { - $this->_writeTable($xmlWriter, $element); - } elseif ($element instanceof ListItem) { - $this->_writeListItem($xmlWriter, $element); - } elseif ($element instanceof Image || - $element instanceof MemoryImage - ) { - $this->_writeImage($xmlWriter, $element); - } elseif ($element instanceof Object) { - $this->_writeObject($xmlWriter, $element); - } elseif ($element instanceof TOC) { - $this->_writeTOC($xmlWriter); - } elseif ($element instanceof Footnote) { - $this->_writeFootnoteReference($xmlWriter, $element); - } - } - - if ($pSection == $countSections) { - $this->_writeEndSection($xmlWriter, $section); - } else { - $this->_writeSection($xmlWriter, $section); - } - } - } - - $xmlWriter->endElement(); // End w:body - $xmlWriter->endElement(); // End w:document - - // Return - return $xmlWriter->getData(); - } - - private function _writeSection(XMLWriter $xmlWriter = null, Section $section) - { - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:pPr'); - $this->_writeEndSection($xmlWriter, $section, 3); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section) - { - $settings = $section->getSettings(); - $_headers = $section->getHeaders(); - $_footer = $section->getFooter(); - $pgSzW = $settings->getPageSizeW(); - $pgSzH = $settings->getPageSizeH(); - $orientation = $settings->getOrientation(); - - $marginTop = $settings->getMarginTop(); - $marginLeft = $settings->getMarginLeft(); - $marginRight = $settings->getMarginRight(); - $marginBottom = $settings->getMarginBottom(); - - $headerHeight = $settings->getHeaderHeight(); - $footerHeight = $settings->getFooterHeight(); - - $borders = $settings->getBorderSize(); - - $colsNum = $settings->getColsNum(); - $colsSpace = $settings->getColsSpace(); - $breakType = $settings->getBreakType(); - - $xmlWriter->startElement('w:sectPr'); - - foreach ($_headers as &$_header) { - $rId = $_header->getRelationId(); - $xmlWriter->startElement('w:headerReference'); - $xmlWriter->writeAttribute('w:type', $_header->getType()); - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $xmlWriter->endElement(); - } - - if ($section->hasDifferentFirstPage()) { - $xmlWriter->startElement('w:titlePg'); - $xmlWriter->endElement(); - } - - if (!is_null($breakType)) { - $xmlWriter->startElement('w:type'); - $xmlWriter->writeAttribute('w:val', $breakType); - $xmlWriter->endElement(); - } - - if (!is_null($_footer)) { - $rId = $_footer->getRelationId(); - $xmlWriter->startElement('w:footerReference'); - $xmlWriter->writeAttribute('w:type', 'default'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:pgSz'); - $xmlWriter->writeAttribute('w:w', $pgSzW); - $xmlWriter->writeAttribute('w:h', $pgSzH); - - if (!is_null($orientation) && strtolower($orientation) != 'portrait') { - $xmlWriter->writeAttribute('w:orient', $orientation); - } - - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:pgMar'); - $xmlWriter->writeAttribute('w:top', $marginTop); - $xmlWriter->writeAttribute('w:right', $marginRight); - $xmlWriter->writeAttribute('w:bottom', $marginBottom); - $xmlWriter->writeAttribute('w:left', $marginLeft); - $xmlWriter->writeAttribute('w:header', $headerHeight); - $xmlWriter->writeAttribute('w:footer', $footerHeight); - $xmlWriter->writeAttribute('w:gutter', '0'); - $xmlWriter->endElement(); - - - if (!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) { - $borderColor = $settings->getBorderColor(); - - $xmlWriter->startElement('w:pgBorders'); - $xmlWriter->writeAttribute('w:offsetFrom', 'page'); - - if (!is_null($borders[0])) { - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $borders[0]); - $xmlWriter->writeAttribute('w:space', '24'); - $xmlWriter->writeAttribute('w:color', $borderColor[0]); - $xmlWriter->endElement(); - } - - if (!is_null($borders[1])) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $borders[1]); - $xmlWriter->writeAttribute('w:space', '24'); - $xmlWriter->writeAttribute('w:color', $borderColor[1]); - $xmlWriter->endElement(); - } - - if (!is_null($borders[2])) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $borders[2]); - $xmlWriter->writeAttribute('w:space', '24'); - $xmlWriter->writeAttribute('w:color', $borderColor[2]); - $xmlWriter->endElement(); - } - - if (!is_null($borders[3])) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $borders[3]); - $xmlWriter->writeAttribute('w:space', '24'); - $xmlWriter->writeAttribute('w:color', $borderColor[3]); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - - // Page numbering - if (null !== $settings->getPageNumberingStart()) { - $xmlWriter->startElement('w:pgNumType'); - $xmlWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart()); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:cols'); - $xmlWriter->writeAttribute('w:num', $colsNum); - $xmlWriter->writeAttribute('w:space', $colsSpace); - $xmlWriter->endElement(); - - - $xmlWriter->endElement(); - } - - private function _writePageBreak(XMLWriter $xmlWriter = null) - { - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:br'); - $xmlWriter->writeAttribute('w:type', 'page'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - public function _writeListItem(XMLWriter $xmlWriter = null, ListItem $listItem) - { - $textObject = $listItem->getTextObject(); - $text = $textObject->getText(); - $styleParagraph = $textObject->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - $depth = $listItem->getDepth(); - $listType = $listItem->getStyle()->getListType(); - - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:pPr'); - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph, true); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:numPr'); - - $xmlWriter->startElement('w:ilvl'); - $xmlWriter->writeAttribute('w:val', $depth); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:numId'); - $xmlWriter->writeAttribute('w:val', $listType); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $this->_writeText($xmlWriter, $textObject, true); - - $xmlWriter->endElement(); - } - - protected function _writeObject(XMLWriter $xmlWriter = null, Object $object) - { - $rIdObject = $object->getRelationId(); - $rIdImage = $object->getImageRelationId(); - $shapeId = md5($rIdObject . '_' . $rIdImage); - - $objectId = $object->getObjectId(); - - $style = $object->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $align = $style->getAlign(); - - - $xmlWriter->startElement('w:p'); - - if (!is_null($align)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:jc'); - $xmlWriter->writeAttribute('w:val', $align); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:r'); - - $xmlWriter->startElement('w:object'); - $xmlWriter->writeAttribute('w:dxaOrig', '249'); - $xmlWriter->writeAttribute('w:dyaOrig', '160'); - - $xmlWriter->startElement('v:shape'); - $xmlWriter->writeAttribute('id', $shapeId); - $xmlWriter->writeAttribute('type', '#_x0000_t75'); - $xmlWriter->writeAttribute('style', 'width:104px;height:67px'); - $xmlWriter->writeAttribute('o:ole', ''); - - $xmlWriter->startElement('v:imagedata'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rIdImage); - $xmlWriter->writeAttribute('o:title', ''); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->startElement('o:OLEObject'); - $xmlWriter->writeAttribute('Type', 'Embed'); - $xmlWriter->writeAttribute('ProgID', 'Package'); - $xmlWriter->writeAttribute('ShapeID', $shapeId); - $xmlWriter->writeAttribute('DrawAspect', 'Icon'); - $xmlWriter->writeAttribute('ObjectID', '_' . $objectId); - $xmlWriter->writeAttribute('r:id', 'rId' . $rIdObject); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); // w:r - - $xmlWriter->endElement(); // w:p - } - - private function _writeTOC(XMLWriter $xmlWriter = null) - { - $titles = TOC::getTitles(); - $styleFont = TOC::getStyleFont(); - - $styleTOC = TOC::getStyleTOC(); - $fIndent = $styleTOC->getIndent(); - $tabLeader = $styleTOC->getTabLeader(); - $tabPos = $styleTOC->getTabPos(); - - $isObject = ($styleFont instanceof Font) ? true : false; - - for ($i = 0; $i < count($titles); $i++) { - $title = $titles[$i]; - $indent = ($title['depth'] - 1) * $fIndent; - - $xmlWriter->startElement('w:p'); - - $xmlWriter->startElement('w:pPr'); - - if ($isObject && !is_null($styleFont->getParagraphStyle())) { - $this->_writeParagraphStyle($xmlWriter, $styleFont->getParagraphStyle()); - } - - if ($indent > 0) { - $xmlWriter->startElement('w:ind'); - $xmlWriter->writeAttribute('w:left', $indent); - $xmlWriter->endElement(); - } - - if (!empty($styleFont) && !$isObject) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:tabs'); - $xmlWriter->startElement('w:tab'); - $xmlWriter->writeAttribute('w:val', 'right'); - if (!empty($tabLeader)) { - $xmlWriter->writeAttribute('w:leader', $tabLeader); - } - $xmlWriter->writeAttribute('w:pos', $tabPos); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); // w:pPr - - - if ($i == 0) { - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:instrText'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw('TOC \o "1-9" \h \z \u'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'separate'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:hyperlink'); - $xmlWriter->writeAttribute('w:anchor', $title['anchor']); - $xmlWriter->writeAttribute('w:history', '1'); - - $xmlWriter->startElement('w:r'); - - if ($isObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } - - $xmlWriter->startElement('w:t'); - $xmlWriter->writeRaw($title['text']); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->writeElement('w:tab', null); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:instrText'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'end'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); // w:hyperlink - - $xmlWriter->endElement(); // w:p - } - - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'end'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/DocumentRels.php b/Classes/PhpWord/Writer/Word2007/DocumentRels.php deleted file mode 100644 index 176dd05512..0000000000 --- a/Classes/PhpWord/Writer/Word2007/DocumentRels.php +++ /dev/null @@ -1,182 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Relationships - $xmlWriter->startElement('Relationships'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - // Relationship word/document.xml - $this->_writeRelationship( - $xmlWriter, - 1, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', - 'styles.xml' - ); - - // Relationship word/numbering.xml - $this->_writeRelationship( - $xmlWriter, - 2, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering', - 'numbering.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $xmlWriter, - 3, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings', - 'settings.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $xmlWriter, - 4, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', - 'theme/theme1.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $xmlWriter, - 5, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings', - 'webSettings.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $xmlWriter, - 6, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable', - 'fontTable.xml' - ); - - // Relationships to Images / Embeddings / Headers / Footers - foreach ($_relsCollection as $relation) { - $relationType = $relation['type']; - $relationName = $relation['target']; - $relationId = $relation['rID']; - $targetMode = ($relationType == 'hyperlink') ? 'External' : ''; - - $this->_writeRelationship( - $xmlWriter, - $relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, - $relationName, - $targetMode - ); - } - - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - public function writeHeaderFooterRels($_relsCollection) - { - // Create XML writer - $xmlWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Relationships - $xmlWriter->startElement('Relationships'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - // Relationships to Images / Embeddings / Headers / Footers - foreach ($_relsCollection as $relation) { - $relationType = $relation['type']; - $relationName = $relation['target']; - $relationId = $relation['rID']; - - $this->_writeRelationship( - $xmlWriter, - $relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, - $relationName - ); - } - - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') - { - if ($pType != '' && $pTarget != '') { - if (strpos($pId, 'rId') === false) { - $pId = 'rId' . $pId; - } - - // Write relationship - $xmlWriter->startElement('Relationship'); - $xmlWriter->writeAttribute('Id', $pId); - $xmlWriter->writeAttribute('Type', $pType); - $xmlWriter->writeAttribute('Target', $pTarget); - - if ($pTargetMode != '') { - $xmlWriter->writeAttribute('TargetMode', $pTargetMode); - } - - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Footer.php b/Classes/PhpWord/Writer/Word2007/Footer.php deleted file mode 100644 index f3ef2a1fb4..0000000000 --- a/Classes/PhpWord/Writer/Word2007/Footer.php +++ /dev/null @@ -1,90 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - $xmlWriter->startElement('w:ftr'); - $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - - $_elements = $footer->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter, $element); - } elseif ($element instanceof Table) { - $this->_writeTable($xmlWriter, $element); - } elseif ($element instanceof Image || - $element instanceof MemoryImage - ) { - $this->_writeImage($xmlWriter, $element); - } elseif ($element instanceof PreserveText) { - $this->_writePreserveText($xmlWriter, $element); - } - } - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Footnotes.php b/Classes/PhpWord/Writer/Word2007/Footnotes.php deleted file mode 100644 index d467859f90..0000000000 --- a/Classes/PhpWord/Writer/Word2007/Footnotes.php +++ /dev/null @@ -1,87 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - $xmlWriter->startElement('w:footnotes'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - - // write separator and continuation separator - $xmlWriter->startElement('w:footnote'); - $xmlWriter->writeAttribute('w:id', 0); - $xmlWriter->writeAttribute('w:type', 'separator'); - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:separator'); - $xmlWriter->endElement(); // w:separator - $xmlWriter->endElement(); // w:r - $xmlWriter->endElement(); // w:p - $xmlWriter->endElement(); // w:footnote - - $xmlWriter->startElement('w:footnote'); - $xmlWriter->writeAttribute('w:id', 1); - $xmlWriter->writeAttribute('w:type', 'continuationSeparator'); - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:continuationSeparator'); - $xmlWriter->endElement(); // w:continuationSeparator - $xmlWriter->endElement(); // w:r - $xmlWriter->endElement(); // w:p - $xmlWriter->endElement(); // w:footnote - - - foreach ($allFootnotesCollection as $footnote) { - if ($footnote instanceof Footnote) { - $this->_writeFootnote($xmlWriter, $footnote); - } - } - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/FootnotesRels.php b/Classes/PhpWord/Writer/Word2007/FootnotesRels.php deleted file mode 100644 index b181987676..0000000000 --- a/Classes/PhpWord/Writer/Word2007/FootnotesRels.php +++ /dev/null @@ -1,89 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Relationships - $xmlWriter->startElement('Relationships'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - // Relationships to Links - foreach ($_relsCollection as $relation) { - $relationType = $relation['type']; - $relationName = $relation['target']; - $relationId = $relation['rID']; - $targetMode = ($relationType == 'hyperlink') ? 'External' : ''; - - $this->_writeRelationship($xmlWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName, $targetMode); - } - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') - { - if ($pType != '' && $pTarget != '') { - if (strpos($pId, 'rId') === false) { - $pId = 'rId' . $pId; - } - - // Write relationship - $xmlWriter->startElement('Relationship'); - $xmlWriter->writeAttribute('Id', $pId); - $xmlWriter->writeAttribute('Type', $pType); - $xmlWriter->writeAttribute('Target', $pTarget); - - if ($pTargetMode != '') { - $xmlWriter->writeAttribute('TargetMode', $pTargetMode); - } - - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Header.php b/Classes/PhpWord/Writer/Word2007/Header.php deleted file mode 100644 index aef2c38a7c..0000000000 --- a/Classes/PhpWord/Writer/Word2007/Header.php +++ /dev/null @@ -1,94 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - $xmlWriter->startElement('w:hdr'); - $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - - - $_elements = $header->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter, $element); - } elseif ($element instanceof Table) { - $this->_writeTable($xmlWriter, $element); - } elseif ($element instanceof Image || - $element instanceof MemoryImage - ) { - if (!$element->getIsWatermark()) { - $this->_writeImage($xmlWriter, $element); - } else { - $this->_writeWatermark($xmlWriter, $element); - } - } elseif ($element instanceof PreserveText) { - $this->_writePreserveText($xmlWriter, $element); - } - } - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Rels.php b/Classes/PhpWord/Writer/Word2007/Rels.php deleted file mode 100644 index 615fd13e9c..0000000000 --- a/Classes/PhpWord/Writer/Word2007/Rels.php +++ /dev/null @@ -1,115 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Relationships - $xmlWriter->startElement('Relationships'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - $relationId = 1; - - // Relationship word/document.xml - $this->_writeRelationship( - $xmlWriter, - $relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', - 'word/document.xml' - ); - - // Relationship docProps/core.xml - $this->_writeRelationship( - $xmlWriter, - ++$relationId, - 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', - 'docProps/core.xml' - ); - - // Relationship docProps/app.xml - $this->_writeRelationship( - $xmlWriter, - ++$relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', - 'docProps/app.xml' - ); - - $xmlWriter->endElement(); - - return $xmlWriter->getData(); - } - - /** - * Write Override content type - * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param int $pId Relationship ID. rId will be prepended! - * @param string $pType Relationship type - * @param string $pTarget Relationship target - * @param string $pTargetMode Relationship target mode - * @throws Exception - */ - private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') - { - if ($pType != '' && $pTarget != '') { - if (strpos($pId, 'rId') === false) { - $pId = 'rId' . $pId; - } - - // Write relationship - $xmlWriter->startElement('Relationship'); - $xmlWriter->writeAttribute('Id', $pId); - $xmlWriter->writeAttribute('Type', $pType); - $xmlWriter->writeAttribute('Target', $pTarget); - - if ($pTargetMode != '') { - $xmlWriter->writeAttribute('TargetMode', $pTargetMode); - } - - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Styles.php b/Classes/PhpWord/Writer/Word2007/Styles.php deleted file mode 100644 index 7918851c0f..0000000000 --- a/Classes/PhpWord/Writer/Word2007/Styles.php +++ /dev/null @@ -1,399 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - $this->_document = $phpWord; - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - $xmlWriter->startElement('w:styles'); - - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - - // Write DocDefaults - $this->_writeDocDefaults($xmlWriter); - - - // Write Style Definitions - $styles = Style::getStyles(); - - // Write normal paragraph style - $normalStyle = null; - if (array_key_exists('Normal', $styles)) { - $normalStyle = $styles['Normal']; - } - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', 'paragraph'); - $xmlWriter->writeAttribute('w:default', '1'); - $xmlWriter->writeAttribute('w:styleId', 'Normal'); - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', 'Normal'); - $xmlWriter->endElement(); - if (!is_null($normalStyle)) { - $this->_writeParagraphStyle($xmlWriter, $normalStyle); - } - $xmlWriter->endElement(); - - // Write other styles - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - if ($styleName == 'Normal') { - continue; - } - if ($style instanceof Font) { - - $paragraphStyle = $style->getParagraphStyle(); - $styleType = $style->getStyleType(); - - $type = ($styleType == 'title') ? 'paragraph' : 'character'; - - if (!is_null($paragraphStyle)) { - $type = 'paragraph'; - } - - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', $type); - - if ($styleType == 'title') { - $arrStyle = explode('_', $styleName); - $styleId = 'Heading' . $arrStyle[1]; - $styleName = 'heading ' . $arrStyle[1]; - $styleLink = 'Heading' . $arrStyle[1] . 'Char'; - $xmlWriter->writeAttribute('w:styleId', $styleId); - - $xmlWriter->startElement('w:link'); - $xmlWriter->writeAttribute('w:val', $styleLink); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $styleName); - $xmlWriter->endElement(); - - if (!is_null($paragraphStyle)) { - // Point parent style to Normal - $xmlWriter->startElement('w:basedOn'); - $xmlWriter->writeAttribute('w:val', 'Normal'); - $xmlWriter->endElement(); - $this->_writeParagraphStyle($xmlWriter, $paragraphStyle); - } - - $this->_writeTextStyle($xmlWriter, $style); - - $xmlWriter->endElement(); - - } elseif ($style instanceof Paragraph) { - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', 'paragraph'); - $xmlWriter->writeAttribute('w:customStyle', '1'); - $xmlWriter->writeAttribute('w:styleId', $styleName); - - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $styleName); - $xmlWriter->endElement(); - - // Parent style - $basedOn = $style->getBasedOn(); - if (!is_null($basedOn)) { - $xmlWriter->startElement('w:basedOn'); - $xmlWriter->writeAttribute('w:val', $basedOn); - $xmlWriter->endElement(); - } - - // Next paragraph style - $next = $style->getNext(); - if (!is_null($next)) { - $xmlWriter->startElement('w:next'); - $xmlWriter->writeAttribute('w:val', $next); - $xmlWriter->endElement(); - } - - $this->_writeParagraphStyle($xmlWriter, $style); - $xmlWriter->endElement(); - - } elseif ($style instanceof TableFull) { - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', 'table'); - $xmlWriter->writeAttribute('w:customStyle', '1'); - $xmlWriter->writeAttribute('w:styleId', $styleName); - - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $styleName); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:uiPriority'); - $xmlWriter->writeAttribute('w:val', '99'); - $xmlWriter->endElement(); - - $this->_writeFullTableStyle($xmlWriter, $style); - - $xmlWriter->endElement(); - } - } - } - - $xmlWriter->endElement(); // w:styles - - // Return - return $xmlWriter->getData(); - } - - private function _writeFullTableStyle(XMLWriter $xmlWriter = null, TableFull $style) - { - - $brdSz = $style->getBorderSize(); - $brdCol = $style->getBorderColor(); - $bgColor = $style->getBgColor(); - $cellMargin = $style->getCellMargin(); - - $bTop = (!is_null($brdSz[0])) ? true : false; - $bLeft = (!is_null($brdSz[1])) ? true : false; - $bRight = (!is_null($brdSz[2])) ? true : false; - $bBottom = (!is_null($brdSz[3])) ? true : false; - $bInsH = (!is_null($brdSz[4])) ? true : false; - $bInsV = (!is_null($brdSz[5])) ? true : false; - $borders = ($bTop || $bLeft || $bRight || $bBottom || $bInsH || $bInsV) ? true : false; - - $mTop = (!is_null($cellMargin[0])) ? true : false; - $mLeft = (!is_null($cellMargin[1])) ? true : false; - $mRight = (!is_null($cellMargin[2])) ? true : false; - $mBottom = (!is_null($cellMargin[3])) ? true : false; - $margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false; - - $xmlWriter->startElement('w:tblPr'); - - if ($margins) { - $xmlWriter->startElement('w:tblCellMar'); - if ($mTop) { - echo $margins[0]; - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:w', $cellMargin[0]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - if ($mLeft) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:w', $cellMargin[1]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - if ($mRight) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:w', $cellMargin[2]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - if ($mBottom) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:w', $cellMargin[3]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - - if ($borders) { - $xmlWriter->startElement('w:tblBorders'); - if ($bTop) { - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[0]); - $xmlWriter->writeAttribute('w:color', $brdCol[0]); - $xmlWriter->endElement(); - } - if ($bLeft) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[1]); - $xmlWriter->writeAttribute('w:color', $brdCol[1]); - $xmlWriter->endElement(); - } - if ($bRight) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[2]); - $xmlWriter->writeAttribute('w:color', $brdCol[2]); - $xmlWriter->endElement(); - } - if ($bBottom) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[3]); - $xmlWriter->writeAttribute('w:color', $brdCol[3]); - $xmlWriter->endElement(); - } - if ($bInsH) { - $xmlWriter->startElement('w:insideH'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[4]); - $xmlWriter->writeAttribute('w:color', $brdCol[4]); - $xmlWriter->endElement(); - } - if ($bInsV) { - $xmlWriter->startElement('w:insideV'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[5]); - $xmlWriter->writeAttribute('w:color', $brdCol[5]); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - - $xmlWriter->endElement(); - - if (!is_null($bgColor)) { - $xmlWriter->startElement('w:tcPr'); - $xmlWriter->startElement('w:shd'); - $xmlWriter->writeAttribute('w:val', 'clear'); - $xmlWriter->writeAttribute('w:color', 'auto'); - $xmlWriter->writeAttribute('w:fill', $bgColor); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - - // First Row - $firstRow = $style->getFirstRow(); - if (!is_null($firstRow)) { - $this->_writeRowStyle($xmlWriter, 'firstRow', $firstRow); - } - } - - private function _writeRowStyle(XMLWriter $xmlWriter = null, $type, TableFull $style) - { - $brdSz = $style->getBorderSize(); - $brdCol = $style->getBorderColor(); - $bgColor = $style->getBgColor(); - - $bTop = (!is_null($brdSz[0])) ? true : false; - $bLeft = (!is_null($brdSz[1])) ? true : false; - $bRight = (!is_null($brdSz[2])) ? true : false; - $bBottom = (!is_null($brdSz[3])) ? true : false; - $borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false; - - $xmlWriter->startElement('w:tblStylePr'); - $xmlWriter->writeAttribute('w:type', $type); - - $xmlWriter->startElement('w:tcPr'); - if (!is_null($bgColor)) { - $xmlWriter->startElement('w:shd'); - $xmlWriter->writeAttribute('w:val', 'clear'); - $xmlWriter->writeAttribute('w:color', 'auto'); - $xmlWriter->writeAttribute('w:fill', $bgColor); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:tcBorders'); - if ($bTop) { - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[0]); - $xmlWriter->writeAttribute('w:color', $brdCol[0]); - $xmlWriter->endElement(); - } - if ($bLeft) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[1]); - $xmlWriter->writeAttribute('w:color', $brdCol[1]); - $xmlWriter->endElement(); - } - if ($bRight) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[2]); - $xmlWriter->writeAttribute('w:color', $brdCol[2]); - $xmlWriter->endElement(); - } - if ($bBottom) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[3]); - $xmlWriter->writeAttribute('w:color', $brdCol[3]); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - } - - - private function _writeDocDefaults(XMLWriter $xmlWriter = null) - { - $fontName = $this->_document->getDefaultFontName(); - $fontSize = $this->_document->getDefaultFontSize(); - - $xmlWriter->startElement('w:docDefaults'); - $xmlWriter->startElement('w:rPrDefault'); - $xmlWriter->startElement('w:rPr'); - - $xmlWriter->startElement('w:rFonts'); - $xmlWriter->writeAttribute('w:ascii', $fontName); - $xmlWriter->writeAttribute('w:hAnsi', $fontName); - $xmlWriter->writeAttribute('w:eastAsia', $fontName); - $xmlWriter->writeAttribute('w:cs', $fontName); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:sz'); - $xmlWriter->writeAttribute('w:val', $fontSize * 2); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:szCs'); - $xmlWriter->writeAttribute('w:val', $fontSize * 2); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/WriterPart.php b/Classes/PhpWord/Writer/Word2007/WriterPart.php deleted file mode 100644 index bb8fefc334..0000000000 --- a/Classes/PhpWord/Writer/Word2007/WriterPart.php +++ /dev/null @@ -1,49 +0,0 @@ -_parentWriter = $pWriter; - } - - public function getParentWriter() - { - if (!is_null($this->_parentWriter)) { - return $this->_parentWriter; - } else { - throw new Exception("No parent IWriter assigned."); - } - } -} diff --git a/Classes/PhpWord/_staticDocParts/_doc.png b/Classes/PhpWord/_staticDocParts/_doc.png deleted file mode 100644 index 3128a803b4eb829a6eb098e3736366ebfb43cef7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1157 zcmV;01bX|4P)0{{R3N2#!80000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUzQ&3D)MgRZ*0002t=Ji~3tGCGXHb!Y? zeY1m{+VJxFdy&6FRe$>X{`>s?{r>+{Y@~07x=L=rNOQ~tHG)iIn>S#t05NwhRIBRl z_y8eM=}aaf{Nayy{$g%gNH>D_Nxe|Nj6SMq`QM_4oXlvF-Hs`~3a>MO=(m zebHZq-6cqOIAXL%cG+c!+caRpt-8>Qq}@YlxrwFeQFh7zC0adWzw-3@6+2aCiq(6U z*cLo)c8Z+V-0DANw4k@}J5qNCJBTk)k0wisIcT_&qqQhfpZNLxF#dt- z_uX#SR(tRN|I)^<+{jmyZq)XA`T5O~lY>H!qAd!i^Y)K@VAX7ctD^`7k~{HkL|E zAcb-R(47;o6|y+{sa3R45JD71HAGR@7vpf|$v;_R?$z8jK%$t8Ml}-0yi}1Q1F|SK z>Z~0Q98y&Cl7CKr6~(_~;5#16{y257P9lZUBVG(^>rst~(_T%ivv^?lCYIT4yT77^ z)ChzyJzC`31&XQ%S!RV-Lf38D9_VwF;tOQ)LP?kSQAWz_(zH8`7OM2129Hy^qE>1t zp4+>Q)8P#jEhHPzBAFC z$Yh$WTgOFYr;tLvG7i5N_^adN!t%;?=Im@Oe(SghA7bbT?|%RImsdW~ba9tV${^%My7w!<$0EU(Az z^f?eP@4dSVdY3S_00XAk8zV43K27RFz3TvAz70U;N&WN8ohL$rgS!8>vW(~d29G>vf?KbCZ<^iBfdBg+S#J!O^9loZ)5&~}hRr$*06U-Xms&}joSa@!{{$ES XtjuZObd?ae00000NkvXXu0mjf9*{Wp diff --git a/Classes/PhpWord/_staticDocParts/_ppt.png b/Classes/PhpWord/_staticDocParts/_ppt.png deleted file mode 100644 index 3e925f50199cf96e881dee05455b410fcc282731..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1886 zcmV-k2ch_hP)0{{R3N2#!80000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#08mU+MgHT}{J4`=3l5Y_PyNxl|M>L& z>*4*!s;emi|Mc&CLQc?fRsZbb{J)<5-p=8CT>QYHHw6p-`uOdVZSI#@{@cm__VezG zROXUu|K{0_NlpLgx#W&%(_<;@mTfg0dJ4Of%qf{&CtBn2Az3Gi<++`{M z@8$pg{n&6(xit#IJ`S!*HfRwK>6LD)MKZ!+NXteO_MdtG_3-`6v63|{{JWURYEJ+E z|C~@yg+@-gRzT&1V*SLX{lcWydRzYK-~Z#&?PVta`S$(Hv;Xqz|Lx?(WlQ0SX5)ch z%49h1gh&77*#G0y{@23&*24YNzHSu}f<#T}i)Ztib@G^V!CpnYTSM-VN&VHq?t@d_ zhGW@(UEX?FkvTHfZcof_QqyNic|uV1oOiNPG~9Mp)oV@ZVI$sG9@tVF&q)=&It(oY z3$-!_u`UH*4h;YR0RQ~@|Nj24UPJ%!>i_of|K-=AMl$`+xBukU|LNWT|Nj5{``KzP z|LEMaPB{OsasTMHyj&^KWk>ppOXPGr{FGAYr-uIF((r97uSPiMoOjG&DdTN0w^Tm= z)S~~`rsaG_|K_stbTapTKIf!@^LaPtpnU(xlmE_}sZ}ekSS$ajXyt)V|Dj>!k7NJ+ z{Qtaz{h3+oVkG96aKUq0|K6(jg+>3vi{*t?<%(SYw|V~L*5hd{|K--?a5db5VB~l~ z{m!-jsB(`icXt#Q<8O7fe0 z>4|RQfMn!@Vg1dtfJ9FI=-vM5-7>lgfdBvl^hrcPRCwBA@TL=B7`15BqEU;6n?-Ur zPg#0w=i)_cR`1@jZ}R$$TW3z+ zwS48WIiZ?Vw#e1BEImU*SlA-%mH%&k{(_3$LkkWlsH&b(NujPq$I@G^&A`mo53HP5*tFh>CbB4~T2b4g=$#qL*0aD& zYauap#o+yXO3B>{R}_7YJ5bf4yv1^xH?Q#4(K&bT?wubR*MENg#eedTrB$R)HFYgI zyhymeWtI0MV3xfd^yC&W!vgcGyJaMg;R)(ml)naO(L4~VKg=y6@;?KglKD|RSspgS znkK4R6tvpn#ii|_7`nvDsmi7`TQrHqon4m4h*`U-m6{ek*`0PtNW$BjrLC~=u_q)c z=&{c?GGeZ!u8+94yb{vip88wupG#HOANGfAj))J=aOb`_@s{qO6(E-P~p75+g=g#dw5jHU;B{x(q8qJ_JPo~bWrftCu1 z;H2QmXxh`m)gVY!i;S07s<$6dP*AY6l$D)tU@%o)e%)GA(}V=BM(SELY328bc2!j? z#Yi4DBctAl=OraO5B4M^gp@W4_EFO!`(-8Vs#g>hd4Trxg6xU!>;%~pQp!Ohscg!!W`DC<4e9 z!9|f&BKfGfxf$6XP>7@$jfpCU;v<~$49GExZc#HvSQ2j$LN5^(VZ=0PKJq4D5jt-6 z#ui83-q_qiAdb8-a|3D`!VNvsF={;)Es6|8EB7gt` Y0LsdDm^Yzu*8l(j07*qoM6N<$f~$WKuK)l5 diff --git a/Classes/PhpWord/_staticDocParts/_xls.png b/Classes/PhpWord/_staticDocParts/_xls.png deleted file mode 100644 index a7d7697fc5666629b9d8bb3090339c5f557536b5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1924 zcmV-~2YdL5P)0{{R3N2#!80000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#08mU+MKVMjJ8dS}_T8hyou0{*wA87C zmvPhL)a~~1NrWgzm_<~EN>Exj*6P;k^5g?(0%wzE$L6|btYq}{@H&V*R)JDem^j_+ z;>+g3+2z`es)5Pf!teX;s?(l1cNJY^MNEetb|F z_5Ar)lT>TAX7ly=6eI}5-n?LlN-8xJ@Ksom<`OJX!7Iw5nmXINZ8)#lgP=-T-H z_fm^EUusEIeL9cJfqS}c&f3#-onmB;QswdHe5GrFyn9TKLm_Ygc$Zv6j3xT{`dgzx z;O*m`(U@PDSx1sKc(!zQvvlh6>Iz~6PMKF?s#O2~`;w@1e7bvKqEmjTX;z;-=k4a& z?b+$--CLwo|N8!Ro@n~~`IEVge6er&`t^IJaay2A=JD!;vT}&5f>o(hcD7nJZy3+& z&incPkj05>m01d66;+~A_WbpAy=rooZu9!^aGPIMrcG?9V|KD^<>%t!=iGXtWI=r* z+Uebp!i8g+UrTU2ZM0tg{``WidE)Qh|NsALY*rsA4BP3`Rbf2m^Y8lq{NL^0BrFsz zK_+IZUg7fMXp&Vrf*=+h3?(%XH%=e`007+T+u`r#=kMd?_T%mE>WjU8fV_6~{qXMc z=|E;C$l=An>%iCV*Uje0&g;L}?cCq&+TP~k{rdIh_~LT9Wa<6v8z2+Z-`8QGTl)0( zZK6;O+D8ZtY>$yY?;iD|Nj42rdl6+k>n z^yc*EnZuFR=H>nU|IzHp{Qv)dlxP3_|9Ze^ki3Ea{QWLJ81wk}?EUrj_w;3;C`$@AU0!xN!LV?n)1(VE_OG8c9S!RCwBAm`NwVFly1LMWYtc$)al+ z8QJI0_xEQ9^%n(ob~XhEFV)xAH`V9%^HcgmO^c@Q-1$ag>kd6VJ!4kZ$FeLeFF&f8 z1eA8)?oL}tRUcJbT(z_;DRFePoGx{>TI$jzYwMHNZ133EBA-yzqPONh9n)W@f0~wF zmj1M(qxf5yy71;3!khUvYh+Q^N9Gcz?#}%4cK(m~#hRL5bacLa;V?^n@q5Wy(->-7 z%j~;YnH-Y*OzAsyEh?8NF`It7XYsB0$u~P>4(PQDOb)iS zwPniH$XR)pnihrXo%T)=eC*Wd6eb|~El^;8z()6bqAAZbmPtiiLyWo>1+iBDpRe5DkAjF zzC2$lThz%~?H&E?fbtzKJ*UOpLRq5C(kg~)d&R}&eLhpwq9)dAow7~eWa{sS8><~l zyLWGjvyo9R@Aiqa6bz_q(c|jYXpZPTT3!6%vKw2vx@uCU*ama&dF30mg1Q#PN$r*4 zP`2PINJ(JLY_aJ|OPL}XY`ZH@p2|L2dgr+CS7qMR(y0afTya$u_qba46(*eF<@Jp+ zplUu^>U3O3XAaj?lK`O>{)D*O4i4c7&34R^_Otw`>!aYt<6p#6-7_GGt9`?2H92t5>h~^78a# zx3@Utae=x%@~eHfe*OB~+}yQm7r3}g^zxFFWcOmXueS$UL`@&1o4U8Z;CnO!2zKY? z@q&RTyQk_7Rr$K*RP~W*caf5kk_Hg@LV$;dhrEZ!TzQ@?)V0X(=(!jm$jK2C6Z26} zP~ha8FhLFo>gpn>YmvrEFkk?I&ju?%VD@a?g$H$kkeU_&n~rbMh5mqvKSVb1M>}Gp z7L8g&GmBP%0ah7=3MB3-9I6OggwtI}Ca=P+kW`DHMnN6F3SlywTs0Fe3iIPCIFke) zt%4W^MKB84A}sQ&NbwOgj#i - \ No newline at end of file diff --git a/Classes/PhpWord/_staticDocParts/numbering.xml b/Classes/PhpWord/_staticDocParts/numbering.xml deleted file mode 100644 index ac229f400e..0000000000 --- a/Classes/PhpWord/_staticDocParts/numbering.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/Classes/PhpWord/_staticDocParts/settings.xml b/Classes/PhpWord/_staticDocParts/settings.xml deleted file mode 100644 index 5eb2289137..0000000000 --- a/Classes/PhpWord/_staticDocParts/settings.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Classes/PhpWord/_staticDocParts/theme1.xml b/Classes/PhpWord/_staticDocParts/theme1.xml deleted file mode 100644 index 4fab507b66..0000000000 --- a/Classes/PhpWord/_staticDocParts/theme1.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/Classes/PhpWord/_staticDocParts/webSettings.xml b/Classes/PhpWord/_staticDocParts/webSettings.xml deleted file mode 100644 index 72d2830728..0000000000 --- a/Classes/PhpWord/_staticDocParts/webSettings.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/src/Exceptions/Exception.php b/src/Exceptions/Exception.php old mode 100644 new mode 100755 From 9c6d07aaeb94c4da02853a82f358e2ad479464cf Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 22 Mar 2014 15:32:02 +0400 Subject: [PATCH 11/15] https://github.com/PHPOffice/PHPWord/issues/58 - autoloading fix. --- src/Autoloader.php | 2 +- src/PhpWord.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Autoloader.php b/src/Autoloader.php index ca762c6ae5..ace06fcc7e 100644 --- a/src/Autoloader.php +++ b/src/Autoloader.php @@ -25,7 +25,7 @@ * @version 0.8.0 */ -namespace PhpOffice\PhpWord\Autoloader; +namespace PhpOffice\PhpWord; if (!\defined('PHPWORD_BASE_DIR')) { \define('PHPWORD_BASE_DIR', \realpath(__DIR__) . \DIRECTORY_SEPARATOR); diff --git a/src/PhpWord.php b/src/PhpWord.php index e08ec04132..9439f9ce2b 100644 --- a/src/PhpWord.php +++ b/src/PhpWord.php @@ -37,7 +37,7 @@ if (!defined('PHPWORD_BASE_DIR')) { define('PHPWORD_BASE_DIR', \realpath(__DIR__) . \DIRECTORY_SEPARATOR); require \PHPWORD_BASE_DIR . 'Autoloader.php'; - PhpOffice\PhpWord\Autoloader::register(); + Autoloader::register(); } // @codeCoverageIgnoreEnd From 0c449a6a0c390e98ecc6493e2fcae36e063a86bf Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 22 Mar 2014 15:36:17 +0400 Subject: [PATCH 12/15] https://github.com/PHPOffice/PHPWord/issues/58 - fixes for samples. --- README.md | 2 +- samples/Sample_01_SimpleText.php | 2 +- samples/Sample_02_TabStops.php | 2 +- samples/Sample_03_Sections.php | 2 +- samples/Sample_04_Textrun.php | 2 +- samples/Sample_05_Multicolumn.php | 2 +- samples/Sample_06_Footnote.php | 2 +- samples/Sample_07_TemplateCloneRow.php | 2 +- samples/Sample_08_ParagraphPagination.php | 2 +- samples/Sample_09_Tables.php | 2 +- samples/Sample_10_EastAsianFontStyle.php | 2 +- samples/Sample_12_HeaderFooter.php | 2 +- samples/Sample_13_Images.php | 2 +- samples/Sample_14_ListItem.php | 2 +- samples/Sample_15_Link.php | 2 +- samples/Sample_16_Object.php | 2 +- samples/Sample_17_TitleTOC.php | 2 +- samples/Sample_18_Watermark.php | 2 +- samples/Sample_19_TextBreak.php | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index e401de24f1..2ee8e766b0 100755 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ We're reorganizing our documentation. Below are some of the most important thing The following is a basic example of the PhpWord library. More examples are provided in the [samples folder](samples/). ```php -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Every element you want to append to the word document is placed in a section. // To create a basic section: diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index 34a93ecf94..bdb163ba15 100755 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -6,7 +6,7 @@ // New Word Document echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\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)); diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index 5eef59a833..1026cc0916 100755 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -6,7 +6,7 @@ // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Ads styles $phpWord->addParagraphStyle('multipleTab', array( diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index e066097c0d..4d26945432 100755 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -6,7 +6,7 @@ // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // New portrait section $section = $phpWord->createSection(array('borderColor' => '00FF00', 'borderSize' => 12)); diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php index c0b6cf3ad7..ac0d274a0a 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -6,7 +6,7 @@ // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Ads styles $phpWord->addParagraphStyle('pStyle', array('spacing'=>100)); diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php index 2095f24a37..3148177c8b 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -6,7 +6,7 @@ // New Word Document echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); $filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . 'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' . 'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. ' . diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php index 9fc2cc5723..b6d8aba46d 100755 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -6,7 +6,7 @@ // New Word Document echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // New portrait section $section = $phpWord->createSection(); diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php index f2feb1558d..bbe94a0f78 100755 --- a/samples/Sample_07_TemplateCloneRow.php +++ b/samples/Sample_07_TemplateCloneRow.php @@ -6,7 +6,7 @@ // New Word document echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); $document = $phpWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx'); diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index cb52f7f0f1..588370f600 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -6,7 +6,7 @@ // New Word document echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); $phpWord->setDefaultParagraphStyle(array( 'align' => 'both', 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12), diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index ec65e104e4..a184be5a81 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -6,7 +6,7 @@ // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); $section = $phpWord->createSection(); $header = array('size' => 16, 'bold' => true); diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php index e3d192605f..48a19539f8 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -6,7 +6,7 @@ // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); $section = $phpWord->createSection(); $header = array('size' => 16, 'bold' => true); //1.Use EastAisa FontStyle diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index 86ff9190e0..73589d9930 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -6,7 +6,7 @@ // New Word document echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // New portrait section $section = $phpWord->createSection(); diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index 744b8b379f..5bd480d831 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -10,7 +10,7 @@ // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index 78dca727bb..f3894d25ae 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -10,7 +10,7 @@ // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php index 2907fc4ecd..69916ae69e 100644 --- a/samples/Sample_15_Link.php +++ b/samples/Sample_15_Link.php @@ -10,7 +10,7 @@ // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php index 06206d9c8b..29d627051f 100644 --- a/samples/Sample_16_Object.php +++ b/samples/Sample_16_Object.php @@ -10,7 +10,7 @@ // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php index a3aa36c33d..cbed2d7fab 100644 --- a/samples/Sample_17_TitleTOC.php +++ b/samples/Sample_17_TitleTOC.php @@ -10,7 +10,7 @@ // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php index 667b7c65b6..e80a0530b1 100644 --- a/samples/Sample_18_Watermark.php +++ b/samples/Sample_18_Watermark.php @@ -10,7 +10,7 @@ // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Begin code diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php index 78f689aa15..d6bdafc423 100644 --- a/samples/Sample_19_TextBreak.php +++ b/samples/Sample_19_TextBreak.php @@ -10,7 +10,7 @@ // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord(); +$phpWord = new PhpOffice\PhpWord\PhpWord(); // Begin code $fontStyle = array('size' => 24); From 7e23484619904702dde3c37b68bdd11739654912 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 22 Mar 2014 16:13:43 +0400 Subject: [PATCH 13/15] https://github.com/PHPOffice/PHPWord/issues/58 - fix for ZipArchive calls. --- src/Reader/Word2007.php | 4 ++-- src/Shared/ZipStreamWrapper.php | 2 +- src/Template.php | 4 ++-- src/Writer/ODText.php | 10 +++++----- src/Writer/Word2007.php | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Reader/Word2007.php b/src/Reader/Word2007.php index 2620b58021..f978e03d82 100644 --- a/src/Reader/Word2007.php +++ b/src/Reader/Word2007.php @@ -55,7 +55,7 @@ public function canRead($pFilename) $return = false; // Load file - $zip = new ZipArchive(); + $zip = new \ZipArchive(); if ($zip->open($pFilename) === true) { // check if it is an OOXML archive $rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels")); @@ -120,7 +120,7 @@ public function load($pFilename) // Initialisations $word = new PhpWord(); - $zip = new ZipArchive(); + $zip = new \ZipArchive(); $zip->open($pFilename); // Read properties and documents diff --git a/src/Shared/ZipStreamWrapper.php b/src/Shared/ZipStreamWrapper.php index 4a8bac6c3f..2676ac552f 100644 --- a/src/Shared/ZipStreamWrapper.php +++ b/src/Shared/ZipStreamWrapper.php @@ -99,7 +99,7 @@ public function stream_open($path, $mode, $options, &$opened_path) } // Open archive - $this->_archive = new ZipArchive(); + $this->_archive = new \ZipArchive(); $this->_archive->open($url['host']); $this->_fileNameInArchive = $url['fragment']; diff --git a/src/Template.php b/src/Template.php index f934257ec5..a248de7f42 100644 --- a/src/Template.php +++ b/src/Template.php @@ -35,7 +35,7 @@ class Template /** * ZipArchive * - * @var ZipArchive + * @var \ZipArchive */ private $_objZip; @@ -72,7 +72,7 @@ public function __construct($strFilename) throw new Exception("Could not copy the template from {$strFilename} to {$this->_tempFileName}."); } - $this->_objZip = new ZipArchive(); + $this->_objZip = new \ZipArchive(); $this->_objZip->open($this->_tempFileName); $this->_documentXML = $this->_objZip->getFromName('word/document.xml'); diff --git a/src/Writer/ODText.php b/src/Writer/ODText.php index 312b3d5f56..c8a2c75a2b 100644 --- a/src/Writer/ODText.php +++ b/src/Writer/ODText.php @@ -115,17 +115,17 @@ public function save($pFilename = null) // Create drawing dictionary // Create new ZIP file and open it for writing - $objZip = new ZipArchive(); + $objZip = new \ZipArchive(); // Try opening the ZIP file - if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { - if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { + if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) { + if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) { throw new \Exception("Could not open " . $pFilename . " for writing."); } } // Add mimetype to ZIP file - //@todo Not in ZIPARCHIVE::CM_STORE mode + //@todo Not in \ZipArchive::CM_STORE mode $objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype($this->_document)); // Add content.xml to ZIP file @@ -151,7 +151,7 @@ public function save($pFilename = null) $imagePath = substr($imagePath, 6); $imagePathSplitted = explode('#', $imagePath); - $imageZip = new ZipArchive(); + $imageZip = new \ZipArchive(); $imageZip->open($imagePathSplitted[0]); $imageContents = $imageZip->getFromName($imagePathSplitted[1]); $imageZip->close(); diff --git a/src/Writer/Word2007.php b/src/Writer/Word2007.php index be14287083..de31e71e53 100644 --- a/src/Writer/Word2007.php +++ b/src/Writer/Word2007.php @@ -86,11 +86,11 @@ public function save($pFilename = null) } // Create new ZIP file and open it for writing - $objZip = new ZipArchive(); + $objZip = new \ZipArchive(); // Try opening the ZIP file - if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { - if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { + if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) { + if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) { throw new Exception("Could not open " . $pFilename . " for writing."); } } From ddb6277764bbec17975112f44302a5386020f0bd Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Mar 2014 10:32:08 +0400 Subject: [PATCH 14/15] https://github.com/PHPOffice/PHPWord/issues/58 - More fixes. --- README.md | 10 +- Tests/PhpWord/DocumentPropertiesTest.php | 3 +- Tests/PhpWord/Exceptions/ExceptionTest.php | 4 +- .../Exceptions/InvalidImageExceptionTest.php | 4 +- .../Exceptions/InvalidStyleExceptionTest.php | 4 +- .../UnsupportedImageTypeExceptionTest.php | 4 +- Tests/PhpWord/IOFactoryTest.php | 7 +- Tests/PhpWord/MediaTest.php | 2 +- Tests/PhpWord/Reader/Word2007Test.php | 22 ++-- Tests/PhpWord/Section/ImageTest.php | 8 +- Tests/PhpWord/Section/ListItemTest.php | 2 +- Tests/PhpWord/Section/TextBreakTest.php | 3 +- Tests/PhpWord/SectionTest.php | 7 +- Tests/PhpWord/SettingsTest.php | 3 +- Tests/PhpWord/Shared/DrawingTest.php | 1 - Tests/PhpWord/Shared/FileTest.php | 11 +- Tests/PhpWord/Shared/FontTest.php | 1 - Tests/PhpWord/Shared/StringTest.php | 3 +- Tests/PhpWord/Style/CellTest.php | 1 - Tests/PhpWord/Style/FontTest.php | 1 - Tests/PhpWord/Style/ImageTest.php | 3 +- Tests/PhpWord/Style/ListItemTest.php | 1 - Tests/PhpWord/Style/ParagraphTest.php | 1 - Tests/PhpWord/Style/RowTest.php | 1 - Tests/PhpWord/Style/TOCTest.php | 7 +- Tests/PhpWord/Style/TableFullTest.php | 1 - Tests/PhpWord/Style/TableTest.php | 1 - Tests/PhpWord/Style/TabsTest.php | 1 - Tests/PhpWord/StyleTest.php | 3 +- Tests/PhpWord/TOCTest.php | 14 +-- Tests/PhpWord/TemplateTest.php | 10 +- Tests/PhpWord/Writer/ODText/ContentTest.php | 3 +- Tests/PhpWord/Writer/ODTextTest.php | 9 +- Tests/PhpWord/Writer/RTFTest.php | 7 +- Tests/PhpWord/Writer/Word2007/BaseTest.php | 7 +- .../PhpWord/Writer/Word2007/DocumentTest.php | 3 +- .../PhpWord/Writer/Word2007/FootnotesTest.php | 1 - Tests/PhpWord/Writer/Word2007/StylesTest.php | 1 - Tests/PhpWord/Writer/Word2007Test.php | 5 +- Tests/PhpWordTest.php | 5 +- Tests/_inc/TestHelperDOCX.php | 4 +- Tests/_inc/XmlDocument.php | 6 +- Tests/bootstrap.php | 2 +- samples/Sample_01_SimpleText.php | 16 +-- samples/Sample_02_TabStops.php | 26 ++--- samples/Sample_03_Sections.php | 16 +-- samples/Sample_04_Textrun.php | 18 +-- samples/Sample_05_Multicolumn.php | 16 +-- samples/Sample_06_Footnote.php | 18 +-- samples/Sample_07_TemplateCloneRow.php | 14 +-- samples/Sample_08_ParagraphPagination.php | 18 +-- samples/Sample_09_Tables.php | 18 +-- samples/Sample_10_EastAsianFontStyle.php | 16 +-- samples/Sample_11_ReadWord2007.php | 16 +-- samples/Sample_12_HeaderFooter.php | 16 +-- samples/Sample_13_Images.php | 16 +-- samples/Sample_14_ListItem.php | 20 ++-- samples/Sample_15_Link.php | 18 +-- samples/Sample_16_Object.php | 16 +-- samples/Sample_17_TitleTOC.php | 18 +-- samples/Sample_18_Watermark.php | 16 +-- samples/Sample_19_TextBreak.php | 16 +-- src/Autoloader.php | 2 - src/DocumentProperties.php | 40 ++++--- src/Exceptions/InvalidImageException.php | 4 - src/Exceptions/InvalidStyleException.php | 4 - .../UnsupportedImageTypeException.php | 4 - src/Footnote.php | 4 +- src/HashTable.php | 23 ++-- src/IOFactory.php | 15 +-- src/Media.php | 36 +++--- src/PhpWord.php | 24 ++-- src/Reader/AbstractReader.php | 6 +- src/Reader/IReader.php | 8 +- src/Reader/Word2007.php | 14 +-- src/Section.php | 52 ++++----- src/Section/Footer.php | 19 ++-- src/Section/Footer/PreserveText.php | 12 +- src/Section/Footnote.php | 14 +-- src/Section/Header.php | 21 ++-- src/Section/Image.php | 13 +-- src/Section/Link.php | 10 +- src/Section/ListItem.php | 8 +- src/Section/MemoryImage.php | 6 +- src/Section/Object.php | 6 +- src/Section/PageBreak.php | 5 - src/Section/Settings.php | 2 - src/Section/Table.php | 10 +- src/Section/Table/Cell.php | 29 +++-- src/Section/Table/Row.php | 10 +- src/Section/Text.php | 24 ++-- src/Section/TextBreak.php | 20 ++-- src/Section/TextRun.php | 23 ++-- src/Section/Title.php | 2 - src/Settings.php | 2 - src/Shared/Drawing.php | 2 - src/Shared/File.php | 4 +- src/Shared/Font.php | 2 - src/Shared/String.php | 2 - src/Shared/XMLWriter.php | 10 +- src/Shared/ZipStreamWrapper.php | 12 +- src/Style.php | 4 +- src/Style/Cell.php | 2 - src/Style/Font.php | 106 +++++------------- src/Style/Image.php | 6 +- src/Style/ListItem.php | 2 - src/Style/Paragraph.php | 32 +++--- src/Style/Row.php | 2 - src/Style/TOC.php | 2 - src/Style/Tab.php | 4 +- src/Style/Table.php | 2 - src/Style/TableFull.php | 8 +- src/Style/Tabs.php | 4 +- src/TOC.php | 8 +- src/Template.php | 28 ++--- src/Writer/IWriter.php | 3 - src/Writer/ODText.php | 41 ++++--- src/Writer/ODText/Content.php | 17 ++- src/Writer/ODText/Manifest.php | 14 +-- src/Writer/ODText/Meta.php | 5 +- src/Writer/ODText/Mimetype.php | 8 +- src/Writer/ODText/Styles.php | 5 +- src/Writer/ODText/WriterPart.php | 14 +-- src/Writer/RTF.php | 52 +++++---- src/Writer/Word2007.php | 13 +-- src/Writer/Word2007/Base.php | 24 ++-- src/Writer/Word2007/ContentTypes.php | 27 +++-- src/Writer/Word2007/DocProps.php | 2 - src/Writer/Word2007/Document.php | 3 +- src/Writer/Word2007/DocumentRels.php | 5 +- src/Writer/Word2007/Footer.php | 4 +- src/Writer/Word2007/Footnotes.php | 3 - src/Writer/Word2007/FootnotesRels.php | 5 +- src/Writer/Word2007/Header.php | 4 +- src/Writer/Word2007/Rels.php | 17 ++- src/Writer/Word2007/Styles.php | 5 +- src/Writer/Word2007/WriterPart.php | 5 +- 137 files changed, 626 insertions(+), 889 deletions(-) diff --git a/README.md b/README.md index 2ee8e766b0..9b11d116af 100755 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ $section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle'); // You can also put the appended element to local object like this: -$fontStyle = new PhpOffice\PhpWord\Style\Font(); +$fontStyle = new \PhpOffice\PhpWord\Style\Font(); $fontStyle->setBold(true); $fontStyle->setName('Verdana'); $fontStyle->setSize(22); @@ -111,7 +111,7 @@ $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); // Finally, write the document: -$xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); +$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $xmlWriter->save('helloWorld.docx'); ``` @@ -125,15 +125,15 @@ You can use PhpWord helper functions to convert inches, centimeters, or points t ```php // Paragraph with 6 points space after $phpWord->addParagraphStyle('My Style', array( - 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6)) + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6)) ); $section = $phpWord->createSection(); $sectionStyle = $section->getSettings(); // half inch left margin -$sectionStyle->setMarginLeft(PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); +$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); // 2 cm right margin -$sectionStyle->setMarginRight(PhpOffice\PhpWord\Shared\Font::centimeterSizeToTwips(2)); +$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Font::centimeterSizeToTwips(2)); ``` diff --git a/Tests/PhpWord/DocumentPropertiesTest.php b/Tests/PhpWord/DocumentPropertiesTest.php index b8ad93743c..f6e6ba3c16 100644 --- a/Tests/PhpWord/DocumentPropertiesTest.php +++ b/Tests/PhpWord/DocumentPropertiesTest.php @@ -4,8 +4,7 @@ use PhpOffice\PhpWord\DocumentProperties; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\DocumentProperties + * @coversDefaultClass \PhpOffice\PhpWord\DocumentProperties * @runTestsInSeparateProcesses */ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Exceptions/ExceptionTest.php b/Tests/PhpWord/Exceptions/ExceptionTest.php index 12dcbf48da..bea725c963 100644 --- a/Tests/PhpWord/Exceptions/ExceptionTest.php +++ b/Tests/PhpWord/Exceptions/ExceptionTest.php @@ -6,8 +6,8 @@ class ExceptionTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException PhpOffice\PhpWord\Exceptions\Exception - * @covers PhpOffice\PhpWord\Exceptions\Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception + * @covers \PhpOffice\PhpWord\Exceptions\Exception */ public function testThrowException() { diff --git a/Tests/PhpWord/Exceptions/InvalidImageExceptionTest.php b/Tests/PhpWord/Exceptions/InvalidImageExceptionTest.php index e6257fa82d..f804d56d13 100644 --- a/Tests/PhpWord/Exceptions/InvalidImageExceptionTest.php +++ b/Tests/PhpWord/Exceptions/InvalidImageExceptionTest.php @@ -6,8 +6,8 @@ class InvalidImageExceptionTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException PhpOffice\PhpWord\Exceptions\InvalidImageException - * @covers PhpOffice\PhpWord\Exceptions\InvalidImageException + * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidImageException + * @covers \PhpOffice\PhpWord\Exceptions\InvalidImageException */ public function testThrowException() { diff --git a/Tests/PhpWord/Exceptions/InvalidStyleExceptionTest.php b/Tests/PhpWord/Exceptions/InvalidStyleExceptionTest.php index 7a0e774190..2572bdf367 100644 --- a/Tests/PhpWord/Exceptions/InvalidStyleExceptionTest.php +++ b/Tests/PhpWord/Exceptions/InvalidStyleExceptionTest.php @@ -6,8 +6,8 @@ class InvalidStyleExceptionTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException PhpOffice\PhpWord\Exceptions\InvalidStyleException - * @covers PhpOffice\PhpWord\Exceptions\InvalidStyleException + * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidStyleException + * @covers \PhpOffice\PhpWord\Exceptions\InvalidStyleException */ public function testThrowException() { diff --git a/Tests/PhpWord/Exceptions/UnsupportedImageTypeExceptionTest.php b/Tests/PhpWord/Exceptions/UnsupportedImageTypeExceptionTest.php index d5e935063d..7d314fa071 100644 --- a/Tests/PhpWord/Exceptions/UnsupportedImageTypeExceptionTest.php +++ b/Tests/PhpWord/Exceptions/UnsupportedImageTypeExceptionTest.php @@ -6,8 +6,8 @@ class UnsupportedImageTypeExceptionTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException - * @covers PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException + * @expectedException \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException + * @covers \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException */ public function testThrowException() { diff --git a/Tests/PhpWord/IOFactoryTest.php b/Tests/PhpWord/IOFactoryTest.php index d10bcfebe0..db90c47036 100644 --- a/Tests/PhpWord/IOFactoryTest.php +++ b/Tests/PhpWord/IOFactoryTest.php @@ -5,8 +5,7 @@ use PhpOffice\PhpWord\IOFactory; /** - * @@coversDefaultClass PhpOffice\PhpWord\IOFactory - * @package PhpWord\Tests + * @coversDefaultClass \PhpOffice\PhpWord\IOFactory * @runTestsInSeparateProcesses */ final class IOFactoryTest extends \PHPUnit_Framework_TestCase @@ -24,7 +23,7 @@ final public function testExistingWriterCanBeCreated() /** * @covers ::createWriter - * @expectedException PhpOffice\PhpWord\Exceptions\Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedExceptionMessage Could not instantiate "Word2006" class. */ final public function testNonexistentWriterCanNotBeCreated() @@ -45,7 +44,7 @@ final public function testExistingReaderCanBeCreated() /** * @covers ::createReader - * @expectedException PhpOffice\PhpWord\Exceptions\Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedExceptionMessage Could not instantiate "Word2006" class. */ final public function testNonexistentReaderCanNotBeCreated() diff --git a/Tests/PhpWord/MediaTest.php b/Tests/PhpWord/MediaTest.php index 6dd33aa689..179fbc020d 100644 --- a/Tests/PhpWord/MediaTest.php +++ b/Tests/PhpWord/MediaTest.php @@ -37,7 +37,7 @@ public function testGetFooterMediaElements() /** * Todo: add memory image to this test * - * @covers PhpOffice\PhpWord\Media::addSectionMediaElement + * @covers \PhpOffice\PhpWord\Media::addSectionMediaElement */ public function testAddSectionMediaElement() { diff --git a/Tests/PhpWord/Reader/Word2007Test.php b/Tests/PhpWord/Reader/Word2007Test.php index 40219d340b..63f771d2e4 100644 --- a/Tests/PhpWord/Reader/Word2007Test.php +++ b/Tests/PhpWord/Reader/Word2007Test.php @@ -4,14 +4,8 @@ use PhpOffice\PhpWord\Reader\Word2007; use PhpOffice\PhpWord\IOFactory; -/** - * @package PhpWord\Tests - */ class Word2007Test extends \PHPUnit_Framework_TestCase { - /** @var Test file directory */ - private $dir; - /** * Init */ @@ -25,27 +19,25 @@ public function tearDown() public function testCanRead() { $dir = join( - DIRECTORY_SEPARATOR, + \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents') ); $object = new Word2007; - $file = $dir . DIRECTORY_SEPARATOR . 'reader.docx'; + $file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx'; $this->assertTrue($object->canRead($file)); } /** - * Test canRead() failure - * - * @expectedException Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception */ public function testCanReadFailed() { $dir = join( - DIRECTORY_SEPARATOR, + \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents') ); $object = new Word2007; - $file = $dir . DIRECTORY_SEPARATOR . 'foo.docx'; + $file = $dir . \DIRECTORY_SEPARATOR . 'foo.docx'; $this->assertFalse($object->canRead($file)); $object = IOFactory::load($file); } @@ -56,10 +48,10 @@ public function testCanReadFailed() public function testLoad() { $dir = join( - DIRECTORY_SEPARATOR, + \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents') ); - $file = $dir . DIRECTORY_SEPARATOR . 'reader.docx'; + $file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx'; $object = IOFactory::load($file); $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object); } diff --git a/Tests/PhpWord/Section/ImageTest.php b/Tests/PhpWord/Section/ImageTest.php index 4067f2183a..d341a8ed1a 100644 --- a/Tests/PhpWord/Section/ImageTest.php +++ b/Tests/PhpWord/Section/ImageTest.php @@ -4,7 +4,7 @@ use PhpOffice\PhpWord\Section\Image; /** - * @coversDefaultClass PhpOffice\PhpWord\Section\Image + * @coversDefaultClass \PhpOffice\PhpWord\Section\Image */ class ImageTest extends \PHPUnit_Framework_TestCase { @@ -32,7 +32,7 @@ public function testConstructWithStyle() $oImage = new Image( $src, array('width' => 210, 'height' => 210, 'align' => 'center', - 'wrappingStyle' => PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND) + 'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND) ); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle()); @@ -52,7 +52,7 @@ public function testValidImageTypes() } /** - * @expectedException PhpOffice\PhpWord\Exceptions\InvalidImageException + * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidImageException * @covers ::__construct */ public function testImageNotFound() @@ -61,7 +61,7 @@ public function testImageNotFound() } /** - * @expectedException PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException + * @expectedException \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException * @covers ::__construct */ public function testInvalidImageTypes() diff --git a/Tests/PhpWord/Section/ListItemTest.php b/Tests/PhpWord/Section/ListItemTest.php index 3b2fff10d8..ff65bfb89c 100644 --- a/Tests/PhpWord/Section/ListItemTest.php +++ b/Tests/PhpWord/Section/ListItemTest.php @@ -18,7 +18,7 @@ public function testStyle() 'text', 1, null, - array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER) + array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER) ); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\ListItem', $oListItem->getStyle()); diff --git a/Tests/PhpWord/Section/TextBreakTest.php b/Tests/PhpWord/Section/TextBreakTest.php index 38640381bb..ceb0ea94d4 100644 --- a/Tests/PhpWord/Section/TextBreakTest.php +++ b/Tests/PhpWord/Section/TextBreakTest.php @@ -6,8 +6,7 @@ use PhpOffice\PhpWord\Style\Paragraph; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Section\TextBreak + * @coversDefaultClass \PhpOffice\PhpWord\Section\TextBreak * @runTestsInSeparateProcesses */ class TextBreakTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/SectionTest.php b/Tests/PhpWord/SectionTest.php index dc90f808ab..55d649e1f8 100644 --- a/Tests/PhpWord/SectionTest.php +++ b/Tests/PhpWord/SectionTest.php @@ -4,8 +4,7 @@ use PhpOffice\PhpWord\Section; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Section + * @coversDefaultClass \PhpOffice\PhpWord\Section * @runTestsInSeparateProcesses */ class SectionTest extends \PHPUnit_Framework_TestCase @@ -75,11 +74,11 @@ public function testSetSettings() public function testAddElements() { $objectSource = join( - DIRECTORY_SEPARATOR, + \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); $imageSource = join( - DIRECTORY_SEPARATOR, + \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'PhpWord.png') ); $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif'; diff --git a/Tests/PhpWord/SettingsTest.php b/Tests/PhpWord/SettingsTest.php index 13f8dd52b2..bd33cb61f3 100644 --- a/Tests/PhpWord/SettingsTest.php +++ b/Tests/PhpWord/SettingsTest.php @@ -4,8 +4,7 @@ use PhpOffice\PhpWord\Settings; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Settings + * @coversDefaultClass \PhpOffice\PhpWord\Settings * @runTestsInSeparateProcesses */ class SettingsTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Shared/DrawingTest.php b/Tests/PhpWord/Shared/DrawingTest.php index 95dc30f16f..5c7001ed47 100644 --- a/Tests/PhpWord/Shared/DrawingTest.php +++ b/Tests/PhpWord/Shared/DrawingTest.php @@ -4,7 +4,6 @@ use PhpOffice\PhpWord\Shared\Drawing; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class DrawingTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Shared/FileTest.php b/Tests/PhpWord/Shared/FileTest.php index 197a318e91..579f266200 100644 --- a/Tests/PhpWord/Shared/FileTest.php +++ b/Tests/PhpWord/Shared/FileTest.php @@ -4,8 +4,7 @@ use PhpOffice\PhpWord\Shared\File; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Shared\File + * @coversDefaultClass \PhpOffice\PhpWord\Shared\File * @runTestsInSeparateProcesses */ class FileTest extends \PHPUnit_Framework_TestCase @@ -15,7 +14,7 @@ class FileTest extends \PHPUnit_Framework_TestCase */ public function testFileExists() { - $dir = join(DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates')); + $dir = join(\DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates')); chdir($dir); $this->assertTrue(File::file_exists('blank.docx')); } @@ -24,7 +23,7 @@ public function testFileExists() */ public function testNoFileExists() { - $dir = join(DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates')); + $dir = join(\DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates')); chdir($dir); $this->assertFalse(File::file_exists('404.docx')); } @@ -34,10 +33,10 @@ public function testNoFileExists() */ public function testRealpath() { - $dir = join(DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates')); + $dir = join(\DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'templates')); chdir($dir); $file = 'blank.docx'; - $expected = $dir . DIRECTORY_SEPARATOR . $file; + $expected = $dir . \DIRECTORY_SEPARATOR . $file; $this->assertEquals($expected, File::realpath($file)); } } \ No newline at end of file diff --git a/Tests/PhpWord/Shared/FontTest.php b/Tests/PhpWord/Shared/FontTest.php index 0a662a3f8c..1ba4831024 100644 --- a/Tests/PhpWord/Shared/FontTest.php +++ b/Tests/PhpWord/Shared/FontTest.php @@ -5,7 +5,6 @@ use PhpOffice\PhpWord\Shared\Font; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class FontTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Shared/StringTest.php b/Tests/PhpWord/Shared/StringTest.php index dec719d80c..9da8502d1f 100644 --- a/Tests/PhpWord/Shared/StringTest.php +++ b/Tests/PhpWord/Shared/StringTest.php @@ -4,8 +4,7 @@ use PhpOffice\PhpWord\Shared\String; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Shared\String + * @coversDefaultClass \PhpOffice\PhpWord\Shared\String * @runTestsInSeparateProcesses */ class StringTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Style/CellTest.php b/Tests/PhpWord/Style/CellTest.php index 9da9eefd86..ee79ec3b56 100644 --- a/Tests/PhpWord/Style/CellTest.php +++ b/Tests/PhpWord/Style/CellTest.php @@ -4,7 +4,6 @@ use PhpOffice\PhpWord\Style\Cell; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class CellTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Style/FontTest.php b/Tests/PhpWord/Style/FontTest.php index 105c46d732..5bef23b19b 100644 --- a/Tests/PhpWord/Style/FontTest.php +++ b/Tests/PhpWord/Style/FontTest.php @@ -6,7 +6,6 @@ use PhpWord\Tests\TestHelperDOCX; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class FontTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Style/ImageTest.php b/Tests/PhpWord/Style/ImageTest.php index c06bba2e50..3b8cd96f7b 100644 --- a/Tests/PhpWord/Style/ImageTest.php +++ b/Tests/PhpWord/Style/ImageTest.php @@ -4,7 +4,6 @@ use PhpOffice\PhpWord\Style\Image; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class ImageTest extends \PHPUnit_Framework_TestCase @@ -56,7 +55,7 @@ public function testSetStyleValue() /** * Test setWrappingStyle exception * - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testSetWrappingStyleException() { diff --git a/Tests/PhpWord/Style/ListItemTest.php b/Tests/PhpWord/Style/ListItemTest.php index 6383fde887..5c7a3332ce 100644 --- a/Tests/PhpWord/Style/ListItemTest.php +++ b/Tests/PhpWord/Style/ListItemTest.php @@ -4,7 +4,6 @@ use PhpOffice\PhpWord\Style\ListItem; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class ListItemTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Style/ParagraphTest.php b/Tests/PhpWord/Style/ParagraphTest.php index 37d872635e..05eabbb357 100644 --- a/Tests/PhpWord/Style/ParagraphTest.php +++ b/Tests/PhpWord/Style/ParagraphTest.php @@ -7,7 +7,6 @@ use PhpWord\Tests\TestHelperDOCX; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class ParagraphTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Style/RowTest.php b/Tests/PhpWord/Style/RowTest.php index ca5f6a637c..b83f2e5ff8 100644 --- a/Tests/PhpWord/Style/RowTest.php +++ b/Tests/PhpWord/Style/RowTest.php @@ -4,7 +4,6 @@ use PhpOffice\PhpWord\Style\Row; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class RowTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Style/TOCTest.php b/Tests/PhpWord/Style/TOCTest.php index 68650ddbe2..6f2520738f 100644 --- a/Tests/PhpWord/Style/TOCTest.php +++ b/Tests/PhpWord/Style/TOCTest.php @@ -4,8 +4,7 @@ use PhpOffice\PhpWord\Style\TOC; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Style\TOC + * @coversDefaultClass \PhpOffice\PhpWord\Style\TOC * @runTestsInSeparateProcesses */ class TOCTest extends \PHPUnit_Framework_TestCase @@ -18,9 +17,9 @@ public function testProperties() $object = new TOC(); $properties = array( - 'tabPos' => 9062, + 'tabPos' => 9062, 'tabLeader' => TOC::TABLEADER_DOT, - 'indent' => 200, + 'indent' => 200, ); foreach ($properties as $key => $value) { // set/get diff --git a/Tests/PhpWord/Style/TableFullTest.php b/Tests/PhpWord/Style/TableFullTest.php index 8ea594ff1e..e84191e08e 100644 --- a/Tests/PhpWord/Style/TableFullTest.php +++ b/Tests/PhpWord/Style/TableFullTest.php @@ -4,7 +4,6 @@ use PhpOffice\PhpWord\Style\TableFull; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class TableFullTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Style/TableTest.php b/Tests/PhpWord/Style/TableTest.php index 0837b8536d..c9ea73018f 100644 --- a/Tests/PhpWord/Style/TableTest.php +++ b/Tests/PhpWord/Style/TableTest.php @@ -4,7 +4,6 @@ use PhpOffice\PhpWord\Style\Table; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class TableTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Style/TabsTest.php b/Tests/PhpWord/Style/TabsTest.php index 3bfb138e6b..dcecdf938d 100644 --- a/Tests/PhpWord/Style/TabsTest.php +++ b/Tests/PhpWord/Style/TabsTest.php @@ -6,7 +6,6 @@ use PhpWord\Tests\TestHelperDOCX; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class TabsTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/StyleTest.php b/Tests/PhpWord/StyleTest.php index 226387d092..bd24188fb3 100644 --- a/Tests/PhpWord/StyleTest.php +++ b/Tests/PhpWord/StyleTest.php @@ -4,8 +4,7 @@ use PhpOffice\PhpWord\Style; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Style + * @coversDefaultClass \PhpOffice\PhpWord\Style * @runTestsInSeparateProcesses */ class StyleTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/TOCTest.php b/Tests/PhpWord/TOCTest.php index d519cdf16c..7007e03b41 100644 --- a/Tests/PhpWord/TOCTest.php +++ b/Tests/PhpWord/TOCTest.php @@ -4,8 +4,7 @@ use PhpOffice\PhpWord\TOC; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\TOC + * @coversDefaultClass \PhpOffice\PhpWord\TOC * @runTestsInSeparateProcesses */ class TOCTest extends \PHPUnit_Framework_TestCase @@ -18,14 +17,11 @@ class TOCTest extends \PHPUnit_Framework_TestCase public function testConstruct() { $expected = array( - 'tabPos' => 9062, - 'tabLeader' => PhpOffice\PhpWord\Style\TOC::TABLEADER_DOT, - 'indent' => 200, - ); - $object = new TOC( - array('size' => 11), - array('tabPos' => $expected['tabPos']) + 'tabPos' => 9062, + 'tabLeader' => \PhpOffice\PhpWord\Style\TOC::TABLEADER_DOT, + 'indent' => 200, ); + $object = new TOC(array('size' => 11), array('tabPos' => $expected['tabPos'])); $tocStyle = $object->getStyleTOC(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TOC', $tocStyle); diff --git a/Tests/PhpWord/TemplateTest.php b/Tests/PhpWord/TemplateTest.php index d15185ec57..ebb0c6659b 100644 --- a/Tests/PhpWord/TemplateTest.php +++ b/Tests/PhpWord/TemplateTest.php @@ -5,7 +5,7 @@ use PhpOffice\PhpWord\Template; /** - * @coversDefaultClass PhpOffice\PhpWord\Template + * @coversDefaultClass \PhpOffice\PhpWord\Template */ final class TemplateTest extends \PHPUnit_Framework_TestCase { @@ -87,7 +87,7 @@ final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn) /** * @covers ::applyXslStyleSheet - * @expectedException Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedExceptionMessage Could not set values for the given XSL style sheet parameters. * @test */ @@ -109,7 +109,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete ); /* - * We have to use error control below, because XSLTProcessor::setParameter omits warning on failure. + * We have to use error control below, because \XSLTProcessor::setParameter omits warning on failure. * This warning fails the test. */ @$template->applyXslStyleSheet($xslDOMDocument, array(1 => 'somevalue')); @@ -117,7 +117,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete /** * @covers ::applyXslStyleSheet - * @expectedException Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedExceptionMessage Could not load XML from the given template. * @test */ @@ -139,7 +139,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromT ); /* - * We have to use error control below, because DOMDocument::loadXML omits warning on failure. + * We have to use error control below, because \DOMDocument::loadXML omits warning on failure. * This warning fails the test. */ @$template->applyXslStyleSheet($xslDOMDocument); diff --git a/Tests/PhpWord/Writer/ODText/ContentTest.php b/Tests/PhpWord/Writer/ODText/ContentTest.php index ce3a7b3b90..64f224ca88 100644 --- a/Tests/PhpWord/Writer/ODText/ContentTest.php +++ b/Tests/PhpWord/Writer/ODText/ContentTest.php @@ -5,8 +5,7 @@ use PhpWord\Tests\TestHelperDOCX; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Writer\ODText\Content + * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Content * @runTestsInSeparateProcesses */ class ContentTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Writer/ODTextTest.php b/Tests/PhpWord/Writer/ODTextTest.php index 0338f4e03b..631360d8b4 100644 --- a/Tests/PhpWord/Writer/ODTextTest.php +++ b/Tests/PhpWord/Writer/ODTextTest.php @@ -5,8 +5,7 @@ use PhpOffice\PhpWord\Writer\ODText; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Writer\ODText + * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText * @runTestsInSeparateProcesses */ class ODTextTest extends \PHPUnit_Framework_TestCase @@ -36,7 +35,7 @@ public function testConstruct() /** * @covers ::getPhpWord - * @expectedException Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedExceptionMessage No PhpWord assigned. */ public function testConstructWithNull() @@ -104,7 +103,7 @@ public function testSavePhpOutput() /** * @covers ::save - * @expectedException Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedExceptionMessage PhpWord object unassigned. */ public function testSaveException() @@ -136,7 +135,7 @@ public function testSetGetUseDiskCaching() /** * @covers ::setUseDiskCaching - * @expectedException Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception */ public function testSetUseDiskCachingException() { diff --git a/Tests/PhpWord/Writer/RTFTest.php b/Tests/PhpWord/Writer/RTFTest.php index 3b6cb723de..656f6d4710 100644 --- a/Tests/PhpWord/Writer/RTFTest.php +++ b/Tests/PhpWord/Writer/RTFTest.php @@ -5,8 +5,7 @@ use PhpOffice\PhpWord\Writer\RTF; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Writer\RTF + * @coversDefaultClass \PhpOffice\PhpWord\Writer\RTF * @runTestsInSeparateProcesses */ class RTFTest extends \PHPUnit_Framework_TestCase @@ -24,7 +23,7 @@ public function testConstruct() /** * covers ::__construct - * @expectedException Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedExceptionMessage No PhpWord assigned. */ public function testConstructWithNull() @@ -48,7 +47,7 @@ public function testSavePhpOutput() /** * @covers ::save - * @expectedException Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception * @expectedExceptionMessage PhpWord object unassigned. */ public function testSaveException() diff --git a/Tests/PhpWord/Writer/Word2007/BaseTest.php b/Tests/PhpWord/Writer/Word2007/BaseTest.php index 1d00e06ebd..ea44e9f19f 100644 --- a/Tests/PhpWord/Writer/Word2007/BaseTest.php +++ b/Tests/PhpWord/Writer/Word2007/BaseTest.php @@ -5,8 +5,7 @@ use PhpWord\Tests\TestHelperDOCX; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Writer\Word2007\Base + * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Base * @runTestsInSeparateProcesses */ class BaseTest extends \PHPUnit_Framework_TestCase @@ -48,7 +47,7 @@ public function testWriteTextRun() $pStyle = 'pStyle'; $aStyle = array('align' => 'justify', 'spaceBefore' => 120, 'spaceAfter' => 120); $imageSrc = join( - DIRECTORY_SEPARATOR, + \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); @@ -321,7 +320,7 @@ public function testWriteImagePosition() public function testWriteWatermark() { $imageSrc = join( - DIRECTORY_SEPARATOR, + \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'images', 'earth.jpg') ); diff --git a/Tests/PhpWord/Writer/Word2007/DocumentTest.php b/Tests/PhpWord/Writer/Word2007/DocumentTest.php index 056e7b55a3..e3eb847053 100644 --- a/Tests/PhpWord/Writer/Word2007/DocumentTest.php +++ b/Tests/PhpWord/Writer/Word2007/DocumentTest.php @@ -5,7 +5,6 @@ use PhpWord\Tests\TestHelperDOCX; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class DocumentTest extends \PHPUnit_Framework_TestCase @@ -40,7 +39,7 @@ public function testWriteEndSectionPageNumbering() public function testElements() { $objectSrc = join( - DIRECTORY_SEPARATOR, + \DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'sheet.xls') ); diff --git a/Tests/PhpWord/Writer/Word2007/FootnotesTest.php b/Tests/PhpWord/Writer/Word2007/FootnotesTest.php index fe4199868a..3913ff2c62 100644 --- a/Tests/PhpWord/Writer/Word2007/FootnotesTest.php +++ b/Tests/PhpWord/Writer/Word2007/FootnotesTest.php @@ -5,7 +5,6 @@ use PhpWord\Tests\TestHelperDOCX; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class FootnotesTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Writer/Word2007/StylesTest.php b/Tests/PhpWord/Writer/Word2007/StylesTest.php index cbebb19a28..5de21c7d52 100644 --- a/Tests/PhpWord/Writer/Word2007/StylesTest.php +++ b/Tests/PhpWord/Writer/Word2007/StylesTest.php @@ -5,7 +5,6 @@ use PhpWord\Tests\TestHelperDOCX; /** - * @package PhpWord\Tests * @runTestsInSeparateProcesses */ class StylesTest extends \PHPUnit_Framework_TestCase diff --git a/Tests/PhpWord/Writer/Word2007Test.php b/Tests/PhpWord/Writer/Word2007Test.php index a4365e4d81..9bdf74a286 100644 --- a/Tests/PhpWord/Writer/Word2007Test.php +++ b/Tests/PhpWord/Writer/Word2007Test.php @@ -6,8 +6,7 @@ use PhpWord\Tests\TestHelperDOCX; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord\Writer\Word2007 + * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007 * @runTestsInSeparateProcesses */ class Word2007Test extends \PHPUnit_Framework_TestCase @@ -118,7 +117,7 @@ public function testSetGetUseDiskCaching() /** * @covers ::setUseDiskCaching - * @expectedException Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception */ public function testSetUseDiskCachingException() { diff --git a/Tests/PhpWordTest.php b/Tests/PhpWordTest.php index 73841bd7a7..cc51755f27 100644 --- a/Tests/PhpWordTest.php +++ b/Tests/PhpWordTest.php @@ -7,8 +7,7 @@ use PhpOffice\PhpWord\Style; /** - * @package PhpWord\Tests - * @coversDefaultClass PhpOffice\PhpWord + * @coversDefaultClass \PhpOffice\PhpWord\PhpWord * @runTestsInSeparateProcesses */ class PhpWordTest extends \PHPUnit_Framework_TestCase @@ -144,7 +143,7 @@ public function testLoadTemplate() /** * @covers ::loadTemplate - * @expectedException PhpOffice\PhpWord\Exceptions\Exception + * @expectedException \PhpOffice\PhpWord\Exceptions\Exception */ public function testLoadTemplateException() { diff --git a/Tests/_inc/TestHelperDOCX.php b/Tests/_inc/TestHelperDOCX.php index 0e63dcf8d0..bd3d4f8caf 100644 --- a/Tests/_inc/TestHelperDOCX.php +++ b/Tests/_inc/TestHelperDOCX.php @@ -10,8 +10,8 @@ class TestHelperDOCX static protected $file; /** - * @param PhpOffice\PhpWord $phpWord - * @return PhpWord\Tests\XmlDocument + * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return \PhpWord\Tests\XmlDocument */ public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007') { diff --git a/Tests/_inc/XmlDocument.php b/Tests/_inc/XmlDocument.php index 3a6c182d4d..c6b1e83e20 100644 --- a/Tests/_inc/XmlDocument.php +++ b/Tests/_inc/XmlDocument.php @@ -1,8 +1,6 @@ file = $file; $file = $this->path . '/' . $file; - $this->dom = new DOMDocument(); + $this->dom = new \DOMDocument(); $this->dom->load($file); return $this->dom; } @@ -112,4 +110,4 @@ public function elementExists($path, $file = 'word/document.xml') $nodeList = $this->getNodeList($path, $file); return !($nodeList->length == 0); } -} +} \ No newline at end of file diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index c986ffcbe8..dd261c3b77 100755 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -8,7 +8,7 @@ // loading classes with PSR-4 autoloader require_once __DIR__ . '/../src/Autoloader.php'; -PhpOffice\PhpWord\Autoloader::register(); +\PhpOffice\PhpWord\Autoloader::register(); require_once __DIR__ . '/_inc/TestHelperDOCX.php'; require_once __DIR__ . '/_inc/XmlDocument.php'; \ No newline at end of file diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index bdb163ba15..a2fe9e9b3b 100755 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -1,12 +1,12 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word Document -echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , " Create new PhpWord object" , \EOL; +$phpWord = new \PhpOffice\PhpWord\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)); @@ -51,12 +51,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; \ No newline at end of file +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; \ No newline at end of file diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index 1026cc0916..24f47678f8 100755 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -1,29 +1,29 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // Ads styles $phpWord->addParagraphStyle('multipleTab', array( 'tabs' => array( - new PhpOffice\PhpWord\Style\Tab('left', 1550), - new PhpOffice\PhpWord\Style\Tab('center', 3200), - new PhpOffice\PhpWord\Style\Tab('right', 5300) + new \PhpOffice\PhpWord\Style\Tab('left', 1550), + new \PhpOffice\PhpWord\Style\Tab('center', 3200), + new \PhpOffice\PhpWord\Style\Tab('right', 5300) ) )); $phpWord->addParagraphStyle('rightTab', array( 'tabs' => array( - new PhpOffice\PhpWord\Style\Tab('right', 9090) + new \PhpOffice\PhpWord\Style\Tab('right', 9090) ) )); $phpWord->addParagraphStyle('centerTab', array( 'tabs' => array( - new PhpOffice\PhpWord\Style\Tab('center', 4680) + new \PhpOffice\PhpWord\Style\Tab('center', 4680) ) )); @@ -39,12 +39,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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 4d26945432..e3c1057c41 100755 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -1,12 +1,12 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section $section = $phpWord->createSection(array('borderColor' => '00FF00', 'borderSize' => 12)); @@ -32,12 +32,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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 ac0d274a0a..0d984dfe2b 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -1,18 +1,18 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // Ads styles $phpWord->addParagraphStyle('pStyle', array('spacing'=>100)); $phpWord->addFontStyle('BoldText', array('bold'=>true)); $phpWord->addFontStyle('ColoredText', array('color'=>'FF8080')); -$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); +$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); // New portrait section $section = $phpWord->createSection(); @@ -38,12 +38,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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 3148177c8b..2b630d2727 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -1,12 +1,12 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word Document -echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , " Create new PhpWord object" , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); $filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . 'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' . 'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. ' . @@ -42,12 +42,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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 b6d8aba46d..fd495afbf5 100755 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -1,12 +1,12 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word Document -echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , " Create new PhpWord object" , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section $section = $phpWord->createSection(); @@ -15,7 +15,7 @@ $phpWord->addParagraphStyle('pStyle', array('spacing'=>100)); $phpWord->addFontStyle('BoldText', array('bold'=>true)); $phpWord->addFontStyle('ColoredText', array('color'=>'FF8080')); -$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); +$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); // Add text elements $textrun = $section->createTextRun('pStyle'); @@ -40,12 +40,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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 bbe94a0f78..3dc92a06a3 100755 --- a/samples/Sample_07_TemplateCloneRow.php +++ b/samples/Sample_07_TemplateCloneRow.php @@ -1,12 +1,12 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , " Create new PhpWord object" , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); $document = $phpWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx'); @@ -57,10 +57,10 @@ $document->setValue('userPhone#3', '+1 428 889 775'); $name = 'Sample_07_TemplateCloneRow_result.docx'; -echo date('H:i:s'), " Write to Word2007 format", EOL; +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; +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 588370f600..e0d646cd2f 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -1,15 +1,15 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , " Create new PhpWord object" , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->setDefaultParagraphStyle(array( 'align' => 'both', - 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12), + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12), 'spacing' => 120, )); @@ -52,12 +52,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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 a184be5a81..a43b98d81f 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -1,12 +1,12 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->createSection(); $header = array('size' => 16, 'bold' => true); @@ -32,7 +32,7 @@ $styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80); $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF'); $styleCell = array('valign' => 'center'); -$styleCellBTLR = array('valign' => 'center', 'textDirection' => PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR); +$styleCellBTLR = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR); $fontStyle = array('bold' => true, 'align' => 'center'); $phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow); $table = $section->addTable('Fancy Table'); @@ -80,12 +80,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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 48a19539f8..6770d1ff6f 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -1,12 +1,12 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->createSection(); $header = array('size' => 16, 'bold' => true); //1.Use EastAisa FontStyle @@ -16,12 +16,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php index 3ba4905e52..980b1d4f3e 100644 --- a/samples/Sample_11_ReadWord2007.php +++ b/samples/Sample_11_ReadWord2007.php @@ -1,24 +1,24 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // Read contents $name = basename(__FILE__, '.php'); $source = "resources/{$name}.docx"; -echo date('H:i:s'), " Reading contents from `{$source}`", EOL; -$phpWord = PhpOffice\PhpWord\IOFactory::load($source); +echo date('H:i:s'), " Reading contents from `{$source}`", \EOL; +$phpWord = \PhpOffice\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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index 73589d9930..dd1b24d94b 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -1,12 +1,12 @@ '); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s') , " Create new PhpWord object" , EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s') , " Create new PhpWord object" , \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section $section = $phpWord->createSection(); @@ -63,12 +63,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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_13_Images.php b/samples/Sample_13_Images.php index 5bd480d831..e64f638639 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -4,13 +4,13 @@ */ // Init -error_reporting(E_ALL); -define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s'), " Create new PhpWord object", \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); @@ -31,12 +31,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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_14_ListItem.php b/samples/Sample_14_ListItem.php index f3894d25ae..7b23fb05ed 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -4,13 +4,13 @@ */ // Init -error_reporting(E_ALL); -define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s'), " Create new PhpWord object", \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); @@ -31,7 +31,7 @@ $section->addTextBreak(2); // Add listitem elements -$listStyle = array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER); +$listStyle = array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER); $section->addListItem('List Item 1', 0, null, $listStyle); $section->addListItem('List Item 2', 0, null, $listStyle); $section->addListItem('List Item 3', 0, null, $listStyle); @@ -40,7 +40,7 @@ // Add listitem elements $phpWord->addFontStyle('myOwnStyle', array('color'=>'FF0000')); $phpWord->addParagraphStyle('P-Style', array('spaceAfter'=>95)); -$listStyle = array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED); +$listStyle = array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED); $section->addListItem('List Item 1', 0, 'myOwnStyle', $listStyle, 'P-Style'); $section->addListItem('List Item 2', 0, 'myOwnStyle', $listStyle, 'P-Style'); $section->addListItem('List Item 3', 1, 'myOwnStyle', $listStyle, 'P-Style'); @@ -55,12 +55,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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_15_Link.php b/samples/Sample_15_Link.php index 69916ae69e..34519e8b86 100644 --- a/samples/Sample_15_Link.php +++ b/samples/Sample_15_Link.php @@ -4,19 +4,19 @@ */ // Init -error_reporting(E_ALL); -define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s'), " Create new PhpWord object", \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); // Add hyperlink elements -$section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); +$section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); $section->addTextBreak(2); $phpWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000')); @@ -29,12 +29,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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_16_Object.php b/samples/Sample_16_Object.php index 29d627051f..1d2a51cb24 100644 --- a/samples/Sample_16_Object.php +++ b/samples/Sample_16_Object.php @@ -4,13 +4,13 @@ */ // Init -error_reporting(E_ALL); -define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s'), " Create new PhpWord object", \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); @@ -24,12 +24,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php index cbed2d7fab..7cc89e14fe 100644 --- a/samples/Sample_17_TitleTOC.php +++ b/samples/Sample_17_TitleTOC.php @@ -4,13 +4,13 @@ */ // Init -error_reporting(E_ALL); -define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s'), " Create new PhpWord object", \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->createSection(); @@ -49,19 +49,19 @@ $section->addTitle('I am a Subtitle of Title 3', 2); $section->addText('Again and again, more text...'); -echo date('H:i:s'), " Note: Please refresh TOC manually.", EOL; +echo date('H:i:s'), " Note: Please refresh TOC manually.", \EOL; // End code // 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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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_18_Watermark.php b/samples/Sample_18_Watermark.php index e80a0530b1..60f735da39 100644 --- a/samples/Sample_18_Watermark.php +++ b/samples/Sample_18_Watermark.php @@ -4,13 +4,13 @@ */ // Init -error_reporting(E_ALL); -define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s'), " Create new PhpWord object", \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -25,12 +25,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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_19_TextBreak.php b/samples/Sample_19_TextBreak.php index d6bdafc423..7fffed6d3d 100644 --- a/samples/Sample_19_TextBreak.php +++ b/samples/Sample_19_TextBreak.php @@ -4,13 +4,13 @@ */ // Init -error_reporting(E_ALL); -define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
'); +error_reporting(\E_ALL); +define('EOL', (\PHP_SAPI == 'cli') ? \PHP_EOL : '
'); require_once '../src/PhpWord.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; -$phpWord = new PhpOffice\PhpWord\PhpWord(); +echo date('H:i:s'), " Create new PhpWord object", \EOL; +$phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code $fontStyle = array('size' => 24); @@ -38,12 +38,12 @@ $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; - $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + echo date('H:i:s'), " Write to {$writer} format", \EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->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; +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/src/Autoloader.php b/src/Autoloader.php index ace06fcc7e..cc82d23640 100644 --- a/src/Autoloader.php +++ b/src/Autoloader.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/DocumentProperties.php b/src/DocumentProperties.php index 25dddc2f98..6dc3160813 100644 --- a/src/DocumentProperties.php +++ b/src/DocumentProperties.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -152,8 +150,8 @@ public function getCreator() /** * Set Creator * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @param string $pValue + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setCreator($pValue = '') { @@ -174,8 +172,8 @@ public function getLastModifiedBy() /** * Set Last Modified By * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @param string $pValue + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setLastModifiedBy($pValue = '') { @@ -196,8 +194,8 @@ public function getCreated() /** * Set Created * - * @param datetime $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @param datetime $pValue + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setCreated($pValue = null) { @@ -221,8 +219,8 @@ public function getModified() /** * Set Modified * - * @param datetime $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @param datetime $pValue + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setModified($pValue = null) { @@ -246,8 +244,8 @@ public function getTitle() /** * Set Title * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @param string $pValue + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setTitle($pValue = '') { @@ -268,8 +266,8 @@ public function getDescription() /** * Set Description * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @param string $pValue + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setDescription($pValue = '') { @@ -290,8 +288,8 @@ public function getSubject() /** * Set Subject * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @param string $pValue + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setSubject($pValue = '') { @@ -313,7 +311,7 @@ public function getKeywords() * Set Keywords * * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setKeywords($pValue = '') { @@ -335,7 +333,7 @@ public function getCategory() * Set Category * * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setCategory($pValue = '') { @@ -357,7 +355,7 @@ public function getCompany() * Set Company * * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setCompany($pValue = '') { @@ -379,7 +377,7 @@ public function getManager() * Set Manager * * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setManager($pValue = '') { @@ -447,7 +445,7 @@ public function getCustomPropertyType($propertyName) * 's': String * 'd': Date/Time * 'b': Boolean - * @return PhpOffice\PhpWord\DocumentProperties + * @return \PhpOffice\PhpWord\DocumentProperties */ public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) { diff --git a/src/Exceptions/InvalidImageException.php b/src/Exceptions/InvalidImageException.php index aca82c8c59..11a2a660a2 100644 --- a/src/Exceptions/InvalidImageException.php +++ b/src/Exceptions/InvalidImageException.php @@ -2,11 +2,7 @@ namespace PhpOffice\PhpWord\Exceptions; /** - * InvalidImageException - * * Exception used for when an image is not found - * - * @package PhpWord */ class InvalidImageException extends Exception { diff --git a/src/Exceptions/InvalidStyleException.php b/src/Exceptions/InvalidStyleException.php index df405cf9e3..6eccb8e0a2 100644 --- a/src/Exceptions/InvalidStyleException.php +++ b/src/Exceptions/InvalidStyleException.php @@ -4,11 +4,7 @@ use InvalidArgumentException; /** - * InvalidStyleException - * * Exception used for when a style value is invalid - * - * @package PhpWord */ class InvalidStyleException extends InvalidArgumentException { diff --git a/src/Exceptions/UnsupportedImageTypeException.php b/src/Exceptions/UnsupportedImageTypeException.php index 1e126df7d4..80f459c5d0 100644 --- a/src/Exceptions/UnsupportedImageTypeException.php +++ b/src/Exceptions/UnsupportedImageTypeException.php @@ -2,11 +2,7 @@ namespace PhpOffice\PhpWord\Exceptions; /** - * UnsupportedImageTypeException - * * Exception used for when an image type is unsupported - * - * @package PhpWord */ class UnsupportedImageTypeException extends Exception { diff --git a/src/Footnote.php b/src/Footnote.php index a66a340f49..92aaadfc78 100644 --- a/src/Footnote.php +++ b/src/Footnote.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -51,7 +49,7 @@ class Footnote * * @return mixed */ - public static function addFootnoteElement(PhpOffice\PhpWord\Section\Footnote $footnote) + public static function addFootnoteElement(\PhpOffice\PhpWord\Section\Footnote $footnote) { $refID = self::countFootnoteElements() + 2; diff --git a/src/HashTable.php b/src/HashTable.php index 183820c461..4a8cca0708 100644 --- a/src/HashTable.php +++ b/src/HashTable.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,8 @@ namespace PhpOffice\PhpWord; +use PhpOffice\PhpWord\Exceptions\Exception; + /** * @codeCoverageIgnore Legacy from PHPExcel */ @@ -47,8 +47,7 @@ class HashTable public $_keyMap = array(); /** - * @param PhpOffice\PhpWord\IComparable[] $pSource Optional source array to create HashTable from - * @throws Exception + * @param \PhpOffice\PhpWord\IComparable[] $pSource Optional source array to create HashTable from */ public function __construct($pSource = null) { @@ -60,8 +59,8 @@ public function __construct($pSource = null) /** * Add HashTable items from source * - * @param PhpOffice\PhpWord\IComparable[] $pSource Source array to create HashTable from - * @throws Exception + * @param \PhpOffice\PhpWord\IComparable[] $pSource Source array to create HashTable from + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function addFromSource($pSource = null) { @@ -80,8 +79,7 @@ public function addFromSource($pSource = null) /** * Add HashTable item * - * @param PhpOffice\PhpWord\IComparable $pSource Item to add - * @throws Exception + * @param \PhpOffice\PhpWord\IComparable $pSource Item to add */ public function add(IComparable $pSource = null) { @@ -110,8 +108,7 @@ public function add(IComparable $pSource = null) /** * Remove HashTable item * - * @param PhpOffice\PhpWord\IComparable $pSource Item to remove - * @throws Exception + * @param \PhpOffice\PhpWord\IComparable $pSource Item to remove */ public function remove(IComparable $pSource = null) { @@ -161,7 +158,7 @@ public function getIndexForHashCode($pHashCode = '') /** * @param int $pIndex - * @return PhpOffice\PhpWord\IComparable + * @return \PhpOffice\PhpWord\IComparable */ public function getByIndex($pIndex = 0) { @@ -174,7 +171,7 @@ public function getByIndex($pIndex = 0) /** * @param string $pHashCode - * @return PhpOffice\PhpWord\IComparable + * @return \PhpOffice\PhpWord\IComparable * */ public function getByHashCode($pHashCode = '') @@ -187,7 +184,7 @@ public function getByHashCode($pHashCode = '') } /** - * @return PhpOffice\PhpWord\IComparable[] + * @return \PhpOffice\PhpWord\IComparable[] */ public function toArray() { diff --git a/src/IOFactory.php b/src/IOFactory.php index 88810f79f0..ffe825a09d 100644 --- a/src/IOFactory.php +++ b/src/IOFactory.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,16 +25,15 @@ namespace PhpOffice\PhpWord; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Exceptions\Exception; abstract class IOFactory { /** - * @param PhpOffice\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param string $name - * @return PhpOffice\PhpWord\Writer\IWriter - * @throws PhpOffice\PhpWord\Exceptions\Exception + * @return \PhpOffice\PhpWord\Writer\IWriter + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public static function createWriter(PhpWord $phpWord, $name) { @@ -51,8 +48,8 @@ public static function createWriter(PhpWord $phpWord, $name) /** * @param string $name - * @return PhpOffice\PhpWord\Reader\IReader - * @throws PhpOffice\PhpWord\Exceptions\Exception + * @return \PhpOffice\PhpWord\Reader\IReader + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public static function createReader($name) { @@ -70,7 +67,7 @@ public static function createReader($name) * * @param string $filename The name of the file * @param string $readerName - * @return PhpOffice\PhpWord + * @return \PhpOffice\PhpWord */ public static function load($filename, $readerName = 'Word2007') { diff --git a/src/Media.php b/src/Media.php index 2656b3fdd0..f7954df3d3 100644 --- a/src/Media.php +++ b/src/Media.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -37,9 +35,9 @@ class Media * @var array */ private static $_sectionMedia = array( - 'images' => array(), + 'images' => array(), 'embeddings' => array(), - 'links' => array() + 'links' => array() ); /** @@ -66,9 +64,9 @@ class Media /** * Add new Section Media Element * - * @param string $src - * @param string $type - * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage + * @param string $src + * @param string $type + * @param \PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage * @return mixed */ public static function addSectionMediaElement($src, $type, MemoryImage $memoryImage = null) @@ -93,7 +91,7 @@ public static function addSectionMediaElement($src, $type, MemoryImage $memoryIm $isMemImage = true; } if (!$isMemImage) { - $isMemImage = (filter_var($src, FILTER_VALIDATE_URL) !== false); + $isMemImage = (filter_var($src, \FILTER_VALIDATE_URL) !== false); } $extension = ''; if ($isMemImage) { @@ -103,15 +101,15 @@ public static function addSectionMediaElement($src, $type, MemoryImage $memoryIm $media['imagefunction'] = $memoryImage->getImageFunction(); } else { $imageType = exif_imagetype($src); - if ($imageType === IMAGETYPE_JPEG) { + if ($imageType === \IMAGETYPE_JPEG) { $extension = 'jpg'; - } elseif ($imageType === IMAGETYPE_GIF) { + } elseif ($imageType === \IMAGETYPE_GIF) { $extension = 'gif'; - } elseif ($imageType === IMAGETYPE_PNG) { + } elseif ($imageType === \IMAGETYPE_PNG) { $extension = 'png'; - } elseif ($imageType === IMAGETYPE_BMP) { + } elseif ($imageType === \IMAGETYPE_BMP) { $extension = 'bmp'; - } elseif ($imageType === IMAGETYPE_TIFF_II || $imageType === IMAGETYPE_TIFF_MM) { + } elseif ($imageType === \IMAGETYPE_TIFF_II || $imageType === \IMAGETYPE_TIFF_MM) { $extension = 'tif'; } } @@ -204,9 +202,9 @@ public static function countSectionMediaElements($key = null) /** * Add new Header Media Element * - * @param int $headerCount - * @param string $src - * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage + * @param int $headerCount + * @param string $src + * @param \PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage * @return int */ public static function addHeaderMediaElement($headerCount, $src, MemoryImage $memoryImage = null) @@ -276,9 +274,9 @@ public static function getHeaderMediaElements() /** * Add new Footer Media Element * - * @param int $footerCount - * @param string $src - * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage + * @param int $footerCount + * @param string $src + * @param \PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage * @return int */ public static function addFooterMediaElement($footerCount, $src, MemoryImage $memoryImage = null) diff --git a/src/PhpWord.php b/src/PhpWord.php index 9439f9ce2b..c2adbe874c 100644 --- a/src/PhpWord.php +++ b/src/PhpWord.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -37,7 +35,7 @@ if (!defined('PHPWORD_BASE_DIR')) { define('PHPWORD_BASE_DIR', \realpath(__DIR__) . \DIRECTORY_SEPARATOR); require \PHPWORD_BASE_DIR . 'Autoloader.php'; - Autoloader::register(); + \PhpOffice\PhpWord\Autoloader::register(); } // @codeCoverageIgnoreEnd @@ -55,7 +53,7 @@ class PhpWord const DEFAULT_FONT_SIZE = 10; /** - * @var PhpOffice\PhpWord\DocumentProperties + * @var \PhpOffice\PhpWord\DocumentProperties */ private $_documentProperties; @@ -70,7 +68,7 @@ class PhpWord private $_defaultFontSize; /** - * @var PhpOffice\PhpWord\Section[] + * @var \PhpOffice\PhpWord\Section[] */ private $_sections = array(); @@ -82,7 +80,7 @@ public function __construct() } /** - * @return PhpOffice\PhpWord\DocumentProperties + * @return \PhpOffice\PhpWord\DocumentProperties */ public function getDocumentProperties() { @@ -90,8 +88,8 @@ public function getDocumentProperties() } /** - * @param PhpOffice\PhpWord\DocumentProperties $documentProperties - * @return PhpOffice\PhpWord + * @param \PhpOffice\PhpWord\DocumentProperties $documentProperties + * @return \PhpOffice\PhpWord\PhpWord */ public function setDocumentProperties(DocumentProperties $documentProperties) { @@ -101,8 +99,8 @@ public function setDocumentProperties(DocumentProperties $documentProperties) } /** - * @param PhpOffice\PhpWord\Section\Settings $settings - * @return PhpOffice\PhpWord\Section + * @param \PhpOffice\PhpWord\Section\Settings $settings + * @return \PhpOffice\PhpWord\Section */ public function createSection($settings = null) { @@ -210,7 +208,7 @@ public function addLinkStyle($styleName, $styles) } /** - * @return PhpOffice\PhpWord\Section[] + * @return \PhpOffice\PhpWord\Section[] */ public function getSections() { @@ -219,8 +217,8 @@ public function getSections() /** * @param string $filename Fully qualified filename. - * @return PhpOffice\PhpWord\Template - * @throws PhpOffice\PhpWord\Exceptions\Exception + * @return \PhpOffice\PhpWord\Template + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function loadTemplate($filename) { diff --git a/src/Reader/AbstractReader.php b/src/Reader/AbstractReader.php index f92980cb8e..0d68e3138f 100644 --- a/src/Reader/AbstractReader.php +++ b/src/Reader/AbstractReader.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -61,7 +59,7 @@ public function getReadDataOnly() * Set read data only * * @param bool $pValue - * @return PhpOffice\PhpWord\Reader\IReader + * @return \PhpOffice\PhpWord\Reader\IReader */ public function setReadDataOnly($pValue = true) { @@ -74,7 +72,7 @@ public function setReadDataOnly($pValue = true) * * @param string $pFilename * @return resource - * @throws Exception + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ protected function openFile($pFilename) { diff --git a/src/Reader/IReader.php b/src/Reader/IReader.php index 94db13e576..7c14b8fa43 100644 --- a/src/Reader/IReader.php +++ b/src/Reader/IReader.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -32,8 +30,8 @@ interface IReader /** * Can the current IReader read the file? * - * @param string $pFilename - * @return boolean + * @param string $pFilename + * @return boolean */ public function canRead($pFilename); @@ -43,4 +41,4 @@ public function canRead($pFilename); * @param string $pFilename */ public function load($pFilename); -} +} \ No newline at end of file diff --git a/src/Reader/Word2007.php b/src/Reader/Word2007.php index f978e03d82..aecf899c5d 100644 --- a/src/Reader/Word2007.php +++ b/src/Reader/Word2007.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -44,7 +42,7 @@ class Word2007 extends AbstractReader implements IReader * * @param string $pFilename * @return bool - * @throws PhpOffice\PhpWord\Exceptions\Exception + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function canRead($pFilename) { @@ -78,7 +76,7 @@ public function canRead($pFilename) } /** - * @param ZipArchive $archive + * @param \ZipArchive $archive * @param string $fileName * @param bool $removeNamespace * @return mixed @@ -109,7 +107,7 @@ public function getFromZipArchive($archive, $fileName = '', $removeNamespace = f * Loads PhpWord from file * * @param string $pFilename - * @return PhpOffice\PhpWord|null + * @return \PhpOffice\PhpWord\PhpWord|null */ public function load($pFilename) { @@ -271,7 +269,7 @@ public function load($pFilename) /** * Load section settings from SimpleXMLElement * - * @param SimpleXMLElement $elm + * @param \SimpleXMLElement $elm * @return array|string|null * * @todo Implement gutter @@ -333,7 +331,7 @@ private function loadSectionSettings($elm) /** * Load paragraph style from SimpleXMLElement * - * @param SimpleXMLElement $elm + * @param \SimpleXMLElement $elm * @return array|string|null */ private function loadParagraphStyle($elm) @@ -394,7 +392,7 @@ private function loadParagraphStyle($elm) /** * Load font style from SimpleXMLElement * - * @param SimpleXMLElement $elm + * @param \SimpleXMLElement $elm * @return array|string|null */ private function loadFontStyle($elm) diff --git a/src/Section.php b/src/Section.php index cfcb6bc931..7fabb0b901 100644 --- a/src/Section.php +++ b/src/Section.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -29,8 +27,8 @@ use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Section\Footer; -use PhpOffice\PhpWord\Section\Footnote; use PhpOffice\PhpWord\Section\Image; +use PhpOffice\PhpWord\Section\Header; use PhpOffice\PhpWord\Section\Link; use PhpOffice\PhpWord\Section\ListItem; use PhpOffice\PhpWord\Section\MemoryImage; @@ -56,7 +54,7 @@ class Section /** * Section settings * - * @var PhpOffice\PhpWord\Section\Settings + * @var \PhpOffice\PhpWord\Section\Settings */ private $_settings; @@ -77,7 +75,7 @@ class Section /** * Section Footer * - * @var PhpOffice\PhpWord\Section\Footer + * @var \PhpOffice\PhpWord\Section\Footer */ private $_footer = null; @@ -115,7 +113,7 @@ public function setSettings($settings = null) /** * Get Section Settings * - * @return PhpOffice\PhpWord\Section\Settings + * @return \PhpOffice\PhpWord\Section\Settings */ public function getSettings() { @@ -128,7 +126,7 @@ public function getSettings() * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Text + * @return \PhpOffice\PhpWord\Section\Text */ public function addText($text, $styleFont = null, $styleParagraph = null) { @@ -147,7 +145,7 @@ public function addText($text, $styleFont = null, $styleParagraph = null) * @param string $linkName * @param mixed $styleFont * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Link + * @return \PhpOffice\PhpWord\Section\Link */ public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) { @@ -172,8 +170,8 @@ public function addLink($linkSrc, $linkName = null, $styleFont = null, $stylePar * Add a TextBreak Element * * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { @@ -194,7 +192,7 @@ public function addPageBreak() * Add a Table Element * * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table + * @return \PhpOffice\PhpWord\Section\Table */ public function addTable($style = null) { @@ -211,7 +209,7 @@ public function addTable($style = null) * @param mixed $styleFont * @param mixed $styleList * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\ListItem + * @return \PhpOffice\PhpWord\Section\ListItem */ public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) { @@ -228,8 +226,8 @@ public function addListItem($text, $depth = 0, $styleFont = null, $styleList = n * * @param string $src * @param mixed $style - * @return PhpOffice\PhpWord\Section\Object - * @throws Exception + * @return \PhpOffice\PhpWord\Section\Object + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function addObject($src, $style = null) { @@ -269,8 +267,8 @@ public function addObject($src, $style = null) * * @param string $src * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image - * @throws Exception + * @return \PhpOffice\PhpWord\Section\Image + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function addImage($src, $style = null) { @@ -291,8 +289,8 @@ public function addImage($src, $style = null) * * @param string $link * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage - * @throws Exception + * @return \PhpOffice\PhpWord\Section\MemoryImage + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function addMemoryImage($link, $style = null) { @@ -312,7 +310,7 @@ public function addMemoryImage($link, $style = null) * * @param mixed $styleFont * @param mixed $styleTOC - * @return PhpOffice\PhpWord\TOC + * @return \PhpOffice\PhpWord\TOC */ public function addTOC($styleFont = null, $styleTOC = null) { @@ -326,7 +324,7 @@ public function addTOC($styleFont = null, $styleTOC = null) * * @param string $text * @param int $depth - * @return PhpOffice\PhpWord\Section\Title + * @return \PhpOffice\PhpWord\Section\Title */ public function addTitle($text, $depth = 1) { @@ -357,7 +355,7 @@ public function addTitle($text, $depth = 1) * Create a new TextRun * * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\TextRun + * @return \PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) { @@ -379,7 +377,7 @@ public function getElements() /** * Create a new Header * - * @return PhpOffice\PhpWord\Section\Header + * @return \PhpOffice\PhpWord\Section\Header */ public function createHeader() { @@ -417,7 +415,7 @@ public function hasDifferentFirstPage() /** * Create a new Footer * - * @return PhpOffice\PhpWord\Section\Footer + * @return \PhpOffice\PhpWord\Section\Footer */ public function createFooter() { @@ -427,9 +425,7 @@ public function createFooter() } /** - * Get Footer - * - * @return PhpOffice\PhpWord\Section\Footer + * @return \PhpOffice\PhpWord\Section\Footer */ public function getFooter() { @@ -440,11 +436,11 @@ public function getFooter() * Create a new Footnote Element * * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footnote + * @return \PhpOffice\PhpWord\Section\Footnote */ public function createFootnote($styleParagraph = null) { - $footnote = new Footnote($styleParagraph); + $footnote = new \PhpOffice\PhpWord\Section\Footnote($styleParagraph); $refID = Footnote::addFootnoteElement($footnote); $footnote->setReferenceId($refID); $this->_elementCollection[] = $footnote; diff --git a/src/Section/Footer.php b/src/Section/Footer.php index 8c88bd846a..085bcd0769 100644 --- a/src/Section/Footer.php +++ b/src/Section/Footer.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Shared\String; @@ -68,7 +67,7 @@ public function __construct($sectionCount) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Text + * @return \PhpOffice\PhpWord\Section\Text */ public function addText($text, $styleFont = null, $styleParagraph = null) { @@ -84,8 +83,8 @@ public function addText($text, $styleFont = null, $styleParagraph = null) * Add TextBreak * * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { @@ -97,7 +96,7 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu /** * Create a new TextRun * - * @return PhpOffice\PhpWord\Section\TextRun + * @return \PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) { @@ -110,7 +109,7 @@ public function createTextRun($styleParagraph = null) * Add a Table Element * * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table + * @return \PhpOffice\PhpWord\Section\Table */ public function addTable($style = null) { @@ -124,7 +123,7 @@ public function addTable($style = null) * * @param string $src * @param mixed $style - * @return Image + * @return \PhpOffice\PhpWord\Section\Image */ public function addImage($src, $style = null) { @@ -146,7 +145,7 @@ public function addImage($src, $style = null) * * @param string $link * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage + * @return \PhpOffice\PhpWord\Section\MemoryImage */ public function addMemoryImage($link, $style = null) { @@ -168,7 +167,7 @@ public function addMemoryImage($link, $style = null) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footer\PreserveText + * @return \PhpOffice\PhpWord\Section\Footer\PreserveText */ public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { diff --git a/src/Section/Footer/PreserveText.php b/src/Section/Footer/PreserveText.php index fa9f8a8617..635af9f21d 100644 --- a/src/Section/Footer/PreserveText.php +++ b/src/Section/Footer/PreserveText.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -42,14 +40,14 @@ class PreserveText /** * Text style * - * @var PhpOffice\PhpWord\Style\Font + * @var \PhpOffice\PhpWord\Style\Font */ private $_styleFont; /** * Paragraph style * - * @var PhpOffice\PhpWord\Style\Paragraph + * @var \PhpOffice\PhpWord\Style\Paragraph */ private $_styleParagraph; @@ -90,7 +88,7 @@ public function __construct($text = null, $styleFont = null, $styleParagraph = n $this->_styleParagraph = $styleParagraph; } - $matches = preg_split('/({.*?})/', $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $matches = preg_split('/({.*?})/', $text, null, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); if (isset($matches[0])) { $this->_text = $matches[0]; } @@ -101,7 +99,7 @@ public function __construct($text = null, $styleFont = null, $styleParagraph = n /** * Get Text style * - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function getFontStyle() { @@ -111,7 +109,7 @@ public function getFontStyle() /** * Get Paragraph style * - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/src/Section/Footnote.php b/src/Section/Footnote.php index e5b6e6d814..2a9eacaf31 100644 --- a/src/Section/Footnote.php +++ b/src/Section/Footnote.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -34,7 +32,7 @@ class Footnote /** * Paragraph style * - * @var PhpOffice\PhpWord\Style\Paragraph + * @var \PhpOffice\PhpWord\Style\Paragraph */ private $_styleParagraph; @@ -80,7 +78,7 @@ public function __construct($styleParagraph = null) * * @var string $text * @var mixed $styleFont - * @return PhpOffice\PhpWord\Section\Text + * @return \PhpOffice\PhpWord\Section\Text */ public function addText($text = null, $styleFont = null) { @@ -96,13 +94,13 @@ public function addText($text = null, $styleFont = null) * @param string $linkSrc * @param string $linkName * @param mixed $styleFont - * @return PhpOffice\PhpWord\Section\Link + * @return \PhpOffice\PhpWord\Section\Link */ public function addLink($linkSrc, $linkName = null, $styleFont = null) { $link = new Link($linkSrc, $linkName, $styleFont); - $rID = PhpOffice\PhpWord\Footnote::addFootnoteLinkElement($linkSrc); + $rID = \PhpOffice\PhpWord\Footnote::addFootnoteLinkElement($linkSrc); $link->setRelationId($rID); $this->_elementCollection[] = $link; @@ -120,9 +118,7 @@ public function getElements() } /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/src/Section/Header.php b/src/Section/Header.php index 6067945b1a..d9d3eed1ed 100644 --- a/src/Section/Header.php +++ b/src/Section/Header.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Shared\String; @@ -97,7 +96,7 @@ public function __construct($sectionCount) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Text + * @return \PhpOffice\PhpWord\Section\Text */ public function addText($text, $styleFont = null, $styleParagraph = null) { @@ -113,8 +112,8 @@ public function addText($text, $styleFont = null, $styleParagraph = null) * Add TextBreak * * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { @@ -126,7 +125,7 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu /** * Create a new TextRun * - * @return PhpOffice\PhpWord\Section\TextRun + * @return \PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) { @@ -139,7 +138,7 @@ public function createTextRun($styleParagraph = null) * Add a Table Element * * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table + * @return \PhpOffice\PhpWord\Section\Table */ public function addTable($style = null) { @@ -153,7 +152,7 @@ public function addTable($style = null) * * @param string $src * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image + * @return \PhpOffice\PhpWord\Section\Image */ public function addImage($src, $style = null) { @@ -175,7 +174,7 @@ public function addImage($src, $style = null) * * @param string $link * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage + * @return \PhpOffice\PhpWord\Section\MemoryImage */ public function addMemoryImage($link, $style = null) { @@ -197,7 +196,7 @@ public function addMemoryImage($link, $style = null) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footer\PreserveText + * @return \PhpOffice\PhpWord\Section\Footer\PreserveText */ public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { @@ -214,7 +213,7 @@ public function addPreserveText($text, $styleFont = null, $styleParagraph = null * * @param string $src * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image + * @return \PhpOffice\PhpWord\Section\Image */ public function addWatermark($src, $style = null) { diff --git a/src/Section/Image.php b/src/Section/Image.php index 8762e8ca90..2c04125396 100644 --- a/src/Section/Image.php +++ b/src/Section/Image.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -42,7 +40,7 @@ class Image /** * Image Style * - * @var PhpOffice\PhpWord\Style\Image + * @var \PhpOffice\PhpWord\Style\Image */ private $_style; @@ -67,11 +65,12 @@ class Image * @param string $src * @param mixed $style * @param bool $isWatermark - * @throws InvalidImageException|UnsupportedImageTypeException + * @throws \PhpOffice\PhpWord\Exceptions\InvalidImageException + * @throws \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException */ public function __construct($src, $style = null, $isWatermark = false) { - $supportedImageTypes = array(IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM); + $supportedImageTypes = array(\IMAGETYPE_JPEG, \IMAGETYPE_GIF, \IMAGETYPE_PNG, \IMAGETYPE_BMP, \IMAGETYPE_TIFF_II, \IMAGETYPE_TIFF_MM); if (!file_exists($src)) { throw new InvalidImageException; @@ -83,7 +82,7 @@ public function __construct($src, $style = null, $isWatermark = false) $this->_src = $src; $this->_isWatermark = $isWatermark; - $this->_style = new PhpOffice\PhpWord\Style\Image(); + $this->_style = new \PhpOffice\PhpWord\Style\Image(); if (!is_null($style) && is_array($style)) { foreach ($style as $key => $value) { @@ -108,7 +107,7 @@ public function __construct($src, $style = null, $isWatermark = false) /** * Get Image style * - * @return PhpOffice\PhpWord\Style\Image + * @return \PhpOffice\PhpWord\Style\Image */ public function getStyle() { diff --git a/src/Section/Link.php b/src/Section/Link.php index 5c3cc9fedd..c3c14466d6 100644 --- a/src/Section/Link.php +++ b/src/Section/Link.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -56,14 +54,14 @@ class Link /** * Link style * - * @var PhpOffice\PhpWord\Style\Font + * @var \PhpOffice\PhpWord\Style\Font */ private $_styleFont; /** * Paragraph style * - * @var PhpOffice\PhpWord\Style\Paragraph + * @var \PhpOffice\PhpWord\Style\Paragraph */ private $_styleParagraph; @@ -155,7 +153,7 @@ public function getLinkName() /** * Get Text style * - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function getFontStyle() { @@ -165,7 +163,7 @@ public function getFontStyle() /** * Get Paragraph style * - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/src/Section/ListItem.php b/src/Section/ListItem.php index 2aaf4c34dd..7760e87dbd 100644 --- a/src/Section/ListItem.php +++ b/src/Section/ListItem.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -32,14 +30,14 @@ class ListItem /** * ListItem Style * - * @var PhpOffice\PhpWord\Style\ListItem + * @var \PhpOffice\PhpWord\Style\ListItem */ private $_style; /** * Textrun * - * @var PhpOffice\PhpWord\Section\Text + * @var \PhpOffice\PhpWord\Section\Text */ private $_textObject; @@ -61,7 +59,7 @@ class ListItem */ public function __construct($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) { - $this->_style = new PhpOffice\PhpWord\Style\ListItem(); + $this->_style = new \PhpOffice\PhpWord\Style\ListItem(); $this->_textObject = new Text($text, $styleFont, $styleParagraph); $this->_depth = $depth; diff --git a/src/Section/MemoryImage.php b/src/Section/MemoryImage.php index 4d81ee87bd..62de8317ae 100644 --- a/src/Section/MemoryImage.php +++ b/src/Section/MemoryImage.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -41,7 +39,7 @@ class MemoryImage /** * Image Style * - * @var PhpOffice\PhpWord\Style\Image + * @var \PhpOffice\PhpWord\Style\Image */ private $_style; @@ -144,7 +142,7 @@ private function _setFunctions() /** * Get Image style * - * @return PhpOffice\PhpWord\Style\Image + * @return \PhpOffice\PhpWord\Style\Image */ public function getStyle() { diff --git a/src/Section/Object.php b/src/Section/Object.php index 2569478a8c..a7cbdfc187 100644 --- a/src/Section/Object.php +++ b/src/Section/Object.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -41,7 +39,7 @@ class Object /** * Image Style * - * @var PhpOffice\PhpWord\Style\Image + * @var \PhpOffice\PhpWord\Style\Image */ private $_style; @@ -100,7 +98,7 @@ public function __construct($src, $style = null) /** * Get Image style * - * @return PhpOffice\PhpWord\Style\Image + * @return \PhpOffice\PhpWord\Style\Image */ public function getStyle() { diff --git a/src/Section/PageBreak.php b/src/Section/PageBreak.php index ebf7f31ff3..a164b32853 100644 --- a/src/Section/PageBreak.php +++ b/src/Section/PageBreak.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -29,9 +27,6 @@ class PageBreak { - /** - * Create a new PageBreak Element - */ public function __construct() { } diff --git a/src/Section/Settings.php b/src/Section/Settings.php index 9563a44499..b2c65e4ae0 100644 --- a/src/Section/Settings.php +++ b/src/Section/Settings.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Section/Table.php b/src/Section/Table.php index a06b41acca..51b3325281 100644 --- a/src/Section/Table.php +++ b/src/Section/Table.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -34,7 +32,7 @@ class Table /** * Table style * - * @var PhpOffice\PhpWord\Style\Table + * @var \PhpOffice\PhpWord\Style\Table */ private $_style; @@ -81,7 +79,7 @@ public function __construct($insideOf, $pCount, $style = null) if (!is_null($style)) { if (is_array($style)) { - $this->_style = new PhpOffice\PhpWord\Style\Table(); + $this->_style = new \PhpOffice\PhpWord\Style\Table(); foreach ($style as $key => $value) { if (substr($key, 0, 1) != '_') { @@ -112,7 +110,7 @@ public function addRow($height = null, $style = null) * * @param int $width * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table\Cell + * @return \PhpOffice\PhpWord\Section\Table\Cell */ public function addCell($width = null, $style = null) { @@ -134,7 +132,7 @@ public function getRows() /** * Get table style * - * @return PhpOffice\PhpWord\Style\Table + * @return \PhpOffice\PhpWord\Style\Table */ public function getStyle() { diff --git a/src/Section/Table/Cell.php b/src/Section/Table/Cell.php index 0088ceb00e..21ae054fff 100644 --- a/src/Section/Table/Cell.php +++ b/src/Section/Table/Cell.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Section\Table; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Section\Image; @@ -51,7 +50,7 @@ class Cell /** * Cell Style * - * @var PhpOffice\PhpWord\Style\Cell + * @var \PhpOffice\PhpWord\Style\Cell */ private $_style; @@ -90,7 +89,7 @@ public function __construct($insideOf, $pCount, $width = null, $style = null) $this->_insideOf = $insideOf; $this->_pCount = $pCount; $this->_width = $width; - $this->_style = new PhpOffice\PhpWord\Style\Cell(); + $this->_style = new \PhpOffice\PhpWord\Style\Cell(); if (!is_null($style)) { if (is_array($style)) { @@ -111,7 +110,7 @@ public function __construct($insideOf, $pCount, $width = null, $style = null) * * @param string $text * @param mixed $style - * @return PhpOffice\PhpWord\Section\Text + * @return \PhpOffice\PhpWord\Section\Text */ public function addText($text, $styleFont = null, $styleParagraph = null) { @@ -129,7 +128,7 @@ public function addText($text, $styleFont = null, $styleParagraph = null) * @param string $linkSrc * @param string $linkName * @param mixed $style - * @return PhpOffice\PhpWord\Section\Link + * @return \PhpOffice\PhpWord\Section\Link */ public function addLink($linkSrc, $linkName = null, $style = null) { @@ -159,8 +158,8 @@ public function addLink($linkSrc, $linkName = null, $style = null) * Add TextBreak * * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { @@ -176,7 +175,7 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu * @param int $depth * @param mixed $styleText * @param mixed $styleList - * @return PhpOffice\PhpWord\Section\ListItem + * @return \PhpOffice\PhpWord\Section\ListItem */ public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) { @@ -193,7 +192,7 @@ public function addListItem($text, $depth = 0, $styleText = null, $styleList = n * * @param string $src * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image + * @return \PhpOffice\PhpWord\Section\Image */ public function addImage($src, $style = null) { @@ -221,7 +220,7 @@ public function addImage($src, $style = null) * * @param string $link * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage + * @return \PhpOffice\PhpWord\Section\MemoryImage */ public function addMemoryImage($link, $style = null) { @@ -248,7 +247,7 @@ public function addMemoryImage($link, $style = null) * * @param string $src * @param mixed $style - * @return PhpOffice\PhpWord\Section\Object + * @return \PhpOffice\PhpWord\Section\Object */ public function addObject($src, $style = null) { @@ -290,7 +289,7 @@ public function addObject($src, $style = null) * @param string $text * @param mixed $styleFont * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footer\PreserveText + * @return \PhpOffice\PhpWord\Section\Footer\PreserveText */ public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { @@ -309,7 +308,7 @@ public function addPreserveText($text, $styleFont = null, $styleParagraph = null /** * Create a new TextRun * - * @return PhpOffice\PhpWord\Section\TextRun + * @return \PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) { @@ -331,7 +330,7 @@ public function getElements() /** * Get Cell Style * - * @return PhpOffice\PhpWord\Style\Cell + * @return \PhpOffice\PhpWord\Style\Cell */ public function getStyle() { diff --git a/src/Section/Table/Row.php b/src/Section/Table/Row.php index de9822b34f..b9092295b3 100644 --- a/src/Section/Table/Row.php +++ b/src/Section/Table/Row.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2013 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -39,7 +37,7 @@ class Row /** * Row style * - * @var PhpOffice\PhpWord\Style\Row + * @var \PhpOffice\PhpWord\Style\Row */ private $_style; @@ -78,7 +76,7 @@ public function __construct($insideOf, $pCount, $height = null, $style = null) $this->_insideOf = $insideOf; $this->_pCount = $pCount; $this->_height = $height; - $this->_style = new PhpOffice\PhpWord\Style\Row(); + $this->_style = new \PhpOffice\PhpWord\Style\Row(); if (!is_null($style)) { if (is_array($style)) { @@ -98,7 +96,7 @@ public function __construct($insideOf, $pCount, $height = null, $style = null) * * @param int $width * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table\Cell + * @return \PhpOffice\PhpWord\Section\Table\Cell */ public function addCell($width = null, $style = null) { @@ -120,7 +118,7 @@ public function getCells() /** * Get row style * - * @return PhpOffice\PhpWord\Style\Row + * @return \PhpOffice\PhpWord\Style\Row */ public function getStyle() { diff --git a/src/Section/Text.php b/src/Section/Text.php index 3e51bc8679..50dfdc8930 100644 --- a/src/Section/Text.php +++ b/src/Section/Text.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -42,14 +40,14 @@ class Text /** * Text style * - * @var PhpOffice\PhpWord\Style\Font + * @var \PhpOffice\PhpWord\Style\Font */ private $fontStyle; /** * Paragraph style * - * @var PhpOffice\PhpWord\Style\Paragraph + * @var \PhpOffice\PhpWord\Style\Paragraph */ private $paragraphStyle; @@ -57,8 +55,8 @@ class Text * Create a new Text Element * * @param string $text - * @param null|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @param null|array|\PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function __construct($text = null, $fontStyle = null, $paragraphStyle = null) { @@ -70,9 +68,9 @@ public function __construct($text = null, $fontStyle = null, $paragraphStyle = n /** * Set Text style * - * @param null|array|PhpOffice\PhpWord\Style\Font $style - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - * @return PhpOffice\PhpWord\Style\Font + * @param null|array|\PhpOffice\PhpWord\Style\Font $style + * @param null|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @return \PhpOffice\PhpWord\Style\Font */ public function setFontStyle($style = null, $paragraphStyle = null) { @@ -94,7 +92,7 @@ public function setFontStyle($style = null, $paragraphStyle = null) /** * Get Text style * - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function getFontStyle() { @@ -104,8 +102,8 @@ public function getFontStyle() /** * Set Paragraph style * - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style - * @return null|PhpOffice\PhpWord\Style\Paragraph + * @param null|array|\PhpOffice\PhpWord\Style\Paragraph $style + * @return null|\PhpOffice\PhpWord\Style\Paragraph */ public function setParagraphStyle($style = null) { @@ -125,7 +123,7 @@ public function setParagraphStyle($style = null) /** * Get Paragraph style * - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/src/Section/TextBreak.php b/src/Section/TextBreak.php index cd296c745a..938f66c2a5 100644 --- a/src/Section/TextBreak.php +++ b/src/Section/TextBreak.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -35,14 +33,14 @@ class TextBreak /** * Paragraph style * - * @var PhpOffice\PhpWord\Style\Pagaraph + * @var \PhpOffice\PhpWord\Style\Pagaraph */ private $paragraphStyle = null; /** * Text style * - * @var PhpOffice\PhpWord\Style\Font + * @var \PhpOffice\PhpWord\Style\Font */ private $fontStyle = null; @@ -62,9 +60,9 @@ public function __construct($fontStyle = null, $paragraphStyle = null) /** * Set Text style * - * @param null|array|PhpOffice\PhpWord\Style\Font $style - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - * @return PhpOffice\PhpWord\Style\Font + * @param null|array|\PhpOffice\PhpWord\Style\Font $style + * @param null|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @return \PhpOffice\PhpWord\Style\Font */ public function setFontStyle($style = null, $paragraphStyle = null) { @@ -84,7 +82,7 @@ public function setFontStyle($style = null, $paragraphStyle = null) /** * Get Text style * - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function getFontStyle() { @@ -94,8 +92,8 @@ public function getFontStyle() /** * Set Paragraph style * - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style - * @return null|PhpOffice\PhpWord\Style\Paragraph + * @param null|array|\PhpOffice\PhpWord\Style\Paragraph $style + * @return null|\PhpOffice\PhpWord\Style\Paragraph */ public function setParagraphStyle($style = null) { @@ -113,7 +111,7 @@ public function setParagraphStyle($style = null) /** * Get Paragraph style * - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/src/Section/TextRun.php b/src/Section/TextRun.php index 4cee06d60e..0911b5dc61 100644 --- a/src/Section/TextRun.php +++ b/src/Section/TextRun.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Section; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style\Paragraph; @@ -36,7 +35,7 @@ class TextRun /** * Paragraph style * - * @var PhpOffice\PhpWord\Style\Paragraph + * @var \PhpOffice\PhpWord\Style\Paragraph */ private $_styleParagraph; @@ -76,7 +75,7 @@ public function __construct($styleParagraph = null) * * @var string $text * @var mixed $styleFont - * @return PhpOffice\PhpWord\Section\Text + * @return \PhpOffice\PhpWord\Section\Text */ public function addText($text = null, $styleFont = null) { @@ -94,7 +93,7 @@ public function addText($text = null, $styleFont = null) * @param string $linkSrc * @param string $linkName * @param mixed $styleFont - * @return PhpOffice\PhpWord\Section\Link + * @return \PhpOffice\PhpWord\Section\Link */ public function addLink($linkSrc, $linkName = null, $styleFont = null) { @@ -116,7 +115,7 @@ public function addLink($linkSrc, $linkName = null, $styleFont = null) * * @param string $imageSrc * @param mixed $styleFont - * @return PhpOffice\PhpWord\Section\Image + * @return \PhpOffice\PhpWord\Section\Image */ public function addImage($imageSrc, $style = null) { @@ -137,8 +136,8 @@ public function addImage($imageSrc, $style = null) * Add TextBreak * * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Font $fontStyle + * @param null|string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { @@ -151,12 +150,12 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu * Create a new Footnote Element * * @param string $text - * @return PhpOffice\PhpWord\Section\Footnote + * @return \PhpOffice\PhpWord\Section\Footnote */ public function createFootnote($styleParagraph = null) { - $footnote = new PhpOffice\PhpWord\Section\Footnote($styleParagraph); - $refID = PhpOffice\PhpWord\Footnote::addFootnoteElement($footnote); + $footnote = new \PhpOffice\PhpWord\Section\Footnote($styleParagraph); + $refID = \PhpOffice\PhpWord\Footnote::addFootnoteElement($footnote); $footnote->setReferenceId($refID); $this->_elementCollection[] = $footnote; return $footnote; @@ -175,7 +174,7 @@ public function getElements() /** * Get Paragraph style * - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { diff --git a/src/Section/Title.php b/src/Section/Title.php index fdc31ac885..1c3546aee9 100644 --- a/src/Section/Title.php +++ b/src/Section/Title.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Settings.php b/src/Settings.php index 8eb3a60f9a..b93fa94ee2 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Shared/Drawing.php b/src/Shared/Drawing.php index e7289a8a8c..16a363aceb 100644 --- a/src/Shared/Drawing.php +++ b/src/Shared/Drawing.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Shared/File.php b/src/Shared/File.php index f2d4f3beb1..e738524104 100644 --- a/src/Shared/File.php +++ b/src/Shared/File.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -32,7 +30,7 @@ class File /** * Verify if a file exists * - * @param string $pFilename Filename + * @param string $pFilename Filename * @return bool */ public static function file_exists($pFilename) diff --git a/src/Shared/Font.php b/src/Shared/Font.php index adee50ada4..8b9c7d09c8 100644 --- a/src/Shared/Font.php +++ b/src/Shared/Font.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Shared/String.php b/src/Shared/String.php index d7d66a4761..63bfe14863 100644 --- a/src/Shared/String.php +++ b/src/Shared/String.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Shared/XMLWriter.php b/src/Shared/XMLWriter.php index 2334997fa0..b0c6906df5 100644 --- a/src/Shared/XMLWriter.php +++ b/src/Shared/XMLWriter.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -47,7 +45,7 @@ class XMLWriter /** * Internal XMLWriter * - * @var XMLWriter + * @var \XMLWriter */ private $_xmlWriter; @@ -59,15 +57,13 @@ class XMLWriter private $_tempFileName = ''; /** - * Create a new XMLWriter instance - * * @param int $pTemporaryStorage Temporary storage location * @param string $pTemporaryStorageFolder Temporary storage folder */ public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = './') { // Create internal XMLWriter - $this->_xmlWriter = new XMLWriter(); + $this->_xmlWriter = new \XMLWriter(); // Open temporary storage if ($pTemporaryStorage == self::STORAGE_MEMORY) { @@ -133,7 +129,7 @@ public function __call($function, $args) { try { @call_user_func_array(array($this->_xmlWriter, $function), $args); - } catch (Exception $ex) { + } catch (\Exception $ex) { // Do nothing! } } diff --git a/src/Shared/ZipStreamWrapper.php b/src/Shared/ZipStreamWrapper.php index 2676ac552f..55b2fec650 100644 --- a/src/Shared/ZipStreamWrapper.php +++ b/src/Shared/ZipStreamWrapper.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,8 @@ namespace PhpOffice\PhpWord\Shared; +use PhpOffice\PhpWord\Exceptions\Exception; + /** * @codeCoverageIgnore Legacy from PHPExcel */ @@ -35,7 +35,7 @@ class ZipStreamWrapper /** * Internal ZipAcrhive * - * @var ZipAcrhive + * @var \ZipAcrhive */ private $_archive; @@ -149,7 +149,7 @@ public function stream_eof() public function stream_seek($offset, $whence) { switch ($whence) { - case SEEK_SET: + case \SEEK_SET: if ($offset < strlen($this->_data) && $offset >= 0) { $this->_position = $offset; return true; @@ -158,7 +158,7 @@ public function stream_seek($offset, $whence) } break; - case SEEK_CUR: + case \SEEK_CUR: if ($offset >= 0) { $this->_position += $offset; return true; @@ -167,7 +167,7 @@ public function stream_seek($offset, $whence) } break; - case SEEK_END: + case \SEEK_END: if (strlen($this->_data) + $offset >= 0) { $this->_position = strlen($this->_data) + $offset; return true; diff --git a/src/Style.php b/src/Style.php index 387dc468d1..d765db691a 100644 --- a/src/Style.php +++ b/src/Style.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -140,7 +138,7 @@ public static function setDefaultParagraphStyle($styles) /** * Get all styles * - * @return PhpOffice\PhpWord\Style\Font[] + * @return \PhpOffice\PhpWord\Style\Font[] */ public static function getStyles() { diff --git a/src/Style/Cell.php b/src/Style/Cell.php index 23cd0c07d2..99b7e8c550 100644 --- a/src/Style/Cell.php +++ b/src/Style/Cell.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Style/Font.php b/src/Style/Font.php index 7551200b95..137d696469 100644 --- a/src/Style/Font.php +++ b/src/Style/Font.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -74,9 +72,7 @@ class Font private $_type; /** - * Paragraph Style - * - * @var PhpOffice\PhpWord\Style\Paragraph + * @var \PhpOffice\PhpWord\Style\Paragraph */ private $_paragraphStyle; @@ -95,43 +91,31 @@ class Font private $_size = PhpWord::DEFAULT_FONT_SIZE; /** - * Bold - * * @var bool */ private $_bold = false; /** - * Italics - * * @var bool */ private $_italic = false; /** - * Superscript - * * @var bool */ private $_superScript = false; /** - * Subscript - * * @var bool */ private $_subScript = false; /** - * Underline mode - * * @var string */ private $_underline = self::UNDERLINE_NONE; /** - * Strikethrough - * * @var bool */ private $_strikethrough = false; @@ -165,8 +149,6 @@ class Font private $_hint = PhpWord::DEFAULT_FONT_CONTENT_TYPE; /** - * New font style - * * @param string $type Type of font * @param array $paragraphStyle Paragraph styles definition */ @@ -204,10 +186,8 @@ public function setArrayStyle(array $style = array()) } /** - * Set style value - * - * @param string $key - * @param mixed $value + * @param string $key + * @param mixed $value */ public function setStyleValue($key, $value) { @@ -220,7 +200,7 @@ public function setStyleValue($key, $value) /** * Get font name * - * @return bool + * @return bool */ public function getName() { @@ -231,7 +211,7 @@ public function getName() * Set font name * * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setName($pValue = PhpWord::DEFAULT_FONT_NAME) { @@ -257,7 +237,7 @@ public function getSize() * Set font size * * @param int|float $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setSize($pValue = PhpWord::DEFAULT_FONT_SIZE) { @@ -269,9 +249,7 @@ public function setSize($pValue = PhpWord::DEFAULT_FONT_SIZE) } /** - * Get bold - * - * @return bool + * @return bool */ public function getBold() { @@ -279,10 +257,8 @@ public function getBold() } /** - * Set bold - * * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setBold($pValue = false) { @@ -294,9 +270,7 @@ public function setBold($pValue = false) } /** - * Get italics - * - * @return bool + * @return bool */ public function getItalic() { @@ -304,10 +278,8 @@ public function getItalic() } /** - * Set italics - * * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setItalic($pValue = false) { @@ -319,9 +291,7 @@ public function setItalic($pValue = false) } /** - * Get superscript - * - * @return bool + * @return bool */ public function getSuperScript() { @@ -329,10 +299,8 @@ public function getSuperScript() } /** - * Set superscript - * * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setSuperScript($pValue = false) { @@ -345,9 +313,7 @@ public function setSuperScript($pValue = false) } /** - * Get superscript - * - * @return bool + * @return bool */ public function getSubScript() { @@ -355,10 +321,8 @@ public function getSubScript() } /** - * Set subscript - * * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setSubScript($pValue = false) { @@ -371,9 +335,7 @@ public function setSubScript($pValue = false) } /** - * Get underline - * - * @return string + * @return string */ public function getUnderline() { @@ -381,10 +343,8 @@ public function getUnderline() } /** - * Set underline - * * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setUnderline($pValue = self::UNDERLINE_NONE) { @@ -396,9 +356,7 @@ public function setUnderline($pValue = self::UNDERLINE_NONE) } /** - * Get strikethrough - * - * @return bool + * @return bool */ public function getStrikethrough() { @@ -406,10 +364,8 @@ public function getStrikethrough() } /** - * Set strikethrough - * * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setStrikethrough($pValue = false) { @@ -423,7 +379,7 @@ public function setStrikethrough($pValue = false) /** * Get font color * - * @return string + * @return string */ public function getColor() { @@ -431,10 +387,8 @@ public function getColor() } /** - * Set font color - * * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setColor($pValue = PhpWord::DEFAULT_FONT_COLOR) { @@ -448,7 +402,7 @@ public function setColor($pValue = PhpWord::DEFAULT_FONT_COLOR) /** * Get foreground/highlight color * - * @return bool + * @return bool */ public function getFgColor() { @@ -459,7 +413,7 @@ public function getFgColor() * Set foreground/highlight color * * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setFgColor($pValue = null) { @@ -468,8 +422,6 @@ public function setFgColor($pValue = null) } /** - * Get style type - * * @return string */ public function getStyleType() @@ -478,9 +430,7 @@ public function getStyleType() } /** - * Get paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() { @@ -488,11 +438,9 @@ public function getParagraphStyle() } /** - * Set the line height - * - * @param int|float|string $lineHeight + * @param int|float|string $lineHeight * @return $this - * @throws InvalidStyleException + * @throws \PhpOffice\PhpWord\Exceptions\InvalidStyleException */ public function setLineHeight($lineHeight) { @@ -531,7 +479,7 @@ public function getHint() * Set Font Content Type * * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public function setHint($pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE) { @@ -541,4 +489,4 @@ public function setHint($pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE) $this->_hint = $pValue; return $this; } -} +} \ No newline at end of file diff --git a/src/Style/Image.php b/src/Style/Image.php index fbc074bea7..a2390126ba 100644 --- a/src/Style/Image.php +++ b/src/Style/Image.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -145,7 +143,7 @@ public function setMarginLeft($pValue = null) /** * @param string $wrappingStyle - * @throws InvalidArgumentException + * @throws \InvalidArgumentException * @return $this */ public function setWrappingStyle($wrappingStyle) @@ -159,7 +157,7 @@ public function setWrappingStyle($wrappingStyle) $this->wrappingStyle = $wrappingStyle; break; default: - throw new InvalidArgumentException('Wrapping style does not exists'); + throw new \InvalidArgumentException('Wrapping style does not exists'); break; } return $this; diff --git a/src/Style/ListItem.php b/src/Style/ListItem.php index 458e08e8a0..d0d6c75086 100644 --- a/src/Style/ListItem.php +++ b/src/Style/ListItem.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Style/Paragraph.php b/src/Style/Paragraph.php index 87827448ea..b4d9006f67 100644 --- a/src/Style/Paragraph.php +++ b/src/Style/Paragraph.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -186,7 +184,7 @@ public function getAlign() * Set Paragraph Alignment * * @param string $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setAlign($pValue = null) { @@ -212,7 +210,7 @@ public function getSpaceBefore() * Set Space before Paragraph * * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setSpaceBefore($pValue = null) { @@ -234,7 +232,7 @@ public function getSpaceAfter() * Set Space after Paragraph * * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setSpaceAfter($pValue = null) { @@ -256,7 +254,7 @@ public function getSpacing() * Set Spacing between breaks * * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setSpacing($pValue = null) { @@ -278,7 +276,7 @@ public function getIndent() * Set indentation * * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setIndent($pValue = null) { @@ -300,7 +298,7 @@ public function getHanging() * Set hanging * * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setHanging($pValue = null) { @@ -311,7 +309,7 @@ public function setHanging($pValue = null) /** * Get tabs * - * @return PhpOffice\PhpWord\Style\Tabs + * @return \PhpOffice\PhpWord\Style\Tabs */ public function getTabs() { @@ -322,7 +320,7 @@ public function getTabs() * Set tabs * * @param array $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setTabs($pValue = null) { @@ -346,7 +344,7 @@ public function getBasedOn() * Set parent style ID * * @param string $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setBasedOn($pValue = 'Normal') { @@ -368,7 +366,7 @@ public function getNext() * Set style for next paragraph * * @param string $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setNext($pValue = null) { @@ -390,7 +388,7 @@ public function getWidowControl() * Set keep paragraph with next paragraph setting * * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setWidowControl($pValue = true) { @@ -415,7 +413,7 @@ public function getKeepNext() * Set keep paragraph with next paragraph setting * * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setKeepNext($pValue = false) { @@ -440,7 +438,7 @@ public function getKeepLines() * Set keep all lines on one page setting * * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setKeepLines($pValue = false) { @@ -465,7 +463,7 @@ public function getPageBreakBefore() * Set start paragraph on next page setting * * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setPageBreakBefore($pValue = false) { @@ -481,7 +479,7 @@ public function setPageBreakBefore($pValue = false) * * @param int|float|string $lineHeight * @return $this - * @throws InvalidStyleException + * @throws \PhpOffice\PhpWord\Exceptions\InvalidStyleException */ public function setLineHeight($lineHeight) { diff --git a/src/Style/Row.php b/src/Style/Row.php index 5431dd201d..237241e58f 100644 --- a/src/Style/Row.php +++ b/src/Style/Row.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2013 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Style/TOC.php b/src/Style/TOC.php index b7da10595c..dac60b40bb 100644 --- a/src/Style/TOC.php +++ b/src/Style/TOC.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Style/Tab.php b/src/Style/Tab.php index b9d949e904..d55e914abb 100644 --- a/src/Style/Tab.php +++ b/src/Style/Tab.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -107,7 +105,7 @@ public function __construct($val = null, $position = 0, $leader = null) /** * Creates the XML DOM for the instance of Tab. * - * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter + * @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter */ public function toXml(XMLWriter &$xmlWriter = null) { diff --git a/src/Style/Table.php b/src/Style/Table.php index 4de5660567..15c766d21b 100644 --- a/src/Style/Table.php +++ b/src/Style/Table.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Style/TableFull.php b/src/Style/TableFull.php index 5ca7561b23..f2b41b3703 100644 --- a/src/Style/TableFull.php +++ b/src/Style/TableFull.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -32,7 +30,7 @@ class TableFull /** * Style for first row * - * @var PhpOffice\PhpWord\Style\TableFull + * @var \PhpOffice\PhpWord\Style\TableFull */ private $_firstRow = null; @@ -174,7 +172,7 @@ public function setStyleValue($key, $value) /** * Get First Row Style * - * @return PhpOffice\PhpWord\Style\TableFull + * @return \PhpOffice\PhpWord\Style\TableFull */ public function getFirstRow() { @@ -184,7 +182,7 @@ public function getFirstRow() /** * Get Last Row Style * - * @return PhpOffice\PhpWord\Style\TableFull + * @return \PhpOffice\PhpWord\Style\TableFull */ public function getLastRow() { diff --git a/src/Style/Tabs.php b/src/Style/Tabs.php index 45fdb5682d..f836532f32 100644 --- a/src/Style/Tabs.php +++ b/src/Style/Tabs.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -48,7 +46,7 @@ public function __construct(array $tabs) } /** - * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter + * @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter */ public function toXml(XMLWriter &$xmlWriter = null) { diff --git a/src/TOC.php b/src/TOC.php index 932e54be3b..17df13b1ef 100644 --- a/src/TOC.php +++ b/src/TOC.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -75,7 +73,7 @@ class TOC */ public function __construct($styleFont = null, $styleTOC = null) { - self::$_styleTOC = new PhpOffice\PhpWord\Style\TOC(); + self::$_styleTOC = new \PhpOffice\PhpWord\Style\TOC(); if (!is_null($styleTOC) && is_array($styleTOC)) { foreach ($styleTOC as $key => $value) { @@ -136,7 +134,7 @@ public static function getTitles() /** * Get TOC Style * - * @return PhpOffice\PhpWord\Style\TOC + * @return \PhpOffice\PhpWord\Style\TOC */ public static function getStyleTOC() { @@ -146,7 +144,7 @@ public static function getStyleTOC() /** * Get Font Style * - * @return PhpOffice\PhpWord\Style\Font + * @return \PhpOffice\PhpWord\Style\Font */ public static function getStyleFont() { diff --git a/src/Template.php b/src/Template.php index a248de7f42..65d0c989c9 100644 --- a/src/Template.php +++ b/src/Template.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -33,22 +31,16 @@ class Template { /** - * ZipArchive - * * @var \ZipArchive */ private $_objZip; /** - * Temporary Filename - * * @var string */ private $_tempFileName; /** - * Document XML - * * @var string */ private $_documentXML; @@ -58,7 +50,7 @@ class Template * Create a new Template Object * * @param string $strFilename - * @throws Exception + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function __construct($strFilename) { @@ -81,14 +73,14 @@ public function __construct($strFilename) /** * Applies XSL style sheet to template's parts * - * @param DOMDocument $xslDOMDocument + * @param \DOMDocument $xslDOMDocument * @param array $xslOptions * @param string $xslOptionsURI - * @throws Exception + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') { - $processor = new XSLTProcessor(); + $processor = new \XSLTProcessor(); $processor->importStylesheet($xslDOMDocument); @@ -96,7 +88,7 @@ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xsl throw new Exception('Could not set values for the given XSL style sheet parameters.'); } - $xmlDOMDocument = new DOMDocument(); + $xmlDOMDocument = new \DOMDocument(); if ($xmlDOMDocument->loadXML($this->_documentXML) === false) { throw new Exception('Could not load XML from the given template.'); } @@ -160,7 +152,7 @@ public function getVariables() * * @param int $offset * @return int - * @throws Exception + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ private function _findRowStart($offset) { @@ -206,7 +198,7 @@ private function _getSlice($startPosition, $endPosition = 0) * * @param string $search * @param int $numberOfClones - * @throws Exception + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function cloneRow($search, $numberOfClones) { @@ -257,10 +249,8 @@ public function cloneRow($search, $numberOfClones) } /** - * Save Template - * * @return string - * @throws Exception + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function save() { @@ -275,8 +265,6 @@ public function save() } /** - * Save Template As... - * * @param string $strFilename */ public function saveAs($strFilename) diff --git a/src/Writer/IWriter.php b/src/Writer/IWriter.php index 98c15704fe..697aaa9e14 100644 --- a/src/Writer/IWriter.php +++ b/src/Writer/IWriter.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -33,7 +31,6 @@ interface IWriter * Save PhpWord to file * * @param string $pFileName - * @throws \Exception */ public function save($pFilename = null); } \ No newline at end of file diff --git a/src/Writer/ODText.php b/src/Writer/ODText.php index c8a2c75a2b..1b12e65097 100644 --- a/src/Writer/ODText.php +++ b/src/Writer/ODText.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\HashTable; use PhpOffice\PhpWord\Writer\ODText\Content; @@ -38,19 +37,19 @@ class ODText implements IWriter { /** - * @var PhpOffice\PhpWord + * @var \PhpOffice\PhpWord\PhpWord */ private $_document; /** - * @var PhpOffice\PhpWord\Writer\ODText\WriterPart[] + * @var \PhpOffice\PhpWord\Writer\ODText\WriterPart[] */ private $_writerParts; /** * Private unique PHPWord_Worksheet_BaseDrawing HashTable * - * @var PhpOffice\PhpWord\HashTable + * @var \PhpOffice\PhpWord\HashTable */ private $_drawingHashTable; @@ -67,7 +66,7 @@ class ODText implements IWriter private $_diskCachingDirectory; /** - * @param PhpOffice\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord */ public function __construct(PhpWord $phpWord = null) { @@ -98,7 +97,7 @@ public function __construct(PhpWord $phpWord = null) * Save PhpWord to file * * @param string $pFileName - * @throws \Exception + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function save($pFilename = null) { @@ -120,7 +119,7 @@ public function save($pFilename = null) // Try opening the ZIP file if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) { if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) { - throw new \Exception("Could not open " . $pFilename . " for writing."); + throw new Exception("Could not open " . $pFilename . " for writing."); } } @@ -177,38 +176,38 @@ public function save($pFilename = null) // Close file if ($objZip->close() === false) { - throw new \Exception("Could not close zip file $pFilename."); + throw new Exception("Could not close zip file $pFilename."); } // If a temporary file was used, copy it to the correct file stream if ($originalFilename != $pFilename) { if (copy($pFilename, $originalFilename) === false) { - throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename."); } @unlink($pFilename); } } else { - throw new \Exception("PhpWord object unassigned."); + throw new Exception("PhpWord object unassigned."); } } /** - * @return PhpOffice\PhpWord - * @throws \Exception + * @return \PhpOffice\PhpWord\PhpWord + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function getPhpWord() { if (!is_null($this->_document)) { return $this->_document; } else { - throw new \Exception("No PhpWord assigned."); + throw new Exception("No PhpWord assigned."); } } /** - * @param PhpOffice\PhpWord $phpWord - * @return PhpOffice\PhpWord\Writer\ODText + * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return \PhpOffice\PhpWord\Writer\ODText */ public function setPhpWord(PhpWord $phpWord = null) { @@ -219,7 +218,7 @@ public function setPhpWord(PhpWord $phpWord = null) /** * Get PHPWord_Worksheet_BaseDrawing HashTable * - * @return PhpOffice\PhpWord\HashTable + * @return \PhpOffice\PhpWord\HashTable */ public function getDrawingHashTable() { @@ -228,7 +227,7 @@ public function getDrawingHashTable() /** * @param string $pPartName Writer part name - * @return PhpOffice\PhpWord\Writer\ODText\WriterPart + * @return \PhpOffice\PhpWord\Writer\ODText\WriterPart */ public function getWriterPart($pPartName = '') { @@ -254,8 +253,8 @@ public function getUseDiskCaching() * * @param boolean $pValue * @param string $pDirectory Disk caching directory - * @throws \Exception Exception when directory does not exist - * @return PhpOffice\PhpWord\Writer\ODText + * @throws \PhpOffice\PhpWord\Exceptions\Exception Exception when directory does not exist + * @return \PhpOffice\PhpWord\Writer\ODText */ public function setUseDiskCaching($pValue = false, $pDirectory = null) { @@ -265,7 +264,7 @@ public function setUseDiskCaching($pValue = false, $pDirectory = null) if (is_dir($pDirectory)) { $this->_diskCachingDirectory = $pDirectory; } else { - throw new \Exception("Directory does not exist: $pDirectory"); + throw new Exception("Directory does not exist: $pDirectory"); } } diff --git a/src/Writer/ODText/Content.php b/src/Writer/ODText/Content.php index c809708f07..c73c6cf8b4 100644 --- a/src/Writer/ODText/Content.php +++ b/src/Writer/ODText/Content.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -51,9 +49,8 @@ class Content extends WriterPart /** * Write content file to XML format * - * @param PhpOffice\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return string XML Output - * @throws Exception */ public function writeContent(PhpWord $phpWord = null) { @@ -125,7 +122,7 @@ public function writeContent(PhpWord $phpWord = null) $arrStyle = array( 'color' => $fStyle->getColor(), - 'name' => $fStyle->getName() + 'name' => $fStyle->getName() ); $phpWord->addFontStyle('T' . $numFStyles, $arrStyle); $element->setFontStyle('T' . $numFStyles); @@ -311,8 +308,8 @@ public function writeContent(PhpWord $phpWord = null) /** * Write text * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\Text $text + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Section\Text $text * @param bool $withoutP */ protected function _writeText(XMLWriter $xmlWriter = null, Text $text, $withoutP = false) @@ -359,8 +356,8 @@ protected function _writeText(XMLWriter $xmlWriter = null, Text $text, $withoutP /** * Write TextRun section * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\TextRun $textrun + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Section\TextRun $textrun * @todo Enable all other section types */ protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) @@ -400,7 +397,7 @@ private function _writeSection(XMLWriter $xmlWriter = null, Section $section = n /** * Write unsupported element * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $element */ private function writeUnsupportedElement($xmlWriter, $element) diff --git a/src/Writer/ODText/Manifest.php b/src/Writer/ODText/Manifest.php index f27f135059..48b230e947 100644 --- a/src/Writer/ODText/Manifest.php +++ b/src/Writer/ODText/Manifest.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer\ODText; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\File; use PhpOffice\PhpWord\Shared\XMLWriter; @@ -36,9 +35,8 @@ class Manifest extends WriterPart /** * Write Manifest file to XML format * - * @param PhpOffice\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return string XML Output - * @throws Exception */ public function writeManifest(PhpWord $phpWord = null) { @@ -116,9 +114,9 @@ public function writeManifest(PhpWord $phpWord = null) /** * Get image mime type * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception + * @param string $pFile Filename + * @return string Mime Type + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ private function _getImageMimeType($pFile = '') { @@ -129,4 +127,4 @@ private function _getImageMimeType($pFile = '') throw new Exception("File $pFile does not exist"); } } -} +} \ No newline at end of file diff --git a/src/Writer/ODText/Meta.php b/src/Writer/ODText/Meta.php index 1b30efa394..16814cb3b1 100644 --- a/src/Writer/ODText/Meta.php +++ b/src/Writer/ODText/Meta.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -35,9 +33,8 @@ class Meta extends WriterPart /** * Write Meta file to XML format * - * @param PhpOffice\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return string XML Output - * @throws Exception */ public function writeMeta(PhpWord $phpWord = null) { diff --git a/src/Writer/ODText/Mimetype.php b/src/Writer/ODText/Mimetype.php index 59386d5ac6..6e0638dedb 100644 --- a/src/Writer/ODText/Mimetype.php +++ b/src/Writer/ODText/Mimetype.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -34,13 +32,11 @@ class Mimetype extends WriterPart /** * Write Mimetype to Text format * - * @param PhpOffice\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return string Text Output - * @throws Exception */ public function writeMimetype(PhpWord $phpWord = null) { - return 'application/vnd.oasis.opendocument.text'; } -} +} \ No newline at end of file diff --git a/src/Writer/ODText/Styles.php b/src/Writer/ODText/Styles.php index 721a6b60cf..e5a53172a6 100644 --- a/src/Writer/ODText/Styles.php +++ b/src/Writer/ODText/Styles.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -39,9 +37,8 @@ class Styles extends WriterPart /** * Write Styles file to XML format * - * @param PhpOffice\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return string XML Output - * @throws Exception */ public function writeStyles(PhpWord $phpWord = null) { diff --git a/src/Writer/ODText/WriterPart.php b/src/Writer/ODText/WriterPart.php index 06e4a404cc..a08b25c276 100644 --- a/src/Writer/ODText/WriterPart.php +++ b/src/Writer/ODText/WriterPart.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer\ODText; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Writer\IWriter; abstract class WriterPart @@ -34,15 +33,14 @@ abstract class WriterPart /** * Parent IWriter object * - * @var PhpOffice\PhpWord\Writer\IWriter + * @var \PhpOffice\PhpWord\Writer\IWriter */ private $_parentWriter; /** * Set parent IWriter object * - * @param PhpOffice\PhpWord\Writer\IWriter $pWriter - * @throws Exception + * @param \PhpOffice\PhpWord\Writer\IWriter $pWriter */ public function setParentWriter(IWriter $pWriter = null) { @@ -52,8 +50,8 @@ public function setParentWriter(IWriter $pWriter = null) /** * Get parent IWriter object * - * @return PhpOffice\PhpWord\Writer\IWriter - * @throws Exception + * @return \PhpOffice\PhpWord\Writer\IWriter + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function getParentWriter() { @@ -63,4 +61,4 @@ public function getParentWriter() throw new Exception("No parent IWriter assigned."); } } -} +} \ No newline at end of file diff --git a/src/Writer/RTF.php b/src/Writer/RTF.php index 57c17fdb4b..263dce0e17 100644 --- a/src/Writer/RTF.php +++ b/src/Writer/RTF.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\HashTable; use PhpOffice\PhpWord\Section\Image; @@ -51,14 +50,14 @@ class RTF implements IWriter /** * Private PhpWord * - * @var PhpOffice\PhpWord + * @var \PhpOffice\PhpWord\PhpWord */ private $_document; /** * Private unique PHPWord_Worksheet_BaseDrawing HashTable * - * @var PhpOffice\PhpWord\HashTable + * @var \PhpOffice\PhpWord\HashTable */ private $_drawingHashTable; @@ -67,7 +66,7 @@ class RTF implements IWriter private $_lastParagraphStyle; /** - * @param PhpOffice\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord */ public function __construct(PhpWord $phpWord = null) { @@ -82,7 +81,7 @@ public function __construct(PhpWord $phpWord = null) * Save PhpWord to file * * @param string $pFileName - * @throws \Exception + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function save($pFilename = null) { @@ -103,33 +102,32 @@ public function save($pFilename = null) // If a temporary file was used, copy it to the correct file stream if ($originalFilename != $pFilename) { if (copy($pFilename, $originalFilename) === false) { - throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename."); } @unlink($pFilename); } } else { - throw new \Exception("PhpWord object unassigned."); + throw new Exception("PhpWord object unassigned."); } } /** - * @return PhpOffice\PhpWord - * @throws \Exception + * @return \PhpOffice\PhpWord\PhpWord + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function getPhpWord() { if (!is_null($this->_document)) { return $this->_document; } else { - throw new \Exception("No PhpWord assigned."); + throw new Exception("No PhpWord assigned."); } } /** - * @param PhpOffice\PhpWord $phpWord - * @throws \Exception - * @return PhpOffice\PhpWord\Writer\RTF + * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return \PhpOffice\PhpWord\Writer\RTF */ public function setPhpWord(PhpWord $phpWord = null) { @@ -140,7 +138,7 @@ public function setPhpWord(PhpWord $phpWord = null) /** * Get PHPWord_Worksheet_BaseDrawing HashTable * - * @return PhpOffice\PhpWord\HashTable + * @return \PhpOffice\PhpWord\HashTable */ public function getDrawingHashTable() { @@ -160,22 +158,22 @@ private function getData() $sRTFContent .= '\deff0'; // Set the default tab size (720 twips) $sRTFContent .= '\deftab720'; - $sRTFContent .= PHP_EOL; + $sRTFContent .= \PHP_EOL; // Set the font tbl group $sRTFContent .= '{\fonttbl'; foreach ($this->_fontTable as $idx => $font) { $sRTFContent .= '{\f' . $idx . '\fnil\fcharset0 ' . $font . ';}'; } - $sRTFContent .= '}' . PHP_EOL; + $sRTFContent .= '}' . \PHP_EOL; // Set the color tbl group $sRTFContent .= '{\colortbl '; foreach ($this->_colorTable as $idx => $color) { $arrColor = Drawing::htmlToRGB($color); $sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; } - $sRTFContent .= ';}' . PHP_EOL; + $sRTFContent .= ';}' . \PHP_EOL; // Set the generator - $sRTFContent .= '{\*\generator PhpWord;}' . PHP_EOL; + $sRTFContent .= '{\*\generator PhpWord;}' . \PHP_EOL; // Set the view mode of the document $sRTFContent .= '\viewkind4'; // Set the numberof bytes that follows a unicode character @@ -190,7 +188,7 @@ private function getData() $sRTFContent .= '\kerning1'; // Set the font size in half-points $sRTFContent .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); - $sRTFContent .= PHP_EOL; + $sRTFContent .= \PHP_EOL; // Body $sRTFContent .= $this->getDataContent(); @@ -435,7 +433,7 @@ private function getDataContentText(Text $text, $withoutP = false) } if (!$withoutP) { - $sRTFText .= '\par' . PHP_EOL; + $sRTFText .= '\par' . \PHP_EOL; } return $sRTFText; } @@ -445,15 +443,15 @@ private function getDataContentTextRun(TextRun $textrun) $sRTFText = ''; $elements = $textrun->getElements(); if (count($elements) > 0) { - $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; + $sRTFText .= '\pard\nowidctlpar' . \PHP_EOL; foreach ($elements as $element) { if ($element instanceof Text) { $sRTFText .= '{'; $sRTFText .= $this->getDataContentText($element, true); - $sRTFText .= '}' . PHP_EOL; + $sRTFText .= '}' . \PHP_EOL; } } - $sRTFText .= '\par' . PHP_EOL; + $sRTFText .= '\par' . \PHP_EOL; } return $sRTFText; } @@ -462,7 +460,7 @@ private function getDataContentTextBreak() { $this->_lastParagraphStyle = ''; - return '\par' . PHP_EOL; + return '\par' . \PHP_EOL; } /** @@ -473,9 +471,9 @@ private function getDataContentTextBreak() private function getDataContentUnsupportedElement($element) { $sRTFText = ''; - $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; + $sRTFText .= '\pard\nowidctlpar' . \PHP_EOL; $sRTFText .= "{$element}"; - $sRTFText .= '\par' . PHP_EOL; + $sRTFText .= '\par' . \PHP_EOL; return $sRTFText; } diff --git a/src/Writer/Word2007.php b/src/Writer/Word2007.php index de31e71e53..a8c2dacc11 100644 --- a/src/Writer/Word2007.php +++ b/src/Writer/Word2007.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Footnote; use PhpOffice\PhpWord\Media; @@ -222,15 +221,15 @@ private function checkContentTypes($src) $extension = 'php'; } else { $imageType = exif_imagetype($src); - if ($imageType === IMAGETYPE_JPEG) { + if ($imageType === \IMAGETYPE_JPEG) { $extension = 'jpg'; - } elseif ($imageType === IMAGETYPE_GIF) { + } elseif ($imageType === \IMAGETYPE_GIF) { $extension = 'gif'; - } elseif ($imageType === IMAGETYPE_PNG) { + } elseif ($imageType === \IMAGETYPE_PNG) { $extension = 'png'; - } elseif ($imageType === IMAGETYPE_BMP) { + } elseif ($imageType === \IMAGETYPE_BMP) { $extension = 'bmp'; - } elseif ($imageType === IMAGETYPE_TIFF_II || $imageType === IMAGETYPE_TIFF_MM) { + } elseif ($imageType === \IMAGETYPE_TIFF_II || $imageType === \IMAGETYPE_TIFF_MM) { $extension = 'tif'; } } diff --git a/src/Writer/Word2007/Base.php b/src/Writer/Word2007/Base.php index f0029fc499..a7090d1e65 100644 --- a/src/Writer/Word2007/Base.php +++ b/src/Writer/Word2007/Base.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -137,8 +135,8 @@ protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) } /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Style\Paragraph $style + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Paragraph $style * @param bool $withoutPPR * @return void */ @@ -475,8 +473,8 @@ protected function _writeTextStyle(XMLWriter $xmlWriter = null, Font $style) } /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\TextBreak $element + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Section\TextBreak $element */ protected function _writeTextBreak($xmlWriter, $element = null) { @@ -632,7 +630,7 @@ protected function _writeTable(XMLWriter $xmlWriter = null, Table $table) protected function _writeTableStyle( XMLWriter $xmlWriter = null, - PhpOffice\PhpWord\Style\Table $style = null + \PhpOffice\PhpWord\Style\Table $style = null ) { $margins = $style->getCellMargin(); $mTop = (!is_null($margins[0])) ? true : false; @@ -781,8 +779,8 @@ protected function _writeCellStyle(XMLWriter $xmlWriter = null, Cell $style = nu } /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\Image|PhpOffice\PhpWord\Section\MemoryImage $image + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Section\Image|\PhpOffice\PhpWord\Section\MemoryImage $image */ protected function _writeImage(XMLWriter $xmlWriter = null, $image, $withoutP = false) { @@ -830,16 +828,16 @@ protected function _writeImage(XMLWriter $xmlWriter = null, $image, $withoutP = } switch ($wrappingStyle) { - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND: + case \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND: $imgStyle .= 'position:absolute;z-index:-251658752;'; break; - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE: + case \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE: $imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; break; - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_TIGHT: + case \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_TIGHT: $imgStyle .= 'position:absolute;z-index:251659264;mso-wrap-edited:f;mso-position-horizontal:absolute;mso-position-vertical:absolute'; break; - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_INFRONT: + case \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_INFRONT: $imgStyle .= 'position:absolute;zz-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; break; } diff --git a/src/Writer/Word2007/ContentTypes.php b/src/Writer/Word2007/ContentTypes.php index 2d84070d01..787eb5ad68 100644 --- a/src/Writer/Word2007/ContentTypes.php +++ b/src/Writer/Word2007/ContentTypes.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Shared\File; use PhpOffice\PhpWord\Shared\XMLWriter; @@ -174,9 +173,9 @@ public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers /** * Get image mime type * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception + * @param string $pFile Filename + * @return string Mime Type + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ private function _getImageMimeType($pFile = '') { @@ -189,10 +188,10 @@ private function _getImageMimeType($pFile = '') } /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ private function _writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') { @@ -208,10 +207,10 @@ private function _writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartnam } /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ private function _writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') { @@ -225,4 +224,4 @@ private function _writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartna throw new Exception("Invalid parameters passed."); } } -} +} \ No newline at end of file diff --git a/src/Writer/Word2007/DocProps.php b/src/Writer/Word2007/DocProps.php index 98a5abb871..bbfc6523f8 100644 --- a/src/Writer/Word2007/DocProps.php +++ b/src/Writer/Word2007/DocProps.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 diff --git a/src/Writer/Word2007/Document.php b/src/Writer/Word2007/Document.php index f865c41c47..142fa252fb 100644 --- a/src/Writer/Word2007/Document.php +++ b/src/Writer/Word2007/Document.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -28,6 +26,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Section; use PhpOffice\PhpWord\Section\Footnote; use PhpOffice\PhpWord\Section\Image; use PhpOffice\PhpWord\Section\Link; diff --git a/src/Writer/Word2007/DocumentRels.php b/src/Writer/Word2007/DocumentRels.php index 176dd05512..02071666ec 100644 --- a/src/Writer/Word2007/DocumentRels.php +++ b/src/Writer/Word2007/DocumentRels.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Shared\XMLWriter; class DocumentRels extends WriterPart @@ -179,4 +178,4 @@ private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pTyp throw new Exception("Invalid parameters passed."); } } -} +} \ No newline at end of file diff --git a/src/Writer/Word2007/Footer.php b/src/Writer/Word2007/Footer.php index f3ef2a1fb4..e10a7eff05 100644 --- a/src/Writer/Word2007/Footer.php +++ b/src/Writer/Word2007/Footer.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -38,7 +36,7 @@ class Footer extends Base { - public function writeFooter(PhpOffice\PhpWord\Section\Footer $footer) + public function writeFooter(\PhpOffice\PhpWord\Section\Footer $footer) { // Create XML writer $xmlWriter = null; diff --git a/src/Writer/Word2007/Footnotes.php b/src/Writer/Word2007/Footnotes.php index d467859f90..fa048c4623 100644 --- a/src/Writer/Word2007/Footnotes.php +++ b/src/Writer/Word2007/Footnotes.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -72,7 +70,6 @@ public function writeFootnotes($allFootnotesCollection) $xmlWriter->endElement(); // w:p $xmlWriter->endElement(); // w:footnote - foreach ($allFootnotesCollection as $footnote) { if ($footnote instanceof Footnote) { $this->_writeFootnote($xmlWriter, $footnote); diff --git a/src/Writer/Word2007/FootnotesRels.php b/src/Writer/Word2007/FootnotesRels.php index b181987676..6b2b56026f 100644 --- a/src/Writer/Word2007/FootnotesRels.php +++ b/src/Writer/Word2007/FootnotesRels.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Shared\XMLWriter; class FootnotesRels extends WriterPart @@ -86,4 +85,4 @@ private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pTyp throw new Exception("Invalid parameters passed."); } } -} +} \ No newline at end of file diff --git a/src/Writer/Word2007/Header.php b/src/Writer/Word2007/Header.php index aef2c38a7c..b5695f8816 100644 --- a/src/Writer/Word2007/Header.php +++ b/src/Writer/Word2007/Header.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -38,7 +36,7 @@ class Header extends Base { - public function writeHeader(PhpOffice\PhpWord\Section\Header $header) + public function writeHeader(\PhpOffice\PhpWord\Section\Header $header) { // Create XML writer if ($this->getParentWriter()->getUseDiskCaching()) { diff --git a/src/Writer/Word2007/Rels.php b/src/Writer/Word2007/Rels.php index 09de0e63fb..db817f9cbc 100644 --- a/src/Writer/Word2007/Rels.php +++ b/src/Writer/Word2007/Rels.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; @@ -83,12 +82,12 @@ public function writeRelationships(PhpWord $phpWord = null) /** * Write Override content type * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param int $pId Relationship ID. rId will be prepended! - * @param string $pType Relationship type - * @param string $pTarget Relationship target - * @param string $pTargetMode Relationship target mode - * @throws Exception + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param int $pId Relationship ID. rId will be prepended! + * @param string $pType Relationship type + * @param string $pTarget Relationship target + * @param string $pTargetMode Relationship target mode + * @throws \PhpOffice\PhpWord\Exceptions\Exception */ private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { @@ -112,4 +111,4 @@ private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pTyp throw new Exception("Invalid parameters passed."); } } -} +} \ No newline at end of file diff --git a/src/Writer/Word2007/Styles.php b/src/Writer/Word2007/Styles.php index 81ee36ef2a..b90f4eb31c 100644 --- a/src/Writer/Word2007/Styles.php +++ b/src/Writer/Word2007/Styles.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -299,7 +297,6 @@ private function _writeFullTableStyle(XMLWriter $xmlWriter = null, TableFull $st $xmlWriter->endElement(); } - // First Row $firstRow = $style->getFirstRow(); if (!is_null($firstRow)) { @@ -396,4 +393,4 @@ private function _writeDocDefaults(XMLWriter $xmlWriter = null) $xmlWriter->endElement(); $xmlWriter->endElement(); } -} +} \ No newline at end of file diff --git a/src/Writer/Word2007/WriterPart.php b/src/Writer/Word2007/WriterPart.php index bb8fefc334..38bead77ff 100644 --- a/src/Writer/Word2007/WriterPart.php +++ b/src/Writer/Word2007/WriterPart.php @@ -18,8 +18,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PhpWord - * @package PhpWord * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.8.0 @@ -27,6 +25,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; +use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Writer\IWriter; abstract class WriterPart @@ -46,4 +45,4 @@ public function getParentWriter() throw new Exception("No parent IWriter assigned."); } } -} +} \ No newline at end of file From c305273e25018305678255d30079cfde84640e4e Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Mar 2014 10:33:10 +0400 Subject: [PATCH 15/15] https://github.com/PHPOffice/PHPWord/issues/58 - PNG filename fix. --- samples/resources/{PHPWord.png => PhpWord.png} | Bin 1 file changed, 0 insertions(+), 0 deletions(-) rename samples/resources/{PHPWord.png => PhpWord.png} (100%) diff --git a/samples/resources/PHPWord.png b/samples/resources/PhpWord.png similarity index 100% rename from samples/resources/PHPWord.png rename to samples/resources/PhpWord.png