From 8c4efdd607540030829e7bf0b50399bb6eb0b5f1 Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Wed, 11 Dec 2013 14:39:43 -0500 Subject: [PATCH 01/11] Added support for composer --- .gitignore | 13 +++++++++-- .travis.yml | 10 +++++++++ README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++-- changelog.txt | 2 ++ composer.json | 22 +++++++++++++++++++ phpunit.xml.dist | 0 6 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 .travis.yml create mode 100644 changelog.txt create mode 100644 composer.json create mode 100644 phpunit.xml.dist diff --git a/.gitignore b/.gitignore index 29a804cb59..4553eaa28c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,14 @@ - +.DS_Store +._* +.Spotlight-V100 +.Trashes +Thumbs.db +Desktop.ini +.idea +phpunit.xml +composer.lock +vendor /.settings /.buildpath /.project -/docs \ No newline at end of file +/docs diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..7604e9cfc8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + +before_script: + - curl -s http://getcomposer.org/installer | php + - php composer.phar install --dev --prefer-source diff --git a/README.md b/README.md index 6355848c2e..cac0d1193a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,61 @@ # PHPWord - OpenXML - Read, Write and Create Word documents in PHP + PHPWord is a library written in PHP that create word documents. -No Windows operating system is needed for usage because the result are docx files (Office Open XML) that can be opened by all major office software. +No Windows operating system is needed for usage because the result are docx files (Office Open XML) that can be +opened by all major office software. ## Want to contribute? Fork us! +## Requirements + +* PHP version 5.2.0 or higher + ## License -PHPWord is licensed under [LGPL (GNU LESSER GENERAL PUBLIC LICENSE)](https://github.com/PHPOffice/PHPWord/blob/master/license.md) \ No newline at end of file +PHPWord is licensed under [LGPL (GNU LESSER GENERAL PUBLIC LICENSE)](https://github.com/PHPOffice/PHPWord/blob/master/license.md) + +## Installation + +It is recommended that you install the PHPWord library [through composer](http://getcomposer.org/). To do so, add +the following lines to your ``composer.json``. + +```json +{ + "require": { + "phpoffice/phpword": "dev-master" + } +} +``` + +## Usage + +The following is a basic example of the PHPWord library. + +```php +// Create a new PHPWord Object +$PHPWord = new PHPWord(); + +// Every element you want to append to the word document is placed in a section. So you need a section: +$section = $PHPWord->createSection(); + +// After creating a section, you can append elements: +$section->addText('Hello world!'); + +// You can directly style your text by giving the addText function an array: +$section->addText('Hello world! I am formatted.', array('name'=>'Tahoma', 'size'=>16, 'bold'=>true)); + +// 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', array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232')); +$section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle'); + +// You can also putthe appended element to local object an call functions like this: +$myTextElement = $section->addText('Hello World!'); +$myTextElement->setBold(); +$myTextElement->setName('Verdana'); +$myTextElement->setSize(22); + +// At least write the document to webspace: +$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); +$objWriter->save('helloWorld.docx'); +``` diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000000..abd7d3dad6 --- /dev/null +++ b/changelog.txt @@ -0,0 +1,2 @@ +2013-12-11 (v1.0): +- Feature: (gavroche) Added composer file \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000..3d111441a8 --- /dev/null +++ b/composer.json @@ -0,0 +1,22 @@ +{ + "name": "phpoffice/phpword", + "description": "PHPWord - OpenXML - Read, Write and Create Word documents in PHP", + "keywords": ["PHP","Word","docx","doc"], + "homepage": "http://phpword.codeplex.com", + "type": "library", + "license": "LGPL", + "authors": [ + { + "name": "Gabriel Bull", + "email": "gavroche.bull@gmail.com" + } + ], + "require": { + "php": ">=5.2.0" + }, + "autoload": { + "psr-0": { + "PHPWord": "src/" + } + } +} \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000000..e69de29bb2 From 3f7ed20a2818c1ef56e77943b2f282e6bbdd32b4 Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Wed, 11 Dec 2013 14:41:54 -0500 Subject: [PATCH 02/11] Moved examples outside of the source --- {src/Examples => Examples}/AdvancedTable.php | 0 {src/Examples => Examples}/BasicTable.php | 0 {src/Examples => Examples}/HeaderFooter.php | 0 {src/Examples => Examples}/Image.php | 0 {src/Examples => Examples}/Link.php | 0 {src/Examples => Examples}/ListItem.php | 0 {src/Examples => Examples}/Object.php | 0 {src/Examples => Examples}/Section.php | 0 {src/Examples => Examples}/Template.php | 0 {src/Examples => Examples}/Textrun.php | 0 {src/Examples => Examples}/TitleTOC.php | 0 {src/Examples => Examples}/Watermark.php | 0 {src/Examples => Examples}/_earth.JPG | Bin {src/Examples => Examples}/_mars.jpg | Bin {src/Examples => Examples}/_sheet.xls | Bin 15 files changed, 0 insertions(+), 0 deletions(-) rename {src/Examples => Examples}/AdvancedTable.php (100%) rename {src/Examples => Examples}/BasicTable.php (100%) rename {src/Examples => Examples}/HeaderFooter.php (100%) rename {src/Examples => Examples}/Image.php (100%) rename {src/Examples => Examples}/Link.php (100%) rename {src/Examples => Examples}/ListItem.php (100%) rename {src/Examples => Examples}/Object.php (100%) rename {src/Examples => Examples}/Section.php (100%) rename {src/Examples => Examples}/Template.php (100%) rename {src/Examples => Examples}/Textrun.php (100%) rename {src/Examples => Examples}/TitleTOC.php (100%) rename {src/Examples => Examples}/Watermark.php (100%) rename {src/Examples => Examples}/_earth.JPG (100%) rename {src/Examples => Examples}/_mars.jpg (100%) rename {src/Examples => Examples}/_sheet.xls (100%) diff --git a/src/Examples/AdvancedTable.php b/Examples/AdvancedTable.php similarity index 100% rename from src/Examples/AdvancedTable.php rename to Examples/AdvancedTable.php diff --git a/src/Examples/BasicTable.php b/Examples/BasicTable.php similarity index 100% rename from src/Examples/BasicTable.php rename to Examples/BasicTable.php diff --git a/src/Examples/HeaderFooter.php b/Examples/HeaderFooter.php similarity index 100% rename from src/Examples/HeaderFooter.php rename to Examples/HeaderFooter.php diff --git a/src/Examples/Image.php b/Examples/Image.php similarity index 100% rename from src/Examples/Image.php rename to Examples/Image.php diff --git a/src/Examples/Link.php b/Examples/Link.php similarity index 100% rename from src/Examples/Link.php rename to Examples/Link.php diff --git a/src/Examples/ListItem.php b/Examples/ListItem.php similarity index 100% rename from src/Examples/ListItem.php rename to Examples/ListItem.php diff --git a/src/Examples/Object.php b/Examples/Object.php similarity index 100% rename from src/Examples/Object.php rename to Examples/Object.php diff --git a/src/Examples/Section.php b/Examples/Section.php similarity index 100% rename from src/Examples/Section.php rename to Examples/Section.php diff --git a/src/Examples/Template.php b/Examples/Template.php similarity index 100% rename from src/Examples/Template.php rename to Examples/Template.php diff --git a/src/Examples/Textrun.php b/Examples/Textrun.php similarity index 100% rename from src/Examples/Textrun.php rename to Examples/Textrun.php diff --git a/src/Examples/TitleTOC.php b/Examples/TitleTOC.php similarity index 100% rename from src/Examples/TitleTOC.php rename to Examples/TitleTOC.php diff --git a/src/Examples/Watermark.php b/Examples/Watermark.php similarity index 100% rename from src/Examples/Watermark.php rename to Examples/Watermark.php diff --git a/src/Examples/_earth.JPG b/Examples/_earth.JPG similarity index 100% rename from src/Examples/_earth.JPG rename to Examples/_earth.JPG diff --git a/src/Examples/_mars.jpg b/Examples/_mars.jpg similarity index 100% rename from src/Examples/_mars.jpg rename to Examples/_mars.jpg diff --git a/src/Examples/_sheet.xls b/Examples/_sheet.xls similarity index 100% rename from src/Examples/_sheet.xls rename to Examples/_sheet.xls From b6c33c89313b2fe2d1efd372ab34b33332705f85 Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Wed, 11 Dec 2013 14:45:44 -0500 Subject: [PATCH 03/11] Formatted PHP code toward PSR-2 compliance --- src/PHPWord.php | 374 ++--- src/PHPWord/Autoloader.php | 33 +- src/PHPWord/DocumentProperties.php | 611 ++++---- src/PHPWord/HashTable.php | 182 +-- src/PHPWord/IOFactory.php | 174 +-- src/PHPWord/Media.php | 595 ++++---- src/PHPWord/Section.php | 687 ++++----- src/PHPWord/Section/Footer.php | 342 ++--- src/PHPWord/Section/Footer/PreserveText.php | 188 +-- src/PHPWord/Section/Header.php | 385 ++--- src/PHPWord/Section/Image.php | 273 ++-- src/PHPWord/Section/Link.php | 277 ++-- src/PHPWord/Section/ListItem.php | 140 +- src/PHPWord/Section/MemoryImage.php | 402 ++--- src/PHPWord/Section/Object.php | 287 ++-- src/PHPWord/Section/PageBreak.php | 17 +- src/PHPWord/Section/Settings.php | 993 +++++++------ src/PHPWord/Section/Table.php | 238 +-- src/PHPWord/Section/Table/Cell.php | 581 ++++---- src/PHPWord/Section/Text.php | 224 +-- src/PHPWord/Section/TextBreak.php | 19 +- src/PHPWord/Section/TextRun.php | 191 +-- src/PHPWord/Section/Title.php | 225 +-- src/PHPWord/Shared/Drawing.php | 249 ++-- src/PHPWord/Shared/File.php | 112 +- src/PHPWord/Shared/Font.php | 88 +- src/PHPWord/Shared/String.php | 467 +++--- src/PHPWord/Shared/XMLWriter.php | 227 +-- src/PHPWord/Shared/ZipStreamWrapper.php | 293 ++-- src/PHPWord/Style.php | 266 ++-- src/PHPWord/Style/Cell.php | 540 +++---- src/PHPWord/Style/Font.php | 474 +++--- src/PHPWord/Style/Image.php | 200 +-- src/PHPWord/Style/ListItem.php | 98 +- src/PHPWord/Style/Paragraph.php | 350 ++--- src/PHPWord/Style/TOC.php | 212 +-- src/PHPWord/Style/Table.php | 119 +- src/PHPWord/Style/TableFull.php | 856 ++++++----- src/PHPWord/TOC.php | 245 ++-- src/PHPWord/Template.php | 65 +- src/PHPWord/Writer/IWriter.php | 15 +- src/PHPWord/Writer/ODText.php | 507 +++---- src/PHPWord/Writer/ODText/Content.php | 571 ++++---- src/PHPWord/Writer/ODText/Manifest.php | 178 +-- src/PHPWord/Writer/ODText/Meta.php | 115 +- src/PHPWord/Writer/ODText/Mimetype.php | 24 +- src/PHPWord/Writer/ODText/Styles.php | 461 +++--- src/PHPWord/Writer/ODText/WriterPart.php | 58 +- src/PHPWord/Writer/RTF.php | 758 +++++----- src/PHPWord/Writer/Word2007.php | 426 +++--- src/PHPWord/Writer/Word2007/Base.php | 1386 +++++++++--------- src/PHPWord/Writer/Word2007/ContentTypes.php | 317 ++-- src/PHPWord/Writer/Word2007/DocProps.php | 227 +-- src/PHPWord/Writer/Word2007/Document.php | 853 +++++------ src/PHPWord/Writer/Word2007/DocumentRels.php | 299 ++-- src/PHPWord/Writer/Word2007/Footer.php | 102 +- src/PHPWord/Writer/Word2007/Header.php | 110 +- src/PHPWord/Writer/Word2007/Rels.php | 151 +- src/PHPWord/Writer/Word2007/Styles.php | 638 ++++---- src/PHPWord/Writer/Word2007/WriterPart.php | 31 +- 60 files changed, 10016 insertions(+), 9510 deletions(-) diff --git a/src/PHPWord.php b/src/PHPWord.php index cf160233ea..6ff77a0a19 100644 --- a/src/PHPWord.php +++ b/src/PHPWord.php @@ -26,7 +26,7 @@ */ /** PHPWORD_BASE_PATH */ -if(!defined('PHPWORD_BASE_PATH')) { +if (!defined('PHPWORD_BASE_PATH')) { define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/'); require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php'; PHPWord_Autoloader::Register(); @@ -40,191 +40,207 @@ * @package PHPWord * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord { - - /** - * Document properties - * - * @var PHPWord_DocumentProperties - */ - private $_properties; - - /** - * Default Font Name - * - * @var string - */ - private $_defaultFontName; - - /** - * Default Font Size - * - * @var int - */ - private $_defaultFontSize; - - /** - * Collection of section elements - * - * @var array - */ - private $_sectionCollection = array(); - - - /** - * Create a new PHPWord Document - */ - public function __construct() { - $this->_properties = new PHPWord_DocumentProperties(); - $this->_defaultFontName = 'Arial'; - $this->_defaultFontSize = 20; - } - - /** - * Get properties - * @return PHPWord_DocumentProperties - */ - public function getProperties() { - return $this->_properties; - } - - /** - * Set properties - * - * @param PHPWord_DocumentProperties $value - * @return PHPWord - */ - public function setProperties(PHPWord_DocumentProperties $value) { - $this->_properties = $value; - return $this; - } - - /** - * Create a new Section - * - * @param PHPWord_Section_Settings $settings - * @return PHPWord_Section - */ - public function createSection($settings = null) { - $sectionCount = $this->_countSections() + 1; - - $section = new PHPWord_Section($sectionCount, $settings); - $this->_sectionCollection[] = $section; - return $section; - } - - /** - * Get default Font name - * @return string - */ - public function getDefaultFontName() { - return $this->_defaultFontName; - } - - /** - * Set default Font name - * @param string $pValue - */ - public function setDefaultFontName($pValue) { - $this->_defaultFontName = $pValue; - } - - /** - * Get default Font size - * @return string - */ - public function getDefaultFontSize() { - return $this->_defaultFontSize; - } - - /** - * Set default Font size - * @param int $pValue - */ - public function setDefaultFontSize($pValue) { - $pValue = $pValue * 2; - $this->_defaultFontSize = $pValue; - } - - /** - * Adds a paragraph style definition to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addParagraphStyle($styleName, $styles) { - PHPWord_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) { - PHPWord_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) { - PHPWord_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) { - PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); - } - - /** - * Adds a hyperlink style to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addLinkStyle($styleName, $styles) { - PHPWord_Style::addLinkStyle($styleName, $styles); - } - - /** - * Get sections - * @return PHPWord_Section[] - */ - public function getSections() { - return $this->_sectionCollection; - } - - /** - * Get section count - * @return int - */ - private function _countSections() { - return count($this->_sectionCollection); - } - +class PHPWord +{ + + /** + * Document properties + * + * @var PHPWord_DocumentProperties + */ + private $_properties; + + /** + * Default Font Name + * + * @var string + */ + private $_defaultFontName; + + /** + * Default Font Size + * + * @var int + */ + private $_defaultFontSize; + + /** + * Collection of section elements + * + * @var array + */ + private $_sectionCollection = array(); + + + /** + * Create a new PHPWord Document + */ + public function __construct() + { + $this->_properties = new PHPWord_DocumentProperties(); + $this->_defaultFontName = 'Arial'; + $this->_defaultFontSize = 20; + } + + /** + * Get properties + * @return PHPWord_DocumentProperties + */ + public function getProperties() + { + return $this->_properties; + } + + /** + * Set properties + * + * @param PHPWord_DocumentProperties $value + * @return PHPWord + */ + public function setProperties(PHPWord_DocumentProperties $value) + { + $this->_properties = $value; + return $this; + } + + /** + * Create a new Section + * + * @param PHPWord_Section_Settings $settings + * @return PHPWord_Section + */ + public function createSection($settings = null) + { + $sectionCount = $this->_countSections() + 1; + + $section = new PHPWord_Section($sectionCount, $settings); + $this->_sectionCollection[] = $section; + return $section; + } + + /** + * Get default Font name + * @return string + */ + public function getDefaultFontName() + { + return $this->_defaultFontName; + } + + /** + * Set default Font name + * @param string $pValue + */ + public function setDefaultFontName($pValue) + { + $this->_defaultFontName = $pValue; + } + + /** + * Get default Font size + * @return string + */ + public function getDefaultFontSize() + { + return $this->_defaultFontSize; + } + + /** + * Set default Font size + * @param int $pValue + */ + public function setDefaultFontSize($pValue) + { + $pValue = $pValue * 2; + $this->_defaultFontSize = $pValue; + } + + /** + * Adds a paragraph style definition to styles.xml + * + * @param $styleName string + * @param $styles array + */ + public function addParagraphStyle($styleName, $styles) + { + PHPWord_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) + { + PHPWord_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) + { + PHPWord_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) + { + PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); + } + + /** + * Adds a hyperlink style to styles.xml + * + * @param $styleName string + * @param $styles array + */ + public function addLinkStyle($styleName, $styles) + { + PHPWord_Style::addLinkStyle($styleName, $styles); + } + + /** + * Get sections + * @return PHPWord_Section[] + */ + public function getSections() + { + return $this->_sectionCollection; + } + + /** + * Get section count + * @return int + */ + private function _countSections() + { + return count($this->_sectionCollection); + } + /** * Load a Template File - * + * * @param string $strFilename * @return PHPWord_Template */ - public function loadTemplate($strFilename) { - if(file_exists($strFilename)) { + public function loadTemplate($strFilename) + { + if (file_exists($strFilename)) { $template = new PHPWord_Template($strFilename); return $template; } else { - trigger_error('Template file '.$strFilename.' not found.', E_ERROR); + trigger_error('Template file ' . $strFilename . ' not found.', E_ERROR); } } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/src/PHPWord/Autoloader.php b/src/PHPWord/Autoloader.php index d682f4d12f..86ad651d91 100644 --- a/src/PHPWord/Autoloader.php +++ b/src/PHPWord/Autoloader.php @@ -27,22 +27,23 @@ class PHPWord_Autoloader { - public static function Register() { - return spl_autoload_register(array('PHPWord_Autoloader', 'Load')); - } + public static function Register() + { + return spl_autoload_register(array('PHPWord_Autoloader', 'Load')); + } - public static function Load($strObjectName) { - if((class_exists($strObjectName)) || (strpos($strObjectName, 'PHPWord') === false)) { - return false; - } + public static function Load($strObjectName) + { + if ((class_exists($strObjectName)) || (strpos($strObjectName, 'PHPWord') === false)) { + return false; + } - $strObjectFilePath = PHPWORD_BASE_PATH . str_replace('_', '/', $strObjectName) . '.php'; - - if((file_exists($strObjectFilePath) === false) || (is_readable($strObjectFilePath) === false)) { - return false; - } - - require($strObjectFilePath); - } + $strObjectFilePath = PHPWORD_BASE_PATH . str_replace('_', '/', $strObjectName) . '.php'; + + if ((file_exists($strObjectFilePath) === false) || (is_readable($strObjectFilePath) === false)) { + return false; + } + + require($strObjectFilePath); + } } -?> \ No newline at end of file diff --git a/src/PHPWord/DocumentProperties.php b/src/PHPWord/DocumentProperties.php index b284f63122..5a9023893b 100644 --- a/src/PHPWord/DocumentProperties.php +++ b/src/PHPWord/DocumentProperties.php @@ -33,298 +33,319 @@ * @package PHPWord * @copyright Copyright (c) 2009 - 2011 PHPWord (http://www.codeplex.com/PHPWord) */ -class PHPWord_DocumentProperties { - - /** - * Creator - * - * @var string - */ - private $_creator; - - /** - * LastModifiedBy - * - * @var string - */ - private $_lastModifiedBy; - - /** - * Created - * - * @var datetime - */ - private $_created; - - /** - * Modified - * - * @var datetime - */ - private $_modified; - - /** - * Title - * - * @var string - */ - private $_title; - - /** - * Description - * - * @var string - */ - private $_description; - - /** - * Subject - * - * @var string - */ - private $_subject; - - /** - * Keywords - * - * @var string - */ - private $_keywords; - - /** - * Category - * - * @var string - */ - private $_category; - - /** - * Company - * - * @var string - */ - private $_company; - - /** - * Create new PHPWord_DocumentProperties - */ - public function __construct() { - $this->_creator = ''; - $this->_lastModifiedBy = $this->_creator; - $this->_created = time(); - $this->_modified = time(); - $this->_title = ''; - $this->_subject = ''; - $this->_description = ''; - $this->_keywords = ''; - $this->_category = ''; - $this->_company = ''; - } - - /** - * Get Creator - * - * @return string - */ - public function getCreator() { - return $this->_creator; - } - - /** - * Set Creator - * - * @param string $pValue - * @return 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 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 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 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 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 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 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 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 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 PHPWord_DocumentProperties - */ - public function setCompany($pValue = '') { - $this->_company = $pValue; - return $this; - } -} -?> +class PHPWord_DocumentProperties +{ + + /** + * Creator + * + * @var string + */ + private $_creator; + + /** + * LastModifiedBy + * + * @var string + */ + private $_lastModifiedBy; + + /** + * Created + * + * @var datetime + */ + private $_created; + + /** + * Modified + * + * @var datetime + */ + private $_modified; + + /** + * Title + * + * @var string + */ + private $_title; + + /** + * Description + * + * @var string + */ + private $_description; + + /** + * Subject + * + * @var string + */ + private $_subject; + + /** + * Keywords + * + * @var string + */ + private $_keywords; + + /** + * Category + * + * @var string + */ + private $_category; + + /** + * Company + * + * @var string + */ + private $_company; + + /** + * Create new PHPWord_DocumentProperties + */ + public function __construct() + { + $this->_creator = ''; + $this->_lastModifiedBy = $this->_creator; + $this->_created = time(); + $this->_modified = time(); + $this->_title = ''; + $this->_subject = ''; + $this->_description = ''; + $this->_keywords = ''; + $this->_category = ''; + $this->_company = ''; + } + + /** + * Get Creator + * + * @return string + */ + public function getCreator() + { + return $this->_creator; + } + + /** + * Set Creator + * + * @param string $pValue + * @return 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 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 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 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 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 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 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 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 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 PHPWord_DocumentProperties + */ + public function setCompany($pValue = '') + { + $this->_company = $pValue; + return $this; + } +} \ No newline at end of file diff --git a/src/PHPWord/HashTable.php b/src/PHPWord/HashTable.php index 5f791fd1ff..fc253e9731 100644 --- a/src/PHPWord/HashTable.php +++ b/src/PHPWord/HashTable.php @@ -52,25 +52,26 @@ class PHPWord_HashTable /** * Create a new PHPWord_HashTable * - * @param PHPWord_IComparable[] $pSource Optional source array to create HashTable from - * @throws Exception + * @param PHPWord_IComparable[] $pSource Optional source array to create HashTable from + * @throws Exception */ public function __construct($pSource = null) { - if (!is_null($pSource)) { - // Create HashTable - $this->addFromSource($pSource); - } + if (!is_null($pSource)) { + // Create HashTable + $this->addFromSource($pSource); + } } /** * Add HashTable items from source * - * @param PHPWord_IComparable[] $pSource Source array to create HashTable from - * @throws Exception + * @param PHPWord_IComparable[] $pSource Source array to create HashTable from + * @throws Exception */ - public function addFromSource($pSource = null) { - // Check if an array was passed + public function addFromSource($pSource = null) + { + // Check if an array was passed if ($pSource == null) { return; } else if (!is_array($pSource)) { @@ -85,63 +86,66 @@ public function addFromSource($pSource = null) { /** * Add HashTable item * - * @param PHPWord_IComparable $pSource Item to add - * @throws Exception + * @param PHPWord_IComparable $pSource Item to add + * @throws Exception */ - public function add(PHPWord_IComparable $pSource = null) { - // Determine hashcode - $hashCode = null; - $hashIndex = $pSource->getHashIndex(); - if ( is_null ( $hashIndex ) ) { - $hashCode = $pSource->getHashCode(); - } else if ( isset ( $this->_keyMap[$hashIndex] ) ) { - $hashCode = $this->_keyMap[$hashIndex]; - } else { - $hashCode = $pSource->getHashCode(); - } - - // Add value - if (!isset($this->_items[ $hashCode ])) { - $this->_items[ $hashCode ] = $pSource; + public function add(PHPWord_IComparable $pSource = null) + { + // Determine hashcode + $hashCode = null; + $hashIndex = $pSource->getHashIndex(); + if (is_null($hashIndex)) { + $hashCode = $pSource->getHashCode(); + } else if (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() ); - } + $this->_keyMap[$index] = $hashCode; + $pSource->setHashIndex($index); + } else { + $pSource->setHashIndex($this->_items[$hashCode]->getHashIndex()); + } } /** * Remove HashTable item * - * @param PHPWord_IComparable $pSource Item to remove - * @throws Exception + * @param PHPWord_IComparable $pSource Item to remove + * @throws Exception */ - public function remove(PHPWord_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 ]); - } + public function remove(PHPWord_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(); + public function clear() + { + $this->_items = array(); + $this->_keyMap = array(); } /** @@ -149,48 +153,52 @@ public function clear() { * * @return int */ - public function count() { - return count($this->_items); + public function count() + { + return count($this->_items); } /** * Get index for hash code * - * @param string $pHashCode - * @return int Index + * @param string $pHashCode + * @return int Index */ - public function getIndexForHashCode($pHashCode = '') { - return array_search($pHashCode, $this->_keyMap); + public function getIndexForHashCode($pHashCode = '') + { + return array_search($pHashCode, $this->_keyMap); } /** * Get by index * - * @param int $pIndex - * @return PHPWord_IComparable + * @param int $pIndex + * @return PHPWord_IComparable * */ - public function getByIndex($pIndex = 0) { - if (isset($this->_keyMap[$pIndex])) { - return $this->getByHashCode( $this->_keyMap[$pIndex] ); - } + public function getByIndex($pIndex = 0) + { + if (isset($this->_keyMap[$pIndex])) { + return $this->getByHashCode($this->_keyMap[$pIndex]); + } - return null; + return null; } /** * Get by hashcode * - * @param string $pHashCode - * @return PHPWord_IComparable + * @param string $pHashCode + * @return PHPWord_IComparable * */ - public function getByHashCode($pHashCode = '') { - if (isset($this->_items[$pHashCode])) { - return $this->_items[$pHashCode]; - } + public function getByHashCode($pHashCode = '') + { + if (isset($this->_items[$pHashCode])) { + return $this->_items[$pHashCode]; + } - return null; + return null; } /** @@ -198,19 +206,21 @@ public function getByHashCode($pHashCode = '') { * * @return PHPWord_IComparable[] */ - public function toArray() { - return $this->_items; + 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; - } - } - } + /** + * 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; + } + } + } } diff --git a/src/PHPWord/IOFactory.php b/src/PHPWord/IOFactory.php index ac4b206b02..dcf2a316d7 100644 --- a/src/PHPWord/IOFactory.php +++ b/src/PHPWord/IOFactory.php @@ -33,88 +33,94 @@ * @package PHPWord * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_IOFactory { - - /** - * Search locations - * - * @var array - */ - private static $_searchLocations = array( - array('type' => 'IWriter', 'path' => 'PHPWord/Writer/{0}.php', 'class' => 'PHPWord_Writer_{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($value) { - if (is_array($value)) { - self::$_searchLocations = $value; - } else { - throw new Exception('Invalid parameter passed.'); - } - } - - /** - * 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 - */ - public static function createWriter(PHPWord $PHPWord, $writerType = '') { - $searchType = 'IWriter'; - - 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; - } - } - } - - throw new Exception("No $searchType found for type $writerType"); - } +class PHPWord_IOFactory +{ + + /** + * Search locations + * + * @var array + */ + private static $_searchLocations = array( + array('type' => 'IWriter', 'path' => 'PHPWord/Writer/{0}.php', 'class' => 'PHPWord_Writer_{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($value) + { + if (is_array($value)) { + self::$_searchLocations = $value; + } else { + throw new Exception('Invalid parameter passed.'); + } + } + + /** + * 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 + */ + public static function createWriter(PHPWord $PHPWord, $writerType = '') + { + $searchType = 'IWriter'; + + 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; + } + } + } + + throw new Exception("No $searchType found for type $writerType"); + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Media.php b/src/PHPWord/Media.php index fcc53ac579..6cdc92b921 100644 --- a/src/PHPWord/Media.php +++ b/src/PHPWord/Media.php @@ -33,296 +33,307 @@ * @package PHPWord * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Media { - - /** - * Section Media Elements - * - * @var array - */ - private static $_sectionMedia = array('images'=>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 - * - * @return mixed - */ - public static function addSectionMediaElement($src, $type, PHPWord_Section_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(); - - if($type == 'image') { - $cImg++; - $inf = pathinfo($src); - $isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php' && $type == 'image') ? true : false; - - 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'; - } - } - - $folder = 'media'; - $file = $type.$cImg.'.'.strtolower($ext); - } 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); - } else { - return $rID; - } - } else { - if($type == 'oleObject') { - $rID = self::$_sectionMedia[$key][$mediaId]['rID']; - return array($rID, ++self::$_objectId); - } else { - return self::$_sectionMedia[$key][$mediaId]['rID']; - } - } - } - - /** - * Add new Section Link Element - * - * @param string $linkSrc - * @param string $linkName - * - * @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]; - } else { - $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]); - } else { - $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 - * @return int - */ - public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_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; - } else { - 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 - * @return int - */ - public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_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; - } else { - 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; - } +class PHPWord_Media +{ + + /** + * Section Media Elements + * + * @var array + */ + private static $_sectionMedia = array('images' => 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 + * + * @return mixed + */ + public static function addSectionMediaElement($src, $type, PHPWord_Section_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(); + + if ($type == 'image') { + $cImg++; + $inf = pathinfo($src); + $isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php' && $type == 'image') ? true : false; + + 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'; + } + } + + $folder = 'media'; + $file = $type . $cImg . '.' . strtolower($ext); + } 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); + } else { + return $rID; + } + } else { + if ($type == 'oleObject') { + $rID = self::$_sectionMedia[$key][$mediaId]['rID']; + return array($rID, ++self::$_objectId); + } else { + return self::$_sectionMedia[$key][$mediaId]['rID']; + } + } + } + + /** + * Add new Section Link Element + * + * @param string $linkSrc + * @param string $linkName + * + * @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]; + } else { + $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]); + } else { + $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 + * @return int + */ + public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_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; + } else { + 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 + * @return int + */ + public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_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; + } else { + 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/Section.php b/src/PHPWord/Section.php index 10d1ce6d0d..abfa42ec71 100644 --- a/src/PHPWord/Section.php +++ b/src/PHPWord/Section.php @@ -33,339 +33,358 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section { - - /** - * Section count - * - * @var int - */ - private $_sectionCount; - - /** - * Section settings - * - * @var PHPWord_Section_Settings - */ - private $_settings; - - /** - * Section Element Collection - * - * @var array - */ - private $_elementCollection = array(); - - /** - * Section Header - * - * @var PHPWord_Section_Header - */ - private $_header = null; - - /** - * Section Footer - * - * @var PHPWord_Section_Footer - */ - private $_footer = null; - - - /** - * Create a new Section - * - * @param int $sectionCount - * @param mixed $settings - */ - public function __construct($sectionCount, $settings = null) { - $this->_sectionCount = $sectionCount; - $this->_settings = new PHPWord_Section_Settings(); - - 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 PHPWord_Section_Settings - */ - public function getSettings() { - return $this->_settings; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) { - $givenText = utf8_encode($text); - $text = new PHPWord_Section_Text($givenText, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Link - */ - public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) { - $linkSrc = utf8_encode($linkSrc); - if(!is_null($linkName)) { - $linkName = utf8_encode($linkName); - } - - $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph); - $rID = PHPWord_Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Add a TextBreak Element - * - * @param int $count - */ - public function addTextBreak($count = 1) { - for($i=1; $i<=$count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak(); - } - } - - /** - * Add a PageBreak Element - */ - public function addPageBreak() { - $this->_elementCollection[] = new PHPWord_Section_PageBreak(); - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PHPWord_Section_Table - */ - public function addTable($style = null) { - $table = new PHPWord_Section_Table('section', $this->_sectionCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a ListItem Element - * - * @param string $text - * @param int $depth - * @param mixed $styleFont +class PHPWord_Section +{ + + /** + * Section count + * + * @var int + */ + private $_sectionCount; + + /** + * Section settings + * + * @var PHPWord_Section_Settings + */ + private $_settings; + + /** + * Section Element Collection + * + * @var array + */ + private $_elementCollection = array(); + + /** + * Section Header + * + * @var PHPWord_Section_Header + */ + private $_header = null; + + /** + * Section Footer + * + * @var PHPWord_Section_Footer + */ + private $_footer = null; + + + /** + * Create a new Section + * + * @param int $sectionCount + * @param mixed $settings + */ + public function __construct($sectionCount, $settings = null) + { + $this->_sectionCount = $sectionCount; + $this->_settings = new PHPWord_Section_Settings(); + + 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 PHPWord_Section_Settings + */ + public function getSettings() + { + return $this->_settings; + } + + /** + * Add a Text Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + $givenText = utf8_encode($text); + $text = new PHPWord_Section_Text($givenText, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Link + */ + public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) + { + $linkSrc = utf8_encode($linkSrc); + if (!is_null($linkName)) { + $linkName = utf8_encode($linkName); + } + + $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph); + $rID = PHPWord_Media::addSectionLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } + + /** + * Add a TextBreak Element + * + * @param int $count + */ + public function addTextBreak($count = 1) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new PHPWord_Section_TextBreak(); + } + } + + /** + * Add a PageBreak Element + */ + public function addPageBreak() + { + $this->_elementCollection[] = new PHPWord_Section_PageBreak(); + } + + /** + * Add a Table Element + * + * @param mixed $style + * @return PHPWord_Section_Table + */ + public function addTable($style = null) + { + $table = new PHPWord_Section_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 PHPWord_Section_ListItem - */ - public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) { - $text = utf8_encode($text); - $listItem = new PHPWord_Section_ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); - $this->_elementCollection[] = $listItem; - return $listItem; - } - - /** - * Add a OLE-Object Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Object - */ - public function addObject($src, $style = null) { - $object = new PHPWord_Section_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 = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); - $data = PHPWord_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 { - trigger_error('Source does not exist or unsupported object type.'); - } - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); - - if(!is_null($image->getSource())) { - $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Source does not exist or unsupported image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PHPWord_Section_MemoryImage - */ - public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); - if(!is_null($memoryImage->getSource())) { - $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - trigger_error('Unsupported image type.'); - } - } - - /** - * Add a Table-of-Contents Element - * - * @param mixed $styleFont - * @param mixed $styleTOC - * @return PHPWord_TOC - */ - public function addTOC($styleFont = null, $styleTOC = null) { - $toc = new PHPWord_TOC($styleFont, $styleTOC); - $this->_elementCollection[] = $toc; - return $toc; - } - - /** - * Add a Title Element - * - * @param string $text - * @param int $depth - * @return PHPWord_Section_Title - */ - public function addTitle($text, $depth = 1) { - $text = utf8_encode($text); - $styles = PHPWord_Style::getStyles(); - if(array_key_exists('Heading_'.$depth, $styles)) { - $style = 'Heading'.$depth; - } else { - $style = null; - } - - $title = new PHPWord_Section_Title($text, $depth, $style); - - $data = PHPWord_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 - * - * @return PHPWord_Section_TextRun - */ - public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Get all Elements - * - * @return array - */ - public function getElements() { - return $this->_elementCollection; - } - - /** - * Create a new Header - * - * @return PHPWord_Section_Header - */ - public function createHeader() { - $header = new PHPWord_Section_Header($this->_sectionCount); - $this->_header = $header; - return $header; - } - - /** - * Get Header - * - * @return PHPWord_Section_Header - */ - public function getHeader() { - return $this->_header; - } - - /** - * Create a new Footer - * - * @return PHPWord_Section_Footer - */ - public function createFooter() { - $footer = new PHPWord_Section_Footer($this->_sectionCount); - $this->_footer = $footer; - return $footer; - } - - /** - * Get Footer - * - * @return PHPWord_Section_Footer - */ - public function getFooter() { - return $this->_footer; - } + * @param mixed $styleParagraph + * @return PHPWord_Section_ListItem + */ + public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) + { + $text = utf8_encode($text); + $listItem = new PHPWord_Section_ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); + $this->_elementCollection[] = $listItem; + return $listItem; + } + + /** + * Add a OLE-Object Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Object + */ + public function addObject($src, $style = null) + { + $object = new PHPWord_Section_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 = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); + $data = PHPWord_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 { + trigger_error('Source does not exist or unsupported object type.'); + } + } + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addImage($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style); + + if (!is_null($image->getSource())) { + $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Source does not exist or unsupported image type.'); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PHPWord_Section_MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + trigger_error('Unsupported image type.'); + } + } + + /** + * Add a Table-of-Contents Element + * + * @param mixed $styleFont + * @param mixed $styleTOC + * @return PHPWord_TOC + */ + public function addTOC($styleFont = null, $styleTOC = null) + { + $toc = new PHPWord_TOC($styleFont, $styleTOC); + $this->_elementCollection[] = $toc; + return $toc; + } + + /** + * Add a Title Element + * + * @param string $text + * @param int $depth + * @return PHPWord_Section_Title + */ + public function addTitle($text, $depth = 1) + { + $text = utf8_encode($text); + $styles = PHPWord_Style::getStyles(); + if (array_key_exists('Heading_' . $depth, $styles)) { + $style = 'Heading' . $depth; + } else { + $style = null; + } + + $title = new PHPWord_Section_Title($text, $depth, $style); + + $data = PHPWord_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 + * + * @return PHPWord_Section_TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new PHPWord_Section_TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Get all Elements + * + * @return array + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Create a new Header + * + * @return PHPWord_Section_Header + */ + public function createHeader() + { + $header = new PHPWord_Section_Header($this->_sectionCount); + $this->_header = $header; + return $header; + } + + /** + * Get Header + * + * @return PHPWord_Section_Header + */ + public function getHeader() + { + return $this->_header; + } + + /** + * Create a new Footer + * + * @return PHPWord_Section_Footer + */ + public function createFooter() + { + $footer = new PHPWord_Section_Footer($this->_sectionCount); + $this->_footer = $footer; + return $footer; + } + + /** + * Get Footer + * + * @return PHPWord_Section_Footer + */ + public function getFooter() + { + return $this->_footer; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/Footer.php b/src/PHPWord/Section/Footer.php index 90cc9a487b..115153b3f6 100644 --- a/src/PHPWord/Section/Footer.php +++ b/src/PHPWord/Section/Footer.php @@ -33,169 +33,181 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Footer { - - /** - * Footer Count - * - * @var int - */ - private $_footerCount; - - /** - * Footer Relation ID - * - * @var int - */ - private $_rId; - - /** - * Footer Element Collection - * - * @var int - */ - private $_elementCollection = array(); - - /** - * Create a new Footer - */ - public function __construct($sectionCount) { - $this->_footerCount = $sectionCount; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) { - $givenText = utf8_encode($text); - $text = new PHPWord_Section_Text($givenText, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a TextBreak Element - * - * @param int $count - */ - public function addTextBreak($count = 1) { - for($i=1; $i<=$count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak(); - } - } - - /** - * Create a new TextRun - * - * @return PHPWord_Section_TextRun - */ - public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PHPWord_Section_Table - */ - public function addTable($style = null) { - $table = new PHPWord_Section_Table('footer', $this->_footerCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); - - if(!is_null($image->getSource())) { - $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Src does not exist or invalid image type.', E_ERROR); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PHPWord_Section_MemoryImage - */ - public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); - if(!is_null($memoryImage->getSource())) { - $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - trigger_error('Unsupported image type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Footer_PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { - $text = utf8_encode($text); - $ptext = new PHPWord_Section_Footer_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 - */ - public function getElements() { - return $this->_elementCollection; - } - - /** - * Get Footer Count - */ - public function getFooterCount() { - return $this->_footerCount; - } +class PHPWord_Section_Footer +{ + + /** + * Footer Count + * + * @var int + */ + private $_footerCount; + + /** + * Footer Relation ID + * + * @var int + */ + private $_rId; + + /** + * Footer Element Collection + * + * @var int + */ + private $_elementCollection = array(); + + /** + * Create a new Footer + */ + public function __construct($sectionCount) + { + $this->_footerCount = $sectionCount; + } + + /** + * Add a Text Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + $givenText = utf8_encode($text); + $text = new PHPWord_Section_Text($givenText, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a TextBreak Element + * + * @param int $count + */ + public function addTextBreak($count = 1) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new PHPWord_Section_TextBreak(); + } + } + + /** + * Create a new TextRun + * + * @return PHPWord_Section_TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new PHPWord_Section_TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Add a Table Element + * + * @param mixed $style + * @return PHPWord_Section_Table + */ + public function addTable($style = null) + { + $table = new PHPWord_Section_Table('footer', $this->_footerCount, $style); + $this->_elementCollection[] = $table; + return $table; + } + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addImage($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style); + + if (!is_null($image->getSource())) { + $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Src does not exist or invalid image type.', E_ERROR); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PHPWord_Section_MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + trigger_error('Unsupported image type.'); + } + } + + /** + * Add a PreserveText Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Footer_PreserveText + */ + public function addPreserveText($text, $styleFont = null, $styleParagraph = null) + { + $text = utf8_encode($text); + $ptext = new PHPWord_Section_Footer_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 + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Footer Count + */ + public function getFooterCount() + { + return $this->_footerCount; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/Footer/PreserveText.php b/src/PHPWord/Section/Footer/PreserveText.php index 05442c2df2..c4cf177753 100644 --- a/src/PHPWord/Section/Footer/PreserveText.php +++ b/src/PHPWord/Section/Footer/PreserveText.php @@ -33,96 +33,100 @@ * @package PHPWord_Section_Footer * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Footer_PreserveText { - - /** - * Text content - * - * @var string - */ - private $_text; - - /** - * Text style - * - * @var PHPWord_Style_Font - */ - private $_styleFont; - - /** - * Paragraph style - * - * @var PHPWord_Style_Font - */ - private $_styleParagraph; - - - /** - * Create a new Preserve Text Element - * - * @var string $text - * @var mixed $style - */ - public function __construct($text = null, $styleFont = null, $styleParagraph = null) { - // Set font style - if(is_array($styleFont)) { - $this->_styleFont = new PHPWord_Style_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 PHPWord_Style_Paragraph(); - - foreach($styleParagraph as $key => $value) { - if(substr($key, 0, 1) != '_') { - $key = '_'.$key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - - $pattern = '/({.*?})/'; - $this->_text = preg_split($pattern, $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - - return $this; - } - - /** - * Get Text style - * - * @return PHPWord_Style_Font - */ - public function getFontStyle() { - return $this->_styleFont; - } - - /** - * Get Paragraph style - * - * @return PHPWord_Style_Paragraph - */ - public function getParagraphStyle() { - return $this->_styleParagraph; - } - - /** - * Get Text content - * - * @return string - */ - public function getText() { - return $this->_text; - } +class PHPWord_Section_Footer_PreserveText +{ + + /** + * Text content + * + * @var string + */ + private $_text; + + /** + * Text style + * + * @var PHPWord_Style_Font + */ + private $_styleFont; + + /** + * Paragraph style + * + * @var PHPWord_Style_Font + */ + private $_styleParagraph; + + + /** + * Create a new Preserve Text Element + * + * @var string $text + * @var mixed $style + */ + public function __construct($text = null, $styleFont = null, $styleParagraph = null) + { + // Set font style + if (is_array($styleFont)) { + $this->_styleFont = new PHPWord_Style_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 PHPWord_Style_Paragraph(); + + foreach ($styleParagraph as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_styleParagraph->setStyleValue($key, $value); + } + } else { + $this->_styleParagraph = $styleParagraph; + } + + $pattern = '/({.*?})/'; + $this->_text = preg_split($pattern, $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + + return $this; + } + + /** + * Get Text style + * + * @return PHPWord_Style_Font + */ + public function getFontStyle() + { + return $this->_styleFont; + } + + /** + * Get Paragraph style + * + * @return PHPWord_Style_Paragraph + */ + public function getParagraphStyle() + { + return $this->_styleParagraph; + } + + /** + * Get Text content + * + * @return string + */ + public function getText() + { + return $this->_text; + } } -?> diff --git a/src/PHPWord/Section/Header.php b/src/PHPWord/Section/Header.php index 5ea9919aed..dc55d62d40 100644 --- a/src/PHPWord/Section/Header.php +++ b/src/PHPWord/Section/Header.php @@ -33,190 +33,203 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Header { - - /** - * Header Count - * - * @var int - */ - private $_headerCount; - - /** - * Header Relation ID - * - * @var int - */ - private $_rId; - - /** - * Header Element Collection - * - * @var int - */ - private $_elementCollection = array(); - - /** - * Create a new Header - */ - public function __construct($sectionCount) { - $this->_headerCount = $sectionCount; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) { - $givenText = utf8_encode($text); - $text = new PHPWord_Section_Text($givenText, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a TextBreak Element - * - * @param int $count - */ - public function addTextBreak($count = 1) { - for($i=1; $i<=$count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak(); - } - } - - /** - * Create a new TextRun - * - * @return PHPWord_Section_TextRun - */ - public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PHPWord_Section_Table - */ - public function addTable($style = null) { - $table = new PHPWord_Section_Table('header', $this->_headerCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); - - if(!is_null($image->getSource())) { - $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Src does not exist or invalid image type.', E_ERROR); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PHPWord_Section_MemoryImage - */ - public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); - if(!is_null($memoryImage->getSource())) { - $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - trigger_error('Unsupported image type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Footer_PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { - $text = utf8_encode($text); - $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } - - /** - * Add a Watermark Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addWatermark($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style, true); - - if(!is_null($image->getSource())) { - $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Src does not exist or invalid image type.', E_ERROR); - } - } - - /** - * 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; - } +class PHPWord_Section_Header +{ + + /** + * Header Count + * + * @var int + */ + private $_headerCount; + + /** + * Header Relation ID + * + * @var int + */ + private $_rId; + + /** + * Header Element Collection + * + * @var int + */ + private $_elementCollection = array(); + + /** + * Create a new Header + */ + public function __construct($sectionCount) + { + $this->_headerCount = $sectionCount; + } + + /** + * Add a Text Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + $givenText = utf8_encode($text); + $text = new PHPWord_Section_Text($givenText, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a TextBreak Element + * + * @param int $count + */ + public function addTextBreak($count = 1) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new PHPWord_Section_TextBreak(); + } + } + + /** + * Create a new TextRun + * + * @return PHPWord_Section_TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new PHPWord_Section_TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Add a Table Element + * + * @param mixed $style + * @return PHPWord_Section_Table + */ + public function addTable($style = null) + { + $table = new PHPWord_Section_Table('header', $this->_headerCount, $style); + $this->_elementCollection[] = $table; + return $table; + } + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addImage($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style); + + if (!is_null($image->getSource())) { + $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Src does not exist or invalid image type.', E_ERROR); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PHPWord_Section_MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + trigger_error('Unsupported image type.'); + } + } + + /** + * Add a PreserveText Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Footer_PreserveText + */ + public function addPreserveText($text, $styleFont = null, $styleParagraph = null) + { + $text = utf8_encode($text); + $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $ptext; + return $ptext; + } + + /** + * Add a Watermark Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addWatermark($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style, true); + + if (!is_null($image->getSource())) { + $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Src does not exist or invalid image type.', E_ERROR); + } + } + + /** + * 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; + } } -?> diff --git a/src/PHPWord/Section/Image.php b/src/PHPWord/Section/Image.php index 6eb2a418eb..68ac306501 100644 --- a/src/PHPWord/Section/Image.php +++ b/src/PHPWord/Section/Image.php @@ -33,136 +33,145 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Image { - - /** - * Image Src - * - * @var string - */ - private $_src; - - /** - * Image Style - * - * @var PHPWord_Style_Image - */ - private $_style; - - /** - * Image Relation ID - * - * @var string - */ - private $_rId; - - /** - * Is Watermark - * - * @var bool - */ - private $_isWatermark; - - - /** - * Create a new Image - * - * @param string $src - * @param mixed style - */ - public function __construct($src, $style = null, $isWatermark = false) { - $_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff'); - - $inf = pathinfo($src); - $ext = strtolower($inf['extension']); - - if(file_exists($src) && in_array($ext, $_supportedImageTypes)) { - $this->_src = $src; - $this->_isWatermark = $isWatermark; - $this->_style = new 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($this->_style->getWidth() == null && $this->_style->getHeight() == null) { - $imgData = getimagesize($this->_src); - $this->_style->setWidth($imgData[0]); - $this->_style->setHeight($imgData[1]); - } - - return $this; - } else { - return false; - } - } - - /** - * Get Image style - * - * @return 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; - } +class PHPWord_Section_Image +{ + + /** + * Image Src + * + * @var string + */ + private $_src; + + /** + * Image Style + * + * @var PHPWord_Style_Image + */ + private $_style; + + /** + * Image Relation ID + * + * @var string + */ + private $_rId; + + /** + * Is Watermark + * + * @var bool + */ + private $_isWatermark; + + + /** + * Create a new Image + * + * @param string $src + * @param mixed style + */ + public function __construct($src, $style = null, $isWatermark = false) + { + $_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff'); + + $inf = pathinfo($src); + $ext = strtolower($inf['extension']); + + if (file_exists($src) && in_array($ext, $_supportedImageTypes)) { + $this->_src = $src; + $this->_isWatermark = $isWatermark; + $this->_style = new 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 ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { + $imgData = getimagesize($this->_src); + $this->_style->setWidth($imgData[0]); + $this->_style->setHeight($imgData[1]); + } + + return $this; + } else { + return false; + } + } + + /** + * Get Image style + * + * @return 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/PHPWord/Section/Link.php b/src/PHPWord/Section/Link.php index 5c582fa082..d981c45e95 100644 --- a/src/PHPWord/Section/Link.php +++ b/src/PHPWord/Section/Link.php @@ -33,139 +33,146 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Link { - - /** - * Link source - * - * @var string - */ - private $_linkSrc; - - /** - * Link name - * - * @var string - */ - private $_linkName; - - /** - * Link Relation ID - * - * @var string - */ - private $_rId; - - /** - * Link style - * - * @var PHPWord_Style_Font - */ - private $_styleFont; - - /** - * Paragraph style - * - * @var PHPWord_Style_Font - */ - private $_styleParagraph; - - - /** - * Create a new Link Element - * - * @var string $linkSrc - * @var string $linkName - * @var mixed $styleFont - * @var mixed $styleParagraph - */ - public function __construct($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) { - $this->_linkSrc = $linkSrc; - $this->_linkName = $linkName; - - // Set font style - if(is_array($styleFont)) { - $this->_styleFont = new PHPWord_Style_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 PHPWord_Style_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 PHPWord_Style_Font - */ - public function getFontStyle() { - return $this->_styleFont; - } - - /** - * Get Paragraph style - * - * @return PHPWord_Style_Paragraph - */ - public function getParagraphStyle() { - return $this->_styleParagraph; - } +class PHPWord_Section_Link +{ + + /** + * Link source + * + * @var string + */ + private $_linkSrc; + + /** + * Link name + * + * @var string + */ + private $_linkName; + + /** + * Link Relation ID + * + * @var string + */ + private $_rId; + + /** + * Link style + * + * @var PHPWord_Style_Font + */ + private $_styleFont; + + /** + * Paragraph style + * + * @var PHPWord_Style_Font + */ + private $_styleParagraph; + + + /** + * Create a new Link Element + * + * @var string $linkSrc + * @var string $linkName + * @var mixed $styleFont + * @var mixed $styleParagraph + */ + public function __construct($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) + { + $this->_linkSrc = $linkSrc; + $this->_linkName = $linkName; + + // Set font style + if (is_array($styleFont)) { + $this->_styleFont = new PHPWord_Style_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 PHPWord_Style_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 PHPWord_Style_Font + */ + public function getFontStyle() + { + return $this->_styleFont; + } + + /** + * Get Paragraph style + * + * @return PHPWord_Style_Paragraph + */ + public function getParagraphStyle() + { + return $this->_styleParagraph; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/ListItem.php b/src/PHPWord/Section/ListItem.php index c509252b00..0b6625e3fb 100644 --- a/src/PHPWord/Section/ListItem.php +++ b/src/PHPWord/Section/ListItem.php @@ -33,72 +33,76 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_ListItem { - - /** - * ListItem Style - * - * @var PHPWord_Style_ListItem - */ - private $_style; - - /** - * Textrun - * - * @var PHPWord_Section_Text - */ - private $_textObject; - - /** - * ListItem Depth - * - * @var int - */ - private $_depth; - - - /** - * Create a new ListItem - * - * @param string $text - * @param int $depth - * @param mixed $styleText - * @param mixed $styleList - */ - 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->_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; - } +class PHPWord_Section_ListItem +{ + + /** + * ListItem Style + * + * @var PHPWord_Style_ListItem + */ + private $_style; + + /** + * Textrun + * + * @var PHPWord_Section_Text + */ + private $_textObject; + + /** + * ListItem Depth + * + * @var int + */ + private $_depth; + + + /** + * Create a new ListItem + * + * @param string $text + * @param int $depth + * @param mixed $styleText + * @param mixed $styleList + */ + 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->_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; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/MemoryImage.php b/src/PHPWord/Section/MemoryImage.php index 8e5d840dc9..6144595156 100644 --- a/src/PHPWord/Section/MemoryImage.php +++ b/src/PHPWord/Section/MemoryImage.php @@ -33,199 +33,211 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_MemoryImage { - - /** - * Image Src - * - * @var string - */ - private $_src; - - /** - * Image Style - * - * @var PHPWord_Style_Image - */ - private $_style; - - /** - * Image Relation ID - * - * @var string - */ - private $_rId; - - /** - * Image Type - * - * @var string - */ - private $_imageType; - - /** - * Image Create function - * - * @var string - */ - private $_imageCreateFunc; - - /** - * Image function - * - * @var string - */ - private $_imageFunc; - - /** - * Image function - * - * @var string - */ - private $_imageExtension; - - - /** - * Create a new Image - * - * @param string $src - * @param mixed style - */ - public function __construct($src, $style = null) { - $imgData = getimagesize($src); - $this->_imageType = $imgData['mime']; - - $_supportedImageTypes = array('image/jpeg', 'image/gif', 'image/png'); - - if(in_array($this->_imageType, $_supportedImageTypes)) { - $this->_src = $src; - $this->_style = new 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($this->_style->getWidth() == null && $this->_style->getHeight() == null) { - $this->_style->setWidth($imgData[0]); - $this->_style->setHeight($imgData[1]); - } - - $this->_setFunctions(); - - return $this; - } else { - return false; - } - } - - /** - * 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 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; - } +class PHPWord_Section_MemoryImage +{ + + /** + * Image Src + * + * @var string + */ + private $_src; + + /** + * Image Style + * + * @var PHPWord_Style_Image + */ + private $_style; + + /** + * Image Relation ID + * + * @var string + */ + private $_rId; + + /** + * Image Type + * + * @var string + */ + private $_imageType; + + /** + * Image Create function + * + * @var string + */ + private $_imageCreateFunc; + + /** + * Image function + * + * @var string + */ + private $_imageFunc; + + /** + * Image function + * + * @var string + */ + private $_imageExtension; + + + /** + * Create a new Image + * + * @param string $src + * @param mixed style + */ + public function __construct($src, $style = null) + { + $imgData = getimagesize($src); + $this->_imageType = $imgData['mime']; + + $_supportedImageTypes = array('image/jpeg', 'image/gif', 'image/png'); + + if (in_array($this->_imageType, $_supportedImageTypes)) { + $this->_src = $src; + $this->_style = new 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 ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { + $this->_style->setWidth($imgData[0]); + $this->_style->setHeight($imgData[1]); + } + + $this->_setFunctions(); + + return $this; + } else { + return false; + } + } + + /** + * 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 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; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/Object.php b/src/PHPWord/Section/Object.php index 7aad4ba5e3..63b1106930 100644 --- a/src/PHPWord/Section/Object.php +++ b/src/PHPWord/Section/Object.php @@ -33,143 +33,152 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Object { - - /** - * Ole-Object Src - * - * @var string - */ - private $_src; - - /** - * Image Style - * - * @var PHPWord_Style_Image - */ - private $_style; - - /** - * Object Relation ID - * - * @var int - */ - private $_rId; - - /** - * Image Relation ID - * - * @var int - */ - private $_rIdImg; - - /** - * Object ID - * - * @var int - */ - private $_objId; - - - /** - * Create a new Ole-Object Element - * - * @param string $src - * @param mixed $style - */ - public function __construct($src, $style = null) { - $_supportedObjectTypes = array('xls', 'doc', 'ppt'); - $inf = pathinfo($src); - - if(file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) { - $this->_src = $src; - $this->_style = new 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); - } - } - - return $this; - } else { - return false; - } - } - - /** - * Get Image style - * - * @return 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; - } +class PHPWord_Section_Object +{ + + /** + * Ole-Object Src + * + * @var string + */ + private $_src; + + /** + * Image Style + * + * @var PHPWord_Style_Image + */ + private $_style; + + /** + * Object Relation ID + * + * @var int + */ + private $_rId; + + /** + * Image Relation ID + * + * @var int + */ + private $_rIdImg; + + /** + * Object ID + * + * @var int + */ + private $_objId; + + + /** + * Create a new Ole-Object Element + * + * @param string $src + * @param mixed $style + */ + public function __construct($src, $style = null) + { + $_supportedObjectTypes = array('xls', 'doc', 'ppt'); + $inf = pathinfo($src); + + if (file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) { + $this->_src = $src; + $this->_style = new 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); + } + } + + return $this; + } else { + return false; + } + } + + /** + * Get Image style + * + * @return 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/PHPWord/Section/PageBreak.php b/src/PHPWord/Section/PageBreak.php index 48b41c7563..9a9c76ec90 100644 --- a/src/PHPWord/Section/PageBreak.php +++ b/src/PHPWord/Section/PageBreak.php @@ -33,13 +33,14 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_PageBreak { +class PHPWord_Section_PageBreak +{ - /** - * Create a new PageBreak Element - */ - public function __construct() { - // nothing - } + /** + * Create a new PageBreak Element + */ + public function __construct() + { + // nothing + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/Settings.php b/src/PHPWord/Section/Settings.php index 84dcc8ee64..a83192dc32 100644 --- a/src/PHPWord/Section/Settings.php +++ b/src/PHPWord/Section/Settings.php @@ -33,483 +33,518 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Settings { - - /** - * Default Page Size Width - * - * @var int - */ - private $_defaultPageSizeW = 11906; - - /** - * Default Page Size Height - * - * @var int - */ - private $_defaultPageSizeH = 16838; - - /** - * Page Orientation - * - * @var string - */ - private $_orientation; - - /** - * Page Margin Top - * - * @var int - */ - private $_marginTop; - - /** - * Page Margin Left - * - * @var int - */ - private $_marginLeft; - - /** - * Page Margin Right - * - * @var int - */ - private $_marginRight; - - /** - * Page Margin Bottom - * - * @var int - */ - private $_marginBottom; - - /** - * Page Size Width - * - * @var int - */ - private $_pageSizeW; - - /** - * Page Size Height - * - * @var int - */ - private $_pageSizeH; - - /** - * Page Border Top Size - * - * @var int - */ - private $_borderTopSize; - - /** - * Page Border Top Color - * - * @var int - */ - private $_borderTopColor; - - /** - * Page Border Left Size - * - * @var int - */ - private $_borderLeftSize; - - /** - * Page Border Left Color - * - * @var int - */ - private $_borderLeftColor; - - /** - * Page Border Right Size - * - * @var int - */ - private $_borderRightSize; - - /** - * Page Border Right Color - * - * @var int - */ - private $_borderRightColor; - - /** - * Page Border Bottom Size - * - * @var int - */ - private $_borderBottomSize; - - /** - * Page Border Bottom Color - * - * @var int - */ - private $_borderBottomColor; - - /** - * Create new Section Settings - */ - public function __construct() { - $this->_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; - } - - /** - * 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; - } +class PHPWord_Section_Settings +{ + + /** + * Default Page Size Width + * + * @var int + */ + private $_defaultPageSizeW = 11906; + + /** + * Default Page Size Height + * + * @var int + */ + private $_defaultPageSizeH = 16838; + + /** + * Page Orientation + * + * @var string + */ + private $_orientation; + + /** + * Page Margin Top + * + * @var int + */ + private $_marginTop; + + /** + * Page Margin Left + * + * @var int + */ + private $_marginLeft; + + /** + * Page Margin Right + * + * @var int + */ + private $_marginRight; + + /** + * Page Margin Bottom + * + * @var int + */ + private $_marginBottom; + + /** + * Page Size Width + * + * @var int + */ + private $_pageSizeW; + + /** + * Page Size Height + * + * @var int + */ + private $_pageSizeH; + + /** + * Page Border Top Size + * + * @var int + */ + private $_borderTopSize; + + /** + * Page Border Top Color + * + * @var int + */ + private $_borderTopColor; + + /** + * Page Border Left Size + * + * @var int + */ + private $_borderLeftSize; + + /** + * Page Border Left Color + * + * @var int + */ + private $_borderLeftColor; + + /** + * Page Border Right Size + * + * @var int + */ + private $_borderRightSize; + + /** + * Page Border Right Color + * + * @var int + */ + private $_borderRightColor; + + /** + * Page Border Bottom Size + * + * @var int + */ + private $_borderBottomSize; + + /** + * Page Border Bottom Color + * + * @var int + */ + private $_borderBottomColor; + + /** + * Create new Section Settings + */ + public function __construct() + { + $this->_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; + } + + /** + * 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; + } } -?> diff --git a/src/PHPWord/Section/Table.php b/src/PHPWord/Section/Table.php index 783c8776c8..94878e8183 100644 --- a/src/PHPWord/Section/Table.php +++ b/src/PHPWord/Section/Table.php @@ -33,120 +33,126 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Table { - - /** - * Table style - * - * @var PHPWord_Style_Table - */ - private $_style; - - /** - * Table rows - * - * @var array - */ - private $_rows = array(); - - /** - * Row heights - * - * @var array - */ - private $_rowHeights = array(); - - /** - * Table holder - * - * @var string - */ - private $_insideOf = null; - - /** - * Table holder count - * - * @var array - */ - private $_pCount; - - - /** - * Create a new table - * - * @param string $insideOf - * @param int $pCount - * @param mixed $style - */ - public function __construct($insideOf, $pCount, $style = null) { - $this->_insideOf = $insideOf; - $this->_pCount = $pCount; - - if(!is_null($style)) { - if(is_array($style)) { - $this->_style = new 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) { - $this->_rows[] = array(); - $this->_rowHeights[] = $height; - } - - /** - * Add a cell - * - * @param int $width - * @param mixed $style - * @return PHPWord_Section_Table_Cell - */ - public function addCell($width, $style = null) { - $cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style); - $i = count($this->_rows) - 1; - $this->_rows[$i][] = $cell; - return $cell; - } - - /** - * Get all rows - * - * @return array - */ - public function getRows() { - return $this->_rows; - } - - /** - * Get all row heights - * - * @return array - */ - public function getRowHeights() { - return $this->_rowHeights; - } - - /** - * Get table style - * - * @return PHPWord_Style_Table - */ - public function getStyle() { - return $this->_style; - } +class PHPWord_Section_Table +{ + + /** + * Table style + * + * @var PHPWord_Style_Table + */ + private $_style; + + /** + * Table rows + * + * @var array + */ + private $_rows = array(); + + /** + * Row heights + * + * @var array + */ + private $_rowHeights = array(); + + /** + * Table holder + * + * @var string + */ + private $_insideOf = null; + + /** + * Table holder count + * + * @var array + */ + private $_pCount; + + + /** + * Create a new table + * + * @param string $insideOf + * @param int $pCount + * @param mixed $style + */ + public function __construct($insideOf, $pCount, $style = null) + { + $this->_insideOf = $insideOf; + $this->_pCount = $pCount; + + if (!is_null($style)) { + if (is_array($style)) { + $this->_style = new 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) + { + $this->_rows[] = array(); + $this->_rowHeights[] = $height; + } + + /** + * Add a cell + * + * @param int $width + * @param mixed $style + * @return PHPWord_Section_Table_Cell + */ + public function addCell($width, $style = null) + { + $cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style); + $i = count($this->_rows) - 1; + $this->_rows[$i][] = $cell; + return $cell; + } + + /** + * Get all rows + * + * @return array + */ + public function getRows() + { + return $this->_rows; + } + + /** + * Get all row heights + * + * @return array + */ + public function getRowHeights() + { + return $this->_rowHeights; + } + + /** + * Get table style + * + * @return PHPWord_Style_Table + */ + public function getStyle() + { + return $this->_style; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/Table/Cell.php b/src/PHPWord/Section/Table/Cell.php index 2cf03a62c5..e9eb1d1b57 100644 --- a/src/PHPWord/Section/Table/Cell.php +++ b/src/PHPWord/Section/Table/Cell.php @@ -33,287 +33,300 @@ * @package PHPWord_Section_Table * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Table_Cell { - - /** - * Cell Width - * - * @var int - */ - private $_width = null; - - /** - * Cell Style - * - * @var PHPWord_Style_Cell - */ - private $_style; - - /** - * Cell Element Collection - * - * @var array - */ - private $_elementCollection = array(); - - /** - * Table holder - * - * @var string - */ - private $_insideOf; - - /** - * Section/Header/Footer count - * - * @var int - */ - private $_pCount; - - - /** - * Create a new Table Cell - * - * @param string $insideOf - * @param int $pCount - * @param int $width - * @param mixed $style - */ - public function __construct($insideOf, $pCount, $width = null, $style = null) { - $this->_insideOf = $insideOf; - $this->_pCount = $pCount; - $this->_width = $width; - - if(!is_null($style)) { - if(is_array($style)) { - $this->_style = new PHPWord_Style_Cell(); - - 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 PHPWord_Section_Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) { - $text = utf8_encode($text); - $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $style - * @return PHPWord_Section_Link - */ - public function addLink($linkSrc, $linkName = null, $style = null) { - if($this->_insideOf == 'section') { - $linkSrc = utf8_encode($linkSrc); - if(!is_null($linkName)) { - $linkName = utf8_encode($linkName); - } - - $link = new PHPWord_Section_Link($linkSrc, $linkName, $style); - $rID = PHPWord_Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } else { - trigger_error('Unsupported Link header / footer reference'); - return false; - } - } - - /** - * Add a TextBreak Element - * - * @param int $count - */ - public function addTextBreak() { - $this->_elementCollection[] = new PHPWord_Section_TextBreak(); - } - - /** - * Add a ListItem Element - * - * @param string $text - * @param int $depth - * @param mixed $styleText - * @param mixed $styleList - * @return PHPWord_Section_ListItem - */ - public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) { - $text = utf8_encode($text); - $listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList); - $this->_elementCollection[] = $listItem; - return $listItem; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); - - if(!is_null($image->getSource())) { - if($this->_insideOf == 'section') { - $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); - } elseif($this->_insideOf == 'header') { - $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src); - } elseif($this->_insideOf == 'footer') { - $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src); - } - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Source does not exist or unsupported image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PHPWord_Section_MemoryImage - */ - public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); - if(!is_null($memoryImage->getSource())) { - if($this->_insideOf == 'section') { - $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); - } elseif($this->_insideOf == 'header') { - $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); - } elseif($this->_insideOf == 'footer') { - $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); - } - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - trigger_error('Unsupported image type.'); - } - } - - /** - * Add a OLE-Object Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Object - */ - public function addObject($src, $style = null) { - $object = new PHPWord_Section_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 = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); - $data = PHPWord_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 { - trigger_error('Source does not exist or unsupported object type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Footer_PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { - if($this->_insideOf == 'footer' || $this->_insideOf == 'header') { - $text = utf8_encode($text); - $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } else { - trigger_error('addPreserveText only supported in footer/header.'); - } - } - - /** - * Create a new TextRun - * - * @return PHPWord_Section_TextRun - */ - public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Get all Elements - * - * @return array - */ - public function getElements() { - return $this->_elementCollection; - } - - /** - * Get Cell Style - * - * @return PHPWord_Style_Cell - */ - public function getStyle() { - return $this->_style; - } - - /** - * Get Cell width - * - * @return int - */ - public function getWidth() { - return $this->_width; - } -} -?> +class PHPWord_Section_Table_Cell +{ + + /** + * Cell Width + * + * @var int + */ + private $_width = null; + + /** + * Cell Style + * + * @var PHPWord_Style_Cell + */ + private $_style; + + /** + * Cell Element Collection + * + * @var array + */ + private $_elementCollection = array(); + + /** + * Table holder + * + * @var string + */ + private $_insideOf; + + /** + * Section/Header/Footer count + * + * @var int + */ + private $_pCount; + + + /** + * Create a new Table Cell + * + * @param string $insideOf + * @param int $pCount + * @param int $width + * @param mixed $style + */ + public function __construct($insideOf, $pCount, $width = null, $style = null) + { + $this->_insideOf = $insideOf; + $this->_pCount = $pCount; + $this->_width = $width; + + if (!is_null($style)) { + if (is_array($style)) { + $this->_style = new PHPWord_Style_Cell(); + + 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 PHPWord_Section_Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + $text = utf8_encode($text); + $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $style + * @return PHPWord_Section_Link + */ + public function addLink($linkSrc, $linkName = null, $style = null) + { + if ($this->_insideOf == 'section') { + $linkSrc = utf8_encode($linkSrc); + if (!is_null($linkName)) { + $linkName = utf8_encode($linkName); + } + + $link = new PHPWord_Section_Link($linkSrc, $linkName, $style); + $rID = PHPWord_Media::addSectionLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } else { + trigger_error('Unsupported Link header / footer reference'); + return false; + } + } + + /** + * Add a TextBreak Element + * + * @param int $count + */ + public function addTextBreak() + { + $this->_elementCollection[] = new PHPWord_Section_TextBreak(); + } + + /** + * Add a ListItem Element + * + * @param string $text + * @param int $depth + * @param mixed $styleText + * @param mixed $styleList + * @return PHPWord_Section_ListItem + */ + public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) + { + $text = utf8_encode($text); + $listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList); + $this->_elementCollection[] = $listItem; + return $listItem; + } + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addImage($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style); + + if (!is_null($image->getSource())) { + if ($this->_insideOf == 'section') { + $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); + } elseif ($this->_insideOf == 'header') { + $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src); + } elseif ($this->_insideOf == 'footer') { + $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src); + } + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Source does not exist or unsupported image type.'); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PHPWord_Section_MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + if ($this->_insideOf == 'section') { + $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); + } elseif ($this->_insideOf == 'header') { + $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); + } elseif ($this->_insideOf == 'footer') { + $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); + } + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + trigger_error('Unsupported image type.'); + } + } + + /** + * Add a OLE-Object Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Object + */ + public function addObject($src, $style = null) + { + $object = new PHPWord_Section_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 = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); + $data = PHPWord_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 { + trigger_error('Source does not exist or unsupported object type.'); + } + } + + /** + * Add a PreserveText Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Footer_PreserveText + */ + public function addPreserveText($text, $styleFont = null, $styleParagraph = null) + { + if ($this->_insideOf == 'footer' || $this->_insideOf == 'header') { + $text = utf8_encode($text); + $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $ptext; + return $ptext; + } else { + trigger_error('addPreserveText only supported in footer/header.'); + } + } + + /** + * Create a new TextRun + * + * @return PHPWord_Section_TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new PHPWord_Section_TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Get all Elements + * + * @return array + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Cell Style + * + * @return PHPWord_Style_Cell + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Get Cell width + * + * @return int + */ + public function getWidth() + { + return $this->_width; + } +} \ No newline at end of file diff --git a/src/PHPWord/Section/Text.php b/src/PHPWord/Section/Text.php index f7b49feb8e..340ae92a4a 100644 --- a/src/PHPWord/Section/Text.php +++ b/src/PHPWord/Section/Text.php @@ -33,113 +33,119 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Text { - - /** - * Text content - * - * @var string - */ - private $_text; - - /** - * Text style - * - * @var PHPWord_Style_Font - */ - private $_styleFont; - - /** - * Paragraph style - * - * @var PHPWord_Style_Font - */ - private $_styleParagraph; - - - /** - * Create a new Text Element - * - * @var string $text - * @var mixed $style - */ - public function __construct($text = null, $styleFont = null, $styleParagraph = null) { - // Set font style - $this->setFontStyle($styleFont); - - // Set paragraph style - $this->setParagraphStyle($styleParagraph); - - $this->_text = $text; - - return $this; - } - - /** - * Get Text style - * - * @return PHPWord_Style_Font - */ - public function getFontStyle() { - return $this->_styleFont; - } - - /** - * Set Text style - * - * @return PHPWord_Style_Font - */ - public function setFontStyle($styleFont) { - if(is_array($styleFont)) { - $this->_styleFont = new PHPWord_Style_Font('text'); - - foreach($styleFont as $key => $value) { - if(substr($key, 0, 1) != '_') { - $key = '_'.$key; - } - $this->_styleFont->setStyleValue($key, $value); - } - } else { - $this->_styleFont = $styleFont; - } - } - - /** - * Get Paragraph style - * - * @return PHPWord_Style_Paragraph - */ - public function getParagraphStyle() { - return $this->_styleParagraph; - } - - /** - * Set Paragraph style - * - * @return PHPWord_Style_Paragraph - */ - public function setParagraphStyle($styleParagraph) { - if(is_array($styleParagraph)) { - $this->_styleParagraph = new PHPWord_Style_Paragraph(); - - foreach($styleParagraph as $key => $value) { - if(substr($key, 0, 1) != '_') { - $key = '_'.$key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - } - - /** - * Get Text content - * - * @return string - */ - public function getText() { - return $this->_text; - } +class PHPWord_Section_Text +{ + + /** + * Text content + * + * @var string + */ + private $_text; + + /** + * Text style + * + * @var PHPWord_Style_Font + */ + private $_styleFont; + + /** + * Paragraph style + * + * @var PHPWord_Style_Font + */ + private $_styleParagraph; + + + /** + * Create a new Text Element + * + * @var string $text + * @var mixed $style + */ + public function __construct($text = null, $styleFont = null, $styleParagraph = null) + { + // Set font style + $this->setFontStyle($styleFont); + + // Set paragraph style + $this->setParagraphStyle($styleParagraph); + + $this->_text = $text; + + return $this; + } + + /** + * Get Text style + * + * @return PHPWord_Style_Font + */ + public function getFontStyle() + { + return $this->_styleFont; + } + + /** + * Set Text style + * + * @return PHPWord_Style_Font + */ + public function setFontStyle($styleFont) + { + if (is_array($styleFont)) { + $this->_styleFont = new PHPWord_Style_Font('text'); + + foreach ($styleFont as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_styleFont->setStyleValue($key, $value); + } + } else { + $this->_styleFont = $styleFont; + } + } + + /** + * Get Paragraph style + * + * @return PHPWord_Style_Paragraph + */ + public function getParagraphStyle() + { + return $this->_styleParagraph; + } + + /** + * Set Paragraph style + * + * @return PHPWord_Style_Paragraph + */ + public function setParagraphStyle($styleParagraph) + { + if (is_array($styleParagraph)) { + $this->_styleParagraph = new PHPWord_Style_Paragraph(); + + foreach ($styleParagraph as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $this->_styleParagraph->setStyleValue($key, $value); + } + } else { + $this->_styleParagraph = $styleParagraph; + } + } + + /** + * Get Text content + * + * @return string + */ + public function getText() + { + return $this->_text; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/TextBreak.php b/src/PHPWord/Section/TextBreak.php index 92a7b49b7d..37d5f72cb4 100644 --- a/src/PHPWord/Section/TextBreak.php +++ b/src/PHPWord/Section/TextBreak.php @@ -33,13 +33,14 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_TextBreak { - - /** - * Create a new TextBreak Element - */ - public function __construct() { - // nothing - } +class PHPWord_Section_TextBreak +{ + + /** + * Create a new TextBreak Element + */ + public function __construct() + { + // nothing + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/TextRun.php b/src/PHPWord/Section/TextRun.php index 4f5eece91a..d4cde48029 100644 --- a/src/PHPWord/Section/TextRun.php +++ b/src/PHPWord/Section/TextRun.php @@ -33,97 +33,102 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_TextRun { - - /** - * Paragraph style - * - * @var PHPWord_Style_Font - */ - private $_styleParagraph; - - /** - * Text collection - * - * @var array - */ - private $_elementCollection; - - - /** - * Create a new TextRun Element - */ - public function __construct($styleParagraph = null) { - $this->_elementCollection = array(); - - // Set paragraph style - if(is_array($styleParagraph)) { - $this->_styleParagraph = new PHPWord_Style_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 PHPWord_Section_Text - */ - public function addText($text = null, $styleFont = null) { - $givenText = utf8_encode($text); - $text = new PHPWord_Section_Text($givenText, $styleFont); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $styleFont - * @return 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 PHPWord_Section_Link($linkSrc, $linkName, $styleFont); - $rID = PHPWord_Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Get TextRun content - * - * @return string - */ - public function getElements() { - return $this->_elementCollection; - } - - /** - * Get Paragraph style - * - * @return PHPWord_Style_Paragraph - */ - public function getParagraphStyle() { - return $this->_styleParagraph; - } +class PHPWord_Section_TextRun +{ + + /** + * Paragraph style + * + * @var PHPWord_Style_Font + */ + private $_styleParagraph; + + /** + * Text collection + * + * @var array + */ + private $_elementCollection; + + + /** + * Create a new TextRun Element + */ + public function __construct($styleParagraph = null) + { + $this->_elementCollection = array(); + + // Set paragraph style + if (is_array($styleParagraph)) { + $this->_styleParagraph = new PHPWord_Style_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 PHPWord_Section_Text + */ + public function addText($text = null, $styleFont = null) + { + $givenText = utf8_encode($text); + $text = new PHPWord_Section_Text($givenText, $styleFont); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $styleFont + * @return 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 PHPWord_Section_Link($linkSrc, $linkName, $styleFont); + $rID = PHPWord_Media::addSectionLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } + + /** + * Get TextRun content + * + * @return string + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Paragraph style + * + * @return PHPWord_Style_Paragraph + */ + public function getParagraphStyle() + { + return $this->_styleParagraph; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Section/Title.php b/src/PHPWord/Section/Title.php index 0956b06295..1aea31b2fa 100644 --- a/src/PHPWord/Section/Title.php +++ b/src/PHPWord/Section/Title.php @@ -33,113 +33,120 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Title { - - /** - * Title Text content - * - * @var string - */ - private $_text; - - /** - * Title depth - * - * @var int - */ - private $_depth; - - /** - * Title anchor - * - * @var int - */ - private $_anchor; - - /** - * Title Bookmark ID - * - * @var int - */ - private $_bookmarkId; - - /** - * Title style - * - * @var string - */ - private $_style; - - - /** - * Create a new Title Element - * - * @var string $text - * @var int $depth - */ - public function __construct($text, $depth = 1, $style = null) { - if(!is_null($style)) { - $this->_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; - } +class PHPWord_Section_Title +{ + + /** + * Title Text content + * + * @var string + */ + private $_text; + + /** + * Title depth + * + * @var int + */ + private $_depth; + + /** + * Title anchor + * + * @var int + */ + private $_anchor; + + /** + * Title Bookmark ID + * + * @var int + */ + private $_bookmarkId; + + /** + * Title style + * + * @var string + */ + private $_style; + + + /** + * Create a new Title Element + * + * @var string $text + * @var int $depth + */ + public function __construct($text, $depth = 1, $style = null) + { + if (!is_null($style)) { + $this->_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; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Shared/Drawing.php b/src/PHPWord/Shared/Drawing.php index 766e62d0d7..00b4a44fc2 100644 --- a/src/PHPWord/Shared/Drawing.php +++ b/src/PHPWord/Shared/Drawing.php @@ -28,127 +28,134 @@ class PHPWord_Shared_Drawing { - /** - * Convert pixels to EMU - * - * @param int $pValue Value in pixels - * @return int Value in EMU - */ - public static function pixelsToEMU($pValue = 0) { - return round($pValue * 9525); - } - - /** - * Convert EMU to pixels - * - * @param int $pValue Value in EMU - * @return int Value in pixels - */ - public static function EMUToPixels($pValue = 0) { - if ($pValue != 0) { - return round($pValue / 9525); - } else { - return 0; - } - } - - /** - * Convert pixels to points - * - * @param int $pValue Value in pixels - * @return int Value in points - */ - public static function pixelsToPoints($pValue = 0) { - return $pValue * 0.67777777; - } - - /** - * Convert points width to pixels - * - * @param int $pValue Value in points - * @return int Value in pixels - */ - public static function pointsToPixels($pValue = 0) { - if ($pValue != 0) { - return $pValue * 1.333333333; - } else { - return 0; - } - } + /** + * Convert pixels to EMU + * + * @param int $pValue Value in pixels + * @return int Value in EMU + */ + public static function pixelsToEMU($pValue = 0) + { + return round($pValue * 9525); + } - /** - * Convert degrees to angle - * - * @param int $pValue Degrees - * @return int Angle - */ - public static function degreesToAngle($pValue = 0) { - return (int)round($pValue * 60000); - } - - /** - * Convert angle to degrees - * - * @param int $pValue Angle - * @return int Degrees - */ - public static function angleToDegrees($pValue = 0) { - if ($pValue != 0) { - return round($pValue / 60000); - } else { - return 0; - } - } + /** + * Convert EMU to pixels + * + * @param int $pValue Value in EMU + * @return int Value in pixels + */ + public static function EMUToPixels($pValue = 0) + { + if ($pValue != 0) { + return round($pValue / 9525); + } else { + return 0; + } + } - /** - * Convert pixels to centimeters - * - * @param int $pValue Value in pixels - * @return int Value in centimeters - */ - public static function pixelsToCentimeters($pValue = 0) { - return $pValue * 0.028; - } - - /** - * Convert centimeters width to pixels - * - * @param int $pValue Value in centimeters - * @return int Value in pixels - */ - public static function centimetersToPixels($pValue = 0) { - if ($pValue != 0) { - return $pValue * 0.028; - } else { - return 0; - } - } - - /** - * Convert HTML hexadecimal to RGB - * - * @param str $pValue HTML Color in hexadecimal - * @return array Value in RGB - */ - public static function htmlToRGB($pValue) { - if ($pValue[0] == '#'){ - $pValue = substr($pValue, 1); - } - - if (strlen($pValue) == 6){ - list($color_R, $color_G, $color_B) = array($pValue[0].$pValue[1],$pValue[2].$pValue[3],$pValue[4].$pValue[5]); - } - elseif (strlen($pValue) == 3){ - list($color_R, $color_G, $color_B) = array($pValue[0].$pValue[0],$pValue[1].$pValue[1],$pValue[2].$pValue[2]); - } - else{ - return false; - } - - $color_R = hexdec($color_R); - $color_G = hexdec($color_G); - $color_B = hexdec($color_B); - - return array($color_R, $color_G, $color_B); - } + /** + * Convert pixels to points + * + * @param int $pValue Value in pixels + * @return int Value in points + */ + public static function pixelsToPoints($pValue = 0) + { + return $pValue * 0.67777777; + } + + /** + * Convert points width to pixels + * + * @param int $pValue Value in points + * @return int Value in pixels + */ + public static function pointsToPixels($pValue = 0) + { + if ($pValue != 0) { + return $pValue * 1.333333333; + } else { + return 0; + } + } + + /** + * Convert degrees to angle + * + * @param int $pValue Degrees + * @return int Angle + */ + public static function degreesToAngle($pValue = 0) + { + return (int)round($pValue * 60000); + } + + /** + * Convert angle to degrees + * + * @param int $pValue Angle + * @return int Degrees + */ + public static function angleToDegrees($pValue = 0) + { + if ($pValue != 0) { + return round($pValue / 60000); + } else { + return 0; + } + } + + /** + * Convert pixels to centimeters + * + * @param int $pValue Value in pixels + * @return int Value in centimeters + */ + public static function pixelsToCentimeters($pValue = 0) + { + return $pValue * 0.028; + } + + /** + * Convert centimeters width to pixels + * + * @param int $pValue Value in centimeters + * @return int Value in pixels + */ + public static function centimetersToPixels($pValue = 0) + { + if ($pValue != 0) { + return $pValue * 0.028; + } else { + return 0; + } + } + + /** + * Convert HTML hexadecimal to RGB + * + * @param str $pValue HTML Color in hexadecimal + * @return array Value in RGB + */ + public static function htmlToRGB($pValue) + { + if ($pValue[0] == '#') { + $pValue = substr($pValue, 1); + } + + if (strlen($pValue) == 6) { + list($color_R, $color_G, $color_B) = array($pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]); + } elseif (strlen($pValue) == 3) { + list($color_R, $color_G, $color_B) = array($pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]); + } else { + return false; + } + + $color_R = hexdec($color_R); + $color_G = hexdec($color_G); + $color_B = hexdec($color_B); + + return array($color_R, $color_G, $color_B); + } } diff --git a/src/PHPWord/Shared/File.php b/src/PHPWord/Shared/File.php index fabaedf396..12e7c42461 100644 --- a/src/PHPWord/Shared/File.php +++ b/src/PHPWord/Shared/File.php @@ -28,64 +28,66 @@ class PHPWord_Shared_File { - /** - * Verify if a file exists - * - * @param string $pFilename Filename - * @return bool - */ - public static function file_exists($pFilename) { - // Sick construction, but it seems that - // file_exists returns strange values when - // doing the original file_exists on ZIP archives... - if ( strtolower(substr($pFilename, 0, 3)) == 'zip' ) { - // Open ZIP file and verify if the file exists - $zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6); - $archiveFile = substr($pFilename, strpos($pFilename, '#') + 1); + /** + * Verify if a file exists + * + * @param string $pFilename Filename + * @return bool + */ + public static function file_exists($pFilename) + { + // Sick construction, but it seems that + // file_exists returns strange values when + // doing the original file_exists on ZIP archives... + if (strtolower(substr($pFilename, 0, 3)) == 'zip') { + // Open ZIP file and verify if the file exists + $zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6); + $archiveFile = substr($pFilename, strpos($pFilename, '#') + 1); - $zip = new ZipArchive(); - if ($zip->open($zipFile) === true) { - $returnValue = ($zip->getFromName($archiveFile) !== false); - $zip->close(); - return $returnValue; - } else { - return false; - } - } else { - // Regular file_exists - return file_exists($pFilename); - } - } + $zip = new ZipArchive(); + if ($zip->open($zipFile) === true) { + $returnValue = ($zip->getFromName($archiveFile) !== false); + $zip->close(); + return $returnValue; + } else { + return false; + } + } else { + // Regular file_exists + return file_exists($pFilename); + } + } - /** - * Returns canonicalized absolute pathname, also for ZIP archives - * - * @param string $pFilename - * @return string - */ - public static function realpath($pFilename) { - // Returnvalue - $returnValue = ''; + /** + * Returns canonicalized absolute pathname, also for ZIP archives + * + * @param string $pFilename + * @return string + */ + public static function realpath($pFilename) + { + // Returnvalue + $returnValue = ''; - // Try using realpath() - $returnValue = realpath($pFilename); + // Try using realpath() + $returnValue = realpath($pFilename); - // Found something? - if ($returnValue == '' || is_null($returnValue)) { - $pathArray = split('/' , $pFilename); - while(in_array('..', $pathArray) && $pathArray[0] != '..') { - for ($i = 0; $i < count($pathArray); ++$i) { - if ($pathArray[$i] == '..' && $i > 0) { - unset($pathArray[$i]); - unset($pathArray[$i - 1]); - break; - } - } - } - $returnValue = implode('/', $pathArray); - } + // Found something? + if ($returnValue == '' || is_null($returnValue)) { + $pathArray = split('/', $pFilename); + while (in_array('..', $pathArray) && $pathArray[0] != '..') { + for ($i = 0; $i < count($pathArray); ++$i) { + if ($pathArray[$i] == '..' && $i > 0) { + unset($pathArray[$i]); + unset($pathArray[$i - 1]); + break; + } + } + } + $returnValue = implode('/', $pathArray); + } - // Return - return $returnValue; - } + // Return + return $returnValue; + } } diff --git a/src/PHPWord/Shared/Font.php b/src/PHPWord/Shared/Font.php index aae43764cf..ec1d47014f 100644 --- a/src/PHPWord/Shared/Font.php +++ b/src/PHPWord/Shared/Font.php @@ -28,45 +28,51 @@ class PHPWord_Shared_Font { - /** - * Calculate an (approximate) pixel size, based on a font points size - * - * @param int $fontSizeInPoints Font size (in points) - * @return int Font size (in pixels) - */ - public static function fontSizeToPixels($fontSizeInPoints = 12) { - return ((16 / 12) * $fontSizeInPoints); - } - - /** - * Calculate an (approximate) pixel size, based on inch size - * - * @param int $sizeInInch Font size (in inch) - * @return int Size (in pixels) - */ - public static function inchSizeToPixels($sizeInInch = 1) { - return ($sizeInInch * 96); - } - - /** - * Calculate an (approximate) pixel size, based on centimeter size - * - * @param int $sizeInCm Font size (in centimeters) - * @return int Size (in pixels) - */ - public static function centimeterSizeToPixels($sizeInCm = 1) { - return ($sizeInCm * 37.795275591); - } - - public static function centimeterSizeToTwips($sizeInCm = 1) { - return ($sizeInCm * 565.217); - } - - public static function inchSizeToTwips($sizeInInch = 1) { - return self::centimeterSizeToTwips($sizeInInch * 2.54); - } - - public static function pixelSizeToTwips($sizeInPixel = 1) { - return self::centimeterSizeToTwips($sizeInPixel / 37.795275591); - } + /** + * Calculate an (approximate) pixel size, based on a font points size + * + * @param int $fontSizeInPoints Font size (in points) + * @return int Font size (in pixels) + */ + public static function fontSizeToPixels($fontSizeInPoints = 12) + { + return ((16 / 12) * $fontSizeInPoints); + } + + /** + * Calculate an (approximate) pixel size, based on inch size + * + * @param int $sizeInInch Font size (in inch) + * @return int Size (in pixels) + */ + public static function inchSizeToPixels($sizeInInch = 1) + { + return ($sizeInInch * 96); + } + + /** + * Calculate an (approximate) pixel size, based on centimeter size + * + * @param int $sizeInCm Font size (in centimeters) + * @return int Size (in pixels) + */ + public static function centimeterSizeToPixels($sizeInCm = 1) + { + return ($sizeInCm * 37.795275591); + } + + public static function centimeterSizeToTwips($sizeInCm = 1) + { + return ($sizeInCm * 565.217); + } + + public static function inchSizeToTwips($sizeInInch = 1) + { + return self::centimeterSizeToTwips($sizeInInch * 2.54); + } + + public static function pixelSizeToTwips($sizeInPixel = 1) + { + return self::centimeterSizeToTwips($sizeInPixel / 37.795275591); + } } diff --git a/src/PHPWord/Shared/String.php b/src/PHPWord/Shared/String.php index 64309229aa..1085f66d86 100644 --- a/src/PHPWord/Shared/String.php +++ b/src/PHPWord/Shared/String.php @@ -28,236 +28,241 @@ class PHPWord_Shared_String { - /** - * Control characters array - * - * @var string[] - */ - private static $_controlCharacters = array(); - - /** - * Is mbstring extension avalable? - * - * @var boolean - */ - private static $_isMbstringEnabled; - - /** - * Is iconv extension avalable? - * - * @var boolean - */ - private static $_isIconvEnabled; - - /** - * Build control characters array - */ - private static function _buildControlCharacters() { - for ($i = 0; $i <= 19; ++$i) { - if ($i != 9 && $i != 10 && $i != 13) { - $find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_'; - $replace = chr($i); - self::$_controlCharacters[$find] = $replace; - } - } - } - - /** - * Get whether mbstring extension is available - * - * @return boolean - */ - public static function getIsMbstringEnabled() - { - if (isset(self::$_isMbstringEnabled)) { - return self::$_isMbstringEnabled; - } - - self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ? - true : false; - - return self::$_isMbstringEnabled; - } - - /** - * Get whether iconv extension is available - * - * @return boolean - */ - public static function getIsIconvEnabled() - { - if (isset(self::$_isIconvEnabled)) { - return self::$_isIconvEnabled; - } - - self::$_isIconvEnabled = function_exists('iconv') ? - true : false; - - return self::$_isIconvEnabled; - } - - /** - * Convert from OpenXML escaped control character to PHP 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 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 UTF8 data - * - * @param string $value - * @return boolean - */ - public static function IsUTF8($value = '') { - return utf8_encode(utf8_decode($value)) === $value; - } - - /** - * Formats a numeric value as a string for output in various output writers - * - * @param mixed $value - * @return string - */ - public static function FormatNumber($value) { - return number_format($value, 2, '.', ''); - } - - /** - * Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) - * Writes the string using uncompressed notation, no rich text, no Asian phonetics - * If mbstring extension is not available, ASCII is assumed, and compressed notation is used - * although this will give wrong results for non-ASCII strings - * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 - * - * @param string $value UTF-8 encoded string - * @return string - */ - public static function UTF8toBIFF8UnicodeShort($value) - { - // character count - $ln = self::CountCharacters($value, 'UTF-8'); - - // option flags - $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? - 0x0001 : 0x0000; - - // characters - $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); - - $data = pack('CC', $ln, $opt) . $chars; - return $data; - } - - /** - * Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) - * Writes the string using uncompressed notation, no rich text, no Asian phonetics - * If mbstring extension is not available, ASCII is assumed, and compressed notation is used - * although this will give wrong results for non-ASCII strings - * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 - * - * @param string $value UTF-8 encoded string - * @return string - */ - public static function UTF8toBIFF8UnicodeLong($value) - { - // character count - $ln = self::CountCharacters($value, 'UTF-8'); - - // option flags - $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? - 0x0001 : 0x0000; - - // characters - $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); - - $data = pack('vC', $ln, $opt) . $chars; - return $data; - } - - /** - * Convert string from one encoding to another. First try mbstring, then iconv, or no convertion - * - * @param string $value - * @param string $to Encoding to convert to, e.g. 'UTF-8' - * @param string $from Encoding to convert from, e.g. 'UTF-16LE' - * @return string - */ - public static function ConvertEncoding($value, $to, $from) - { - if (self::getIsMbstringEnabled()) { - $value = mb_convert_encoding($value, $to, $from); - return $value; - } - - if (self::getIsIconvEnabled()) { - $value = iconv($from, $to, $value); - return $value; - } - - // else, no conversion - return $value; - } - - /** - * Get character count. First try mbstring, then iconv, finally strlen - * - * @param string $value - * @param string $enc Encoding - * @return int Character count - */ - public static function CountCharacters($value, $enc = 'UTF-8') - { - if (self::getIsMbstringEnabled()) { - $count = mb_strlen($value, $enc); - return $count; - } - - if (self::getIsIconvEnabled()) { - $count = iconv_strlen($value, $enc); - return $count; - } - - // else strlen - $count = strlen($value); - return $count; - } + /** + * Control characters array + * + * @var string[] + */ + private static $_controlCharacters = array(); + + /** + * Is mbstring extension avalable? + * + * @var boolean + */ + private static $_isMbstringEnabled; + + /** + * Is iconv extension avalable? + * + * @var boolean + */ + private static $_isIconvEnabled; + + /** + * Build control characters array + */ + private static function _buildControlCharacters() + { + for ($i = 0; $i <= 19; ++$i) { + if ($i != 9 && $i != 10 && $i != 13) { + $find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_'; + $replace = chr($i); + self::$_controlCharacters[$find] = $replace; + } + } + } + + /** + * Get whether mbstring extension is available + * + * @return boolean + */ + public static function getIsMbstringEnabled() + { + if (isset(self::$_isMbstringEnabled)) { + return self::$_isMbstringEnabled; + } + + self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ? + true : false; + + return self::$_isMbstringEnabled; + } + + /** + * Get whether iconv extension is available + * + * @return boolean + */ + public static function getIsIconvEnabled() + { + if (isset(self::$_isIconvEnabled)) { + return self::$_isIconvEnabled; + } + + self::$_isIconvEnabled = function_exists('iconv') ? + true : false; + + return self::$_isIconvEnabled; + } + + /** + * Convert from OpenXML escaped control character to PHP 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 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 UTF8 data + * + * @param string $value + * @return boolean + */ + public static function IsUTF8($value = '') + { + return utf8_encode(utf8_decode($value)) === $value; + } + + /** + * Formats a numeric value as a string for output in various output writers + * + * @param mixed $value + * @return string + */ + public static function FormatNumber($value) + { + return number_format($value, 2, '.', ''); + } + + /** + * Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) + * Writes the string using uncompressed notation, no rich text, no Asian phonetics + * If mbstring extension is not available, ASCII is assumed, and compressed notation is used + * although this will give wrong results for non-ASCII strings + * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 + * + * @param string $value UTF-8 encoded string + * @return string + */ + public static function UTF8toBIFF8UnicodeShort($value) + { + // character count + $ln = self::CountCharacters($value, 'UTF-8'); + + // option flags + $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? + 0x0001 : 0x0000; + + // characters + $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); + + $data = pack('CC', $ln, $opt) . $chars; + return $data; + } + + /** + * Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) + * Writes the string using uncompressed notation, no rich text, no Asian phonetics + * If mbstring extension is not available, ASCII is assumed, and compressed notation is used + * although this will give wrong results for non-ASCII strings + * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 + * + * @param string $value UTF-8 encoded string + * @return string + */ + public static function UTF8toBIFF8UnicodeLong($value) + { + // character count + $ln = self::CountCharacters($value, 'UTF-8'); + + // option flags + $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? + 0x0001 : 0x0000; + + // characters + $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); + + $data = pack('vC', $ln, $opt) . $chars; + return $data; + } + + /** + * Convert string from one encoding to another. First try mbstring, then iconv, or no convertion + * + * @param string $value + * @param string $to Encoding to convert to, e.g. 'UTF-8' + * @param string $from Encoding to convert from, e.g. 'UTF-16LE' + * @return string + */ + public static function ConvertEncoding($value, $to, $from) + { + if (self::getIsMbstringEnabled()) { + $value = mb_convert_encoding($value, $to, $from); + return $value; + } + + if (self::getIsIconvEnabled()) { + $value = iconv($from, $to, $value); + return $value; + } + + // else, no conversion + return $value; + } + + /** + * Get character count. First try mbstring, then iconv, finally strlen + * + * @param string $value + * @param string $enc Encoding + * @return int Character count + */ + public static function CountCharacters($value, $enc = 'UTF-8') + { + if (self::getIsMbstringEnabled()) { + $count = mb_strlen($value, $enc); + return $count; + } + + if (self::getIsIconvEnabled()) { + $count = iconv_strlen($value, $enc); + return $count; + } + + // else strlen + $count = strlen($value); + return $count; + } } diff --git a/src/PHPWord/Shared/XMLWriter.php b/src/PHPWord/Shared/XMLWriter.php index d16f981d41..5f699cdc14 100644 --- a/src/PHPWord/Shared/XMLWriter.php +++ b/src/PHPWord/Shared/XMLWriter.php @@ -26,118 +26,123 @@ */ -if(!defined('DATE_W3C')) { - define('DATE_W3C', 'Y-m-d\TH:i:sP'); +if (!defined('DATE_W3C')) { + define('DATE_W3C', 'Y-m-d\TH:i:sP'); } -class PHPWord_Shared_XMLWriter { - /** Temporary storage method */ - const STORAGE_MEMORY = 1; - const STORAGE_DISK = 2; - - /** - * Internal XMLWriter - * - * @var XMLWriter - */ - private $_xmlWriter; - - /** - * Temporary filename - * - * @var string - */ - private $_tempFileName = ''; - - /** - * Create a new PHPPowerPoint_Shared_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(); - - // 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 default values - // proposed to be false in production version - $this->_xmlWriter->setIndent(true); - //$this->_xmlWriter->setIndent(false); - - // Set indent - // proposed to be '' in production version - $this->_xmlWriter->setIndentString(' '); - //$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); - } +class PHPWord_Shared_XMLWriter +{ + /** Temporary storage method */ + const STORAGE_MEMORY = 1; + const STORAGE_DISK = 2; + + /** + * Internal XMLWriter + * + * @var XMLWriter + */ + private $_xmlWriter; + + /** + * Temporary filename + * + * @var string + */ + private $_tempFileName = ''; + + /** + * Create a new PHPPowerPoint_Shared_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(); + + // 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 default values + // proposed to be false in production version + $this->_xmlWriter->setIndent(true); + //$this->_xmlWriter->setIndent(false); + + // Set indent + // proposed to be '' in production version + $this->_xmlWriter->setIndentString(' '); + //$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/PHPWord/Shared/ZipStreamWrapper.php b/src/PHPWord/Shared/ZipStreamWrapper.php index 9243f6f337..106d0ec919 100644 --- a/src/PHPWord/Shared/ZipStreamWrapper.php +++ b/src/PHPWord/Shared/ZipStreamWrapper.php @@ -30,147 +30,154 @@ PHPWord_Shared_ZipStreamWrapper::register(); -class PHPWord_Shared_ZipStreamWrapper { - /** - * Internal ZipAcrhive - * - * @var ZipAcrhive - */ - private $_archive; - - /** - * Filename in ZipAcrhive - * - * @var string - */ - private $_fileNameInArchive = ''; - - /** - * Position in file - * - * @var int - */ - private $_position = 0; - - /** - * Data - * - * @var mixed - */ - private $_data = ''; - - /** - * Register wrapper - */ - public static function register() { - @stream_wrapper_unregister("zip"); - @stream_wrapper_register("zip", __CLASS__); - } - - /** - * Open stream - */ - public function stream_open($path, $mode, $options, &$opened_path) { - // Check for mode - if ($mode{0} != 'r') { - throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.'); - } - - // Parse URL - $url = @parse_url($path); - - // Fix URL - if (!is_array($url)) { - $url['host'] = substr($path, strlen('zip://')); - $url['path'] = ''; - } - if (strpos($url['host'], '#') !== false) { - if (!isset($url['fragment'])) { - $url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path']; - $url['host'] = substr($url['host'], 0, strpos($url['host'], '#')); - unset($url['path']); - } - } else { - $url['host'] = $url['host'] . $url['path']; - unset($url['path']); - } - - // Open archive - $this->_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 - */ - 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; - } - } +class PHPWord_Shared_ZipStreamWrapper +{ + /** + * Internal ZipAcrhive + * + * @var ZipAcrhive + */ + private $_archive; + + /** + * Filename in ZipAcrhive + * + * @var string + */ + private $_fileNameInArchive = ''; + + /** + * Position in file + * + * @var int + */ + private $_position = 0; + + /** + * Data + * + * @var mixed + */ + private $_data = ''; + + /** + * Register wrapper + */ + public static function register() + { + @stream_wrapper_unregister("zip"); + @stream_wrapper_register("zip", __CLASS__); + } + + /** + * Open stream + */ + public function stream_open($path, $mode, $options, &$opened_path) + { + // Check for mode + if ($mode{0} != 'r') { + throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.'); + } + + // Parse URL + $url = @parse_url($path); + + // Fix URL + if (!is_array($url)) { + $url['host'] = substr($path, strlen('zip://')); + $url['path'] = ''; + } + if (strpos($url['host'], '#') !== false) { + if (!isset($url['fragment'])) { + $url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path']; + $url['host'] = substr($url['host'], 0, strpos($url['host'], '#')); + unset($url['path']); + } + } else { + $url['host'] = $url['host'] . $url['path']; + unset($url['path']); + } + + // Open archive + $this->_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 + */ + 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; + } + } } -?> diff --git a/src/PHPWord/Style.php b/src/PHPWord/Style.php index 30461c0e5f..afd2840f26 100644 --- a/src/PHPWord/Style.php +++ b/src/PHPWord/Style.php @@ -33,133 +33,141 @@ * @package PHPWord_Style * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_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(); - foreach($styles as $key => $value) { - if(substr($key, 0, 1) != '_') { - $key = '_'.$key; - } - $style->setStyleValue($key, $value); - } - - self::$_styleElements[$styleName] = $style; - } - } - - /** - * Add a font 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 PHPWord_Style_Font('text', $styleParagraph); - foreach($styleFont as $key => $value) { - if(substr($key, 0, 1) != '_') { - $key = '_'.$key; - } - $font->setStyleValue($key, $value); - } - self::$_styleElements[$styleName] = $font; - } - } - - /** - * 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'); - foreach($styles as $key => $value) { - if(substr($key, 0, 1) != '_') { - $key = '_'.$key; - } - $style->setStyleValue($key, $value); - } - - self::$_styleElements[$styleName] = $style; - } - } - - /** - * 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); - - self::$_styleElements[$styleName] = $style; - } - } - - /** - * Add a title 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 PHPWord_Style_Font('title', $styleParagraph); - foreach($styleFont as $key => $value) { - if(substr($key, 0, 1) != '_') { - $key = '_'.$key; - } - $font->setStyleValue($key, $value); - } - - self::$_styleElements[$styleName] = $font; - } - } - - /** - * Get all styles - * - * @return PHPWord_Style_Font[] - */ - public static function getStyles() { - return self::$_styleElements; - } - - /** - * Get style - * - * @param string - * @return PHPWord_Style - */ - public static function getStyle($styleName) { - if(array_key_exists($styleName, self::$_styleElements)){ - return self::$_styleElements[$styleName]; - } else { - return null; - } - } +class PHPWord_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(); + foreach ($styles as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $style->setStyleValue($key, $value); + } + + self::$_styleElements[$styleName] = $style; + } + } + + /** + * Add a font 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 PHPWord_Style_Font('text', $styleParagraph); + foreach ($styleFont as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $font->setStyleValue($key, $value); + } + self::$_styleElements[$styleName] = $font; + } + } + + /** + * 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'); + foreach ($styles as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $style->setStyleValue($key, $value); + } + + self::$_styleElements[$styleName] = $style; + } + } + + /** + * 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); + + self::$_styleElements[$styleName] = $style; + } + } + + /** + * Add a title 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 PHPWord_Style_Font('title', $styleParagraph); + foreach ($styleFont as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $font->setStyleValue($key, $value); + } + + self::$_styleElements[$styleName] = $font; + } + } + + /** + * Get all styles + * + * @return PHPWord_Style_Font[] + */ + public static function getStyles() + { + return self::$_styleElements; + } + + /** + * Get style + * + * @param string + * @return PHPWord_Style + */ + public static function getStyle($styleName) + { + if (array_key_exists($styleName, self::$_styleElements)) { + return self::$_styleElements[$styleName]; + } else { + return null; + } + } } -?> + diff --git a/src/PHPWord/Style/Cell.php b/src/PHPWord/Style/Cell.php index a09b306714..f8db60e855 100644 --- a/src/PHPWord/Style/Cell.php +++ b/src/PHPWord/Style/Cell.php @@ -33,259 +33,289 @@ * @package PHPWord_Style * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Style_Cell { - - const TEXT_DIR_BTLR = 'btLr'; - const TEXT_DIR_TBRL = 'tbRl'; - - /** - * Vertical align - * - * @var string - */ - private $_valign; - - /** - * Text Direction - * - * @var string - */ - private $_textDirection; - - /** - * 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 Default Color - * - * @var string - */ - private $_defaultBorderColor; - - - /** - * Create a new Cell Style - */ - public function __construct() { - $this->_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 setHeight($pValue = null) { - $this->_height = $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; - } +class PHPWord_Style_Cell +{ + + const TEXT_DIR_BTLR = 'btLr'; + const TEXT_DIR_TBRL = 'tbRl'; + + /** + * Vertical align + * + * @var string + */ + private $_valign; + + /** + * Text Direction + * + * @var string + */ + private $_textDirection; + + /** + * 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 Default Color + * + * @var string + */ + private $_defaultBorderColor; + + + /** + * Create a new Cell Style + */ + public function __construct() + { + $this->_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 setHeight($pValue = null) + { + $this->_height = $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; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Style/Font.php b/src/PHPWord/Style/Font.php index 9bb2f467ff..e3b5a89e9a 100644 --- a/src/PHPWord/Style/Font.php +++ b/src/PHPWord/Style/Font.php @@ -33,229 +33,253 @@ * @package PHPWord_Style * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Style_Font { - - const UNDERLINE_NONE = 'none'; - const UNDERLINE_DASH = 'dash'; - const UNDERLINE_DASHHEAVY = 'dashHeavy'; - const UNDERLINE_DASHLONG = 'dashLong'; - const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy'; - const UNDERLINE_DOUBLE = 'dbl'; - const UNDERLINE_DOTHASH = 'dotDash'; - const UNDERLINE_DOTHASHHEAVY = 'dotDashHeavy'; - const UNDERLINE_DOTDOTDASH = 'dotDotDash'; - const UNDERLINE_DOTDOTDASHHEAVY = 'dotDotDashHeavy'; - const UNDERLINE_DOTTED = 'dotted'; - const UNDERLINE_DOTTEDHEAVY = 'dottedHeavy'; - const UNDERLINE_HEAVY = 'heavy'; - const UNDERLINE_SINGLE = 'single'; - const UNDERLINE_WAVY = 'wavy'; - const UNDERLINE_WAVYDOUBLE = 'wavyDbl'; - const UNDERLINE_WAVYHEAVY = 'wavyHeavy'; - const UNDERLINE_WORDS = 'words'; - - const FGCOLOR_YELLOW = 'yellow'; - const FGCOLOR_LIGHTGREEN = 'green'; - const FGCOLOR_CYAN = 'cyan'; - const FGCOLOR_MAGENTA = 'magenta'; - const FGCOLOR_BLUE = 'blue'; - const FGCOLOR_RED = 'red'; - const FGCOLOR_DARKBLUE = 'darkBlue'; - const FGCOLOR_DARKCYAN = 'darkCyan'; - const FGCOLOR_DARKGREEN = 'darkGreen'; - const FGCOLOR_DARKMAGENTA = 'darkMagenta'; - const FGCOLOR_DARKRED = 'darkRed'; - const FGCOLOR_DARKYELLOW = 'darkYellow'; - const FGCOLOR_DARKGRAY = 'darkGray'; - const FGCOLOR_LIGHTGRAY = 'lightGray'; - const FGCOLOR_BLACK = 'black'; - - /** - * Font style type - * - * @var string - */ - private $_type; - - /** - * Paragraph Style - * - * @var PHPWord_Style_Paragraph - */ - private $_paragraphStyle; - - private $_size; - private $_name; - private $_bold; - private $_italic; - private $_superScript; - private $_subScript; - private $_underline; - private $_strikethrough; - private $_color; - private $_fgColor; - - public function __construct($type = 'text', $styleParagraph = null) { - $this->_type = $type; - $this->_name = 'Arial'; - $this->_size = 20; - $this->_bold = false; - $this->_italic = false; - $this->_superScript = false; - $this->_subScript = false; - $this->_underline = PHPWord_Style_Font::UNDERLINE_NONE; - $this->_strikethrough = false; - $this->_color = '000000'; - $this->_fgColor = null; - - if(!is_null($styleParagraph)) { - $paragraph = new PHPWord_Style_Paragraph(); - foreach($styleParagraph as $key => $value) { - if(substr($key, 0, 1) != '_') { - $key = '_'.$key; - } - $paragraph->setStyleValue($key, $value); - } - $this->_paragraphStyle = $paragraph; - } else { - $this->_paragraphStyle = null; - } - } - - public function getName() { - return $this->_name; - } - - public function setStyleValue($key, $value) { - if($key == '_size') { - $value *= 2; - } - $this->$key = $value; - } - - public function setName($pValue = 'Arial') { - if($pValue == '') { - $pValue = 'Arial'; - } - $this->_name = $pValue; - return $this; - } - - public function getSize() { - return $this->_size; - } - - public function setSize($pValue = 20) { - if($pValue == '') { - $pValue = 20; - } - $this->_size = ($pValue*2); - return $this; - } - - public function getBold() { - return $this->_bold; - } - - public function setBold($pValue = false) { - if($pValue == '') { - $pValue = false; - } - $this->_bold = $pValue; - return $this; - } - - public function getItalic() { - return $this->_italic; - } - - public function setItalic($pValue = false) { - if($pValue == '') { - $pValue = false; - } - $this->_italic = $pValue; - return $this; - } - - public function getSuperScript() { - return $this->_superScript; - } - - public function setSuperScript($pValue = false) { - if($pValue == '') { - $pValue = false; - } - $this->_superScript = $pValue; - $this->_subScript = !$pValue; - return $this; - } - - public function getSubScript() { - return $this->_subScript; - } - - public function setSubScript($pValue = false) { - if($pValue == '') { - $pValue = false; - } - $this->_subScript = $pValue; - $this->_superScript = !$pValue; - return $this; - } - - public function getUnderline() { - return $this->_underline; - } - - public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) { - if ($pValue == '') { - $pValue = PHPWord_Style_Font::UNDERLINE_NONE; - } - $this->_underline = $pValue; - return $this; - } - - public function getStrikethrough() { - return $this->_strikethrough; - } - - public function setStrikethrough($pValue = false) { - if($pValue == '') { - $pValue = false; - } - $this->_strikethrough = $pValue; - return $this; - } - - public function getColor() { - return $this->_color; - } - - public function setColor($pValue = '000000') { - $this->_color = $pValue; - return $this; - } - - public function getFgColor() { - return $this->_fgColor; - } - - public function setFgColor($pValue = null) { - $this->_fgColor = $pValue; - return $this; - } - - public function getStyleType() { - return $this->_type; - } - - /** - * Get Paragraph style - * - * @return PHPWord_Style_Paragraph - */ - public function getParagraphStyle() { - return $this->_paragraphStyle; - } +class PHPWord_Style_Font +{ + + const UNDERLINE_NONE = 'none'; + const UNDERLINE_DASH = 'dash'; + const UNDERLINE_DASHHEAVY = 'dashHeavy'; + const UNDERLINE_DASHLONG = 'dashLong'; + const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy'; + const UNDERLINE_DOUBLE = 'dbl'; + const UNDERLINE_DOTHASH = 'dotDash'; + const UNDERLINE_DOTHASHHEAVY = 'dotDashHeavy'; + const UNDERLINE_DOTDOTDASH = 'dotDotDash'; + const UNDERLINE_DOTDOTDASHHEAVY = 'dotDotDashHeavy'; + const UNDERLINE_DOTTED = 'dotted'; + const UNDERLINE_DOTTEDHEAVY = 'dottedHeavy'; + const UNDERLINE_HEAVY = 'heavy'; + const UNDERLINE_SINGLE = 'single'; + const UNDERLINE_WAVY = 'wavy'; + const UNDERLINE_WAVYDOUBLE = 'wavyDbl'; + const UNDERLINE_WAVYHEAVY = 'wavyHeavy'; + const UNDERLINE_WORDS = 'words'; + + const FGCOLOR_YELLOW = 'yellow'; + const FGCOLOR_LIGHTGREEN = 'green'; + const FGCOLOR_CYAN = 'cyan'; + const FGCOLOR_MAGENTA = 'magenta'; + const FGCOLOR_BLUE = 'blue'; + const FGCOLOR_RED = 'red'; + const FGCOLOR_DARKBLUE = 'darkBlue'; + const FGCOLOR_DARKCYAN = 'darkCyan'; + const FGCOLOR_DARKGREEN = 'darkGreen'; + const FGCOLOR_DARKMAGENTA = 'darkMagenta'; + const FGCOLOR_DARKRED = 'darkRed'; + const FGCOLOR_DARKYELLOW = 'darkYellow'; + const FGCOLOR_DARKGRAY = 'darkGray'; + const FGCOLOR_LIGHTGRAY = 'lightGray'; + const FGCOLOR_BLACK = 'black'; + + /** + * Font style type + * + * @var string + */ + private $_type; + + /** + * Paragraph Style + * + * @var PHPWord_Style_Paragraph + */ + private $_paragraphStyle; + + private $_size; + private $_name; + private $_bold; + private $_italic; + private $_superScript; + private $_subScript; + private $_underline; + private $_strikethrough; + private $_color; + private $_fgColor; + + public function __construct($type = 'text', $styleParagraph = null) + { + $this->_type = $type; + $this->_name = 'Arial'; + $this->_size = 20; + $this->_bold = false; + $this->_italic = false; + $this->_superScript = false; + $this->_subScript = false; + $this->_underline = PHPWord_Style_Font::UNDERLINE_NONE; + $this->_strikethrough = false; + $this->_color = '000000'; + $this->_fgColor = null; + + if (!is_null($styleParagraph)) { + $paragraph = new PHPWord_Style_Paragraph(); + foreach ($styleParagraph as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + $paragraph->setStyleValue($key, $value); + } + $this->_paragraphStyle = $paragraph; + } else { + $this->_paragraphStyle = null; + } + } + + public function getName() + { + return $this->_name; + } + + public function setStyleValue($key, $value) + { + if ($key == '_size') { + $value *= 2; + } + $this->$key = $value; + } + + public function setName($pValue = 'Arial') + { + if ($pValue == '') { + $pValue = 'Arial'; + } + $this->_name = $pValue; + return $this; + } + + public function getSize() + { + return $this->_size; + } + + public function setSize($pValue = 20) + { + if ($pValue == '') { + $pValue = 20; + } + $this->_size = ($pValue * 2); + return $this; + } + + public function getBold() + { + return $this->_bold; + } + + public function setBold($pValue = false) + { + if ($pValue == '') { + $pValue = false; + } + $this->_bold = $pValue; + return $this; + } + + public function getItalic() + { + return $this->_italic; + } + + public function setItalic($pValue = false) + { + if ($pValue == '') { + $pValue = false; + } + $this->_italic = $pValue; + return $this; + } + + public function getSuperScript() + { + return $this->_superScript; + } + + public function setSuperScript($pValue = false) + { + if ($pValue == '') { + $pValue = false; + } + $this->_superScript = $pValue; + $this->_subScript = !$pValue; + return $this; + } + + public function getSubScript() + { + return $this->_subScript; + } + + public function setSubScript($pValue = false) + { + if ($pValue == '') { + $pValue = false; + } + $this->_subScript = $pValue; + $this->_superScript = !$pValue; + return $this; + } + + public function getUnderline() + { + return $this->_underline; + } + + public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) + { + if ($pValue == '') { + $pValue = PHPWord_Style_Font::UNDERLINE_NONE; + } + $this->_underline = $pValue; + return $this; + } + + public function getStrikethrough() + { + return $this->_strikethrough; + } + + public function setStrikethrough($pValue = false) + { + if ($pValue == '') { + $pValue = false; + } + $this->_strikethrough = $pValue; + return $this; + } + + public function getColor() + { + return $this->_color; + } + + public function setColor($pValue = '000000') + { + $this->_color = $pValue; + return $this; + } + + public function getFgColor() + { + return $this->_fgColor; + } + + public function setFgColor($pValue = null) + { + $this->_fgColor = $pValue; + return $this; + } + + public function getStyleType() + { + return $this->_type; + } + + /** + * Get Paragraph style + * + * @return PHPWord_Style_Paragraph + */ + public function getParagraphStyle() + { + return $this->_paragraphStyle; + } } -?> diff --git a/src/PHPWord/Style/Image.php b/src/PHPWord/Style/Image.php index c0007d3e70..1c93674f41 100644 --- a/src/PHPWord/Style/Image.php +++ b/src/PHPWord/Style/Image.php @@ -33,98 +33,110 @@ * @package PHPWord_Section * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Style_Image { - - private $_width; - private $_height; - private $_align; - - /** - * Margin Top - * - * @var int - */ - private $_marginTop; - - /** - * Margin Left - * - * @var int - */ - private $_marginLeft; - - public function __construct() { - $this->_width = null; - $this->_height = null; - $this->_align = null; - $this->_marginTop = null; - $this->_marginLeft = null; - } - - 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 - */ - 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 - */ - public function setMarginLeft($pValue = null) { - $this->_marginLeft = $pValue; - return $this; - } +class PHPWord_Style_Image +{ + + private $_width; + private $_height; + private $_align; + + /** + * Margin Top + * + * @var int + */ + private $_marginTop; + + /** + * Margin Left + * + * @var int + */ + private $_marginLeft; + + public function __construct() + { + $this->_width = null; + $this->_height = null; + $this->_align = null; + $this->_marginTop = null; + $this->_marginLeft = null; + } + + 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 + */ + 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 + */ + public function setMarginLeft($pValue = null) + { + $this->_marginLeft = $pValue; + return $this; + } } -?> diff --git a/src/PHPWord/Style/ListItem.php b/src/PHPWord/Style/ListItem.php index e4ddb8a72b..1ff7cb50a7 100644 --- a/src/PHPWord/Style/ListItem.php +++ b/src/PHPWord/Style/ListItem.php @@ -33,51 +33,55 @@ * @package PHPWord_Style * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Style_ListItem { - - const TYPE_NUMBER = 7; - const TYPE_NUMBER_NESTED = 8; - const TYPE_ALPHANUM = 9; - const TYPE_BULLET_FILLED = 3; - const TYPE_BULLET_EMPTY = 5; - const TYPE_SQUARE_FILLED = 1; - - /** - * List Type - */ - private $_listType; - - /** - * Create a new ListItem Style - */ - public function __construct() { - $this->_listType = PHPWord_Style_ListItem::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 = PHPWord_Style_ListItem::TYPE_BULLET_FILLED) { - $this->_listType = $pValue; - } - - /** - * Get List Type - */ - public function getListType() { - return $this->_listType; - } +class PHPWord_Style_ListItem +{ + + const TYPE_NUMBER = 7; + const TYPE_NUMBER_NESTED = 8; + const TYPE_ALPHANUM = 9; + const TYPE_BULLET_FILLED = 3; + const TYPE_BULLET_EMPTY = 5; + const TYPE_SQUARE_FILLED = 1; + + /** + * List Type + */ + private $_listType; + + /** + * Create a new ListItem Style + */ + public function __construct() + { + $this->_listType = PHPWord_Style_ListItem::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 = PHPWord_Style_ListItem::TYPE_BULLET_FILLED) + { + $this->_listType = $pValue; + } + + /** + * Get List Type + */ + public function getListType() + { + return $this->_listType; + } } -?> diff --git a/src/PHPWord/Style/Paragraph.php b/src/PHPWord/Style/Paragraph.php index 9c841c7c59..a7b0f5d995 100644 --- a/src/PHPWord/Style/Paragraph.php +++ b/src/PHPWord/Style/Paragraph.php @@ -33,174 +33,186 @@ * @package PHPWord_Style * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Style_Paragraph { - - /** - * Paragraph alignment - * - * @var string - */ - private $_align; - - /** - * Space before Paragraph - * - * @var int - */ - private $_spaceBefore; - - /** - * Space after Paragraph - * - * @var int - */ - private $_spaceAfter; - - /** - * Spacing between breaks - * - * @var int - */ - private $_spacing; - - - /** - * Indent by how much - * - * @var int - */ - private $_indent; - - - /** - * New Paragraph Style - */ - public function __construct() { - $this->_align = null; - $this->_spaceBefore = null; - $this->_spaceAfter = null; - $this->_spacing = null; - $this->_indent = null; - } - - /** - * Set Style value - * - * @param string $key - * @param mixed $value - */ - public function setStyleValue($key, $value) { - if($key == '_spacing') { - $value += 240; // because line height of 1 matches 240 twips - } - if($key == '_indent') { +class PHPWord_Style_Paragraph +{ + + /** + * Paragraph alignment + * + * @var string + */ + private $_align; + + /** + * Space before Paragraph + * + * @var int + */ + private $_spaceBefore; + + /** + * Space after Paragraph + * + * @var int + */ + private $_spaceAfter; + + /** + * Spacing between breaks + * + * @var int + */ + private $_spacing; + + + /** + * Indent by how much + * + * @var int + */ + private $_indent; + + + /** + * New Paragraph Style + */ + public function __construct() + { + $this->_align = null; + $this->_spaceBefore = null; + $this->_spaceAfter = null; + $this->_spacing = null; + $this->_indent = null; + } + + /** + * Set Style value + * + * @param string $key + * @param mixed $value + */ + public function setStyleValue($key, $value) + { + if ($key == '_spacing') { + $value += 240; // because line height of 1 matches 240 twips + } + if ($key == '_indent') { $value = (int)$value * 720; // 720 twips per indent - } - $this->$key = $value; - } - - /** - * Get Paragraph Alignment - * - * @return string - */ - public function getAlign() { - return $this->_align; - } - - /** - * Set Paragraph Alignment - * - * @param string $pValue - * @return 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 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 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 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 PHPWord_Style_Paragraph - */ - public function setIndent($pValue = null) { - $this->_indent = $pValue; - return $this; - } + } + $this->$key = $value; + } + + /** + * Get Paragraph Alignment + * + * @return string + */ + public function getAlign() + { + return $this->_align; + } + + /** + * Set Paragraph Alignment + * + * @param string $pValue + * @return 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 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 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 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 PHPWord_Style_Paragraph + */ + public function setIndent($pValue = null) + { + $this->_indent = $pValue; + return $this; + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Style/TOC.php b/src/PHPWord/Style/TOC.php index 29b31304d4..4604b24258 100644 --- a/src/PHPWord/Style/TOC.php +++ b/src/PHPWord/Style/TOC.php @@ -33,106 +33,114 @@ * @package PHPWord_Style * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Style_TOC { - - const TABLEADER_DOT = 'dot'; - const TABLEADER_UNDERSCORE = 'underscore'; - const TABLEADER_LINE = 'hyphen'; - const TABLEADER_NONE = ''; - - /** - * Tab Leader - * - * @var string - */ - private $_tabLeader; - - /** - * Tab Position - * - * @var int - */ - private $_tabPos; - - /** - * Indent - * - * @var int - */ - private $_indent; - - - /** - * Create a new TOC Style - */ - public function __construct() { - $this->_tabPos = 9062; - $this->_tabLeader = PHPWord_Style_TOC::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->_tabLeader = $pValue; - } - - /** - * Get Tab Leader - * - * @return string - */ - public function getTabLeader() { - return $this->_tabLeader; - } - - /** - * Set Tab Leader - * - * @param string $pValue - */ - public function setTabLeader($pValue = PHPWord_Style_TOC::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; - } +class PHPWord_Style_TOC +{ + + const TABLEADER_DOT = 'dot'; + const TABLEADER_UNDERSCORE = 'underscore'; + const TABLEADER_LINE = 'hyphen'; + const TABLEADER_NONE = ''; + + /** + * Tab Leader + * + * @var string + */ + private $_tabLeader; + + /** + * Tab Position + * + * @var int + */ + private $_tabPos; + + /** + * Indent + * + * @var int + */ + private $_indent; + + + /** + * Create a new TOC Style + */ + public function __construct() + { + $this->_tabPos = 9062; + $this->_tabLeader = PHPWord_Style_TOC::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->_tabLeader = $pValue; + } + + /** + * Get Tab Leader + * + * @return string + */ + public function getTabLeader() + { + return $this->_tabLeader; + } + + /** + * Set Tab Leader + * + * @param string $pValue + */ + public function setTabLeader($pValue = PHPWord_Style_TOC::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/PHPWord/Style/Table.php b/src/PHPWord/Style/Table.php index a6f080601f..c60ce4843e 100644 --- a/src/PHPWord/Style/Table.php +++ b/src/PHPWord/Style/Table.php @@ -26,58 +26,69 @@ */ -class PHPWord_Style_Table { - - private $_cellMarginTop; - private $_cellMarginLeft; - private $_cellMarginRight; - private $_cellMarginBottom; - - public function __construct() { - $this->_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); - } +class PHPWord_Style_Table +{ + + private $_cellMarginTop; + private $_cellMarginLeft; + private $_cellMarginRight; + private $_cellMarginBottom; + + public function __construct() + { + $this->_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); + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Style/TableFull.php b/src/PHPWord/Style/TableFull.php index 4140e63929..66b2832323 100644 --- a/src/PHPWord/Style/TableFull.php +++ b/src/PHPWord/Style/TableFull.php @@ -33,410 +33,454 @@ * @package PHPWord_Style * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Style_TableFull { - - /** - * Style for first row - * - * @var PHPWord_Style_Table - */ - 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) { - - if(!is_null($styleFirstRow) && is_array($styleFirstRow)) { - $this->_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); - } - } - } - - /** - * Set style 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 PHPWord_Style_TableFull - */ - public function getFirstRow() { - return $this->_firstRow; - } - - /** - * Get Last Row Style - * - * @return 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 - */ - 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; - } - - 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); - } +class PHPWord_Style_TableFull +{ + + /** + * Style for first row + * + * @var PHPWord_Style_Table + */ + 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) + { + + if (!is_null($styleFirstRow) && is_array($styleFirstRow)) { + $this->_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); + } + } + } + + /** + * Set style 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 PHPWord_Style_TableFull + */ + public function getFirstRow() + { + return $this->_firstRow; + } + + /** + * Get Last Row Style + * + * @return 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 + */ + 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; + } + + 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/PHPWord/TOC.php b/src/PHPWord/TOC.php index ab4f05c6f5..6c20fd3eb9 100644 --- a/src/PHPWord/TOC.php +++ b/src/PHPWord/TOC.php @@ -33,123 +33,128 @@ * @package PHPWord_TOC * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_TOC { - - /** - * Title Elements - * - * @var array - */ - private static $_titles = array(); - - /** - * TOC Style - * - * @var array - */ - private static $_styleTOC; - - /** - * Font Style - * - * @var array - */ - private static $_styleFont; - - /** - * Title Anchor - * - * @var array - */ - private static $_anchor = 252634154; - - /** - * Title Bookmark - * - * @var array - */ - private static $_bookmarkId = 0; - - - /** - * Create a new Table-of-Contents Element - * - * @param array $styleFont - * @param array $styleTOC - */ - public function __construct($styleFont = null, $styleTOC = null) { - self::$_styleTOC = new PHPWord_Style_TOC(); - - if(!is_null($styleTOC) && is_array($styleTOC)) { - foreach($styleTOC as $key => $value) { - if(substr($key, 0, 1) != '_') { - $key = '_'.$key; - } - self::$_styleTOC->setStyleValue($key, $value); - } - } - - if(!is_null($styleFont)) { - if(is_array($styleFont)) { - self::$_styleFont = new PHPWord_Style_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 PHPWord_Style_TOC - */ - public static function getStyleTOC() { - return self::$_styleTOC; - } - - /** - * Get Font Style - * - * @return PHPWord_Style_Font - */ - public static function getStyleFont() { - return self::$_styleFont; - } -} -?> \ No newline at end of file +class PHPWord_TOC +{ + + /** + * Title Elements + * + * @var array + */ + private static $_titles = array(); + + /** + * TOC Style + * + * @var array + */ + private static $_styleTOC; + + /** + * Font Style + * + * @var array + */ + private static $_styleFont; + + /** + * Title Anchor + * + * @var array + */ + private static $_anchor = 252634154; + + /** + * Title Bookmark + * + * @var array + */ + private static $_bookmarkId = 0; + + + /** + * Create a new Table-of-Contents Element + * + * @param array $styleFont + * @param array $styleTOC + */ + public function __construct($styleFont = null, $styleTOC = null) + { + self::$_styleTOC = new PHPWord_Style_TOC(); + + if (!is_null($styleTOC) && is_array($styleTOC)) { + foreach ($styleTOC as $key => $value) { + if (substr($key, 0, 1) != '_') { + $key = '_' . $key; + } + self::$_styleTOC->setStyleValue($key, $value); + } + } + + if (!is_null($styleFont)) { + if (is_array($styleFont)) { + self::$_styleFont = new PHPWord_Style_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 PHPWord_Style_TOC + */ + public static function getStyleTOC() + { + return self::$_styleTOC; + } + + /** + * Get Font Style + * + * @return PHPWord_Style_Font + */ + public static function getStyleFont() + { + return self::$_styleFont; + } +} \ No newline at end of file diff --git a/src/PHPWord/Template.php b/src/PHPWord/Template.php index 832776c3ab..44e8bdf499 100644 --- a/src/PHPWord/Template.php +++ b/src/PHPWord/Template.php @@ -33,64 +33,68 @@ * @package PHPWord * @copyright Copyright (c) 2009 - 2011 PHPWord (http://www.codeplex.com/PHPWord) */ -class PHPWord_Template { - +class PHPWord_Template +{ + /** * ZipArchive - * + * * @var ZipArchive */ private $_objZip; - + /** * Temporary Filename - * + * * @var string */ private $_tempFileName; - + /** * Document XML - * + * * @var string */ private $_documentXML; - - + + /** * Create a new Template Object - * + * * @param string $strFilename */ - public function __construct($strFilename) { + public function __construct($strFilename) + { $path = dirname($strFilename); - $this->_tempFileName = $path.DIRECTORY_SEPARATOR.time().'.docx'; - + $this->_tempFileName = $path . DIRECTORY_SEPARATOR . time() . '.docx'; + copy($strFilename, $this->_tempFileName); // Copy the source File to the temp File $this->_objZip = new ZipArchive(); $this->_objZip->open($this->_tempFileName); - + $this->_documentXML = $this->_objZip->getFromName('word/document.xml'); } - + /** * Set a Template value - * + * * @param mixed $search * @param mixed $replace */ - public function setValue($search, $replace) { - if(substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { - $search = '${'.$search.'}'; + public function setValue($search, $replace) + { + if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { + $search = '${' . $search . '}'; } - - if(!is_array($replace)) { + + if (!is_array($replace)) { $replace = utf8_encode($replace); } - + $this->_documentXML = str_replace($search, $replace, $this->_documentXML); } + /** * Returns array of all variables in template */ @@ -99,24 +103,25 @@ public function getVariables() preg_match_all('/\$\{(.*?)}/i', $this->_documentXML, $matches); return $matches[1]; } + /** * Save Template - * + * * @param string $strFilename */ - public function save($strFilename) { - if(file_exists($strFilename)) { + public function save($strFilename) + { + if (file_exists($strFilename)) { unlink($strFilename); } - + $this->_objZip->addFromString('word/document.xml', $this->_documentXML); - + // Close zip file - if($this->_objZip->close() === false) { + if ($this->_objZip->close() === false) { throw new Exception('Could not close zip file.'); } - + rename($this->_tempFileName, $strFilename); } } -?> \ No newline at end of file diff --git a/src/PHPWord/Writer/IWriter.php b/src/PHPWord/Writer/IWriter.php index 76db31e98e..8302bee56b 100644 --- a/src/PHPWord/Writer/IWriter.php +++ b/src/PHPWord/Writer/IWriter.php @@ -28,12 +28,11 @@ interface PHPWord_Writer_IWriter { - /** - * Save PHPWord to file - * - * @param string $pFileName - * @throws Exception - */ - public function save($pFilename = null); + /** + * Save PHPWord to file + * + * @param string $pFileName + * @throws Exception + */ + public function save($pFilename = null); } -?> \ No newline at end of file diff --git a/src/PHPWord/Writer/ODText.php b/src/PHPWord/Writer/ODText.php index 0dd9712784..6ace605f3d 100644 --- a/src/PHPWord/Writer/ODText.php +++ b/src/PHPWord/Writer/ODText.php @@ -27,254 +27,261 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter { - /** - * Private PHPWord - * - * @var PHPWord - */ - private $_document; - - /** - * Private writer parts - * - * @var PHPWord_Writer_ODText_WriterPart[] - */ - private $_writerParts; - - /** - * Private unique PHPWord_Worksheet_BaseDrawing HashTable - * - * @var PHPWord_HashTable - */ - private $_drawingHashTable; - - /** - * Use disk caching where possible? - * - * @var boolean - */ - private $_useDiskCaching = false; - - /** - * Disk caching directory - * - * @var string - */ - private $_diskCachingDirectory; - - /** - * Create a new PHPWord_Writer_ODText - * - * @param PHPWord $pPHPWord - */ - public function __construct(PHPWord $pPHPWord = null) - { - // Assign PHPWord - $this->setPHPWord($pPHPWord); - - // Set up disk caching location - $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(); - - - // Assign parent IWriter - foreach ($this->_writerParts as $writer) { - $writer->setParentWriter($this); - } - - // Set HashTable variables - $this->_drawingHashTable = new PHPWord_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 - 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); - } else if ($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); - } - } - - // 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."); - } - } - - /** - * Get PHPWord object - * - * @return PHPWord - * @throws Exception - */ - public function getPHPWord() { - if (!is_null($this->_document)) { - return $this->_document; - } else { - throw new Exception("No PHPWord assigned."); - } - } - - /** - * Get PHPWord object - * - * @param PHPWord $pPHPWord PHPWord object - * @throws Exception - * @return PHPWord_Writer_PowerPoint2007 - */ - public function setPHPWord(PHPWord $pPHPWord = null) { - $this->_document = $pPHPWord; - return $this; - } - - /** - * Get PHPWord_Worksheet_BaseDrawing HashTable - * - * @return PHPWord_HashTable - */ - public function getDrawingHashTable() { - return $this->_drawingHashTable; - } - - /** - * Get writer part - * - * @param string $pPartName Writer part name - * @return PHPWord_Writer_ODText_WriterPart - */ - 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 PHPWord_Writer_PowerPoint2007 - */ - 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; - } - - /** - * Get disk caching directory - * - * @return string - */ - public function getDiskCachingDirectory() { - return $this->_diskCachingDirectory; - } + /** + * Private PHPWord + * + * @var PHPWord + */ + private $_document; + + /** + * Private writer parts + * + * @var PHPWord_Writer_ODText_WriterPart[] + */ + private $_writerParts; + + /** + * Private unique PHPWord_Worksheet_BaseDrawing HashTable + * + * @var PHPWord_HashTable + */ + private $_drawingHashTable; + + /** + * Use disk caching where possible? + * + * @var boolean + */ + private $_useDiskCaching = false; + + /** + * Disk caching directory + * + * @var string + */ + private $_diskCachingDirectory; + + /** + * Create a new PHPWord_Writer_ODText + * + * @param PHPWord $pPHPWord + */ + public function __construct(PHPWord $pPHPWord = null) + { + // Assign PHPWord + $this->setPHPWord($pPHPWord); + + // Set up disk caching location + $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(); + + + // Assign parent IWriter + foreach ($this->_writerParts as $writer) { + $writer->setParentWriter($this); + } + + // Set HashTable variables + $this->_drawingHashTable = new PHPWord_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 + 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); + } else if ($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); + } + } + + // 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."); + } + } + + /** + * Get PHPWord object + * + * @return PHPWord + * @throws Exception + */ + public function getPHPWord() + { + if (!is_null($this->_document)) { + return $this->_document; + } else { + throw new Exception("No PHPWord assigned."); + } + } + + /** + * Get PHPWord object + * + * @param PHPWord $pPHPWord PHPWord object + * @throws Exception + * @return PHPWord_Writer_PowerPoint2007 + */ + public function setPHPWord(PHPWord $pPHPWord = null) + { + $this->_document = $pPHPWord; + return $this; + } + + /** + * Get PHPWord_Worksheet_BaseDrawing HashTable + * + * @return PHPWord_HashTable + */ + public function getDrawingHashTable() + { + return $this->_drawingHashTable; + } + + /** + * Get writer part + * + * @param string $pPartName Writer part name + * @return PHPWord_Writer_ODText_WriterPart + */ + 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 PHPWord_Writer_PowerPoint2007 + */ + 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; + } + + /** + * Get disk caching directory + * + * @return string + */ + public function getDiskCachingDirectory() + { + return $this->_diskCachingDirectory; + } } \ No newline at end of file diff --git a/src/PHPWord/Writer/ODText/Content.php b/src/PHPWord/Writer/ODText/Content.php index 25e1d39e89..c5fd42a7ec 100644 --- a/src/PHPWord/Writer/ODText/Content.php +++ b/src/PHPWord/Writer/ODText/Content.php @@ -35,234 +35,234 @@ */ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart { - /** - * Write content file to XML format - * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception - */ - public function writeContent(PHPWord $pPHPWord = null) - { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } + /** + * Write content file to XML format + * + * @param PHPWord $pPHPWord + * @return string XML Output + * @throws Exception + */ + public function writeContent(PHPWord $pPHPWord = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } - // XML header - $objWriter->startDocument('1.0','UTF-8'); + // XML header + $objWriter->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'); - - // We firstly search all fonts used - $_sections = $pPHPWord->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 PHPWord_Section_Text) { - $fStyle = $element->getFontStyle(); - $pStyle = $element->getParagraphStyle(); - - if($fStyle instanceof PHPWord_Style_Font){ - $numFStyles++; - - $arrStyle = array( - 'color'=>$fStyle->getColor(), - 'name' =>$fStyle->getName() - ); - $pPHPWord->addFontStyle('T'.$numFStyles, $arrStyle); - $element->setFontStyle('T'.$numFStyles); - } - elseif($pStyle instanceof PHPWord_Style_Paragraph){ - $numPStyles++; - - $pPHPWord->addParagraphStyle('P'.$numPStyles, array()); - $element->setParagraph('P'.$numPStyles); - } - } - } - } - } - - // office:font-face-decls - $objWriter->startElement('office:font-face-decls'); - $arrFonts = array(); - - $styles = PHPWord_Style::getStyles(); - $numFonts = 0; - if(count($styles) > 0) { - foreach($styles as $styleName => $style) { - // PHPWord_Style_Font - if($style instanceof PHPWord_Style_Font) { - $numFonts++; - $name = $style->getName(); - if(!in_array($name, $arrFonts)){ - $arrFonts[] = $name; + // 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'); - // style:font-face - $objWriter->startElement('style:font-face'); - $objWriter->writeAttribute('style:name', $name); - $objWriter->writeAttribute('svg:font-family', $name); - $objWriter->endElement(); - } - } - } - if(!in_array('Arial', $arrFonts)){ - $objWriter->startElement('style:font-face'); - $objWriter->writeAttribute('style:name', 'Arial'); - $objWriter->writeAttribute('svg:font-family', 'Arial'); - $objWriter->endElement(); - } - } - $objWriter->endElement(); - - $objWriter->startElement('office:automatic-styles'); - $styles = PHPWord_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'); - // 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(); - } - if($style instanceof PHPWord_Style_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'); - // style:paragraph-properties - $objWriter->startElement('style:paragraph-properties'); - $objWriter->writeAttribute('style:page-number', 'auto'); - $objWriter->endElement(); - $objWriter->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'); - // style:paragraph-properties - $objWriter->startElement('style:paragraph-properties'); - $objWriter->writeAttribute('style:page-number', 'auto'); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - $objWriter->endElement(); - - // office:body - $objWriter->startElement('office:body'); - // office:text - $objWriter->startElement('office:text'); - // text:sequence-decls - $objWriter->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(); - // text:sequence-decl - $objWriter->startElement('text:sequence-decl'); - $objWriter->writeAttribute('text:display-outline-level', 0); - $objWriter->writeAttribute('text:name', 'Table'); - $objWriter->endElement(); - // text:sequence-decl - $objWriter->startElement('text:sequence-decl'); - $objWriter->writeAttribute('text:display-outline-level', 0); - $objWriter->writeAttribute('text:name', 'Text'); - $objWriter->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(); - - $_sections = $pPHPWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if($countSections > 0) { - foreach($_sections as $section) { - $pSection++; - - $_elements = $section->getElements(); - - foreach($_elements as $element) { - if($element instanceof PHPWord_Section_Text) { - $this->_writeText($objWriter, $element); - }/* elseif($element instanceof PHPWord_Section_TextRun) { + // We firstly search all fonts used + $_sections = $pPHPWord->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 PHPWord_Section_Text) { + $fStyle = $element->getFontStyle(); + $pStyle = $element->getParagraphStyle(); + + if ($fStyle instanceof PHPWord_Style_Font) { + $numFStyles++; + + $arrStyle = array( + 'color' => $fStyle->getColor(), + 'name' => $fStyle->getName() + ); + $pPHPWord->addFontStyle('T' . $numFStyles, $arrStyle); + $element->setFontStyle('T' . $numFStyles); + } elseif ($pStyle instanceof PHPWord_Style_Paragraph) { + $numPStyles++; + + $pPHPWord->addParagraphStyle('P' . $numPStyles, array()); + $element->setParagraph('P' . $numPStyles); + } + } + } + } + } + + // office:font-face-decls + $objWriter->startElement('office:font-face-decls'); + $arrFonts = array(); + + $styles = PHPWord_Style::getStyles(); + $numFonts = 0; + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + // PHPWord_Style_Font + if ($style instanceof PHPWord_Style_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(); + } + } + } + if (!in_array('Arial', $arrFonts)) { + $objWriter->startElement('style:font-face'); + $objWriter->writeAttribute('style:name', 'Arial'); + $objWriter->writeAttribute('svg:font-family', 'Arial'); + $objWriter->endElement(); + } + } + $objWriter->endElement(); + + $objWriter->startElement('office:automatic-styles'); + $styles = PHPWord_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'); + // 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(); + } + if ($style instanceof PHPWord_Style_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'); + // style:paragraph-properties + $objWriter->startElement('style:paragraph-properties'); + $objWriter->writeAttribute('style:page-number', 'auto'); + $objWriter->endElement(); + $objWriter->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'); + // style:paragraph-properties + $objWriter->startElement('style:paragraph-properties'); + $objWriter->writeAttribute('style:page-number', 'auto'); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + $objWriter->endElement(); + + // office:body + $objWriter->startElement('office:body'); + // office:text + $objWriter->startElement('office:text'); + // text:sequence-decls + $objWriter->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(); + // text:sequence-decl + $objWriter->startElement('text:sequence-decl'); + $objWriter->writeAttribute('text:display-outline-level', 0); + $objWriter->writeAttribute('text:name', 'Table'); + $objWriter->endElement(); + // text:sequence-decl + $objWriter->startElement('text:sequence-decl'); + $objWriter->writeAttribute('text:display-outline-level', 0); + $objWriter->writeAttribute('text:name', 'Text'); + $objWriter->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(); + + $_sections = $pPHPWord->getSections(); + $countSections = count($_sections); + $pSection = 0; + + if ($countSections > 0) { + foreach ($_sections as $section) { + $pSection++; + + $_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); - }/* elseif($element instanceof PHPWord_Section_PageBreak) { + }*/ elseif ($element instanceof PHPWord_Section_TextBreak) { + $this->_writeTextBreak($objWriter); + } /* elseif($element instanceof PHPWord_Section_PageBreak) { $this->_writePageBreak($objWriter); } elseif($element instanceof PHPWord_Section_Table) { $this->_writeTable($objWriter, $element); @@ -276,70 +276,71 @@ public function writeContent(PHPWord $pPHPWord = null) } elseif($element instanceof PHPWord_TOC) { $this->_writeTOC($objWriter); }*/ - else { - print_r($element); - echo '
'; - } - } - - if($pSection == $countSections) { - $this->_writeEndSection($objWriter, $section); - } else { - $this->_writeSection($objWriter, $section); - } - } - } - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); + else { + print_r($element); + echo '
'; + } + } + + if ($pSection == $countSections) { + $this->_writeEndSection($objWriter, $section); + } else { + $this->_writeSection($objWriter, $section); + } + } + } + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) + { + $styleFont = $text->getFontStyle(); + $styleParagraph = $text->getParagraphStyle(); + + $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : 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 { + // text:p + $objWriter->startElement('text:p'); + if (empty($styleFont)) { + if (empty($styleParagraph)) { + $objWriter->writeAttribute('text:style-name', 'P1'); + } else { + $objWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); + } + $objWriter->writeRaw($text->getText()); + } else { + if (empty($styleParagraph)) { + $objWriter->writeAttribute('text:style-name', 'Standard'); + } else { + $objWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); + } + // text:span + $objWriter->startElement('text:span'); + $objWriter->writeAttribute('text:style-name', $styleFont); + $objWriter->writeRaw($text->getText()); + $objWriter->endElement(); + } + $objWriter->endElement(); + } + } + + protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) + { + $objWriter->startElement('text:p'); + $objWriter->writeAttribute('text:style-name', 'Standard'); + $objWriter->endElement(); + } - // Return - return $objWriter->getData(); - } - - protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) { - $styleFont = $text->getFontStyle(); - $styleParagraph = $text->getParagraphStyle(); - - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : 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 { - // text:p - $objWriter->startElement('text:p'); - if(empty($styleFont)){ - if(empty($styleParagraph)){ - $objWriter->writeAttribute('text:style-name', 'P1'); - } - else { - $objWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); - } - $objWriter->writeRaw($text->getText()); - } - else { - if(empty($styleParagraph)){ - $objWriter->writeAttribute('text:style-name', 'Standard'); - } - else { - $objWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); - } - // text:span - $objWriter->startElement('text:span'); - $objWriter->writeAttribute('text:style-name', $styleFont); - $objWriter->writeRaw($text->getText()); - $objWriter->endElement(); - } - $objWriter->endElement(); - } - } - protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) { - $objWriter->startElement('text:p'); - $objWriter->writeAttribute('text:style-name', 'Standard'); - $objWriter->endElement(); - } - private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) { - } + private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) + { + } } diff --git a/src/PHPWord/Writer/ODText/Manifest.php b/src/PHPWord/Writer/ODText/Manifest.php index 1908bbcb3f..d2b783f71d 100644 --- a/src/PHPWord/Writer/ODText/Manifest.php +++ b/src/PHPWord/Writer/ODText/Manifest.php @@ -35,97 +35,97 @@ */ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart { - /** - * Write Manifest file to XML format - * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception - */ - public function writeManifest(PHPWord $pPHPWord = null) - { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } + /** + * Write Manifest file to XML format + * + * @param PHPWord $pPHPWord + * @return string XML Output + * @throws Exception + */ + public function writeManifest(PHPWord $pPHPWord = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } - // XML header - $objWriter->startDocument('1.0','UTF-8'); + // XML header + $objWriter->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'); - - // 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(); - // manifest:file-entry - $objWriter->startElement('manifest:file-entry'); - $objWriter->writeAttribute('manifest:media-type', 'text/xml'); - $objWriter->writeAttribute('manifest:full-path', 'content.xml'); - $objWriter->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(); - // manifest:file-entry - $objWriter->startElement('manifest:file-entry'); - $objWriter->writeAttribute('manifest:media-type', 'text/xml'); - $objWriter->writeAttribute('manifest:full-path', 'styles.xml'); - $objWriter->endElement(); - - 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() ); - - $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(); - } else if ($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(); - - $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(); - } - } - - $objWriter->endElement(); + // 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'); - // Return - return $objWriter->getData(); - } + // 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(); + // manifest:file-entry + $objWriter->startElement('manifest:file-entry'); + $objWriter->writeAttribute('manifest:media-type', 'text/xml'); + $objWriter->writeAttribute('manifest:full-path', 'content.xml'); + $objWriter->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(); + // manifest:file-entry + $objWriter->startElement('manifest:file-entry'); + $objWriter->writeAttribute('manifest:media-type', 'text/xml'); + $objWriter->writeAttribute('manifest:full-path', 'styles.xml'); + $objWriter->endElement(); - - /** - * Get image mime type - * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception - */ - private function _getImageMimeType($pFile = '') - { - if (PHPWord_Shared_File::file_exists($pFile)) { - $image = getimagesize($pFile); - return image_type_to_mime_type($image[2]); - } else { - throw new Exception("File $pFile does not exist"); - } - } + 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()); + + $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(); + } else if ($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(); + + $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(); + } + } + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + + /** + * Get image mime type + * + * @param string $pFile Filename + * @return string Mime Type + * @throws Exception + */ + private function _getImageMimeType($pFile = '') + { + if (PHPWord_Shared_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/PHPWord/Writer/ODText/Meta.php b/src/PHPWord/Writer/ODText/Meta.php index 2f8b42218a..e4778a23db 100644 --- a/src/PHPWord/Writer/ODText/Meta.php +++ b/src/PHPWord/Writer/ODText/Meta.php @@ -35,64 +35,65 @@ */ class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart { - /** - * Write Meta file to XML format - * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception - */ - public function writeMeta(PHPWord $pPHPWord = null) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } + /** + * Write Meta file to XML format + * + * @param PHPWord $pPHPWord + * @return string XML Output + * @throws Exception + */ + public function writeMeta(PHPWord $pPHPWord = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } - // XML header - $objWriter->startDocument('1.0','UTF-8'); + // XML header + $objWriter->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'); - - // office:meta - $objWriter->startElement('office:meta'); - - // dc:creator - $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy()); - // dc:date - $objWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000' ,$pPHPWord->getProperties()->getModified())); - // dc:description - $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); - // dc:subject - $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); - // dc:title - $objWriter->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())); - // meta:initial-creator - $objWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator()); - // meta:keyword - $objWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords()); - - // @todo : Where these properties are written ? - // $pPHPWord->getProperties()->getCategory() - // $pPHPWord->getProperties()->getCompany() - - $objWriter->endElement(); - - $objWriter->endElement(); + // 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'); - // Return - return $objWriter->getData(); - } + // office:meta + $objWriter->startElement('office:meta'); + + // dc:creator + $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy()); + // dc:date + $objWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getModified())); + // dc:description + $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); + // dc:subject + $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); + // dc:title + $objWriter->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())); + // meta:initial-creator + $objWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator()); + // meta:keyword + $objWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords()); + + // @todo : Where these properties are written ? + // $pPHPWord->getProperties()->getCategory() + // $pPHPWord->getProperties()->getCompany() + + $objWriter->endElement(); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } } diff --git a/src/PHPWord/Writer/ODText/Mimetype.php b/src/PHPWord/Writer/ODText/Mimetype.php index cf301cf300..9190ca842c 100644 --- a/src/PHPWord/Writer/ODText/Mimetype.php +++ b/src/PHPWord/Writer/ODText/Mimetype.php @@ -35,17 +35,17 @@ */ class PHPWord_Writer_ODText_Mimetype extends PHPWord_Writer_ODText_WriterPart { - /** - * Write Mimetype to Text format - * - * @param PHPWord $pPHPWord - * @return string Text Output - * @throws Exception - */ - public function writeMimetype(PHPWord $pPHPWord = null) - { - - return 'application/vnd.oasis.opendocument.text'; - } + /** + * Write Mimetype to Text format + * + * @param PHPWord $pPHPWord + * @return string Text Output + * @throws Exception + */ + public function writeMimetype(PHPWord $pPHPWord = null) + { + + return 'application/vnd.oasis.opendocument.text'; + } } diff --git a/src/PHPWord/Writer/ODText/Styles.php b/src/PHPWord/Writer/ODText/Styles.php index b08f8aa427..a4d51a25fd 100644 --- a/src/PHPWord/Writer/ODText/Styles.php +++ b/src/PHPWord/Writer/ODText/Styles.php @@ -35,240 +35,239 @@ */ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart { - /** - * Write Styles file to XML format - * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception - */ - public function writeStyles(PHPWord $pPHPWord = null) - { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } + /** + * Write Styles file to XML format + * + * @param PHPWord $pPHPWord + * @return string XML Output + * @throws Exception + */ + public function writeStyles(PHPWord $pPHPWord = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } - // XML header - $objWriter->startDocument('1.0','UTF-8'); + // XML header + $objWriter->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'); - - - // office:font-face-decls - $objWriter->startElement('office:font-face-decls'); - $arrFonts = array(); - $styles = PHPWord_Style::getStyles(); - $numFonts = 0; - if(count($styles) > 0) { - foreach($styles as $styleName => $style) { - // PHPWord_Style_Font - if($style instanceof PHPWord_Style_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(); - } - } - } - } - if(!in_array('Arial', $arrFonts)){ - $objWriter->startElement('style:font-face'); - $objWriter->writeAttribute('style:name', 'Arial'); - $objWriter->writeAttribute('svg:font-family', 'Arial'); - $objWriter->endElement(); - } - $objWriter->endElement(); - - // office:styles - $objWriter->startElement('office:styles'); + // 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'); - // style:default-style - $objWriter->startElement('style:default-style'); - $objWriter->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(); - - // style:text-properties - $objWriter->startElement('style:text-properties'); - $objWriter->writeAttribute('style:use-window-font-color', 'true'); - $objWriter->writeAttribute('style:font-name', 'Arial'); - $objWriter->writeAttribute('fo:font-size', '10pt'); - $objWriter->writeAttribute('fo:language', 'fr'); - $objWriter->writeAttribute('fo:country', 'FR'); - $objWriter->writeAttribute('style:letter-kerning', 'true'); - $objWriter->writeAttribute('style:font-name-asian', 'Arial2'); - $objWriter->writeAttribute('style:font-size-asian', '10pt'); - $objWriter->writeAttribute('style:language-asian', 'zh'); - $objWriter->writeAttribute('style:country-asian', 'CN'); - $objWriter->writeAttribute('style:font-name-complex', 'Arial2'); - $objWriter->writeAttribute('style:font-size-complex', '10pt'); - $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(); - - $objWriter->endElement(); - - // Write Style Definitions - $styles = PHPWord_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) { - // style:style - $objWriter->startElement('style:style'); - $objWriter->writeAttribute('style:name', $styleName); - $objWriter->writeAttribute('style:family', 'text'); - - // style:text-properties - $objWriter->startElement('style:text-properties'); - $objWriter->writeAttribute('fo:font-size', ($style->getSize() / 2).'pt'); - $objWriter->writeAttribute('style:font-size-asian', ($style->getSize() / 2).'pt'); - $objWriter->writeAttribute('style:font-size-complex', ($style->getSize() / 2).'pt'); - if($style->getItalic()) { - $objWriter->writeAttribute('fo:font-style', 'italic'); - $objWriter->writeAttribute('style:font-style-asian', 'italic'); - $objWriter->writeAttribute('style:font-style-complex', 'italic'); - } - if($style->getBold()) { - $objWriter->writeAttribute('fo:font-weight', 'bold'); - $objWriter->writeAttribute('style:font-weight-asian', 'bold'); - } - $objWriter->endElement(); - $objWriter->endElement(); - } - // PHPWord_Style_Paragraph - elseif($style instanceof PHPWord_Style_Paragraph) { - // style:style - $objWriter->startElement('style:style'); - $objWriter->writeAttribute('style:name', $styleName); - $objWriter->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(); - - $objWriter->endElement(); - - } - // PHPWord_Style_TableFull - elseif($style instanceof PHPWord_Style_TableFull) { - } - } - } - } - $objWriter->endElement(); - - // office:automatic-styles - $objWriter->startElement('office:automatic-styles'); - // style:page-layout - $objWriter->startElement('style:page-layout'); - $objWriter->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'); - //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(); - // style:header-style - $objWriter->startElement('style:header-style'); - $objWriter->endElement(); - // style:footer-style - $objWriter->startElement('style:footer-style'); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - - // office:master-styles - $objWriter->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(); - - $objWriter->endElement(); + // office:font-face-decls + $objWriter->startElement('office:font-face-decls'); + $arrFonts = array(); + $styles = PHPWord_Style::getStyles(); + $numFonts = 0; + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + // PHPWord_Style_Font + if ($style instanceof PHPWord_Style_Font) { + $numFonts++; + $name = $style->getName(); + if (!in_array($name, $arrFonts)) { + $arrFonts[] = $name; - // Return - return $objWriter->getData(); - } + // style:font-face + $objWriter->startElement('style:font-face'); + $objWriter->writeAttribute('style:name', $name); + $objWriter->writeAttribute('svg:font-family', $name); + $objWriter->endElement(); + } + } + } + } + if (!in_array('Arial', $arrFonts)) { + $objWriter->startElement('style:font-face'); + $objWriter->writeAttribute('style:name', 'Arial'); + $objWriter->writeAttribute('svg:font-family', 'Arial'); + $objWriter->endElement(); + } + $objWriter->endElement(); + + // office:styles + $objWriter->startElement('office:styles'); + + // style:default-style + $objWriter->startElement('style:default-style'); + $objWriter->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(); + + // style:text-properties + $objWriter->startElement('style:text-properties'); + $objWriter->writeAttribute('style:use-window-font-color', 'true'); + $objWriter->writeAttribute('style:font-name', 'Arial'); + $objWriter->writeAttribute('fo:font-size', '10pt'); + $objWriter->writeAttribute('fo:language', 'fr'); + $objWriter->writeAttribute('fo:country', 'FR'); + $objWriter->writeAttribute('style:letter-kerning', 'true'); + $objWriter->writeAttribute('style:font-name-asian', 'Arial2'); + $objWriter->writeAttribute('style:font-size-asian', '10pt'); + $objWriter->writeAttribute('style:language-asian', 'zh'); + $objWriter->writeAttribute('style:country-asian', 'CN'); + $objWriter->writeAttribute('style:font-name-complex', 'Arial2'); + $objWriter->writeAttribute('style:font-size-complex', '10pt'); + $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(); + + $objWriter->endElement(); + + // Write Style Definitions + $styles = PHPWord_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) { + // style:style + $objWriter->startElement('style:style'); + $objWriter->writeAttribute('style:name', $styleName); + $objWriter->writeAttribute('style:family', 'text'); + + // style:text-properties + $objWriter->startElement('style:text-properties'); + $objWriter->writeAttribute('fo:font-size', ($style->getSize() / 2) . 'pt'); + $objWriter->writeAttribute('style:font-size-asian', ($style->getSize() / 2) . 'pt'); + $objWriter->writeAttribute('style:font-size-complex', ($style->getSize() / 2) . 'pt'); + if ($style->getItalic()) { + $objWriter->writeAttribute('fo:font-style', 'italic'); + $objWriter->writeAttribute('style:font-style-asian', 'italic'); + $objWriter->writeAttribute('style:font-style-complex', 'italic'); + } + if ($style->getBold()) { + $objWriter->writeAttribute('fo:font-weight', 'bold'); + $objWriter->writeAttribute('style:font-weight-asian', 'bold'); + } + $objWriter->endElement(); + $objWriter->endElement(); + } // PHPWord_Style_Paragraph + elseif ($style instanceof PHPWord_Style_Paragraph) { + // style:style + $objWriter->startElement('style:style'); + $objWriter->writeAttribute('style:name', $styleName); + $objWriter->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(); + + $objWriter->endElement(); + + } // PHPWord_Style_TableFull + elseif ($style instanceof PHPWord_Style_TableFull) { + } + } + } + } + $objWriter->endElement(); + + // office:automatic-styles + $objWriter->startElement('office:automatic-styles'); + // style:page-layout + $objWriter->startElement('style:page-layout'); + $objWriter->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'); + //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(); + // style:header-style + $objWriter->startElement('style:header-style'); + $objWriter->endElement(); + // style:footer-style + $objWriter->startElement('style:footer-style'); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + + // office:master-styles + $objWriter->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(); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } } diff --git a/src/PHPWord/Writer/ODText/WriterPart.php b/src/PHPWord/Writer/ODText/WriterPart.php index c307f3d3c5..6a04f2e102 100644 --- a/src/PHPWord/Writer/ODText/WriterPart.php +++ b/src/PHPWord/Writer/ODText/WriterPart.php @@ -35,34 +35,36 @@ */ abstract class PHPWord_Writer_ODText_WriterPart { - /** - * Parent IWriter object - * - * @var PHPWord_Writer_IWriter - */ - private $_parentWriter; + /** + * Parent IWriter object + * + * @var PHPWord_Writer_IWriter + */ + private $_parentWriter; - /** - * Set parent IWriter object - * - * @param PHPWord_Writer_IWriter $pWriter - * @throws Exception - */ - public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) { - $this->_parentWriter = $pWriter; - } + /** + * Set parent IWriter object + * + * @param PHPWord_Writer_IWriter $pWriter + * @throws Exception + */ + public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) + { + $this->_parentWriter = $pWriter; + } - /** - * Get parent IWriter object - * - * @return PHPWord_Writer_IWriter - * @throws Exception - */ - public function getParentWriter() { - if (!is_null($this->_parentWriter)) { - return $this->_parentWriter; - } else { - throw new Exception("No parent PHPWord_Writer_IWriter assigned."); - } - } + /** + * Get parent IWriter object + * + * @return PHPWord_Writer_IWriter + * @throws Exception + */ + public function getParentWriter() + { + if (!is_null($this->_parentWriter)) { + return $this->_parentWriter; + } else { + throw new Exception("No parent PHPWord_Writer_IWriter assigned."); + } + } } diff --git a/src/PHPWord/Writer/RTF.php b/src/PHPWord/Writer/RTF.php index 2203769c13..361ac5c149 100644 --- a/src/PHPWord/Writer/RTF.php +++ b/src/PHPWord/Writer/RTF.php @@ -27,284 +27,294 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter { - /** - * Private PHPWord - * - * @var PHPWord - */ - private $_document; - - /** - * Private unique PHPWord_Worksheet_BaseDrawing HashTable - * - * @var PHPWord_HashTable - */ - private $_drawingHashTable; - - private $_colorTable; - private $_fontTable; - private $_lastParagraphStyle; - - /** - * Create a new PHPWord_Writer_ODText - * - * @param PHPWord $pPHPWord - */ - public function __construct(PHPWord $pPHPWord = null) - { - // Assign PHPWord - $this->setPHPWord($pPHPWord); - - // Set HashTable variables - $this->_drawingHashTable = new PHPWord_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."); - } - } - - /** - * Get PHPWord object - * - * @return PHPWord - * @throws Exception - */ - public function getPHPWord() { - if (!is_null($this->_document)) { - return $this->_document; - } else { - throw new Exception("No PHPWord assigned."); - } - } - - /** - * Get PHPWord object - * - * @param PHPWord $pPHPWord PHPWord object - * @throws Exception - * @return PHPWord_Writer_PowerPoint2007 - */ - public function setPHPWord(PHPWord $pPHPWord = null) { - $this->_document = $pPHPWord; - return $this; - } - - /** - * Get PHPWord_Worksheet_BaseDrawing HashTable - * - * @return 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'; - // 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 = PHPWord_Shared_Drawing::htmlToRGB($color); - $sRTFContent .= ';\red'.$arrColor[0].'\green'.$arrColor[1].'\blue'.$arrColor[2].''; - } - $sRTFContent .= ';}'.PHP_EOL; - // Set the generator - $sRTFContent .= '{\*\generator PHPWord;}'; - // 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 .= '\fs20'; - // Body - $sRTFContent .= $this->_getDataContent(); - - - $sRTFContent .= '}'; - - return $sRTFContent; - } - private function _getDataFont(){ - $pPHPWord = $this->_document; - - $arrFonts = array(); - // Default font : Arial - $arrFonts[] = 'Arial'; - // PHPWord object : $this->_document - - // Browse styles - $styles = PHPWord_Style::getStyles(); - $numPStyles = 0; - if(count($styles) > 0) { - foreach($styles as $styleName => $style) { - // PHPWord_Style_Font - if($style instanceof PHPWord_Style_Font) { - if(in_array($style->getName(), $arrFonts) == FALSE){ - $arrFonts[] = $style->getName(); - } - } - } - } - - // Search all fonts used - $_sections = $pPHPWord->getSections(); - $countSections = count($_sections); - if($countSections > 0) { - $pSection = 0; - - foreach($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - - foreach($_elements as $element) { - if($element instanceof PHPWord_Section_Text) { - $fStyle = $element->getFontStyle(); - - if($fStyle instanceof PHPWord_Style_Font){ - if(in_array($fStyle->getName(), $arrFonts) == FALSE){ - $arrFonts[] = $fStyle->getName(); - } - } - } - } - } - } - - return $arrFonts; - } - private function _getDataColor(){ - $pPHPWord = $this->_document; - - $arrColors = array(); - // PHPWord object : $this->_document - - // Browse styles - $styles = PHPWord_Style::getStyles(); - $numPStyles = 0; - if(count($styles) > 0) { - foreach($styles as $styleName => $style) { - // PHPWord_Style_Font - if($style instanceof PHPWord_Style_Font) { - $color = $style->getColor(); - $fgcolor = $style->getFgColor(); - if(in_array($color, $arrColors) == FALSE && $color != '000000' && !empty($color)){ - $arrColors[] = $color; - } - if(in_array($fgcolor, $arrColors) == FALSE && $fgcolor != '000000' && !empty($fgcolor)){ - $arrColors[] = $fgcolor; - } - } - } - } - - // Search all fonts used - $_sections = $pPHPWord->getSections(); - $countSections = count($_sections); - if($countSections > 0) { - $pSection = 0; - - foreach($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - - foreach($_elements as $element) { - if($element instanceof PHPWord_Section_Text) { - $fStyle = $element->getFontStyle(); - - if($fStyle instanceof PHPWord_Style_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(){ - $pPHPWord = $this->_document; - $sRTFBody = ''; - - $_sections = $pPHPWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if($countSections > 0) { - foreach($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - foreach($_elements as $element) { - if($element instanceof PHPWord_Section_Text) { - $sRTFBody .= $this->_getDataContent_writeText($element); - }/* elseif($element instanceof PHPWord_Section_TextRun) { + /** + * Private PHPWord + * + * @var PHPWord + */ + private $_document; + + /** + * Private unique PHPWord_Worksheet_BaseDrawing HashTable + * + * @var PHPWord_HashTable + */ + private $_drawingHashTable; + + private $_colorTable; + private $_fontTable; + private $_lastParagraphStyle; + + /** + * Create a new PHPWord_Writer_ODText + * + * @param PHPWord $pPHPWord + */ + public function __construct(PHPWord $pPHPWord = null) + { + // Assign PHPWord + $this->setPHPWord($pPHPWord); + + // Set HashTable variables + $this->_drawingHashTable = new PHPWord_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."); + } + } + + /** + * Get PHPWord object + * + * @return PHPWord + * @throws Exception + */ + public function getPHPWord() + { + if (!is_null($this->_document)) { + return $this->_document; + } else { + throw new Exception("No PHPWord assigned."); + } + } + + /** + * Get PHPWord object + * + * @param PHPWord $pPHPWord PHPWord object + * @throws Exception + * @return PHPWord_Writer_PowerPoint2007 + */ + public function setPHPWord(PHPWord $pPHPWord = null) + { + $this->_document = $pPHPWord; + return $this; + } + + /** + * Get PHPWord_Worksheet_BaseDrawing HashTable + * + * @return 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'; + // 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 = PHPWord_Shared_Drawing::htmlToRGB($color); + $sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; + } + $sRTFContent .= ';}' . PHP_EOL; + // Set the generator + $sRTFContent .= '{\*\generator PHPWord;}'; + // 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 .= '\fs20'; + // Body + $sRTFContent .= $this->_getDataContent(); + + + $sRTFContent .= '}'; + + return $sRTFContent; + } + + private function _getDataFont() + { + $pPHPWord = $this->_document; + + $arrFonts = array(); + // Default font : Arial + $arrFonts[] = 'Arial'; + // PHPWord object : $this->_document + + // Browse styles + $styles = PHPWord_Style::getStyles(); + $numPStyles = 0; + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + // PHPWord_Style_Font + if ($style instanceof PHPWord_Style_Font) { + if (in_array($style->getName(), $arrFonts) == FALSE) { + $arrFonts[] = $style->getName(); + } + } + } + } + + // Search all fonts used + $_sections = $pPHPWord->getSections(); + $countSections = count($_sections); + if ($countSections > 0) { + $pSection = 0; + + foreach ($_sections as $section) { + $pSection++; + $_elements = $section->getElements(); + + foreach ($_elements as $element) { + if ($element instanceof PHPWord_Section_Text) { + $fStyle = $element->getFontStyle(); + + if ($fStyle instanceof PHPWord_Style_Font) { + if (in_array($fStyle->getName(), $arrFonts) == FALSE) { + $arrFonts[] = $fStyle->getName(); + } + } + } + } + } + } + + return $arrFonts; + } + + private function _getDataColor() + { + $pPHPWord = $this->_document; + + $arrColors = array(); + // PHPWord object : $this->_document + + // Browse styles + $styles = PHPWord_Style::getStyles(); + $numPStyles = 0; + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + // PHPWord_Style_Font + if ($style instanceof PHPWord_Style_Font) { + $color = $style->getColor(); + $fgcolor = $style->getFgColor(); + if (in_array($color, $arrColors) == FALSE && $color != '000000' && !empty($color)) { + $arrColors[] = $color; + } + if (in_array($fgcolor, $arrColors) == FALSE && $fgcolor != '000000' && !empty($fgcolor)) { + $arrColors[] = $fgcolor; + } + } + } + } + + // Search all fonts used + $_sections = $pPHPWord->getSections(); + $countSections = count($_sections); + if ($countSections > 0) { + $pSection = 0; + + foreach ($_sections as $section) { + $pSection++; + $_elements = $section->getElements(); + + foreach ($_elements as $element) { + if ($element instanceof PHPWord_Section_Text) { + $fStyle = $element->getFontStyle(); + + if ($fStyle instanceof PHPWord_Style_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() + { + $pPHPWord = $this->_document; + $sRTFBody = ''; + + $_sections = $pPHPWord->getSections(); + $countSections = count($_sections); + $pSection = 0; + + if ($countSections > 0) { + foreach ($_sections as $section) { + $pSection++; + $_elements = $section->getElements(); + foreach ($_elements as $element) { + if ($element instanceof PHPWord_Section_Text) { + $sRTFBody .= $this->_getDataContent_writeText($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) { - $sRTFBody .= $this->_getDataContent_writeTextBreak(); - }/* elseif($element instanceof PHPWord_Section_PageBreak) { + }*/ + elseif ($element instanceof PHPWord_Section_TextBreak) { + $sRTFBody .= $this->_getDataContent_writeTextBreak(); + } /* elseif($element instanceof PHPWord_Section_PageBreak) { $this->_writePageBreak($objWriter); } elseif($element instanceof PHPWord_Section_Table) { $this->_writeTable($objWriter, $element); @@ -318,106 +328,108 @@ private function _getDataContent(){ } elseif($element instanceof PHPWord_TOC) { $this->_writeTOC($objWriter); }*/ - else { - print_r($element); - echo '
'; - } - } - } - } - return $sRTFBody; - } - private function _getDataContent_writeText(PHPWord_Section_Text $text){ - $sRTFText = ''; - - $styleFont = $text->getFontStyle(); - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - if(!$SfIsObject) { - $styleFont = PHPWord_Style::getStyle($styleFont); - } - - $styleParagraph = $text->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - if(!$SpIsObject) { - $styleParagraph = PHPWord_Style::getStyle($styleParagraph); - } - - if($styleParagraph){ - 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){ - 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(); - } - } - if($this->_lastParagraphStyle != '' || $styleFont){ - $sRTFText .= ' '; - } - $sRTFText .= $text->getText(); - - if($styleFont){ - $sRTFText .= '\cf0'; - $sRTFText .= '\f0'; - - if($styleFont->getBold()){ - $sRTFText .= '\b0'; - } - if($styleFont->getItalic()){ - $sRTFText .= '\i0'; - } - if($styleFont->getSize()){ - $sRTFText .= '\fs20'; - } - } - - $sRTFText .= '\par'.PHP_EOL; - return $sRTFText; - } - private function _getDataContent_writeTextBreak(){ - $this->_lastParagraphStyle = ''; - - return '\par'.PHP_EOL; - } + else { + print_r($element); + echo '
'; + } + } + } + } + return $sRTFBody; + } + + private function _getDataContent_writeText(PHPWord_Section_Text $text) + { + $sRTFText = ''; + + $styleFont = $text->getFontStyle(); + $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + if (!$SfIsObject) { + $styleFont = PHPWord_Style::getStyle($styleFont); + } + + $styleParagraph = $text->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + if (!$SpIsObject) { + $styleParagraph = PHPWord_Style::getStyle($styleParagraph); + } + + if ($styleParagraph) { + 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) { + 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(); + } + } + if ($this->_lastParagraphStyle != '' || $styleFont) { + $sRTFText .= ' '; + } + $sRTFText .= $text->getText(); + + if ($styleFont) { + $sRTFText .= '\cf0'; + $sRTFText .= '\f0'; + + if ($styleFont->getBold()) { + $sRTFText .= '\b0'; + } + if ($styleFont->getItalic()) { + $sRTFText .= '\i0'; + } + if ($styleFont->getSize()) { + $sRTFText .= '\fs20'; + } + } + + $sRTFText .= '\par' . PHP_EOL; + return $sRTFText; + } + + private function _getDataContent_writeTextBreak() + { + $this->_lastParagraphStyle = ''; + + return '\par' . PHP_EOL; + } } \ No newline at end of file diff --git a/src/PHPWord/Writer/Word2007.php b/src/PHPWord/Writer/Word2007.php index 0ad491dde2..a6551f6fa8 100644 --- a/src/PHPWord/Writer/Word2007.php +++ b/src/PHPWord/Writer/Word2007.php @@ -26,216 +26,222 @@ */ -class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter { - - private $_document; - private $_writerParts; - private $_diskCachingDirectory; - private $_useDiskCaching = false; - private $_imageTypes = array(); - private $_objectTypes = array(); - - public function __construct(PHPWord $PHPWord = null) { - $this->_document = $PHPWord; - - $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(); - - 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 = PHPWord_Media::getSectionMediaElements(); - foreach($_secElements as $element) { // loop through section media elements - if($element['type'] != 'hyperlink') { - $this->_addFileToPackage($objZip, $element); - } - $sectionElements[] = $element; - } - - $_hdrElements = PHPWord_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 = PHPWord_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); - } - } - } - - - - $_cHdrs = 0; - $_cFtrs = 0; - $rID = PHPWord_Media::countSectionMediaElements() + 6; - $_sections = $this->_document->getSections(); - - foreach($_sections as $section) { - $_header = $section->getHeader(); - if(!is_null($_header)) { - $_cHdrs++; - $_header->setRelationId(++$rID); - $_headerCount = $_header->getHeaderCount(); - $_headerFile = 'header'.$_headerCount.'.xml'; - $sectionElements[] = array('target'=>$_headerFile, 'type'=>'header', 'rID'=>$rID); - $objZip->addFromString('word/'.$_headerFile, $this->getWriterPart('header')->writeHeader($_header)); - } - - $_footer = $section->getFooter(); - if(!is_null($_footer)) { - $_cFtrs++; - $_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)); - } - } - - // build docx file - // Write dynamic files +class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter +{ + + private $_document; + private $_writerParts; + private $_diskCachingDirectory; + private $_useDiskCaching = false; + private $_imageTypes = array(); + private $_objectTypes = array(); + + public function __construct(PHPWord $PHPWord = null) + { + $this->_document = $PHPWord; + + $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(); + + 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 = PHPWord_Media::getSectionMediaElements(); + foreach ($_secElements as $element) { // loop through section media elements + if ($element['type'] != 'hyperlink') { + $this->_addFileToPackage($objZip, $element); + } + $sectionElements[] = $element; + } + + $_hdrElements = PHPWord_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 = PHPWord_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); + } + } + } + + + $_cHdrs = 0; + $_cFtrs = 0; + $rID = PHPWord_Media::countSectionMediaElements() + 6; + $_sections = $this->_document->getSections(); + + foreach ($_sections as $section) { + $_header = $section->getHeader(); + if (!is_null($_header)) { + $_cHdrs++; + $_header->setRelationId(++$rID); + $_headerCount = $_header->getHeaderCount(); + $_headerFile = 'header' . $_headerCount . '.xml'; + $sectionElements[] = array('target' => $_headerFile, 'type' => 'header', 'rID' => $rID); + $objZip->addFromString('word/' . $_headerFile, $this->getWriterPart('header')->writeHeader($_header)); + } + + $_footer = $section->getFooter(); + if (!is_null($_footer)) { + $_cFtrs++; + $_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)); + } + } + + // build docx file + // Write dynamic files $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('contenttypes')->writeContentTypes($this->_imageTypes, $this->_objectTypes, $_cHdrs, $_cFtrs)); - $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)); - + $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."); - } - } - - private function _chkContentTypes($src) { - $srcInfo = pathinfo($src); - $extension = strtolower($srcInfo['extension']); - if(substr($extension, 0, 3) == 'php') { - $extension = 'php'; - } - $_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff', 'php'); - - if(in_array($extension, $_supportedImageTypes)) { - $imagedata = getimagesize($src); - $imagetype = image_type_to_mime_type($imagedata[2]); - $imageext = image_type_to_extension($imagedata[2]); - $imageext = str_replace('.', '', $imageext); - if($imageext == 'jpeg') $imageext = 'jpg'; - - if(!in_array($imagetype, $this->_imageTypes)) { - $this->_imageTypes[$imageext] = $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->_chkContentTypes($element['source']); - } else { - $objZip->addFile($element['source'], 'word/'.$element['target']); - $this->_chkContentTypes($element['source']); - } - } + $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."); + } + } + + private function _chkContentTypes($src) + { + $srcInfo = pathinfo($src); + $extension = strtolower($srcInfo['extension']); + if (substr($extension, 0, 3) == 'php') { + $extension = 'php'; + } + $_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff', 'php'); + + if (in_array($extension, $_supportedImageTypes)) { + $imagedata = getimagesize($src); + $imagetype = image_type_to_mime_type($imagedata[2]); + $imageext = image_type_to_extension($imagedata[2]); + $imageext = str_replace('.', '', $imageext); + if ($imageext == 'jpeg') $imageext = 'jpg'; + + if (!in_array($imagetype, $this->_imageTypes)) { + $this->_imageTypes[$imageext] = $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->_chkContentTypes($element['source']); + } else { + $objZip->addFile($element['source'], 'word/' . $element['target']); + $this->_chkContentTypes($element['source']); + } + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Writer/Word2007/Base.php b/src/PHPWord/Writer/Word2007/Base.php index c03342eac1..b55dcb2c69 100644 --- a/src/PHPWord/Writer/Word2007/Base.php +++ b/src/PHPWord/Writer/Word2007/Base.php @@ -26,689 +26,711 @@ */ -class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart { - - protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) { - $styleFont = $text->getFontStyle(); - - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - - if(!$withoutP) { - $objWriter->startElement('w:p'); - - $styleParagraph = $text->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - $strText = htmlspecialchars($text->getText()); - $strText = PHPWord_Shared_String::ControlCharacterPHP2OOXML($strText); - - $objWriter->startElement('w:r'); - - if($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); - } elseif(!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:t'); - $objWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text - $objWriter->writeRaw($strText); - $objWriter->endElement(); - - $objWriter->endElement(); // w:r - - if(!$withoutP) { - $objWriter->endElement(); // w:p - } - } - - protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) { - $elements = $textrun->getElements(); - $styleParagraph = $textrun->getParagraphStyle(); - - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - $objWriter->startElement('w:p'); - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->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); - } - } - } - - $objWriter->endElement(); - } - - protected function _writeParagraphStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Paragraph $style, $withoutPPR = false) { - $align = $style->getAlign(); - $spaceBefore = $style->getSpaceBefore(); - $spaceAfter = $style->getSpaceAfter(); - $spacing = $style->getSpacing(); - $indent = $style->getIndent(); - - - if(!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indent)) { - - if(!$withoutPPR) { +class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart +{ + + protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) + { + $styleFont = $text->getFontStyle(); + + $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + + if (!$withoutP) { + $objWriter->startElement('w:p'); + + $styleParagraph = $text->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + $strText = htmlspecialchars($text->getText()); + $strText = PHPWord_Shared_String::ControlCharacterPHP2OOXML($strText); + + $objWriter->startElement('w:r'); + + if ($SfIsObject) { + $this->_writeTextStyle($objWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $objWriter->startElement('w:rPr'); + $objWriter->startElement('w:rStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:t'); + $objWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text + $objWriter->writeRaw($strText); + $objWriter->endElement(); + + $objWriter->endElement(); // w:r + + if (!$withoutP) { + $objWriter->endElement(); // w:p + } + } + + protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) + { + $elements = $textrun->getElements(); + $styleParagraph = $textrun->getParagraphStyle(); + + $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + + $objWriter->startElement('w:p'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + $objWriter->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); + } + } + } + + $objWriter->endElement(); + } + + protected function _writeParagraphStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Paragraph $style, $withoutPPR = false) + { + $align = $style->getAlign(); + $spaceBefore = $style->getSpaceBefore(); + $spaceAfter = $style->getSpaceAfter(); + $spacing = $style->getSpacing(); + $indent = $style->getIndent(); + + + if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indent)) { + + if (!$withoutPPR) { + $objWriter->startElement('w:pPr'); + } + + if (!is_null($align)) { + $objWriter->startElement('w:jc'); + $objWriter->writeAttribute('w:val', $align); + $objWriter->endElement(); + } + + if (!is_null($indent)) { + $objWriter->startElement('w:ind'); + $objWriter->writeAttribute('w:firstLine', 0); + $objWriter->writeAttribute('w:left', $indent); + $objWriter->endElement(); + } + + if (!is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($spacing)) { + + $objWriter->startElement('w:spacing'); + + if (!is_null($spaceBefore)) { + $objWriter->writeAttribute('w:before', $spaceBefore); + } + if (!is_null($spaceAfter)) { + $objWriter->writeAttribute('w:after', $spaceAfter); + } + if (!is_null($spacing)) { + $objWriter->writeAttribute('w:line', $spacing); + $objWriter->writeAttribute('w:lineRule', 'auto'); + } + + $objWriter->endElement(); + } + + if (!$withoutPPR) { + $objWriter->endElement(); // w:pPr + } + } + } + + protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) + { + $rID = $link->getRelationId(); + $linkName = $link->getLinkName(); + if (is_null($linkName)) { + $linkName = $link->getLinkSrc(); + } + + $styleFont = $link->getFontStyle(); + $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + + if (!$withoutP) { + $objWriter->startElement('w:p'); + + $styleParagraph = $link->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + $objWriter->startElement('w:hyperlink'); + $objWriter->writeAttribute('r:id', 'rId' . $rID); + $objWriter->writeAttribute('w:history', '1'); + + $objWriter->startElement('w:r'); + if ($SfIsObject) { + $this->_writeTextStyle($objWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $objWriter->startElement('w:rPr'); + $objWriter->startElement('w:rStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->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(); + + $objWriter->endElement(); + + if (!$withoutP) { + $objWriter->endElement(); // w:p + } + } + + protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) + { + $styleFont = $textrun->getFontStyle(); + $styleParagraph = $textrun->getParagraphStyle(); + + $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + + $arrText = $textrun->getText(); + + $objWriter->startElement('w:p'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + $objWriter->endElement(); + } + + foreach ($arrText as $text) { + + 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(); + + $objWriter->startElement('w:r'); + + if ($SfIsObject) { + $this->_writeTextStyle($objWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $objWriter->startElement('w:rPr'); + $objWriter->startElement('w:rStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->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(); + } else { + $text = htmlspecialchars($text); + $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); + + $objWriter->startElement('w:r'); + + if ($SfIsObject) { + $this->_writeTextStyle($objWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $objWriter->startElement('w:rPr'); + $objWriter->startElement('w:rStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:t'); + $objWriter->writeAttribute('xml:space', 'preserve'); + $objWriter->writeRaw($text); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + $objWriter->endElement(); // p + } + + protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) + { + $font = $style->getName(); + $bold = $style->getBold(); + $italic = $style->getItalic(); + $color = $style->getColor(); + $size = $style->getSize(); + $fgColor = $style->getFgColor(); + $striketrough = $style->getStrikethrough(); + $underline = $style->getUnderline(); + + $objWriter->startElement('w:rPr'); + + // Font + if ($font != 'Arial') { + $objWriter->startElement('w:rFonts'); + $objWriter->writeAttribute('w:ascii', $font); + $objWriter->writeAttribute('w:hAnsi', $font); + $objWriter->writeAttribute('w:cs', $font); + $objWriter->endElement(); + } + + // Color + if ($color != '000000') { + $objWriter->startElement('w:color'); + $objWriter->writeAttribute('w:val', $color); + $objWriter->endElement(); + } + + // Size + if ($size != 20) { + $objWriter->startElement('w:sz'); + $objWriter->writeAttribute('w:val', $size); + $objWriter->endElement(); + $objWriter->startElement('w:szCs'); + $objWriter->writeAttribute('w:val', $size); + $objWriter->endElement(); + } + + // Bold + if ($bold) { + $objWriter->writeElement('w:b', null); + } + + // Italic + if ($italic) { + $objWriter->writeElement('w:i', null); + $objWriter->writeElement('w:iCs', null); + } + + // Underline + if (!is_null($underline) && $underline != 'none') { + $objWriter->startElement('w:u'); + $objWriter->writeAttribute('w:val', $underline); + $objWriter->endElement(); + } + + // Striketrough + if ($striketrough) { + $objWriter->writeElement('w:strike', null); + } + + // Foreground-Color + if (!is_null($fgColor)) { + $objWriter->startElement('w:highlight'); + $objWriter->writeAttribute('w:val', $fgColor); + $objWriter->endElement(); + } + + $objWriter->endElement(); + } + + protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) + { + $objWriter->writeElement('w:p', null); + } + + protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) + { + $_rows = $table->getRows(); + $_cRows = count($_rows); + + if ($_cRows > 0) { + $objWriter->startElement('w:tbl'); + $tblStyle = $table->getStyle(); + if ($tblStyle instanceof PHPWord_Style_Table) { + $this->_writeTableStyle($objWriter, $tblStyle); + } else { + if (!empty($tblStyle)) { + $objWriter->startElement('w:tblPr'); + $objWriter->startElement('w:tblStyle'); + $objWriter->writeAttribute('w:val', $tblStyle); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + $_heights = $table->getRowHeights(); + for ($i = 0; $i < $_cRows; $i++) { + $row = $_rows[$i]; + $height = $_heights[$i]; + + $objWriter->startElement('w:tr'); + + if (!is_null($height)) { + $objWriter->startElement('w:trPr'); + $objWriter->startElement('w:trHeight'); + $objWriter->writeAttribute('w:val', $height); + $objWriter->endElement(); + $objWriter->endElement(); + } + + foreach ($row as $cell) { + $objWriter->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(); + + if ($cellStyle instanceof PHPWord_Style_Cell) { + $this->_writeCellStyle($objWriter, $cellStyle); + } + + $objWriter->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); + } elseif ($element instanceof PHPWord_Section_ListItem) { + $this->_writeListItem($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Image || + $element instanceof PHPWord_Section_MemoryImage + ) { + $this->_writeImage($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Object) { + $this->_writeObject($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) { + $this->_writePreserveText($objWriter, $element); + } + } + } else { + $this->_writeTextBreak($objWriter); + } + + $objWriter->endElement(); + } + $objWriter->endElement(); + } + $objWriter->endElement(); + } + } + + protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) + { + $margins = $style->getCellMargin(); + $mTop = (!is_null($margins[0])) ? true : false; + $mLeft = (!is_null($margins[1])) ? true : false; + $mRight = (!is_null($margins[2])) ? true : false; + $mBottom = (!is_null($margins[3])) ? true : false; + + if ($mTop || $mLeft || $mRight || $mBottom) { + $objWriter->startElement('w:tblPr'); + $objWriter->startElement('w:tblCellMar'); + + if ($mTop) { + $objWriter->startElement('w:top'); + $objWriter->writeAttribute('w:w', $margins[0]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + + if ($mLeft) { + $objWriter->startElement('w:left'); + $objWriter->writeAttribute('w:w', $margins[1]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + + if ($mRight) { + $objWriter->startElement('w:right'); + $objWriter->writeAttribute('w:w', $margins[2]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + + if ($mBottom) { + $objWriter->startElement('w:bottom'); + $objWriter->writeAttribute('w:w', $margins[3]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_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)) { + $objWriter->startElement('w:textDirection'); + $objWriter->writeAttribute('w:val', $textDir); + $objWriter->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(); + } + + if (!is_null($valign)) { + $objWriter->startElement('w:vAlign'); + $objWriter->writeAttribute('w:val', $valign); + $objWriter->endElement(); } - - if(!is_null($align)) { - $objWriter->startElement('w:jc'); - $objWriter->writeAttribute('w:val', $align); - $objWriter->endElement(); - } - - if(!is_null($indent)) { - $objWriter->startElement('w:ind'); - $objWriter->writeAttribute('w:firstLine', 0); - $objWriter->writeAttribute('w:left', $indent); - $objWriter->endElement(); - } - - if(!is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($spacing)) { - - $objWriter->startElement('w:spacing'); - - if(!is_null($spaceBefore)) { - $objWriter->writeAttribute('w:before', $spaceBefore); - } - if(!is_null($spaceAfter)) { - $objWriter->writeAttribute('w:after', $spaceAfter); - } - if(!is_null($spacing)) { - $objWriter->writeAttribute('w:line', $spacing); - $objWriter->writeAttribute('w:lineRule', 'auto'); - } - - $objWriter->endElement(); - } - - if(!$withoutPPR) { - $objWriter->endElement(); // w:pPr + + if ($borders) { + $_defaultColor = $style->getDefaultBorderColor(); + + $objWriter->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(); + } + + 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(); + } + + 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(); + } + + 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(); + } + + $objWriter->endElement(); } - } - } - - protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) { - $rID = $link->getRelationId(); - $linkName = $link->getLinkName(); - if(is_null($linkName)) { - $linkName = $link->getLinkSrc(); - } - - $styleFont = $link->getFontStyle(); - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - - if(!$withoutP) { - $objWriter->startElement('w:p'); - - $styleParagraph = $link->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - $objWriter->startElement('w:hyperlink'); - $objWriter->writeAttribute('r:id', 'rId'.$rID); - $objWriter->writeAttribute('w:history', '1'); - - $objWriter->startElement('w:r'); - if($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); - } elseif(!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->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(); - - $objWriter->endElement(); - - if(!$withoutP) { - $objWriter->endElement(); // w:p - } - } - - protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) { - $styleFont = $textrun->getFontStyle(); - $styleParagraph = $textrun->getParagraphStyle(); - - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - $arrText = $textrun->getText(); - - $objWriter->startElement('w:p'); - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); - } - - foreach($arrText as $text) { - - 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(); - - $objWriter->startElement('w:r'); - - if($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); - } elseif(!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->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(); - } else { - $text = htmlspecialchars($text); - $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); - - $objWriter->startElement('w:r'); - - if($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); - } elseif(!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:t'); - $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRaw($text); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - $objWriter->endElement(); // p - } - - protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) { - $font = $style->getName(); - $bold = $style->getBold(); - $italic = $style->getItalic(); - $color = $style->getColor(); - $size = $style->getSize(); - $fgColor = $style->getFgColor(); - $striketrough = $style->getStrikethrough(); - $underline = $style->getUnderline(); - - $objWriter->startElement('w:rPr'); - - // Font - if($font != 'Arial') { - $objWriter->startElement('w:rFonts'); - $objWriter->writeAttribute('w:ascii', $font); - $objWriter->writeAttribute('w:hAnsi', $font); - $objWriter->writeAttribute('w:cs', $font); - $objWriter->endElement(); - } - - // Color - if($color != '000000') { - $objWriter->startElement('w:color'); - $objWriter->writeAttribute('w:val', $color); - $objWriter->endElement(); - } - - // Size - if($size != 20) { - $objWriter->startElement('w:sz'); - $objWriter->writeAttribute('w:val', $size); - $objWriter->endElement(); - $objWriter->startElement('w:szCs'); - $objWriter->writeAttribute('w:val', $size); - $objWriter->endElement(); - } - - // Bold - if($bold) { - $objWriter->writeElement('w:b', null); - } - - // Italic - if($italic) { - $objWriter->writeElement('w:i', null); - $objWriter->writeElement('w:iCs', null); - } - - // Underline - if(!is_null($underline) && $underline != 'none') { - $objWriter->startElement('w:u'); - $objWriter->writeAttribute('w:val', $underline); - $objWriter->endElement(); - } - - // Striketrough - if($striketrough) { - $objWriter->writeElement('w:strike', null); - } - - // Foreground-Color - if(!is_null($fgColor)) { - $objWriter->startElement('w:highlight'); - $objWriter->writeAttribute('w:val', $fgColor); - $objWriter->endElement(); - } - - $objWriter->endElement(); - } - - protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) { - $objWriter->writeElement('w:p', null); - } - - protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) { - $_rows = $table->getRows(); - $_cRows = count($_rows); - - if($_cRows > 0) { - $objWriter->startElement('w:tbl'); - $tblStyle = $table->getStyle(); - if($tblStyle instanceof PHPWord_Style_Table) { - $this->_writeTableStyle($objWriter, $tblStyle); - } else { - if(!empty($tblStyle)) { - $objWriter->startElement('w:tblPr'); - $objWriter->startElement('w:tblStyle'); - $objWriter->writeAttribute('w:val', $tblStyle); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - $_heights = $table->getRowHeights(); - for($i=0; $i<$_cRows; $i++) { - $row = $_rows[$i]; - $height = $_heights[$i]; - - $objWriter->startElement('w:tr'); - - if(!is_null($height)) { - $objWriter->startElement('w:trPr'); - $objWriter->startElement('w:trHeight'); - $objWriter->writeAttribute('w:val', $height); - $objWriter->endElement(); - $objWriter->endElement(); - } - - foreach($row as $cell) { - $objWriter->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(); - - if($cellStyle instanceof PHPWord_Style_Cell) { - $this->_writeCellStyle($objWriter, $cellStyle); - } - - $objWriter->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); - } elseif($element instanceof PHPWord_Section_ListItem) { - $this->_writeListItem($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Image || - $element instanceof PHPWord_Section_MemoryImage) { - $this->_writeImage($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Object) { - $this->_writeObject($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Footer_PreserveText) { - $this->_writePreserveText($objWriter, $element); - } - } - } else { - $this->_writeTextBreak($objWriter); - } - - $objWriter->endElement(); - } - $objWriter->endElement(); - } - $objWriter->endElement(); - } - } - - protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) { - $margins = $style->getCellMargin(); - $mTop = (!is_null($margins[0])) ? true : false; - $mLeft = (!is_null($margins[1])) ? true : false; - $mRight = (!is_null($margins[2])) ? true : false; - $mBottom = (!is_null($margins[3])) ? true : false; - - if($mTop || $mLeft || $mRight || $mBottom) { - $objWriter->startElement('w:tblPr'); - $objWriter->startElement('w:tblCellMar'); - - if($mTop) { - $objWriter->startElement('w:top'); - $objWriter->writeAttribute('w:w', $margins[0]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - - if($mLeft) { - $objWriter->startElement('w:left'); - $objWriter->writeAttribute('w:w', $margins[1]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - - if($mRight) { - $objWriter->startElement('w:right'); - $objWriter->writeAttribute('w:w', $margins[2]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - - if($mBottom) { - $objWriter->startElement('w:bottom'); - $objWriter->writeAttribute('w:w', $margins[3]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_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)) { - $objWriter->startElement('w:textDirection'); - $objWriter->writeAttribute('w:val', $textDir); - $objWriter->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(); - } - - if(!is_null($valign)) { - $objWriter->startElement('w:vAlign'); - $objWriter->writeAttribute('w:val', $valign); - $objWriter->endElement(); - } - - if($borders) { - $_defaultColor = $style->getDefaultBorderColor(); - - $objWriter->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(); - } - - 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(); - } - - 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(); - } - - 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(); - } - - $objWriter->endElement(); - } - } - } - - protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image) { - $rId = $image->getRelationId(); - - $style = $image->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $align = $style->getAlign(); - - $objWriter->startElement('w:p'); - - if(!is_null($align)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:jc'); - $objWriter->writeAttribute('w:val', $align); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:r'); - - $objWriter->startElement('w:pict'); - - $objWriter->startElement('v:shape'); - $objWriter->writeAttribute('type', '#_x0000_t75'); - $objWriter->writeAttribute('style', 'width:'.$width.'px;height:'.$height.'px'); - - $objWriter->startElement('v:imagedata'); - $objWriter->writeAttribute('r:id', 'rId'.$rId); - $objWriter->writeAttribute('o:title', ''); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->endElement(); - - $objWriter->endElement(); - - $objWriter->endElement(); - } - - protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) { - $rId = $image->getRelationId(); - - $style = $image->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $marginLeft = $style->getMarginLeft(); - $marginTop = $style->getMarginTop(); - - $objWriter->startElement('w:p'); - - $objWriter->startElement('w:r'); - - $objWriter->startElement('w:pict'); - - $objWriter->startElement('v:shape'); - $objWriter->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;'; - } - - $objWriter->writeAttribute('style', $strStyle); - - $objWriter->startElement('v:imagedata'); - $objWriter->writeAttribute('r:id', 'rId'.$rId); - $objWriter->writeAttribute('o:title', ''); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->endElement(); - - $objWriter->endElement(); - - $objWriter->endElement(); - } - - protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) { - $text = htmlspecialchars($title->getText()); - $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); - $anchor = $title->getAnchor(); - $bookmarkId = $title->getBookmarkId(); - $style = $title->getStyle(); - - $objWriter->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(); - } + } + } + + protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image) + { + $rId = $image->getRelationId(); + + $style = $image->getStyle(); + $width = $style->getWidth(); + $height = $style->getHeight(); + $align = $style->getAlign(); + + $objWriter->startElement('w:p'); + + if (!is_null($align)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:jc'); + $objWriter->writeAttribute('w:val', $align); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:r'); + + $objWriter->startElement('w:pict'); + + $objWriter->startElement('v:shape'); + $objWriter->writeAttribute('type', '#_x0000_t75'); + $objWriter->writeAttribute('style', 'width:' . $width . 'px;height:' . $height . 'px'); + + $objWriter->startElement('v:imagedata'); + $objWriter->writeAttribute('r:id', 'rId' . $rId); + $objWriter->writeAttribute('o:title', ''); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) + { + $rId = $image->getRelationId(); + + $style = $image->getStyle(); + $width = $style->getWidth(); + $height = $style->getHeight(); + $marginLeft = $style->getMarginLeft(); + $marginTop = $style->getMarginTop(); + + $objWriter->startElement('w:p'); + + $objWriter->startElement('w:r'); + + $objWriter->startElement('w:pict'); + + $objWriter->startElement('v:shape'); + $objWriter->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;'; + } + + $objWriter->writeAttribute('style', $strStyle); + + $objWriter->startElement('v:imagedata'); + $objWriter->writeAttribute('r:id', 'rId' . $rId); + $objWriter->writeAttribute('o:title', ''); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) + { + $text = htmlspecialchars($title->getText()); + $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); + $anchor = $title->getAnchor(); + $bookmarkId = $title->getBookmarkId(); + $style = $title->getStyle(); + + $objWriter->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(); + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Writer/Word2007/ContentTypes.php b/src/PHPWord/Writer/Word2007/ContentTypes.php index 0bc0460375..3afb239db7 100644 --- a/src/PHPWord/Writer/Word2007/ContentTypes.php +++ b/src/PHPWord/Writer/Word2007/ContentTypes.php @@ -26,160 +26,165 @@ */ -class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_WriterPart { - - public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $_cFtrs) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } - - // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Types - $objWriter->startElement('Types'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); - - // Rels - $this->_writeDefaultContentType( - $objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml' - ); - - // XML - $this->_writeDefaultContentType( - $objWriter, 'xml', 'application/xml' - ); - - // Add media content-types - foreach($_imageTypes as $key => $value) { - $this->_writeDefaultContentType($objWriter, $key, $value); - } - - // Add embedding content-types - if(count($_objectTypes) > 0) { - $this->_writeDefaultContentType($objWriter, 'bin', 'application/vnd.openxmlformats-officedocument.oleObject'); - } - - // DocProps - $this->_writeOverrideContentType( - $objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml' - ); - - $this->_writeOverrideContentType( - $objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml' - ); - - // Document - $this->_writeOverrideContentType( - $objWriter, '/word/document.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml' - ); - - // Styles - $this->_writeOverrideContentType( - $objWriter, '/word/styles.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml' - ); - - // Numbering - $this->_writeOverrideContentType( - $objWriter, '/word/numbering.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml' - ); - - // Settings - $this->_writeOverrideContentType( - $objWriter, '/word/settings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml' - ); - - // Theme1 - $this->_writeOverrideContentType( - $objWriter, '/word/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml' - ); - - // WebSettings - $this->_writeOverrideContentType( - $objWriter, '/word/webSettings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml' - ); - - // Font Table - $this->_writeOverrideContentType( - $objWriter, '/word/fontTable.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml' - ); - - for($i=1; $i<=$_cHdrs; $i++) { - $this->_writeOverrideContentType( - $objWriter, '/word/header'.$i.'.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml' - ); - } - - for($i=1; $i<=$_cFtrs; $i++) { - $this->_writeOverrideContentType( - $objWriter, '/word/footer'.$i.'.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml' - ); - } - - - $objWriter->endElement(); - - // Return - return $objWriter->getData(); - } - - /** - * Get image mime type - * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception - */ - private function _getImageMimeType($pFile = '') { - if(PHPWord_Shared_File::file_exists($pFile)) { - $image = getimagesize($pFile); - return image_type_to_mime_type($image[2]); - } else { - throw new Exception("File $pFile does not exist"); - } - } - - /** - * Write Default content type - * - * @param PHPWord_Shared_XMLWriter $objWriter XML Writer - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception - */ - private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') { - if($pPartname != '' && $pContentType != '') { - // Write content type - $objWriter->startElement('Default'); - $objWriter->writeAttribute('Extension', $pPartname); - $objWriter->writeAttribute('ContentType', $pContentType); - $objWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } - - /** - * Write Override content type - * - * @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception - */ - private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') { - if($pPartname != '' && $pContentType != '') { - // Write content type - $objWriter->startElement('Override'); - $objWriter->writeAttribute('PartName', $pPartname); - $objWriter->writeAttribute('ContentType', $pContentType); - $objWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } +class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_WriterPart +{ + + public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $_cFtrs) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Types + $objWriter->startElement('Types'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); + + // Rels + $this->_writeDefaultContentType( + $objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml' + ); + + // XML + $this->_writeDefaultContentType( + $objWriter, 'xml', 'application/xml' + ); + + // Add media content-types + foreach ($_imageTypes as $key => $value) { + $this->_writeDefaultContentType($objWriter, $key, $value); + } + + // Add embedding content-types + if (count($_objectTypes) > 0) { + $this->_writeDefaultContentType($objWriter, 'bin', 'application/vnd.openxmlformats-officedocument.oleObject'); + } + + // DocProps + $this->_writeOverrideContentType( + $objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml' + ); + + $this->_writeOverrideContentType( + $objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml' + ); + + // Document + $this->_writeOverrideContentType( + $objWriter, '/word/document.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml' + ); + + // Styles + $this->_writeOverrideContentType( + $objWriter, '/word/styles.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml' + ); + + // Numbering + $this->_writeOverrideContentType( + $objWriter, '/word/numbering.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml' + ); + + // Settings + $this->_writeOverrideContentType( + $objWriter, '/word/settings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml' + ); + + // Theme1 + $this->_writeOverrideContentType( + $objWriter, '/word/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml' + ); + + // WebSettings + $this->_writeOverrideContentType( + $objWriter, '/word/webSettings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml' + ); + + // Font Table + $this->_writeOverrideContentType( + $objWriter, '/word/fontTable.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml' + ); + + for ($i = 1; $i <= $_cHdrs; $i++) { + $this->_writeOverrideContentType( + $objWriter, '/word/header' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml' + ); + } + + for ($i = 1; $i <= $_cFtrs; $i++) { + $this->_writeOverrideContentType( + $objWriter, '/word/footer' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml' + ); + } + + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Get image mime type + * + * @param string $pFile Filename + * @return string Mime Type + * @throws Exception + */ + private function _getImageMimeType($pFile = '') + { + if (PHPWord_Shared_File::file_exists($pFile)) { + $image = getimagesize($pFile); + return image_type_to_mime_type($image[2]); + } else { + throw new Exception("File $pFile does not exist"); + } + } + + /** + * Write Default content type + * + * @param PHPWord_Shared_XMLWriter $objWriter XML Writer + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception + */ + private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') + { + if ($pPartname != '' && $pContentType != '') { + // Write content type + $objWriter->startElement('Default'); + $objWriter->writeAttribute('Extension', $pPartname); + $objWriter->writeAttribute('ContentType', $pContentType); + $objWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } + + /** + * Write Override content type + * + * @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception + */ + private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') + { + if ($pPartname != '' && $pContentType != '') { + // Write content type + $objWriter->startElement('Override'); + $objWriter->writeAttribute('PartName', $pPartname); + $objWriter->writeAttribute('ContentType', $pContentType); + $objWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } } diff --git a/src/PHPWord/Writer/Word2007/DocProps.php b/src/PHPWord/Writer/Word2007/DocProps.php index 1b91759686..b94ac0d677 100644 --- a/src/PHPWord/Writer/Word2007/DocProps.php +++ b/src/PHPWord/Writer/Word2007/DocProps.php @@ -26,155 +26,158 @@ */ -class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPart { +class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPart +{ - public function writeDocPropsApp(PHPWord $pPHPWord = null) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } + public function writeDocPropsApp(PHPWord $pPHPWord = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); + // XML header + $objWriter->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'); + // 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'); - // Application - $objWriter->writeElement('Application', 'Microsoft Office Word'); + // Application + $objWriter->writeElement('Application', 'Microsoft Office Word'); - // ScaleCrop - $objWriter->writeElement('ScaleCrop', 'false'); + // ScaleCrop + $objWriter->writeElement('ScaleCrop', 'false'); - // HeadingPairs - $objWriter->startElement('HeadingPairs'); + // HeadingPairs + $objWriter->startElement('HeadingPairs'); - // Vector - $objWriter->startElement('vt:vector'); - $objWriter->writeAttribute('size', '4'); - $objWriter->writeAttribute('baseType', 'variant'); + // Vector + $objWriter->startElement('vt:vector'); + $objWriter->writeAttribute('size', '4'); + $objWriter->writeAttribute('baseType', 'variant'); - // Variant - $objWriter->startElement('vt:variant'); - $objWriter->writeElement('vt:lpstr', 'Theme'); - $objWriter->endElement(); + // Variant + $objWriter->startElement('vt:variant'); + $objWriter->writeElement('vt:lpstr', 'Theme'); + $objWriter->endElement(); - // Variant - $objWriter->startElement('vt:variant'); - $objWriter->writeElement('vt:i4', '1'); - $objWriter->endElement(); - - // Variant - $objWriter->startElement('vt:variant'); - $objWriter->writeElement('vt:lpstr', 'Slide Titles'); - $objWriter->endElement(); + // Variant + $objWriter->startElement('vt:variant'); + $objWriter->writeElement('vt:i4', '1'); + $objWriter->endElement(); - // Variant - $objWriter->startElement('vt:variant'); - $objWriter->writeElement('vt:i4', '1'); - $objWriter->endElement(); + // Variant + $objWriter->startElement('vt:variant'); + $objWriter->writeElement('vt:lpstr', 'Slide Titles'); + $objWriter->endElement(); - $objWriter->endElement(); + // Variant + $objWriter->startElement('vt:variant'); + $objWriter->writeElement('vt:i4', '1'); + $objWriter->endElement(); - $objWriter->endElement(); + $objWriter->endElement(); - // TitlesOfParts - $objWriter->startElement('TitlesOfParts'); + $objWriter->endElement(); - // Vector - $objWriter->startElement('vt:vector'); - $objWriter->writeAttribute('size', '1'); - $objWriter->writeAttribute('baseType', 'lpstr'); + // TitlesOfParts + $objWriter->startElement('TitlesOfParts'); - $objWriter->writeElement('vt:lpstr', 'Office Theme'); + // Vector + $objWriter->startElement('vt:vector'); + $objWriter->writeAttribute('size', '1'); + $objWriter->writeAttribute('baseType', 'lpstr'); - $objWriter->endElement(); + $objWriter->writeElement('vt:lpstr', 'Office Theme'); - $objWriter->endElement(); + $objWriter->endElement(); - // Company - $objWriter->writeElement('Company', $pPHPWord->getProperties()->getCompany()); + $objWriter->endElement(); - // LinksUpToDate - $objWriter->writeElement('LinksUpToDate', 'false'); + // Company + $objWriter->writeElement('Company', $pPHPWord->getProperties()->getCompany()); - // SharedDoc - $objWriter->writeElement('SharedDoc', 'false'); + // LinksUpToDate + $objWriter->writeElement('LinksUpToDate', 'false'); - // HyperlinksChanged - $objWriter->writeElement('HyperlinksChanged', 'false'); + // SharedDoc + $objWriter->writeElement('SharedDoc', 'false'); - // AppVersion - $objWriter->writeElement('AppVersion', '12.0000'); + // HyperlinksChanged + $objWriter->writeElement('HyperlinksChanged', 'false'); - $objWriter->endElement(); + // AppVersion + $objWriter->writeElement('AppVersion', '12.0000'); - // Return - return $objWriter->getData(); - } + $objWriter->endElement(); + // Return + return $objWriter->getData(); + } - public function writeDocPropsCore(PHPWord $pPHPWord = null) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); + public function writeDocPropsCore(PHPWord $pPHPWord = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } - // 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'); + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); - // dc:creator - $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getCreator()); + // 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'); - // cp:lastModifiedBy - $objWriter->writeElement('cp:lastModifiedBy', $pPHPWord->getProperties()->getLastModifiedBy()); + // dc:creator + $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getCreator()); - // dcterms:created - $objWriter->startElement('dcterms:created'); - $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getCreated())); - $objWriter->endElement(); + // cp:lastModifiedBy + $objWriter->writeElement('cp:lastModifiedBy', $pPHPWord->getProperties()->getLastModifiedBy()); - // dcterms:modified - $objWriter->startElement('dcterms:modified'); - $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getModified())); - $objWriter->endElement(); + // dcterms:created + $objWriter->startElement('dcterms:created'); + $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); + $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getCreated())); + $objWriter->endElement(); - // dc:title - $objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle()); + // dcterms:modified + $objWriter->startElement('dcterms:modified'); + $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); + $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getModified())); + $objWriter->endElement(); - // dc:description - $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); + // dc:title + $objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle()); - // dc:subject - $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); + // dc:description + $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); - // cp:keywords - $objWriter->writeElement('cp:keywords', $pPHPWord->getProperties()->getKeywords()); + // dc:subject + $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); - // cp:category - $objWriter->writeElement('cp:category', $pPHPWord->getProperties()->getCategory()); + // cp:keywords + $objWriter->writeElement('cp:keywords', $pPHPWord->getProperties()->getKeywords()); - $objWriter->endElement(); + // cp:category + $objWriter->writeElement('cp:category', $pPHPWord->getProperties()->getCategory()); - // Return - return $objWriter->getData(); - } + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } } diff --git a/src/PHPWord/Writer/Word2007/Document.php b/src/PHPWord/Writer/Word2007/Document.php index b07e2698c8..247d172f02 100644 --- a/src/PHPWord/Writer/Word2007/Document.php +++ b/src/PHPWord/Writer/Word2007/Document.php @@ -26,428 +26,437 @@ */ -class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base { - - public function writeDocument(PHPWord $pPHPWord = null) { - // Create XML writer - - if($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } - - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); - - // w:document - $objWriter->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'); - - $objWriter->startElement('w:body'); - - $_sections = $pPHPWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if($countSections > 0) { - foreach($_sections as $section) { - $pSection++; - - $_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); - } 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) { - $this->_writeImage($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Object) { - $this->_writeObject($objWriter, $element); - } elseif($element instanceof PHPWord_TOC) { - $this->_writeTOC($objWriter); - } - } - - if($pSection == $countSections) { - $this->_writeEndSection($objWriter, $section); - } else { - $this->_writeSection($objWriter, $section); - } - } - } - - $objWriter->endElement(); // End w:body - $objWriter->endElement(); // End w:document - - // Return - return $objWriter->getData(); - } - - private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) { - $objWriter->startElement('w:p'); - $objWriter->startElement('w:pPr'); - $this->_writeEndSection($objWriter, $section, 3); - $objWriter->endElement(); - $objWriter->endElement(); - } - - private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) { - $_settings = $section->getSettings(); - $_header = $section->getHeader(); - $_footer = $section->getFooter(); - $pgSzW = $_settings->getPageSizeW(); - $pgSzH = $_settings->getPageSizeH(); - $orientation = $_settings->getOrientation(); - - $marginTop = $_settings->getMarginTop(); - $marginLeft = $_settings->getMarginLeft(); - $marginRight = $_settings->getMarginRight(); - $marginBottom = $_settings->getMarginBottom(); - - $borders = $_settings->getBorderSize(); - - $objWriter->startElement('w:sectPr'); - - if(!is_null($_header)) { - $rId = $_header->getRelationId(); - $objWriter->startElement('w:headerReference'); - $objWriter->writeAttribute('w:type', 'default'); - $objWriter->writeAttribute('r:id', 'rId'.$rId); - $objWriter->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(); - } - - $objWriter->startElement('w:pgSz'); - $objWriter->writeAttribute('w:w', $pgSzW); - $objWriter->writeAttribute('w:h', $pgSzH); - - if(!is_null($orientation) && strtolower($orientation) != 'portrait') { - $objWriter->writeAttribute('w:orient', $orientation); - } - - $objWriter->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', '720'); - $objWriter->writeAttribute('w:footer', '720'); - $objWriter->writeAttribute('w:gutter', '0'); - $objWriter->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'); - - 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(); - } - - 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(); - } - - 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(); - } - - 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(); - } - $objWriter->endElement(); - } - - - $objWriter->startElement('w:cols'); - $objWriter->writeAttribute('w:space', '720'); - $objWriter->endElement(); - - - $objWriter->endElement(); - } - - private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null) { - $objWriter->startElement('w:p'); - $objWriter->startElement('w:r'); - $objWriter->startElement('w:br'); - $objWriter->writeAttribute('w:type', 'page'); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - } - - private function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem) { - $textObject = $listItem->getTextObject(); - $text = $textObject->getText(); +class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base +{ + + public function writeDocument(PHPWord $pPHPWord = null) + { + // Create XML writer + + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // w:document + $objWriter->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'); + + $objWriter->startElement('w:body'); + + $_sections = $pPHPWord->getSections(); + $countSections = count($_sections); + $pSection = 0; + + if ($countSections > 0) { + foreach ($_sections as $section) { + $pSection++; + + $_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); + } 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 + ) { + $this->_writeImage($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Object) { + $this->_writeObject($objWriter, $element); + } elseif ($element instanceof PHPWord_TOC) { + $this->_writeTOC($objWriter); + } + } + + if ($pSection == $countSections) { + $this->_writeEndSection($objWriter, $section); + } else { + $this->_writeSection($objWriter, $section); + } + } + } + + $objWriter->endElement(); // End w:body + $objWriter->endElement(); // End w:document + + // Return + return $objWriter->getData(); + } + + private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) + { + $objWriter->startElement('w:p'); + $objWriter->startElement('w:pPr'); + $this->_writeEndSection($objWriter, $section, 3); + $objWriter->endElement(); + $objWriter->endElement(); + } + + private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) + { + $_settings = $section->getSettings(); + $_header = $section->getHeader(); + $_footer = $section->getFooter(); + $pgSzW = $_settings->getPageSizeW(); + $pgSzH = $_settings->getPageSizeH(); + $orientation = $_settings->getOrientation(); + + $marginTop = $_settings->getMarginTop(); + $marginLeft = $_settings->getMarginLeft(); + $marginRight = $_settings->getMarginRight(); + $marginBottom = $_settings->getMarginBottom(); + + $borders = $_settings->getBorderSize(); + + $objWriter->startElement('w:sectPr'); + + if (!is_null($_header)) { + $rId = $_header->getRelationId(); + $objWriter->startElement('w:headerReference'); + $objWriter->writeAttribute('w:type', 'default'); + $objWriter->writeAttribute('r:id', 'rId' . $rId); + $objWriter->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(); + } + + $objWriter->startElement('w:pgSz'); + $objWriter->writeAttribute('w:w', $pgSzW); + $objWriter->writeAttribute('w:h', $pgSzH); + + if (!is_null($orientation) && strtolower($orientation) != 'portrait') { + $objWriter->writeAttribute('w:orient', $orientation); + } + + $objWriter->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', '720'); + $objWriter->writeAttribute('w:footer', '720'); + $objWriter->writeAttribute('w:gutter', '0'); + $objWriter->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'); + + 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(); + } + + 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(); + } + + 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(); + } + + 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(); + } + $objWriter->endElement(); + } + + + $objWriter->startElement('w:cols'); + $objWriter->writeAttribute('w:space', '720'); + $objWriter->endElement(); + + + $objWriter->endElement(); + } + + private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null) + { + $objWriter->startElement('w:p'); + $objWriter->startElement('w:r'); + $objWriter->startElement('w:br'); + $objWriter->writeAttribute('w:type', 'page'); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } + + private function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem) + { + $textObject = $listItem->getTextObject(); + $text = $textObject->getText(); $styleParagraph = $textObject->getParagraphStyle(); $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - $depth = $listItem->getDepth(); - $listType = $listItem->getStyle()->getListType(); - - $objWriter->startElement('w:p'); - $objWriter->startElement('w:pPr'); - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph, true); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - } - - $objWriter->startElement('w:numPr'); - - $objWriter->startElement('w:ilvl'); - $objWriter->writeAttribute('w:val', $depth); - $objWriter->endElement(); - - $objWriter->startElement('w:numId'); - $objWriter->writeAttribute('w:val', $listType); - $objWriter->endElement(); - - $objWriter->endElement(); - $objWriter->endElement(); - - $this->_writeText($objWriter, $textObject, true); - - $objWriter->endElement(); - } - - protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_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(); - - - $objWriter->startElement('w:p'); - - if(!is_null($align)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:jc'); - $objWriter->writeAttribute('w:val', $align); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:r'); - - $objWriter->startElement('w:object'); - $objWriter->writeAttribute('w:dxaOrig', '249'); - $objWriter->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', ''); - - $objWriter->startElement('v:imagedata'); - $objWriter->writeAttribute('r:id', 'rId'.$rIdImage); - $objWriter->writeAttribute('o:title', ''); - $objWriter->endElement(); - - $objWriter->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(); - - $objWriter->endElement(); - - $objWriter->endElement(); // w:r - - $objWriter->endElement(); // w:p - } - - private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null) { - $titles = PHPWord_TOC::getTitles(); - $styleFont = PHPWord_TOC::getStyleFont(); - - $styleTOC = PHPWord_TOC::getStyleTOC(); - $fIndent = $styleTOC->getIndent(); - $tabLeader = $styleTOC->getTabLeader(); - $tabPos = $styleTOC->getTabPos(); - - $isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - - for($i=0; $istartElement('w:p'); - - $objWriter->startElement('w:pPr'); - - if($isObject && !is_null($styleFont->getParagraphStyle())) { - $this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle()); - } - - if($indent > 0) { - $objWriter->startElement('w:ind'); - $objWriter->writeAttribute('w:left', $indent); - $objWriter->endElement(); - } - - if(!empty($styleFont) && !$isObject) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:tabs'); - $objWriter->startElement('w:tab'); - $objWriter->writeAttribute('w:val', 'right'); - if(!empty($tabLeader)) { - $objWriter->writeAttribute('w:leader', $tabLeader); - } - $objWriter->writeAttribute('w:pos', $tabPos); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->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(); - } - - $objWriter->startElement('w:hyperlink'); - $objWriter->writeAttribute('w:anchor', $title['anchor']); - $objWriter->writeAttribute('w:history', '1'); - - $objWriter->startElement('w:r'); - - if($isObject) { - $this->_writeTextStyle($objWriter, $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 - } - - $objWriter->startElement('w:p'); - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'end'); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - } + + $depth = $listItem->getDepth(); + $listType = $listItem->getStyle()->getListType(); + + $objWriter->startElement('w:p'); + $objWriter->startElement('w:pPr'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph, true); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + } + + $objWriter->startElement('w:numPr'); + + $objWriter->startElement('w:ilvl'); + $objWriter->writeAttribute('w:val', $depth); + $objWriter->endElement(); + + $objWriter->startElement('w:numId'); + $objWriter->writeAttribute('w:val', $listType); + $objWriter->endElement(); + + $objWriter->endElement(); + $objWriter->endElement(); + + $this->_writeText($objWriter, $textObject, true); + + $objWriter->endElement(); + } + + protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_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(); + + + $objWriter->startElement('w:p'); + + if (!is_null($align)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:jc'); + $objWriter->writeAttribute('w:val', $align); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:r'); + + $objWriter->startElement('w:object'); + $objWriter->writeAttribute('w:dxaOrig', '249'); + $objWriter->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', ''); + + $objWriter->startElement('v:imagedata'); + $objWriter->writeAttribute('r:id', 'rId' . $rIdImage); + $objWriter->writeAttribute('o:title', ''); + $objWriter->endElement(); + + $objWriter->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(); + + $objWriter->endElement(); + + $objWriter->endElement(); // w:r + + $objWriter->endElement(); // w:p + } + + private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null) + { + $titles = PHPWord_TOC::getTitles(); + $styleFont = PHPWord_TOC::getStyleFont(); + + $styleTOC = PHPWord_TOC::getStyleTOC(); + $fIndent = $styleTOC->getIndent(); + $tabLeader = $styleTOC->getTabLeader(); + $tabPos = $styleTOC->getTabPos(); + + $isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + + for ($i = 0; $i < count($titles); $i++) { + $title = $titles[$i]; + $indent = ($title['depth'] - 1) * $fIndent; + + $objWriter->startElement('w:p'); + + $objWriter->startElement('w:pPr'); + + if ($isObject && !is_null($styleFont->getParagraphStyle())) { + $this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle()); + } + + if ($indent > 0) { + $objWriter->startElement('w:ind'); + $objWriter->writeAttribute('w:left', $indent); + $objWriter->endElement(); + } + + if (!empty($styleFont) && !$isObject) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:tabs'); + $objWriter->startElement('w:tab'); + $objWriter->writeAttribute('w:val', 'right'); + if (!empty($tabLeader)) { + $objWriter->writeAttribute('w:leader', $tabLeader); + } + $objWriter->writeAttribute('w:pos', $tabPos); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->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(); + } + + $objWriter->startElement('w:hyperlink'); + $objWriter->writeAttribute('w:anchor', $title['anchor']); + $objWriter->writeAttribute('w:history', '1'); + + $objWriter->startElement('w:r'); + + if ($isObject) { + $this->_writeTextStyle($objWriter, $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 + } + + $objWriter->startElement('w:p'); + $objWriter->startElement('w:r'); + $objWriter->startElement('w:fldChar'); + $objWriter->writeAttribute('w:fldCharType', 'end'); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } } diff --git a/src/PHPWord/Writer/Word2007/DocumentRels.php b/src/PHPWord/Writer/Word2007/DocumentRels.php index b5b5bd0c78..a6d452bb67 100644 --- a/src/PHPWord/Writer/Word2007/DocumentRels.php +++ b/src/PHPWord/Writer/Word2007/DocumentRels.php @@ -26,152 +26,155 @@ */ -class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_WriterPart { - - public function writeDocumentRels($_relsCollection) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } - - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); - - // Relationships - $objWriter->startElement('Relationships'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - // Relationship word/document.xml - $this->_writeRelationship( - $objWriter, - 1, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', - 'styles.xml' - ); - - // Relationship word/numbering.xml - $this->_writeRelationship( - $objWriter, - 2, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering', - 'numbering.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $objWriter, - 3, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings', - 'settings.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $objWriter, - 4, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', - 'theme/theme1.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $objWriter, - 5, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings', - 'webSettings.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $objWriter, - 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( - $objWriter, - $relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/'.$relationType, - $relationName, - $targetMode - ); - } - - - $objWriter->endElement(); - - // Return - return $objWriter->getData(); - } - - public function writeHeaderFooterRels($_relsCollection) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } - - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); - - // Relationships - $objWriter->startElement('Relationships'); - $objWriter->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( - $objWriter, - $relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/'.$relationType, - $relationName - ); - } - - - $objWriter->endElement(); - - // Return - return $objWriter->getData(); - } - - private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { - if($pType != '' && $pTarget != '') { - if(strpos($pId, 'rId') === false) { - $pId = 'rId' . $pId; - } - - // Write relationship - $objWriter->startElement('Relationship'); - $objWriter->writeAttribute('Id', $pId); - $objWriter->writeAttribute('Type', $pType); - $objWriter->writeAttribute('Target', $pTarget); - - if($pTargetMode != '') { - $objWriter->writeAttribute('TargetMode', $pTargetMode); - } - - $objWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } +class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_WriterPart +{ + + public function writeDocumentRels($_relsCollection) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + // Relationship word/document.xml + $this->_writeRelationship( + $objWriter, + 1, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + 'styles.xml' + ); + + // Relationship word/numbering.xml + $this->_writeRelationship( + $objWriter, + 2, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering', + 'numbering.xml' + ); + + // Relationship word/settings.xml + $this->_writeRelationship( + $objWriter, + 3, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings', + 'settings.xml' + ); + + // Relationship word/settings.xml + $this->_writeRelationship( + $objWriter, + 4, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + 'theme/theme1.xml' + ); + + // Relationship word/settings.xml + $this->_writeRelationship( + $objWriter, + 5, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings', + 'webSettings.xml' + ); + + // Relationship word/settings.xml + $this->_writeRelationship( + $objWriter, + 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( + $objWriter, + $relationId, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, + $relationName, + $targetMode + ); + } + + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + public function writeHeaderFooterRels($_relsCollection) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->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( + $objWriter, + $relationId, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, + $relationName + ); + } + + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') + { + if ($pType != '' && $pTarget != '') { + if (strpos($pId, 'rId') === false) { + $pId = 'rId' . $pId; + } + + // Write relationship + $objWriter->startElement('Relationship'); + $objWriter->writeAttribute('Id', $pId); + $objWriter->writeAttribute('Type', $pType); + $objWriter->writeAttribute('Target', $pTarget); + + if ($pTargetMode != '') { + $objWriter->writeAttribute('TargetMode', $pTargetMode); + } + + $objWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Writer/Word2007/Footer.php b/src/PHPWord/Writer/Word2007/Footer.php index 8508b8678f..afdd81b39f 100644 --- a/src/PHPWord/Writer/Word2007/Footer.php +++ b/src/PHPWord/Writer/Word2007/Footer.php @@ -26,54 +26,56 @@ */ -class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base { - - public function writeFooter(PHPWord_Section_Footer $footer) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } - - // XML header - $objWriter->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'); - - $_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); - } elseif($element instanceof PHPWord_Section_Table) { - $this->_writeTable($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Image || - $element instanceof PHPWord_Section_MemoryImage) { - $this->_writeImage($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Footer_PreserveText) { - $this->_writePreserveText($objWriter, $element); - } - } - - $objWriter->endElement(); - - // Return - return $objWriter->getData(); - } +class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base +{ + + public function writeFooter(PHPWord_Section_Footer $footer) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->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'); + + $_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); + } elseif ($element instanceof PHPWord_Section_Table) { + $this->_writeTable($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Image || + $element instanceof PHPWord_Section_MemoryImage + ) { + $this->_writeImage($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) { + $this->_writePreserveText($objWriter, $element); + } + } + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } } -?> diff --git a/src/PHPWord/Writer/Word2007/Header.php b/src/PHPWord/Writer/Word2007/Header.php index f677899cc9..b7d7b2a67f 100644 --- a/src/PHPWord/Writer/Word2007/Header.php +++ b/src/PHPWord/Writer/Word2007/Header.php @@ -26,58 +26,60 @@ */ -class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base { - - public function writeHeader(PHPWord_Section_Header $header) { - // Create XML writer - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } - - // XML header - $objWriter->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'); - - - $_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); - } elseif($element instanceof PHPWord_Section_Table) { - $this->_writeTable($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Image || - $element instanceof PHPWord_Section_MemoryImage) { - if(!$element->getIsWatermark()) { - $this->_writeImage($objWriter, $element); - } else { - $this->_writeWatermark($objWriter, $element); - } - } elseif($element instanceof PHPWord_Section_Footer_PreserveText) { - $this->_writePreserveText($objWriter, $element); - } - } - - $objWriter->endElement(); - - // Return - return $objWriter->getData(); - } +class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base +{ + + public function writeHeader(PHPWord_Section_Header $header) + { + // Create XML writer + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->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'); + + + $_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); + } elseif ($element instanceof PHPWord_Section_Table) { + $this->_writeTable($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Image || + $element instanceof PHPWord_Section_MemoryImage + ) { + if (!$element->getIsWatermark()) { + $this->_writeImage($objWriter, $element); + } else { + $this->_writeWatermark($objWriter, $element); + } + } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) { + $this->_writePreserveText($objWriter, $element); + } + } + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } } -?> diff --git a/src/PHPWord/Writer/Word2007/Rels.php b/src/PHPWord/Writer/Word2007/Rels.php index 1811e8b582..4ea39c6985 100644 --- a/src/PHPWord/Writer/Word2007/Rels.php +++ b/src/PHPWord/Writer/Word2007/Rels.php @@ -26,85 +26,88 @@ */ -class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart { - - public function writeRelationships(PHPWord $pPHPWord = null) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } +class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart +{ - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); + public function writeRelationships(PHPWord $pPHPWord = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } - // Relationships - $objWriter->startElement('Relationships'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - $relationId = 1; - - // Relationship word/document.xml - $this->_writeRelationship( - $objWriter, - $relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', - 'word/document.xml' - ); - - // Relationship docProps/core.xml - $this->_writeRelationship( - $objWriter, - ++$relationId, - 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', - 'docProps/core.xml' - ); - - // Relationship docProps/app.xml - $this->_writeRelationship( - $objWriter, - ++$relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', - 'docProps/app.xml' - ); + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); - $objWriter->endElement(); + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - // Return - return $objWriter->getData(); - } + $relationId = 1; - /** - * Write Override content type - * - * @param PHPWord_Shared_XMLWriter $objWriter XML Writer - * @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 = '') { - if($pType != '' && $pTarget != '') { - if(strpos($pId, 'rId') === false) { - $pId = 'rId' . $pId; - } - - // Write relationship - $objWriter->startElement('Relationship'); - $objWriter->writeAttribute('Id', $pId); - $objWriter->writeAttribute('Type', $pType); - $objWriter->writeAttribute('Target', $pTarget); + // Relationship word/document.xml + $this->_writeRelationship( + $objWriter, + $relationId, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + 'word/document.xml' + ); - if($pTargetMode != '') { - $objWriter->writeAttribute('TargetMode', $pTargetMode); - } + // Relationship docProps/core.xml + $this->_writeRelationship( + $objWriter, + ++$relationId, + 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + 'docProps/core.xml' + ); - $objWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } + // Relationship docProps/app.xml + $this->_writeRelationship( + $objWriter, + ++$relationId, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + 'docProps/app.xml' + ); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write Override content type + * + * @param PHPWord_Shared_XMLWriter $objWriter XML Writer + * @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 = '') + { + if ($pType != '' && $pTarget != '') { + if (strpos($pId, 'rId') === false) { + $pId = 'rId' . $pId; + } + + // Write relationship + $objWriter->startElement('Relationship'); + $objWriter->writeAttribute('Id', $pId); + $objWriter->writeAttribute('Type', $pType); + $objWriter->writeAttribute('Target', $pTarget); + + if ($pTargetMode != '') { + $objWriter->writeAttribute('TargetMode', $pTargetMode); + } + + $objWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } } diff --git a/src/PHPWord/Writer/Word2007/Styles.php b/src/PHPWord/Writer/Word2007/Styles.php index 602b2bee0d..900f833f45 100644 --- a/src/PHPWord/Writer/Word2007/Styles.php +++ b/src/PHPWord/Writer/Word2007/Styles.php @@ -26,321 +26,325 @@ */ -class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base { - - private $_document; - - public function writeStyles(PHPWord $pPHPWord = null) { - // Create XML writer - $objWriter = null; - if($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } - - $this->_document = $pPHPWord; - - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); - - $objWriter->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'); - - // Write DocDefaults - $this->_writeDocDefaults($objWriter); - - - // Write Style Definitions - $styles = PHPWord_Style::getStyles(); - if(count($styles) > 0) { - foreach($styles as $styleName => $style) { - if($style instanceof PHPWord_Style_Font) { - - $paragraphStyle = $style->getParagraphStyle(); - $styleType = $style->getStyleType(); - - $type = ($styleType == 'title') ? 'paragraph' : 'character'; - - if(!is_null($paragraphStyle)) { - $type = 'paragraph'; - } - - $objWriter->startElement('w:style'); - $objWriter->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); - - $objWriter->startElement('w:link'); - $objWriter->writeAttribute('w:val', $styleLink); - $objWriter->endElement(); - } - - $objWriter->startElement('w:name'); - $objWriter->writeAttribute('w:val', $styleName); - $objWriter->endElement(); - - if(!is_null($paragraphStyle)) { - $this->_writeParagraphStyle($objWriter, $paragraphStyle); - } - - $this->_writeTextStyle($objWriter, $style); - - $objWriter->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); - - $objWriter->startElement('w:name'); - $objWriter->writeAttribute('w:val', $styleName); - $objWriter->endElement(); - - $this->_writeParagraphStyle($objWriter, $style); - $objWriter->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); - - $objWriter->startElement('w:name'); - $objWriter->writeAttribute('w:val', $styleName); - $objWriter->endElement(); - - $objWriter->startElement('w:uiPriority'); - $objWriter->writeAttribute('w:val', '99'); - $objWriter->endElement(); - - $this->_writeFullTableStyle($objWriter, $style); - - $objWriter->endElement(); - } - } - } - - $objWriter->endElement(); // w:styles - - // Return - return $objWriter->getData(); - } - - private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_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; - - $objWriter->startElement('w:tblPr'); - - if($margins) { - $objWriter->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(); - } - if($mLeft) { - $objWriter->startElement('w:left'); - $objWriter->writeAttribute('w:w', $cellMargin[1]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - if($mRight) { - $objWriter->startElement('w:right'); - $objWriter->writeAttribute('w:w', $cellMargin[2]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - if($mBottom) { - $objWriter->startElement('w:bottom'); - $objWriter->writeAttribute('w:w', $cellMargin[3]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - $objWriter->endElement(); - } - - if($borders) { - $objWriter->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(); - } - 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(); - } - 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(); - } - 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(); - } - 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(); - } - 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(); - } - $objWriter->endElement(); - } - - $objWriter->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(); - } - - - // First Row - $firstRow = $style->getFirstRow(); - if(!is_null($firstRow)) { - $this->_writeRowStyle($objWriter, 'firstRow', $firstRow); - } - } - - private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_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; - - $objWriter->startElement('w:tblStylePr'); - $objWriter->writeAttribute('w:type', $type); - - $objWriter->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(); - } - - $objWriter->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(); - } - 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(); - } - 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(); - } - 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(); - } - $objWriter->endElement(); - - $objWriter->endElement(); - - $objWriter->endElement(); - } - - - private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null) { - $fontName = $this->_document->getDefaultFontName(); - $fontSize = $this->_document->getDefaultFontSize(); - - $objWriter->startElement('w:docDefaults'); - $objWriter->startElement('w:rPrDefault'); - $objWriter->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(); - - $objWriter->startElement('w:sz'); - $objWriter->writeAttribute('w:val', $fontSize); - $objWriter->endElement(); - - $objWriter->startElement('w:szCs'); - $objWriter->writeAttribute('w:val', $fontSize); - $objWriter->endElement(); - - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - } +class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base +{ + + private $_document; + + public function writeStyles(PHPWord $pPHPWord = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } + + $this->_document = $pPHPWord; + + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + + $objWriter->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'); + + // Write DocDefaults + $this->_writeDocDefaults($objWriter); + + + // Write Style Definitions + $styles = PHPWord_Style::getStyles(); + if (count($styles) > 0) { + foreach ($styles as $styleName => $style) { + if ($style instanceof PHPWord_Style_Font) { + + $paragraphStyle = $style->getParagraphStyle(); + $styleType = $style->getStyleType(); + + $type = ($styleType == 'title') ? 'paragraph' : 'character'; + + if (!is_null($paragraphStyle)) { + $type = 'paragraph'; + } + + $objWriter->startElement('w:style'); + $objWriter->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); + + $objWriter->startElement('w:link'); + $objWriter->writeAttribute('w:val', $styleLink); + $objWriter->endElement(); + } + + $objWriter->startElement('w:name'); + $objWriter->writeAttribute('w:val', $styleName); + $objWriter->endElement(); + + if (!is_null($paragraphStyle)) { + $this->_writeParagraphStyle($objWriter, $paragraphStyle); + } + + $this->_writeTextStyle($objWriter, $style); + + $objWriter->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); + + $objWriter->startElement('w:name'); + $objWriter->writeAttribute('w:val', $styleName); + $objWriter->endElement(); + + $this->_writeParagraphStyle($objWriter, $style); + $objWriter->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); + + $objWriter->startElement('w:name'); + $objWriter->writeAttribute('w:val', $styleName); + $objWriter->endElement(); + + $objWriter->startElement('w:uiPriority'); + $objWriter->writeAttribute('w:val', '99'); + $objWriter->endElement(); + + $this->_writeFullTableStyle($objWriter, $style); + + $objWriter->endElement(); + } + } + } + + $objWriter->endElement(); // w:styles + + // Return + return $objWriter->getData(); + } + + private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_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; + + $objWriter->startElement('w:tblPr'); + + if ($margins) { + $objWriter->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(); + } + if ($mLeft) { + $objWriter->startElement('w:left'); + $objWriter->writeAttribute('w:w', $cellMargin[1]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + if ($mRight) { + $objWriter->startElement('w:right'); + $objWriter->writeAttribute('w:w', $cellMargin[2]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + if ($mBottom) { + $objWriter->startElement('w:bottom'); + $objWriter->writeAttribute('w:w', $cellMargin[3]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + $objWriter->endElement(); + } + + if ($borders) { + $objWriter->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(); + } + 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(); + } + 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(); + } + 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(); + } + 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(); + } + 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(); + } + $objWriter->endElement(); + } + + $objWriter->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(); + } + + + // First Row + $firstRow = $style->getFirstRow(); + if (!is_null($firstRow)) { + $this->_writeRowStyle($objWriter, 'firstRow', $firstRow); + } + } + + private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_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; + + $objWriter->startElement('w:tblStylePr'); + $objWriter->writeAttribute('w:type', $type); + + $objWriter->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(); + } + + $objWriter->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(); + } + 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(); + } + 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(); + } + 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(); + } + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + + private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null) + { + $fontName = $this->_document->getDefaultFontName(); + $fontSize = $this->_document->getDefaultFontSize(); + + $objWriter->startElement('w:docDefaults'); + $objWriter->startElement('w:rPrDefault'); + $objWriter->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(); + + $objWriter->startElement('w:sz'); + $objWriter->writeAttribute('w:val', $fontSize); + $objWriter->endElement(); + + $objWriter->startElement('w:szCs'); + $objWriter->writeAttribute('w:val', $fontSize); + $objWriter->endElement(); + + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } } -?> \ No newline at end of file diff --git a/src/PHPWord/Writer/Word2007/WriterPart.php b/src/PHPWord/Writer/Word2007/WriterPart.php index 1556a6f55a..afde53d276 100644 --- a/src/PHPWord/Writer/Word2007/WriterPart.php +++ b/src/PHPWord/Writer/Word2007/WriterPart.php @@ -26,18 +26,21 @@ */ -abstract class PHPWord_Writer_Word2007_WriterPart { - private $_parentWriter; - - public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) { - $this->_parentWriter = $pWriter; - } - - public function getParentWriter() { - if (!is_null($this->_parentWriter)) { - return $this->_parentWriter; - } else { - throw new Exception("No parent PHPWord_Writer_IWriter assigned."); - } - } +abstract class PHPWord_Writer_Word2007_WriterPart +{ + private $_parentWriter; + + public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) + { + $this->_parentWriter = $pWriter; + } + + public function getParentWriter() + { + if (!is_null($this->_parentWriter)) { + return $this->_parentWriter; + } else { + throw new Exception("No parent PHPWord_Writer_IWriter assigned."); + } + } } From fa77c4f1595e190390f092d7869e5d67f5574994 Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Wed, 11 Dec 2013 14:51:35 -0500 Subject: [PATCH 04/11] Added wrapping style to images --- src/PHPWord/Autoloader.php | 26 ++++++++++++----- src/PHPWord/Section/Image.php | 7 +++-- src/PHPWord/Shared/XMLWriter.php | 13 +++++++-- src/PHPWord/Style/Image.php | 41 +++++++++++++++++++++++++- src/PHPWord/Writer/Word2007/Base.php | 43 ++++++++++++++++++++++++++-- 5 files changed, 115 insertions(+), 15 deletions(-) diff --git a/src/PHPWord/Autoloader.php b/src/PHPWord/Autoloader.php index 86ad651d91..dc48ef91ad 100644 --- a/src/PHPWord/Autoloader.php +++ b/src/PHPWord/Autoloader.php @@ -27,23 +27,35 @@ class PHPWord_Autoloader { - public static function Register() + /** + * Register the autoloader + * + * @return void + */ + public static function register() { - return spl_autoload_register(array('PHPWord_Autoloader', 'Load')); + spl_autoload_register(array('PHPWord_Autoloader', 'load')); } - public static function Load($strObjectName) + /** + * Autoloader + * + * @param string $strObjectName + * @return mixed + */ + public static function load($strObjectName) { if ((class_exists($strObjectName)) || (strpos($strObjectName, 'PHPWord') === false)) { - return false; + return null; } $strObjectFilePath = PHPWORD_BASE_PATH . str_replace('_', '/', $strObjectName) . '.php'; if ((file_exists($strObjectFilePath) === false) || (is_readable($strObjectFilePath) === false)) { - return false; + return null; } - require($strObjectFilePath); + require_once $strObjectFilePath; + return true; } -} +} \ No newline at end of file diff --git a/src/PHPWord/Section/Image.php b/src/PHPWord/Section/Image.php index 68ac306501..3df4f9e826 100644 --- a/src/PHPWord/Section/Image.php +++ b/src/PHPWord/Section/Image.php @@ -92,6 +92,10 @@ public function __construct($src, $style = null, $isWatermark = false) } } + 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]); @@ -173,5 +177,4 @@ public function setIsWatermark($pValue) { $this->_isWatermark = $pValue; } -} - +} \ No newline at end of file diff --git a/src/PHPWord/Shared/XMLWriter.php b/src/PHPWord/Shared/XMLWriter.php index 5f699cdc14..7d62b82a16 100644 --- a/src/PHPWord/Shared/XMLWriter.php +++ b/src/PHPWord/Shared/XMLWriter.php @@ -30,7 +30,16 @@ define('DATE_W3C', 'Y-m-d\TH:i:sP'); } - +/** + * Class PHPWord_Shared_XMLWriter + * + * @category PHPWord + * @package PHPWord_Section + * @copyright Copyright (c) 2011 PHPWord + * @method bool startElement(string $name) + * @method bool writeAttribute(string $name, string $value) + * @method bool endElement() + */ class PHPWord_Shared_XMLWriter { /** Temporary storage method */ @@ -145,4 +154,4 @@ public function writeRaw($text) return $this->text($text); } -} +} \ No newline at end of file diff --git a/src/PHPWord/Style/Image.php b/src/PHPWord/Style/Image.php index 1c93674f41..556d53f303 100644 --- a/src/PHPWord/Style/Image.php +++ b/src/PHPWord/Style/Image.php @@ -35,10 +35,16 @@ */ class PHPWord_Style_Image { + const WRAPPING_STYLE_INLINE = 'inline'; + const WRAPPING_STYLE_SQUARE = 'square'; + const WRAPPING_STYLE_TIGHT = 'tight'; + const WRAPPING_STYLE_BEHIND = 'behind'; + const WRAPPING_STYLE_INFRONT = 'infront'; private $_width; private $_height; private $_align; + private $wrappingStyle; /** * Margin Top @@ -61,6 +67,7 @@ public function __construct() $this->_align = null; $this->_marginTop = null; $this->_marginLeft = null; + $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); } public function setStyleValue($key, $value) @@ -112,6 +119,7 @@ public function getMarginTop() * Set Margin Top * * @param int $pValue + * @return $this */ public function setMarginTop($pValue = null) { @@ -133,10 +141,41 @@ public function getMarginLeft() * 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; + } +} \ No newline at end of file diff --git a/src/PHPWord/Writer/Word2007/Base.php b/src/PHPWord/Writer/Word2007/Base.php index b55dcb2c69..ae39e1bd89 100644 --- a/src/PHPWord/Writer/Word2007/Base.php +++ b/src/PHPWord/Writer/Word2007/Base.php @@ -608,7 +608,11 @@ protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, P } } - protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image) + /** + * @param \PHPWord_Shared_XMLWriter $objWriter + * @param \PHPWord_Section_Image $image + */ + protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Image $image) { $rId = $image->getRelationId(); @@ -616,6 +620,9 @@ protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $imag $width = $style->getWidth(); $height = $style->getHeight(); $align = $style->getAlign(); + $marginTop = $style->getMarginTop(); + $marginLeft = $style->getMarginLeft(); + $wrappingStyle = $style->getWrappingStyle(); $objWriter->startElement('w:p'); @@ -633,7 +640,37 @@ protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $imag $objWriter->startElement('v:shape'); $objWriter->writeAttribute('type', '#_x0000_t75'); - $objWriter->writeAttribute('style', 'width:' . $width . 'px;height:' . $height . 'px'); + + $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 PHPWord_Style_Image::WRAPPING_STYLE_BEHIND: + $imgStyle .= 'position:absolute;z-index:-251658752;'; + break; + case 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: + $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: + $imgStyle .= 'position:absolute;zz-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; + break; + } + + $objWriter->writeAttribute('style', $imgStyle); $objWriter->startElement('v:imagedata'); $objWriter->writeAttribute('r:id', 'rId' . $rId); @@ -733,4 +770,4 @@ protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo $objWriter->endElement(); } -} +} \ No newline at end of file From 50a9ab52b051eef82595e77029301c4d11353a9d Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Wed, 11 Dec 2013 15:08:54 -0500 Subject: [PATCH 05/11] Added Unit Tests and fixed bugs with Autoloader --- .gitignore | 1 + composer.json | 3 +++ phpunit.xml.dist | 16 ++++++++++++++++ src/PHPWord.php | 4 ++-- src/PHPWord/Autoloader.php | 17 +++++++---------- test/PHPWord/Tests/AutoloaderTest.php | 14 ++++++++++++++ test/PHPWord/Tests/_files/.gitkeep | 0 test/bootstrap.php | 4 ++++ 8 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 test/PHPWord/Tests/AutoloaderTest.php create mode 100644 test/PHPWord/Tests/_files/.gitkeep create mode 100644 test/bootstrap.php diff --git a/.gitignore b/.gitignore index 4553eaa28c..23e11e8e99 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ Desktop.ini .idea phpunit.xml composer.lock +composer.phar vendor /.settings /.buildpath diff --git a/composer.json b/composer.json index 3d111441a8..80cb3484c5 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,9 @@ "require": { "php": ">=5.2.0" }, + "require-dev": { + "phpunit/phpunit": "3.7.28" + }, "autoload": { "psr-0": { "PHPWord": "src/" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e69de29bb2..edb893a757 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + ./test/PHPWord/ + + + \ No newline at end of file diff --git a/src/PHPWord.php b/src/PHPWord.php index 6ff77a0a19..78dec75d09 100644 --- a/src/PHPWord.php +++ b/src/PHPWord.php @@ -28,8 +28,8 @@ /** PHPWORD_BASE_PATH */ if (!defined('PHPWORD_BASE_PATH')) { define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/'); - require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php'; - PHPWord_Autoloader::Register(); + require_once PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php'; + PHPWord_Autoloader::register(); } diff --git a/src/PHPWord/Autoloader.php b/src/PHPWord/Autoloader.php index dc48ef91ad..7c39830c49 100644 --- a/src/PHPWord/Autoloader.php +++ b/src/PHPWord/Autoloader.php @@ -25,6 +25,8 @@ * @version Beta 0.6.3, 08.07.2011 */ +define('PHPWORD_BASE_PATH', realpath(__DIR__ . '/../')); + class PHPWord_Autoloader { /** @@ -45,17 +47,12 @@ public static function register() */ public static function load($strObjectName) { - if ((class_exists($strObjectName)) || (strpos($strObjectName, 'PHPWord') === false)) { - return null; - } - - $strObjectFilePath = PHPWORD_BASE_PATH . str_replace('_', '/', $strObjectName) . '.php'; - - if ((file_exists($strObjectFilePath) === false) || (is_readable($strObjectFilePath) === false)) { - return null; + $strObjectFilePath = __DIR__ . '/../' . str_replace('_', '/', $strObjectName) . '.php'; + if (file_exists($strObjectFilePath) && is_readable($strObjectFilePath)) { + require_once $strObjectFilePath; + return true; } - require_once $strObjectFilePath; - return true; + return null; } } \ No newline at end of file diff --git a/test/PHPWord/Tests/AutoloaderTest.php b/test/PHPWord/Tests/AutoloaderTest.php new file mode 100644 index 0000000000..cdfcf68e01 --- /dev/null +++ b/test/PHPWord/Tests/AutoloaderTest.php @@ -0,0 +1,14 @@ +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'); + } +} \ No newline at end of file diff --git a/test/PHPWord/Tests/_files/.gitkeep b/test/PHPWord/Tests/_files/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 0000000000..564f3f768b --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,4 @@ + Date: Wed, 11 Dec 2013 15:34:07 -0500 Subject: [PATCH 06/11] Fixed bug with autoloader --- src/PHPWord/Autoloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 src/PHPWord/Autoloader.php diff --git a/src/PHPWord/Autoloader.php b/src/PHPWord/Autoloader.php old mode 100644 new mode 100755 index 7c39830c49..165850d258 --- a/src/PHPWord/Autoloader.php +++ b/src/PHPWord/Autoloader.php @@ -25,7 +25,7 @@ * @version Beta 0.6.3, 08.07.2011 */ -define('PHPWORD_BASE_PATH', realpath(__DIR__ . '/../')); +define('PHPWORD_BASE_PATH', realpath(__DIR__ . '/../') . '/'); class PHPWord_Autoloader { From d8ea62c50eba1e1f381ab48b02c46dcc0e9859fc Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Wed, 11 Dec 2013 16:09:58 -0500 Subject: [PATCH 07/11] Added test for image wrapping behind --- test/PHPWord/TestHelper.php | 113 +++++++++++++++++++++ test/PHPWord/Tests/ImageTest.php | 38 +++++++ test/PHPWord/Tests/_files/.gitkeep | 0 test/PHPWord/Tests/_files/images/earth.jpg | Bin 0 -> 37654 bytes test/PHPWord/Tests/_files/images/mars.jpg | Bin 0 -> 24524 bytes test/bootstrap.php | 6 +- 6 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 test/PHPWord/TestHelper.php create mode 100644 test/PHPWord/Tests/ImageTest.php delete mode 100644 test/PHPWord/Tests/_files/.gitkeep create mode 100644 test/PHPWord/Tests/_files/images/earth.jpg create mode 100644 test/PHPWord/Tests/_files/images/mars.jpg diff --git a/test/PHPWord/TestHelper.php b/test/PHPWord/TestHelper.php new file mode 100644 index 0000000000..db626428ad --- /dev/null +++ b/test/PHPWord/TestHelper.php @@ -0,0 +1,113 @@ +save(__DIR__ . '/Tests/_files/test.docx'); + + $zip = new \ZipArchive; + $res = $zip->open(__DIR__ . '/Tests/_files/test.docx'); + if ($res === true) { + $zip->extractTo(__DIR__ . '/Tests/_files/test/'); + $zip->close(); + } + + return new Doc(__DIR__ . '/Tests/_files/test/'); + } + + public static function clear() + { + unlink(__DIR__ . '/Tests/_files/test.docx'); + self::deleteDir(__DIR__ . '/Tests/_files/test/'); + } + + /** + * @param string $dir + */ + public static function deleteDir($dir) + { + foreach (scandir($dir) as $file) { + if ($file === '.' || $file === '..') { + continue; + } else if (is_file($dir . "/" . $file)) { + unlink($dir . "/" . $file); + } else if (is_dir($dir . "/" . $file)) { + self::deleteDir($dir . "/" . $file); + } + } + + rmdir($dir); + } +} + +class Doc +{ + /** @var string $path */ + private $path; + + /** @var \DOMDocument $dom */ + private $dom; + + /** @var \DOMXpath $xpath */ + private $xpath; + + /** @var string $file */ + private $file; + + /** + * @param string $path + */ + public function __construct($path) + { + $this->path = realpath($path); + } + + /** + * @param string $file + * @return \DOMDocument + */ + public function getFileDom($file = 'word/document.xml') + { + if (null !== $this->dom && $file === $this->file) { + return $this->dom; + } + + $this->xpath = null; + $this->file = $file; + + $file = $this->path . '/' . $file; + $this->dom = new DOMDocument(); + $this->dom->load($file); + return $this->dom; + } + + /** + * @param string $path + * @param string $file + * @return \DOMElement + */ + public function getElement($path, $file = 'word/document.xml') + { + if ($this->dom === null || $file !== $this->file) { + $this->getFileDom($file); + } + + if (null === $this->xpath) { + $this->xpath = new \DOMXpath($this->dom); + + } + + $elements = $this->xpath->query($path); + return $elements->item(0); + } +} \ No newline at end of file diff --git a/test/PHPWord/Tests/ImageTest.php b/test/PHPWord/Tests/ImageTest.php new file mode 100644 index 0000000000..c1ee9afd0d --- /dev/null +++ b/test/PHPWord/Tests/ImageTest.php @@ -0,0 +1,38 @@ +createSection(12240, 15840, 0, 0, 0, 0); + + $section->addImage( + __DIR__ . '/_files/images/earth.jpg', + array( + 'marginTop' => -1, + 'marginLeft' => -1, + 'wrappingStyle' => 'behind' + ) + ); + + $doc = TestHelper::getDocument($PHPWord); + $element = $doc->getElement('/w:document/w:body/w:p/w:r/w:pict/v:shape'); + + $style = $element->getAttribute('style'); + + $this->assertRegExp('/z\-index:\-[0-9]*/', $style); + $this->assertRegExp('/position:absolute;/', $style); + } +} \ No newline at end of file diff --git a/test/PHPWord/Tests/_files/.gitkeep b/test/PHPWord/Tests/_files/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/PHPWord/Tests/_files/images/earth.jpg b/test/PHPWord/Tests/_files/images/earth.jpg new file mode 100644 index 0000000000000000000000000000000000000000..28537b069ee4f205ae077245a48fff4020463339 GIT binary patch literal 37654 zcmdSAWmFtd)GgR(;{*ah8*Q8r92%G4?oNUS4bV6tSRe#K@tW)Zc}_>wssfiYkf#G&BGJ?cWCY`vee| z*Hw_!*U}YZaIk&p=ip}W@V0Vs^zvtr zWDpU;`@0N~2jF011F^AifIuKFE)E_686g2aJ^>Z!b7C?OH9Z}OnwFLU%)`dO#LY}g z%Pzvf&C4e!C`iu+krd^Z;1Lky|Bs8H;o{;F;1f_15>oOr(lYY@UmkyZ03lT`hO&`(EjTH{7(Z79Rm{!8;FC8hyQN^;u!!P4Fdxm69Wqi6Z7Bf zpnvB9m?T)FjC``#&vmSTOde$Xp-F`}%yJFA^ywEW*F))Gu!3z!D_a87wFtHf1$2LtTYLV%djS^QU^)8_YX6nl{}{2b|69!dXJY>guO$Eh2HL-u zhd~062HZVGvlpQM{|X%LT225}j!ia6vY8l1u3+5Kq6PD?=oW4k$%;PBHGp?d(2}URsk&e9-9M?wP{7&;V670!=8UN9MwN}1F{T6K9 zMK{{ZpS~l4HWLP@8Fl5E8<1BZY)_QBqnY@K6l(7qa2wup$Xxcb+?Am;8&axW!CPqh z?J|`p9P!BS+y=8~yD;(pWtK2kp;FNfDj6ZzqVeQ1Q1NX1hh}=cJLNKHvc38vdYyP8!+C(3rP-N*4G1i_|KW_cD=!Z>iB)lU zvF`3S!KoI^bo}*4b&>H!912fbXI#S<1RMG|^J^>su9MDucAy!q-Q;s#*!qP8h?R3f z|C!80sNm%J0-QdGf^u?1z~F_rVg@ZfeX_k)beh@E_J&M|s1o!46~@x9e1-Cv=!oon=; zpZvBC2DG#Leykr8aMk6byDnI3RSd{8i4u%t-sjB3ZrFdffQAvz7~pzU=-omuYp<2! zBB_~ZY9*Z_MwD7vnG<$&r>MS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-ohYk(U7*zS0$?utp0^z8M^0tgVW;v0F={+4Dns`|${jGC5)@Q8Bm za(Q5ox)A5;j>=<`AC3w)T^_3`$?TcxXL3-`+|D~WzCdVHjc@&Rl*}d7fZ}&=yNVN} z{w3x5H&Ooo+nbEibi6r?Y$VG8NHw?O1TO%G)WE>!xvsB|okkJDyas_qNw7C_B3TZu2QmKS0PO_x% LciK@|e@y=q%=4v= literal 0 HcmV?d00001 diff --git a/test/PHPWord/Tests/_files/images/mars.jpg b/test/PHPWord/Tests/_files/images/mars.jpg new file mode 100644 index 0000000000000000000000000000000000000000..584d3171c9dba89241a90267bf0e1c6e0f06f331 GIT binary patch literal 24524 zcmb4qV{|25x9*N@+qP|W*wIcpwrzK8bkebH+qOFHSUYCN>fq*mzjN<7tOFzfu+Y#j&`_{2Ffed%u<(eO zNQejshoZXW{xG*~b%uowt1asW6Q7z7&F#}I%3004&o`yB3nHwZ9r zNGNES&rUor!2i_;00W1Bg!)(mAVPovz)>Mk0RXV)CjbU4zz_f+rG%w~rIt}OrMJC= zNfi!kCSez@hIm%F>oUHAY2JfD+z2DB!(xPzjV~t^Bh5<#K>z2V3gCv|pLWIpUv%jT zOP8Yue~r1oT;TRm6}<1J7Bta7)}ik$8?J~017qw6`c;cW)s1b_h) zK93S=+<%M(e3}FY|GQ+iu`V?Tt*9|C-IS@StK3M(zVyX(Q?=qA+{XDvR}YBIh)izC zT3DH@;3PTR2M7Rw1^jdSKkoq!GpfN=X#V7?DUd%2ThTJ4CxFwXUDdBTDsEF5Nb1Xm z<-Mlr`g>21*Emdc8Ikbd=s~4Ku;Fewiy9IDK>W0lmZkuZu$j;7wA|n~PXwxJd}D7_ zdZ^x$?KY?XtvaX@2^7Ky&4($PyV6-Vsm@RRZc?qbLz4WmWV~Z~_|RxGJw?rZ2*4Z~ z{Io?)jR7HQHK$|J9Z|KEjM--L^Q2TedPWZ;r*L+vlX@vt17T7d!{*l;B0=NojRA5K zI$t%5My0fBMD^~pv2;W{owNkslaFup(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!UF3Qwer4iHqDk^FpD_pwE&<$Z$HriXUfQ$igOk@#9~G>^b`ZXY z5G1L#$H&x8OrZqskjK_nW@x1=x1u)O3#&@;VD2~+4Tb?f8-^i4ou59)P%FKj%J`W? zK!r@}!v;iM$Hy=g51Rh>F-A>Yl~GR=X$C5Lj7t$)@7xo}Z0HA<2h3S@FnvB((DxCB z$3f6&JRj=e`kBx8>-=;64|OkJ=b57yT0NWiF(44$L(!w?B{HzrQu+*9EVp~_tI0D$ z&Nh3fT#=v|<;Z->i@~EMdd@y#3|Jhxj;~M5tGe=|FOYL8t(C@4vEJlw0~S`<(v(o6NuS$LZnvzmN03)J{LgAK~(|Wxry>6{Yt6t;u}| zHUsCA^t0|jO#%)2ixMh6pLA{$70V@8DHn#5gnpmAOs>3U%3Q9`Kd6nYj zWqiu{p6N>Fc}*2Eq%gn`eo#7lvoC8AK4><7vvP_zYvL=0S8a32c%md`zcfD)E?B4b z3WFdCTc2|Qr_!*M>XCx}(%0rw%%_=3=2y(8nO`!#WjxACN=qfd7cD?Vkz;)&#k&6h H^&kJ)m~{Io literal 0 HcmV?d00001 diff --git a/test/bootstrap.php b/test/bootstrap.php index 564f3f768b..0ca799f67c 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,4 +1,8 @@ Date: Wed, 11 Dec 2013 16:17:53 -0500 Subject: [PATCH 08/11] Moved image example to README.md --- Examples/Image.php | 24 ------------------------ README.md | 33 ++++++++++++++++++++++++++++++++- changelog.txt | 3 ++- 3 files changed, 34 insertions(+), 26 deletions(-) delete mode 100644 Examples/Image.php diff --git a/Examples/Image.php b/Examples/Image.php deleted file mode 100644 index 8362a2dcb3..0000000000 --- a/Examples/Image.php +++ /dev/null @@ -1,24 +0,0 @@ -createSection(); - -// Add image elements -$section->addImage('_mars.jpg'); -$section->addTextBreak(2); - -$section->addImage('_earth.JPG', array('width'=>210, 'height'=>210, 'align'=>'center')); -$section->addTextBreak(2); - -$section->addImage('_mars.jpg', array('width'=>100, 'height'=>100, 'align'=>'right')); - - - -// Save File -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save('Image.docx'); -?> \ No newline at end of file diff --git a/README.md b/README.md index cac0d1193a..1a5911de3a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ the following lines to your ``composer.json``. The following is a basic example of the PHPWord library. ```php -// Create a new PHPWord Object $PHPWord = new PHPWord(); // Every element you want to append to the word document is placed in a section. So you need a section: @@ -59,3 +58,35 @@ $myTextElement->setSize(22); $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('helloWorld.docx'); ``` + +## Image + +You can add images easily using the following example. + +```php +$section = $PHPWord->createSection(); +$section->addImage('mars.jpg'); +``` + +Images settings include: + * ``width`` width in pixels + * ``height`` height in pixels + * ``align`` image alignment, __left__, __right__ or __center__ + * ``marginTop`` top margin in inches, can be negative + * ``marginLeft`` left margin in inches, can be negative + * ``wrappingStyle`` can be inline, __square__, __tight__, __behind__, __infront__ + + To add an image with settings, consider the following example. + + ```php +$section->addImage( + 'mars.jpg', + array( + 'width' => 100, + 'height' => 100, + 'marginTop' => -1, + 'marginLeft' => -1, + wrappingStyle => 'behind' + ) +); + ``` diff --git a/changelog.txt b/changelog.txt index abd7d3dad6..288aab2454 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,2 +1,3 @@ 2013-12-11 (v1.0): -- Feature: (gavroche) Added composer file \ No newline at end of file +- Feature: (gavroche) Added composer file +- Feature: (gavroche) Added support for image wrapping style \ No newline at end of file From be1e357b83bcf5721c795e00518c64e16d85b8b1 Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Wed, 11 Dec 2013 19:57:36 -0500 Subject: [PATCH 09/11] Changed version number --- README.md | 2 +- changelog.txt | 2 +- composer.json | 2 +- src/PHPWord.php | 13 ++++--------- src/PHPWord/Autoloader.php | 9 ++++++--- src/PHPWord/DocumentProperties.php | 10 +++------- src/PHPWord/HashTable.php | 10 +++------- src/PHPWord/IOFactory.php | 13 ++++--------- src/PHPWord/Media.php | 14 ++++---------- src/PHPWord/Section.php | 13 ++++--------- src/PHPWord/Section/Footer.php | 13 ++++--------- src/PHPWord/Section/Footer/PreserveText.php | 13 ++++--------- src/PHPWord/Section/Header.php | 13 ++++--------- src/PHPWord/Section/Image.php | 13 ++++--------- src/PHPWord/Section/Link.php | 13 ++++--------- src/PHPWord/Section/ListItem.php | 13 ++++--------- src/PHPWord/Section/MemoryImage.php | 13 ++++--------- src/PHPWord/Section/Object.php | 13 ++++--------- src/PHPWord/Section/PageBreak.php | 13 ++++--------- src/PHPWord/Section/Settings.php | 13 ++++--------- src/PHPWord/Section/Table.php | 13 ++++--------- src/PHPWord/Section/Table/Cell.php | 13 ++++--------- src/PHPWord/Section/Text.php | 13 ++++--------- src/PHPWord/Section/TextBreak.php | 13 ++++--------- src/PHPWord/Section/TextRun.php | 13 ++++--------- src/PHPWord/Section/Title.php | 13 ++++--------- src/PHPWord/Shared/Drawing.php | 10 ++++++---- src/PHPWord/Shared/File.php | 10 ++++++---- src/PHPWord/Shared/Font.php | 10 ++++++---- src/PHPWord/Shared/String.php | 10 ++++++---- src/PHPWord/Shared/XMLWriter.php | 10 +++------- src/PHPWord/Shared/ZipStreamWrapper.php | 11 ++++++----- src/PHPWord/Style.php | 13 ++++--------- src/PHPWord/Style/Cell.php | 13 ++++--------- src/PHPWord/Style/Font.php | 13 ++++--------- src/PHPWord/Style/Image.php | 13 ++++--------- src/PHPWord/Style/ListItem.php | 13 ++++--------- src/PHPWord/Style/Paragraph.php | 13 ++++--------- src/PHPWord/Style/TOC.php | 13 ++++--------- src/PHPWord/Style/Table.php | 10 ++++++---- src/PHPWord/Style/TableFull.php | 13 ++++--------- src/PHPWord/TOC.php | 13 ++++--------- src/PHPWord/Template.php | 13 ++++--------- src/PHPWord/Writer/IWriter.php | 10 ++++++---- src/PHPWord/Writer/ODText.php | 9 ++++++--- src/PHPWord/Writer/ODText/Content.php | 15 +++++---------- src/PHPWord/Writer/ODText/Manifest.php | 15 +++++---------- src/PHPWord/Writer/ODText/Meta.php | 15 +++++---------- src/PHPWord/Writer/ODText/Mimetype.php | 15 +++++---------- src/PHPWord/Writer/ODText/Styles.php | 15 +++++---------- src/PHPWord/Writer/ODText/WriterPart.php | 15 +++++---------- src/PHPWord/Writer/RTF.php | 9 ++++++--- src/PHPWord/Writer/Word2007.php | 10 ++++++---- src/PHPWord/Writer/Word2007/Base.php | 10 ++++++---- src/PHPWord/Writer/Word2007/ContentTypes.php | 10 ++++++---- src/PHPWord/Writer/Word2007/DocProps.php | 10 ++++++---- src/PHPWord/Writer/Word2007/Document.php | 10 ++++++---- src/PHPWord/Writer/Word2007/DocumentRels.php | 10 ++++++---- src/PHPWord/Writer/Word2007/Footer.php | 10 ++++++---- src/PHPWord/Writer/Word2007/Header.php | 10 ++++++---- src/PHPWord/Writer/Word2007/Rels.php | 10 ++++++---- src/PHPWord/Writer/Word2007/Styles.php | 10 ++++++---- src/PHPWord/Writer/Word2007/WriterPart.php | 10 ++++++---- 63 files changed, 288 insertions(+), 437 deletions(-) diff --git a/README.md b/README.md index 1a5911de3a..b23011b5e8 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Fork us! ## Requirements -* PHP version 5.2.0 or higher +* PHP version 5.3.0 or higher ## License PHPWord is licensed under [LGPL (GNU LESSER GENERAL PUBLIC LICENSE)](https://github.com/PHPOffice/PHPWord/blob/master/license.md) diff --git a/changelog.txt b/changelog.txt index 288aab2454..a632a34fad 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,3 @@ -2013-12-11 (v1.0): +2013-12-11 (v0.7.0): - Feature: (gavroche) Added composer file - Feature: (gavroche) Added support for image wrapping style \ No newline at end of file diff --git a/composer.json b/composer.json index 80cb3484c5..888f3bac67 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=5.2.0" + "php": ">=5.3.0" }, "require-dev": { "phpunit/phpunit": "3.7.28" diff --git a/src/PHPWord.php b/src/PHPWord.php index 78dec75d09..9fbe125a3b 100644 --- a/src/PHPWord.php +++ b/src/PHPWord.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,9 +20,9 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ /** PHPWORD_BASE_PATH */ @@ -32,13 +32,8 @@ PHPWord_Autoloader::register(); } - /** - * PHPWord - * - * @category PHPWord - * @package PHPWord - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord */ class PHPWord { diff --git a/src/PHPWord/Autoloader.php b/src/PHPWord/Autoloader.php index 165850d258..dbe1322d2c 100755 --- a/src/PHPWord/Autoloader.php +++ b/src/PHPWord/Autoloader.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,13 +20,16 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ define('PHPWORD_BASE_PATH', realpath(__DIR__ . '/../') . '/'); +/** + * Class PHPWord_Autoloader + */ class PHPWord_Autoloader { /** diff --git a/src/PHPWord/DocumentProperties.php b/src/PHPWord/DocumentProperties.php index 5a9023893b..f2a0904d08 100644 --- a/src/PHPWord/DocumentProperties.php +++ b/src/PHPWord/DocumentProperties.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ /** * PHPWord_DocumentProperties - * - * @category PHPWord - * @package PHPWord - * @copyright Copyright (c) 2009 - 2011 PHPWord (http://www.codeplex.com/PHPWord) */ class PHPWord_DocumentProperties { diff --git a/src/PHPWord/HashTable.php b/src/PHPWord/HashTable.php index fc253e9731..c32e0abbd3 100644 --- a/src/PHPWord/HashTable.php +++ b/src/PHPWord/HashTable.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2009 - 2010 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ /** * PHPWord_HashTable - * - * @category PHPWord - * @package PHPWord - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) */ class PHPWord_HashTable { diff --git a/src/PHPWord/IOFactory.php b/src/PHPWord/IOFactory.php index dcf2a316d7..a07a72db22 100644 --- a/src/PHPWord/IOFactory.php +++ b/src/PHPWord/IOFactory.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_IOFactory - * - * @category PHPWord - * @package PHPWord - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_IOFactory */ class PHPWord_IOFactory { diff --git a/src/PHPWord/Media.php b/src/PHPWord/Media.php index 6cdc92b921..044db8f78f 100644 --- a/src/PHPWord/Media.php +++ b/src/PHPWord/Media.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Media - * - * @category PHPWord - * @package PHPWord - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Media */ class PHPWord_Media { @@ -72,7 +67,6 @@ class PHPWord_Media * * @param string $src * @param string $type - * * @return mixed */ public static function addSectionMediaElement($src, $type, PHPWord_Section_MemoryImage $memoryImage = null) diff --git a/src/PHPWord/Section.php b/src/PHPWord/Section.php index abfa42ec71..38bb63d5e6 100644 --- a/src/PHPWord/Section.php +++ b/src/PHPWord/Section.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section */ class PHPWord_Section { diff --git a/src/PHPWord/Section/Footer.php b/src/PHPWord/Section/Footer.php index 115153b3f6..a21031fcc4 100644 --- a/src/PHPWord/Section/Footer.php +++ b/src/PHPWord/Section/Footer.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Footer - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Footer */ class PHPWord_Section_Footer { diff --git a/src/PHPWord/Section/Footer/PreserveText.php b/src/PHPWord/Section/Footer/PreserveText.php index c4cf177753..7d08712f0f 100644 --- a/src/PHPWord/Section/Footer/PreserveText.php +++ b/src/PHPWord/Section/Footer/PreserveText.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Footer_PreserveText - * - * @category PHPWord - * @package PHPWord_Section_Footer - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Footer_PreserveText */ class PHPWord_Section_Footer_PreserveText { diff --git a/src/PHPWord/Section/Header.php b/src/PHPWord/Section/Header.php index dc55d62d40..fff730fdda 100644 --- a/src/PHPWord/Section/Header.php +++ b/src/PHPWord/Section/Header.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Header - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Header */ class PHPWord_Section_Header { diff --git a/src/PHPWord/Section/Image.php b/src/PHPWord/Section/Image.php index 3df4f9e826..e994fb959f 100644 --- a/src/PHPWord/Section/Image.php +++ b/src/PHPWord/Section/Image.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Image - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Image */ class PHPWord_Section_Image { diff --git a/src/PHPWord/Section/Link.php b/src/PHPWord/Section/Link.php index d981c45e95..551eb4f211 100644 --- a/src/PHPWord/Section/Link.php +++ b/src/PHPWord/Section/Link.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Link - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Link */ class PHPWord_Section_Link { diff --git a/src/PHPWord/Section/ListItem.php b/src/PHPWord/Section/ListItem.php index 0b6625e3fb..e6a1ac76cf 100644 --- a/src/PHPWord/Section/ListItem.php +++ b/src/PHPWord/Section/ListItem.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_ListItem - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_ListItem */ class PHPWord_Section_ListItem { diff --git a/src/PHPWord/Section/MemoryImage.php b/src/PHPWord/Section/MemoryImage.php index 6144595156..f1a027e28d 100644 --- a/src/PHPWord/Section/MemoryImage.php +++ b/src/PHPWord/Section/MemoryImage.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_MemoryImage - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_MemoryImage */ class PHPWord_Section_MemoryImage { diff --git a/src/PHPWord/Section/Object.php b/src/PHPWord/Section/Object.php index 63b1106930..40aa272c86 100644 --- a/src/PHPWord/Section/Object.php +++ b/src/PHPWord/Section/Object.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Object - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Object */ class PHPWord_Section_Object { diff --git a/src/PHPWord/Section/PageBreak.php b/src/PHPWord/Section/PageBreak.php index 9a9c76ec90..bdaf58eaf0 100644 --- a/src/PHPWord/Section/PageBreak.php +++ b/src/PHPWord/Section/PageBreak.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_PageBreak - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_PageBreak */ class PHPWord_Section_PageBreak { diff --git a/src/PHPWord/Section/Settings.php b/src/PHPWord/Section/Settings.php index a83192dc32..fa30c367f4 100644 --- a/src/PHPWord/Section/Settings.php +++ b/src/PHPWord/Section/Settings.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Settings - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Settings */ class PHPWord_Section_Settings { diff --git a/src/PHPWord/Section/Table.php b/src/PHPWord/Section/Table.php index 94878e8183..3c9cbfb75d 100644 --- a/src/PHPWord/Section/Table.php +++ b/src/PHPWord/Section/Table.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Table - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Table */ class PHPWord_Section_Table { diff --git a/src/PHPWord/Section/Table/Cell.php b/src/PHPWord/Section/Table/Cell.php index e9eb1d1b57..48c9de8178 100644 --- a/src/PHPWord/Section/Table/Cell.php +++ b/src/PHPWord/Section/Table/Cell.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Table_Cell - * - * @category PHPWord - * @package PHPWord_Section_Table - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Table_Cell */ class PHPWord_Section_Table_Cell { diff --git a/src/PHPWord/Section/Text.php b/src/PHPWord/Section/Text.php index 340ae92a4a..72ff4333ca 100644 --- a/src/PHPWord/Section/Text.php +++ b/src/PHPWord/Section/Text.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Text - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Text */ class PHPWord_Section_Text { diff --git a/src/PHPWord/Section/TextBreak.php b/src/PHPWord/Section/TextBreak.php index 37d5f72cb4..0339521dc3 100644 --- a/src/PHPWord/Section/TextBreak.php +++ b/src/PHPWord/Section/TextBreak.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_TextBreak - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_TextBreak */ class PHPWord_Section_TextBreak { diff --git a/src/PHPWord/Section/TextRun.php b/src/PHPWord/Section/TextRun.php index d4cde48029..2ff89044b4 100644 --- a/src/PHPWord/Section/TextRun.php +++ b/src/PHPWord/Section/TextRun.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_TextRun - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_TextRun */ class PHPWord_Section_TextRun { diff --git a/src/PHPWord/Section/Title.php b/src/PHPWord/Section/Title.php index 1aea31b2fa..3e7f2f43fc 100644 --- a/src/PHPWord/Section/Title.php +++ b/src/PHPWord/Section/Title.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section_Title - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section_Title */ class PHPWord_Section_Title { diff --git a/src/PHPWord/Shared/Drawing.php b/src/PHPWord/Shared/Drawing.php index 00b4a44fc2..8f93344e3e 100644 --- a/src/PHPWord/Shared/Drawing.php +++ b/src/PHPWord/Shared/Drawing.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Shared_Drawing + */ class PHPWord_Shared_Drawing { /** diff --git a/src/PHPWord/Shared/File.php b/src/PHPWord/Shared/File.php index 12e7c42461..bd214eef73 100644 --- a/src/PHPWord/Shared/File.php +++ b/src/PHPWord/Shared/File.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Shared_File + */ class PHPWord_Shared_File { /** diff --git a/src/PHPWord/Shared/Font.php b/src/PHPWord/Shared/Font.php index ec1d47014f..4dc0a54d99 100644 --- a/src/PHPWord/Shared/Font.php +++ b/src/PHPWord/Shared/Font.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Shared_Font + */ class PHPWord_Shared_Font { /** diff --git a/src/PHPWord/Shared/String.php b/src/PHPWord/Shared/String.php index 1085f66d86..1e703893e5 100644 --- a/src/PHPWord/Shared/String.php +++ b/src/PHPWord/Shared/String.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Shared_String + */ class PHPWord_Shared_String { /** diff --git a/src/PHPWord/Shared/XMLWriter.php b/src/PHPWord/Shared/XMLWriter.php index 7d62b82a16..7144f9cc17 100644 --- a/src/PHPWord/Shared/XMLWriter.php +++ b/src/PHPWord/Shared/XMLWriter.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,11 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - if (!defined('DATE_W3C')) { define('DATE_W3C', 'Y-m-d\TH:i:sP'); } @@ -33,9 +32,6 @@ /** * Class PHPWord_Shared_XMLWriter * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord * @method bool startElement(string $name) * @method bool writeAttribute(string $name, string $value) * @method bool endElement() diff --git a/src/PHPWord/Shared/ZipStreamWrapper.php b/src/PHPWord/Shared/ZipStreamWrapper.php index 106d0ec919..575327586a 100644 --- a/src/PHPWord/Shared/ZipStreamWrapper.php +++ b/src/PHPWord/Shared/ZipStreamWrapper.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,16 +20,17 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** Register new zip wrapper */ PHPWord_Shared_ZipStreamWrapper::register(); - +/** + * Class PHPWord_Shared_ZipStreamWrapper + */ class PHPWord_Shared_ZipStreamWrapper { /** diff --git a/src/PHPWord/Style.php b/src/PHPWord/Style.php index afd2840f26..18f2212384 100644 --- a/src/PHPWord/Style.php +++ b/src/PHPWord/Style.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Style - * - * @category PHPWord - * @package PHPWord_Style - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Style */ class PHPWord_Style { diff --git a/src/PHPWord/Style/Cell.php b/src/PHPWord/Style/Cell.php index f8db60e855..0c294f297d 100644 --- a/src/PHPWord/Style/Cell.php +++ b/src/PHPWord/Style/Cell.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Style_Cell - * - * @category PHPWord - * @package PHPWord_Style - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Style_Cell */ class PHPWord_Style_Cell { diff --git a/src/PHPWord/Style/Font.php b/src/PHPWord/Style/Font.php index e3b5a89e9a..4b39120529 100644 --- a/src/PHPWord/Style/Font.php +++ b/src/PHPWord/Style/Font.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Style_Font - * - * @category PHPWord - * @package PHPWord_Style - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Style_Font */ class PHPWord_Style_Font { diff --git a/src/PHPWord/Style/Image.php b/src/PHPWord/Style/Image.php index 556d53f303..1d81806064 100644 --- a/src/PHPWord/Style/Image.php +++ b/src/PHPWord/Style/Image.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Style_Image - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Style_Image */ class PHPWord_Style_Image { diff --git a/src/PHPWord/Style/ListItem.php b/src/PHPWord/Style/ListItem.php index 1ff7cb50a7..498b88e9aa 100644 --- a/src/PHPWord/Style/ListItem.php +++ b/src/PHPWord/Style/ListItem.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Style_ListItem - * - * @category PHPWord - * @package PHPWord_Style - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Style_ListItem */ class PHPWord_Style_ListItem { diff --git a/src/PHPWord/Style/Paragraph.php b/src/PHPWord/Style/Paragraph.php index a7b0f5d995..c92933d2b8 100644 --- a/src/PHPWord/Style/Paragraph.php +++ b/src/PHPWord/Style/Paragraph.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Style_Paragraph - * - * @category PHPWord - * @package PHPWord_Style - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Style_Paragraph */ class PHPWord_Style_Paragraph { diff --git a/src/PHPWord/Style/TOC.php b/src/PHPWord/Style/TOC.php index 4604b24258..a91add955d 100644 --- a/src/PHPWord/Style/TOC.php +++ b/src/PHPWord/Style/TOC.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Style_TOC - * - * @category PHPWord - * @package PHPWord_Style - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Style_TOC */ class PHPWord_Style_TOC { diff --git a/src/PHPWord/Style/Table.php b/src/PHPWord/Style/Table.php index c60ce4843e..ea54d8d248 100644 --- a/src/PHPWord/Style/Table.php +++ b/src/PHPWord/Style/Table.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Style_Table + */ class PHPWord_Style_Table { diff --git a/src/PHPWord/Style/TableFull.php b/src/PHPWord/Style/TableFull.php index 66b2832323..f19ddd1e04 100644 --- a/src/PHPWord/Style/TableFull.php +++ b/src/PHPWord/Style/TableFull.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Style_TableFull - * - * @category PHPWord - * @package PHPWord_Style - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Style_TableFull */ class PHPWord_Style_TableFull { diff --git a/src/PHPWord/TOC.php b/src/PHPWord/TOC.php index 6c20fd3eb9..5d9a97cb3b 100644 --- a/src/PHPWord/TOC.php +++ b/src/PHPWord/TOC.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_TOC - * - * @category PHPWord - * @package PHPWord_TOC - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_TOC */ class PHPWord_TOC { diff --git a/src/PHPWord/Template.php b/src/PHPWord/Template.php index 44e8bdf499..3704431227 100644 --- a/src/PHPWord/Template.php +++ b/src/PHPWord/Template.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,18 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_DocumentProperties - * - * @category PHPWord - * @package PHPWord - * @copyright Copyright (c) 2009 - 2011 PHPWord (http://www.codeplex.com/PHPWord) + * Class PHPWord_Template */ class PHPWord_Template { diff --git a/src/PHPWord/Writer/IWriter.php b/src/PHPWord/Writer/IWriter.php index 8302bee56b..5e26341af9 100644 --- a/src/PHPWord/Writer/IWriter.php +++ b/src/PHPWord/Writer/IWriter.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Interface PHPWord_Writer_IWriter + */ interface PHPWord_Writer_IWriter { /** diff --git a/src/PHPWord/Writer/ODText.php b/src/PHPWord/Writer/ODText.php index 6ace605f3d..f8b10ab972 100644 --- a/src/PHPWord/Writer/ODText.php +++ b/src/PHPWord/Writer/ODText.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2009 - 2010 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,11 +20,14 @@ * * @category PHPWord * @package PHPWord_Writer_PowerPoint2007 - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ +/** + * Class PHPWord_Writer_ODText + */ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter { /** diff --git a/src/PHPWord/Writer/ODText/Content.php b/src/PHPWord/Writer/ODText/Content.php index c5fd42a7ec..7baac27935 100644 --- a/src/PHPWord/Writer/ODText/Content.php +++ b/src/PHPWord/Writer/ODText/Content.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2009 - 2010 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,19 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @package PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ - /** - * PHPWord_Writer_ODText_Content - * - * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * Class PHPWord_Writer_ODText_Manifest */ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart { diff --git a/src/PHPWord/Writer/ODText/Manifest.php b/src/PHPWord/Writer/ODText/Manifest.php index d2b783f71d..61f9f84dcc 100644 --- a/src/PHPWord/Writer/ODText/Manifest.php +++ b/src/PHPWord/Writer/ODText/Manifest.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2009 - 2010 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,19 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @package PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ - /** - * PHPWord_Writer_ODText_Manifest - * - * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * Class PHPWord_Writer_ODText_Manifest */ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart { diff --git a/src/PHPWord/Writer/ODText/Meta.php b/src/PHPWord/Writer/ODText/Meta.php index e4778a23db..6dd1ba0c33 100644 --- a/src/PHPWord/Writer/ODText/Meta.php +++ b/src/PHPWord/Writer/ODText/Meta.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2009 - 2010 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,19 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @package PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ - /** - * PHPWord_Writer_ODText_Meta - * - * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * Class PHPWord_Writer_ODText_Meta */ class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart { diff --git a/src/PHPWord/Writer/ODText/Mimetype.php b/src/PHPWord/Writer/ODText/Mimetype.php index 9190ca842c..b88d7d4f9d 100644 --- a/src/PHPWord/Writer/ODText/Mimetype.php +++ b/src/PHPWord/Writer/ODText/Mimetype.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2009 - 2010 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,19 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @package PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ - /** - * PHPWord_Writer_ODText_Mimetype - * - * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * Class PHPWord_Writer_ODText_Mimetype */ class PHPWord_Writer_ODText_Mimetype extends PHPWord_Writer_ODText_WriterPart { diff --git a/src/PHPWord/Writer/ODText/Styles.php b/src/PHPWord/Writer/ODText/Styles.php index a4d51a25fd..b2ddda00b5 100644 --- a/src/PHPWord/Writer/ODText/Styles.php +++ b/src/PHPWord/Writer/ODText/Styles.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2009 - 2010 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,19 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @package PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ - /** - * PHPWord_Writer_ODText_Styles - * - * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * Class PHPWord_Writer_ODText_Styles */ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart { diff --git a/src/PHPWord/Writer/ODText/WriterPart.php b/src/PHPWord/Writer/ODText/WriterPart.php index 6a04f2e102..0416040cdc 100644 --- a/src/PHPWord/Writer/ODText/WriterPart.php +++ b/src/PHPWord/Writer/ODText/WriterPart.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2009 - 2010 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,19 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPWord - * @package PHPWord_Writer_PowerPoint2007 - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @package PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ - /** - * PHPWord_Writer_ODText_WriterPart - * - * @category PHPWord - * @package PHPWord_Writer_ODText - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * Class PHPWord_Writer_ODText_WriterPart */ abstract class PHPWord_Writer_ODText_WriterPart { diff --git a/src/PHPWord/Writer/RTF.php b/src/PHPWord/Writer/RTF.php index 361ac5c149..24e2681e1d 100644 --- a/src/PHPWord/Writer/RTF.php +++ b/src/PHPWord/Writer/RTF.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2009 - 2010 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,11 +20,14 @@ * * @category PHPWord * @package PHPWord_Writer_RTF - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ +/** + * Class PHPWord_Writer_RTF + */ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter { /** diff --git a/src/PHPWord/Writer/Word2007.php b/src/PHPWord/Writer/Word2007.php index a6551f6fa8..bb9b9da670 100644 --- a/src/PHPWord/Writer/Word2007.php +++ b/src/PHPWord/Writer/Word2007.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007 + */ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter { diff --git a/src/PHPWord/Writer/Word2007/Base.php b/src/PHPWord/Writer/Word2007/Base.php index ae39e1bd89..1c889ddb82 100644 --- a/src/PHPWord/Writer/Word2007/Base.php +++ b/src/PHPWord/Writer/Word2007/Base.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007_Base + */ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart { diff --git a/src/PHPWord/Writer/Word2007/ContentTypes.php b/src/PHPWord/Writer/Word2007/ContentTypes.php index 3afb239db7..e9d1b40cb2 100644 --- a/src/PHPWord/Writer/Word2007/ContentTypes.php +++ b/src/PHPWord/Writer/Word2007/ContentTypes.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007_ContentTypes + */ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_WriterPart { diff --git a/src/PHPWord/Writer/Word2007/DocProps.php b/src/PHPWord/Writer/Word2007/DocProps.php index b94ac0d677..529fe615bb 100644 --- a/src/PHPWord/Writer/Word2007/DocProps.php +++ b/src/PHPWord/Writer/Word2007/DocProps.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007_DocProps + */ class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPart { diff --git a/src/PHPWord/Writer/Word2007/Document.php b/src/PHPWord/Writer/Word2007/Document.php index 247d172f02..e3ecd46e8b 100644 --- a/src/PHPWord/Writer/Word2007/Document.php +++ b/src/PHPWord/Writer/Word2007/Document.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007_Document + */ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base { diff --git a/src/PHPWord/Writer/Word2007/DocumentRels.php b/src/PHPWord/Writer/Word2007/DocumentRels.php index a6d452bb67..a19084a9ad 100644 --- a/src/PHPWord/Writer/Word2007/DocumentRels.php +++ b/src/PHPWord/Writer/Word2007/DocumentRels.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007_DocumentRels + */ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_WriterPart { diff --git a/src/PHPWord/Writer/Word2007/Footer.php b/src/PHPWord/Writer/Word2007/Footer.php index afdd81b39f..d6e03a635d 100644 --- a/src/PHPWord/Writer/Word2007/Footer.php +++ b/src/PHPWord/Writer/Word2007/Footer.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007_Footer + */ class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base { diff --git a/src/PHPWord/Writer/Word2007/Header.php b/src/PHPWord/Writer/Word2007/Header.php index b7d7b2a67f..97d9a7b42c 100644 --- a/src/PHPWord/Writer/Word2007/Header.php +++ b/src/PHPWord/Writer/Word2007/Header.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007_Header + */ class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base { diff --git a/src/PHPWord/Writer/Word2007/Rels.php b/src/PHPWord/Writer/Word2007/Rels.php index 4ea39c6985..39d3740597 100644 --- a/src/PHPWord/Writer/Word2007/Rels.php +++ b/src/PHPWord/Writer/Word2007/Rels.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007_Rels + */ class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart { diff --git a/src/PHPWord/Writer/Word2007/Styles.php b/src/PHPWord/Writer/Word2007/Styles.php index 900f833f45..2253d99511 100644 --- a/src/PHPWord/Writer/Word2007/Styles.php +++ b/src/PHPWord/Writer/Word2007/Styles.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Writer_Word2007_Styles + */ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base { diff --git a/src/PHPWord/Writer/Word2007/WriterPart.php b/src/PHPWord/Writer/Word2007/WriterPart.php index afde53d276..9291d28ca0 100644 --- a/src/PHPWord/Writer/Word2007/WriterPart.php +++ b/src/PHPWord/Writer/Word2007/WriterPart.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +20,14 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Abstract Class PHPWord_Writer_Word2007_WriterPart + */ abstract class PHPWord_Writer_Word2007_WriterPart { private $_parentWriter; From 5c6319f15b799b918821198fca33242ba66c5a19 Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Fri, 13 Dec 2013 09:07:50 -0500 Subject: [PATCH 10/11] Now only define PHPWORD_BASE_PATH once --- src/PHPWord/Autoloader.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PHPWord/Autoloader.php b/src/PHPWord/Autoloader.php index dbe1322d2c..c6b53a74d5 100755 --- a/src/PHPWord/Autoloader.php +++ b/src/PHPWord/Autoloader.php @@ -25,7 +25,9 @@ * @version 0.7.0 */ -define('PHPWORD_BASE_PATH', realpath(__DIR__ . '/../') . '/'); +if (!defined('PHPWORD_BASE_PATH')) { + define('PHPWORD_BASE_PATH', realpath(__DIR__ . '/../') . '/'); +} /** * Class PHPWord_Autoloader From d09f0958c601d4d1e34f9309a99b439f5efedb2c Mon Sep 17 00:00:00 2001 From: Gabriel Bull Date: Mon, 16 Dec 2013 06:40:30 -0500 Subject: [PATCH 11/11] Fixed some merge issues --- Classes/PHPWord.php | 381 ++--- Classes/PHPWord/Autoloader.php | 2 +- Classes/PHPWord/DocumentProperties.php | 5 +- Classes/PHPWord/Exception.php | 45 +- Classes/PHPWord/HashTable.php | 3 +- Classes/PHPWord/IOFactory.php | 2 +- Classes/PHPWord/Media.php | 2 +- Classes/PHPWord/Section.php | 747 ++++----- Classes/PHPWord/Section/Footer.php | 359 ++-- .../PHPWord/Section/Footer/PreserveText.php | 2 +- Classes/PHPWord/Section/Header.php | 504 +++--- Classes/PHPWord/Section/Image.php | 2 +- Classes/PHPWord/Section/Link.php | 2 +- Classes/PHPWord/Section/ListItem.php | 2 +- Classes/PHPWord/Section/MemoryImage.php | 2 +- Classes/PHPWord/Section/Object.php | 2 +- Classes/PHPWord/Section/PageBreak.php | 2 +- Classes/PHPWord/Section/Settings.php | 2 +- Classes/PHPWord/Section/Table.php | 2 +- Classes/PHPWord/Section/Table/Cell.php | 606 +++---- Classes/PHPWord/Section/Text.php | 2 +- Classes/PHPWord/Section/TextBreak.php | 2 +- Classes/PHPWord/Section/TextRun.php | 206 +-- Classes/PHPWord/Section/Title.php | 2 +- Classes/PHPWord/Shared/Drawing.php | 2 +- Classes/PHPWord/Shared/File.php | 2 +- Classes/PHPWord/Shared/Font.php | 2 +- Classes/PHPWord/Shared/String.php | 421 ++--- Classes/PHPWord/Shared/XMLWriter.php | 2 +- Classes/PHPWord/Shared/ZipStreamWrapper.php | 2 +- Classes/PHPWord/Style.php | 2 +- Classes/PHPWord/Style/Cell.php | 611 +++---- Classes/PHPWord/Style/Font.php | 2 +- Classes/PHPWord/Style/Image.php | 2 +- Classes/PHPWord/Style/ListItem.php | 2 +- Classes/PHPWord/Style/Paragraph.php | 400 ++--- Classes/PHPWord/Style/TOC.php | 2 +- Classes/PHPWord/Style/Tab.php | 215 ++- Classes/PHPWord/Style/Table.php | 2 +- Classes/PHPWord/Style/TableFull.php | 2 +- Classes/PHPWord/Style/Tabs.php | 69 +- Classes/PHPWord/TOC.php | 2 +- Classes/PHPWord/Template.php | 96 +- Classes/PHPWord/Writer/IWriter.php | 2 +- Classes/PHPWord/Writer/ODText.php | 4 +- Classes/PHPWord/Writer/ODText/Content.php | 2 +- Classes/PHPWord/Writer/ODText/Manifest.php | 2 +- Classes/PHPWord/Writer/ODText/Meta.php | 2 +- Classes/PHPWord/Writer/ODText/Mimetype.php | 2 +- Classes/PHPWord/Writer/ODText/Styles.php | 2 +- Classes/PHPWord/Writer/ODText/WriterPart.php | 2 +- Classes/PHPWord/Writer/RTF.php | 4 +- Classes/PHPWord/Writer/Word2007.php | 434 ++--- Classes/PHPWord/Writer/Word2007/Base.php | 1459 +++++++++-------- .../PHPWord/Writer/Word2007/ContentTypes.php | 2 +- Classes/PHPWord/Writer/Word2007/DocProps.php | 2 +- Classes/PHPWord/Writer/Word2007/Document.php | 871 +++++----- .../PHPWord/Writer/Word2007/DocumentRels.php | 2 +- Classes/PHPWord/Writer/Word2007/Footer.php | 2 +- Classes/PHPWord/Writer/Word2007/Header.php | 2 +- Classes/PHPWord/Writer/Word2007/Rels.php | 2 +- Classes/PHPWord/Writer/Word2007/Styles.php | 2 +- .../PHPWord/Writer/Word2007/WriterPart.php | 2 +- README.md | 2 +- changelog.txt | 5 +- samples/Sample_01_SimpleText.php | 1 - samples/Sample_02_TabStops.php | 3 +- samples/old/AdvancedTable.php | 1 - samples/old/BasicTable.php | 1 - samples/old/HeaderFooter.php | 1 - samples/old/Image.php | 1 - samples/old/Link.php | 1 - samples/old/ListItem.php | 1 - samples/old/Object.php | 1 - samples/old/Section.php | 1 - samples/old/Template.php | 1 - samples/old/Textrun.php | 1 - samples/old/TitleTOC.php | 1 - samples/old/Watermark.php | 1 - test/PHPWord/Tests/ImageTest.php | 2 - test/bootstrap.php | 2 +- 81 files changed, 3852 insertions(+), 3701 deletions(-) mode change 100644 => 100755 Classes/PHPWord.php mode change 100644 => 100755 Classes/PHPWord/DocumentProperties.php mode change 100644 => 100755 Classes/PHPWord/Exception.php mode change 100644 => 100755 Classes/PHPWord/HashTable.php mode change 100644 => 100755 Classes/PHPWord/IOFactory.php mode change 100644 => 100755 Classes/PHPWord/Media.php mode change 100644 => 100755 Classes/PHPWord/Section.php mode change 100644 => 100755 Classes/PHPWord/Section/Footer.php mode change 100644 => 100755 Classes/PHPWord/Section/Footer/PreserveText.php mode change 100644 => 100755 Classes/PHPWord/Section/Header.php mode change 100644 => 100755 Classes/PHPWord/Section/Image.php mode change 100644 => 100755 Classes/PHPWord/Section/Link.php mode change 100644 => 100755 Classes/PHPWord/Section/ListItem.php mode change 100644 => 100755 Classes/PHPWord/Section/MemoryImage.php mode change 100644 => 100755 Classes/PHPWord/Section/Object.php mode change 100644 => 100755 Classes/PHPWord/Section/PageBreak.php mode change 100644 => 100755 Classes/PHPWord/Section/Settings.php mode change 100644 => 100755 Classes/PHPWord/Section/Table.php mode change 100644 => 100755 Classes/PHPWord/Section/Table/Cell.php mode change 100644 => 100755 Classes/PHPWord/Section/Text.php mode change 100644 => 100755 Classes/PHPWord/Section/TextBreak.php mode change 100644 => 100755 Classes/PHPWord/Section/TextRun.php mode change 100644 => 100755 Classes/PHPWord/Section/Title.php mode change 100644 => 100755 Classes/PHPWord/Shared/Drawing.php mode change 100644 => 100755 Classes/PHPWord/Shared/File.php mode change 100644 => 100755 Classes/PHPWord/Shared/Font.php mode change 100644 => 100755 Classes/PHPWord/Shared/String.php mode change 100644 => 100755 Classes/PHPWord/Shared/XMLWriter.php mode change 100644 => 100755 Classes/PHPWord/Shared/ZipStreamWrapper.php mode change 100644 => 100755 Classes/PHPWord/Style.php mode change 100644 => 100755 Classes/PHPWord/Style/Cell.php mode change 100644 => 100755 Classes/PHPWord/Style/Font.php mode change 100644 => 100755 Classes/PHPWord/Style/Image.php mode change 100644 => 100755 Classes/PHPWord/Style/ListItem.php mode change 100644 => 100755 Classes/PHPWord/Style/Paragraph.php mode change 100644 => 100755 Classes/PHPWord/Style/TOC.php mode change 100644 => 100755 Classes/PHPWord/Style/Tab.php mode change 100644 => 100755 Classes/PHPWord/Style/Table.php mode change 100644 => 100755 Classes/PHPWord/Style/TableFull.php mode change 100644 => 100755 Classes/PHPWord/Style/Tabs.php mode change 100644 => 100755 Classes/PHPWord/TOC.php mode change 100644 => 100755 Classes/PHPWord/Template.php mode change 100644 => 100755 Classes/PHPWord/Writer/IWriter.php mode change 100644 => 100755 Classes/PHPWord/Writer/ODText.php mode change 100644 => 100755 Classes/PHPWord/Writer/ODText/Content.php mode change 100644 => 100755 Classes/PHPWord/Writer/ODText/Manifest.php mode change 100644 => 100755 Classes/PHPWord/Writer/ODText/Meta.php mode change 100644 => 100755 Classes/PHPWord/Writer/ODText/Mimetype.php mode change 100644 => 100755 Classes/PHPWord/Writer/ODText/Styles.php mode change 100644 => 100755 Classes/PHPWord/Writer/ODText/WriterPart.php mode change 100644 => 100755 Classes/PHPWord/Writer/RTF.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/Base.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/ContentTypes.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/DocProps.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/Document.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/DocumentRels.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/Footer.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/Header.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/Rels.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/Styles.php mode change 100644 => 100755 Classes/PHPWord/Writer/Word2007/WriterPart.php mode change 100644 => 100755 README.md mode change 100644 => 100755 changelog.txt mode change 100644 => 100755 samples/Sample_01_SimpleText.php mode change 100644 => 100755 samples/Sample_02_TabStops.php mode change 100644 => 100755 samples/old/AdvancedTable.php mode change 100644 => 100755 samples/old/BasicTable.php mode change 100644 => 100755 samples/old/HeaderFooter.php mode change 100644 => 100755 samples/old/Image.php mode change 100644 => 100755 samples/old/Link.php mode change 100644 => 100755 samples/old/ListItem.php mode change 100644 => 100755 samples/old/Object.php mode change 100644 => 100755 samples/old/Section.php mode change 100644 => 100755 samples/old/Template.php mode change 100644 => 100755 samples/old/Textrun.php mode change 100644 => 100755 samples/old/TitleTOC.php mode change 100644 => 100755 samples/old/Watermark.php mode change 100644 => 100755 test/PHPWord/Tests/ImageTest.php mode change 100644 => 100755 test/bootstrap.php diff --git a/Classes/PHPWord.php b/Classes/PHPWord.php old mode 100644 new mode 100755 index feda87611c..3879d7cdd8 --- a/Classes/PHPWord.php +++ b/Classes/PHPWord.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,13 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ /** PHPWORD_BASE_PATH */ -if(!defined('PHPWORD_BASE_PATH')) { +if (!defined('PHPWORD_BASE_PATH')) { define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/'); require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php'; PHPWord_Autoloader::Register(); @@ -35,195 +35,208 @@ /** * PHPWord - * - * @category PHPWord - * @package PHPWord - * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord { - - /** - * Document properties - * - * @var PHPWord_DocumentProperties - */ - private $_properties; - - /** - * Default Font Name - * - * @var string - */ - private $_defaultFontName; - - /** - * Default Font Size - * - * @var int - */ - private $_defaultFontSize; - - /** - * Collection of section elements - * - * @var array - */ - private $_sectionCollection = array(); - - - /** - * Create a new PHPWord Document - */ - public function __construct() { - $this->_properties = new PHPWord_DocumentProperties(); - $this->_defaultFontName = 'Arial'; - $this->_defaultFontSize = 20; - } - - /** - * Get properties - * @return PHPWord_DocumentProperties - */ - public function getProperties() { - return $this->_properties; - } - - /** - * Set properties - * - * @param PHPWord_DocumentProperties $value - * @return PHPWord - */ - public function setProperties(PHPWord_DocumentProperties $value) { - $this->_properties = $value; - return $this; - } - - /** - * Create a new Section - * - * @param PHPWord_Section_Settings $settings - * @return PHPWord_Section - */ - public function createSection($settings = null) { - $sectionCount = $this->_countSections() + 1; - - $section = new PHPWord_Section($sectionCount, $settings); - $this->_sectionCollection[] = $section; - return $section; - } - - /** - * Get default Font name - * @return string - */ - public function getDefaultFontName() { - return $this->_defaultFontName; - } - - /** - * Set default Font name - * @param string $pValue - */ - public function setDefaultFontName($pValue) { - $this->_defaultFontName = $pValue; - } - - /** - * Get default Font size - * @return string - */ - public function getDefaultFontSize() { - return $this->_defaultFontSize; - } - - /** - * Set default Font size - * @param int $pValue - */ - public function setDefaultFontSize($pValue) { - $pValue = $pValue * 2; - $this->_defaultFontSize = $pValue; - } - - /** - * Adds a paragraph style definition to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addParagraphStyle($styleName, $styles) { - PHPWord_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) { - PHPWord_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) { - PHPWord_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) { - PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); - } - - /** - * Adds a hyperlink style to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addLinkStyle($styleName, $styles) { - PHPWord_Style::addLinkStyle($styleName, $styles); - } - - /** - * Get sections - * @return PHPWord_Section[] - */ - public function getSections() { - return $this->_sectionCollection; - } - - /** - * Get section count - * @return int - */ - private function _countSections() { - return count($this->_sectionCollection); - } - +class PHPWord +{ + + /** + * Document properties + * + * @var PHPWord_DocumentProperties + */ + private $_properties; + + /** + * Default Font Name + * + * @var string + */ + private $_defaultFontName; + + /** + * Default Font Size + * + * @var int + */ + private $_defaultFontSize; + + /** + * Collection of section elements + * + * @var array + */ + private $_sectionCollection = array(); + + + /** + * Create a new PHPWord Document + */ + public function __construct() + { + $this->_properties = new PHPWord_DocumentProperties(); + $this->_defaultFontName = 'Arial'; + $this->_defaultFontSize = 20; + } + + /** + * Get properties + * @return PHPWord_DocumentProperties + */ + public function getProperties() + { + return $this->_properties; + } + + /** + * Set properties + * + * @param PHPWord_DocumentProperties $value + * @return PHPWord + */ + public function setProperties(PHPWord_DocumentProperties $value) + { + $this->_properties = $value; + return $this; + } + + /** + * Create a new Section + * + * @param PHPWord_Section_Settings $settings + * @return PHPWord_Section + */ + public function createSection($settings = null) + { + $sectionCount = $this->_countSections() + 1; + + $section = new PHPWord_Section($sectionCount, $settings); + $this->_sectionCollection[] = $section; + return $section; + } + + /** + * Get default Font name + * @return string + */ + public function getDefaultFontName() + { + return $this->_defaultFontName; + } + + /** + * Set default Font name + * @param string $pValue + */ + public function setDefaultFontName($pValue) + { + $this->_defaultFontName = $pValue; + } + + /** + * Get default Font size + * @return string + */ + public function getDefaultFontSize() + { + return $this->_defaultFontSize; + } + + /** + * Set default Font size + * @param int $pValue + */ + public function setDefaultFontSize($pValue) + { + $pValue = $pValue * 2; + $this->_defaultFontSize = $pValue; + } + + /** + * Adds a paragraph style definition to styles.xml + * + * @param $styleName string + * @param $styles array + */ + public function addParagraphStyle($styleName, $styles) + { + PHPWord_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) + { + PHPWord_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) + { + PHPWord_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) + { + PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); + } + + /** + * Adds a hyperlink style to styles.xml + * + * @param $styleName string + * @param $styles array + */ + public function addLinkStyle($styleName, $styles) + { + PHPWord_Style::addLinkStyle($styleName, $styles); + } + + /** + * Get sections + * @return PHPWord_Section[] + */ + public function getSections() + { + return $this->_sectionCollection; + } + + /** + * Get section count + * @return int + */ + private function _countSections() + { + return count($this->_sectionCollection); + } + /** * Load a Template File - * + * * @param string $strFilename * @return PHPWord_Template */ - public function loadTemplate($strFilename) { - if(file_exists($strFilename)) { + public function loadTemplate($strFilename) + { + if (file_exists($strFilename)) { $template = new PHPWord_Template($strFilename); return $template; } else { - trigger_error('Template file '.$strFilename.' not found.', E_USER_ERROR); + trigger_error('Template file ' . $strFilename . ' not found.', E_USER_ERROR); } } } \ No newline at end of file diff --git a/Classes/PHPWord/Autoloader.php b/Classes/PHPWord/Autoloader.php index c6b53a74d5..601c2ebf14 100755 --- a/Classes/PHPWord/Autoloader.php +++ b/Classes/PHPWord/Autoloader.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/DocumentProperties.php b/Classes/PHPWord/DocumentProperties.php old mode 100644 new mode 100755 index f2a0904d08..c96ac0d49a --- a/Classes/PHPWord/DocumentProperties.php +++ b/Classes/PHPWord/DocumentProperties.php @@ -20,14 +20,13 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ - /** - * PHPWord_DocumentProperties + * Class PHPWord_DocumentProperties */ class PHPWord_DocumentProperties { diff --git a/Classes/PHPWord/Exception.php b/Classes/PHPWord/Exception.php old mode 100644 new mode 100755 index 1cf4f050d0..d1da2099bd --- a/Classes/PHPWord/Exception.php +++ b/Classes/PHPWord/Exception.php @@ -20,33 +20,30 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 0.7.0 */ - /** - * PHPWord_Exception - * - * @category PHPWord - * @package PHPWord - * @copyright Copyright (c) 2006 - 2013 PHPWord (http://www.codeplex.com/PHPWord) + * Class PHPWord_Exception */ -class PHPWord_Exception extends Exception { - /** - * Error handler callback - * - * @param mixed $code - * @param mixed $string - * @param mixed $file - * @param mixed $line - * @param mixed $context - */ - public static function errorHandlerCallback($code, $string, $file, $line, $context) { - $e = new self($string, $code); - $e->line = $line; - $e->file = $file; - throw $e; - } +class PHPWord_Exception extends Exception +{ + /** + * Error handler callback + * + * @param mixed $code + * @param mixed $string + * @param mixed $file + * @param mixed $line + * @param mixed $context + */ + public static function errorHandlerCallback($code, $string, $file, $line, $context) + { + $e = new self($string, $code); + $e->line = $line; + $e->file = $file; + throw $e; + } } \ No newline at end of file diff --git a/Classes/PHPWord/HashTable.php b/Classes/PHPWord/HashTable.php old mode 100644 new mode 100755 index c32e0abbd3..cb4f853951 --- a/Classes/PHPWord/HashTable.php +++ b/Classes/PHPWord/HashTable.php @@ -20,12 +20,11 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ - /** * PHPWord_HashTable */ diff --git a/Classes/PHPWord/IOFactory.php b/Classes/PHPWord/IOFactory.php old mode 100644 new mode 100755 index a07a72db22..9dd1c1ad57 --- a/Classes/PHPWord/IOFactory.php +++ b/Classes/PHPWord/IOFactory.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Media.php b/Classes/PHPWord/Media.php old mode 100644 new mode 100755 index 044db8f78f..b739d365f4 --- a/Classes/PHPWord/Media.php +++ b/Classes/PHPWord/Media.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section.php b/Classes/PHPWord/Section.php old mode 100644 new mode 100755 index d5f5618d36..3bb11c1c75 --- a/Classes/PHPWord/Section.php +++ b/Classes/PHPWord/Section.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,378 +20,393 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** - * PHPWord_Section - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord + * Class PHPWord_Section */ -class PHPWord_Section { - - /** - * Section count - * - * @var int - */ - private $_sectionCount; - - /** - * Section settings - * - * @var PHPWord_Section_Settings - */ - private $_settings; - - /** - * Section Element Collection - * - * @var array - */ - private $_elementCollection = array(); - - /** - * Section Headers - * - * @var array - */ - private $_headers = array(); - - /** - * Section Footer - * - * @var PHPWord_Section_Footer - */ - private $_footer = null; - - - /** - * Create a new Section - * - * @param int $sectionCount - * @param mixed $settings - */ - public function __construct($sectionCount, $settings = null) { - $this->_sectionCount = $sectionCount; - $this->_settings = new PHPWord_Section_Settings(); - - 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 PHPWord_Section_Settings - */ - public function getSettings() { - return $this->_settings; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); +class PHPWord_Section +{ + + /** + * Section count + * + * @var int + */ + private $_sectionCount; + + /** + * Section settings + * + * @var PHPWord_Section_Settings + */ + private $_settings; + + /** + * Section Element Collection + * + * @var array + */ + private $_elementCollection = array(); + + /** + * Section Headers + * + * @var array + */ + private $_headers = array(); + + /** + * Section Footer + * + * @var PHPWord_Section_Footer + */ + private $_footer = null; + + + /** + * Create a new Section + * + * @param int $sectionCount + * @param mixed $settings + */ + public function __construct($sectionCount, $settings = null) + { + $this->_sectionCount = $sectionCount; + $this->_settings = new PHPWord_Section_Settings(); + + 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 PHPWord_Section_Settings + */ + public function getSettings() + { + return $this->_settings; + } + + /** + * Add a Text Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; } - $text = new PHPWord_Section_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 PHPWord_Section_Link - */ - public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) { - if(!PHPWord_Shared_String::IsUTF8($linkSrc)){ - $linkSrc = utf8_encode($linkSrc); + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Link + */ + public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) + { + if (!PHPWord_Shared_String::IsUTF8($linkSrc)) { + $linkSrc = utf8_encode($linkSrc); + } + if (!is_null($linkName)) { + if (!PHPWord_Shared_String::IsUTF8($linkName)) { + $linkName = utf8_encode($linkName); + } + } + + $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph); + $rID = PHPWord_Media::addSectionLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } + + /** + * Add a TextBreak Element + * + * @param int $count + */ + public function addTextBreak($count = 1) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new PHPWord_Section_TextBreak(); + } + } + + /** + * Add a PageBreak Element + */ + public function addPageBreak() + { + $this->_elementCollection[] = new PHPWord_Section_PageBreak(); } - if(!is_null($linkName)) { - if(!PHPWord_Shared_String::IsUTF8($linkName)){ - $linkName = utf8_encode($linkName); - } - } - - $link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph); - $rID = PHPWord_Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Add a TextBreak Element - * - * @param int $count - */ - public function addTextBreak($count = 1) { - for($i=1; $i<=$count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak(); - } - } - - /** - * Add a PageBreak Element - */ - public function addPageBreak() { - $this->_elementCollection[] = new PHPWord_Section_PageBreak(); - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PHPWord_Section_Table - */ - public function addTable($style = null) { - $table = new PHPWord_Section_Table('section', $this->_sectionCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a ListItem Element - * - * @param string $text - * @param int $depth - * @param mixed $styleFont + + /** + * Add a Table Element + * + * @param mixed $style + * @return PHPWord_Section_Table + */ + public function addTable($style = null) + { + $table = new PHPWord_Section_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 PHPWord_Section_ListItem - */ - public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); + * @param mixed $styleParagraph + * @return PHPWord_Section_ListItem + */ + public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $listItem = new PHPWord_Section_ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); + $this->_elementCollection[] = $listItem; + return $listItem; + } + + /** + * Add a OLE-Object Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Object + */ + public function addObject($src, $style = null) + { + $object = new PHPWord_Section_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 = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); + $data = PHPWord_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 { + trigger_error('Source does not exist or unsupported object type.'); + } + } + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addImage($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style); + + if (!is_null($image->getSource())) { + $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Source does not exist or unsupported image type.'); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PHPWord_Section_MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + trigger_error('Unsupported image type.'); + } + } + + /** + * Add a Table-of-Contents Element + * + * @param mixed $styleFont + * @param mixed $styleTOC + * @return PHPWord_TOC + */ + public function addTOC($styleFont = null, $styleTOC = null) + { + $toc = new PHPWord_TOC($styleFont, $styleTOC); + $this->_elementCollection[] = $toc; + return $toc; + } + + /** + * Add a Title Element + * + * @param string $text + * @param int $depth + * @return PHPWord_Section_Title + */ + public function addTitle($text, $depth = 1) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $styles = PHPWord_Style::getStyles(); + if (array_key_exists('Heading_' . $depth, $styles)) { + $style = 'Heading' . $depth; + } else { + $style = null; + } + + $title = new PHPWord_Section_Title($text, $depth, $style); + + $data = PHPWord_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 + * + * @return PHPWord_Section_TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new PHPWord_Section_TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Get all Elements + * + * @return array + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Create a new Header + * + * @return PHPWord_Section_Header + */ + public function createHeader() + { + $header = new PHPWord_Section_Header($this->_sectionCount); + $this->_headers[] = $header; + return $header; } - $listItem = new PHPWord_Section_ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); - $this->_elementCollection[] = $listItem; - return $listItem; - } - - /** - * Add a OLE-Object Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Object - */ - public function addObject($src, $style = null) { - $object = new PHPWord_Section_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 = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); - $data = PHPWord_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 { - trigger_error('Source does not exist or unsupported object type.'); - } - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); - - if(!is_null($image->getSource())) { - $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Source does not exist or unsupported image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PHPWord_Section_MemoryImage - */ - public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); - if(!is_null($memoryImage->getSource())) { - $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - trigger_error('Unsupported image type.'); - } - } - - /** - * Add a Table-of-Contents Element - * - * @param mixed $styleFont - * @param mixed $styleTOC - * @return PHPWord_TOC - */ - public function addTOC($styleFont = null, $styleTOC = null) { - $toc = new PHPWord_TOC($styleFont, $styleTOC); - $this->_elementCollection[] = $toc; - return $toc; - } - - /** - * Add a Title Element - * - * @param string $text - * @param int $depth - * @return PHPWord_Section_Title - */ - public function addTitle($text, $depth = 1) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); + + /** + * 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 PHPWord_Section_Header instances have a type of + * PHPWord_Section_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; + }); + return count($value) > 0; + } + + /** + * Create a new Footer + * + * @return PHPWord_Section_Footer + */ + public function createFooter() + { + $footer = new PHPWord_Section_Footer($this->_sectionCount); + $this->_footer = $footer; + return $footer; + } + + /** + * Get Footer + * + * @return PHPWord_Section_Footer + */ + public function getFooter() + { + return $this->_footer; } - $styles = PHPWord_Style::getStyles(); - if(array_key_exists('Heading_'.$depth, $styles)) { - $style = 'Heading'.$depth; - } else { - $style = null; - } - - $title = new PHPWord_Section_Title($text, $depth, $style); - - $data = PHPWord_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 - * - * @return PHPWord_Section_TextRun - */ - public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Get all Elements - * - * @return array - */ - public function getElements() { - return $this->_elementCollection; - } - - /** - * Create a new Header - * - * @return PHPWord_Section_Header - */ - public function createHeader() { - $header = new PHPWord_Section_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 PHPWord_Section_Header instances have a type of - * PHPWord_Section_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; - }); - return count($value) > 0; - } - - /** - * Create a new Footer - * - * @return PHPWord_Section_Footer - */ - public function createFooter() { - $footer = new PHPWord_Section_Footer($this->_sectionCount); - $this->_footer = $footer; - return $footer; - } - - /** - * Get Footer - * - * @return PHPWord_Section_Footer - */ - public function getFooter() { - return $this->_footer; - } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/Classes/PHPWord/Section/Footer.php b/Classes/PHPWord/Section/Footer.php old mode 100644 new mode 100755 index e54d1ea5c3..a5de189176 --- a/Classes/PHPWord/Section/Footer.php +++ b/Classes/PHPWord/Section/Footer.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,186 +20,193 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** * PHPWord_Section_Footer - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Footer { - - /** - * Footer Count - * - * @var int - */ - private $_footerCount; - - /** - * Footer Relation ID - * - * @var int - */ - private $_rId; - - /** - * Footer Element Collection - * - * @var int - */ - private $_elementCollection = array(); - - /** - * Create a new Footer - */ - public function __construct($sectionCount) { - $this->_footerCount = $sectionCount; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); +class PHPWord_Section_Footer +{ + + /** + * Footer Count + * + * @var int + */ + private $_footerCount; + + /** + * Footer Relation ID + * + * @var int + */ + private $_rId; + + /** + * Footer Element Collection + * + * @var int + */ + private $_elementCollection = array(); + + /** + * Create a new Footer + */ + public function __construct($sectionCount) + { + $this->_footerCount = $sectionCount; + } + + /** + * Add a Text Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a TextBreak Element + * + * @param int $count + */ + public function addTextBreak($count = 1) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new PHPWord_Section_TextBreak(); + } + } + + /** + * Create a new TextRun + * + * @return PHPWord_Section_TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new PHPWord_Section_TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Add a Table Element + * + * @param mixed $style + * @return PHPWord_Section_Table + */ + public function addTable($style = null) + { + $table = new PHPWord_Section_Table('footer', $this->_footerCount, $style); + $this->_elementCollection[] = $table; + return $table; } - $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a TextBreak Element - * - * @param int $count - */ - public function addTextBreak($count = 1) { - for($i=1; $i<=$count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak(); - } - } - - /** - * Create a new TextRun - * - * @return PHPWord_Section_TextRun - */ - public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PHPWord_Section_Table - */ - public function addTable($style = null) { - $table = new PHPWord_Section_Table('footer', $this->_footerCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); - - if(!is_null($image->getSource())) { - $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Src does not exist or invalid image type.', E_USER_ERROR); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PHPWord_Section_MemoryImage - */ - public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); - if(!is_null($memoryImage->getSource())) { - $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - trigger_error('Unsupported image type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Footer_PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addImage($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style); + + if (!is_null($image->getSource())) { + $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Src does not exist or invalid image type.', E_USER_ERROR); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PHPWord_Section_MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + trigger_error('Unsupported image type.'); + } + } + + /** + * Add a PreserveText Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Footer_PreserveText + */ + public function addPreserveText($text, $styleFont = null, $styleParagraph = null) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $ptext = new PHPWord_Section_Footer_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 + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Footer Count + */ + public function getFooterCount() + { + return $this->_footerCount; } - $ptext = new PHPWord_Section_Footer_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 - */ - public function getElements() { - return $this->_elementCollection; - } - - /** - * Get Footer Count - */ - public function getFooterCount() { - return $this->_footerCount; - } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/Classes/PHPWord/Section/Footer/PreserveText.php b/Classes/PHPWord/Section/Footer/PreserveText.php old mode 100644 new mode 100755 index 7d08712f0f..a38b1dcc90 --- a/Classes/PHPWord/Section/Footer/PreserveText.php +++ b/Classes/PHPWord/Section/Footer/PreserveText.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/Header.php b/Classes/PHPWord/Section/Header.php old mode 100644 new mode 100755 index 65ad397115..483f887eab --- a/Classes/PHPWord/Section/Header.php +++ b/Classes/PHPWord/Section/Header.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,265 +20,277 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** * PHPWord_Section_Header - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Header { - - /** - * Header Count - * - * @var int - */ - private $_headerCount; - - /** - * Header Relation ID - * - * @var int - */ - private $_rId; +class PHPWord_Section_Header +{ + + /** + * Header Count + * + * @var int + */ + private $_headerCount; + + /** + * Header Relation ID + * + * @var int + */ + private $_rId; + + /** + * Header type + * + * @var string + * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type + */ + private $_type = PHPWord_Section_Header::AUTO; + + /** + * Even Numbered Pages Only + * @var string + * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type + */ + const EVEN = 'even'; + + /** + * Default Header or Footer + * @var string + * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type + */ + const AUTO = 'default'; // Did not use DEFAULT because it is a PHP keyword + + /** + * First Page Only + * @var string + * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type + */ + const FIRST = 'first'; + + /** + * Header Element Collection + * + * @var int + */ + private $_elementCollection = array(); - /** - * Header type - * - * @var string - * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type - */ - private $_type = PHPWord_Section_Header::AUTO; + /** + * Create a new Header + */ + public function __construct($sectionCount) + { + $this->_headerCount = $sectionCount; + } - /** - * Even Numbered Pages Only - * @var string - * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type - */ - const EVEN = 'even'; + /** + * Add a Text Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } - /** - * Default Header or Footer - * @var string - * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type - */ - const AUTO = 'default'; // Did not use DEFAULT because it is a PHP keyword + /** + * Add a TextBreak Element + * + * @param int $count + */ + public function addTextBreak($count = 1) + { + for ($i = 1; $i <= $count; $i++) { + $this->_elementCollection[] = new PHPWord_Section_TextBreak(); + } + } + + /** + * Create a new TextRun + * + * @return PHPWord_Section_TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new PHPWord_Section_TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } - /** - * First Page Only - * @var string - * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type - */ - const FIRST = 'first'; - - /** - * Header Element Collection - * - * @var int - */ - private $_elementCollection = array(); - - /** - * Create a new Header - */ - public function __construct($sectionCount) { - $this->_headerCount = $sectionCount; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); + /** + * Add a Table Element + * + * @param mixed $style + * @return PHPWord_Section_Table + */ + public function addTable($style = null) + { + $table = new PHPWord_Section_Table('header', $this->_headerCount, $style); + $this->_elementCollection[] = $table; + return $table; } - $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a TextBreak Element - * - * @param int $count - */ - public function addTextBreak($count = 1) { - for($i=1; $i<=$count; $i++) { - $this->_elementCollection[] = new PHPWord_Section_TextBreak(); - } - } - - /** - * Create a new TextRun - * - * @return PHPWord_Section_TextRun - */ - public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PHPWord_Section_Table - */ - public function addTable($style = null) { - $table = new PHPWord_Section_Table('header', $this->_headerCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); - - if(!is_null($image->getSource())) { - $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Src does not exist or invalid image type.', E_USER_ERROR); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PHPWord_Section_MemoryImage - */ - public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); - if(!is_null($memoryImage->getSource())) { - $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - trigger_error('Unsupported image type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PHPWord_Section_Footer_PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addImage($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style); + + if (!is_null($image->getSource())) { + $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Src does not exist or invalid image type.', E_USER_ERROR); + } } - $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } - - /** - * Add a Watermark Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addWatermark($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style, true); - - if(!is_null($image->getSource())) { - $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Src does not exist or invalid image type.', E_USER_ERROR); - } - } - - /** - * 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; - } + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PHPWord_Section_MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); + $memoryImage->setRelationId($rID); - /** - * Reset back to default - */ - public function resetType() { - return $this->_type = PHPWord_Section_Header::AUTO; - } + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + trigger_error('Unsupported image type.'); + } + } - /** - * First page only header - */ - public function firstPage() { - return $this->_type = PHPWord_Section_Header::FIRST; - } + /** + * Add a PreserveText Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return PHPWord_Section_Footer_PreserveText + */ + public function addPreserveText($text, $styleFont = null, $styleParagraph = null) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $ptext; + return $ptext; + } - /** - * Even numbered Pages only - */ - public function evenPage() { - return $this->_type = PHPWord_Section_Header::EVEN; - } + /** + * Add a Watermark Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addWatermark($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style, true); + + if (!is_null($image->getSource())) { + $rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Src does not exist or invalid image type.', E_USER_ERROR); + } + } + + /** + * 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 = PHPWord_Section_Header::AUTO; + } + + /** + * First page only header + */ + public function firstPage() + { + return $this->_type = PHPWord_Section_Header::FIRST; + } + + /** + * Even numbered Pages only + */ + public function evenPage() + { + return $this->_type = PHPWord_Section_Header::EVEN; + } -} -?> +} \ No newline at end of file diff --git a/Classes/PHPWord/Section/Image.php b/Classes/PHPWord/Section/Image.php old mode 100644 new mode 100755 index e994fb959f..4dbf8808f8 --- a/Classes/PHPWord/Section/Image.php +++ b/Classes/PHPWord/Section/Image.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/Link.php b/Classes/PHPWord/Section/Link.php old mode 100644 new mode 100755 index 551eb4f211..d3396c7de6 --- a/Classes/PHPWord/Section/Link.php +++ b/Classes/PHPWord/Section/Link.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/ListItem.php b/Classes/PHPWord/Section/ListItem.php old mode 100644 new mode 100755 index e6a1ac76cf..f70f839648 --- a/Classes/PHPWord/Section/ListItem.php +++ b/Classes/PHPWord/Section/ListItem.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/MemoryImage.php b/Classes/PHPWord/Section/MemoryImage.php old mode 100644 new mode 100755 index f1a027e28d..d4e8b6ff35 --- a/Classes/PHPWord/Section/MemoryImage.php +++ b/Classes/PHPWord/Section/MemoryImage.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/Object.php b/Classes/PHPWord/Section/Object.php old mode 100644 new mode 100755 index 40aa272c86..30d253dc7a --- a/Classes/PHPWord/Section/Object.php +++ b/Classes/PHPWord/Section/Object.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/PageBreak.php b/Classes/PHPWord/Section/PageBreak.php old mode 100644 new mode 100755 index bdaf58eaf0..d72c2318a2 --- a/Classes/PHPWord/Section/PageBreak.php +++ b/Classes/PHPWord/Section/PageBreak.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/Settings.php b/Classes/PHPWord/Section/Settings.php old mode 100644 new mode 100755 index fa30c367f4..e168821c87 --- a/Classes/PHPWord/Section/Settings.php +++ b/Classes/PHPWord/Section/Settings.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/Table.php b/Classes/PHPWord/Section/Table.php old mode 100644 new mode 100755 index 3c9cbfb75d..5f3e1ea595 --- a/Classes/PHPWord/Section/Table.php +++ b/Classes/PHPWord/Section/Table.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/Table/Cell.php b/Classes/PHPWord/Section/Table/Cell.php old mode 100644 new mode 100755 index 989042fe51..cf6f1dc8be --- a/Classes/PHPWord/Section/Table/Cell.php +++ b/Classes/PHPWord/Section/Table/Cell.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,310 +20,318 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** * PHPWord_Section_Table_Cell - * - * @category PHPWord - * @package PHPWord_Section_Table - * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_Table_Cell { - - /** - * Cell Width - * - * @var int - */ - private $_width = null; - - /** - * Cell Style - * - * @var PHPWord_Style_Cell - */ - private $_style; - - /** - * Cell Element Collection - * - * @var array - */ - private $_elementCollection = array(); - - /** - * Table holder - * - * @var string - */ - private $_insideOf; - - /** - * Section/Header/Footer count - * - * @var int - */ - private $_pCount; - - - /** - * Create a new Table Cell - * - * @param string $insideOf - * @param int $pCount - * @param int $width - * @param mixed $style - */ - public function __construct($insideOf, $pCount, $width = null, $style = null) { - $this->_insideOf = $insideOf; - $this->_pCount = $pCount; - $this->_width = $width; - - if(!is_null($style)) { - if(is_array($style)) { - $this->_style = new PHPWord_Style_Cell(); - - 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 PHPWord_Section_Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); +class PHPWord_Section_Table_Cell +{ + + /** + * Cell Width + * + * @var int + */ + private $_width = null; + + /** + * Cell Style + * + * @var PHPWord_Style_Cell + */ + private $_style; + + /** + * Cell Element Collection + * + * @var array + */ + private $_elementCollection = array(); + + /** + * Table holder + * + * @var string + */ + private $_insideOf; + + /** + * Section/Header/Footer count + * + * @var int + */ + private $_pCount; + + + /** + * Create a new Table Cell + * + * @param string $insideOf + * @param int $pCount + * @param int $width + * @param mixed $style + */ + public function __construct($insideOf, $pCount, $width = null, $style = null) + { + $this->_insideOf = $insideOf; + $this->_pCount = $pCount; + $this->_width = $width; + + if (!is_null($style)) { + if (is_array($style)) { + $this->_style = new PHPWord_Style_Cell(); + + 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 PHPWord_Section_Text + */ + public function addText($text, $styleFont = null, $styleParagraph = null) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $style + * @return PHPWord_Section_Link + */ + public function addLink($linkSrc, $linkName = null, $style = null) + { + if ($this->_insideOf == 'section') { + if (!PHPWord_Shared_String::IsUTF8($linkSrc)) { + $linkSrc = utf8_encode($linkSrc); + } + if (!is_null($linkName)) { + if (!PHPWord_Shared_String::IsUTF8($linkName)) { + $linkName = utf8_encode($linkName); + } + } + + $link = new PHPWord_Section_Link($linkSrc, $linkName, $style); + $rID = PHPWord_Media::addSectionLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } else { + trigger_error('Unsupported Link header / footer reference'); + return false; + } + } + + /** + * Add a TextBreak Element + * + * @param int $count + */ + public function addTextBreak() + { + $this->_elementCollection[] = new PHPWord_Section_TextBreak(); + } + + /** + * Add a ListItem Element + * + * @param string $text + * @param int $depth + * @param mixed $styleText + * @param mixed $styleList + * @return PHPWord_Section_ListItem + */ + public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList); + $this->_elementCollection[] = $listItem; + return $listItem; } - $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $style - * @return PHPWord_Section_Link - */ - public function addLink($linkSrc, $linkName = null, $style = null) { - if($this->_insideOf == 'section') { - if(!PHPWord_Shared_String::IsUTF8($linkSrc)){ - $linkSrc = utf8_encode($linkSrc); - } - if(!is_null($linkName)) { - if(!PHPWord_Shared_String::IsUTF8($linkName)){ - $linkName = utf8_encode($linkName); + + /** + * Add a Image Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Image + */ + public function addImage($src, $style = null) + { + $image = new PHPWord_Section_Image($src, $style); + + if (!is_null($image->getSource())) { + if ($this->_insideOf == 'section') { + $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); + } elseif ($this->_insideOf == 'header') { + $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src); + } elseif ($this->_insideOf == 'footer') { + $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src); + } + $image->setRelationId($rID); + + $this->_elementCollection[] = $image; + return $image; + } else { + trigger_error('Source does not exist or unsupported image type.'); + } + } + + /** + * Add a by PHP created Image Element + * + * @param string $link + * @param mixed $style + * @return PHPWord_Section_MemoryImage + */ + public function addMemoryImage($link, $style = null) + { + $memoryImage = new PHPWord_Section_MemoryImage($link, $style); + if (!is_null($memoryImage->getSource())) { + if ($this->_insideOf == 'section') { + $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); + } elseif ($this->_insideOf == 'header') { + $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); + } elseif ($this->_insideOf == 'footer') { + $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); + } + $memoryImage->setRelationId($rID); + + $this->_elementCollection[] = $memoryImage; + return $memoryImage; + } else { + trigger_error('Unsupported image type.'); + } + } + + /** + * Add a OLE-Object Element + * + * @param string $src + * @param mixed $style + * @return PHPWord_Section_Object + */ + public function addObject($src, $style = null) + { + $object = new PHPWord_Section_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 = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); + $data = PHPWord_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 { + trigger_error('Source does not exist or unsupported object type.'); } - } - - $link = new PHPWord_Section_Link($linkSrc, $linkName, $style); - $rID = PHPWord_Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } else { - trigger_error('Unsupported Link header / footer reference'); - return false; - } - } - - /** - * Add a TextBreak Element - * - * @param int $count - */ - public function addTextBreak() { - $this->_elementCollection[] = new PHPWord_Section_TextBreak(); - } - - /** - * Add a ListItem Element - * - * @param string $text - * @param int $depth - * @param mixed $styleText - * @param mixed $styleList - * @return PHPWord_Section_ListItem - */ - public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); } - $listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList); - $this->_elementCollection[] = $listItem; - return $listItem; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Image - */ - public function addImage($src, $style = null) { - $image = new PHPWord_Section_Image($src, $style); - - if(!is_null($image->getSource())) { - if($this->_insideOf == 'section') { - $rID = PHPWord_Media::addSectionMediaElement($src, 'image'); - } elseif($this->_insideOf == 'header') { - $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src); - } elseif($this->_insideOf == 'footer') { - $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src); - } - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - trigger_error('Source does not exist or unsupported image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PHPWord_Section_MemoryImage - */ - public function addMemoryImage($link, $style = null) { - $memoryImage = new PHPWord_Section_MemoryImage($link, $style); - if(!is_null($memoryImage->getSource())) { - if($this->_insideOf == 'section') { - $rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); - } elseif($this->_insideOf == 'header') { - $rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); - } elseif($this->_insideOf == 'footer') { - $rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); - } - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - trigger_error('Unsupported image type.'); - } - } - - /** - * Add a OLE-Object Element - * - * @param string $src - * @param mixed $style - * @return PHPWord_Section_Object - */ - public function addObject($src, $style = null) { - $object = new PHPWord_Section_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 = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); - $data = PHPWord_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 { - trigger_error('Source does not exist or unsupported object type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return 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)){ - $text = utf8_encode($text); - } - $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } else { - trigger_error('addPreserveText only supported in footer/header.'); - } - } - - /** - * Create a new TextRun - * - * @return PHPWord_Section_TextRun - */ - public function createTextRun($styleParagraph = null) { - $textRun = new PHPWord_Section_TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Get all Elements - * - * @return array - */ - public function getElements() { - return $this->_elementCollection; - } - - /** - * Get Cell Style - * - * @return PHPWord_Style_Cell - */ - public function getStyle() { - return $this->_style; - } - - /** - * Get Cell width - * - * @return int - */ - public function getWidth() { - return $this->_width; - } -} -?> + + /** + * Add a PreserveText Element + * + * @param string $text + * @param mixed $styleFont + * @param mixed $styleParagraph + * @return 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)) { + $text = utf8_encode($text); + } + $ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); + $this->_elementCollection[] = $ptext; + return $ptext; + } else { + trigger_error('addPreserveText only supported in footer/header.'); + } + } + + /** + * Create a new TextRun + * + * @return PHPWord_Section_TextRun + */ + public function createTextRun($styleParagraph = null) + { + $textRun = new PHPWord_Section_TextRun($styleParagraph); + $this->_elementCollection[] = $textRun; + return $textRun; + } + + /** + * Get all Elements + * + * @return array + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Cell Style + * + * @return PHPWord_Style_Cell + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Get Cell width + * + * @return int + */ + public function getWidth() + { + return $this->_width; + } +} \ No newline at end of file diff --git a/Classes/PHPWord/Section/Text.php b/Classes/PHPWord/Section/Text.php old mode 100644 new mode 100755 index 72ff4333ca..aa6266e78e --- a/Classes/PHPWord/Section/Text.php +++ b/Classes/PHPWord/Section/Text.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/TextBreak.php b/Classes/PHPWord/Section/TextBreak.php old mode 100644 new mode 100755 index 0339521dc3..cf4ef5631b --- a/Classes/PHPWord/Section/TextBreak.php +++ b/Classes/PHPWord/Section/TextBreak.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Section/TextRun.php b/Classes/PHPWord/Section/TextRun.php old mode 100644 new mode 100755 index 6a9bfaca92..2c7a216697 --- a/Classes/PHPWord/Section/TextRun.php +++ b/Classes/PHPWord/Section/TextRun.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,112 +20,112 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** * PHPWord_Section_TextRun - * - * @category PHPWord - * @package PHPWord_Section - * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Section_TextRun { - - /** - * Paragraph style - * - * @var PHPWord_Style_Font - */ - private $_styleParagraph; - - /** - * Text collection - * - * @var array - */ - private $_elementCollection; - - - /** - * Create a new TextRun Element - */ - public function __construct($styleParagraph = null) { - $this->_elementCollection = array(); - - // Set paragraph style - if(is_array($styleParagraph)) { - $this->_styleParagraph = new PHPWord_Style_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 PHPWord_Section_Text - */ - public function addText($text = null, $styleFont = null) { - if(!PHPWord_Shared_String::IsUTF8($text)){ - $text = utf8_encode($text); +class PHPWord_Section_TextRun +{ + + /** + * Paragraph style + * + * @var PHPWord_Style_Font + */ + private $_styleParagraph; + + /** + * Text collection + * + * @var array + */ + private $_elementCollection; + + + /** + * Create a new TextRun Element + */ + public function __construct($styleParagraph = null) + { + $this->_elementCollection = array(); + + // Set paragraph style + if (is_array($styleParagraph)) { + $this->_styleParagraph = new PHPWord_Style_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 PHPWord_Section_Text + */ + public function addText($text = null, $styleFont = null) + { + if (!PHPWord_Shared_String::IsUTF8($text)) { + $text = utf8_encode($text); + } + $text = new PHPWord_Section_Text($text, $styleFont); + $this->_elementCollection[] = $text; + return $text; + } + + /** + * Add a Link Element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $styleFont + * @return 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 PHPWord_Section_Link($linkSrc, $linkName, $styleFont); + $rID = PHPWord_Media::addSectionLinkElement($linkSrc); + $link->setRelationId($rID); + + $this->_elementCollection[] = $link; + return $link; + } + + /** + * Get TextRun content + * + * @return string + */ + public function getElements() + { + return $this->_elementCollection; + } + + /** + * Get Paragraph style + * + * @return PHPWord_Style_Paragraph + */ + public function getParagraphStyle() + { + return $this->_styleParagraph; } - $text = new PHPWord_Section_Text($text, $styleFont); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $styleFont - * @return 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 PHPWord_Section_Link($linkSrc, $linkName, $styleFont); - $rID = PHPWord_Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Get TextRun content - * - * @return string - */ - public function getElements() { - return $this->_elementCollection; - } - - /** - * Get Paragraph style - * - * @return PHPWord_Style_Paragraph - */ - public function getParagraphStyle() { - return $this->_styleParagraph; - } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/Classes/PHPWord/Section/Title.php b/Classes/PHPWord/Section/Title.php old mode 100644 new mode 100755 index 3e7f2f43fc..a1de15cf62 --- a/Classes/PHPWord/Section/Title.php +++ b/Classes/PHPWord/Section/Title.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Shared/Drawing.php b/Classes/PHPWord/Shared/Drawing.php old mode 100644 new mode 100755 index 8f93344e3e..eadf0b1900 --- a/Classes/PHPWord/Shared/Drawing.php +++ b/Classes/PHPWord/Shared/Drawing.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Shared/File.php b/Classes/PHPWord/Shared/File.php old mode 100644 new mode 100755 index bd214eef73..f09b3849e3 --- a/Classes/PHPWord/Shared/File.php +++ b/Classes/PHPWord/Shared/File.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Shared/Font.php b/Classes/PHPWord/Shared/Font.php old mode 100644 new mode 100755 index 4dc0a54d99..28b6c2e599 --- a/Classes/PHPWord/Shared/Font.php +++ b/Classes/PHPWord/Shared/Font.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Shared/String.php b/Classes/PHPWord/Shared/String.php old mode 100644 new mode 100755 index 3dcdc80e78..ca331642ec --- a/Classes/PHPWord/Shared/String.php +++ b/Classes/PHPWord/Shared/String.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,244 +20,251 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - +/** + * Class PHPWord_Shared_String + */ class PHPWord_Shared_String { - /** - * Control characters array - * - * @var string[] - */ - private static $_controlCharacters = array(); + /** + * Control characters array + * + * @var string[] + */ + private static $_controlCharacters = array(); + + /** + * Is mbstring extension avalable? + * + * @var boolean + */ + private static $_isMbstringEnabled; - /** - * Is mbstring extension avalable? - * - * @var boolean - */ - private static $_isMbstringEnabled; + /** + * Is iconv extension avalable? + * + * @var boolean + */ + private static $_isIconvEnabled; - /** - * Is iconv extension avalable? - * - * @var boolean - */ - private static $_isIconvEnabled; + /** + * Build control characters array + */ + private static function _buildControlCharacters() + { + for ($i = 0; $i <= 19; ++$i) { + if ($i != 9 && $i != 10 && $i != 13) { + $find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_'; + $replace = chr($i); + self::$_controlCharacters[$find] = $replace; + } + } + } - /** - * Build control characters array - */ - private static function _buildControlCharacters() { - for ($i = 0; $i <= 19; ++$i) { - if ($i != 9 && $i != 10 && $i != 13) { - $find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_'; - $replace = chr($i); - self::$_controlCharacters[$find] = $replace; - } - } - } + /** + * Get whether mbstring extension is available + * + * @return boolean + */ + public static function getIsMbstringEnabled() + { + if (isset(self::$_isMbstringEnabled)) { + return self::$_isMbstringEnabled; + } - /** - * Get whether mbstring extension is available - * - * @return boolean - */ - public static function getIsMbstringEnabled() - { - if (isset(self::$_isMbstringEnabled)) { - return self::$_isMbstringEnabled; - } + self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ? + true : false; - self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ? - true : false; + return self::$_isMbstringEnabled; + } - return self::$_isMbstringEnabled; - } + /** + * Get whether iconv extension is available + * + * @return boolean + */ + public static function getIsIconvEnabled() + { + if (isset(self::$_isIconvEnabled)) { + return self::$_isIconvEnabled; + } - /** - * Get whether iconv extension is available - * - * @return boolean - */ - public static function getIsIconvEnabled() - { - if (isset(self::$_isIconvEnabled)) { - return self::$_isIconvEnabled; - } + self::$_isIconvEnabled = function_exists('iconv') ? + true : false; - self::$_isIconvEnabled = function_exists('iconv') ? - true : false; + return self::$_isIconvEnabled; + } - return self::$_isIconvEnabled; - } + /** + * Convert from OpenXML escaped control character to PHP 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 unescape + * @return string + */ + public static function ControlCharacterOOXML2PHP($value = '') + { + if (empty(self::$_controlCharacters)) { + self::_buildControlCharacters(); + } - /** - * Convert from OpenXML escaped control character to PHP 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 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); + } - 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(); + } - /** - * 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); + } - 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; + } - /** - * 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; - } + /** + * Formats a numeric value as a string for output in various output writers + * + * @param mixed $value + * @return string + */ + public static function FormatNumber($value) + { + return number_format($value, 2, '.', ''); + } - /** - * Formats a numeric value as a string for output in various output writers - * - * @param mixed $value - * @return string - */ - public static function FormatNumber($value) { - return number_format($value, 2, '.', ''); - } + /** + * Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) + * Writes the string using uncompressed notation, no rich text, no Asian phonetics + * If mbstring extension is not available, ASCII is assumed, and compressed notation is used + * although this will give wrong results for non-ASCII strings + * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 + * + * @param string $value UTF-8 encoded string + * @return string + */ + public static function UTF8toBIFF8UnicodeShort($value) + { + // character count + $ln = self::CountCharacters($value, 'UTF-8'); - /** - * Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) - * Writes the string using uncompressed notation, no rich text, no Asian phonetics - * If mbstring extension is not available, ASCII is assumed, and compressed notation is used - * although this will give wrong results for non-ASCII strings - * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 - * - * @param string $value UTF-8 encoded string - * @return string - */ - public static function UTF8toBIFF8UnicodeShort($value) - { - // character count - $ln = self::CountCharacters($value, 'UTF-8'); + // option flags + $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? + 0x0001 : 0x0000; - // option flags - $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? - 0x0001 : 0x0000; + // characters + $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); - // characters - $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); + $data = pack('CC', $ln, $opt) . $chars; + return $data; + } - $data = pack('CC', $ln, $opt) . $chars; - return $data; - } + /** + * Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) + * Writes the string using uncompressed notation, no rich text, no Asian phonetics + * If mbstring extension is not available, ASCII is assumed, and compressed notation is used + * although this will give wrong results for non-ASCII strings + * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 + * + * @param string $value UTF-8 encoded string + * @return string + */ + public static function UTF8toBIFF8UnicodeLong($value) + { + // character count + $ln = self::CountCharacters($value, 'UTF-8'); - /** - * Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) - * Writes the string using uncompressed notation, no rich text, no Asian phonetics - * If mbstring extension is not available, ASCII is assumed, and compressed notation is used - * although this will give wrong results for non-ASCII strings - * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 - * - * @param string $value UTF-8 encoded string - * @return string - */ - public static function UTF8toBIFF8UnicodeLong($value) - { - // character count - $ln = self::CountCharacters($value, 'UTF-8'); + // option flags + $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? + 0x0001 : 0x0000; - // option flags - $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? - 0x0001 : 0x0000; + // characters + $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); - // characters - $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); + $data = pack('vC', $ln, $opt) . $chars; + return $data; + } - $data = pack('vC', $ln, $opt) . $chars; - return $data; - } + /** + * Convert string from one encoding to another. First try mbstring, then iconv, or no convertion + * + * @param string $value + * @param string $to Encoding to convert to, e.g. 'UTF-8' + * @param string $from Encoding to convert from, e.g. 'UTF-16LE' + * @return string + */ + public static function ConvertEncoding($value, $to, $from) + { + if (self::getIsMbstringEnabled()) { + $value = mb_convert_encoding($value, $to, $from); + return $value; + } - /** - * Convert string from one encoding to another. First try mbstring, then iconv, or no convertion - * - * @param string $value - * @param string $to Encoding to convert to, e.g. 'UTF-8' - * @param string $from Encoding to convert from, e.g. 'UTF-16LE' - * @return string - */ - public static function ConvertEncoding($value, $to, $from) - { - if (self::getIsMbstringEnabled()) { - $value = mb_convert_encoding($value, $to, $from); - return $value; - } + if (self::getIsIconvEnabled()) { + $value = iconv($from, $to, $value); + return $value; + } - if (self::getIsIconvEnabled()) { - $value = iconv($from, $to, $value); - return $value; - } + // else, no conversion + return $value; + } - // else, no conversion - return $value; - } - - /** - * Get character count. First try mbstring, then iconv, finally strlen - * - * @param string $value - * @param string $enc Encoding - * @return int Character count - */ - public static function CountCharacters($value, $enc = 'UTF-8') - { - if (self::getIsMbstringEnabled()) { - $count = mb_strlen($value, $enc); - return $count; - } + /** + * Get character count. First try mbstring, then iconv, finally strlen + * + * @param string $value + * @param string $enc Encoding + * @return int Character count + */ + public static function CountCharacters($value, $enc = 'UTF-8') + { + if (self::getIsMbstringEnabled()) { + $count = mb_strlen($value, $enc); + return $count; + } - if (self::getIsIconvEnabled()) { - $count = iconv_strlen($value, $enc); - return $count; - } + if (self::getIsIconvEnabled()) { + $count = iconv_strlen($value, $enc); + return $count; + } - // else strlen - $count = strlen($value); - return $count; - } + // else strlen + $count = strlen($value); + return $count; + } } diff --git a/Classes/PHPWord/Shared/XMLWriter.php b/Classes/PHPWord/Shared/XMLWriter.php old mode 100644 new mode 100755 index 7144f9cc17..a8e8377e52 --- a/Classes/PHPWord/Shared/XMLWriter.php +++ b/Classes/PHPWord/Shared/XMLWriter.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Shared/ZipStreamWrapper.php b/Classes/PHPWord/Shared/ZipStreamWrapper.php old mode 100644 new mode 100755 index 575327586a..57f06fca59 --- a/Classes/PHPWord/Shared/ZipStreamWrapper.php +++ b/Classes/PHPWord/Shared/ZipStreamWrapper.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Style.php b/Classes/PHPWord/Style.php old mode 100644 new mode 100755 index 18f2212384..7255e557c8 --- a/Classes/PHPWord/Style.php +++ b/Classes/PHPWord/Style.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Style/Cell.php b/Classes/PHPWord/Style/Cell.php old mode 100644 new mode 100755 index 090ff7b468..8bc224a9c8 --- a/Classes/PHPWord/Style/Cell.php +++ b/Classes/PHPWord/Style/Cell.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,299 +20,328 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** * PHPWord_Style_Cell - * - * @category PHPWord - * @package PHPWord_Style - * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Style_Cell { - - const TEXT_DIR_BTLR = 'btLr'; - const TEXT_DIR_TBRL = 'tbRl'; - - /** - * Vertical align - * - * @var string - */ - private $_valign; - - /** - * Text Direction - * - * @var string - */ - private $_textDirection; - - /** - * 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 Default Color - * - * @var string - */ - private $_defaultBorderColor; - - /** - * colspan - * - * @var integer - */ - private $_gridSpan = NULL; - - /** - * rowspan - * - * @var integer - */ - private $_vMerge = NULL; - - /** - * Create a new Cell Style - */ - public function __construct() { - $this->_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 setHeight($pValue = null) { - $this->_height = $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; - } -} -?> \ No newline at end of file +class PHPWord_Style_Cell +{ + + const TEXT_DIR_BTLR = 'btLr'; + const TEXT_DIR_TBRL = 'tbRl'; + + /** + * Vertical align + * + * @var string + */ + private $_valign; + + /** + * Text Direction + * + * @var string + */ + private $_textDirection; + + /** + * 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 Default Color + * + * @var string + */ + private $_defaultBorderColor; + + /** + * colspan + * + * @var integer + */ + private $_gridSpan = NULL; + + /** + * rowspan + * + * @var integer + */ + private $_vMerge = NULL; + + /** + * Create a new Cell Style + */ + public function __construct() + { + $this->_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 setHeight($pValue = null) + { + $this->_height = $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; + } +} \ No newline at end of file diff --git a/Classes/PHPWord/Style/Font.php b/Classes/PHPWord/Style/Font.php old mode 100644 new mode 100755 index 4b39120529..eafc10b7ec --- a/Classes/PHPWord/Style/Font.php +++ b/Classes/PHPWord/Style/Font.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Style/Image.php b/Classes/PHPWord/Style/Image.php old mode 100644 new mode 100755 index 1d81806064..422ddfb8ca --- a/Classes/PHPWord/Style/Image.php +++ b/Classes/PHPWord/Style/Image.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Style/ListItem.php b/Classes/PHPWord/Style/ListItem.php old mode 100644 new mode 100755 index 498b88e9aa..8eb7ffa2a6 --- a/Classes/PHPWord/Style/ListItem.php +++ b/Classes/PHPWord/Style/ListItem.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Style/Paragraph.php b/Classes/PHPWord/Style/Paragraph.php old mode 100644 new mode 100755 index 937d86509b..ccbbd616d9 --- a/Classes/PHPWord/Style/Paragraph.php +++ b/Classes/PHPWord/Style/Paragraph.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,206 +20,214 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** * PHPWord_Style_Paragraph - * - * @category PHPWord - * @package PHPWord_Style - * @copyright Copyright (c) 2011 PHPWord */ -class PHPWord_Style_Paragraph { - - /** - * Paragraph alignment - * - * @var string - */ - private $_align; - - /** - * Space before Paragraph - * - * @var int - */ - private $_spaceBefore; - - /** - * Space after Paragraph - * - * @var int - */ - private $_spaceAfter; - - /** - * Spacing between breaks - * - * @var int - */ - private $_spacing; - - /** - * Set of Custom Tab Stops - * - * @var array - */ - private $_tabs; - - /** - * Indent by how much - * - * @var int - */ - private $_indent; - - - /** - * New Paragraph Style - */ - public function __construct() { - $this->_align = null; - $this->_spaceBefore = null; - $this->_spaceAfter = null; - $this->_spacing = null; - $this->_tabs = null; - $this->_indent = null; - } - - /** - * Set Style value - * - * @param string $key - * @param mixed $value - */ - public function setStyleValue($key, $value) { - if($key == '_indent') { - $value = (int)$value * 720; // 720 twips per indent - } - if($key == '_spacing') { - $value += 240; // because line height of 1 matches 240 twips +class PHPWord_Style_Paragraph +{ + + /** + * Paragraph alignment + * + * @var string + */ + private $_align; + + /** + * Space before Paragraph + * + * @var int + */ + private $_spaceBefore; + + /** + * Space after Paragraph + * + * @var int + */ + private $_spaceAfter; + + /** + * Spacing between breaks + * + * @var int + */ + private $_spacing; + + /** + * Set of Custom Tab Stops + * + * @var array + */ + private $_tabs; + + /** + * Indent by how much + * + * @var int + */ + private $_indent; + + + /** + * New Paragraph Style + */ + public function __construct() + { + $this->_align = null; + $this->_spaceBefore = null; + $this->_spaceAfter = null; + $this->_spacing = null; + $this->_tabs = null; + $this->_indent = null; + } + + /** + * Set Style value + * + * @param string $key + * @param mixed $value + */ + public function setStyleValue($key, $value) + { + if ($key == '_indent') { + $value = (int)$value * 720; // 720 twips per indent + } + if ($key == '_spacing') { + $value += 240; // because line height of 1 matches 240 twips + } + if ($key === '_tabs') { + $value = new PHPWord_Style_Tabs($value); + } + $this->$key = $value; + } + + /** + * Get Paragraph Alignment + * + * @return string + */ + public function getAlign() + { + return $this->_align; + } + + /** + * Set Paragraph Alignment + * + * @param string $pValue + * @return PHPWord_Style_Paragraph + */ + public function setAlign($pValue = null) + { + if (strtolower($pValue) == 'justify') { + // justify becames both + $pValue = 'both'; + } + $this->_align = $pValue; + return $this; } - if($key === '_tabs') { - $value = new PHPWord_Style_Tabs($value); + + /** + * Get Space before Paragraph + * + * @return string + */ + public function getSpaceBefore() + { + return $this->_spaceBefore; + } + + /** + * Set Space before Paragraph + * + * @param int $pValue + * @return 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 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 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 PHPWord_Style_Paragraph + */ + public function setIndent($pValue = null) + { + $this->_indent = $pValue; + return $this; + } + + /** + * Get tabs + * + * @return PHPWord_Style_Tabs + */ + public function getTabs() + { + return $this->_tabs; } - $this->$key = $value; - } - - /** - * Get Paragraph Alignment - * - * @return string - */ - public function getAlign() { - return $this->_align; - } - - /** - * Set Paragraph Alignment - * - * @param string $pValue - * @return 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 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 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 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 PHPWord_Style_Paragraph - */ - public function setIndent($pValue = null) { - $this->_indent = $pValue; - return $this; - } - - /** - * Get tabs - * - * @return PHPWord_Style_Tabs - */ - public function getTabs() { - return $this->_tabs; - } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/Classes/PHPWord/Style/TOC.php b/Classes/PHPWord/Style/TOC.php old mode 100644 new mode 100755 index a91add955d..41eaefc466 --- a/Classes/PHPWord/Style/TOC.php +++ b/Classes/PHPWord/Style/TOC.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Style/Tab.php b/Classes/PHPWord/Style/Tab.php old mode 100644 new mode 100755 index cd0882c191..c35f04cbd6 --- a/Classes/PHPWord/Style/Tab.php +++ b/Classes/PHPWord/Style/Tab.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,128 +20,127 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version {something} + * @version 0.7.0 */ /** * PHPWord_Style_Tabs - * - * @category PHPWord - * @package PHPWord_Style_Paragraph - * @copyright Copyright (c) 2011 PHPWord - * @link http://www.schemacentral.com/sc/ooxml/e-w_tab-1.html w:tab */ -class PHPWord_Style_Tab { +class PHPWord_Style_Tab +{ - /** - * Tab Stop Type - * - * @var string - */ - private $_val; + /** + * Tab Stop Type + * + * @var string + */ + private $_val; - /** - * Tab Leader Character - * - * @var string - */ - private $_leader; + /** + * Tab Leader Character + * + * @var string + */ + private $_leader; - /** - * Tab Stop Position - * - * @var int - */ - private $_position; + /** + * Tab Stop Position + * + * @var int + */ + private $_position; - /** - * Tab Stop Type - * - * @var array - * @link http://www.schemacentral.com/sc/ooxml/a-w_val-26.html Tab Stop Type - */ - private static $_possibleStopTypes = array( - 'clear', // No Tab Stop - 'left', // Left Tab Stop - 'center', // Center Tab Stop - 'right', // Right Tab Stop - 'decimal', // Decimal Tab - 'bar', // Bar Tab - 'num' // List tab - ); + /** + * Tab Stop Type + * + * @var array + * @link http://www.schemacentral.com/sc/ooxml/a-w_val-26.html Tab Stop Type + */ + private static $_possibleStopTypes = array( + 'clear', // No Tab Stop + 'left', // Left Tab Stop + 'center', // Center Tab Stop + 'right', // Right Tab Stop + 'decimal', // Decimal Tab + 'bar', // Bar Tab + 'num' // List tab + ); - /** - * Tab Leader Character - * - * @var array - * @link http://www.schemacentral.com/sc/ooxml/a-w_leader-1.html Tab Leader Character - */ - private static $_possibleLeaders = array( - 'none', // No tab stop leader - 'dot', // Dotted leader line - 'hyphen', // Dashed tab stop leader line - 'underscore', // Solid leader line - 'heavy', // Heavy solid leader line - 'middleDot' // Middle dot leader line - ); + /** + * Tab Leader Character + * + * @var array + * @link http://www.schemacentral.com/sc/ooxml/a-w_leader-1.html Tab Leader Character + */ + private static $_possibleLeaders = array( + 'none', // No tab stop leader + 'dot', // Dotted leader line + 'hyphen', // Dashed tab stop leader line + 'underscore', // Solid leader line + 'heavy', // Heavy solid leader line + 'middleDot' // Middle dot leader line + ); - /** - * Create a new instance of PHPWord_Style_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. - * - * @param string $val Defaults to 'clear' if value is not possible. - * @param int $position Must be an integer; otherwise defaults to 0. - * @param string $leader Defaults to NULL if value is not possible. - */ - public function __construct($val = NULL, $position = 0, $leader = NULL) { - // Default to clear if the stop type is not matched - $this->_val = (self::isStopType($val)) ? $val : 'clear'; + /** + * Create a new instance of PHPWord_Style_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. + * + * @param string $val Defaults to 'clear' if value is not possible. + * @param int $position Must be an integer; otherwise defaults to 0. + * @param string $leader Defaults to NULL if value is not possible. + */ + public function __construct($val = NULL, $position = 0, $leader = NULL) + { + // Default to clear if the stop type is not matched + $this->_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 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; - } + // Default to NULL if no tab leader + $this->_leader = (self::isLeaderType($leader)) ? $leader : NULL; + } - /** - * Creates the XML DOM for the instance of PHPWord_Style_Tab. - * - * @param PHPWord_Shared_XMLWriter $objWriter - */ - public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL) { - if(isset($objWriter)) { - $objWriter->startElement("w:tab"); - $objWriter->writeAttribute("w:val", $this->_val); - if(!is_null($this->_leader)) { - $objWriter->writeAttribute("w:leader", $this->_leader); - } - $objWriter->writeAttribute("w:pos", $this->_position); - $objWriter->endElement(); + /** + * Creates the XML DOM for the instance of PHPWord_Style_Tab. + * + * @param PHPWord_Shared_XMLWriter $objWriter + */ + public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL) + { + if (isset($objWriter)) { + $objWriter->startElement("w:tab"); + $objWriter->writeAttribute("w:val", $this->_val); + if (!is_null($this->_leader)) { + $objWriter->writeAttribute("w:leader", $this->_leader); + } + $objWriter->writeAttribute("w:pos", $this->_position); + $objWriter->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 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); - } -} -?> \ No newline at end of file + /** + * 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); + } +} \ No newline at end of file diff --git a/Classes/PHPWord/Style/Table.php b/Classes/PHPWord/Style/Table.php old mode 100644 new mode 100755 index ea54d8d248..c3b49ea3ec --- a/Classes/PHPWord/Style/Table.php +++ b/Classes/PHPWord/Style/Table.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Style/TableFull.php b/Classes/PHPWord/Style/TableFull.php old mode 100644 new mode 100755 index f19ddd1e04..b359a59291 --- a/Classes/PHPWord/Style/TableFull.php +++ b/Classes/PHPWord/Style/TableFull.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Style/Tabs.php b/Classes/PHPWord/Style/Tabs.php old mode 100644 new mode 100755 index 096c0b6f55..c98d472ed4 --- a/Classes/PHPWord/Style/Tabs.php +++ b/Classes/PHPWord/Style/Tabs.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,48 +20,45 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version {something} + * @version 0.7.0 */ /** * PHPWord_Style_Tabs - * - * @category PHPWord - * @package PHPWord_Style_Paragraph - * @copyright Copyright (c) 2011 PHPWord - * @link http://www.schemacentral.com/sc/ooxml/e-w_tabs-1.html w:tabs */ -class PHPWord_Style_Tabs { +class PHPWord_Style_Tabs +{ - /** - * Tabs - * - * @var array - */ - private $_tabs; + /** + * Tabs + * + * @var array + */ + private $_tabs; - /** - * - * @param array $tabs - */ - public function __construct(array $tabs) { - $this->_tabs = $tabs; - } + /** + * + * @param array $tabs + */ + public function __construct(array $tabs) + { + $this->_tabs = $tabs; + } - /** - * - * @param PHPWord_Shared_XMLWriter $objWriter - */ - public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL) { - if(isset($objWriter)) { - $objWriter->startElement("w:tabs"); - foreach ($this->_tabs as &$tab) { - $tab->toXml($objWriter); - } - $objWriter->endElement(); + /** + * + * @param PHPWord_Shared_XMLWriter $objWriter + */ + public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL) + { + if (isset($objWriter)) { + $objWriter->startElement("w:tabs"); + foreach ($this->_tabs as &$tab) { + $tab->toXml($objWriter); + } + $objWriter->endElement(); + } } - } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/Classes/PHPWord/TOC.php b/Classes/PHPWord/TOC.php old mode 100644 new mode 100755 index 5d9a97cb3b..994ff2c321 --- a/Classes/PHPWord/TOC.php +++ b/Classes/PHPWord/TOC.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php old mode 100644 new mode 100755 index 1d2765d017..a01a854166 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,90 +20,88 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ - /** * PHPWord_DocumentProperties - * - * @category PHPWord - * @package PHPWord - * @copyright Copyright (c) 2009 - 2011 PHPWord (http://www.codeplex.com/PHPWord) */ -class PHPWord_Template { - +class PHPWord_Template +{ + /** * ZipArchive - * + * * @var ZipArchive */ private $_objZip; - + /** * Temporary Filename - * + * * @var string */ private $_tempFileName; - + /** * Document XML - * + * * @var string */ private $_documentXML; - - + + /** * Create a new Template Object - * + * * @param string $strFilename */ - public function __construct($strFilename) { + public function __construct($strFilename) + { $this->_tempFileName = tempnam(sys_get_temp_dir(), ''); if ($this->_tempFileName !== false) { - // Copy the source File to the temp File - if(!copy($strFilename, $this->_tempFileName)){ - throw new PHPWord_Exception('Could not copy the template from '.$strFilename.' to '.$this->_tempFileName.'.'); - } + // Copy the source File to the temp File + if (!copy($strFilename, $this->_tempFileName)) { + throw new PHPWord_Exception('Could not copy the template from ' . $strFilename . ' to ' . $this->_tempFileName . '.'); + } - $this->_objZip = new ZipArchive(); - $this->_objZip->open($this->_tempFileName); + $this->_objZip = new ZipArchive(); + $this->_objZip->open($this->_tempFileName); - $this->_documentXML = $this->_objZip->getFromName('word/document.xml'); + $this->_documentXML = $this->_objZip->getFromName('word/document.xml'); } else { - throw new PHPWord_Exception('Could not create temporary file with unique name in the default temporary directory.'); + throw new PHPWord_Exception('Could not create temporary file with unique name in the default temporary directory.'); } } - + /** * Set a Template value - * + * * @param mixed $search * @param mixed $replace */ - public function setValue($search, $replace) { + public function setValue($search, $replace) + { $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); + $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 (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { + $search = '${' . $search . '}'; } - - if(!is_array($replace)) { - if(!PHPWord_Shared_String::IsUTF8($replace)){ - $replace = utf8_encode($replace); + + if (!is_array($replace)) { + if (!PHPWord_Shared_String::IsUTF8($replace)) { + $replace = utf8_encode($replace); } } - + $this->_documentXML = str_replace($search, $replace, $this->_documentXML); } @@ -118,22 +116,22 @@ public function getVariables() /** * Save Template - * + * * @param string $strFilename */ - public function save($strFilename) { - if(file_exists($strFilename)) { + public function save($strFilename) + { + if (file_exists($strFilename)) { unlink($strFilename); } - + $this->_objZip->addFromString('word/document.xml', $this->_documentXML); - + // Close zip file - if($this->_objZip->close() === false) { + if ($this->_objZip->close() === false) { throw new Exception('Could not close zip file.'); } - + rename($this->_tempFileName, $strFilename); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/Classes/PHPWord/Writer/IWriter.php b/Classes/PHPWord/Writer/IWriter.php old mode 100644 new mode 100755 index 5e26341af9..545c29a8da --- a/Classes/PHPWord/Writer/IWriter.php +++ b/Classes/PHPWord/Writer/IWriter.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/ODText.php b/Classes/PHPWord/Writer/ODText.php old mode 100644 new mode 100755 index f8b10ab972..19e55f60a7 --- a/Classes/PHPWord/Writer/ODText.php +++ b/Classes/PHPWord/Writer/ODText.php @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPWord - * @package PHPWord_Writer_PowerPoint2007 - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @package PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PHPWord/Writer/ODText/Content.php old mode 100644 new mode 100755 index 7baac27935..69ba3befb7 --- a/Classes/PHPWord/Writer/ODText/Content.php +++ b/Classes/PHPWord/Writer/ODText/Content.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/ODText/Manifest.php b/Classes/PHPWord/Writer/ODText/Manifest.php old mode 100644 new mode 100755 index 61f9f84dcc..5509073b87 --- a/Classes/PHPWord/Writer/ODText/Manifest.php +++ b/Classes/PHPWord/Writer/ODText/Manifest.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/ODText/Meta.php b/Classes/PHPWord/Writer/ODText/Meta.php old mode 100644 new mode 100755 index 6dd1ba0c33..ca6d305ce3 --- a/Classes/PHPWord/Writer/ODText/Meta.php +++ b/Classes/PHPWord/Writer/ODText/Meta.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/ODText/Mimetype.php b/Classes/PHPWord/Writer/ODText/Mimetype.php old mode 100644 new mode 100755 index b88d7d4f9d..f6348f480f --- a/Classes/PHPWord/Writer/ODText/Mimetype.php +++ b/Classes/PHPWord/Writer/ODText/Mimetype.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/ODText/Styles.php b/Classes/PHPWord/Writer/ODText/Styles.php old mode 100644 new mode 100755 index b2ddda00b5..2ec591aec1 --- a/Classes/PHPWord/Writer/ODText/Styles.php +++ b/Classes/PHPWord/Writer/ODText/Styles.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/ODText/WriterPart.php b/Classes/PHPWord/Writer/ODText/WriterPart.php old mode 100644 new mode 100755 index 0416040cdc..5d95d69cb7 --- a/Classes/PHPWord/Writer/ODText/WriterPart.php +++ b/Classes/PHPWord/Writer/ODText/WriterPart.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/RTF.php b/Classes/PHPWord/Writer/RTF.php old mode 100644 new mode 100755 index 24e2681e1d..24f0157eab --- a/Classes/PHPWord/Writer/RTF.php +++ b/Classes/PHPWord/Writer/RTF.php @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPWord - * @package PHPWord_Writer_RTF - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @package PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php old mode 100644 new mode 100755 index c9bf9870ae..91706ab2f5 --- a/Classes/PHPWord/Writer/Word2007.php +++ b/Classes/PHPWord/Writer/Word2007.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,221 +20,229 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ +/** + * Class PHPWord_Writer_Word2007 + */ +class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter +{ + + private $_document; + private $_writerParts; + private $_diskCachingDirectory; + private $_useDiskCaching = false; + private $_imageTypes = array(); + private $_objectTypes = array(); + + public function __construct(PHPWord $PHPWord = null) + { + $this->_document = $PHPWord; + + $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(); + + 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 = PHPWord_Media::getSectionMediaElements(); + foreach ($_secElements as $element) { // loop through section media elements + if ($element['type'] != 'hyperlink') { + $this->_addFileToPackage($objZip, $element); + } + $sectionElements[] = $element; + } + + $_hdrElements = PHPWord_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 = PHPWord_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); + } + } + } + + + $_cHdrs = 0; + $_cFtrs = 0; + $rID = PHPWord_Media::countSectionMediaElements() + 6; + $_sections = $this->_document->getSections(); -class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter { - - private $_document; - private $_writerParts; - private $_diskCachingDirectory; - private $_useDiskCaching = false; - private $_imageTypes = array(); - private $_objectTypes = array(); - - public function __construct(PHPWord $PHPWord = null) { - $this->_document = $PHPWord; - - $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(); - - 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 = PHPWord_Media::getSectionMediaElements(); - foreach($_secElements as $element) { // loop through section media elements - if($element['type'] != 'hyperlink') { - $this->_addFileToPackage($objZip, $element); - } - $sectionElements[] = $element; - } - - $_hdrElements = PHPWord_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 = PHPWord_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); - } - } - } - - - - $_cHdrs = 0; - $_cFtrs = 0; - $rID = PHPWord_Media::countSectionMediaElements() + 6; - $_sections = $this->_document->getSections(); - - 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(); - if(!is_null($_footer)) { - $_cFtrs++; - $_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)); - } - } - - // build docx file - // Write dynamic files + 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(); + if (!is_null($_footer)) { + $_cFtrs++; + $_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)); + } + } + + // build docx file + // Write dynamic files $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('contenttypes')->writeContentTypes($this->_imageTypes, $this->_objectTypes, $_cHdrs, $_cFtrs)); - $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)); - + $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."); - } - } - - private function _chkContentTypes($src) { - $srcInfo = pathinfo($src); - $extension = strtolower($srcInfo['extension']); - if(substr($extension, 0, 3) == 'php') { - $extension = 'php'; - } - $_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff', 'php'); - - if(in_array($extension, $_supportedImageTypes)) { - $imagedata = getimagesize($src); - $imagetype = image_type_to_mime_type($imagedata[2]); - $imageext = image_type_to_extension($imagedata[2]); - $imageext = str_replace('.', '', $imageext); - if($imageext == 'jpeg') $imageext = 'jpg'; - - if(!in_array($imagetype, $this->_imageTypes)) { - $this->_imageTypes[$imageext] = $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->_chkContentTypes($element['source']); - } else { - $objZip->addFile($element['source'], 'word/'.$element['target']); - $this->_chkContentTypes($element['source']); - } - } -} -?> \ No newline at end of file + $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."); + } + } + + private function _chkContentTypes($src) + { + $srcInfo = pathinfo($src); + $extension = strtolower($srcInfo['extension']); + if (substr($extension, 0, 3) == 'php') { + $extension = 'php'; + } + $_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff', 'php'); + + if (in_array($extension, $_supportedImageTypes)) { + $imagedata = getimagesize($src); + $imagetype = image_type_to_mime_type($imagedata[2]); + $imageext = image_type_to_extension($imagedata[2]); + $imageext = str_replace('.', '', $imageext); + if ($imageext == 'jpeg') $imageext = 'jpg'; + + if (!in_array($imagetype, $this->_imageTypes)) { + $this->_imageTypes[$imageext] = $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->_chkContentTypes($element['source']); + } else { + $objZip->addFile($element['source'], 'word/' . $element['target']); + $this->_chkContentTypes($element['source']); + } + } +} \ No newline at end of file diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php old mode 100644 new mode 100755 index 549f12537a..331625fccb --- a/Classes/PHPWord/Writer/Word2007/Base.php +++ b/Classes/PHPWord/Writer/Word2007/Base.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,708 +20,769 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ +/** + * Class PHPWord_Writer_Word2007_Base + */ +class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart +{ + + protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) + { + $styleFont = $text->getFontStyle(); + + $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + + if (!$withoutP) { + $objWriter->startElement('w:p'); + + $styleParagraph = $text->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + $strText = htmlspecialchars($text->getText()); + $strText = PHPWord_Shared_String::ControlCharacterPHP2OOXML($strText); + + $objWriter->startElement('w:r'); + + if ($SfIsObject) { + $this->_writeTextStyle($objWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $objWriter->startElement('w:rPr'); + $objWriter->startElement('w:rStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:t'); + $objWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text + $objWriter->writeRaw($strText); + $objWriter->endElement(); + + $objWriter->endElement(); // w:r + + if (!$withoutP) { + $objWriter->endElement(); // w:p + } + } + + protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) + { + $elements = $textrun->getElements(); + $styleParagraph = $textrun->getParagraphStyle(); + + $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + + $objWriter->startElement('w:p'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + $objWriter->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); + } + } + } + + $objWriter->endElement(); + } + + protected function _writeParagraphStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Paragraph $style, $withoutPPR = false) + { + $align = $style->getAlign(); + $spaceBefore = $style->getSpaceBefore(); + $spaceAfter = $style->getSpaceAfter(); + $spacing = $style->getSpacing(); + $indent = $style->getIndent(); + $tabs = $style->getTabs(); + + if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indent) || !is_null($tabs)) { + if (!$withoutPPR) { + $objWriter->startElement('w:pPr'); + } + + if (!is_null($align)) { + $objWriter->startElement('w:jc'); + $objWriter->writeAttribute('w:val', $align); + $objWriter->endElement(); + } + + if (!is_null($indent)) { + $objWriter->startElement('w:ind'); + $objWriter->writeAttribute('w:firstLine', 0); + $objWriter->writeAttribute('w:left', $indent); + $objWriter->endElement(); + } + + if (!is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($spacing)) { + $objWriter->startElement('w:spacing'); + if (!is_null($spaceBefore)) { + $objWriter->writeAttribute('w:before', $spaceBefore); + } + if (!is_null($spaceAfter)) { + $objWriter->writeAttribute('w:after', $spaceAfter); + } + if (!is_null($spacing)) { + $objWriter->writeAttribute('w:line', $spacing); + $objWriter->writeAttribute('w:lineRule', 'auto'); + } + $objWriter->endElement(); + } + + if (!is_null($tabs)) { + $tabs->toXml($objWriter); + } + + if (!$withoutPPR) { + $objWriter->endElement(); // w:pPr + } + } + } + + protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) + { + $rID = $link->getRelationId(); + $linkName = $link->getLinkName(); + if (is_null($linkName)) { + $linkName = $link->getLinkSrc(); + } + + $styleFont = $link->getFontStyle(); + $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + + if (!$withoutP) { + $objWriter->startElement('w:p'); + + $styleParagraph = $link->getParagraphStyle(); + $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + $objWriter->startElement('w:hyperlink'); + $objWriter->writeAttribute('r:id', 'rId' . $rID); + $objWriter->writeAttribute('w:history', '1'); + + $objWriter->startElement('w:r'); + if ($SfIsObject) { + $this->_writeTextStyle($objWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $objWriter->startElement('w:rPr'); + $objWriter->startElement('w:rStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->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(); + + $objWriter->endElement(); + + if (!$withoutP) { + $objWriter->endElement(); // w:p + } + } + + protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) + { + $styleFont = $textrun->getFontStyle(); + $styleParagraph = $textrun->getParagraphStyle(); + + $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; + + $arrText = $textrun->getText(); + + $objWriter->startElement('w:p'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + $objWriter->endElement(); + } + + foreach ($arrText as $text) { + + 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(); + + $objWriter->startElement('w:r'); + + if ($SfIsObject) { + $this->_writeTextStyle($objWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $objWriter->startElement('w:rPr'); + $objWriter->startElement('w:rStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->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(); + } else { + $text = htmlspecialchars($text); + $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); + + $objWriter->startElement('w:r'); + + if ($SfIsObject) { + $this->_writeTextStyle($objWriter, $styleFont); + } elseif (!$SfIsObject && !is_null($styleFont)) { + $objWriter->startElement('w:rPr'); + $objWriter->startElement('w:rStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:t'); + $objWriter->writeAttribute('xml:space', 'preserve'); + $objWriter->writeRaw($text); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + $objWriter->endElement(); // p + } + + protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) + { + $font = $style->getName(); + $bold = $style->getBold(); + $italic = $style->getItalic(); + $color = $style->getColor(); + $size = $style->getSize(); + $fgColor = $style->getFgColor(); + $striketrough = $style->getStrikethrough(); + $underline = $style->getUnderline(); + + $objWriter->startElement('w:rPr'); + + // Font + if ($font != 'Arial') { + $objWriter->startElement('w:rFonts'); + $objWriter->writeAttribute('w:ascii', $font); + $objWriter->writeAttribute('w:hAnsi', $font); + $objWriter->writeAttribute('w:cs', $font); + $objWriter->endElement(); + } + + // Color + if ($color != '000000') { + $objWriter->startElement('w:color'); + $objWriter->writeAttribute('w:val', $color); + $objWriter->endElement(); + } + + // Size + if ($size != 20) { + $objWriter->startElement('w:sz'); + $objWriter->writeAttribute('w:val', $size); + $objWriter->endElement(); + $objWriter->startElement('w:szCs'); + $objWriter->writeAttribute('w:val', $size); + $objWriter->endElement(); + } + + // Bold + if ($bold) { + $objWriter->writeElement('w:b', null); + } + + // Italic + if ($italic) { + $objWriter->writeElement('w:i', null); + $objWriter->writeElement('w:iCs', null); + } + + // Underline + if (!is_null($underline) && $underline != 'none') { + $objWriter->startElement('w:u'); + $objWriter->writeAttribute('w:val', $underline); + $objWriter->endElement(); + } + + // Striketrough + if ($striketrough) { + $objWriter->writeElement('w:strike', null); + } + + // Foreground-Color + if (!is_null($fgColor)) { + $objWriter->startElement('w:highlight'); + $objWriter->writeAttribute('w:val', $fgColor); + $objWriter->endElement(); + } + + $objWriter->endElement(); + } + + protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) + { + $objWriter->writeElement('w:p', null); + } + + protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) + { + $_rows = $table->getRows(); + $_cRows = count($_rows); + + if ($_cRows > 0) { + $objWriter->startElement('w:tbl'); + $tblStyle = $table->getStyle(); + if ($tblStyle instanceof PHPWord_Style_Table) { + $this->_writeTableStyle($objWriter, $tblStyle); + } else { + if (!empty($tblStyle)) { + $objWriter->startElement('w:tblPr'); + $objWriter->startElement('w:tblStyle'); + $objWriter->writeAttribute('w:val', $tblStyle); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + $_heights = $table->getRowHeights(); + for ($i = 0; $i < $_cRows; $i++) { + $row = $_rows[$i]; + $height = $_heights[$i]; + + $objWriter->startElement('w:tr'); + + if (!is_null($height)) { + $objWriter->startElement('w:trPr'); + $objWriter->startElement('w:trHeight'); + $objWriter->writeAttribute('w:val', $height); + $objWriter->endElement(); + $objWriter->endElement(); + } + + foreach ($row as $cell) { + $objWriter->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(); + + if ($cellStyle instanceof PHPWord_Style_Cell) { + $this->_writeCellStyle($objWriter, $cellStyle); + } + + $objWriter->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); + } elseif ($element instanceof PHPWord_Section_ListItem) { + $this->_writeListItem($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Image || + $element instanceof PHPWord_Section_MemoryImage + ) { + $this->_writeImage($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Object) { + $this->_writeObject($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) { + $this->_writePreserveText($objWriter, $element); + } + } + } else { + $this->_writeTextBreak($objWriter); + } + + $objWriter->endElement(); + } + $objWriter->endElement(); + } + $objWriter->endElement(); + } + } + + protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) + { + $margins = $style->getCellMargin(); + $mTop = (!is_null($margins[0])) ? true : false; + $mLeft = (!is_null($margins[1])) ? true : false; + $mRight = (!is_null($margins[2])) ? true : false; + $mBottom = (!is_null($margins[3])) ? true : false; + + if ($mTop || $mLeft || $mRight || $mBottom) { + $objWriter->startElement('w:tblPr'); + $objWriter->startElement('w:tblCellMar'); + + if ($mTop) { + $objWriter->startElement('w:top'); + $objWriter->writeAttribute('w:w', $margins[0]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } -class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart { - - protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) { - $styleFont = $text->getFontStyle(); - - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - - if(!$withoutP) { - $objWriter->startElement('w:p'); - - $styleParagraph = $text->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - $strText = htmlspecialchars($text->getText()); - $strText = PHPWord_Shared_String::ControlCharacterPHP2OOXML($strText); - - $objWriter->startElement('w:r'); - - if($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); - } elseif(!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:t'); - $objWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text - $objWriter->writeRaw($strText); - $objWriter->endElement(); - - $objWriter->endElement(); // w:r - - if(!$withoutP) { - $objWriter->endElement(); // w:p - } - } - - protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) { - $elements = $textrun->getElements(); - $styleParagraph = $textrun->getParagraphStyle(); - - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - $objWriter->startElement('w:p'); - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->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); - } - } - } - - $objWriter->endElement(); - } - - protected function _writeParagraphStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Paragraph $style, $withoutPPR = false) { - $align = $style->getAlign(); - $spaceBefore = $style->getSpaceBefore(); - $spaceAfter = $style->getSpaceAfter(); - $spacing = $style->getSpacing(); - $indent = $style->getIndent(); - $tabs = $style->getTabs(); - - if(!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indent) || !is_null($tabs)) { - if(!$withoutPPR) { - $objWriter->startElement('w:pPr'); - } - - if(!is_null($align)) { - $objWriter->startElement('w:jc'); - $objWriter->writeAttribute('w:val', $align); - $objWriter->endElement(); - } - - if(!is_null($indent)) { - $objWriter->startElement('w:ind'); - $objWriter->writeAttribute('w:firstLine', 0); - $objWriter->writeAttribute('w:left', $indent); - $objWriter->endElement(); - } - - if(!is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($spacing)) { - $objWriter->startElement('w:spacing'); - if(!is_null($spaceBefore)) { - $objWriter->writeAttribute('w:before', $spaceBefore); - } - if(!is_null($spaceAfter)) { - $objWriter->writeAttribute('w:after', $spaceAfter); - } - if(!is_null($spacing)) { - $objWriter->writeAttribute('w:line', $spacing); - $objWriter->writeAttribute('w:lineRule', 'auto'); - } - $objWriter->endElement(); - } - - if(!is_null($tabs)) { - $tabs->toXml($objWriter); - } - - if(!$withoutPPR) { - $objWriter->endElement(); // w:pPr - } - } - } - - protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) { - $rID = $link->getRelationId(); - $linkName = $link->getLinkName(); - if(is_null($linkName)) { - $linkName = $link->getLinkSrc(); - } - - $styleFont = $link->getFontStyle(); - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - - if(!$withoutP) { - $objWriter->startElement('w:p'); - - $styleParagraph = $link->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - $objWriter->startElement('w:hyperlink'); - $objWriter->writeAttribute('r:id', 'rId'.$rID); - $objWriter->writeAttribute('w:history', '1'); - - $objWriter->startElement('w:r'); - if($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); - } elseif(!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->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(); - - $objWriter->endElement(); - - if(!$withoutP) { - $objWriter->endElement(); // w:p - } - } - - protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) { - $styleFont = $textrun->getFontStyle(); - $styleParagraph = $textrun->getParagraphStyle(); - - $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - $arrText = $textrun->getText(); - - $objWriter->startElement('w:p'); - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - $objWriter->endElement(); - } - - foreach($arrText as $text) { - - 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(); - - $objWriter->startElement('w:r'); - - if($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); - } elseif(!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->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(); - } else { - $text = htmlspecialchars($text); - $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); - - $objWriter->startElement('w:r'); - - if($SfIsObject) { - $this->_writeTextStyle($objWriter, $styleFont); - } elseif(!$SfIsObject && !is_null($styleFont)) { - $objWriter->startElement('w:rPr'); - $objWriter->startElement('w:rStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:t'); - $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRaw($text); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - $objWriter->endElement(); // p - } - - protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) { - $font = $style->getName(); - $bold = $style->getBold(); - $italic = $style->getItalic(); - $color = $style->getColor(); - $size = $style->getSize(); - $fgColor = $style->getFgColor(); - $striketrough = $style->getStrikethrough(); - $underline = $style->getUnderline(); - - $objWriter->startElement('w:rPr'); - - // Font - if($font != 'Arial') { - $objWriter->startElement('w:rFonts'); - $objWriter->writeAttribute('w:ascii', $font); - $objWriter->writeAttribute('w:hAnsi', $font); - $objWriter->writeAttribute('w:cs', $font); - $objWriter->endElement(); - } - - // Color - if($color != '000000') { - $objWriter->startElement('w:color'); - $objWriter->writeAttribute('w:val', $color); - $objWriter->endElement(); - } - - // Size - if($size != 20) { - $objWriter->startElement('w:sz'); - $objWriter->writeAttribute('w:val', $size); - $objWriter->endElement(); - $objWriter->startElement('w:szCs'); - $objWriter->writeAttribute('w:val', $size); - $objWriter->endElement(); - } - - // Bold - if($bold) { - $objWriter->writeElement('w:b', null); - } - - // Italic - if($italic) { - $objWriter->writeElement('w:i', null); - $objWriter->writeElement('w:iCs', null); - } - - // Underline - if(!is_null($underline) && $underline != 'none') { - $objWriter->startElement('w:u'); - $objWriter->writeAttribute('w:val', $underline); - $objWriter->endElement(); - } - - // Striketrough - if($striketrough) { - $objWriter->writeElement('w:strike', null); - } - - // Foreground-Color - if(!is_null($fgColor)) { - $objWriter->startElement('w:highlight'); - $objWriter->writeAttribute('w:val', $fgColor); - $objWriter->endElement(); - } - - $objWriter->endElement(); - } - - protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) { - $objWriter->writeElement('w:p', null); - } - - protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) { - $_rows = $table->getRows(); - $_cRows = count($_rows); - - if($_cRows > 0) { - $objWriter->startElement('w:tbl'); - $tblStyle = $table->getStyle(); - if($tblStyle instanceof PHPWord_Style_Table) { - $this->_writeTableStyle($objWriter, $tblStyle); - } else { - if(!empty($tblStyle)) { - $objWriter->startElement('w:tblPr'); - $objWriter->startElement('w:tblStyle'); - $objWriter->writeAttribute('w:val', $tblStyle); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - $_heights = $table->getRowHeights(); - for($i=0; $i<$_cRows; $i++) { - $row = $_rows[$i]; - $height = $_heights[$i]; - - $objWriter->startElement('w:tr'); - - if(!is_null($height)) { - $objWriter->startElement('w:trPr'); - $objWriter->startElement('w:trHeight'); - $objWriter->writeAttribute('w:val', $height); - $objWriter->endElement(); - $objWriter->endElement(); - } - - foreach($row as $cell) { - $objWriter->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(); - - if($cellStyle instanceof PHPWord_Style_Cell) { - $this->_writeCellStyle($objWriter, $cellStyle); - } - - $objWriter->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); - } elseif($element instanceof PHPWord_Section_ListItem) { - $this->_writeListItem($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Image || - $element instanceof PHPWord_Section_MemoryImage) { - $this->_writeImage($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Object) { - $this->_writeObject($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Footer_PreserveText) { - $this->_writePreserveText($objWriter, $element); - } - } - } else { - $this->_writeTextBreak($objWriter); - } - - $objWriter->endElement(); - } - $objWriter->endElement(); - } - $objWriter->endElement(); - } - } - - protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) { - $margins = $style->getCellMargin(); - $mTop = (!is_null($margins[0])) ? true : false; - $mLeft = (!is_null($margins[1])) ? true : false; - $mRight = (!is_null($margins[2])) ? true : false; - $mBottom = (!is_null($margins[3])) ? true : false; - - if($mTop || $mLeft || $mRight || $mBottom) { - $objWriter->startElement('w:tblPr'); - $objWriter->startElement('w:tblCellMar'); - - if($mTop) { - $objWriter->startElement('w:top'); - $objWriter->writeAttribute('w:w', $margins[0]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - - if($mLeft) { - $objWriter->startElement('w:left'); - $objWriter->writeAttribute('w:w', $margins[1]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - - if($mRight) { - $objWriter->startElement('w:right'); - $objWriter->writeAttribute('w:w', $margins[2]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - - if($mBottom) { - $objWriter->startElement('w:bottom'); - $objWriter->writeAttribute('w:w', $margins[3]); - $objWriter->writeAttribute('w:type', 'dxa'); - $objWriter->endElement(); - } - - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_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)) { - $objWriter->startElement('w:textDirection'); - $objWriter->writeAttribute('w:val', $textDir); - $objWriter->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(); - } - - if(!is_null($valign)) { - $objWriter->startElement('w:vAlign'); - $objWriter->writeAttribute('w:val', $valign); - $objWriter->endElement(); - } - - if($borders) { - $_defaultColor = $style->getDefaultBorderColor(); - - $objWriter->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(); - } - - 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(); - } - - 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(); - } - - 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(); - } - - $objWriter->endElement(); - } - } - $gridSpan = $style->getGridSpan(); - if(!is_null($gridSpan)) { - $objWriter->startElement('w:gridSpan'); - $objWriter->writeAttribute('w:val', $gridSpan); - $objWriter->endElement(); + if ($mLeft) { + $objWriter->startElement('w:left'); + $objWriter->writeAttribute('w:w', $margins[1]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + + if ($mRight) { + $objWriter->startElement('w:right'); + $objWriter->writeAttribute('w:w', $margins[2]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + + if ($mBottom) { + $objWriter->startElement('w:bottom'); + $objWriter->writeAttribute('w:w', $margins[3]); + $objWriter->writeAttribute('w:type', 'dxa'); + $objWriter->endElement(); + } + + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_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)) { + $objWriter->startElement('w:textDirection'); + $objWriter->writeAttribute('w:val', $textDir); + $objWriter->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(); + } + + if (!is_null($valign)) { + $objWriter->startElement('w:vAlign'); + $objWriter->writeAttribute('w:val', $valign); + $objWriter->endElement(); + } + + if ($borders) { + $_defaultColor = $style->getDefaultBorderColor(); + + $objWriter->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(); + } + + 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(); + } + + 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(); + } + + 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(); + } + + $objWriter->endElement(); + } + } + $gridSpan = $style->getGridSpan(); + if (!is_null($gridSpan)) { + $objWriter->startElement('w:gridSpan'); + $objWriter->writeAttribute('w:val', $gridSpan); + $objWriter->endElement(); + } + + $vMerge = $style->getVMerge(); + if (!is_null($vMerge)) { + $objWriter->startElement('w:vMerge'); + $objWriter->writeAttribute('w:val', $vMerge); + $objWriter->endElement(); + } } - $vMerge = $style->getVMerge(); - if(!is_null($vMerge)) { - $objWriter->startElement('w:vMerge'); - $objWriter->writeAttribute('w:val', $vMerge); - $objWriter->endElement(); + /** + * @param \PHPWord_Shared_XMLWriter $objWriter + * @param \PHPWord_Section_Image $image + */ + protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Image $image) + { + $rId = $image->getRelationId(); + + $style = $image->getStyle(); + $width = $style->getWidth(); + $height = $style->getHeight(); + $align = $style->getAlign(); + $marginTop = $style->getMarginTop(); + $marginLeft = $style->getMarginLeft(); + $wrappingStyle = $style->getWrappingStyle(); + + $objWriter->startElement('w:p'); + + if (!is_null($align)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:jc'); + $objWriter->writeAttribute('w:val', $align); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:r'); + + $objWriter->startElement('w:pict'); + + $objWriter->startElement('v:shape'); + $objWriter->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 PHPWord_Style_Image::WRAPPING_STYLE_BEHIND: + $imgStyle .= 'position:absolute;z-index:-251658752;'; + break; + case 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: + $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: + $imgStyle .= 'position:absolute;zz-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; + break; + } + + $objWriter->writeAttribute('style', $imgStyle); + + $objWriter->startElement('v:imagedata'); + $objWriter->writeAttribute('r:id', 'rId' . $rId); + $objWriter->writeAttribute('o:title', ''); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) + { + $rId = $image->getRelationId(); + + $style = $image->getStyle(); + $width = $style->getWidth(); + $height = $style->getHeight(); + $marginLeft = $style->getMarginLeft(); + $marginTop = $style->getMarginTop(); + + $objWriter->startElement('w:p'); + + $objWriter->startElement('w:r'); + + $objWriter->startElement('w:pict'); + + $objWriter->startElement('v:shape'); + $objWriter->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;'; + } + + $objWriter->writeAttribute('style', $strStyle); + + $objWriter->startElement('v:imagedata'); + $objWriter->writeAttribute('r:id', 'rId' . $rId); + $objWriter->writeAttribute('o:title', ''); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) + { + $text = htmlspecialchars($title->getText()); + $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); + $anchor = $title->getAnchor(); + $bookmarkId = $title->getBookmarkId(); + $style = $title->getStyle(); + + $objWriter->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(); } - } - - protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image) { - $rId = $image->getRelationId(); - - $style = $image->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $align = $style->getAlign(); - - $objWriter->startElement('w:p'); - - if(!is_null($align)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:jc'); - $objWriter->writeAttribute('w:val', $align); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:r'); - - $objWriter->startElement('w:pict'); - - $objWriter->startElement('v:shape'); - $objWriter->writeAttribute('type', '#_x0000_t75'); - $objWriter->writeAttribute('style', 'width:'.$width.'px;height:'.$height.'px'); - - $objWriter->startElement('v:imagedata'); - $objWriter->writeAttribute('r:id', 'rId'.$rId); - $objWriter->writeAttribute('o:title', ''); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->endElement(); - - $objWriter->endElement(); - - $objWriter->endElement(); - } - - protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) { - $rId = $image->getRelationId(); - - $style = $image->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $marginLeft = $style->getMarginLeft(); - $marginTop = $style->getMarginTop(); - - $objWriter->startElement('w:p'); - - $objWriter->startElement('w:r'); - - $objWriter->startElement('w:pict'); - - $objWriter->startElement('v:shape'); - $objWriter->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;'; - } - - $objWriter->writeAttribute('style', $strStyle); - - $objWriter->startElement('v:imagedata'); - $objWriter->writeAttribute('r:id', 'rId'.$rId); - $objWriter->writeAttribute('o:title', ''); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->endElement(); - - $objWriter->endElement(); - - $objWriter->endElement(); - } - - protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) { - $text = htmlspecialchars($title->getText()); - $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); - $anchor = $title->getAnchor(); - $bookmarkId = $title->getBookmarkId(); - $style = $title->getStyle(); - - $objWriter->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(); - } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/Classes/PHPWord/Writer/Word2007/ContentTypes.php b/Classes/PHPWord/Writer/Word2007/ContentTypes.php old mode 100644 new mode 100755 index e9d1b40cb2..6ec85179b1 --- a/Classes/PHPWord/Writer/Word2007/ContentTypes.php +++ b/Classes/PHPWord/Writer/Word2007/ContentTypes.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/Word2007/DocProps.php b/Classes/PHPWord/Writer/Word2007/DocProps.php old mode 100644 new mode 100755 index 529fe615bb..2740d8dab8 --- a/Classes/PHPWord/Writer/Word2007/DocProps.php +++ b/Classes/PHPWord/Writer/Word2007/DocProps.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/Word2007/Document.php b/Classes/PHPWord/Writer/Word2007/Document.php old mode 100644 new mode 100755 index 4543aeae27..6539dd21e9 --- a/Classes/PHPWord/Writer/Word2007/Document.php +++ b/Classes/PHPWord/Writer/Word2007/Document.php @@ -2,7 +2,7 @@ /** * PHPWord * - * Copyright (c) 2011 PHPWord + * Copyright (c) 2013 PHPWord * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,439 +20,450 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 010 PHPWord + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version Beta 0.6.3, 08.07.2011 + * @version 0.7.0 */ +/** + * Class PHPWord_Writer_Word2007_Document + */ +class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base +{ + + public function writeDocument(PHPWord $pPHPWord = null) + { + // Create XML writer + + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // w:document + $objWriter->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'); + + $objWriter->startElement('w:body'); + + $_sections = $pPHPWord->getSections(); + $countSections = count($_sections); + $pSection = 0; + + if ($countSections > 0) { + foreach ($_sections as $section) { + $pSection++; + + $_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); + } 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 + ) { + $this->_writeImage($objWriter, $element); + } elseif ($element instanceof PHPWord_Section_Object) { + $this->_writeObject($objWriter, $element); + } elseif ($element instanceof PHPWord_TOC) { + $this->_writeTOC($objWriter); + } + } + + if ($pSection == $countSections) { + $this->_writeEndSection($objWriter, $section); + } else { + $this->_writeSection($objWriter, $section); + } + } + } + + $objWriter->endElement(); // End w:body + $objWriter->endElement(); // End w:document + + // Return + return $objWriter->getData(); + } + + private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) + { + $objWriter->startElement('w:p'); + $objWriter->startElement('w:pPr'); + $this->_writeEndSection($objWriter, $section, 3); + $objWriter->endElement(); + $objWriter->endElement(); + } + + private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_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(); + + $borders = $_settings->getBorderSize(); + + $objWriter->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(); + } -class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base { - - public function writeDocument(PHPWord $pPHPWord = null) { - // Create XML writer - - if($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); - } - - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); - - // w:document - $objWriter->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'); - - $objWriter->startElement('w:body'); - - $_sections = $pPHPWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if($countSections > 0) { - foreach($_sections as $section) { - $pSection++; - - $_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); - } 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) { - $this->_writeImage($objWriter, $element); - } elseif($element instanceof PHPWord_Section_Object) { - $this->_writeObject($objWriter, $element); - } elseif($element instanceof PHPWord_TOC) { - $this->_writeTOC($objWriter); - } - } - - if($pSection == $countSections) { - $this->_writeEndSection($objWriter, $section); - } else { - $this->_writeSection($objWriter, $section); - } - } - } - - $objWriter->endElement(); // End w:body - $objWriter->endElement(); // End w:document - - // Return - return $objWriter->getData(); - } - - private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) { - $objWriter->startElement('w:p'); - $objWriter->startElement('w:pPr'); - $this->_writeEndSection($objWriter, $section, 3); - $objWriter->endElement(); - $objWriter->endElement(); - } - - private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_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(); - - $borders = $_settings->getBorderSize(); - - $objWriter->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(); - } - - if($section->hasDifferentFirstPage()) { - $objWriter->startElement('w:titlePg'); - $objWriter->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(); - } - - $objWriter->startElement('w:pgSz'); - $objWriter->writeAttribute('w:w', $pgSzW); - $objWriter->writeAttribute('w:h', $pgSzH); - - if(!is_null($orientation) && strtolower($orientation) != 'portrait') { - $objWriter->writeAttribute('w:orient', $orientation); - } - - $objWriter->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', '720'); - $objWriter->writeAttribute('w:footer', '720'); - $objWriter->writeAttribute('w:gutter', '0'); - $objWriter->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'); - - 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(); - } - - 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(); - } - - 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(); - } - - 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(); - } - $objWriter->endElement(); - } - - - $objWriter->startElement('w:cols'); - $objWriter->writeAttribute('w:space', '720'); - $objWriter->endElement(); - - - $objWriter->endElement(); - } - - private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null) { - $objWriter->startElement('w:p'); - $objWriter->startElement('w:r'); - $objWriter->startElement('w:br'); - $objWriter->writeAttribute('w:type', 'page'); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - } - - private function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem) { - $textObject = $listItem->getTextObject(); - $text = $textObject->getText(); + if ($section->hasDifferentFirstPage()) { + $objWriter->startElement('w:titlePg'); + $objWriter->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(); + } + + $objWriter->startElement('w:pgSz'); + $objWriter->writeAttribute('w:w', $pgSzW); + $objWriter->writeAttribute('w:h', $pgSzH); + + if (!is_null($orientation) && strtolower($orientation) != 'portrait') { + $objWriter->writeAttribute('w:orient', $orientation); + } + + $objWriter->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', '720'); + $objWriter->writeAttribute('w:footer', '720'); + $objWriter->writeAttribute('w:gutter', '0'); + $objWriter->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'); + + 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(); + } + + 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(); + } + + 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(); + } + + 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(); + } + $objWriter->endElement(); + } + + + $objWriter->startElement('w:cols'); + $objWriter->writeAttribute('w:space', '720'); + $objWriter->endElement(); + + + $objWriter->endElement(); + } + + private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null) + { + $objWriter->startElement('w:p'); + $objWriter->startElement('w:r'); + $objWriter->startElement('w:br'); + $objWriter->writeAttribute('w:type', 'page'); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } + + private function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem) + { + $textObject = $listItem->getTextObject(); + $text = $textObject->getText(); $styleParagraph = $textObject->getParagraphStyle(); $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false; - - $depth = $listItem->getDepth(); - $listType = $listItem->getStyle()->getListType(); - - $objWriter->startElement('w:p'); - $objWriter->startElement('w:pPr'); - - if($SpIsObject) { - $this->_writeParagraphStyle($objWriter, $styleParagraph, true); - } elseif(!$SpIsObject && !is_null($styleParagraph)) { - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleParagraph); - $objWriter->endElement(); - } - - $objWriter->startElement('w:numPr'); - - $objWriter->startElement('w:ilvl'); - $objWriter->writeAttribute('w:val', $depth); - $objWriter->endElement(); - - $objWriter->startElement('w:numId'); - $objWriter->writeAttribute('w:val', $listType); - $objWriter->endElement(); - - $objWriter->endElement(); - $objWriter->endElement(); - - $this->_writeText($objWriter, $textObject, true); - - $objWriter->endElement(); - } - - protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_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(); - - - $objWriter->startElement('w:p'); - - if(!is_null($align)) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:jc'); - $objWriter->writeAttribute('w:val', $align); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:r'); - - $objWriter->startElement('w:object'); - $objWriter->writeAttribute('w:dxaOrig', '249'); - $objWriter->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', ''); - - $objWriter->startElement('v:imagedata'); - $objWriter->writeAttribute('r:id', 'rId'.$rIdImage); - $objWriter->writeAttribute('o:title', ''); - $objWriter->endElement(); - - $objWriter->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(); - - $objWriter->endElement(); - - $objWriter->endElement(); // w:r - - $objWriter->endElement(); // w:p - } - - private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null) { - $titles = PHPWord_TOC::getTitles(); - $styleFont = PHPWord_TOC::getStyleFont(); - - $styleTOC = PHPWord_TOC::getStyleTOC(); - $fIndent = $styleTOC->getIndent(); - $tabLeader = $styleTOC->getTabLeader(); - $tabPos = $styleTOC->getTabPos(); - - $isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; - - for($i=0; $istartElement('w:p'); - - $objWriter->startElement('w:pPr'); - - if($isObject && !is_null($styleFont->getParagraphStyle())) { - $this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle()); - } - - if($indent > 0) { - $objWriter->startElement('w:ind'); - $objWriter->writeAttribute('w:left', $indent); - $objWriter->endElement(); - } - - if(!empty($styleFont) && !$isObject) { - $objWriter->startElement('w:pPr'); - $objWriter->startElement('w:pStyle'); - $objWriter->writeAttribute('w:val', $styleFont); - $objWriter->endElement(); - $objWriter->endElement(); - } - - $objWriter->startElement('w:tabs'); - $objWriter->startElement('w:tab'); - $objWriter->writeAttribute('w:val', 'right'); - if(!empty($tabLeader)) { - $objWriter->writeAttribute('w:leader', $tabLeader); - } - $objWriter->writeAttribute('w:pos', $tabPos); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->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(); - } - - $objWriter->startElement('w:hyperlink'); - $objWriter->writeAttribute('w:anchor', $title['anchor']); - $objWriter->writeAttribute('w:history', '1'); - - $objWriter->startElement('w:r'); - - if($isObject) { - $this->_writeTextStyle($objWriter, $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 - } - - $objWriter->startElement('w:p'); - $objWriter->startElement('w:r'); - $objWriter->startElement('w:fldChar'); - $objWriter->writeAttribute('w:fldCharType', 'end'); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - } + + $depth = $listItem->getDepth(); + $listType = $listItem->getStyle()->getListType(); + + $objWriter->startElement('w:p'); + $objWriter->startElement('w:pPr'); + + if ($SpIsObject) { + $this->_writeParagraphStyle($objWriter, $styleParagraph, true); + } elseif (!$SpIsObject && !is_null($styleParagraph)) { + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleParagraph); + $objWriter->endElement(); + } + + $objWriter->startElement('w:numPr'); + + $objWriter->startElement('w:ilvl'); + $objWriter->writeAttribute('w:val', $depth); + $objWriter->endElement(); + + $objWriter->startElement('w:numId'); + $objWriter->writeAttribute('w:val', $listType); + $objWriter->endElement(); + + $objWriter->endElement(); + $objWriter->endElement(); + + $this->_writeText($objWriter, $textObject, true); + + $objWriter->endElement(); + } + + protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_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(); + + + $objWriter->startElement('w:p'); + + if (!is_null($align)) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:jc'); + $objWriter->writeAttribute('w:val', $align); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:r'); + + $objWriter->startElement('w:object'); + $objWriter->writeAttribute('w:dxaOrig', '249'); + $objWriter->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', ''); + + $objWriter->startElement('v:imagedata'); + $objWriter->writeAttribute('r:id', 'rId' . $rIdImage); + $objWriter->writeAttribute('o:title', ''); + $objWriter->endElement(); + + $objWriter->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(); + + $objWriter->endElement(); + + $objWriter->endElement(); // w:r + + $objWriter->endElement(); // w:p + } + + private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null) + { + $titles = PHPWord_TOC::getTitles(); + $styleFont = PHPWord_TOC::getStyleFont(); + + $styleTOC = PHPWord_TOC::getStyleTOC(); + $fIndent = $styleTOC->getIndent(); + $tabLeader = $styleTOC->getTabLeader(); + $tabPos = $styleTOC->getTabPos(); + + $isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; + + for ($i = 0; $i < count($titles); $i++) { + $title = $titles[$i]; + $indent = ($title['depth'] - 1) * $fIndent; + + $objWriter->startElement('w:p'); + + $objWriter->startElement('w:pPr'); + + if ($isObject && !is_null($styleFont->getParagraphStyle())) { + $this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle()); + } + + if ($indent > 0) { + $objWriter->startElement('w:ind'); + $objWriter->writeAttribute('w:left', $indent); + $objWriter->endElement(); + } + + if (!empty($styleFont) && !$isObject) { + $objWriter->startElement('w:pPr'); + $objWriter->startElement('w:pStyle'); + $objWriter->writeAttribute('w:val', $styleFont); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('w:tabs'); + $objWriter->startElement('w:tab'); + $objWriter->writeAttribute('w:val', 'right'); + if (!empty($tabLeader)) { + $objWriter->writeAttribute('w:leader', $tabLeader); + } + $objWriter->writeAttribute('w:pos', $tabPos); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->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(); + } + + $objWriter->startElement('w:hyperlink'); + $objWriter->writeAttribute('w:anchor', $title['anchor']); + $objWriter->writeAttribute('w:history', '1'); + + $objWriter->startElement('w:r'); + + if ($isObject) { + $this->_writeTextStyle($objWriter, $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 + } + + $objWriter->startElement('w:p'); + $objWriter->startElement('w:r'); + $objWriter->startElement('w:fldChar'); + $objWriter->writeAttribute('w:fldCharType', 'end'); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } } diff --git a/Classes/PHPWord/Writer/Word2007/DocumentRels.php b/Classes/PHPWord/Writer/Word2007/DocumentRels.php old mode 100644 new mode 100755 index a19084a9ad..b284f0b985 --- a/Classes/PHPWord/Writer/Word2007/DocumentRels.php +++ b/Classes/PHPWord/Writer/Word2007/DocumentRels.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/Word2007/Footer.php b/Classes/PHPWord/Writer/Word2007/Footer.php old mode 100644 new mode 100755 index d6e03a635d..363e05312f --- a/Classes/PHPWord/Writer/Word2007/Footer.php +++ b/Classes/PHPWord/Writer/Word2007/Footer.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/Word2007/Header.php b/Classes/PHPWord/Writer/Word2007/Header.php old mode 100644 new mode 100755 index 97d9a7b42c..4f4eacd8eb --- a/Classes/PHPWord/Writer/Word2007/Header.php +++ b/Classes/PHPWord/Writer/Word2007/Header.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/Word2007/Rels.php b/Classes/PHPWord/Writer/Word2007/Rels.php old mode 100644 new mode 100755 index 39d3740597..6d72839b7e --- a/Classes/PHPWord/Writer/Word2007/Rels.php +++ b/Classes/PHPWord/Writer/Word2007/Rels.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/Word2007/Styles.php b/Classes/PHPWord/Writer/Word2007/Styles.php old mode 100644 new mode 100755 index 2253d99511..71aca63711 --- a/Classes/PHPWord/Writer/Word2007/Styles.php +++ b/Classes/PHPWord/Writer/Word2007/Styles.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/Classes/PHPWord/Writer/Word2007/WriterPart.php b/Classes/PHPWord/Writer/Word2007/WriterPart.php old mode 100644 new mode 100755 index 9291d28ca0..a6168a841e --- a/Classes/PHPWord/Writer/Word2007/WriterPart.php +++ b/Classes/PHPWord/Writer/Word2007/WriterPart.php @@ -20,7 +20,7 @@ * * @category PHPWord * @package PHPWord - * @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord) + * @copyright Copyright (c) 2013 PHPWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version 0.7.0 */ diff --git a/README.md b/README.md old mode 100644 new mode 100755 index b23011b5e8..21c15959ac --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('helloWorld.docx'); ``` -## Image +## Images You can add images easily using the following example. diff --git a/changelog.txt b/changelog.txt old mode 100644 new mode 100755 index 9770653f17..13dfb27e2e --- a/changelog.txt +++ b/changelog.txt @@ -22,7 +22,7 @@ * @version ##VERSION##, ##DATE## ************************************************************************************** -Fixed in branch for release 0.7 : +Fixed in branch for release 0.7.0 : - Bugfix: (RomanSyroeshko) GH-32 - "Warning: Invalid error type specified in ...\PHPWord.php on line 226" is thrown when the specified template file is not found - Bugfix: (RomanSyroeshko) GH-34 - PHPWord_Shared_String.IsUTF8 returns FALSE for Cyrillic UTF-8 input - Bugfix: (RomanSyroeshko) GH-38 - Temporary files naming logic in PHPWord_Template can lead to a collision @@ -38,5 +38,4 @@ Fixed in branch for release 0.7 : - General: (Progi1984) - Added PHPWord_Exception and exception when could not copy the template - General: (Progi1984) - IMPROVED : Moved examples out of Classes directory - General: (Esmeraldo) CP-49 - IMPROVED : Advanced string replace in setValue for Template -- Feature: (gavroche) Added composer file -- Feature: (gavroche) Added support for image wrapping style +- Feature: (gavroche) - Added support for image wrapping style diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php old mode 100644 new mode 100755 index d421c37d42..b2d6593a75 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -49,4 +49,3 @@ // Echo done echo date('H:i:s') , " Done writing file" , EOL; -?> \ No newline at end of file diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php old mode 100644 new mode 100755 index 3c4d3841a1..177e8598f1 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -60,5 +60,4 @@ echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL; // Echo done -echo date('H:i:s') , ' Done writing file' , EOL; -?> \ No newline at end of file +echo date('H:i:s') , ' Done writing file' , EOL; \ No newline at end of file diff --git a/samples/old/AdvancedTable.php b/samples/old/AdvancedTable.php old mode 100644 new mode 100755 index e83c4e9886..021cd9201b --- a/samples/old/AdvancedTable.php +++ b/samples/old/AdvancedTable.php @@ -50,4 +50,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('AdvancedTable.docx'); -?> \ No newline at end of file diff --git a/samples/old/BasicTable.php b/samples/old/BasicTable.php old mode 100644 new mode 100755 index 9e05712e62..6bd8336aa3 --- a/samples/old/BasicTable.php +++ b/samples/old/BasicTable.php @@ -23,4 +23,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('BasicTable.docx'); -?> \ No newline at end of file diff --git a/samples/old/HeaderFooter.php b/samples/old/HeaderFooter.php old mode 100644 new mode 100755 index addb3d8d87..ae3ce5accb --- a/samples/old/HeaderFooter.php +++ b/samples/old/HeaderFooter.php @@ -54,4 +54,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('HeaderFooter.docx'); -?> \ No newline at end of file diff --git a/samples/old/Image.php b/samples/old/Image.php old mode 100644 new mode 100755 index 6316783fb9..5018e20688 --- a/samples/old/Image.php +++ b/samples/old/Image.php @@ -21,4 +21,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('Image.docx'); -?> \ No newline at end of file diff --git a/samples/old/Link.php b/samples/old/Link.php old mode 100644 new mode 100755 index 5cd98bb846..8ad5575e9d --- a/samples/old/Link.php +++ b/samples/old/Link.php @@ -21,4 +21,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('Link.docx'); -?> \ No newline at end of file diff --git a/samples/old/ListItem.php b/samples/old/ListItem.php old mode 100644 new mode 100755 index 2e88e853fd..e0125980fb --- a/samples/old/ListItem.php +++ b/samples/old/ListItem.php @@ -44,4 +44,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('ListItem.docx'); -?> \ No newline at end of file diff --git a/samples/old/Object.php b/samples/old/Object.php old mode 100644 new mode 100755 index fb2f6ca989..b54df97147 --- a/samples/old/Object.php +++ b/samples/old/Object.php @@ -17,4 +17,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('Object.docx'); -?> diff --git a/samples/old/Section.php b/samples/old/Section.php old mode 100644 new mode 100755 index 6c31e35b06..875e9fc27c --- a/samples/old/Section.php +++ b/samples/old/Section.php @@ -23,4 +23,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('Section.docx'); -?> \ No newline at end of file diff --git a/samples/old/Template.php b/samples/old/Template.php old mode 100644 new mode 100755 index f4f5c15679..1b4472b16c --- a/samples/old/Template.php +++ b/samples/old/Template.php @@ -20,4 +20,3 @@ $document->setValue('time', date('H:i')); $document->save('Solarsystem.docx'); -?> \ No newline at end of file diff --git a/samples/old/Textrun.php b/samples/old/Textrun.php old mode 100644 new mode 100755 index 34dd6b5071..3fa12d97e3 --- a/samples/old/Textrun.php +++ b/samples/old/Textrun.php @@ -29,4 +29,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('Textrun.docx'); -?> \ No newline at end of file diff --git a/samples/old/TitleTOC.php b/samples/old/TitleTOC.php old mode 100644 new mode 100755 index 40135658fa..376d26e844 --- a/samples/old/TitleTOC.php +++ b/samples/old/TitleTOC.php @@ -46,4 +46,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('TitleTOC.docx'); -?> diff --git a/samples/old/Watermark.php b/samples/old/Watermark.php old mode 100644 new mode 100755 index 6402e24506..319221c13e --- a/samples/old/Watermark.php +++ b/samples/old/Watermark.php @@ -18,4 +18,3 @@ // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('Watermark.docx'); -?> \ No newline at end of file diff --git a/test/PHPWord/Tests/ImageTest.php b/test/PHPWord/Tests/ImageTest.php old mode 100644 new mode 100755 index c1ee9afd0d..81b2467733 --- a/test/PHPWord/Tests/ImageTest.php +++ b/test/PHPWord/Tests/ImageTest.php @@ -4,8 +4,6 @@ use PHPUnit_Framework_TestCase; use PHPWord; -require_once __DIR__ . '/../../../src/PHPWord.php'; - class ImageTest extends PHPUnit_Framework_TestCase { public function tearDown() diff --git a/test/bootstrap.php b/test/bootstrap.php old mode 100644 new mode 100755 index 0ca799f67c..b03b68cea2 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -2,7 +2,7 @@ date_default_timezone_set('UTC'); -require_once __DIR__ . "/../src/PHPWord/Autoloader.php"; +require_once __DIR__ . "/../Classes/PHPWord/Autoloader.php"; PHPWord_Autoloader::Register(); require_once __DIR__ . "/PHPWord/TestHelper.php";