diff --git a/.gitignore b/.gitignore
index 81767f6bfb..2ea4fd9d4f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
Thumbs.db
Desktop.ini
.idea
+_build
phpunit.xml
composer.lock
composer.phar
@@ -12,10 +13,4 @@ vendor
/report
/.settings
/.buildpath
-/.project
-/docs
-*.odt
-*.docx
-*.rtf
-*.txt
-*.xml
\ No newline at end of file
+/.project
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 77b9ca0d2c..8ed7a45feb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,46 +1,49 @@
language: php
+
php:
+ - 5.3.3
- 5.3
- 5.4
- 5.5
- ## @reference https://github.com/travis-ci/travis-ci/issues/1749
+ - 5.6
- hhvm
+
matrix:
allow_failures:
+ - php: 5.3.3
+ - php: 5.6
- php: hhvm
-
+
before_script:
## Composer
- - curl -s http://getcomposer.org/installer | php
- - php composer.phar install --prefer-source
+ # - curl -s http://getcomposer.org/installer | php
+ # - php composer.phar install --prefer-source
+ - composer install --prefer-source
+ - composer selfupdate --quiet
## PHP_CodeSniffer
- pyrus install pear/PHP_CodeSniffer
- phpenv rehash
## PHP Copy/Paste Detector
- - curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
+ #- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
## PHP Mess Detector
- - pear config-set preferred_state beta
- - printf "\n" | pecl install imagick
+ #- pear config-set preferred_state beta
+ #- printf "\n" | pecl install imagick
#- pear channel-discover pear.phpmd.org
#- pear channel-discover pear.pdepend.org
#- pear install --alldeps phpmd/PHP_PMD
- - phpenv rehash
+ #- phpenv rehash
## PHPLOC
- - curl -o phploc.phar https://phar.phpunit.de/phploc.phar
+ #- curl -o phploc.phar https://phar.phpunit.de/phploc.phar
script:
## PHP_CodeSniffer
- - phpcs --standard=PSR1 Classes/
- - phpcs --standard=PSR2 Classes/
+ - phpcs --standard=PSR2 -n src/
+ - phpcs --standard=PSR2 -n tests/
## PHP Copy/Paste Detector
- - php phpcpd.phar --verbose Classes/
+ #- php phpcpd.phar --verbose src/
## PHP Mess Detector
- #- phpmd Classes/ text unusedcode,naming,design
+ #- phpmd src/ text unusedcode,naming,design
## PHPLOC
- - php phploc.phar Classes/
+ #- php phploc.phar src/
## PHPUnit
- phpunit -c ./ --coverage-text
-
-notifications:
- email:
- - progi1984@gmail.com
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100755
index 0000000000..867bb2aade
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,111 @@
+# Changelog
+
+This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub.
+
+## 0.9.0 - Not yet released
+
+This release marked the transformation to namespaces (PHP 5.3+).
+
+### Features
+
+- Image: Ability to use remote or GD images using `addImage()` on sections, headers, footer, cells, and textruns - @ivanlanin
+- Header: Ability to use remote or GD images using `addWatermark()` - @ivanlanin
+
+### Bugfixes
+
+- Preserve text doesn't render correctly when the text is not the first word, e.g. 'Page {PAGE}' - @ivanlanin
+
+### Miscellaneous
+
+- Move documentation to [Read The Docs](http://phpword.readthedocs.org/en/develop/) - @Progi1984 @ivanlanin GH-82
+- Reorganize and redesign samples folder - @ivanlanin GH-137
+- Use `PhpOffice\PhpWord` namespace for PSR compliance - @RomanSyroeshko @gabrielbull GH-159 GH-58
+- Restructure folders and change folder name `Classes` to `src` and `Tests` to `test` for PSR compliance - @RomanSyroeshko @gabrielbull
+- Compliance to phpDocumentor - @ivanlanin
+- Merge Style\TableFull into Style\Table. Style\TableFull is deprecated - @ivanlanin GH-160
+- Merge Section\MemoryImage into Section\Image. Section\Image is deprecated - @ivanlanin GH-160
+
+## 0.8.1 - 17 Mar 2014
+
+This is a bugfix release for image detection functionality.
+
+- Added fallback for computers that do not have exif_imagetype - @bskrtich, @gabrielbull
+
+## 0.8.0 - 15 Mar 2014
+
+This release merged a lot of improvements from the community. Unit tests introduced in this release and has reached 90% code coverage.
+
+### Features
+
+- Template: Permit to save a template generated as a file (PHPWord_Template::saveAs()) - @RomanSyroeshko GH-56 GH-57
+- Word2007: Support sections page numbering - @gabrielbull
+- Word2007: Added line height methods to mirror the line height settings in Word in the paragraph styling - @gabrielbull
+- Word2007: Added support for page header & page footer height - @JillElaine GH-5
+- General: Add ability to manage line breaks after image insertion - @bskrtich GH-6 GH-66 GH-84
+- Template: Ability to limit number of replacements performed by setValue() method of Template class - @RomanSyroeshko GH-52 GH-53 GH-85
+- Table row: Repeat as header row & allow row to break across pages - @ivanlanin GH-48 GH-86
+- Table: Table width in percentage - @ivanlanin GH-48 GH-86
+- Font: Superscript and subscript - @ivanlanin GH-48 GH-86
+- Paragraph: Hanging paragraph - @ivanlanin GH-48 GH-86
+- Section: Multicolumn and section break - @ivanlanin GH-48 GH-86
+- Template: Ability to apply XSL style sheet to Template - @RomanSyroeshko GH-46 GH-47 GH-83
+- General: PHPWord_Shared_Font::pointSizeToTwips() converter - @ivanlanin GH-87
+- Paragraph: Ability to define normal paragraph style with PHPWord::setNormalStyle() - @ivanlanin GH-87
+- Paragraph: Ability to define parent style (basedOn) and style for following paragraph (next) - @ivanlanin GH-87
+- Clone table rows on the fly when using a template document - @jeroenmoors GH-44 GH-88
+- Initial addition of basic footnote support - @deds GH-16
+- Paragraph: Ability to define paragraph pagination: widow control, keep next, keep lines, and page break before - @ivanlanin GH-92
+- General: PHPWord_Style_Font refactoring - @ivanlanin GH-93
+- Font: Use points instead of halfpoints internally. Conversion to halfpoints done during XML Writing. - @ivanlanin GH-93
+- Paragraph: setTabs() function - @ivanlanin GH-92
+- General: Basic support for TextRun on ODT and RTF - @ivanlanin GH-99
+- Reader: Basic Reader for Word2007 - @ivanlanin GH-104
+- TextRun: Allow Text Break in Text Run - @bskrtich GH-109
+- General: Support for East Asian fontstyle - @jhfangying GH-111 GH-118
+- Image: Use exif_imagetype to check image format instead of extension name - @gabrielbull GH-114
+- General: Setting for XMLWriter Compatibility option - @bskrtich GH-103
+- MemoryImage: Allow remote image when allow_url_open = on - @ivanlanin GH-122
+- TextBreak: Allow font and paragraph style for text break - @ivanlanin GH-18
+
+### Bugfixes
+
+- Fixed bug with cell styling - @gabrielbull
+- Fixed bug list items inside of cells - @gabrielbull
+- Adding a value that contains "&" in a template breaks it - @SiebelsTim GH-51
+- Example in README.md is broken - @Progi1984 GH-89
+- General: PHPWord_Shared_Drawing::centimetersToPixels() conversion - @ivanlanin GH-94
+- Footnote: Corrupt DOCX reported by MS Word when sections > 1 and not every sections have footnote - @ivanlanin GH-125
+
+### Miscellaneous
+
+- UnitTests - @Progi1984
+
+## 0.7.0 - 28 Jan 2014
+
+This is the first release after a long development hiatus in [CodePlex](https://phpword.codeplex.com/). This release initialized ODT and RTF Writer, along with some other new features for the existing Word2007 Writer, e.g. tab, multiple header, rowspan and colspan. [Composer](https://packagist.org/packages/phpoffice/phpword) and [Travis](https://travis-ci.org/PHPOffice/PHPWord) were added.
+
+### Features
+
+- Implement RTF Writer - @Progi1984 GH-1
+- Implement ODT Writer - @Progi1984 GH-2
+- Word2007: Add rowspan and colspan to cells - @kaystrobach
+- Word2007: Support for tab stops - @RLovelett
+- Word2007: Support Multiple headers - @RLovelett
+- Word2007: Wrapping Styles to Images - @gabrielbull
+- Added support for image wrapping style - @gabrielbull
+
+### Bugfixes
+
+- "Warning: Invalid error type specified in ...\PHPWord.php on line 226" is thrown when the specified template file is not found - @RomanSyroeshko GH-32
+- PHPWord_Shared_String.IsUTF8 returns FALSE for Cyrillic UTF-8 input - @RomanSyroeshko GH-34
+- Temporary files naming logic in PHPWord_Template can lead to a collision - @RomanSyroeshko GH-38
+
+### Miscellaneous
+
+- Add superscript/subscript styling in Excel2007 Writer - @MarkBaker
+- add indentation support to paragraphs - @deds
+- Support for Composer - @Progi1984 GH-27
+- Basic CI with Travis - @Progi1984
+- Added PHPWord_Exception and exception when could not copy the template - @Progi1984
+- IMPROVED: Moved examples out of Classes directory - @Progi1984
+- IMPROVED: Advanced string replace in setValue for Template - @Esmeraldo CP-49
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000..34985610b0
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,14 @@
+# Contributing to PHPWord
+
+PHPWord is build by the crowd and for the crowd. Every contributions are welcomed; either by [submitting](https://github.com/PHPOffice/PHPWord/issues) bug issues or suggesting improvements, or in a more active form like [requesting](https://github.com/PHPOffice/PHPWord/pulls) a pull.
+
+We want to create a high quality document writer and reader library that people can use with more confidence and less bugs. We want to collaborate happily, code joyfully, and get a life merrily. Thus, below are some guidelines that we expect to be followed by each contributor.
+
+- **Be brief, but be bold**: State your issues briefly, but speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations.
+- **Code in PSR**: We use PHP Standards Recommendation (PSR) from as the PHP Framework Interoperability Group (PHP-FIG). If you're not familiar with this standard, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to check your code against this standard.
+- **Test your code**: Nobody else knows your code better than you. So, please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework.
+- **Request pull in separate branch**: Do not submit your request to the master branch, but create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get you familiar with forks and how git works in general.
+
+That's it. Thank you for your interest in PHPWord, and welcome!
+
+May the Force be with you.
\ No newline at end of file
diff --git a/Classes/PHPWord.php b/Classes/PHPWord.php
deleted file mode 100755
index 43ba3e7ea7..0000000000
--- a/Classes/PHPWord.php
+++ /dev/null
@@ -1,276 +0,0 @@
-_properties = new PHPWord_DocumentProperties();
- $this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
- $this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
- }
-
- /**
- * 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 (in points)
- * @return string
- */
- public function getDefaultFontSize()
- {
- return $this->_defaultFontSize;
- }
-
- /**
- * Set default Font size (in points)
- * @param int $pValue
- */
- public function setDefaultFontSize($pValue)
- {
- $this->_defaultFontSize = $pValue;
- }
-
- /**
- * Set default paragraph style definition to styles.xml
- *
- * @param array $styles Paragraph style definition
- */
- public function setDefaultParagraphStyle($styles)
- {
- PHPWord_Style::setDefaultParagraphStyle($styles);
- }
-
- /**
- * 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;
- }
-
- /**
- * Load a Template File
- *
- * @param string $strFilename
- * @return PHPWord_Template
- */
- public function loadTemplate($strFilename)
- {
- if (file_exists($strFilename)) {
- $template = new PHPWord_Template($strFilename);
- return $template;
- } else {
- throw new PHPWord_Exception(
- "Template file {$strFilename} not found."
- );
- }
- }
-
- /**
- * Get section count
- * @return int
- */
- private function _countSections()
- {
- return count($this->_sectionCollection);
- }
-}
diff --git a/Classes/PHPWord/Exceptions/InvalidImageException.php b/Classes/PHPWord/Exceptions/InvalidImageException.php
deleted file mode 100644
index eda84a8d19..0000000000
--- a/Classes/PHPWord/Exceptions/InvalidImageException.php
+++ /dev/null
@@ -1,15 +0,0 @@
- 'IWriter', 'path' => 'PHPWord/Writer/{0}.php', 'class' => 'PHPWord_Writer_{0}'),
- array('type' => 'IReader', 'path' => 'PHPWord/Reader/{0}.php', 'class' => 'PHPWord_Reader_{0}' ),
- );
-
- /**
- * Autoresolve classes
- *
- * @var array
- */
- private static $_autoResolveClasses = array(
- 'Serialized'
- );
-
- /**
- * Private constructor for PHPWord_IOFactory
- */
- private function __construct()
- {
- }
-
- /**
- * Get search locations
- *
- * @return array
- */
- public static function getSearchLocations()
- {
- return self::$_searchLocations;
- }
-
- /**
- * Set search locations
- *
- * @param array $value
- * @throws Exception
- */
- public static function setSearchLocations($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");
- }
-
- /**
- * Create PHPWord_Reader_IReader
- *
- * @param string $readerType Example: Word2007
- * @return PHPWord_Reader_IReader
- */
- public static function createReader($readerType = '')
- {
- $searchType = 'IReader';
-
- foreach (self::$_searchLocations as $searchLocation) {
- if ($searchLocation['type'] == $searchType) {
- $className = str_replace('{0}', $readerType, $searchLocation['class']);
-
- $instance = new $className();
- if ($instance !== null) {
- return $instance;
- }
- }
- }
-
- throw new PHPWord_Exception("No $searchType found for type $readerType");
- }
-
- /**
- * Loads PHPWord from file
- *
- * @param string $pFilename The name of the file
- * @return PHPWord
- */
- public static function load($pFilename, $readerType = 'Word2007')
- {
- $reader = self::createReader($readerType);
- return $reader->load($pFilename);
- }
-}
diff --git a/Classes/PHPWord/Section/Image.php b/Classes/PHPWord/Section/Image.php
deleted file mode 100755
index 30a1044962..0000000000
--- a/Classes/PHPWord/Section/Image.php
+++ /dev/null
@@ -1,175 +0,0 @@
-_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 (isset($style['wrappingStyle'])) {
- $this->_style->setWrappingStyle($style['wrappingStyle']);
- }
-
- if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) {
- $imgData = getimagesize($this->_src);
- $this->_style->setWidth($imgData[0]);
- $this->_style->setHeight($imgData[1]);
- }
- }
-
- /**
- * Get Image style
- *
- * @return PHPWord_Style_Image
- */
- public function getStyle()
- {
- return $this->_style;
- }
-
- /**
- * Get Image Relation ID
- *
- * @return int
- */
- public function getRelationId()
- {
- return $this->_rId;
- }
-
- /**
- * Set Image Relation ID
- *
- * @param int $rId
- */
- public function setRelationId($rId)
- {
- $this->_rId = $rId;
- }
-
- /**
- * Get Image Source
- *
- * @return string
- */
- public function getSource()
- {
- return $this->_src;
- }
-
- /**
- * Get Image Media ID
- *
- * @return string
- */
- public function getMediaId()
- {
- return md5($this->_src);
- }
-
- /**
- * Get IsWatermark
- *
- * @return int
- */
- public function getIsWatermark()
- {
- return $this->_isWatermark;
- }
-
- /**
- * Set IsWatermark
- *
- * @param bool $pValue
- */
- public function setIsWatermark($pValue)
- {
- $this->_isWatermark = $pValue;
- }
-}
diff --git a/Classes/PHPWord/Section/MemoryImage.php b/Classes/PHPWord/Section/MemoryImage.php
deleted file mode 100755
index 9d4ed97c0e..0000000000
--- a/Classes/PHPWord/Section/MemoryImage.php
+++ /dev/null
@@ -1,232 +0,0 @@
-_imageType = $imgData['mime'];
-
- $_supportedImageTypes = array('image/jpeg', 'image/gif', 'image/png');
-
- if (in_array($this->_imageType, $_supportedImageTypes)) {
- $this->_src = $src;
- $this->_style = new 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();
- }
- }
-
- /**
- * 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;
- }
-}
diff --git a/Classes/PHPWord/Shared/File.php b/Classes/PHPWord/Shared/File.php
deleted file mode 100755
index 4ed0e72530..0000000000
--- a/Classes/PHPWord/Shared/File.php
+++ /dev/null
@@ -1,128 +0,0 @@
- 0) {
- unset($pathArray[$i]);
- unset($pathArray[$i - 1]);
- break;
- }
- }
- }
- $returnValue = implode('/', $pathArray);
- }
-
- return $returnValue;
- }
-
- /**
- * PHP Words version of exif_imagetype to return the Image Type from a file
- *
- * @param string $filename
- * @return int|bool
- */
- private static function fallbackImagetype($filename)
- {
- if ((list($width, $height, $type, $attr) = getimagesize($filename)) !== false) {
- if ($type === 2) {
- return self::IMAGETYPE_JPEG;
- } elseif ($type === 1) {
- return self::IMAGETYPE_GIF;
- } elseif ($type === 3) {
- return self::IMAGETYPE_PNG;
- } elseif ($type === 6) {
- return self::IMAGETYPE_BMP;
- } elseif ($type === 7 || $type === 8) {
- return self::IMAGETYPE_TIFF;
- }
- }
- return false;
- }
-
- /**
- * Return the Image Type from a file
- *
- * @param string $filename
- * @param bool $userFallbackFunction
- * @return int|bool
- */
- public static function imagetype($filename, $userFallbackFunction = false)
- {
- if ($userFallbackFunction || !function_exists('exif_imagetype')) {
- return self::fallbackImagetype($filename);
- }
-
- $imagetype = exif_imagetype($filename);
- if ($imagetype === IMAGETYPE_JPEG) {
- return self::IMAGETYPE_JPEG;
- } elseif ($imagetype === IMAGETYPE_GIF) {
- return self::IMAGETYPE_GIF;
- } elseif ($imagetype === IMAGETYPE_PNG) {
- return self::IMAGETYPE_PNG;
- } elseif ($imagetype === IMAGETYPE_BMP) {
- return self::IMAGETYPE_BMP;
- } elseif ($imagetype === IMAGETYPE_TIFF_II || $imagetype === IMAGETYPE_TIFF_MM) {
- return self::IMAGETYPE_TIFF;
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/Classes/PHPWord/Style/Table.php b/Classes/PHPWord/Style/Table.php
deleted file mode 100755
index c3ef2e0140..0000000000
--- a/Classes/PHPWord/Style/Table.php
+++ /dev/null
@@ -1,96 +0,0 @@
-_cellMarginTop = null;
- $this->_cellMarginLeft = null;
- $this->_cellMarginRight = null;
- $this->_cellMarginBottom = null;
- }
-
- public function setStyleValue($key, $value)
- {
- $this->$key = $value;
- }
-
- public function setCellMarginTop($pValue = null)
- {
- $this->_cellMarginTop = $pValue;
- }
-
- public function getCellMarginTop()
- {
- return $this->_cellMarginTop;
- }
-
- public function setCellMarginLeft($pValue = null)
- {
- $this->_cellMarginLeft = $pValue;
- }
-
- public function getCellMarginLeft()
- {
- return $this->_cellMarginLeft;
- }
-
- public function setCellMarginRight($pValue = null)
- {
- $this->_cellMarginRight = $pValue;
- }
-
- public function getCellMarginRight()
- {
- return $this->_cellMarginRight;
- }
-
- public function setCellMarginBottom($pValue = null)
- {
- $this->_cellMarginBottom = $pValue;
- }
-
- public function getCellMarginBottom()
- {
- return $this->_cellMarginBottom;
- }
-
- public function getCellMargin()
- {
- return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
- }
-}
diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PHPWord/Writer/ODText/Content.php
deleted file mode 100755
index 0899990b16..0000000000
--- a/Classes/PHPWord/Writer/ODText/Content.php
+++ /dev/null
@@ -1,397 +0,0 @@
-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');
-
- // 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->setParagraphStyle('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(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) {
- $objWriter->startElement('style:font-face');
- $objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME);
- $objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME);
- $objWriter->endElement();
- }
- }
- $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_TextBreak) {
- $this->_writeTextBreak($objWriter);
- } elseif ($element instanceof PHPWord_Section_Link) {
- $this->writeUnsupportedElement($objWriter, 'Link');
- } elseif ($element instanceof PHPWord_Section_Title) {
- $this->writeUnsupportedElement($objWriter, 'Title');
- } elseif ($element instanceof PHPWord_Section_PageBreak) {
- $this->writeUnsupportedElement($objWriter, 'Page Break');
- } elseif ($element instanceof PHPWord_Section_Table) {
- $this->writeUnsupportedElement($objWriter, 'Table');
- } elseif ($element instanceof PHPWord_Section_ListItem) {
- $this->writeUnsupportedElement($objWriter, 'List Item');
- } elseif ($element instanceof PHPWord_Section_Image ||
- $element instanceof PHPWord_Section_MemoryImage) {
- $this->writeUnsupportedElement($objWriter, 'Image');
- } elseif ($element instanceof PHPWord_Section_Object) {
- $this->writeUnsupportedElement($objWriter, 'Object');
- } elseif ($element instanceof PHPWord_TOC) {
- $this->writeUnsupportedElement($objWriter, 'TOC');
- } else {
- $this->writeUnsupportedElement($objWriter, 'Element');
- }
- }
-
- if ($pSection == $countSections) {
- $this->_writeEndSection($objWriter, $section);
- } else {
- $this->_writeSection($objWriter, $section);
- }
- }
- }
- $objWriter->endElement();
- $objWriter->endElement();
- $objWriter->endElement();
-
- // Return
- return $objWriter->getData();
- }
-
- /**
- * Write text
- *
- * @param PHPWord_Shared_XMLWriter $objWriter
- * @param PHPWord_Section_Text $text
- * @param bool $withoutP
- */
- protected function _writeText(
- PHPWord_Shared_XMLWriter $objWriter = null,
- PHPWord_Section_Text $text,
- $withoutP = false
- ) {
- $styleFont = $text->getFontStyle();
- $styleParagraph = $text->getParagraphStyle();
-
- // @todo Commented for TextRun. Should really checkout this value
- // $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
- $SfIsObject = false;
-
- if ($SfIsObject) {
- // Don't never be the case, because I browse all sections for cleaning all styles not declared
- die('PHPWord : $SfIsObject wouldn\'t be an object');
- } else {
- if (!$withoutP) {
- $objWriter->startElement('text:p'); // 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();
- }
- if (!$withoutP) {
- $objWriter->endElement(); // text:p
- }
- }
- }
-
- /**
- * Write TextRun section
- *
- * @param PHPWord_Shared_XMLWriter $objWriter
- * @param PHPWord_Section_TextRun $textrun
- * @todo Enable all other section types
- */
- protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun)
- {
- $elements = $textrun->getElements();
- $objWriter->startElement('text:p');
- if (count($elements) > 0) {
- foreach ($elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
- $this->_writeText($objWriter, $element, true);
- }
- }
- }
- $objWriter->endElement();
- }
-
- /**
- * Write TextBreak
- */
- protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null)
- {
- $objWriter->startElement('text:p');
- $objWriter->writeAttribute('text:style-name', 'Standard');
- $objWriter->endElement();
- }
-
- // @codeCoverageIgnoreStart
- private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
- {
- }
-
- private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
- {
- }
- // @codeCoverageIgnoreEnd
-
- /**
- * Write unsupported element
- *
- * @param PHPWord_Shared_XMLWriter $objWriter
- * @param string $element
- */
- private function writeUnsupportedElement($objWriter, $element)
- {
- $objWriter->startElement('text:p');
- $objWriter->writeRaw("{$element}");
- $objWriter->endElement();
- }
-}
diff --git a/Classes/PHPWord/Writer/ODText/Meta.php b/Classes/PHPWord/Writer/ODText/Meta.php
deleted file mode 100755
index 5397861496..0000000000
--- a/Classes/PHPWord/Writer/ODText/Meta.php
+++ /dev/null
@@ -1,94 +0,0 @@
-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');
-
- // 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();
-
- // Return
- return $objWriter->getData();
- }
-}
diff --git a/Classes/PHPWord/Writer/ODText/Styles.php b/Classes/PHPWord/Writer/ODText/Styles.php
deleted file mode 100755
index b5f87332d6..0000000000
--- a/Classes/PHPWord/Writer/ODText/Styles.php
+++ /dev/null
@@ -1,267 +0,0 @@
-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');
-
- // 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(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) {
- $objWriter->startElement('style:font-face');
- $objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME);
- $objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME);
- $objWriter->endElement();
- }
- $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', PHPWord::DEFAULT_FONT_NAME);
- $objWriter->writeAttribute('fo:font-size', PHPWord::DEFAULT_FONT_SIZE . 'pt');
- $objWriter->writeAttribute('fo:language', 'fr');
- $objWriter->writeAttribute('fo:country', 'FR');
- $objWriter->writeAttribute('style:letter-kerning', 'true');
- $objWriter->writeAttribute('style:font-name-asian', PHPWord::DEFAULT_FONT_NAME . '2');
- $objWriter->writeAttribute('style:font-size-asian', PHPWord::DEFAULT_FONT_SIZE . 'pt');
- $objWriter->writeAttribute('style:language-asian', 'zh');
- $objWriter->writeAttribute('style:country-asian', 'CN');
- $objWriter->writeAttribute('style:font-name-complex', PHPWord::DEFAULT_FONT_NAME . '2');
- $objWriter->writeAttribute('style:font-size-complex', PHPWord::DEFAULT_FONT_SIZE . 'pt');
- $objWriter->writeAttribute('style:language-complex', 'hi');
- $objWriter->writeAttribute('style:country-complex', 'IN');
- $objWriter->writeAttribute('fo:hyphenate', 'false');
- $objWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
- $objWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
- $objWriter->endElement();
-
- $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()) . 'pt');
- $objWriter->writeAttribute('style:font-size-asian', ($style->getSize()) . 'pt');
- $objWriter->writeAttribute('style:font-size-complex', ($style->getSize()) . 'pt');
- if ($style->getItalic()) {
- $objWriter->writeAttribute('fo:font-style', 'italic');
- $objWriter->writeAttribute('style:font-style-asian', 'italic');
- $objWriter->writeAttribute('style:font-style-complex', 'italic');
- }
- if ($style->getBold()) {
- $objWriter->writeAttribute('fo:font-weight', 'bold');
- $objWriter->writeAttribute('style:font-weight-asian', 'bold');
- }
- $objWriter->endElement();
- $objWriter->endElement();
- } elseif ($style instanceof PHPWord_Style_Paragraph) {
- // 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();
- } elseif ($style instanceof PHPWord_Style_TableFull) {
- // 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/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php
deleted file mode 100755
index e9249120e5..0000000000
--- a/Classes/PHPWord/Writer/Word2007/Base.php
+++ /dev/null
@@ -1,1025 +0,0 @@
-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
- }
- }
-
- /**
- * Write text run
- */
- 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);
- } elseif ($element instanceof PHPWord_Section_Image) {
- $this->_writeImage($objWriter, $element, true);
- } elseif ($element instanceof PHPWord_Section_Footnote) {
- $this->_writeFootnoteReference($objWriter, $element, true);
- } elseif ($element instanceof PHPWord_Section_TextBreak) {
- $objWriter->writeElement('w:br');
- }
- }
- }
-
- $objWriter->endElement();
- }
-
- /**
- * Write paragraph style
- *
- * @param PHPWord_Shared_XMLWriter $objWriter
- * @param PHPWord_Style_Paragraph $style
- * @param bool $withoutPPR
- * @return void
- */
- protected function _writeParagraphStyle(
- PHPWord_Shared_XMLWriter $objWriter = null,
- PHPWord_Style_Paragraph $style,
- $withoutPPR = false
- ) {
-
- $align = $style->getAlign();
- $spacing = $style->getSpacing();
- $spaceBefore = $style->getSpaceBefore();
- $spaceAfter = $style->getSpaceAfter();
- $indent = $style->getIndent();
- $hanging = $style->getHanging();
- $tabs = $style->getTabs();
- $widowControl = $style->getWidowControl();
- $keepNext = $style->getKeepNext();
- $keepLines = $style->getKeepLines();
- $pageBreakBefore = $style->getPageBreakBefore();
-
- if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) ||
- !is_null($spaceAfter) || !is_null($indent) || !is_null($hanging) ||
- !is_null($tabs) || !is_null($widowControl) || !is_null($keepNext) ||
- !is_null($keepLines) || !is_null($pageBreakBefore)) {
- if (!$withoutPPR) {
- $objWriter->startElement('w:pPr');
- }
-
- // Alignment
- if (!is_null($align)) {
- $objWriter->startElement('w:jc');
- $objWriter->writeAttribute('w:val', $align);
- $objWriter->endElement();
- }
-
- // Indentation
- if (!is_null($indent) || !is_null($hanging)) {
- $objWriter->startElement('w:ind');
- $objWriter->writeAttribute('w:firstLine', 0);
- if (!is_null($indent)) {
- $objWriter->writeAttribute('w:left', $indent);
- }
- if (!is_null($hanging)) {
- $objWriter->writeAttribute('w:hanging', $hanging);
- }
- $objWriter->endElement();
- }
-
- // Spacing
- 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();
- }
-
- // Pagination
- if (!$widowControl) {
- $objWriter->startElement('w:widowControl');
- $objWriter->writeAttribute('w:val', '0');
- $objWriter->endElement();
- }
- if ($keepNext) {
- $objWriter->startElement('w:keepNext');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
- }
- if ($keepLines) {
- $objWriter->startElement('w:keepLines');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
- }
- if ($pageBreakBefore) {
- $objWriter->startElement('w:pageBreakBefore');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
- }
-
- // Tabs
- if (!is_null($tabs)) {
- $tabs->toXml($objWriter);
- }
-
- if (!$withoutPPR) {
- $objWriter->endElement(); // w:pPr
- }
- }
- }
-
- /**
- * Write link
- */
- protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false)
- {
- $rID = $link->getRelationId();
- $linkName = $link->getLinkName();
- if (is_null($linkName)) {
- $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
- }
- }
-
- /**
- * Write preserve text
- */
- 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();
- if (!is_array($arrText)) {
- $arrText = array($arrText);
- }
-
- $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
- }
-
- /**
- * Write text style
- */
- 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();
- $strikethrough = $style->getStrikethrough();
- $underline = $style->getUnderline();
- $superscript = $style->getSuperScript();
- $subscript = $style->getSubScript();
- $hint = $style->getHint();
-
- $objWriter->startElement('w:rPr');
-
- // Font
- if ($font != PHPWord::DEFAULT_FONT_NAME) {
- $objWriter->startElement('w:rFonts');
- $objWriter->writeAttribute('w:ascii', $font);
- $objWriter->writeAttribute('w:hAnsi', $font);
- $objWriter->writeAttribute('w:eastAsia', $font);
- $objWriter->writeAttribute('w:cs', $font);
- //Font Content Type
- if ($hint != PHPWord::DEFAULT_FONT_CONTENT_TYPE) {
- $objWriter->writeAttribute('w:hint', $hint);
- }
- $objWriter->endElement();
- }
-
-
- // Color
- if ($color != PHPWord::DEFAULT_FONT_COLOR) {
- $objWriter->startElement('w:color');
- $objWriter->writeAttribute('w:val', $color);
- $objWriter->endElement();
- }
-
- // Size
- if ($size != PHPWord::DEFAULT_FONT_SIZE) {
- $objWriter->startElement('w:sz');
- $objWriter->writeAttribute('w:val', $size * 2);
- $objWriter->endElement();
- $objWriter->startElement('w:szCs');
- $objWriter->writeAttribute('w:val', $size * 2);
- $objWriter->endElement();
- }
-
- // 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();
- }
-
- // Strikethrough
- if ($strikethrough) {
- $objWriter->writeElement('w:strike', null);
- }
-
- // Foreground-Color
- if (!is_null($fgColor)) {
- $objWriter->startElement('w:highlight');
- $objWriter->writeAttribute('w:val', $fgColor);
- $objWriter->endElement();
- }
-
- // Superscript/subscript
- if ($superscript || $subscript) {
- $objWriter->startElement('w:vertAlign');
- $objWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript');
- $objWriter->endElement();
- }
-
- $objWriter->endElement();
- }
-
- /**
- * Write text break
- *
- * @param PHPWord_Shared_XMLWriter $objWriter
- * @param PHPWord_Section_TextBreak $element
- */
- protected function _writeTextBreak($objWriter, $element = null)
- {
- $hasStyle = false;
- if (!is_null($element)) {
- $fontStyle = $element->getFontStyle();
- $sfIsObject = ($fontStyle instanceof PHPWord_Style_Font) ? true : false;
- $paragraphStyle = $element->getParagraphStyle();
- $spIsObject = ($paragraphStyle instanceof PHPWord_Style_Paragraph) ? true : false;
- $hasStyle = !is_null($fontStyle) || !is_null($paragraphStyle);
- }
- if ($hasStyle) {
- // Paragraph style
- $objWriter->startElement('w:p');
- if ($spIsObject) {
- $this->_writeParagraphStyle($objWriter, $paragraphStyle);
- } elseif (!$spIsObject && !is_null($paragraphStyle)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $paragraphStyle);
- $objWriter->endElement(); // w:pStyle
- $objWriter->endElement(); // w:pPr
- }
- // Font style
- if (!is_null($fontStyle)) {
- $objWriter->startElement('w:pPr');
- if ($sfIsObject) {
- $this->_writeTextStyle($objWriter, $fontStyle);
- } elseif (!$sfIsObject && !is_null($fontStyle)) {
- $objWriter->startElement('w:rPr');
- $objWriter->startElement('w:rStyle');
- $objWriter->writeAttribute('w:val', $fontStyle);
- $objWriter->endElement(); // w:rStyle
- $objWriter->endElement(); // w:rPr
- }
- $objWriter->endElement(); // w:pPr
- }
- $objWriter->endElement(); // w:p
- } else {
- // Null element. No paragraph nor font style
- $objWriter->writeElement('w:p', null);
- }
- }
-
- /**
- * Write table
- */
- 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();
- $tblWidth = $table->getWidth();
- 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();
- if (!is_null($tblWidth)) {
- $objWriter->startElement('w:tblW');
- $objWriter->writeAttribute('w:w', $tblWidth);
- $objWriter->writeAttribute('w:type', 'pct');
- $objWriter->endElement();
- }
- $objWriter->endElement();
- }
- }
-
- for ($i = 0; $i < $_cRows; $i++) {
- $row = $_rows[$i];
- $height = $row->getHeight();
- $rowStyle = $row->getStyle();
- $tblHeader = $rowStyle->getTblHeader();
- $cantSplit = $rowStyle->getCantSplit();
-
- $objWriter->startElement('w:tr');
-
- if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) {
- $objWriter->startElement('w:trPr');
- if (!is_null($height)) {
- $objWriter->startElement('w:trHeight');
- $objWriter->writeAttribute('w:val', $height);
- $objWriter->endElement();
- }
- if ($tblHeader) {
- $objWriter->startElement('w:tblHeader');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
- }
- if ($cantSplit) {
- $objWriter->startElement('w:cantSplit');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
- }
- $objWriter->endElement();
- }
-
- foreach ($row->getCells() 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, $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_Section_Footer_PreserveText) {
- $this->_writePreserveText($objWriter, $element);
- }
- }
- } else {
- $this->_writeTextBreak($objWriter);
- }
-
- $objWriter->endElement();
- }
- $objWriter->endElement();
- }
- $objWriter->endElement();
- }
- }
-
- /**
- * Write table style
- */
- protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null)
- {
- $margins = $style->getCellMargin();
- $mTop = (!is_null($margins[0])) ? true : false;
- $mLeft = (!is_null($margins[1])) ? true : false;
- $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();
- }
- }
-
- /**
- * Write cell style
- */
- protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Cell $style = null)
- {
- $bgColor = $style->getBgColor();
- $valign = $style->getVAlign();
- $textDir = $style->getTextDirection();
- $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();
- }
- }
-
- /**
- * @param \PHPWord_Shared_XMLWriter $objWriter
- * @param \PHPWord_Section_Image|\PHPWord_Section_MemoryImage $image
- */
- protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image, $withoutP = false)
- {
- $rId = $image->getRelationId();
-
- $style = $image->getStyle();
- $width = $style->getWidth();
- $height = $style->getHeight();
- $align = $style->getAlign();
- $marginTop = $style->getMarginTop();
- $marginLeft = $style->getMarginLeft();
- $wrappingStyle = $style->getWrappingStyle();
-
- if (!$withoutP) {
- $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();
-
- if (!$withoutP) {
- $objWriter->endElement(); // w:p
- }
- }
-
- /**
- * Write watermark
- */
- 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();
- }
-
- /**
- * Write title
- */
- protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title)
- {
- $text = htmlspecialchars($title->getText());
- $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text);
- $anchor = $title->getAnchor();
- $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();
- }
-
- /**
- * Write footnote
- */
- protected function _writeFootnote(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote)
- {
- $objWriter->startElement('w:footnote');
- $objWriter->writeAttribute('w:id', $footnote->getReferenceId());
-
- $styleParagraph = $footnote->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();
- }
-
- $elements = $footnote->getElements();
- if (count($elements) > 0) {
- foreach ($elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
- $this->_writeText($objWriter, $element, true);
- } elseif ($element instanceof PHPWord_Section_Link) {
- $this->_writeLink($objWriter, $element, true);
- }
- }
- }
-
- $objWriter->endElement(); // w:p
- $objWriter->endElement(); // w:footnote
- }
-
- /**
- * Write footnote reference
- */
- protected function _writeFootnoteReference(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote, $withoutP = false)
- {
- if (!$withoutP) {
- $objWriter->startElement('w:p');
- }
-
- $objWriter->startElement('w:r');
-
- $objWriter->startElement('w:footnoteReference');
- $objWriter->writeAttribute('w:id', $footnote->getReferenceId());
- $objWriter->endElement(); // w:footnoteReference
-
- $objWriter->endElement(); // w:r
-
- if (!$withoutP) {
- $objWriter->endElement(); // w:p
- }
- }
-}
diff --git a/Classes/PHPWord/Writer/Word2007/DocProps.php b/Classes/PHPWord/Writer/Word2007/DocProps.php
deleted file mode 100755
index 2e8f8b5a63..0000000000
--- a/Classes/PHPWord/Writer/Word2007/DocProps.php
+++ /dev/null
@@ -1,185 +0,0 @@
-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');
-
- // 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');
-
- // ScaleCrop
- $objWriter->writeElement('ScaleCrop', 'false');
-
- // HeadingPairs
- $objWriter->startElement('HeadingPairs');
-
- // 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: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();
-
- $objWriter->endElement();
-
- $objWriter->endElement();
-
- // TitlesOfParts
- $objWriter->startElement('TitlesOfParts');
-
- // Vector
- $objWriter->startElement('vt:vector');
- $objWriter->writeAttribute('size', '1');
- $objWriter->writeAttribute('baseType', 'lpstr');
-
- $objWriter->writeElement('vt:lpstr', 'Office Theme');
-
- $objWriter->endElement();
-
- $objWriter->endElement();
-
- // Company
- $objWriter->writeElement('Company', $pPHPWord->getProperties()->getCompany());
-
- // LinksUpToDate
- $objWriter->writeElement('LinksUpToDate', 'false');
-
- // SharedDoc
- $objWriter->writeElement('SharedDoc', 'false');
-
- // HyperlinksChanged
- $objWriter->writeElement('HyperlinksChanged', 'false');
-
- // AppVersion
- $objWriter->writeElement('AppVersion', '12.0000');
-
- $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');
-
- // 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');
-
- // dc:creator
- $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getCreator());
-
- // cp:lastModifiedBy
- $objWriter->writeElement('cp:lastModifiedBy', $pPHPWord->getProperties()->getLastModifiedBy());
-
- // dcterms:created
- $objWriter->startElement('dcterms:created');
- $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
- $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getCreated()));
- $objWriter->endElement();
-
- // dcterms:modified
- $objWriter->startElement('dcterms:modified');
- $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
- $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getModified()));
- $objWriter->endElement();
-
- // dc:title
- $objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
-
- // dc:description
- $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
-
- // dc:subject
- $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
-
- // cp:keywords
- $objWriter->writeElement('cp:keywords', $pPHPWord->getProperties()->getKeywords());
-
- // cp:category
- $objWriter->writeElement('cp:category', $pPHPWord->getProperties()->getCategory());
-
- $objWriter->endElement();
-
- // Return
- return $objWriter->getData();
- }
-}
diff --git a/Classes/PHPWord/Writer/Word2007/Document.php b/Classes/PHPWord/Writer/Word2007/Document.php
deleted file mode 100755
index abdd92cc75..0000000000
--- a/Classes/PHPWord/Writer/Word2007/Document.php
+++ /dev/null
@@ -1,491 +0,0 @@
-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, $element);
- } elseif ($element instanceof PHPWord_Section_PageBreak) {
- $this->_writePageBreak($objWriter);
- } elseif ($element instanceof PHPWord_Section_Table) {
- $this->_writeTable($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_ListItem) {
- $this->_writeListItem($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Image ||
- $element instanceof PHPWord_Section_MemoryImage
- ) {
- $this->_writeImage($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Object) {
- $this->_writeObject($objWriter, $element);
- } elseif ($element instanceof PHPWord_TOC) {
- $this->_writeTOC($objWriter);
- } elseif ($element instanceof PHPWord_Section_Footnote) {
- $this->_writeFootnoteReference($objWriter, $element);
- }
- }
-
- 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();
-
- $headerHeight = $settings->getHeaderHeight();
- $footerHeight = $settings->getFooterHeight();
-
- $borders = $settings->getBorderSize();
-
- $colsNum = $settings->getColsNum();
- $colsSpace = $settings->getColsSpace();
- $breakType = $settings->getBreakType();
-
- $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($breakType)) {
- $objWriter->startElement('w:type');
- $objWriter->writeAttribute('w:val', $breakType);
- $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', $headerHeight);
- $objWriter->writeAttribute('w:footer', $footerHeight);
- $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();
- }
-
- // Page numbering
- if (null !== $settings->getPageNumberingStart()) {
- $objWriter->startElement('w:pgNumType');
- $objWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart());
- $objWriter->endElement();
- }
-
- $objWriter->startElement('w:cols');
- $objWriter->writeAttribute('w:num', $colsNum);
- $objWriter->writeAttribute('w:space', $colsSpace);
- $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();
- }
-
- public 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; $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/Footer.php b/Classes/PHPWord/Writer/Word2007/Footer.php
deleted file mode 100755
index 6ee18d66c7..0000000000
--- a/Classes/PHPWord/Writer/Word2007/Footer.php
+++ /dev/null
@@ -1,83 +0,0 @@
-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, $element);
- } 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/Classes/PHPWord/Writer/Word2007/Footnotes.php b/Classes/PHPWord/Writer/Word2007/Footnotes.php
deleted file mode 100644
index 28d087c7d2..0000000000
--- a/Classes/PHPWord/Writer/Word2007/Footnotes.php
+++ /dev/null
@@ -1,83 +0,0 @@
-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:footnotes');
- $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
- $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
-
- // write separator and continuation separator
- $objWriter->startElement('w:footnote');
- $objWriter->writeAttribute('w:id', 0);
- $objWriter->writeAttribute('w:type', 'separator');
- $objWriter->startElement('w:p');
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:separator');
- $objWriter->endElement(); // w:separator
- $objWriter->endElement(); // w:r
- $objWriter->endElement(); // w:p
- $objWriter->endElement(); // w:footnote
-
- $objWriter->startElement('w:footnote');
- $objWriter->writeAttribute('w:id', 1);
- $objWriter->writeAttribute('w:type', 'continuationSeparator');
- $objWriter->startElement('w:p');
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:continuationSeparator');
- $objWriter->endElement(); // w:continuationSeparator
- $objWriter->endElement(); // w:r
- $objWriter->endElement(); // w:p
- $objWriter->endElement(); // w:footnote
-
-
- foreach ($allFootnotesCollection as $footnote) {
- if ($footnote instanceof PHPWord_Section_Footnote) {
- $this->_writeFootnote($objWriter, $footnote);
- }
- }
-
- $objWriter->endElement();
-
- // Return
- return $objWriter->getData();
- }
-}
diff --git a/Classes/PHPWord/Writer/Word2007/Header.php b/Classes/PHPWord/Writer/Word2007/Header.php
deleted file mode 100755
index 59eebd9178..0000000000
--- a/Classes/PHPWord/Writer/Word2007/Header.php
+++ /dev/null
@@ -1,87 +0,0 @@
-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, $element);
- } 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/Classes/PHPWord/Writer/Word2007/Styles.php b/Classes/PHPWord/Writer/Word2007/Styles.php
deleted file mode 100755
index 3724323e10..0000000000
--- a/Classes/PHPWord/Writer/Word2007/Styles.php
+++ /dev/null
@@ -1,394 +0,0 @@
-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();
-
- // Write normal paragraph style
- $normalStyle = null;
- if (array_key_exists('Normal', $styles)) {
- $normalStyle = $styles['Normal'];
- }
- $objWriter->startElement('w:style');
- $objWriter->writeAttribute('w:type', 'paragraph');
- $objWriter->writeAttribute('w:default', '1');
- $objWriter->writeAttribute('w:styleId', 'Normal');
- $objWriter->startElement('w:name');
- $objWriter->writeAttribute('w:val', 'Normal');
- $objWriter->endElement();
- if (!is_null($normalStyle)) {
- $this->_writeParagraphStyle($objWriter, $normalStyle);
- }
- $objWriter->endElement();
-
- // Write other styles
- if (count($styles) > 0) {
- foreach ($styles as $styleName => $style) {
- if ($styleName == 'Normal') {
- continue;
- }
- 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)) {
- // Point parent style to Normal
- $objWriter->startElement('w:basedOn');
- $objWriter->writeAttribute('w:val', 'Normal');
- $objWriter->endElement();
- $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();
-
- // Parent style
- $basedOn = $style->getBasedOn();
- if (!is_null($basedOn)) {
- $objWriter->startElement('w:basedOn');
- $objWriter->writeAttribute('w:val', $basedOn);
- $objWriter->endElement();
- }
-
- // Next paragraph style
- $next = $style->getNext();
- if (!is_null($next)) {
- $objWriter->startElement('w:next');
- $objWriter->writeAttribute('w:val', $next);
- $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 * 2);
- $objWriter->endElement();
-
- $objWriter->startElement('w:szCs');
- $objWriter->writeAttribute('w:val', $fontSize * 2);
- $objWriter->endElement();
-
- $objWriter->endElement();
- $objWriter->endElement();
- $objWriter->endElement();
- }
-}
diff --git a/README.md b/README.md
index 5eb8d74c01..5e319d33bc 100755
--- a/README.md
+++ b/README.md
@@ -1,19 +1,15 @@
-# PHPWord
+# ![PHPWord](https://raw.githubusercontent.com/PHPOffice/PHPWord/develop/docs/images/phpword.svg "PHPWord")
-[![Build Status](https://travis-ci.org/PHPOffice/PHPWord.png?branch=master)](https://travis-ci.org/PHPOffice/PHPWord)
-[![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword) [![Total Downloads](https://poser.pugx.org/phpoffice/phpword/downloads.png)](https://packagist.org/packages/phpoffice/phpword) [![Latest Unstable Version](https://poser.pugx.org/phpoffice/phpword/v/unstable.png)](https://packagist.org/packages/phpoffice/phpword) [![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword)
+[![Build Status](https://travis-ci.org/PHPOffice/PHPWord.svg?branch=master)](https://travis-ci.org/PHPOffice/PHPWord)
+[![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword)
+[![Total Downloads](https://poser.pugx.org/phpoffice/phpword/downloads.png)](https://packagist.org/packages/phpoffice/phpword)
+[![Latest Unstable Version](https://poser.pugx.org/phpoffice/phpword/v/unstable.png)](https://packagist.org/packages/phpoffice/phpword)
+[![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword)
-__OpenXML - Read, Write and Create Word documents in PHP.__
-PHPWord is a library written in pure PHP and providing a set of classes that allow you to write to and read from different document file formats, like Word (.docx), WordPad (.rtf), Libre/OpenOffice Writer (.odt).
+PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), and [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF).
-No Windows operating system is needed for usage because the resulting DOCX, ODT, or RTF files can be opened by all major [word processing softwares](http://en.wikipedia.org/wiki/List_of_word_processors).
-
-PHPWord is an open source project licensed under [LGPL](license.md). PHPWord is unit tested to make sure that the released versions are stable.
-
-__Want to contribute?__ Fork us!
-
-## Features
+With PHPWord, you can create DOCX, ODT, or RTF documents dynamically using your PHP 5.3+ scripts. Below are some of the things that you can do with PHPWord library:
* Set document properties, e.g. title, subject, and creator.
* Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering
@@ -38,10 +34,10 @@ __Want to contribute?__ Fork us!
* PHP [Zip](http://php.net/manual/en/book.zip.php) extension
* PHP [XML Parser](http://www.php.net/manual/en/xml.installation.php) extension
-## Optional PHP extensions
-* [GD](http://php.net/manual/en/book.image.php)
-* [XMLWriter](http://php.net/manual/en/book.xmlwriter.php)
-* [XSL](http://php.net/manual/en/book.xsl.php)
+### Optional PHP extensions
+* PHP [GD](http://php.net/manual/en/book.image.php) extension
+* PHP [XMLWriter](http://php.net/manual/en/book.xmlwriter.php) extension
+* PHP [XSL](http://php.net/manual/en/book.xsl.php) extension
## Installation
@@ -56,37 +52,19 @@ the following lines to your ``composer.json``.
}
```
-## Documentation
-
-We're reorganizing our documentation. Below are some of the most important things that you needed to get PHPWord creates document for you in no time.
-
-### Table of contents
-
-1. [Basic usage](#basic-usage)
- * [Measurement units](#measurement-units)
-2. [Sections](#sections)
- * [Section settings](#section-settings)
- * [Section page numbering](#section-page-numbering)
-3. [Texts](#texts)
- * [Attributes](#text-attributes)
-4. [Paragraph Style](#paragraph-style)
- * [Attributes](#paragraph-style-attributes)
-5. [Tables](#tables)
- * [Cell Style](#tables-cell-style)
-6. [Images](#images)
- * [Attributes](#images-attributes)
-
-
-#### Basic usage
+## Basic usage
The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/).
```php
-$PHPWord = new PHPWord();
+require_once 'src/PhpWord/Autoloader.php';
+PhpOffice\PhpWord\Autoloader::register();
+
+$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Every element you want to append to the word document is placed in a section.
// To create a basic section:
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// After creating a section, you can append elements:
$section->addText('Hello world!');
@@ -97,13 +75,13 @@ $section->addText('Hello world! I am formatted.',
// If you often need the same style again you can create a user defined style
// to the word document and give the addText function the name of the style:
-$PHPWord->addFontStyle('myOwnStyle',
+$phpWord->addFontStyle('myOwnStyle',
array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
$section->addText('Hello world! I am formatted by a user defined style',
'myOwnStyle');
// You can also put the appended element to local object like this:
-$fontStyle = new PHPWord_Style_Font();
+$fontStyle = new \PhpOffice\PhpWord\Style\Font();
$fontStyle->setBold(true);
$fontStyle->setName('Verdana');
$fontStyle->setSize(22);
@@ -111,191 +89,16 @@ $myTextElement = $section->addText('Hello World!');
$myTextElement->setFontStyle($fontStyle);
// Finally, write the document:
-$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
+$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('helloWorld.docx');
-```
-
-##### Measurement units
+$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
+$objWriter->save('helloWorld.odt');
-The base length unit in Open Office XML is twip. Twip means "TWentieth of an Inch Point", i.e. 1 twip = 1/1440 inch.
-
-You can use PHPWord helper functions to convert inches, centimeters, or points to twips.
-
-```php
-// Paragraph with 6 points space after
-$PHPWord->addParagraphStyle('My Style', array(
- 'spaceAfter' => PHPWord_Shared_Font::pointSizeToTwips(6))
-);
-
-$section = $PHPWord->createSection();
-$sectionStyle = $section->getSettings();
-// half inch left margin
-$sectionStyle->setMarginLeft(PHPWord_Shared_Font::inchSizeToTwips(.5));
-// 2 cm right margin
-$sectionStyle->setMarginRight(PHPWord_Shared_Font::centimeterSizeToTwips(2));
+$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF');
+$objWriter->save('helloWorld.rtf');
```
-
-#### Sections
-
-Every visible element in word is placed inside of a section. To create a section, use the following code:
-
-```php
-$section = $PHPWord->createSection($sectionSettings);
-```
-The `$sectionSettings` is an optional associative array that sets the section. Example:
+__Want to contribute?__ [Fork us](https://github.com/PHPOffice/PHPWord/fork) or [submit](https://github.com/PHPOffice/PHPWord/issues) your bug reports or feature requests to us.
-```php
-$sectionSettings = array(
- 'orientation' => 'landscape',
- 'marginTop' => 600,
- 'colsNum' => 2,
-);
-```
-
-##### Section settings
-
-Below are the available settings for section:
-
-* `orientation` Page orientation, i.e. 'portrait' (default) or 'landscape'
-* `marginTop` Page margin top in twips
-* `marginLeft` Page margin left in twips
-* `marginRight` Page margin right in twips
-* `marginBottom` Page margin bottom in twips
-* `borderTopSize` Border top size in twips
-* `borderTopColor` Border top color
-* `borderLeftSize` Border left size in twips
-* `borderLeftColor` Border left color
-* `borderRightSize` Border right size in twips
-* `borderRightColor` Border right color
-* `borderBottomSize` Border bottom size in twips
-* `borderBottomColor` Border bottom color
-* `headerHeight` Spacing to top of header
-* `footerHeight` Spacing to bottom of footer
-* `colsNum` Number of columns
-* `colsSpace` Spacing between columns
-* `breakType` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage)
-
-The following two settings are automatically set by the use of the `orientation` setting. You can alter them but that's not recommended.
-
-* `pageSizeW` Page width in twips
-* `pageSizeH` Page height in twips
-
-
-##### Section page numbering
-
-You can change a section page numbering.
-
-```php
-$section = $PHPWord->createSection();
-$section->getSettings()->setPageNumberingStart(1);
-```
-
-
-#### Texts
-
-Text can be added by using `addText` and `createTextRun` method. `addText` is used for creating simple paragraphs that only contain texts with the same style. `createTextRun` is used for creating complex paragraphs that contain text with different style (some bold, other italics, etc) or other elements, e.g. images or links.
-
-`addText` sample:
-
-```php
-$fontStyle = array('name' => 'Times New Roman', 'size' => 9);
-$paragraphStyle = array('align' => 'both');
-$section->addText('I am simple paragraph', $fontStyle, $paragraphStyle);
-```
-
-`createTextRun` sample:
-
-```php
-$textrun = $section->createTextRun();
-$textrun->addText('I am bold', array('bold' => true));
-$textrun->addText('I am italic', array('italic' => true));
-$textrun->addText('I am colored', array('color' => 'AACC00'));
-```
-
-
-##### Attributes
-
-* ``size`` text size, e.g. _20_, _22_,
-* ``name`` font name, e.g. _Arial_
-* ``bold`` text is bold, _true_ or _false_
-* ``italic`` text is italic, _true_ or _false_
-* ``superScript`` text is super script, _true_ or _false_
-* ``subScript`` text is sub script, _true_ or _false_
-* ``underline`` text is underline, _true_ or _false_
-* ``strikethrough`` text is strikethrough, _true_ or _false_
-* ``color`` text color, e.g. _FF0000_
-* ``fgColor`` fgColor
-* ``line-height`` text line height, e.g. _1.0_, _1.5_, ect...
-
-
-#### Paragraph Style
-
-
-##### Attributes
-
-* ``line-height`` text line height, e.g. _1.0_, _1.5_, ect...
-* ``align`` paragraph alignment, _left_, _right_ or _center_
-* ``spaceBefore`` space before Paragraph
-* ``spaceAfter`` space after Paragraph
-* ``tabs`` set of Custom Tab Stops
-* ``indent`` indent by how much
-
-
-#### Tables
-
-The following illustrates how to create a table.
-
-```php
-$table = $section->addTable();
-$table->addRow();
-$table->addCell();
-```
-
-
-##### Cell Style
-
-###### Cell Span
-
-You can span a cell on multiple columms.
-
-```php
-$cell = $table->addCell(200);
-$cell->getStyle()->setGridSpan(5);
-```
-
-
-#### Images
-
-You can add images easily using the following example.
-
-```php
-$section = $PHPWord->createSection();
-$section->addImage('mars.jpg');
-```
-
-
-##### Attributes
-
-* ``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 attributes, consider the following example.
-
-```php
-$section->addImage(
- 'mars.jpg',
- array(
- 'width' => 100,
- 'height' => 100,
- 'marginTop' => -1,
- 'marginLeft' => -1,
- 'wrappingStyle' => 'behind'
- )
-);
-```
+__Want to know more?__ Read the full documentation of PHPWord on [Read The Docs](http://phpword.readthedocs.org/en/develop/).
diff --git a/Tests/PHPWord/AutoloaderTest.php b/Tests/PHPWord/AutoloaderTest.php
deleted file mode 100644
index 03e16db073..0000000000
--- a/Tests/PHPWord/AutoloaderTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
-assertContains(array('PHPWord_Autoloader', 'load'), spl_autoload_functions());
- $this->assertContains(array('PHPWord_Autoloader', 'autoload'), spl_autoload_functions());
- }
-
- public function testAutoloadLegacy()
- {
- $this->assertNull(
- PHPWord_Autoloader::load('Foo'),
- 'PHPWord_Autoloader::load() is trying to load classes outside of the PHPWord namespace'
- );
- $this->assertTrue(
- PHPWord_Autoloader::load('PHPWord'),
- 'PHPWord_Autoloader::load() failed to autoload the PHPWord class'
- );
- }
-
- public function testAutoload()
- {
- $declared = get_declared_classes();
- $declaredCount = count($declared);
- Autoloader::autoload('Foo');
- $this->assertEquals(
- $declaredCount,
- count(get_declared_classes()),
- 'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load classes ' .
- 'outside of the PhpOffice\\PhpWord namespace'
- );
- // TODO change this class to the main PHPWord class when it is namespaced
- Autoloader::autoload(
- 'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException'
- );
- $this->assertTrue(
- in_array('PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException', get_declared_classes()),
- 'PhpOffice\\PhpWord\\Autoloader::autoload() failed to autoload the ' .
- 'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException class'
- );
- }
-}
diff --git a/Tests/PHPWord/IOFactoryTest.php b/Tests/PHPWord/IOFactoryTest.php
deleted file mode 100644
index 7b15fbb876..0000000000
--- a/Tests/PHPWord/IOFactoryTest.php
+++ /dev/null
@@ -1,72 +0,0 @@
-assertAttributeEquals(
- PHPWord_IOFactory::getSearchLocations(),
- '_searchLocations',
- 'PHPWord_IOFactory'
- );
- }
-
- public function testSetSearchLocationsWithArray()
- {
- PHPWord_IOFactory::setSearchLocations(array());
- $this->assertAttributeEquals(array(), '_searchLocations', 'PHPWord_IOFactory');
- }
-
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Invalid parameter passed.
- */
- public function testSetSearchLocationsWithNotArray()
- {
- PHPWord_IOFactory::setSearchLocations('String');
- }
-
- public function testAddSearchLocation()
- {
- PHPWord_IOFactory::setSearchLocations(array());
- PHPWord_IOFactory::addSearchLocation('type', 'location', 'classname');
- $this->assertAttributeEquals(
- array(array('type' => 'type', 'path' => 'location', 'class' => 'classname')),
- '_searchLocations',
- 'PHPWord_IOFactory'
- );
- }
-
- /**
- * @expectedException Exception
- * @expectedExceptionMessage No IWriter found for type
- */
- public function testCreateWriterException()
- {
- $oPHPWord = new PHPWord();
-
- PHPWord_IOFactory::setSearchLocations(array());
- PHPWord_IOFactory::createWriter($oPHPWord);
- }
-
- public function testCreateWriter()
- {
- $oPHPWord = new PHPWord();
-
- $this->assertEquals(
- PHPWord_IOFactory::createWriter($oPHPWord, 'Word2007'),
- new PHPWord_Writer_Word2007($oPHPWord)
- );
- }
-}
diff --git a/Tests/PHPWord/MediaTest.php b/Tests/PHPWord/MediaTest.php
deleted file mode 100644
index b2ebd6ae89..0000000000
--- a/Tests/PHPWord/MediaTest.php
+++ /dev/null
@@ -1,50 +0,0 @@
-assertEquals(PHPWord_Media::getSectionMediaElements(), array());
- }
-
- public function testCountSectionMediaElementsWithNull()
- {
- $this->assertEquals(PHPWord_Media::countSectionMediaElements(), 0);
- }
-
- public function testGetHeaderMediaElements()
- {
- $this->assertAttributeEquals(PHPWord_Media::getHeaderMediaElements(), '_headerMedia', 'PHPWord_Media');
- }
-
- public function testGetFooterMediaElements()
- {
- $this->assertAttributeEquals(PHPWord_Media::getFooterMediaElements(), '_footerMedia', 'PHPWord_Media');
- }
-
- /**
- * Todo: add memory image to this test
- *
- * @covers PHPWord_Media::addSectionMediaElement
- */
- public function testAddSectionMediaElement()
- {
- $section = new PHPWord_Section(0);
- $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg");
- $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg");
- $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif");
- $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png");
- $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp");
- $section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif");
-
- $elements = $section->getElements();
- $this->assertEquals(6, count($elements));
- foreach ($elements as $element) {
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
- }
- }
-}
diff --git a/Tests/PHPWord/Reader/Word2007Test.php b/Tests/PHPWord/Reader/Word2007Test.php
deleted file mode 100644
index 6fb6684609..0000000000
--- a/Tests/PHPWord/Reader/Word2007Test.php
+++ /dev/null
@@ -1,68 +0,0 @@
-assertTrue($object->canRead($file));
- }
-
- /**
- * Test canRead() failure
- *
- * @expectedException Exception
- */
- public function testCanReadFailed()
- {
- $dir = join(
- DIRECTORY_SEPARATOR,
- array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents')
- );
- $object = new PHPWord_Reader_Word2007;
- $file = $dir . DIRECTORY_SEPARATOR . 'foo.docx';
- $this->assertFalse($object->canRead($file));
- $object = PHPWord_IOFactory::load($file);
- }
-
- /**
- * Test load document
- */
- public function testLoad()
- {
- $dir = join(
- DIRECTORY_SEPARATOR,
- array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents')
- );
- $file = $dir . DIRECTORY_SEPARATOR . 'reader.docx';
- $object = PHPWord_IOFactory::load($file);
- $this->assertInstanceOf('PHPWord', $object);
- }
-}
diff --git a/Tests/PHPWord/Section/ImageTest.php b/Tests/PHPWord/Section/ImageTest.php
deleted file mode 100644
index 50cc4d2acc..0000000000
--- a/Tests/PHPWord/Section/ImageTest.php
+++ /dev/null
@@ -1,102 +0,0 @@
-assertInstanceOf('PHPWord_Section_Image', $oImage);
- $this->assertEquals($oImage->getSource(), $src);
- $this->assertEquals($oImage->getMediaId(), md5($src));
- $this->assertEquals($oImage->getIsWatermark(), false);
- $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle());
- }
-
- public function testConstructWithStyle()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'firefox.png')
- );
- $oImage = new PHPWord_Section_Image(
- $src,
- array('width' => 210, 'height' => 210, 'align' => 'center',
- 'wrappingStyle' => \PHPWord_Style_Image::WRAPPING_STYLE_BEHIND)
- );
-
- $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle());
- }
-
- /**
- * @covers PHPWord_Section_Image::__construct
- */
- public function testValidImageTypes()
- {
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif");
- }
-
- /**
- * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidImageException
- * @covers PHPWord_Section_Image::__construct
- */
- public function testImageNotFound()
- {
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/thisisnotarealimage");
- }
-
- /**
- * @expectedException \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException
- * @covers PHPWord_Section_Image::__construct
- */
- public function testInvalidImageTypes()
- {
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/alexz-johnson.pcx");
- }
-
- public function testStyle()
- {
- $oImage = new PHPWord_Section_Image(\join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
- ), array('width' => 210, 'height' => 210, 'align' => 'center'));
-
- $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle());
- }
-
- public function testRelationID()
- {
- $oImage = new PHPWord_Section_Image(\join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
- ));
-
- $iVal = rand(1, 1000);
- $oImage->setRelationId($iVal);
- $this->assertEquals($oImage->getRelationId(), $iVal);
- }
-
- public function testWatermark()
- {
- $oImage = new PHPWord_Section_Image(\join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
- ));
-
- $oImage->setIsWatermark(true);
- $this->assertEquals($oImage->getIsWatermark(), true);
- }
-}
diff --git a/Tests/PHPWord/Section/ListItemTest.php b/Tests/PHPWord/Section/ListItemTest.php
deleted file mode 100644
index a2a4d43832..0000000000
--- a/Tests/PHPWord/Section/ListItemTest.php
+++ /dev/null
@@ -1,36 +0,0 @@
-assertInstanceOf('PHPWord_Section_Text', $oListItem->getTextObject());
- }
-
- public function testStyle()
- {
- $oListItem = new PHPWord_Section_ListItem(
- 'text',
- 1,
- null,
- array('listType' => PHPWord_Style_ListItem::TYPE_NUMBER)
- );
-
- $this->assertInstanceOf('PHPWord_Style_ListItem', $oListItem->getStyle());
- $this->assertEquals($oListItem->getStyle()->getListType(), PHPWord_Style_ListItem::TYPE_NUMBER);
- }
-
- public function testDepth()
- {
- $iVal = rand(1, 1000);
- $oListItem = new PHPWord_Section_ListItem('text', $iVal);
-
- $this->assertEquals($oListItem->getDepth(), $iVal);
- }
-}
diff --git a/Tests/PHPWord/Section/MemoryImageTest.php b/Tests/PHPWord/Section/MemoryImageTest.php
deleted file mode 100644
index 3bfb39e358..0000000000
--- a/Tests/PHPWord/Section/MemoryImageTest.php
+++ /dev/null
@@ -1,94 +0,0 @@
-assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage);
- $this->assertEquals($oMemoryImage->getSource(), $src);
- $this->assertEquals($oMemoryImage->getMediaId(), md5($src));
- $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefrompng');
- $this->assertEquals($oMemoryImage->getImageFunction(), 'imagepng');
- $this->assertEquals($oMemoryImage->getImageExtension(), 'png');
- $this->assertEquals($oMemoryImage->getImageType(), 'image/png');
- }
-
- public function testGIF()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'mario.gif')
- );
- $oMemoryImage = new PHPWord_Section_MemoryImage($src);
-
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage);
- $this->assertEquals($oMemoryImage->getSource(), $src);
- $this->assertEquals($oMemoryImage->getMediaId(), md5($src));
- $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromgif');
- $this->assertEquals($oMemoryImage->getImageFunction(), 'imagegif');
- $this->assertEquals($oMemoryImage->getImageExtension(), 'gif');
- $this->assertEquals($oMemoryImage->getImageType(), 'image/gif');
- }
-
- public function testJPG()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
- );
- $oMemoryImage = new PHPWord_Section_MemoryImage($src);
-
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage);
- $this->assertEquals($oMemoryImage->getSource(), $src);
- $this->assertEquals($oMemoryImage->getMediaId(), md5($src));
- $this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromjpeg');
- $this->assertEquals($oMemoryImage->getImageFunction(), 'imagejpeg');
- $this->assertEquals($oMemoryImage->getImageExtension(), 'jpg');
- $this->assertEquals($oMemoryImage->getImageType(), 'image/jpeg');
- }
-
- public function testBMP()
- {
- $oMemoryImage = new PHPWord_Section_MemoryImage(\join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'duke_nukem.bmp')
- ));
-
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage);
- $this->assertEquals($oMemoryImage->getImageCreateFunction(), null);
- $this->assertEquals($oMemoryImage->getImageFunction(), null);
- $this->assertEquals($oMemoryImage->getImageExtension(), null);
- $this->assertEquals($oMemoryImage->getImageType(), 'image/x-ms-bmp');
- }
-
- public function testStyle()
- {
- $oMemoryImage = new PHPWord_Section_MemoryImage(\join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
- ), array('width' => 210, 'height' => 210, 'align' => 'center'));
-
- $this->assertInstanceOf('PHPWord_Style_Image', $oMemoryImage->getStyle());
- }
-
- public function testRelationID()
- {
- $oMemoryImage = new PHPWord_Section_MemoryImage(\join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
- ));
-
- $iVal = rand(1, 1000);
- $oMemoryImage->setRelationId($iVal);
- $this->assertEquals($oMemoryImage->getRelationId(), $iVal);
- }
-}
diff --git a/Tests/PHPWord/Section/ObjectTest.php b/Tests/PHPWord/Section/ObjectTest.php
deleted file mode 100644
index b72f2484c8..0000000000
--- a/Tests/PHPWord/Section/ObjectTest.php
+++ /dev/null
@@ -1,85 +0,0 @@
-assertInstanceOf('PHPWord_Section_Object', $oObject);
- $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle());
- $this->assertEquals($oObject->getSource(), $src);
- }
-
- public function testConstructWithNotSupportedFiles()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')
- );
- $oObject = new PHPWord_Section_Object($src);
-
- $this->assertInstanceOf('PHPWord_Section_Object', $oObject);
- $this->assertEquals($oObject->getSource(), null);
- $this->assertEquals($oObject->getStyle(), null);
- }
-
- public function testConstructWithSupportedFilesAndStyle()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
- );
- $oObject = new PHPWord_Section_Object($src, array('width' => '230px'));
-
- $this->assertInstanceOf('PHPWord_Section_Object', $oObject);
- $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle());
- $this->assertEquals($oObject->getSource(), $src);
- }
-
- public function testRelationId()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
- );
- $oObject = new PHPWord_Section_Object($src);
-
- $iVal = rand(1, 1000);
- $oObject->setRelationId($iVal);
- $this->assertEquals($oObject->getRelationId(), $iVal);
- }
-
- public function testImageRelationId()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
- );
- $oObject = new PHPWord_Section_Object($src);
-
- $iVal = rand(1, 1000);
- $oObject->setImageRelationId($iVal);
- $this->assertEquals($oObject->getImageRelationId(), $iVal);
- }
-
- public function testObjectId()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
- );
- $oObject = new PHPWord_Section_Object($src);
-
- $iVal = rand(1, 1000);
- $oObject->setObjectId($iVal);
- $this->assertEquals($oObject->getObjectId(), $iVal);
- }
-}
diff --git a/Tests/PHPWord/Section/PageBreakTest.php b/Tests/PHPWord/Section/PageBreakTest.php
deleted file mode 100644
index 5efd0fe944..0000000000
--- a/Tests/PHPWord/Section/PageBreakTest.php
+++ /dev/null
@@ -1,18 +0,0 @@
-assertInstanceOf('PHPWord_Section_PageBreak', $oPageBreak);
- }
-}
diff --git a/Tests/PHPWord/Section/Table/CellTest.php b/Tests/PHPWord/Section/Table/CellTest.php
deleted file mode 100644
index 30a7fcdb7a..0000000000
--- a/Tests/PHPWord/Section/Table/CellTest.php
+++ /dev/null
@@ -1,209 +0,0 @@
-assertInstanceOf('PHPWord_Section_Table_Cell', $oCell);
- $this->assertEquals($oCell->getWidth(), null);
- }
-
- public function testConstructWithStyleArray()
- {
- $iVal = rand(1, 1000);
- $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, array('valign' => 'center'));
-
- $this->assertInstanceOf('PHPWord_Style_Cell', $oCell->getStyle());
- $this->assertEquals($oCell->getWidth(), null);
- }
-
- public function testConstructWithStyleString()
- {
- $iVal = rand(1, 1000);
- $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, 'cellStyle');
-
- $this->assertEquals($oCell->getStyle(), 'cellStyle');
- }
-
- public function testAddText()
- {
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $element = $oCell->addText('text');
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
- }
-
- public function testAddTextNotUTF8()
- {
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $element = $oCell->addText(utf8_decode('ééé'));
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
- $this->assertEquals($element->getText(), 'ééé');
- }
-
- public function testAddLink()
- {
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $element = $oCell->addLink('http://www.google.fr', 'Nom');
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Link', $element);
- }
-
- public function testAddTextBreak()
- {
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $oCell->addTextBreak();
-
- $this->assertCount(1, $oCell->getElements());
- }
-
- public function testAddListItem()
- {
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $element = $oCell->addListItem('text');
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_ListItem', $element);
- $this->assertEquals($element->getTextObject()->getText(), 'text');
- }
-
- public function testAddListItemNotUTF8()
- {
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $element = $oCell->addListItem(utf8_decode('ééé'));
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_ListItem', $element);
- $this->assertEquals($element->getTextObject()->getText(), 'ééé');
- }
-
- public function testAddImageSection()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
- );
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $element = $oCell->addImage($src);
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
- }
-
- public function testAddImageHeader()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
- );
- $oCell = new PHPWord_Section_Table_Cell('header', 1);
- $element = $oCell->addImage($src);
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
- }
-
- public function testAddImageFooter()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
- );
- $oCell = new PHPWord_Section_Table_Cell('footer', 1);
- $element = $oCell->addImage($src);
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
- }
-
- public function testAddMemoryImageSection()
- {
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $element = $oCell->addMemoryImage(
- 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png'
- );
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
- }
-
- public function testAddMemoryImageHeader()
- {
- $oCell = new PHPWord_Section_Table_Cell('header', 1);
- $element = $oCell->addMemoryImage(
- 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png'
- );
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
- }
-
- public function testAddMemoryImageFooter()
- {
- $oCell = new PHPWord_Section_Table_Cell('footer', 1);
- $element = $oCell->addMemoryImage(
- 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png'
- );
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
- }
-
- public function testAddObjectXLS()
- {
- $src = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
- );
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $element = $oCell->addObject($src);
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Object', $element);
- }
-
- public function testAddPreserveText()
- {
- $oCell = new PHPWord_Section_Table_Cell('header', 1);
- $element = $oCell->addPreserveText('text');
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
- }
-
- public function testAddPreserveTextNotUTF8()
- {
- $oCell = new PHPWord_Section_Table_Cell('header', 1);
- $element = $oCell->addPreserveText(utf8_decode('ééé'));
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
- $this->assertEquals($element->getText(), 'ééé');
- }
-
- public function testCreateTextRun()
- {
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
- $element = $oCell->createTextRun();
-
- $this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_TextRun', $element);
- }
-
- public function testGetElements()
- {
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
-
- $this->assertInternalType('array', $oCell->getElements());
- }
-}
diff --git a/Tests/PHPWord/Section/TextTest.php b/Tests/PHPWord/Section/TextTest.php
deleted file mode 100644
index 1a33a730d7..0000000000
--- a/Tests/PHPWord/Section/TextTest.php
+++ /dev/null
@@ -1,42 +0,0 @@
-assertInstanceOf('PHPWord_Section_Text', $oText);
- $this->assertEquals(null, $oText->getText());
- $this->assertInstanceOf('PHPWord_Style_Font', $oText->getFontStyle());
- $this->assertInstanceOf('PHPWord_Style_Paragraph', $oText->getParagraphStyle());
- }
-
- public function testText()
- {
- $oText = new PHPWord_Section_Text('text');
-
- $this->assertEquals($oText->getText(), 'text');
- }
-
- public function testFont()
- {
- $oText = new PHPWord_Section_Text('text', 'fontStyle');
- $this->assertEquals($oText->getFontStyle(), 'fontStyle');
-
- $oText->setFontStyle(array('bold' => true, 'italic' => true, 'size' => 16));
- $this->assertInstanceOf('PHPWord_Style_Font', $oText->getFontStyle());
- }
-
- public function testParagraph()
- {
- $oText = new PHPWord_Section_Text('text', 'fontStyle', 'paragraphStyle');
- $this->assertEquals($oText->getParagraphStyle(), 'paragraphStyle');
-
- $oText->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
- $this->assertInstanceOf('PHPWord_Style_Paragraph', $oText->getParagraphStyle());
- }
-}
diff --git a/Tests/PHPWord/SectionTest.php b/Tests/PHPWord/SectionTest.php
deleted file mode 100644
index ac540d06a8..0000000000
--- a/Tests/PHPWord/SectionTest.php
+++ /dev/null
@@ -1,133 +0,0 @@
-assertAttributeEquals($oSection->getSettings(), '_settings', new PHPWord_Section(0));
- }
-
- /**
- * @covers PHPWord_Section::getElements
- */
- public function testGetElements()
- {
- $oSection = new PHPWord_Section(0);
- $this->assertAttributeEquals($oSection->getElements(), '_elementCollection', new PHPWord_Section(0));
- }
-
- /**
- * @covers PHPWord_Section::getFooter
- */
- public function testGetFooter()
- {
- $oSection = new PHPWord_Section(0);
- $this->assertAttributeEquals($oSection->getFooter(), '_footer', new PHPWord_Section(0));
- }
-
- /**
- * @covers PHPWord_Section::getHeaders
- */
- public function testGetHeaders()
- {
- $oSection = new PHPWord_Section(0);
- $this->assertAttributeEquals($oSection->getHeaders(), '_headers', new PHPWord_Section(0));
- }
-
- /**
- * @covers PHPWord_Section::setSettings
- */
- public function testSetSettings()
- {
- $expected = 'landscape';
- $object = new PHPWord_Section(0);
- $object->setSettings(array('orientation' => $expected));
- $this->assertEquals($expected, $object->getSettings()->getOrientation());
- }
-
- /**
- * @covers PHPWord_Section::addText
- * @covers PHPWord_Section::addLink
- * @covers PHPWord_Section::addTextBreak
- * @covers PHPWord_Section::addPageBreak
- * @covers PHPWord_Section::addTable
- * @covers PHPWord_Section::addListItem
- * @covers PHPWord_Section::addObject
- * @covers PHPWord_Section::addImage
- * @covers PHPWord_Section::addMemoryImage
- * @covers PHPWord_Section::addTOC
- * @covers PHPWord_Section::addTitle
- * @covers PHPWord_Section::createTextRun
- * @covers PHPWord_Section::createFootnote
- */
- public function testAddElements()
- {
- $objectSource = join(
- DIRECTORY_SEPARATOR,
- array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
- );
- $imageSource = join(
- DIRECTORY_SEPARATOR,
- array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PHPWord.png')
- );
- $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif';
-
- $section = new PHPWord_Section(0);
- $section->addText(utf8_decode('ä'));
- $section->addLink(utf8_decode('http://äää.com'), utf8_decode('ä'));
- $section->addTextBreak();
- $section->addPageBreak();
- $section->addTable();
- $section->addListItem(utf8_decode('ä'));
- $section->addObject($objectSource);
- $section->addImage($imageSource);
- $section->addMemoryImage($imageUrl);
- $section->addTOC();
- $section->addTitle(utf8_decode('ä'), 1);
- $section->createTextRun();
- $section->createFootnote();
-
- $elementCollection = $section->getElements();
- $elementType = 'Link';
- $objectType = "PHPWord_Section_{$elementType}";
- $this->assertInstanceOf($objectType, $elementCollection[1]);
- // $elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak',
- // 'Table', 'ListItem', 'Object', 'Image', 'MemoryImage', 'TOC',
- // 'Title', 'TextRun');
- // $i = 0;
- // foreach ($elementTypes as $elementType) {
- // $objectType = "PHPWord_Section_{$elementType}";
- // $this->assertInstanceOf($objectType, $elementCollection[$i]);
- // $i++;
- // }
- }
-
- /**
- * @covers PHPWord_Section::createHeader
- * @covers PHPWord_Section::createFooter
- */
- public function testCreateHeaderFooter()
- {
- $object = new PHPWord_Section(0);
- $elements = array('Header', 'Footer');
- foreach ($elements as $element) {
- $objectType = "PHPWord_Section_{$element}";
- $method = "create{$element}";
- $this->assertInstanceOf($objectType, $object->$method());
- }
- }
-}
diff --git a/Tests/PHPWord/SettingsTest.php b/Tests/PHPWord/SettingsTest.php
deleted file mode 100644
index e61a212915..0000000000
--- a/Tests/PHPWord/SettingsTest.php
+++ /dev/null
@@ -1,26 +0,0 @@
-assertTrue(PHPWord_Settings::getCompatibility());
- $this->assertTrue(PHPWord_Settings::setCompatibility(false));
- $this->assertFalse(PHPWord_Settings::getCompatibility());
- $this->assertFalse(PHPWord_Settings::setCompatibility('Non boolean'));
- }
-}
diff --git a/Tests/PHPWord/Shared/FileTest.php b/Tests/PHPWord/Shared/FileTest.php
deleted file mode 100644
index fe825b8f8d..0000000000
--- a/Tests/PHPWord/Shared/FileTest.php
+++ /dev/null
@@ -1,92 +0,0 @@
-assertTrue(PHPWord_Shared_File::file_exists('blank.docx'));
- }
- /**
- * Test file_exists()
- */
- public function testNoFileExists()
- {
- $dir = join(DIRECTORY_SEPARATOR, array(
- PHPWORD_TESTS_DIR_ROOT,
- '_files',
- 'templates'
- ));
- chdir($dir);
- $this->assertFalse(PHPWord_Shared_File::file_exists('404.docx'));
- }
-
- /**
- * Test realpath()
- */
- public function testRealpath()
- {
- $dir = join(DIRECTORY_SEPARATOR, array(
- PHPWORD_TESTS_DIR_ROOT,
- '_files',
- 'templates'
- ));
- chdir($dir);
- $file = 'blank.docx';
- $expected = $dir . DIRECTORY_SEPARATOR . $file;
- $this->assertEquals($expected, PHPWord_Shared_File::realpath($file));
- }
-
- /**
- * @covers PHPWord_Shared_File::imagetype
- * @covers PHPWord_Shared_File::fallbackImagetype
- */
- public function testImagetype()
- {
- $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg";
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename, true));
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename));
-
- $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg";
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename, true));
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename));
-
- $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif";
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_GIF, PHPWord_Shared_File::imagetype($filename, true));
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_GIF, PHPWord_Shared_File::imagetype($filename));
-
- $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png";
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_PNG, PHPWord_Shared_File::imagetype($filename, true));
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_PNG, PHPWord_Shared_File::imagetype($filename));
-
- $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp";
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_BMP, PHPWord_Shared_File::imagetype($filename, true));
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_BMP, PHPWord_Shared_File::imagetype($filename));
-
- $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif";
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_TIFF, PHPWord_Shared_File::imagetype($filename, true));
- $this->assertEquals(PHPWord_Shared_File::IMAGETYPE_TIFF, PHPWord_Shared_File::imagetype($filename));
-
- $filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/alexz-johnson.pcx";
- $this->assertFalse(PHPWord_Shared_File::imagetype($filename, true));
- $this->assertFalse(PHPWord_Shared_File::imagetype($filename));
- }
-}
\ No newline at end of file
diff --git a/Tests/PHPWord/Shared/StringTest.php b/Tests/PHPWord/Shared/StringTest.php
deleted file mode 100644
index 3698e2e0e1..0000000000
--- a/Tests/PHPWord/Shared/StringTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-assertTrue(PHPWord_Shared_String::IsUTF8(''));
- $this->assertTrue(PHPWord_Shared_String::IsUTF8('éééé'));
- $this->assertFalse(PHPWord_Shared_String::IsUTF8(utf8_decode('éééé')));
- }
-
- public function testControlCharacterOOXML2PHP()
- {
- $this->assertEquals('', PHPWord_Shared_String::ControlCharacterOOXML2PHP(''));
- $this->assertEquals(chr(0x08), PHPWord_Shared_String::ControlCharacterOOXML2PHP('_x0008_'));
- }
-
- public function testControlCharacterPHP2OOXML()
- {
- $this->assertEquals('', PHPWord_Shared_String::ControlCharacterPHP2OOXML(''));
- $this->assertEquals('_x0008_', PHPWord_Shared_String::ControlCharacterPHP2OOXML(chr(0x08)));
- }
-}
diff --git a/Tests/PHPWord/Style/TableTest.php b/Tests/PHPWord/Style/TableTest.php
deleted file mode 100644
index 439aa5ae8b..0000000000
--- a/Tests/PHPWord/Style/TableTest.php
+++ /dev/null
@@ -1,51 +0,0 @@
-setStyleValue($property, $value);
- $this->assertEquals($value, $object->$get());
- }
- }
-
- /**
- * Test cell margin
- */
- public function testCellMargin()
- {
- $object = new PHPWord_Style_Table();
- $parts = array('Top', 'Left', 'Right', 'Bottom');
-
- // Set cell margin and test if each part has the same margin
- // While looping, push values array to be asserted with getCellMargin
- $value = 240; // In twips
- foreach ($parts as $part) {
- $set = "setCellMargin{$part}";
- $get = "getCellMargin{$part}";
- $values[] = $value;
- $object->$set($value);
- $this->assertEquals($value, $object->$get());
- }
- $this->assertEquals($values, $object->getCellMargin());
- }
-}
diff --git a/Tests/PHPWord/StyleTest.php b/Tests/PHPWord/StyleTest.php
deleted file mode 100644
index 9e442cb13e..0000000000
--- a/Tests/PHPWord/StyleTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
- 'center');
- $font = array('italic' => true);
- $table = array('bgColor' => 'CCCCCC');
- $styles = array('Paragraph' => 'Paragraph', 'Font' => 'Font',
- 'Link' => 'Font', 'Table' => 'TableFull',
- 'Heading_1' => 'Font', 'Normal' => 'Paragraph');
- $elementCount = 6;
- PHPWord_Style::addParagraphStyle('Paragraph', $paragraph);
- PHPWord_Style::addFontStyle('Font', $font);
- PHPWord_Style::addLinkStyle('Link', $font);
- PHPWord_Style::addTableStyle('Table', $table);
- PHPWord_Style::addTitleStyle(1, $font);
- PHPWord_Style::setDefaultParagraphStyle($paragraph);
-
- $this->assertEquals($elementCount, count(PHPWord_Style::getStyles()));
- foreach ($styles as $name => $style) {
- $expected = "PHPWord_Style_{$style}";
- $this->assertInstanceOf($expected, PHPWord_Style::getStyle($name));
- }
- $this->assertNull(PHPWord_Style::getStyle('Unknown'));
- }
-}
diff --git a/Tests/PHPWord/Writer/ODTextTest.php b/Tests/PHPWord/Writer/ODTextTest.php
deleted file mode 100644
index ef92d249fd..0000000000
--- a/Tests/PHPWord/Writer/ODTextTest.php
+++ /dev/null
@@ -1,154 +0,0 @@
-assertInstanceOf('PHPWord', $object->getPHPWord());
- $this->assertInstanceOf("PHPWord_HashTable", $object->getDrawingHashTable());
-
- $this->assertEquals('./', $object->getDiskCachingDirectory());
- $writerParts = array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles');
- foreach ($writerParts as $part) {
- $this->assertInstanceOf(
- "PHPWord_Writer_ODText_{$part}",
- $object->getWriterPart($part)
- );
- $this->assertInstanceOf(
- "PHPWord_Writer_ODText",
- $object->getWriterPart($part)->getParentWriter()
- );
- }
- }
-
- /**
- * @covers ::getPHPWord
- * @expectedException Exception
- * @expectedExceptionMessage No PHPWord assigned.
- */
- public function testConstructWithNull()
- {
- $object = new PHPWord_Writer_ODText();
- $object->getPHPWord();
- }
-
- /**
- * @covers ::save
- */
- public function testSave()
- {
- $imageSrc = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PHPWord.png')
- );
- $objectSrc = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
- );
- $file = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.odt')
- );
-
- $phpWord = new PHPWord();
- $phpWord->addFontStyle('Font', array('size' => 11));
- $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
- $section = $phpWord->createSection();
- $section->addText('Test 1', 'Font');
- $section->addTextBreak();
- $section->addText('Test 2', null, 'Paragraph');
- $section->addLink('http://test.com');
- $section->addTitle('Test', 1);
- $section->addPageBreak();
- $section->addTable();
- $section->addListItem('Test');
- $section->addImage($imageSrc);
- $section->addObject($objectSrc);
- $section->addTOC();
- $section = $phpWord->createSection();
- $textrun = $section->createTextRun();
- $textrun->addText('Test 3');
- $writer = new PHPWord_Writer_ODText($phpWord);
- $writer->save($file);
-
- $this->assertTrue(file_exists($file));
-
- unlink($file);
- }
-
- /**
- * @covers ::save
- * @todo Haven't got any method to test this
- */
- public function testSavePhpOutput()
- {
- $phpWord = new PHPWord();
- $section = $phpWord->createSection();
- $section->addText('Test');
- $writer = new PHPWord_Writer_ODText($phpWord);
- $writer->save('php://output');
- }
-
- /**
- * @covers ::save
- * @expectedException Exception
- * @expectedExceptionMessage PHPWord object unassigned.
- */
- public function testSaveException()
- {
- $writer = new PHPWord_Writer_ODText();
- $writer->save();
- }
-
- /**
- * @covers ::getWriterPart
- */
- public function testGetWriterPartNull()
- {
- $object = new PHPWord_Writer_ODText();
- $this->assertNull($object->getWriterPart('foo'));
- }
-
- /**
- * @covers ::setUseDiskCaching
- * @covers ::getUseDiskCaching
- */
- public function testSetGetUseDiskCaching()
- {
- $object = new PHPWord_Writer_ODText();
- $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT);
- $this->assertTrue($object->getUseDiskCaching());
- $this->assertEquals(PHPWORD_TESTS_DIR_ROOT, $object->getDiskCachingDirectory());
- }
-
- /**
- * @covers ::setUseDiskCaching
- * @expectedException Exception
- */
- public function testSetUseDiskCachingException()
- {
- $dir = \join(
- \DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, 'foo')
- );
-
- $object = new PHPWord_Writer_ODText($phpWord);
- $object->setUseDiskCaching(true, $dir);
- }
-}
diff --git a/Tests/PHPWord/Writer/RTFTest.php b/Tests/PHPWord/Writer/RTFTest.php
deleted file mode 100644
index d071def78f..0000000000
--- a/Tests/PHPWord/Writer/RTFTest.php
+++ /dev/null
@@ -1,107 +0,0 @@
-assertInstanceOf('PHPWord', $object->getPHPWord());
- $this->assertInstanceOf("PHPWord_HashTable", $object->getDrawingHashTable());
- }
-
- /**
- * covers ::__construct
- * @expectedException Exception
- * @expectedExceptionMessage No PHPWord assigned.
- */
- public function testConstructWithNull()
- {
- $object = new PHPWord_Writer_RTF();
- $object->getPHPWord();
- }
-
- /**
- * @covers ::save
- * @todo Haven't got any method to test this
- */
- public function testSavePhpOutput()
- {
- $phpWord = new PHPWord();
- $section = $phpWord->createSection();
- $section->addText('Test');
- $writer = new PHPWord_Writer_RTF($phpWord);
- $writer->save('php://output');
- }
-
- /**
- * @covers ::save
- * @expectedException Exception
- * @expectedExceptionMessage PHPWord object unassigned.
- */
- public function testSaveException()
- {
- $writer = new PHPWord_Writer_RTF();
- $writer->save();
- }
-
- /**
- * @covers ::save
- * @covers ::
Results: '; + foreach ($types as $type) { + $result = "results/{$sampleFile}.{$type}"; + if (file_exists($result)) { + echo "{$type} "; + } + } + echo '
'; + } +?> + + + +