diff --git a/.travis.yml b/.travis.yml
index da52a1746f..0712f73461 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,10 +5,12 @@ php:
- 5.4
- 5.5
- 5.6
+ - 7.0
- hhvm
matrix:
allow_failures:
+ - php: 7.0
- php: hhvm
env:
@@ -31,8 +33,6 @@ before_script:
script:
## PHP_CodeSniffer
- ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
- ## PHP Copy/Paste Detector
- - ./vendor/bin/phpcpd src/ tests/ --verbose
## PHP Mess Detector
- ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
## PHPUnit
@@ -47,4 +47,4 @@ after_script:
- bash .travis_shell_after_success.sh
## Scrutinizer
- wget https://scrutinizer-ci.com/ocular.phar
- - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
\ No newline at end of file
+ - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 89bfc104d0..66f38ddaca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,26 +1,72 @@
-CHANGELOG
-=========
+Change Log
+==========
+All notable changes to this project will be documented in this file.
+This project adheres to [Semantic Versioning](http://semver.org/).
-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.12.1 (30 August 2015)
+v0.13.0 (31 July 2016)
-------------------
+This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).
+It also introduces constants for horizontal alignment options, and resolves some issues with PHP 7.
+Manual installation feature has been dropped since the release. Please, use [Composer](https://getcomposer.org/) to install PHPWord.
+
+### Added
+- Introduced the `\PhpOffice\PhpWord\SimpleType\Jc` simple type. - @RomanSyroeshko
+- Introduced the `\PhpOffice\PhpWord\SimpleType\JcTable` simple type. - @RomanSyroeshko
+- Introduced writer for the "Paragraph Alignment" element (see `\PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment`). - @RomanSyroeshko
+- Introduced writer for the "Table Alignment" element (see `\PhpOffice\PhpWord\Writer\Word2007\Element\TableAlignment`). - @RomanSyroeshko
+- Supported indexed arrays in arguments of `TemplateProcessor::setValue()`. - @RomanSyroeshko #618
+- Introduced automatic output escaping for OOXML, ODF, HTML, and RTF. To turn the feature on use `phpword.ini` or `\PhpOffice\PhpWord\Settings`. - @RomanSyroeshko #483
+- Supported processing of headers and footers in `TemplateProcessor::applyXslStyleSheet()`. - @RomanSyroeshko #335
+
+### Changed
+- Improved error message for the case when `autoload.php` is not found. - @RomanSyroeshko #371
+- Renamed the `align` option of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles into `alignment`. - @RomanSyroeshko
+- Improved performance of `TemplateProcessor::setValue()`. - @kazitanvirahsan #614, #617
-Maintenance release. This release is focused primarily on ``TemplateProcessor``.
+### Deprecated
+- `getAlign` and `setAlign` methods of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles.
+Use the correspondent `getAlignment` and `setAlignment` methods instead. - @RomanSyroeshko
+- `left`, `right`, and `justify` alignment options for paragraphs (now are mapped to `Jc::START`, `Jc::END`, and `Jc::BOTH`). - @RomanSyroeshko
+- `left`, `right`, and `justify` alignment options for tables (now are mapped to `Jc::START`, `Jc::END`, and `Jc::CENTER`). - @RomanSyroeshko
+- `TCPDF` due to its limited HTML support. Use `DomPDF` or `MPDF` writer instead. - @RomanSyroeshko #399
+
+### Removed
+- `\PhpOffice\PhpWord\Style\Alignment`. Style properties, which previously stored instances of this class, now deal with strings.
+In each case set of available string values is defined by the correspondent simple type. - @RomanSyroeshko
+- Manual installation support. Since the release we have dependencies on third party libraries,
+so installation via ZIP-archive download is not an option anymore. To install PHPWord use [Composer](https://getcomposer.org/).
+ We also removed `\PhpOffice\PhpWord\Autoloader`, because the latter change made it completely useless.
+ Autoloaders provided by Composer are in use now (see `bootstrap.php`). - @RomanSyroeshko
+- `\PhpOffice\PhpWord\Shared\Drawing` replaced by `\PhpOffice\Common\Drawing`. - @Progi1984 #658
+- `\PhpOffice\PhpWord\Shared\Font`. - @Progi1984 #658
+- `\PhpOffice\PhpWord\Shared\String` replaced by `\PhpOffice\Common\Text`. - @Progi1984 @RomanSyroeshko #658
+- `\PhpOffice\PhpWord\Shared\XMLReader` replaced by `\PhpOffice\Common\XMLReader`. - @Progi1984 #658
+- `\PhpOffice\PhpWord\Shared\XMLWriter` replaced by `\PhpOffice\Common\XMLWriter`. - @Progi1984 @RomanSyroeshko #658
+- `AbstractContainer::addMemoryImage()`. Use `AbstractContainer::addImage()` instead.
+
+### Fixed
+- `Undefined property` error while reading MS-DOC documents. - @jaberu #610
+- Corrupted OOXML template issue in case when its names is broken immediately after `$` sign.
+That case wasn't taken into account in implementation of `TemplateProcessor::fixBrokenMacros()`. - @RomanSyroeshko @d-damien #548
+
+
+
+v0.12.1 (30 August 2015)
+-----------------------
+Maintenance release. This release is focused primarily on `TemplateProcessor`.
### Changes
-- Changed visibility of all private properties and methods of ``TemplateProcessor`` to ``protected``. - @RomanSyroeshko #498
-- Improved performance of ``TemplateProcessor::setValue()``. - @RomanSyroeshko @nicoSWD #513
+- Changed visibility of all private properties and methods of `TemplateProcessor` to `protected`. - @RomanSyroeshko #498
+- Improved performance of `TemplateProcessor::setValue()`. - @RomanSyroeshko @nicoSWD #513
### Bugfixes
-- Fixed issue with "Access denied" message while opening ``Sample_07_TemplateCloneRow.docx`` and ``Sample_23_TemplateBlock.docx`` result files on Windows platform. - @RomanSyroeshko @AshSat #532
-- Fixed ``PreserveText`` element alignment in footer (see ``Sample_12_HeaderFooter.php``). - @RomanSyroeshko @SSchwaiger #495
+- Fixed issue with "Access denied" message while opening `Sample_07_TemplateCloneRow.docx` and `Sample_23_TemplateBlock.docx` result files on Windows platform. - @RomanSyroeshko @AshSat #532
+- Fixed `PreserveText` element alignment in footer (see `Sample_12_HeaderFooter.php`). - @RomanSyroeshko @SSchwaiger #495
-0.12.0 (3 January 2015)
+v0.12.0 (3 January 2015)
-----------------------
-
This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. Basic MsDoc reader is introduced.
### Features
@@ -78,18 +124,16 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap
-0.11.1 (2 June 2014)
+v0.11.1 (2 June 2014)
--------------------
-
This is an immediate bugfix release for HTML reader.
- HTML Reader: `
` and header tags puts no output - @canyildiz @ivanlanin #257
-0.11.0 (1 June 2014)
+v0.11.0 (1 June 2014)
--------------------
-
This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four new elements were added: TextBox, ListItemRun, Field, and Line. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemented. RTF and HTML reader were initiated.
### Features
@@ -152,18 +196,16 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four
-0.10.1 (21 May 2014)
+v0.10.1 (21 May 2014)
--------------------
-
This is a bugfix release for `php-zip` requirement in Composer.
- Change Composer requirements for php-zip from `require` to `suggest` - @bskrtich #246
-0.10.0 (4 May 2014)
+v0.10.0 (4 May 2014)
-------------------
-
This release marked heavy refactorings on internal code structure with the creation of some abstract classes to reduce code duplication. `Element` subnamespace is introduced in this release to replace `Section`. Word2007 reader capability is greatly enhanced. Endnote is introduced. List numbering is now customizable. Basic HTML and PDF writing support is enabled. Basic ODText reader is introduced.
### Features
@@ -246,18 +288,16 @@ This release marked heavy refactorings on internal code structure with the creat
-0.9.1 (27 Mar 2014)
+v0.9.1 (27 Mar 2014)
-------------------
-
This is a bugfix release for PSR-4 compatibility.
- Fixed PSR-4 composer autoloader - @AntonTyutin
-0.9.0 (26 Mar 2014)
+v0.9.0 (26 Mar 2014)
-------------------
-
This release marked the transformation to namespaces (PHP 5.3+).
### Features
@@ -278,18 +318,16 @@ This release marked the transformation to namespaces (PHP 5.3+).
-0.8.1 (17 Mar 2014)
+v0.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)
+v0.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
@@ -336,9 +374,8 @@ This release merged a lot of improvements from the community. Unit tests introdu
-0.7.0 (28 Jan 2014)
+v0.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
@@ -362,4 +399,4 @@ This is the first release after a long development hiatus in [CodePlex](https://
- 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 [#49](http://phpword.codeplex.com/workitem/49)
+- IMPROVED: Advanced string replace in setValue for Template - @Esmeraldo [#49](http://phpword.codeplex.com/workitem/49)
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 3f6a8c3865..8a1acaeaba 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
PHPWord, a pure PHP library for reading and writing word processing documents.
-Copyright (c) 2010-2014 PHPWord.
+Copyright (c) 2010-2016 PHPWord.
PHPWord is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3 as published by
diff --git a/README.md b/README.md
index 8f499a8ebb..949238a79b 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,7 @@
[](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/)
[](https://packagist.org/packages/phpoffice/phpword)
[](https://packagist.org/packages/phpoffice/phpword)
+[](https://gitter.im/PHPOffice/PHPWord)
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), [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF), HTML, and PDF.
@@ -23,7 +24,7 @@ Read more about PHPWord:
## 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:
+With PHPWord, you can create OOXML, ODF, or RTF documents dynamically using your PHP 5.3.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
@@ -44,50 +45,46 @@ With PHPWord, you can create DOCX, ODT, or RTF documents dynamically using your
- Insert charts (pie, doughnut, bar, line, area, scatter, radar)
- Insert form fields (textinput, checkbox, and dropdown)
- Create document from templates
-- Use XSL 1.0 style sheets to transform main document part of OOXML template
+- Use XSL 1.0 style sheets to transform headers, main document part, and footers of an OOXML template
- ... and many more features on progress
## Requirements
PHPWord requires the following:
-- PHP 5.3+
-- [Zip extension](http://php.net/manual/en/book.zip.php)
+- PHP 5.3.3+
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
+- [Zend\Escaper component](http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html)
+- Zend\Stdlib component
+- [Zend\Validator component](http://framework.zend.com/manual/current/en/modules/zend.validator.html)
+- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)
- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images)
-- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write DOCX and ODT)
+- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write OOXML and ODF)
- [XSL extension](http://php.net/manual/en/book.xsl.php) (optional, used to apply XSL style sheet to template )
-- [dompdf](https://github.com/dompdf/dompdf) (optional, used to write PDF)
+- [dompdf library](https://github.com/dompdf/dompdf) (optional, used to write PDF)
## Installation
-It is recommended that you install the PHPWord library [through composer](http://getcomposer.org/). To do so, add
-the following lines to your ``composer.json``.
+PHPWord is installed via [Composer](https://getcomposer.org/).
+You just need to [add dependency](https://getcomposer.org/doc/04-schema.md#package-links>) on PHPWord into your package.
+
+Example:
```json
{
"require": {
- "phpoffice/phpword": "dev-master"
+ "phpoffice/phpword": "v0.13.*"
}
}
```
-Alternatively, you can download the latest release from the [releases page](https://github.com/PHPOffice/PHPWord/releases).
-In this case, you will have to register the autoloader.
-
-```php
-require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php';
-\PhpOffice\PhpWord\Autoloader::register();
-```
-
## Getting started
The following is a basic usage example of the PHPWord library.
```php
addSection();
// Adding Text element to the Section having font styled by default...
$section->addText(
- htmlspecialchars(
- '"Learn from yesterday, live for today, hope for tomorrow. '
- . 'The important thing is not to stop questioning." '
- . '(Albert Einstein)'
- )
+ '"Learn from yesterday, live for today, hope for tomorrow. '
+ . 'The important thing is not to stop questioning." '
+ . '(Albert Einstein)'
);
/*
@@ -114,11 +109,9 @@ $section->addText(
// Adding Text element with font customized inline...
$section->addText(
- htmlspecialchars(
- '"Great achievement is usually born of great sacrifice, '
- . 'and is never the result of selfishness." '
- . '(Napoleon Hill)'
- ),
+ '"Great achievement is usually born of great sacrifice, '
+ . 'and is never the result of selfishness." '
+ . '(Napoleon Hill)',
array('name' => 'Tahoma', 'size' => 10)
);
@@ -129,11 +122,9 @@ $phpWord->addFontStyle(
array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
);
$section->addText(
- htmlspecialchars(
- '"The greatest accomplishment is not in never falling, '
- . 'but in rising again after you fall." '
- . '(Vince Lombardi)'
- ),
+ '"The greatest accomplishment is not in never falling, '
+ . 'but in rising again after you fall." '
+ . '(Vince Lombardi)',
$fontStyleName
);
@@ -142,9 +133,7 @@ $fontStyle = new \PhpOffice\PhpWord\Style\Font();
$fontStyle->setBold(true);
$fontStyle->setName('Tahoma');
$fontStyle->setSize(13);
-$myTextElement = $section->addText(
- htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
-);
+$myTextElement = $section->addText('"Believe you can and you\'re halfway there." (Theodor Roosevelt)');
$myTextElement->setFontStyle($fontStyle);
// Saving the document as OOXML file...
@@ -162,7 +151,6 @@ $objWriter->save('helloWorld.html');
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
```
-:warning: Escape any string you pass to OOXML/ODF/HTML document, otherwise it may get broken.
More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail.
diff --git a/VERSION b/VERSION
index aac2dacab4..51de3305bb 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.12.1
\ No newline at end of file
+0.13.0
\ No newline at end of file
diff --git a/bootstrap.php b/bootstrap.php
new file mode 100644
index 0000000000..11939feefd
--- /dev/null
+++ b/bootstrap.php
@@ -0,0 +1,28 @@
+=5.3.3",
- "ext-xml": "*"
+ "ext-xml": "*",
+ "zendframework/zend-escaper": "2.4.*",
+ "zendframework/zend-stdlib": "2.4.*",
+ "zendframework/zend-validator": "2.4.*",
+ "phpoffice/common": "0.2.*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpdocumentor/phpdocumentor":"2.*",
"squizlabs/php_codesniffer": "1.*",
"phpmd/phpmd": "2.*",
- "sebastian/phpcpd": "2.*",
"phploc/phploc": "2.*",
"dompdf/dompdf":"0.6.*",
- "tecnick.com/tcpdf": "6.*",
+ "tecnickcom/tcpdf": "6.*",
"mpdf/mpdf": "5.*"
},
"suggest": {
- "ext-zip": "Used to write DOCX and ODT",
- "ext-gd2": "Used to add images",
- "ext-xmlwriter": "Used to write DOCX and ODT",
- "ext-xsl": "Used to apply XSL style sheet to main document part of OOXML template",
- "dompdf/dompdf": "Used to write PDF"
+ "ext-zip": "Allows writing OOXML and ODF",
+ "ext-gd2": "Allows adding images",
+ "ext-xmlwriter": "Allows writing OOXML and ODF",
+ "ext-xsl": "Allows applying XSL style sheet to headers, to main document part, and to footers of an OOXML template",
+ "dompdf/dompdf": "Allows writing PDF"
},
"autoload": {
"psr-4": {
diff --git a/docs/Makefile b/docs/Makefile
index 5631b06028..bd38cd5d9d 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -77,17 +77,17 @@ qthelp:
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
- @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PhpWord.qhcp"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PHPWord.qhcp"
@echo "To view the help file:"
- @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PhpWord.qhc"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PHPWord.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
- @echo "# mkdir -p $$HOME/.local/share/devhelp/PhpWord"
- @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PhpWord"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/PHPWord"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PHPWord"
@echo "# devhelp"
epub:
diff --git a/docs/conf.py b/docs/conf.py
index de645350d0..e9b1c59e45 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -40,15 +40,15 @@
master_doc = 'index'
# General information about the project.
-project = u'PhpWord'
-copyright = u'2014, PHPWord Contributors'
+project = u'PHPWord'
+copyright = u'2014-2015, PHPWord Contributors'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
-version = '0.12.0'
+version = '0.13.0'
# The full version, including alpha/beta/rc tags.
release = version
@@ -164,7 +164,7 @@
#html_file_suffix = None
# Output file base name for HTML help builder.
-htmlhelp_basename = 'PhpWorddoc'
+htmlhelp_basename = 'PHPWorddoc'
# -- Options for LaTeX output --------------------------------------------------
@@ -183,8 +183,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ('index', 'PhpWord.tex', u'PhpWord Documentation',
- u'The PhpWord Team', 'manual'),
+ ('index', 'PHPWord.tex', u'PHPWord Documentation',
+ u'The PHPWord Team', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -213,8 +213,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
- ('index', 'PhpWord', u'PhpWord Documentation',
- [u'The PhpWord Team'], 1)
+ ('index', 'PHPWord', u'PHPWord Documentation',
+ [u'The PHPWord Team'], 1)
]
# If true, show URL addresses after external links.
@@ -227,8 +227,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- ('index', 'PhpWord', u'PhpWord Documentation',
- u'The PhpWord Team', 'PhpWord', 'One line description of project.',
+ ('index', 'PHPWord', u'PHPWord Documentation',
+ u'The PHPWord Team', 'PHPWord', 'One line description of project.',
'Miscellaneous'),
]
@@ -244,9 +244,9 @@
# -- Options for Epub output ---------------------------------------------------
# Bibliographic Dublin Core info.
-epub_title = u'PhpWord'
-epub_author = u'The PhpWord Team'
-epub_publisher = u'The PhpWord Team'
+epub_title = u'PHPWord'
+epub_author = u'The PHPWord Team'
+epub_publisher = u'The PHPWord Team'
epub_copyright = copyright
# The language of the text. It defaults to the language option
diff --git a/docs/elements.rst b/docs/elements.rst
index eb70f9ad9b..d68ee035dc 100644
--- a/docs/elements.rst
+++ b/docs/elements.rst
@@ -50,115 +50,48 @@ column shows the containers while the rows lists the elements.
Legend:
-- ``v`` Available
-- ``v*`` Available only when inside header/footer
-- ``v**`` Available only when inside section
-- ``-`` Not available
-- ``?`` Should be available
+- ``v``. Available.
+- ``v*``. Available only when inside header/footer.
+- ``v**``. Available only when inside section.
+- ``-``. Not available.
+- ``?``. Should be available.
Texts
-----
Text can be added by using ``addText`` and ``addTextRun`` method.
-``addText`` is used for creating simple paragraphs that only contain
-texts with the same style. ``addTextRun`` 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. The syntaxes are
-as follow:
+``addText`` is used for creating simple paragraphs that only contain texts with the same style.
+``addTextRun`` 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. The syntaxes are as follow:
.. code-block:: php
$section->addText($text, [$fontStyle], [$paragraphStyle]);
$textrun = $section->addTextRun([$paragraphStyle]);
-Text styles
-~~~~~~~~~~~
-
-You can use the ``$fontStyle`` and ``$paragraphStyle`` variable to
-define text formatting. There are 2 options to style the inserted text
-elements, i.e. inline style by using array or defined style by adding
-style definition.
-
-Inline style examples:
-
-.. code-block:: php
-
- $fontStyle = array('name' => 'Times New Roman', 'size' => 9);
- $paragraphStyle = array('align' => 'both');
- $section->addText('I am simple paragraph', $fontStyle, $paragraphStyle);
+- ``$text``. Text to be displayed in the document.
+- ``$fontStyle``. See :ref:`font-style`.
+- ``$paragraphStyle``. See :ref:`paragraph-style`.
- $textrun = $section->addTextRun();
- $textrun->addText('I am bold', array('bold' => true));
- $textrun->addText('I am italic', array('italic' => true));
- $textrun->addText('I am colored', array('color' => 'AACC00'));
-
-Defined style examples:
-
-.. code-block:: php
-
- $fontStyle = array('color' => '006699', 'size' => 18, 'bold' => true);
- $phpWord->addFontStyle('fStyle', $fontStyle);
- $text = $section->addText('Hello world!', 'fStyle');
-
- $paragraphStyle = array('align' => 'center');
- $phpWord->addParagraphStyle('pStyle', $paragraphStyle);
- $text = $section->addText('Hello world!', 'pStyle');
-
-Font style
-^^^^^^^^^^
-
-Available font styles:
-
-- ``name`` Font name, e.g. *Arial*
-- ``size`` Font size, e.g. *20*, *22*,
-- ``hint`` Font content type, *default*, *eastAsia*, or *cs*
-- ``bold`` Bold, *true* or *false*
-- ``italic`` Italic, *true* or *false*
-- ``superScript`` Superscript, *true* or *false*
-- ``subScript`` Subscript, *true* or *false*
-- ``underline`` Underline, *dash*, *dotted*, etc.
-- ``strikethrough`` Strikethrough, *true* or *false*
-- ``doubleStrikethrough`` Double strikethrough, *true* or *false*
-- ``color`` Font color, e.g. *FF0000*
-- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue*
-- ``bgColor`` Font background color, e.g. *FF0000*
-- ``smallCaps`` Small caps, *true* or *false*
-- ``allCaps`` All caps, *true* or *false*
-
-Paragraph style
-^^^^^^^^^^^^^^^
-
-Available paragraph styles:
-
-- ``align`` Paragraph alignment, *left*, *right* or *center*
-- ``spaceBefore`` Space before paragraph
-- ``spaceAfter`` Space after paragraph
-- ``indent`` Indent by how much
-- ``hanging`` Hanging by how much
-- ``basedOn`` Parent style
-- ``next`` Style for next paragraph
-- ``widowControl`` Allow first/last line to display on a separate page,
- *true* or *false*
-- ``keepNext`` Keep paragraph with next paragraph, *true* or *false*
-- ``keepLines`` Keep all lines on one page, *true* or *false*
-- ``pageBreakBefore`` Start paragraph on next page, *true* or *false*
-- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect...
-- ``tabs`` Set of custom tab stops
+For available styling options see :ref:`font-style` and :ref:`paragraph-style`.
Titles
~~~~~~
-If you want to structure your document or build table of contents, you
-need titles or headings. To add a title to the document, use the
-``addTitleStyle`` and ``addTitle`` method.
+If you want to structure your document or build table of contents, you need titles or headings.
+To add a title to the document, use the ``addTitleStyle`` and ``addTitle`` method.
.. code-block:: php
$phpWord->addTitleStyle($depth, [$fontStyle], [$paragraphStyle]);
$section->addTitle($text, [$depth]);
-Its necessary to add a title style to your document because otherwise
-the title won't be detected as a real title.
+- ``depth``.
+- ``$fontStyle``. See :ref:`font-style`.
+- ``$paragraphStyle``. See :ref:`paragraph-style`.
+- ``$text``. Text to be displayed in the document.
+
+It's necessary to add a title style to your document because otherwise the title won't be detected as a real title.
Links
~~~~~
@@ -169,16 +102,15 @@ You can add Hyperlinks to the document by using the function addLink:
$section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle]);
-- ``$linkSrc`` The URL of the link.
-- ``$linkName`` Placeholder of the URL that appears in the document.
-- ``$fontStyle`` See "Font style" section.
-- ``$paragraphStyle`` See "Paragraph style" section.
+- ``$linkSrc``. The URL of the link.
+- ``$linkName``. Placeholder of the URL that appears in the document.
+- ``$fontStyle``. See :ref:`font-style`.
+- ``$paragraphStyle``. See :ref:`paragraph-style`.
Preserve texts
~~~~~~~~~~~~~~
-The ``addPreserveText`` method is used to add a page number or page
-count to headers or footers.
+The ``addPreserveText`` method is used to add a page number or page count to headers or footers.
.. code-block:: php
@@ -190,16 +122,15 @@ Breaks
Text breaks
~~~~~~~~~~~
-Text breaks are empty new lines. To add text breaks, use the following
-syntax. All paramaters are optional.
+Text breaks are empty new lines. To add text breaks, use the following syntax. All parameters are optional.
.. code-block:: php
$section->addTextBreak([$breakCount], [$fontStyle], [$paragraphStyle]);
-- ``$breakCount`` How many lines
-- ``$fontStyle`` See "Font style" section.
-- ``$paragraphStyle`` See "Paragraph style" section.
+- ``$breakCount``. How many lines.
+- ``$fontStyle``. See :ref:`font-style`.
+- ``$paragraphStyle``. See :ref:`paragraph-style`.
Page breaks
~~~~~~~~~~~
@@ -224,56 +155,40 @@ Basic usage:
Parameters:
-- ``$text`` Text that appears in the document.
-- ``$depth`` Depth of list item.
-- ``$fontStyle`` See "Font style" section.
-- ``$listStyle`` List style of the current element TYPE\_NUMBER,
- TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in
- PHPWord\_Style\_ListItem.
-- ``$paragraphStyle`` See "Paragraph style" section.
+- ``$text``. Text that appears in the document.
+- ``$depth``. Depth of list item.
+- ``$fontStyle``. See :ref:`font-style`.
+- ``$listStyle``. List style of the current element TYPE\_NUMBER,
+ TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\_Style\_ListItem.
+- ``$paragraphStyle``. See :ref:`paragraph-style`.
Advanced usage:
-You can also create your own numbering style by changing the
-``$listStyle`` parameter with the name of your numbering style.
+You can also create your own numbering style by changing the ``$listStyle`` parameter with the name of your numbering style.
.. code-block:: php
$phpWord->addNumberingStyle(
'multilevel',
- array('type' => 'multilevel', 'levels' => array(
- array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360),
- array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
+ array(
+ 'type' => 'multilevel',
+ 'levels' => array(
+ array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360),
+ array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
)
- )
+ )
);
$section->addListItem('List Item I', 0, null, 'multilevel');
$section->addListItem('List Item I.a', 1, null, 'multilevel');
$section->addListItem('List Item I.b', 1, null, 'multilevel');
$section->addListItem('List Item II', 0, null, 'multilevel');
-Level styles:
-
-- ``start`` Starting value
-- ``format`` Numbering format
- bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter
-- ``restart`` Restart numbering level symbol
-- ``suffix`` Content between numbering symbol and paragraph text
- tab\|space\|nothing
-- ``text`` Numbering level text e.g. %1 for nonbullet or bullet
- character
-- ``align`` Numbering symbol align left\|center\|right\|both
-- ``left`` See paragraph style
-- ``hanging`` See paragraph style
-- ``tabPos`` See paragraph style
-- ``font`` Font name
-- ``hint`` See font style
+For available styling options see :ref:`numbering-level-style`.
Tables
------
-To add tables, rows, and cells, use the ``addTable``, ``addRow``, and
-``addCell`` methods:
+To add tables, rows, and cells, use the ``addTable``, ``addRow``, and ``addCell`` methods:
.. code-block:: php
@@ -287,46 +202,19 @@ Table style can be defined with ``addTableStyle``:
$tableStyle = array(
'borderColor' => '006699',
- 'borderSize' => 6,
- 'cellMargin' => 50
+ 'borderSize' => 6,
+ 'cellMargin' => 50
);
$firstRowStyle = array('bgColor' => '66BBFF');
$phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle);
$table = $section->addTable('myTable');
-Table, row, and cell styles
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Table styles:
-
-- ``width`` Table width in percent
-- ``bgColor`` Background color, e.g. '9966CC'
-- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
-- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
-- ``cellMargin(Top|Right|Bottom|Left)`` Cell margin in twips
-
-Row styles:
-
-- ``tblHeader`` Repeat table row on every new page, *true* or *false*
-- ``cantSplit`` Table row cannot break across pages, *true* or *false*
-- ``exactHeight`` Row height is exact or at least
-
-Cell styles:
-
-- ``width`` Cell width in twips
-- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom*
-- ``textDirection`` Direction of text
-- ``bgColor`` Background color, e.g. '9966CC'
-- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
-- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
-- ``gridSpan`` Number of columns spanned
-- ``vMerge`` *restart* or *continue*
+For available styling options see :ref:`table-style`.
Cell span
~~~~~~~~~
-You can span a cell on multiple columns by using ``gridSpan`` or
-multiple rows by using ``vMerge``.
+You can span a cell on multiple columns by using ``gridSpan`` or multiple rows by using ``vMerge``.
.. code-block:: php
@@ -338,15 +226,14 @@ See ``Sample_09_Tables.php`` for more code sample.
Images
------
-To add an image, use the ``addImage`` method to sections, headers,
-footers, textruns, or table cells.
+To add an image, use the ``addImage`` method to sections, headers, footers, textruns, or table cells.
.. code-block:: php
$section->addImage($src, [$style]);
-- source String path to a local image or URL of a remote image
-- styles Array fo styles for the image. See below.
+- ``$src``. String path to a local image or URL of a remote image.
+- ``$style``. See :ref:`image-style`.
Examples:
@@ -356,10 +243,10 @@ Examples:
$section->addImage(
'mars.jpg',
array(
- 'width' => 100,
- 'height' => 100,
- 'marginTop' => -1,
- 'marginLeft' => -1,
+ 'width' => 100,
+ 'height' => 100,
+ 'marginTop' => -1,
+ 'marginLeft' => -1,
'wrappingStyle' => 'behind'
)
);
@@ -368,19 +255,6 @@ Examples:
$textrun = $section->addTextRun();
$textrun->addImage('http://php.net/logo.jpg');
-Image styles
-~~~~~~~~~~~~
-
-Available image styles:
-
-- ``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`` Wrapping style, *inline*, *square*, *tight*,
- *behind*, or *infront*
-
Watermarks
~~~~~~~~~~
@@ -408,25 +282,22 @@ Table of contents
-----------------
To add a table of contents (TOC), you can use the ``addTOC`` method.
-Your TOC can only be generated if you have add at least one title (See
-"Titles").
+Your TOC can only be generated if you have add at least one title (See "Titles").
.. code-block:: php
$section->addTOC([$fontStyle], [$tocStyle], [$minDepth], [$maxDepth]);
-- ``$fontStyle``: See font style section
-- ``$tocStyle``: See available options below
-- ``$minDepth``: Minimum depth of header to be shown. Default 1
-- ``$maxDepth``: Maximum depth of header to be shown. Default 9
+- ``$fontStyle``. See font style section.
+- ``$tocStyle``. See available options below.
+- ``$minDepth``. Minimum depth of header to be shown. Default 1.
+- ``$maxDepth``. Maximum depth of header to be shown. Default 9.
Options for ``$tocStyle``:
-- ``tabLeader`` Fill type between the title text and the page number.
- Use the defined constants in PHPWord\_Style\_TOC.
-- ``tabPos`` The position of the tab where the page number appears in
- twips.
-- ``indent`` The indent factor of the titles in twips.
+- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\_Style\_TOC.
+- ``tabPos``. The position of the tab where the page number appears in twips.
+- ``indent``. The indent factor of the titles in twips.
Footnotes & endnotes
--------------------
@@ -468,17 +339,16 @@ redefine by ``addFontStyle`` method. Default value for this style is
Checkboxes
----------
-Checkbox elements can be added to sections or table cells by using
-``addCheckBox``.
+Checkbox elements can be added to sections or table cells by using ``addCheckBox``.
.. code-block:: php
$section->addCheckBox($name, $text, [$fontStyle], [$paragraphStyle])
-- ``$name`` Name of the check box.
-- ``$text`` Text following the check box
-- ``$fontStyle`` See "Font style" section.
-- ``$paragraphStyle`` See "Paragraph style" section.
+- ``$name``. Name of the check box.
+- ``$text``. Text to be displayed in the document.
+- ``$fontStyle``. See :ref:`font-style`.
+- ``$paragraphStyle``. See :ref:`paragraph-style`.
Textboxes
---------
@@ -502,11 +372,11 @@ Line elements can be added to sections by using ``addLine``.
Available line style attributes:
-- ``weight`` Line width in twips
-- ``color`` Defines the color of stroke
-- ``dash`` Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot
-- ``beginArrow`` Start type of arrow: block, open, classic, diamond, oval
-- ``endArrow`` End type of arrow: block, open, classic, diamond, ovel
-- ``width`` Line-object width in pt
-- ``height`` Line-object height in pt
-- ``flip`` Flip the line element: true, false
+- ``weight``. Line width in twips.
+- ``color``. Defines the color of stroke.
+- ``dash``. Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot.
+- ``beginArrow``. Start type of arrow: block, open, classic, diamond, oval.
+- ``endArrow``. End type of arrow: block, open, classic, diamond, oval.
+- ``width``. Line-object width in pt.
+- ``height``. Line-object height in pt.
+- ``flip``. Flip the line element: true, false.
\ No newline at end of file
diff --git a/docs/faq.rst b/docs/faq.rst
index 79652ae025..19fca1057f 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -3,11 +3,9 @@
Frequently asked questions
==========================
-How contribute to PHPWord ?
----------------------------
-
-- Improve the documentation (`Sphinx Format `__)
-
+How contribute to PHPWord?
+--------------------------
+- Improve the documentation (`Sphinx Format `__)
Is this the same with PHPWord that I found in CodePlex?
-------------------------------------------------------
diff --git a/docs/general.rst b/docs/general.rst
index 34d3af2477..27d0448abd 100644
--- a/docs/general.rst
+++ b/docs/general.rst
@@ -13,8 +13,7 @@ folder `__.
.. code-block:: php
`__.
$section = $phpWord->addSection();
// Adding Text element to the Section having font styled by default...
$section->addText(
- htmlspecialchars(
- '"Learn from yesterday, live for today, hope for tomorrow. '
- . 'The important thing is not to stop questioning." '
- . '(Albert Einstein)'
- )
+ '"Learn from yesterday, live for today, hope for tomorrow. '
+ . 'The important thing is not to stop questioning." '
+ . '(Albert Einstein)'
);
/*
@@ -41,11 +38,9 @@ folder `__.
// Adding Text element with font customized inline...
$section->addText(
- htmlspecialchars(
- '"Great achievement is usually born of great sacrifice, '
- . 'and is never the result of selfishness." '
- . '(Napoleon Hill)'
- ),
+ '"Great achievement is usually born of great sacrifice, '
+ . 'and is never the result of selfishness." '
+ . '(Napoleon Hill)',
array('name' => 'Tahoma', 'size' => 10)
);
@@ -56,11 +51,9 @@ folder `__.
array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
);
$section->addText(
- htmlspecialchars(
- '"The greatest accomplishment is not in never falling, '
- . 'but in rising again after you fall." '
- . '(Vince Lombardi)'
- ),
+ '"The greatest accomplishment is not in never falling, '
+ . 'but in rising again after you fall." '
+ . '(Vince Lombardi)',
$fontStyleName
);
@@ -69,9 +62,7 @@ folder `__.
$fontStyle->setBold(true);
$fontStyle->setName('Tahoma');
$fontStyle->setSize(13);
- $myTextElement = $section->addText(
- htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
- );
+ $myTextElement = $section->addText('"Believe you can and you\'re halfway there." (Theodor Roosevelt)');
$myTextElement->setFontStyle($fontStyle);
// Saving the document as OOXML file...
@@ -125,8 +116,22 @@ included with PHPWord.
\PhpOffice\PhpWord\Settings::setZipClass(\PhpOffice\PhpWord\Settings::PCLZIP);
+Output escaping
+~~~~~~~~~~~~~~~
+
+Writing documents of some formats, especially XML-based, requires correct output escaping.
+Without it your document may become broken when you put special characters like ampersand, quotes, and others in it.
+
+Escaping can be performed in two ways: outside of the library by a software developer and inside of the library by built-in mechanism.
+By default, the built-in mechanism is disabled for backward compatibility with versions prior to v0.13.0.
+To turn it on set ``outputEscapingEnabled`` option to ``true`` in your PHPWord configuration file or use the following instruction at runtime:
+
+.. code-block:: php
+
+ \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
+
Default font
-------------
+~~~~~~~~~~~~
By default, every text appears in Arial 10 point. You can alter the
default font by using the following two functions:
@@ -178,4 +183,3 @@ points to twips.
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
// 2 cm right margin
$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));
-
diff --git a/docs/installing.rst b/docs/installing.rst
index 6599590460..9593484a55 100644
--- a/docs/installing.rst
+++ b/docs/installing.rst
@@ -8,41 +8,40 @@ Requirements
Mandatory:
-- PHP 5.3+
-- PHP `Zip `__ extension
-- PHP `XML
- Parser `__
- extension
+- PHP 5.3.3+
+- `XML Parser `__ extension
+- `Zend\\Escaper `__ component
+- Zend\\Stdlib component
+- `Zend\\Validator `__ component
-Optional PHP extensions:
+Optional:
-- `GD `__
-- `XMLWriter `__
-- `XSL `__
+- `Zip `__ extension
+- `GD `__ extension
+- `XMLWriter `__ extension
+- `XSL `__ extension
+- `dompdf `__ library
Installation
------------
-There are two ways to install PHPWord, i.e. via
-`Composer `__ or manually by downloading the
-library.
+PHPWord is installed via `Composer `__.
+You just need to `add dependency `__ on PHPWord into your package.
-Using Composer
-~~~~~~~~~~~~~~
-
-To install via Composer, add the following lines to your
-``composer.json``:
+Example:
.. code-block:: json
{
"require": {
- "phpoffice/phpword": "dev-master"
+ "phpoffice/phpword": "v0.13.*"
}
}
If you are a developer or if you want to help us with testing then fetch the latest branch for developers.
-Notice: All contributions must be done against the developer branch.
+Notice: all contributions must be done against the developer branch.
+
+Example:
.. code-block:: json
@@ -53,28 +52,6 @@ Notice: All contributions must be done against the developer branch.
}
-Manual install
-~~~~~~~~~~~~~~
-
-To install manually, you change to the webserver directory of your file system .
-Then you have 2 possibilities.
-
- 1. `download PHPWord package from github `__.
- Extract the package and put the contents to your machine.
- 2. Alternatively you can use Git to install it:
- .. code-block:: console
-
- git clone https://github.com/PHPOffice/PHPWord.git
-
-To use the library, include ``src/PhpWord/Autoloader.php`` in your PHP script and
-invoke ``Autoloader::register``.
-
-.. code-block:: php
-
- require_once '/path/to/src/PhpWord/Autoloader.php';
- \PhpOffice\PhpWord\Autoloader::register();
-
-
Using samples
-------------
diff --git a/docs/intro.rst b/docs/intro.rst
index d2decd7c94..d1c791cf67 100644
--- a/docs/intro.rst
+++ b/docs/intro.rst
@@ -24,35 +24,34 @@ Documentation `__.
Features
--------
-- Set document properties, e.g. title, subject, and creator.
-- Create document sections with different settings, e.g.
- portrait/landscape, page size, and page numbering
-- Create header and footer for each sections
-- Set default font type, font size, and paragraph style
-- Use UTF-8 and East Asia fonts/characters
-- Define custom font styles (e.g. bold, italic, color) and paragraph
- styles (e.g. centered, multicolumns, spacing) either as named style
- or inline in text
-- Insert paragraphs, either as a simple text or complex one (a text
- run) that contains other elements
-- Insert titles (headers) and table of contents
-- Insert text breaks and page breaks
-- Insert right-to-left text
-- Insert and format images, either local, remote, or as page watermarks
-- Insert binary OLE Objects such as Excel or Visio
-- Insert and format table with customized properties for each rows
- (e.g. repeat as header row) and cells (e.g. background color,
- rowspan, colspan)
-- Insert list items as bulleted, numbered, or multilevel
-- Insert hyperlinks
-- Insert footnotes and endnotes
-- Insert drawing shapes (arc, curve, line, polyline, rect, oval)
-- Insert charts (pie, doughnut, bar, line, area, scatter, radar)
-- Insert form fields (textinput, checkbox, and dropdown)
-- Create document from templates
-- Use XSL 1.0 style sheets to transform main document part of OOXML
- template
-- ... and many more features on progress
+- Set document properties, e.g. title, subject, and creator.
+- Create document sections with different settings, e.g.
+ portrait/landscape, page size, and page numbering
+- Create header and footer for each sections
+- Set default font type, font size, and paragraph style
+- Use UTF-8 and East Asia fonts/characters
+- Define custom font styles (e.g. bold, italic, color) and paragraph
+ styles (e.g. centered, multicolumns, spacing) either as named style
+ or inline in text
+- Insert paragraphs, either as a simple text or complex one (a text
+ run) that contains other elements
+- Insert titles (headers) and table of contents
+- Insert text breaks and page breaks
+- Insert right-to-left text
+- Insert and format images, either local, remote, or as page watermarks
+- Insert binary OLE Objects such as Excel or Visio
+- Insert and format table with customized properties for each rows
+ (e.g. repeat as header row) and cells (e.g. background color,
+ rowspan, colspan)
+- Insert list items as bulleted, numbered, or multilevel
+- Insert hyperlinks
+- Insert footnotes and endnotes
+- Insert drawing shapes (arc, curve, line, polyline, rect, oval)
+- Insert charts (pie, doughnut, bar, line, area, scatter, radar)
+- Insert form fields (textinput, checkbox, and dropdown)
+- Create document from templates
+- Use XSL 1.0 style sheets to transform headers, main document part, and footers of an OOXML template
+- ... and many more features on progress
File formats
------------
@@ -63,7 +62,7 @@ Writers
~~~~~~~
+---------------------------+----------------------+--------+-------+-------+--------+-------+
-| Features | | DOCX | ODT | RTF | HTML | PDF |
+| Features | | OOXML | ODF | RTF | HTML | PDF |
+===========================+======================+========+=======+=======+========+=======+
| **Document Properties** | Standard | ✓ | ✓ | ✓ | ✓ | ✓ |
+---------------------------+----------------------+--------+-------+-------+--------+-------+
@@ -122,7 +121,7 @@ Readers
~~~~~~~
+---------------------------+----------------------+--------+-------+-------+-------+-------+
-| Features | | DOCX | DOC | ODT | RTF | HTML |
+| Features | | OOXML | DOC | ODF | RTF | HTML |
+===========================+======================+========+=======+=======+=======+=======+
| **Document Properties** | Standard | ✓ | | | | |
+---------------------------+----------------------+--------+-------+-------+-------+-------+
@@ -183,13 +182,13 @@ Contributing
We welcome everyone to contribute to PHPWord. Below are some of the
things that you can do to contribute.
-- Read `our contributing
- guide `__.
-- `Fork us `__ and `request
- a pull `__ to the
- `develop `__
- branch.
-- Submit `bug reports or feature
- requests `__ to GitHub.
-- Follow `@PHPWord `__ and
- `@PHPOffice `__ on Twitter.
+- Read `our contributing
+ guide `__.
+- `Fork us `__ and `request
+ a pull `__ to the
+ `develop `__
+ branch.
+- Submit `bug reports or feature
+ requests `__ to GitHub.
+- Follow `@PHPWord `__ and
+ `@PHPOffice `__ on Twitter.
diff --git a/docs/recipes.rst b/docs/recipes.rst
index 0be6b4e06a..5042cdedc6 100644
--- a/docs/recipes.rst
+++ b/docs/recipes.rst
@@ -6,8 +6,7 @@ Recipes
Create float left image
-----------------------
-Use absolute positioning relative to margin horizontally and to line
-vertically.
+Use absolute positioning relative to margin horizontally and to line vertically.
.. code-block:: php
diff --git a/docs/references.rst b/docs/references.rst
index 20aa1ed061..9c4e06a809 100644
--- a/docs/references.rst
+++ b/docs/references.rst
@@ -6,25 +6,23 @@ References
ISO/IEC 29500, Third edition, 2012-09-01
---------------------
-- `Part 1: Fundamentals and Markup Language Reference
- `__
-- `Part 2: Open Packaging Conventions
- `__
-- `Part 3: Markup Compatibility and Extensibility
- `__
-- `Part 4: Transitional Migration Features
- `__
+- `Part 1: Fundamentals and Markup Language Reference
+ `__
+- `Part 2: Open Packaging Conventions
+ `__
+- `Part 3: Markup Compatibility and Extensibility
+ `__
+- `Part 4: Transitional Migration Features
+ `__
Formal specifications
---------------------
-- `Oasis OpenDocument Standard Version
- 1.2 `__
-- `Rich Text Format (RTF) Specification, version
- 1.9.1 `__
+- `Oasis OpenDocument Standard Version 1.2 `__
+- `Rich Text Format (RTF) Specification, version 1.9.1 `__
Other resources
---------------
-- `DocumentFormat.OpenXml.Wordprocessing Namespace on
- MSDN `__
+- `DocumentFormat.OpenXml.Wordprocessing Namespace on
+ MSDN `__
diff --git a/docs/src/documentation.md b/docs/src/documentation.md
deleted file mode 100644
index 1a59e94230..0000000000
--- a/docs/src/documentation.md
+++ /dev/null
@@ -1,1134 +0,0 @@
-
-# Contents
-
-- [Introduction](#introduction)
- - [Features](#features)
- - [File formats](#file-formats)
-- [Installing/configuring](#installing-configuring)
- - [Requirements](#requirements)
- - [Installation](#installation)
- - [Using samples](#using-samples)
-- [General usage](#general-usage)
- - [Basic example](#basic-example)
- - [Settings](#settings)
- - [Default font](#default-font)
- - [Document properties](#document-properties)
- - [Measurement units](#measurement-units)
-- [Containers](#containers)
- - [Sections](#sections)
- - [Headers](#headers)
- - [Footers](#footers)
- - [Other containers](#other-containers)
-- [Elements](#elements)
- - [Texts](#texts)
- - [Breaks](#breaks)
- - [Lists](#lists)
- - [Tables](#tables)
- - [Images](#images)
- - [Objects](#objects)
- - [Table of contents](#table-of-contents)
- - [Footnotes & endnotes](#footnotes-endnotes)
- - [Checkboxes](#checkboxes)
- - [Textboxes](#textboxes)
- - [Fields](#fields)
- - [Lines](#lines)
- - [Shapes](#shapes)
- - [Charts](#charts)
- - [FormFields](#form-fields)
-- [Styles](#styles)
- - [Section](#section)
- - [Font](#font)
- - [Paragraph](#paragraph)
- - [Table](#table)
-- [Templates processing](#templates-processing)
-- [Writers & readers](#writers-readers)
- - [OOXML](#ooxml)
- - [OpenDocument](#opendocument)
- - [RTF](#rtf)
- - [HTML](#html)
- - [PDF](#pdf)
-- [Recipes](#recipes)
-- [Frequently asked questions](#frequently-asked-questions)
-- [References](#references)
-
-# Introduction
-
-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).
-
-PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading this Developers' Documentation and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/).
-
-## Features
-
-- Set document properties, e.g. title, subject, and creator.
-- Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering
-- Create header and footer for each sections
-- Set default font type, font size, and paragraph style
-- Use UTF-8 and East Asia fonts/characters
-- Define custom font styles (e.g. bold, italic, color) and paragraph styles (e.g. centered, multicolumns, spacing) either as named style or inline in text
-- Insert paragraphs, either as a simple text or complex one (a text run) that contains other elements
-- Insert titles (headers) and table of contents
-- Insert text breaks and page breaks
-- Insert and format images, either local, remote, or as page watermarks
-- Insert binary OLE Objects such as Excel or Visio
-- Insert and format table with customized properties for each rows (e.g. repeat as header row) and cells (e.g. background color, rowspan, colspan)
-- Insert list items as bulleted, numbered, or multilevel
-- Insert hyperlinks
-- Insert footnotes and endnotes
-- Insert drawing shapes (arc, curve, line, polyline, rect, oval)
-- Insert charts (pie, doughnut, bar, line, area, scatter, radar)
-- Insert form fields (textinput, checkbox, and dropdown)
-- Create document from templates
-- Use XSL 1.0 style sheets to transform main document part of OOXML template
-- ... and many more features on progress
-
-## File formats
-
-Below are the supported features for each file formats.
-
-### Writers
-
-| Features | | DOCX | ODT | RTF | HTML | PDF |
-|-------------------------|--------------------|------|-----|-----|------|-----|
-| **Document Properties** | Standard | ✓ | ✓ | ✓ | ✓ | |
-| | Custom | ✓ | ✓ | | | |
-| **Element Type** | Text | ✓ | ✓ | ✓ | ✓ | ✓ |
-| | Text Run | ✓ | ✓ | ✓ | ✓ | ✓ |
-| | Title | ✓ | ✓ | | ✓ | ✓ |
-| | Link | ✓ | ✓ | ✓ | ✓ | ✓ |
-| | Preserve Text | ✓ | | | | |
-| | Text Break | ✓ | ✓ | ✓ | ✓ | ✓ |
-| | Page Break | ✓ | | ✓ | | |
-| | List | ✓ | | | | |
-| | Table | ✓ | ✓ | ✓ | ✓ | ✓ |
-| | Image | ✓ | ✓ | ✓ | ✓ | |
-| | Object | ✓ | | | | |
-| | Watermark | ✓ | | | | |
-| | Table of Contents | ✓ | | | | |
-| | Header | ✓ | | | | |
-| | Footer | ✓ | | | | |
-| | Footnote | ✓ | | | ✓ | |
-| | Endnote | ✓ | | | ✓ | |
-| **Graphs** | 2D basic graphs | ✓ | | | | |
-| | 2D advanced graphs | | | | | |
-| | 3D graphs | ✓ | | | | |
-| **Math** | OMML support | | | | | |
-| | MathML support | | | | | |
-| **Bonus** | Encryption | | | | | |
-| | Protection | | | | | |
-
-### Readers
-
-| Features | | DOCX | ODT | RTF | HTML|
-|-------------------------|--------------------|------|-----|-----|-----|
-| **Document Properties** | Standard | ✓ | | | |
-| | Custom | ✓ | | | |
-| **Element Type** | Text | ✓ | ✓ | ✓ | ✓ |
-| | Text Run | ✓ | | | |
-| | Title | ✓ | ✓ | | |
-| | Link | ✓ | | | |
-| | Preserve Text | ✓ | | | |
-| | Text Break | ✓ | | | |
-| | Page Break | ✓ | | | |
-| | List | ✓ | ✓ | | ✓ |
-| | Table | ✓ | | | ✓ |
-| | Image | ✓ | | | |
-| | Object | | | | |
-| | Watermark | | | | |
-| | Table of Contents | | | | |
-| | Header | ✓ | | | |
-| | Footer | ✓ | | | |
-| | Footnote | ✓ | | | |
-| | Endnote | ✓ | | | |
-| **Graphs** | 2D basic graphs | | | | |
-| | 2D advanced graphs | | | | |
-| | 3D graphs | | | | |
-| **Math** | OMML support | | | | |
-| | MathML support | | | | |
-| **Bonus** | Encryption | | | | |
-| | Protection | | | | |
-
-## Contributing
-
-We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute:
-
-- Read [our contributing guide](https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md)
-- [Fork us](https://github.com/PHPOffice/PHPWord/fork) and [request a pull](https://github.com/PHPOffice/PHPWord/pulls) to the [develop](https://github.com/PHPOffice/PHPWord/tree/develop) branch
-- Submit [bug reports or feature requests](https://github.com/PHPOffice/PHPWord/issues) to GitHub
-- Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter
-
-# Installing/configuring
-
-## Requirements
-
-Mandatory:
-
-- PHP 5.3+
-- PHP [Zip](http://php.net/manual/en/book.zip.php) extension
-- PHP [XML Parser](http://www.php.net/manual/en/xml.installation.php) extension
-
-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)
-
-## Installation
-
-There are two ways to install PHPWord, i.e. via [Composer](http://getcomposer.org/) or manually by downloading the library.
-
-### Using Composer
-
-To install via Composer, add the following lines to your `composer.json`:
-
-```json
-{
- "require": {
- "phpoffice/phpword": "dev-master"
- }
-}
-```
-
-### Manual install
-
-To install manually, [download PHPWord package from github](https://github.com/PHPOffice/PHPWord/archive/master.zip). Extract the package and put the contents to your machine. To use the library, include `src/PhpWord/Autoloader.php` in your script and invoke `Autoloader::register`.
-
-```php
-require_once '/path/to/src/PhpWord/Autoloader.php';
-\PhpOffice\PhpWord\Autoloader::register();
-```
-
-## Using samples
-
-After installation, you can browse and use the samples that we've provided, either by command line or using browser. If you can access your PHPWord library folder using browser, point your browser to the `samples` folder, e.g. `http://localhost/PhpWord/samples/`.
-
-# General usage
-
-## Basic example
-
-The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](https://github.com/PHPOffice/PHPWord/tree/master/samples/).
-
-```php
-addSection();
-// Adding Text element to the Section having font styled by default...
-$section->addText(
- htmlspecialchars(
- '"Learn from yesterday, live for today, hope for tomorrow. '
- . 'The important thing is not to stop questioning." '
- . '(Albert Einstein)'
- )
-);
-
-/*
- * Note: it's possible to customize font style of the Text element you add in three ways:
- * - inline;
- * - using named font style (new font style object will be implicitly created);
- * - using explicitly created font style object.
- */
-
-// Adding Text element with font customized inline...
-$section->addText(
- htmlspecialchars(
- '"Great achievement is usually born of great sacrifice, '
- . 'and is never the result of selfishness." '
- . '(Napoleon Hill)'
- ),
- array('name' => 'Tahoma', 'size' => 10)
-);
-
-// Adding Text element with font customized using named font style...
-$fontStyleName = 'oneUserDefinedStyle';
-$phpWord->addFontStyle(
- $fontStyleName,
- array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
-);
-$section->addText(
- htmlspecialchars(
- '"The greatest accomplishment is not in never falling, '
- . 'but in rising again after you fall." '
- . '(Vince Lombardi)'
- ),
- $fontStyleName
-);
-
-// Adding Text element with font customized using explicitly created font style object...
-$fontStyle = new \PhpOffice\PhpWord\Style\Font();
-$fontStyle->setBold(true);
-$fontStyle->setName('Tahoma');
-$fontStyle->setSize(13);
-$myTextElement = $section->addText(
- htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
-);
-$myTextElement->setFontStyle($fontStyle);
-
-// Saving the document as OOXML file...
-$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
-$objWriter->save('helloWorld.docx');
-
-// Saving the document as ODF file...
-$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
-$objWriter->save('helloWorld.odt');
-
-// Saving the document as HTML file...
-$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
-$objWriter->save('helloWorld.html');
-
-/* Note: we skip RTF, because it's not XML-based and requires a different example. */
-/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
-```
-
-## Settings
-
-The `PhpOffice\PhpWord\Settings` class provides some options that will affect the behavior of PHPWord. Below are the options.
-
-### XML Writer compatibility
-
-This option sets [XMLWriter::setIndent](http://www.php.net/manual/en/function.xmlwriter-set-indent.php) and [XMLWriter::setIndentString](http://www.php.net/manual/en/function.xmlwriter-set-indent-string.php). The default value of this option is `true` (compatible), which is [required for OpenOffice](https://github.com/PHPOffice/PHPWord/issues/103) to render OOXML document correctly. You can set this option to `false` during development to make the resulting XML file easier to read.
-
-```php
-\PhpOffice\PhpWord\Settings::setCompatibility(false);
-```
-
-### Zip class
-
-By default, PHPWord uses PHP [ZipArchive](http://php.net/manual/en/book.zip.php) to read or write ZIP compressed archive and the files inside them. If you can't have ZipArchive installed on your server, you can use pure PHP library alternative, [PCLZip](http://www.phpconcept.net/pclzip/), which included with PHPWord.
-
-```php
-\PhpOffice\PhpWord\Settings::setZipClass(\PhpOffice\PhpWord\Settings::PCLZIP);
-```
-
-## Default font
-
-By default, every text appears in Arial 10 point. You can alter the default font by using the following two functions:
-
-```php
-$phpWord->setDefaultFontName('Times New Roman');
-$phpWord->setDefaultFontSize(12);
-```
-
-## Document information
-
-You can set the document information such as title, creator, and company name. Use the following functions:
-
-```php
-$properties = $phpWord->getDocInfo();
-$properties->setCreator('My name');
-$properties->setCompany('My factory');
-$properties->setTitle('My title');
-$properties->setDescription('My description');
-$properties->setCategory('My category');
-$properties->setLastModifiedBy('My name');
-$properties->setCreated(mktime(0, 0, 0, 3, 12, 2014));
-$properties->setModified(mktime(0, 0, 0, 3, 14, 2014));
-$properties->setSubject('My subject');
-$properties->setKeywords('my, key, word');
-```
-
-## Measurement units
-
-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' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(6))
-);
-
-$section = $phpWord->addSection();
-$sectionStyle = $section->getStyle();
-// half inch left margin
-$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
-// 2 cm right margin
-$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));
-```
-
-# Containers
-
-Containers are objects where you can put elements (texts, lists, tables, etc). There are 3 main containers, i.e. sections, headers, and footers. There are 3 elements that can also act as containers, i.e. textruns, table cells, and footnotes.
-
-## Sections
-
-Every visible element in word is placed inside of a section. To create a section, use the following code:
-
-```php
-$section = $phpWord->addSection($sectionStyle);
-```
-
-The `$sectionStyle` is an optional associative array that sets the section. Example:
-
-```php
-$sectionStyle = array(
- 'orientation' => 'landscape',
- 'marginTop' => 600,
- 'colsNum' => 2,
-);
-```
-
-
-### Page number
-
-You can change a section page number by using the `pageNumberingStart` style of the section.
-
-```php
-// Method 1
-$section = $phpWord->addSection(array('pageNumberingStart' => 1));
-
-// Method 2
-$section = $phpWord->addSection();
-$section->getStyle()->setPageNumberingStart(1);
-```
-
-### Multicolumn
-
-You can change a section layout to multicolumn (like in a newspaper) by using the `breakType` and `colsNum` style of the section.
-
-```php
-// Method 1
-$section = $phpWord->addSection(array('breakType' => 'continuous', 'colsNum' => 2));
-
-// Method 2
-$section = $phpWord->addSection();
-$section->getStyle()->setBreakType('continuous');
-$section->getStyle()->setColsNum(2);
-```
-
-### Line numbering
-
-You can apply line numbering to a section by using the `lineNumbering` style of the section.
-
-```php
-// Method 1
-$section = $phpWord->addSection(array('lineNumbering' => array()));
-
-// Method 2
-$section = $phpWord->addSection();
-$section->getStyle()->setLineNumbering(array());
-```
-
-Below are the properties of the line numbering style.
-
-- `start` Line numbering starting value
-- `increment` Line number increments
-- `distance` Distance between text and line numbering in twip
-- `restart` Line numbering restart setting continuous|newPage|newSection
-
-## Headers
-
-Each section can have its own header reference. To create a header use the `addHeader` method:
-
-```php
-$header = $section->addHeader();
-```
-
-Be sure to save the result in a local object. You can use all elements that are available for the footer. See "Footer" section for detail. Additionally, only inside of the header reference you can add watermarks or background pictures. See "Watermarks" section.
-
-## Footers
-
-Each section can have its own footer reference. To create a footer, use the `addFooter` method:
-
-```php
-$footer = $section->addFooter();
-```
-
-Be sure to save the result in a local object to add elements to a footer. You can add the following elements to footers:
-
-- Texts `addText` and `createTextrun`
-- Text breaks
-- Images
-- Tables
-- Preserve text
-
-See the "Elements" section for the detail of each elements.
-
-## Other containers
-
-Textruns, table cells, and footnotes are elements that can also act as containers. See the corresponding "Elements" section for the detail of each elements.
-
-# Elements
-
-Below are the matrix of element availability in each container. The column shows the containers while the rows lists the elements.
-
-| Num | Element | Section | Header | Footer | Cell | Text Run | Footnote |
-|-----|---------------|---------|--------|--------|------|----------|----------|
-| 1 | Text | v | v | v | v | v | v |
-| 2 | Text Run | v | v | v | v | - | - |
-| 3 | Link | v | v | v | v | v | v |
-| 4 | Title | v | ? | ? | ? | ? | ? |
-| 5 | Preserve Text | ? | v | v | v* | - | - |
-| 6 | Text Break | v | v | v | v | v | v |
-| 7 | Page Break | v | - | - | - | - | - |
-| 8 | List | v | v | v | v | - | - |
-| 9 | Table | v | v | v | v | - | - |
-| 10 | Image | v | v | v | v | v | v |
-| 11 | Watermark | - | v | - | - | - | - |
-| 12 | Object | v | v | v | v | v | v |
-| 13 | TOC | v | - | - | - | - | - |
-| 14 | Footnote | v | - | - | v** | v** | - |
-| 15 | Endnote | v | - | - | v** | v** | - |
-| 16 | CheckBox | v | v | v | v | - | - |
-| 17 | TextBox | v | v | v | v | - | - |
-| 18 | Field | v | v | v | v | v | v |
-| 19 | Line | v | v | v | v | v | v |
-| 20 | Shape | v | v | v | v | v | v |
-| 21 | Chart | v | - | - | - | - | - |
-| 22 | Form Fields | v | v | v | v | v | v |
-
-Legend:
-
-- `v` Available
-- `v*` Available only when inside header/footer
-- `v**` Available only when inside section
-- `-` Not available
-- `?` Should be available
-
-## Texts
-
-Text can be added by using `addText` and `addTextRun` method. `addText` is used for creating simple paragraphs that only contain texts with the same style. `addTextRun` 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. The syntaxes are as follow:
-
-```php
-$section->addText($text, [$fontStyle], [$paragraphStyle]);
-$textrun = $section->addTextRun([$paragraphStyle]);
-```
-
-You can use the `$fontStyle` and `$paragraphStyle` variable to define text formatting. There are 2 options to style the inserted text elements, i.e. inline style by using array or defined style by adding style definition.
-
-Inline style examples:
-
-```php
-$fontStyle = array('name' => 'Times New Roman', 'size' => 9);
-$paragraphStyle = array('align' => 'both');
-$section->addText('I am simple paragraph', $fontStyle, $paragraphStyle);
-
-$textrun = $section->addTextRun();
-$textrun->addText('I am bold', array('bold' => true));
-$textrun->addText('I am italic', array('italic' => true));
-$textrun->addText('I am colored', array('color' => 'AACC00'));
-```
-
-Defined style examples:
-
-```php
-$fontStyle = array('color' => '006699', 'size' => 18, 'bold' => true);
-$phpWord->addFontStyle('fStyle', $fontStyle);
-$text = $section->addText('Hello world!', 'fStyle');
-
-$paragraphStyle = array('align' => 'center');
-$phpWord->addParagraphStyle('pStyle', $paragraphStyle);
-$text = $section->addText('Hello world!', 'pStyle');
-```
-
-### Titles
-
-If you want to structure your document or build table of contents, you need titles or headings. To add a title to the document, use the `addTitleStyle` and `addTitle` method.
-
-```php
-$phpWord->addTitleStyle($depth, [$fontStyle], [$paragraphStyle]);
-$section->addTitle($text, [$depth]);
-```
-
-Its necessary to add a title style to your document because otherwise the title won't be detected as a real title.
-
-### Links
-
-You can add Hyperlinks to the document by using the function addLink:
-
-```php
-$section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle]);
-```
-
-- `$linkSrc` The URL of the link.
-- `$linkName` Placeholder of the URL that appears in the document.
-- `$fontStyle` See "Font style" section.
-- `$paragraphStyle` See "Paragraph style" section.
-
-### Preserve texts
-
-The `addPreserveText` method is used to add a page number or page count to headers or footers.
-
-```php
-$footer->addPreserveText('Page {PAGE} of {NUMPAGES}.');
-```
-
-## Breaks
-
-### Text breaks
-
-Text breaks are empty new lines. To add text breaks, use the following syntax. All paramaters are optional.
-
-```php
-$section->addTextBreak([$breakCount], [$fontStyle], [$paragraphStyle]);
-```
-
-- `$breakCount` How many lines
-- `$fontStyle` See "Font style" section.
-- `$paragraphStyle` See "Paragraph style" section.
-
-### Page breaks
-
-There are two ways to insert a page breaks, using the `addPageBreak` method or using the `pageBreakBefore` style of paragraph.
-
-```php
-$section->addPageBreak();
-```
-
-## Lists
-
-To add a list item use the function `addListItem`.
-
-Basic usage:
-
-```php
-$section->addListItem($text, [$depth], [$fontStyle], [$listStyle], [$paragraphStyle]);
-```
-
-Parameters:
-
-- `$text` Text that appears in the document.
-- `$depth` Depth of list item.
-- `$fontStyle` See "Font style" section.
-- `$listStyle` List style of the current element TYPE\_NUMBER, TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\_Style\_ListItem.
-- `$paragraphStyle` See "Paragraph style" section.
-
-Advanced usage:
-
-You can also create your own numbering style by changing the `$listStyle` parameter with the name of your numbering style.
-
-```php
-$phpWord->addNumberingStyle(
- 'multilevel',
- array('type' => 'multilevel', 'levels' => array(
- array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360),
- array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
- )
- )
-);
-$section->addListItem('List Item I', 0, null, 'multilevel');
-$section->addListItem('List Item I.a', 1, null, 'multilevel');
-$section->addListItem('List Item I.b', 1, null, 'multilevel');
-$section->addListItem('List Item II', 0, null, 'multilevel');
-```
-
-## Tables
-
-To add tables, rows, and cells, use the `addTable`, `addRow`, and `addCell` methods:
-
-```php
-$table = $section->addTable([$tableStyle]);
-$table->addRow([$height], [$rowStyle]);
-$cell = $table->addCell($width, [$cellStyle]);
-```
-
-Table style can be defined with `addTableStyle`:
-
-```php
-$tableStyle = array(
- 'borderColor' => '006699',
- 'borderSize' => 6,
- 'cellMargin' => 50
-);
-$firstRowStyle = array('bgColor' => '66BBFF');
-$phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle);
-$table = $section->addTable('myTable');
-```
-
-### Cell span
-
-You can span a cell on multiple columns by using `gridSpan` or multiple rows by using `vMerge`.
-
-```php
-$cell = $table->addCell(200);
-$cell->getStyle()->setGridSpan(5);
-```
-
-See `Sample_09_Tables.php` for more code sample.
-
-## Images
-
-To add an image, use the `addImage` method to sections, headers, footers, textruns, or table cells.
-
-```php
-$section->addImage($src, [$style]);
-```
-
-- source String path to a local image or URL of a remote image
-- styles Array fo styles for the image. See below.
-
-Examples:
-
-```php
-$section = $phpWord->addSection();
-$section->addImage(
- 'mars.jpg',
- array(
- 'width' => 100,
- 'height' => 100,
- 'marginTop' => -1,
- 'marginLeft' => -1,
- 'wrappingStyle' => 'behind'
- )
-);
-$footer = $section->addFooter();
-$footer->addImage('http://example.com/image.php');
-$textrun = $section->addTextRun();
-$textrun->addImage('http://php.net/logo.jpg');
-```
-
-### Watermarks
-
-To add a watermark (or page background image), your section needs a header reference. After creating a header, you can use the `addWatermark` method to add a watermark.
-
-```php
-$section = $phpWord->addSection();
-$header = $section->addHeader();
-$header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55));
-```
-
-## Objects
-
-You can add OLE embeddings, such as Excel spreadsheets or PowerPoint presentations to the document by using `addObject` method.
-
-```php
-$section->addObject($src, [$style]);
-```
-
-## Table of contents
-
-To add a table of contents (TOC), you can use the `addTOC` method. Your TOC can only be generated if you have add at least one title (See "Titles").
-
-```php
-$section->addTOC([$fontStyle], [$tocStyle], [$minDepth], [$maxDepth]);
-```
-
-- `$fontStyle`: See font style section
-- `$tocStyle`: See available options below
-- `$minDepth`: Minimum depth of header to be shown. Default 1
-- `$maxDepth`: Maximum depth of header to be shown. Default 9
-
-Options for `$tocStyle`:
-
-- `tabLeader` Fill type between the title text and the page number. Use the defined constants in PHPWord\_Style\_TOC.
-- `tabPos` The position of the tab where the page number appears in twips.
-- `indent` The indent factor of the titles in twips.
-
-## Footnotes & endnotes
-
-You can create footnotes with `addFootnote` and endnotes with `addEndnote` in texts or textruns, but it's recommended to use textrun to have better layout. You can use `addText`, `addLink`, `addTextBreak`, `addImage`, `addObject` on footnotes and endnotes.
-
-On textrun:
-
-```php
-$textrun = $section->addTextRun();
-$textrun->addText('Lead text.');
-$footnote = $textrun->addFootnote();
-$footnote->addText('Footnote text can have ');
-$footnote->addLink('http://test.com', 'links');
-$footnote->addText('.');
-$footnote->addTextBreak();
-$footnote->addText('And text break.');
-$textrun->addText('Trailing text.');
-$endnote = $textrun->addEndnote();
-$endnote->addText('Endnote put at the end');
-```
-
-On text:
-
-```php
-$section->addText('Lead text.');
-$footnote = $section->addFootnote();
-$footnote->addText('Footnote text.');
-```
-
-The footnote reference number will be displayed with decimal number starting from 1. This number use `FooterReference` style which you can redefine by `addFontStyle` method. Default value for this style is `array('superScript' => true)`;
-
-## Checkboxes
-
-Checkbox elements can be added to sections or table cells by using `addCheckBox`.
-
-```php
-$section->addCheckBox($name, $text, [$fontStyle], [$paragraphStyle])
-```
-
-- `$name` Name of the check box.
-- `$text` Text following the check box
-- `$fontStyle` See "Font style" section.
-- `$paragraphStyle` See "Paragraph style" section.
-
-## Textboxes
-
-To be completed.
-
-## Fields
-
-To be completed.
-
-## Lines
-
-To be completed.
-
-## Shapes
-
-To be completed.
-
-## Charts
-
-To be completed.
-
-## Form fields
-
-To be completed.
-
-# Styles
-
-## Section
-
-Below are the available styles 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
-- `gutter` Page gutter spacing
-- `colsNum` Number of columns
-- `colsSpace` Spacing between columns
-- `breakType` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage)
-
-The following two styles are automatically set by the use of the `orientation` style. You can alter them but that's not recommended.
-
-- `pageSizeW` Page width in twips
-- `pageSizeH` Page height in twips
-
-## Font
-
-Available font styles:
-
-- `name` Font name, e.g. *Arial*
-- `size` Font size, e.g. *20*, *22*,
-- `hint` Font content type, *default*, *eastAsia*, or *cs*
-- `bold` Bold, *true* or *false*
-- `italic` Italic, *true* or *false*
-- `superScript` Superscript, *true* or *false*
-- `subScript` Subscript, *true* or *false*
-- `underline` Underline, *dash*, *dotted*, etc.
-- `strikethrough` Strikethrough, *true* or *false*
-- `doubleStrikethrough` Double strikethrough, *true* or *false*
-- `color` Font color, e.g. *FF0000*
-- `fgColor` Font highlight color, e.g. *yellow*, *green*, *blue*
-- `bgColor` Font background color, e.g. *FF0000*
-- `smallCaps` Small caps, *true* or *false*
-- `allCaps` All caps, *true* or *false*
-
-## Paragraph
-
-Available paragraph styles:
-
-- `align` Paragraph alignment, *left*, *right* or *center*
-- `spaceBefore` Space before paragraph
-- `spaceAfter` Space after paragraph
-- `indent` Indent by how much
-- `hanging` Hanging by how much
-- `basedOn` Parent style
-- `next` Style for next paragraph
-- `widowControl` Allow first/last line to display on a separate page, *true* or *false*
-- `keepNext` Keep paragraph with next paragraph, *true* or *false*
-- `keepLines` Keep all lines on one page, *true* or *false*
-- `pageBreakBefore` Start paragraph on next page, *true* or *false*
-- `lineHeight` text line height, e.g. *1.0*, *1.5*, ect...
-- `tabs` Set of custom tab stops
-
-## Table
-
-Table styles:
-
-- `width` Table width in percent
-- `bgColor` Background color, e.g. '9966CC'
-- `border(Top|Right|Bottom|Left)Size` Border size in twips
-- `border(Top|Right|Bottom|Left)Color` Border color, e.g. '9966CC'
-- `cellMargin(Top|Right|Bottom|Left)` Cell margin in twips
-
-Row styles:
-
-- `tblHeader` Repeat table row on every new page, *true* or *false*
-- `cantSplit` Table row cannot break across pages, *true* or *false*
-- `exactHeight` Row height is exact or at least
-
-Cell styles:
-
-- `width` Cell width in twips
-- `valign` Vertical alignment, *top*, *center*, *both*, *bottom*
-- `textDirection` Direction of text
-- `bgColor` Background color, e.g. '9966CC'
-- `border(Top|Right|Bottom|Left)Size` Border size in twips
-- `border(Top|Right|Bottom|Left)Color` Border color, e.g. '9966CC'
-- `gridSpan` Number of columns spanned
-- `vMerge` *restart* or *continue*
-
-## Image
-
-Available image styles:
-
-- `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` Wrapping style, *inline*, *square*, *tight*, *behind*, or *infront*
-
-## Numbering level
-
-- `start` Starting value
-- `format` Numbering format bullet|decimal|upperRoman|lowerRoman|upperLetter|lowerLetter
-- `restart` Restart numbering level symbol
-- `suffix` Content between numbering symbol and paragraph text tab|space|nothing
-- `text` Numbering level text e.g. %1 for nonbullet or bullet character
-- `align` Numbering symbol align left|center|right|both
-- `left` See paragraph style
-- `hanging` See paragraph style
-- `tabPos` See paragraph style
-- `font` Font name
-- `hint` See font style
-
-# Templates processing
-
-You can create a .docx document template with included search-patterns which can be replaced by any value you wish. Only single-line values can be replaced.
-
-To deal with a template file, use `new TemplateProcessor` statement. After TemplateProcessor instance creation the document template is copied into the temporary directory. Then you can use `TemplateProcessor::setValue` method to change the value of a search pattern. The search-pattern model is: `${search-pattern}`.
-
-Example:
-
-```php
-$templateProcessor = new TemplateProcessor('Template.docx');
-$templateProcessor->setValue('Name', 'Somebody someone');
-$templateProcessor->setValue('Street', 'Coming-Undone-Street 32');
-```
-
-It is not possible to directly add new OOXML elements to the template file being processed, but it is possible to transform main document part of the template using XSLT (see `TemplateProcessor::applyXslStyleSheet`).
-
-See `Sample_07_TemplateCloneRow.php` for example on how to create multirow from a single row in a template by using `TemplateProcessor::cloneRow`.
-
-See `Sample_23_TemplateBlock.php` for example on how to clone a block of text using `TemplateProcessor::cloneBlock` and delete a block of text using `TemplateProcessor::deleteBlock`.
-
-# Writers & readers
-
-## OOXML
-
-The package of OOXML document consists of the following files.
-
-- _rels/
- - .rels
-- docProps/
- - app.xml
- - core.xml
- - custom.xml
-- word/
- - rels/
- - document.rels.xml
- - media/
- - theme/
- - theme1.xml
- - document.xml
- - fontTable.xml
- - numbering.xml
- - settings.xml
- - styles.xml
- - webSettings.xml
-- [Content_Types].xml
-
-## OpenDocument
-
-### Package
-
-The package of OpenDocument document consists of the following files.
-
-- META-INF/
- - manifest.xml
-- Pictures/
-- content.xml
-- meta.xml
-- styles.xml
-
-### content.xml
-
-The structure of `content.xml` is described below.
-
-- office:document-content
- - office:font-facedecls
- - office:automatic-styles
- - office:body
- - office:text
- - draw:*
- - office:forms
- - table:table
- - text:list
- - text:numbered-paragraph
- - text:p
- - text:table-of-contents
- - text:section
- - office:chart
- - office:image
- - office:drawing
-
-### styles.xml
-
-The structure of `styles.xml` is described below.
-
-- office:document-styles
- - office:styles
- - office:automatic-styles
- - office:master-styles
- - office:master-page
-
-## RTF
-
-To be completed.
-
-## HTML
-
-To be completed.
-
-## PDF
-
-To be completed.
-
-# Recipes
-
-## Create float left image
-
-Use absolute positioning relative to margin horizontally and to line vertically.
-
-```php
-$imageStyle = array(
- 'width' => 40,
- 'height' => 40
- 'wrappingStyle' => 'square',
- 'positioning' => 'absolute',
- 'posHorizontalRel' => 'margin',
- 'posVerticalRel' => 'line',
-);
-$textrun->addImage('resources/_earth.jpg', $imageStyle);
-$textrun->addText($lipsumText);
-```
-
-## Download the produced file automatically
-
-Use `php://output` as the filename.
-
-```php
-$phpWord = new \PhpOffice\PhpWord\PhpWord();
-$section = $phpWord->createSection();
-$section->addText('Hello World!');
-$file = 'HelloWorld.docx';
-header("Content-Description: File Transfer");
-header('Content-Disposition: attachment; filename="' . $file . '"');
-header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
-header('Content-Transfer-Encoding: binary');
-header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-header('Expires: 0');
-$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
-$xmlWriter->save("php://output");
-```
-
-## Create numbered headings
-
-Define a numbering style and title styles, and match the two styles (with `pStyle` and `numStyle`) like below.
-
-```php
-$phpWord->addNumberingStyle(
- 'hNum',
- array('type' => 'multilevel', 'levels' => array(
- array('pStyle' => 'Heading1', 'format' => 'decimal', 'text' => '%1'),
- array('pStyle' => 'Heading2', 'format' => 'decimal', 'text' => '%1.%2'),
- array('pStyle' => 'Heading3', 'format' => 'decimal', 'text' => '%1.%2.%3'),
- )
- )
-);
-$phpWord->addTitleStyle(1, array('size' => 16), array('numStyle' => 'hNum', 'numLevel' => 0));
-$phpWord->addTitleStyle(2, array('size' => 14), array('numStyle' => 'hNum', 'numLevel' => 1));
-$phpWord->addTitleStyle(3, array('size' => 12), array('numStyle' => 'hNum', 'numLevel' => 2));
-
-$section->addTitle('Heading 1', 1);
-$section->addTitle('Heading 2', 2);
-$section->addTitle('Heading 3', 3);
-```
-
-## Add a link within a title
-
-Apply 'HeadingN' paragraph style to TextRun or Link. Sample code:
-
-```php
-$phpWord = new \PhpOffice\PhpWord\PhpWord();
-$phpWord->addTitleStyle(1, array('size' => 16, 'bold' => true));
-$phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true));
-$phpWord->addFontStyle('Link', array('color' => '0000FF', 'underline' => 'single'));
-
-$section = $phpWord->addSection();
-
-// Textrun
-$textrun = $section->addTextRun('Heading1');
-$textrun->addText('The ');
-$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord', 'Link');
-
-// Link
-$section->addLink('https://github.com/', 'GitHub', 'Link', 'Heading2');
-```
-
-## Remove [Compatibility Mode] text in the MS Word title bar
-
-Use the `Metadata\Compatibility\setOoxmlVersion(n)` method with `n` is the version of Office (14 = Office 2010, 15 = Office 2013).
-
-```php
-$phpWord->getCompatibility()->setOoxmlVersion(15);
-```
-
-# Frequently asked questions
-
-## Is this the same with PHPWord that I found in CodePlex?
-
-No. This one is much better with tons of new features that you can’t find in PHPWord 0.6.3. The development in CodePlex is halted and switched to GitHub to allow more participation from the crowd. The more the merrier, right?
-
-## I’ve been running PHPWord from CodePlex flawlessly, but I can’t use the latest PHPWord from GitHub. Why?
-
-PHPWord requires PHP 5.3+ since 0.8, while PHPWord 0.6.3 from CodePlex can run with PHP 5.2. There’s a lot of new features that we can get from PHP 5.3 and it’s been around since 2009! You should upgrade your PHP version to use PHPWord 0.8+.
-
-# References
-
-## ISO/IEC 29500, Third edition, 2012-09-01
-
-- [Part 1: Fundamentals and Markup Language Reference](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061750_ISO_IEC_29500-1_2012.zip)
-- [Part 2: Open Packaging Conventions](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061796_ISO_IEC_29500-2_2012.zip)
-- [Part 3: Markup Compatibility and Extensibility](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061797_ISO_IEC_29500-3_2012.zip)
-- [Part 4: Transitional Migration Features](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061798_ISO_IEC_29500-4_2012.zip)
-
-## Formal specifications
-
-- [Oasis OpenDocument Standard Version 1.2](http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html)
-- [Rich Text Format (RTF) Specification, version 1.9.1](http://www.microsoft.com/en-us/download/details.aspx?id=10725)
-
-## Other resources
-
-- [DocumentFormat.OpenXml.Wordprocessing Namespace on MSDN](http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing%28v=office.14%29.aspx)
diff --git a/docs/styles.rst b/docs/styles.rst
index f4c1e8ebd4..b71059a69a 100644
--- a/docs/styles.rst
+++ b/docs/styles.rst
@@ -3,132 +3,143 @@
Styles
======
+.. _section-style:
+
Section
-------
-Below are the available styles for section:
-
-- ``pageSizeW`` Page width in twips (the default is 11906/A4 size)
-- ``pageSizeH`` Page height in twips (the default is 16838/A4 size)
-- ``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
-- ``gutter`` Page gutter spacing
-- ``colsNum`` Number of columns
-- ``colsSpace`` Spacing between columns
-- ``breakType`` Section break type (nextPage, nextColumn, continuous,
- evenPage, oddPage)
+Available Section style options:
+
+- ``borderBottomColor``. Border bottom color.
+- ``borderBottomSize``. Border bottom size (in twips).
+- ``borderLeftColor``. Border left color.
+- ``borderLeftSize``. Border left size (in twips).
+- ``borderRightColor``. Border right color.
+- ``borderRightSize``. Border right size (in twips).
+- ``borderTopColor``. Border top color.
+- ``borderTopSize``. Border top size (in twips).
+- ``breakType``. Section break type (nextPage, nextColumn, continuous, evenPage, oddPage).
+- ``colsNum``. Number of columns.
+- ``colsSpace``. Spacing between columns.
+- ``footerHeight``. Spacing to bottom of footer.
+- ``gutter``. Page gutter spacing.
+- ``headerHeight``. Spacing to top of header.
+- ``marginTop``. Page margin top (in twips).
+- ``marginLeft``. Page margin left (in twips).
+- ``marginRight``. Page margin right (in twips).
+- ``marginBottom``. Page margin bottom (in twips).
+- ``orientation``. Page orientation (``portrait``, which is default, or ``landscape``).
+- ``pageSizeH``. Page height (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
+- ``pageSizeW``. Page width (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
+
+.. _font-style:
Font
----
-Available font styles:
-
-- ``name`` Font name, e.g. *Arial*
-- ``size`` Font size, e.g. *20*, *22*,
-- ``hint`` Font content type, *default*, *eastAsia*, or *cs*
-- ``bold`` Bold, *true* or *false*
-- ``italic`` Italic, *true* or *false*
-- ``superScript`` Superscript, *true* or *false*
-- ``subScript`` Subscript, *true* or *false*
-- ``underline`` Underline, *dash*, *dotted*, etc.
-- ``strikethrough`` Strikethrough, *true* or *false*
-- ``doubleStrikethrough`` Double strikethrough, *true* or *false*
-- ``color`` Font color, e.g. *FF0000*
-- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue*
-- ``bgColor`` Font background color, e.g. *FF0000*
-- ``smallCaps`` Small caps, *true* or *false*
-- ``allCaps`` All caps, *true* or *false*
-- ``rtl`` Right to Left language, *true* or *false*
+Available Font style options:
+
+- ``allCaps``. All caps, *true* or *false*.
+- ``bgColor``. Font background color, e.g. *FF0000*.
+- ``bold``. Bold, *true* or *false*.
+- ``color``. Font color, e.g. *FF0000*.
+- ``doubleStrikethrough``. Double strikethrough, *true* or *false*.
+- ``fgColor``. Font highlight color, e.g. *yellow*, *green*, *blue*.
+- ``hint``. Font content type, *default*, *eastAsia*, or *cs*.
+- ``italic``. Italic, *true* or *false*.
+- ``name``. Font name, e.g. *Arial*.
+- ``rtl``. Right to Left language, *true* or *false*.
+- ``size``. Font size, e.g. *20*, *22*.
+- ``smallCaps``. Small caps, *true* or *false*.
+- ``strikethrough``. Strikethrough, *true* or *false*.
+- ``subScript``. Subscript, *true* or *false*.
+- ``superScript``. Superscript, *true* or *false*.
+- ``underline``. Underline, *dash*, *dotted*, etc.
+
+.. _paragraph-style:
Paragraph
---------
-Available paragraph styles:
-
-- ``align`` Paragraph alignment, *left*, *right* or *center*
-- ``spaceBefore`` Space before paragraph
-- ``spaceAfter`` Space after paragraph
-- ``indent`` Indent by how much
-- ``hanging`` Hanging by how much
-- ``basedOn`` Parent style
-- ``next`` Style for next paragraph
-- ``widowControl`` Allow first/last line to display on a separate page,
- *true* or *false*
-- ``keepNext`` Keep paragraph with next paragraph, *true* or *false*
-- ``keepLines`` Keep all lines on one page, *true* or *false*
-- ``pageBreakBefore`` Start paragraph on next page, *true* or *false*
-- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect...
-- ``tabs`` Set of custom tab stops
+Available Paragraph style options:
+
+- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
+See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
+- ``basedOn``. Parent style.
+- ``hanging``. Hanging by how much.
+- ``indent``. Indent by how much.
+- ``keepLines``. Keep all lines on one page, *true* or *false*.
+- ``keepNext``. Keep paragraph with next paragraph, *true* or *false*.
+- ``lineHeight``. Text line height, e.g. *1.0*, *1.5*, etc.
+- ``next``. Style for next paragraph.
+- ``pageBreakBefore``. Start paragraph on next page, *true* or *false*.
+- ``spaceBefore``. Space before paragraph.
+- ``spaceAfter``. Space after paragraph.
+- ``tabs``. Set of custom tab stops.
+- ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*.
+
+.. _table-style:
Table
-----
-Table styles:
+Available Table style options:
+
+- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
+See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
+- ``bgColor``. Background color, e.g. '9966CC'.
+- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
+- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
+- ``cellMargin(Top|Right|Bottom|Left)``. Cell margin in twips.
+- ``width``. Table width in percent.
-- ``width`` Table width in percent
-- ``bgColor`` Background color, e.g. '9966CC'
-- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
-- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
-- ``cellMargin(Top|Right|Bottom|Left)`` Cell margin in twips
+Available Row style options:
-Row styles:
+- ``cantSplit``. Table row cannot break across pages, *true* or *false*.
+- ``exactHeight``. Row height is exact or at least.
+- ``tblHeader``. Repeat table row on every new page, *true* or *false*.
-- ``tblHeader`` Repeat table row on every new page, *true* or *false*
-- ``cantSplit`` Table row cannot break across pages, *true* or *false*
-- ``exactHeight`` Row height is exact or at least
+Available Cell style options:
-Cell styles:
+- ``bgColor``. Background color, e.g. '9966CC'.
+- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
+- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
+- ``gridSpan``. Number of columns spanned.
+- ``textDirection(btLr|tbRl)``. Direction of text. You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
+- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
+- ``vMerge``. *restart* or *continue*.
+- ``width``. Cell width in twips.
-- ``width`` Cell width in twips
-- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom*
-- ``textDirection`` Direction of text
-- ``bgColor`` Background color, e.g. '9966CC'
-- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
-- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
-- ``gridSpan`` Number of columns spanned
-- ``vMerge`` *restart* or *continue*
+.. _image-style:
Image
-----
-Available image styles:
+Available Image style options:
+
+- ``alignment``. See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
+- ``height``. Height in pixels.
+- ``marginLeft``. Left margin in inches, can be negative.
+- ``marginTop``. Top margin in inches, can be negative.
+- ``width``. Width in pixels.
+- ``wrappingStyle``. Wrapping style, *inline*, *square*, *tight*, *behind*, or *infront*.
-- ``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`` Wrapping style, *inline*, *square*, *tight*,
- *behind*, or *infront*
+.. _numbering-level-style:
Numbering level
---------------
-- ``start`` Starting value
-- ``format`` Numbering format
- bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter
-- ``restart`` Restart numbering level symbol
-- ``suffix`` Content between numbering symbol and paragraph text
- tab\|space\|nothing
-- ``text`` Numbering level text e.g. %1 for nonbullet or bullet
- character
-- ``align`` Numbering symbol align left\|center\|right\|both
-- ``left`` See paragraph style
-- ``hanging`` See paragraph style
-- ``tabPos`` See paragraph style
-- ``font`` Font name
-- ``hint`` See font style
+Available NumberingLevel style options:
+
+- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
+See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
+- ``font``. Font name.
+- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
+- ``hanging``. See paragraph style.
+- ``hint``. See font style.
+- ``left``. See paragraph style.
+- ``restart``. Restart numbering level symbol.
+- ``start``. Starting value.
+- ``suffix``. Content between numbering symbol and paragraph text tab\|space\|nothing.
+- ``tabPos``. See paragraph style.
+- ``text``. Numbering level text e.g. %1 for nonbullet or bullet character.
diff --git a/docs/templates-processing.rst b/docs/templates-processing.rst
index 6a65ea0d57..af03b24586 100644
--- a/docs/templates-processing.rst
+++ b/docs/templates-processing.rst
@@ -3,7 +3,7 @@
Templates processing
====================
-You can create a .docx document template with included search-patterns which can be replaced by any value you wish. Only single-line values can be replaced.
+You can create an OOXML document template with included search-patterns (macros) which can be replaced by any value you wish. Only single-line values can be replaced.
To deal with a template file, use ``new TemplateProcessor`` statement. After TemplateProcessor instance creation the document template is copied into the temporary directory. Then you can use ``TemplateProcessor::setValue`` method to change the value of a search pattern. The search-pattern model is: ``${search-pattern}``.
@@ -12,10 +12,10 @@ Example:
.. code-block:: php
$templateProcessor = new TemplateProcessor('Template.docx');
- $templateProcessor->setValue('Name', 'Somebody someone');
- $templateProcessor->setValue('Street', 'Coming-Undone-Street 32');
+ $templateProcessor->setValue('Name', 'John Doe');
+ $templateProcessor->setValue(array('City', 'Street'), array('Detroit', '12th Street'));
-It is not possible to directly add new OOXML elements to the template file being processed, but it is possible to transform main document part of the template using XSLT (see ``TemplateProcessor::applyXslStyleSheet``).
+It is not possible to directly add new OOXML elements to the template file being processed, but it is possible to transform headers, main document part, and footers of the template using XSLT (see ``TemplateProcessor::applyXslStyleSheet``).
See ``Sample_07_TemplateCloneRow.php`` for example on how to create
multirow from a single row in a template by using ``TemplateProcessor::cloneRow``.
diff --git a/docs/writersreaders.rst b/docs/writersreaders.rst
index 34a0805a8c..33aacc72af 100644
--- a/docs/writersreaders.rst
+++ b/docs/writersreaders.rst
@@ -8,35 +8,35 @@ OOXML
The package of OOXML document consists of the following files.
-- \_rels/
+- \_rels/
- - .rels
+ - .rels
-- docProps/
+- docProps/
- - app.xml
- - core.xml
- - custom.xml
+ - app.xml
+ - core.xml
+ - custom.xml
-- word/
+- word/
- - rels/
+ - rels/
- - document.rels.xml
+ - document.rels.xml
- - media/
- - theme/
+ - media/
+ - theme/
- - theme1.xml
+ - theme1.xml
- - document.xml
- - fontTable.xml
- - numbering.xml
- - settings.xml
- - styles.xml
- - webSettings.xml
+ - document.xml
+ - fontTable.xml
+ - numbering.xml
+ - settings.xml
+ - styles.xml
+ - webSettings.xml
-- [Content\_Types].xml
+- [Content\_Types].xml
OpenDocument
------------
@@ -46,53 +46,53 @@ Package
The package of OpenDocument document consists of the following files.
-- META-INF/
+- META-INF/
- - manifest.xml
+ - manifest.xml
-- Pictures/
-- content.xml
-- meta.xml
-- styles.xml
+- Pictures/
+- content.xml
+- meta.xml
+- styles.xml
content.xml
~~~~~~~~~~~
The structure of ``content.xml`` is described below.
-- office:document-content
+- office:document-content
- - office:font-facedecls
- - office:automatic-styles
- - office:body
+ - office:font-facedecls
+ - office:automatic-styles
+ - office:body
- - office:text
+ - office:text
- - draw:\*
- - office:forms
- - table:table
- - text:list
- - text:numbered-paragraph
- - text:p
- - text:table-of-contents
- - text:section
+ - draw:\*
+ - office:forms
+ - table:table
+ - text:list
+ - text:numbered-paragraph
+ - text:p
+ - text:table-of-contents
+ - text:section
- - office:chart
- - office:image
- - office:drawing
+ - office:chart
+ - office:image
+ - office:drawing
styles.xml
~~~~~~~~~~
The structure of ``styles.xml`` is described below.
-- office:document-styles
+- office:document-styles
- - office:styles
- - office:automatic-styles
- - office:master-styles
+ - office:styles
+ - office:automatic-styles
+ - office:master-styles
- - office:master-page
+ - office:master-page
RTF
---
diff --git a/phpmd.xml.dist b/phpmd.xml.dist
index 5eb348ecfe..44b3efdf66 100644
--- a/phpmd.xml.dist
+++ b/phpmd.xml.dist
@@ -4,7 +4,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
-
+
+
+
+
+
+
+
+
diff --git a/phpword.ini.dist b/phpword.ini.dist
index f8eafb6a78..0f4cc358df 100644
--- a/phpword.ini.dist
+++ b/phpword.ini.dist
@@ -3,11 +3,12 @@
[General]
-compatibility = true
-zipClass = ZipArchive
-pdfRendererName = DomPDF
-pdfRendererPath =
-; tempDir = "C:\PhpWordTemp"
+compatibility = true
+zipClass = ZipArchive
+pdfRendererName = DomPDF
+pdfRendererPath =
+; tempDir = "C:\PhpWordTemp"
+outputEscapingEnabled = false
[Font]
diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php
index f7aaece30a..1e51b2c072 100644
--- a/samples/Sample_01_SimpleText.php
+++ b/samples/Sample_01_SimpleText.php
@@ -4,24 +4,29 @@
// New Word Document
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-$phpWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
-$phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100));
+
+$fontStyleName = 'rStyle';
+$phpWord->addFontStyle($fontStyleName, array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
+
+$paragraphStyleName = 'pStyle';
+$phpWord->addParagraphStyle($paragraphStyleName, array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER, 'spaceAfter' => 100));
+
$phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
// New portrait section
$section = $phpWord->addSection();
// Simple text
-$section->addTitle(htmlspecialchars('Welcome to PhpWord'), 1);
-$section->addText(htmlspecialchars('Hello World!'));
+$section->addTitle('Welcome to PhpWord', 1);
+$section->addText('Hello World!');
// Two text break
$section->addTextBreak(2);
-// Defined style
-$section->addText(htmlspecialchars('I am styled by a font style definition.'), 'rStyle');
-$section->addText(htmlspecialchars('I am styled by a paragraph style definition.'), null, 'pStyle');
-$section->addText(htmlspecialchars('I am styled by both font and paragraph style.'), 'rStyle', 'pStyle');
+// Define styles
+$section->addText('I am styled by a font style definition.', $fontStyleName);
+$section->addText('I am styled by a paragraph style definition.', null, $paragraphStyleName);
+$section->addText('I am styled by both font and paragraph style.', $fontStyleName, $paragraphStyleName);
$section->addTextBreak();
@@ -30,39 +35,39 @@
$fontStyle['size'] = 20;
$textrun = $section->addTextRun();
-$textrun->addText(htmlspecialchars('I am inline styled '), $fontStyle);
-$textrun->addText(htmlspecialchars('with '));
-$textrun->addText(htmlspecialchars('color'), array('color' => '996699'));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('bold'), array('bold' => true));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('italic'), array('italic' => true));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('underline'), array('underline' => 'dash'));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('strikethrough'), array('strikethrough' => true));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('doubleStrikethrough'), array('doubleStrikethrough' => true));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('superScript'), array('superScript' => true));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('subScript'), array('subScript' => true));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('smallCaps'), array('smallCaps' => true));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('allCaps'), array('allCaps' => true));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('fgColor'), array('fgColor' => 'yellow'));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('scale'), array('scale' => 200));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('spacing'), array('spacing' => 120));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addText(htmlspecialchars('kerning'), array('kerning' => 10));
-$textrun->addText(htmlspecialchars('. '));
+$textrun->addText('I am inline styled ', $fontStyle);
+$textrun->addText('with ');
+$textrun->addText('color', array('color' => '996699'));
+$textrun->addText(', ');
+$textrun->addText('bold', array('bold' => true));
+$textrun->addText(', ');
+$textrun->addText('italic', array('italic' => true));
+$textrun->addText(', ');
+$textrun->addText('underline', array('underline' => 'dash'));
+$textrun->addText(', ');
+$textrun->addText('strikethrough', array('strikethrough' => true));
+$textrun->addText(', ');
+$textrun->addText('doubleStrikethrough', array('doubleStrikethrough' => true));
+$textrun->addText(', ');
+$textrun->addText('superScript', array('superScript' => true));
+$textrun->addText(', ');
+$textrun->addText('subScript', array('subScript' => true));
+$textrun->addText(', ');
+$textrun->addText('smallCaps', array('smallCaps' => true));
+$textrun->addText(', ');
+$textrun->addText('allCaps', array('allCaps' => true));
+$textrun->addText(', ');
+$textrun->addText('fgColor', array('fgColor' => 'yellow'));
+$textrun->addText(', ');
+$textrun->addText('scale', array('scale' => 200));
+$textrun->addText(', ');
+$textrun->addText('spacing', array('spacing' => 120));
+$textrun->addText(', ');
+$textrun->addText('kerning', array('kerning' => 10));
+$textrun->addText('. ');
// Link
-$section->addLink('http://www.google.com', htmlspecialchars('Google'));
+$section->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub');
$section->addTextBreak();
// Image
diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php
index 46d91cec34..1702198751 100644
--- a/samples/Sample_02_TabStops.php
+++ b/samples/Sample_02_TabStops.php
@@ -5,9 +5,10 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-// Ads styles
+// Define styles
+$multipleTabsStyleName = 'multipleTab';
$phpWord->addParagraphStyle(
- 'multipleTab',
+ $multipleTabsStyleName,
array(
'tabs' => array(
new \PhpOffice\PhpWord\Style\Tab('left', 1550),
@@ -16,22 +17,20 @@
)
)
);
-$phpWord->addParagraphStyle(
- 'rightTab',
- array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('right', 9090)))
-);
-$phpWord->addParagraphStyle(
- 'centerTab',
- array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center', 4680)))
-);
+
+$rightTabStyleName = 'rightTab';
+$phpWord->addParagraphStyle($rightTabStyleName, array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('right', 9090))));
+
+$leftTabStyleName = 'centerTab';
+$phpWord->addParagraphStyle($leftTabStyleName, array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center', 4680))));
// New portrait section
$section = $phpWord->addSection();
// Add listitem elements
-$section->addText(htmlspecialchars("Multiple Tabs:\tOne\tTwo\tThree"), null, 'multipleTab');
-$section->addText(htmlspecialchars("Left Aligned\tRight Aligned"), null, 'rightTab');
-$section->addText(htmlspecialchars("\tCenter Aligned"), null, 'centerTab');
+$section->addText("Multiple Tabs:\tOne\tTwo\tThree", null, $multipleTabsStyleName);
+$section->addText("Left Aligned\tRight Aligned", null, $rightTabStyleName);
+$section->addText("\tCenter Aligned", null, $leftTabStyleName);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php
index a95b15d644..a7b5b13d6d 100644
--- a/samples/Sample_03_Sections.php
+++ b/samples/Sample_03_Sections.php
@@ -7,15 +7,11 @@
// New portrait section
$section = $phpWord->addSection(array('borderColor' => '00FF00', 'borderSize' => 12));
-$section->addText(htmlspecialchars('I am placed on a default section.'));
+$section->addText('I am placed on a default section.');
// New landscape section
$section = $phpWord->addSection(array('orientation' => 'landscape'));
-$section->addText(
- htmlspecialchars(
- 'I am placed on a landscape section. Every page starting from this section will be landscape style.'
- )
-);
+$section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.');
$section->addPageBreak();
$section->addPageBreak();
@@ -23,7 +19,7 @@
$section = $phpWord->addSection(
array('paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)
);
-$section->addText(htmlspecialchars('This section uses other margins with folio papersize.'));
+$section->addText('This section uses other margins with folio papersize.');
// New portrait section with Header & Footer
$section = $phpWord->addSection(
@@ -36,9 +32,9 @@
'footerHeight' => 50,
)
);
-$section->addText(htmlspecialchars('This section and we play with header/footer height.'));
-$section->addHeader()->addText(htmlspecialchars('Header'));
-$section->addFooter()->addText(htmlspecialchars('Footer'));
+$section->addText('This section and we play with header/footer height.');
+$section->addHeader()->addText('Header');
+$section->addFooter()->addText('Footer');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php
index 7ebf6e3365..48978dd36b 100644
--- a/samples/Sample_04_Textrun.php
+++ b/samples/Sample_04_Textrun.php
@@ -5,39 +5,39 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-// Ads styles
-$phpWord->addParagraphStyle('pStyle', array('spacing' => 100));
-$phpWord->addFontStyle('BoldText', array('bold' => true));
-$phpWord->addFontStyle('ColoredText', array('color' => 'FF8080', 'bgColor' => 'FFFFCC'));
-$phpWord->addLinkStyle(
- 'NLink',
- array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)
-);
+// Define styles
+$paragraphStyleName = 'pStyle';
+$phpWord->addParagraphStyle($paragraphStyleName, array('spacing' => 100));
+
+$boldFontStyleName = 'BoldText';
+$phpWord->addFontStyle($boldFontStyleName, array('bold' => true));
+
+$coloredFontStyleName = 'ColoredText';
+$phpWord->addFontStyle($coloredFontStyleName, array('color' => 'FF8080', 'bgColor' => 'FFFFCC'));
+
+$linkFontStyleName = 'NLink';
+$phpWord->addLinkStyle($linkFontStyleName, array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
// New portrait section
$section = $phpWord->addSection();
// Add text run
-$textrun = $section->addTextRun('pStyle');
-
-$textrun->addText(htmlspecialchars('Each textrun can contain native text, link elements or an image.'));
-$textrun->addText(htmlspecialchars(' No break is placed after adding an element.'), 'BoldText');
-$textrun->addText(htmlspecialchars(' Both '));
-$textrun->addText(htmlspecialchars('superscript'), array('superScript' => true));
-$textrun->addText(htmlspecialchars(' and '));
-$textrun->addText(htmlspecialchars('subscript'), array('subScript' => true));
-$textrun->addText(htmlspecialchars(' are also available.'));
-$textrun->addText(
- htmlspecialchars(' All elements are placed inside a paragraph with the optionally given p-Style.'),
- 'ColoredText'
-);
-$textrun->addText(htmlspecialchars(' Sample Link: '));
-$textrun->addLink('http://www.google.com', null, 'NLink');
-$textrun->addText(htmlspecialchars(' Sample Image: '));
+$textrun = $section->addTextRun($paragraphStyleName);
+$textrun->addText('Each textrun can contain native text, link elements or an image.');
+$textrun->addText(' No break is placed after adding an element.', $boldFontStyleName);
+$textrun->addText(' Both ');
+$textrun->addText('superscript', array('superScript' => true));
+$textrun->addText(' and ');
+$textrun->addText('subscript', array('subScript' => true));
+$textrun->addText(' are also available.');
+$textrun->addText(' All elements are placed inside a paragraph with the optionally given paragraph style.', $coloredFontStyleName);
+$textrun->addText(' Sample Link: ');
+$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub', $linkFontStyleName);
+$textrun->addText(' Sample Image: ');
$textrun->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18));
-$textrun->addText(htmlspecialchars(' Sample Object: '));
+$textrun->addText(' Sample Object: ');
$textrun->addObject('resources/_sheet.xls');
-$textrun->addText(htmlspecialchars(' Here is some more text. '));
+$textrun->addText(' Here is some more text. ');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php
index b93ab344c1..f7cefa58d3 100644
--- a/samples/Sample_05_Multicolumn.php
+++ b/samples/Sample_05_Multicolumn.php
@@ -11,7 +11,7 @@
// Normal
$section = $phpWord->addSection();
-$section->addText(htmlspecialchars("Normal paragraph. {$filler}"));
+$section->addText("Normal paragraph. {$filler}");
// Two columns
$section = $phpWord->addSection(
@@ -21,11 +21,11 @@
'breakType' => 'continuous',
)
);
-$section->addText(htmlspecialchars("Two columns, one inch (1440 twips) spacing. {$filler}"));
+$section->addText("Two columns, one inch (1440 twips) spacing. {$filler}");
// Normal
$section = $phpWord->addSection(array('breakType' => 'continuous'));
-$section->addText(htmlspecialchars("Normal paragraph again. {$filler}"));
+$section->addText("Normal paragraph again. {$filler}");
// Three columns
$section = $phpWord->addSection(
@@ -35,11 +35,11 @@
'breakType' => 'continuous',
)
);
-$section->addText(htmlspecialchars("Three columns, half inch (720 twips) spacing. {$filler}"));
+$section->addText("Three columns, half inch (720 twips) spacing. {$filler}");
// Normal
$section = $phpWord->addSection(array('breakType' => 'continuous'));
-$section->addText(htmlspecialchars('Normal paragraph again.'));
+$section->addText("Normal paragraph again. {$filler}");
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php
index c7f3d8c0bc..30afcf815b 100644
--- a/samples/Sample_06_Footnote.php
+++ b/samples/Sample_06_Footnote.php
@@ -6,44 +6,46 @@
$phpWord = new \PhpOffice\PhpWord\PhpWord();
\PhpOffice\PhpWord\Settings::setCompatibility(false);
+// Define styles
+$paragraphStyleName = 'pStyle';
+$phpWord->addParagraphStyle($paragraphStyleName, array('spacing' => 100));
+
+$boldFontStyleName = 'BoldText';
+$phpWord->addFontStyle($boldFontStyleName, array('bold' => true));
+
+$coloredFontStyleName = 'ColoredText';
+$phpWord->addFontStyle($coloredFontStyleName, array('color' => 'FF8080', 'bgColor' => 'FFFFCC'));
+
+$linkFontStyleName = 'NLink';
+$phpWord->addLinkStyle($linkFontStyleName, array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
+
// New portrait section
$section = $phpWord->addSection();
-// Add style definitions
-$phpWord->addParagraphStyle('pStyle', array('spacing' => 100));
-$phpWord->addFontStyle('BoldText', array('bold' => true));
-$phpWord->addFontStyle('ColoredText', array('color' => 'FF8080'));
-$phpWord->addLinkStyle(
- 'NLink',
- array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)
-);
-
// Add text elements
-$textrun = $section->addTextRun('pStyle');
-$textrun->addText(htmlspecialchars('This is some lead text in a paragraph with a following footnote. '), 'pStyle');
+$textrun = $section->addTextRun($paragraphStyleName);
+$textrun->addText('This is some lead text in a paragraph with a following footnote. ', $paragraphStyleName);
$footnote = $textrun->addFootnote();
-$footnote->addText(htmlspecialchars('Just like a textrun, a footnote can contain native texts. '));
-$footnote->addText(htmlspecialchars('No break is placed after adding an element. '), 'BoldText');
-$footnote->addText(htmlspecialchars('All elements are placed inside a paragraph. '), 'ColoredText');
+$footnote->addText('Just like a textrun, a footnote can contain native texts. ');
+$footnote->addText('No break is placed after adding an element. ', $boldFontStyleName);
+$footnote->addText('All elements are placed inside a paragraph. ', $coloredFontStyleName);
$footnote->addTextBreak();
-$footnote->addText(htmlspecialchars('But you can insert a manual text break like above, '));
-$footnote->addText(htmlspecialchars('links like '));
-$footnote->addLink('http://www.google.com', null, 'NLink');
-$footnote->addText(htmlspecialchars(', image like '));
+$footnote->addText('But you can insert a manual text break like above, ');
+$footnote->addText('links like ');
+$footnote->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub', $linkFontStyleName);
+$footnote->addText(', image like ');
$footnote->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18));
-$footnote->addText(htmlspecialchars(', or object like '));
+$footnote->addText(', or object like ');
$footnote->addObject('resources/_sheet.xls');
-$footnote->addText(htmlspecialchars('But you can only put footnote in section, not in header or footer.'));
+$footnote->addText('But you can only put footnote in section, not in header or footer.');
$section->addText(
- htmlspecialchars(
- 'You can also create the footnote directly from the section making it wrap in a paragraph '
- . 'like the footnote below this paragraph. But is is best used from within a textrun.'
- )
+ 'You can also create the footnote directly from the section making it wrap in a paragraph '
+ . 'like the footnote below this paragraph. But is is best used from within a textrun.'
);
$footnote = $section->addFootnote();
-$footnote->addText(htmlspecialchars('The reference for this is wrapped in its own line'));
+$footnote->addText('The reference for this is wrapped in its own line');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php
index 60edacb5a7..22a68537c6 100644
--- a/samples/Sample_07_TemplateCloneRow.php
+++ b/samples/Sample_07_TemplateCloneRow.php
@@ -6,52 +6,52 @@
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
// Variables on different parts of document
-$templateProcessor->setValue('weekday', htmlspecialchars(date('l'))); // On section/content
-$templateProcessor->setValue('time', htmlspecialchars(date('H:i'))); // On footer
-$templateProcessor->setValue('serverName', htmlspecialchars(realpath(__DIR__))); // On header
+$templateProcessor->setValue('weekday', date('l')); // On section/content
+$templateProcessor->setValue('time', date('H:i')); // On footer
+$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
// Simple table
$templateProcessor->cloneRow('rowValue', 10);
-$templateProcessor->setValue('rowValue#1', htmlspecialchars('Sun'));
-$templateProcessor->setValue('rowValue#2', htmlspecialchars('Mercury'));
-$templateProcessor->setValue('rowValue#3', htmlspecialchars('Venus'));
-$templateProcessor->setValue('rowValue#4', htmlspecialchars('Earth'));
-$templateProcessor->setValue('rowValue#5', htmlspecialchars('Mars'));
-$templateProcessor->setValue('rowValue#6', htmlspecialchars('Jupiter'));
-$templateProcessor->setValue('rowValue#7', htmlspecialchars('Saturn'));
-$templateProcessor->setValue('rowValue#8', htmlspecialchars('Uranus'));
-$templateProcessor->setValue('rowValue#9', htmlspecialchars('Neptun'));
-$templateProcessor->setValue('rowValue#10', htmlspecialchars('Pluto'));
-
-$templateProcessor->setValue('rowNumber#1', htmlspecialchars('1'));
-$templateProcessor->setValue('rowNumber#2', htmlspecialchars('2'));
-$templateProcessor->setValue('rowNumber#3', htmlspecialchars('3'));
-$templateProcessor->setValue('rowNumber#4', htmlspecialchars('4'));
-$templateProcessor->setValue('rowNumber#5', htmlspecialchars('5'));
-$templateProcessor->setValue('rowNumber#6', htmlspecialchars('6'));
-$templateProcessor->setValue('rowNumber#7', htmlspecialchars('7'));
-$templateProcessor->setValue('rowNumber#8', htmlspecialchars('8'));
-$templateProcessor->setValue('rowNumber#9', htmlspecialchars('9'));
-$templateProcessor->setValue('rowNumber#10', htmlspecialchars('10'));
+$templateProcessor->setValue('rowValue#1', 'Sun');
+$templateProcessor->setValue('rowValue#2', 'Mercury');
+$templateProcessor->setValue('rowValue#3', 'Venus');
+$templateProcessor->setValue('rowValue#4', 'Earth');
+$templateProcessor->setValue('rowValue#5', 'Mars');
+$templateProcessor->setValue('rowValue#6', 'Jupiter');
+$templateProcessor->setValue('rowValue#7', 'Saturn');
+$templateProcessor->setValue('rowValue#8', 'Uranus');
+$templateProcessor->setValue('rowValue#9', 'Neptun');
+$templateProcessor->setValue('rowValue#10', 'Pluto');
+
+$templateProcessor->setValue('rowNumber#1', '1');
+$templateProcessor->setValue('rowNumber#2', '2');
+$templateProcessor->setValue('rowNumber#3', '3');
+$templateProcessor->setValue('rowNumber#4', '4');
+$templateProcessor->setValue('rowNumber#5', '5');
+$templateProcessor->setValue('rowNumber#6', '6');
+$templateProcessor->setValue('rowNumber#7', '7');
+$templateProcessor->setValue('rowNumber#8', '8');
+$templateProcessor->setValue('rowNumber#9', '9');
+$templateProcessor->setValue('rowNumber#10', '10');
// Table with a spanned cell
$templateProcessor->cloneRow('userId', 3);
-$templateProcessor->setValue('userId#1', htmlspecialchars('1'));
-$templateProcessor->setValue('userFirstName#1', htmlspecialchars('James'));
-$templateProcessor->setValue('userName#1', htmlspecialchars('Taylor'));
-$templateProcessor->setValue('userPhone#1', htmlspecialchars('+1 428 889 773'));
+$templateProcessor->setValue('userId#1', '1');
+$templateProcessor->setValue('userFirstName#1', 'James');
+$templateProcessor->setValue('userName#1', 'Taylor');
+$templateProcessor->setValue('userPhone#1', '+1 428 889 773');
-$templateProcessor->setValue('userId#2', htmlspecialchars('2'));
-$templateProcessor->setValue('userFirstName#2', htmlspecialchars('Robert'));
-$templateProcessor->setValue('userName#2', htmlspecialchars('Bell'));
-$templateProcessor->setValue('userPhone#2', htmlspecialchars('+1 428 889 774'));
+$templateProcessor->setValue('userId#2', '2');
+$templateProcessor->setValue('userFirstName#2', 'Robert');
+$templateProcessor->setValue('userName#2', 'Bell');
+$templateProcessor->setValue('userPhone#2', '+1 428 889 774');
-$templateProcessor->setValue('userId#3', htmlspecialchars('3'));
-$templateProcessor->setValue('userFirstName#3', htmlspecialchars('Michael'));
-$templateProcessor->setValue('userName#3', htmlspecialchars('Ray'));
-$templateProcessor->setValue('userPhone#3', htmlspecialchars('+1 428 889 775'));
+$templateProcessor->setValue('userId#3', '3');
+$templateProcessor->setValue('userFirstName#3', 'Michael');
+$templateProcessor->setValue('userName#3', 'Ray');
+$templateProcessor->setValue('userPhone#3', '+1 428 889 775');
echo date('H:i:s'), ' Saving the result document...', EOL;
$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php
index dd364562d0..f91b1c56b4 100644
--- a/samples/Sample_08_ParagraphPagination.php
+++ b/samples/Sample_08_ParagraphPagination.php
@@ -6,68 +6,58 @@
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->setDefaultParagraphStyle(
array(
- 'align' => 'both',
+ 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::BOTH,
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12),
'spacing' => 120,
)
);
-// Sample
+// New section
$section = $phpWord->addSection();
$section->addText(
- htmlspecialchars(
- 'Below are the samples on how to control your paragraph '
- . 'pagination. See "Line and Page Break" tab on paragraph properties '
- . 'window to see the attribute set by these controls.'
- ),
+ 'Below are the samples on how to control your paragraph '
+ . 'pagination. See "Line and Page Break" tab on paragraph properties '
+ . 'window to see the attribute set by these controls.',
array('bold' => true),
array('space' => array('before' => 360, 'after' => 480))
);
$section->addText(
- htmlspecialchars(
- 'Paragraph with widowControl = false (default: true). '
- . 'A "widow" is the last line of a paragraph printed by itself at the top '
- . 'of a page. An "orphan" is the first line of a paragraph printed by '
- . 'itself at the bottom of a page. Set this option to "false" if you want '
- . 'to disable this automatic control.'
- ),
+ 'Paragraph with widowControl = false (default: true). '
+ . 'A "widow" is the last line of a paragraph printed by itself at the top '
+ . 'of a page. An "orphan" is the first line of a paragraph printed by '
+ . 'itself at the bottom of a page. Set this option to "false" if you want '
+ . 'to disable this automatic control.',
null,
array('widowControl' => false, 'indentation' => array('left' => 240, 'right' => 120))
);
$section->addText(
- htmlspecialchars(
- 'Paragraph with keepNext = true (default: false). '
- . '"Keep with next" is used to prevent Word from inserting automatic page '
- . 'breaks between paragraphs. Set this option to "true" if you do not want '
- . 'your paragraph to be separated with the next paragraph.'
- ),
+ 'Paragraph with keepNext = true (default: false). '
+ . '"Keep with next" is used to prevent Word from inserting automatic page '
+ . 'breaks between paragraphs. Set this option to "true" if you do not want '
+ . 'your paragraph to be separated with the next paragraph.',
null,
array('keepNext' => true, 'indentation' => array('firstLine' => 240))
);
$section->addText(
- htmlspecialchars(
- 'Paragraph with keepLines = true (default: false). '
- . '"Keep lines together" will prevent Word from inserting an automatic page '
- . 'break within a paragraph. Set this option to "true" if you do not want '
- . 'all lines of your paragraph to be in the same page.'
- ),
+ 'Paragraph with keepLines = true (default: false). '
+ . '"Keep lines together" will prevent Word from inserting an automatic page '
+ . 'break within a paragraph. Set this option to "true" if you do not want '
+ . 'all lines of your paragraph to be in the same page.',
null,
array('keepLines' => true, 'indentation' => array('left' => 240, 'hanging' => 240))
);
-$section->addText(htmlspecialchars('Keep scrolling. More below.'));
+$section->addText('Keep scrolling. More below.');
$section->addText(
- htmlspecialchars(
- 'Paragraph with pageBreakBefore = true (default: false). '
- . 'Different with all other control above, "page break before" separates '
- . 'your paragraph into the next page. This option is most useful for '
- . 'heading styles.'
- ),
+ 'Paragraph with pageBreakBefore = true (default: false). '
+ . 'Different with all other control above, "page break before" separates '
+ . 'your paragraph into the next page. This option is most useful for '
+ . 'heading styles.',
null,
array('pageBreakBefore' => true)
);
diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php
index 5c305c8342..53d32e0888 100644
--- a/samples/Sample_09_Tables.php
+++ b/samples/Sample_09_Tables.php
@@ -11,89 +11,132 @@
$rows = 10;
$cols = 5;
-$section->addText(htmlspecialchars('Basic table'), $header);
+$section->addText('Basic table', $header);
$table = $section->addTable();
for ($r = 1; $r <= 8; $r++) {
$table->addRow();
for ($c = 1; $c <= 5; $c++) {
- $table->addCell(1750)->addText(htmlspecialchars("Row {$r}, Cell {$c}"));
+ $table->addCell(1750)->addText("Row {$r}, Cell {$c}");
}
}
// 2. Advanced table
$section->addTextBreak(1);
-$section->addText(htmlspecialchars('Fancy table'), $header);
-
-$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80);
-$styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
-$styleCell = array('valign' => 'center');
-$styleCellBTLR = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
-$fontStyle = array('bold' => true, 'align' => 'center');
-$phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow);
-$table = $section->addTable('Fancy Table');
+$section->addText('Fancy table', $header);
+
+$fancyTableStyleName = 'Fancy Table';
+$fancyTableStyle = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER);
+$fancyTableFirstRowStyle = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
+$fancyTableCellStyle = array('valign' => 'center');
+$fancyTableCellBtlrStyle = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
+$fancyTableFontStyle = array('bold' => true);
+$phpWord->addTableStyle($fancyTableStyleName, $fancyTableStyle, $fancyTableFirstRowStyle);
+$table = $section->addTable($fancyTableStyleName);
$table->addRow(900);
-$table->addCell(2000, $styleCell)->addText(htmlspecialchars('Row 1'), $fontStyle);
-$table->addCell(2000, $styleCell)->addText(htmlspecialchars('Row 2'), $fontStyle);
-$table->addCell(2000, $styleCell)->addText(htmlspecialchars('Row 3'), $fontStyle);
-$table->addCell(2000, $styleCell)->addText(htmlspecialchars('Row 4'), $fontStyle);
-$table->addCell(500, $styleCellBTLR)->addText(htmlspecialchars('Row 5'), $fontStyle);
+$table->addCell(2000, $fancyTableCellStyle)->addText('Row 1', $fancyTableFontStyle);
+$table->addCell(2000, $fancyTableCellStyle)->addText('Row 2', $fancyTableFontStyle);
+$table->addCell(2000, $fancyTableCellStyle)->addText('Row 3', $fancyTableFontStyle);
+$table->addCell(2000, $fancyTableCellStyle)->addText('Row 4', $fancyTableFontStyle);
+$table->addCell(500, $fancyTableCellBtlrStyle)->addText('Row 5', $fancyTableFontStyle);
for ($i = 1; $i <= 8; $i++) {
$table->addRow();
- $table->addCell(2000)->addText(htmlspecialchars("Cell {$i}"));
- $table->addCell(2000)->addText(htmlspecialchars("Cell {$i}"));
- $table->addCell(2000)->addText(htmlspecialchars("Cell {$i}"));
- $table->addCell(2000)->addText(htmlspecialchars("Cell {$i}"));
+ $table->addCell(2000)->addText("Cell {$i}");
+ $table->addCell(2000)->addText("Cell {$i}");
+ $table->addCell(2000)->addText("Cell {$i}");
+ $table->addCell(2000)->addText("Cell {$i}");
$text = (0== $i % 2) ? 'X' : '';
- $table->addCell(500)->addText(htmlspecialchars($text));
+ $table->addCell(500)->addText($text);
}
-// 3. colspan (gridSpan) and rowspan (vMerge)
+/**
+ * 3. colspan (gridSpan) and rowspan (vMerge)
+ * ---------------------
+ * | | B | |
+ * | A |--------| E |
+ * | | C | D | |
+ * ---------------------
+ */
$section->addPageBreak();
-$section->addText(htmlspecialchars('Table with colspan and rowspan'), $header);
+$section->addText('Table with colspan and rowspan', $header);
-$styleTable = array('borderSize' => 6, 'borderColor' => '999999');
+$fancyTableStyle = array('borderSize' => 6, 'borderColor' => '999999');
$cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center', 'bgColor' => 'FFFF00');
$cellRowContinue = array('vMerge' => 'continue');
$cellColSpan = array('gridSpan' => 2, 'valign' => 'center');
-$cellHCentered = array('align' => 'center');
+$cellHCentered = array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER);
$cellVCentered = array('valign' => 'center');
-$phpWord->addTableStyle('Colspan Rowspan', $styleTable);
-$table = $section->addTable('Colspan Rowspan');
+$spanTableStyleName = 'Colspan Rowspan';
+$phpWord->addTableStyle($spanTableStyleName, $fancyTableStyle);
+$table = $section->addTable($spanTableStyleName);
$table->addRow();
$cell1 = $table->addCell(2000, $cellRowSpan);
$textrun1 = $cell1->addTextRun($cellHCentered);
-$textrun1->addText(htmlspecialchars('A'));
-$textrun1->addFootnote()->addText(htmlspecialchars('Row span'));
+$textrun1->addText('A');
+$textrun1->addFootnote()->addText('Row span');
$cell2 = $table->addCell(4000, $cellColSpan);
$textrun2 = $cell2->addTextRun($cellHCentered);
-$textrun2->addText(htmlspecialchars('B'));
-$textrun2->addFootnote()->addText(htmlspecialchars('Colspan span'));
+$textrun2->addText('B');
+$textrun2->addFootnote()->addText('Column span');
-$table->addCell(2000, $cellRowSpan)->addText(htmlspecialchars('E'), null, $cellHCentered);
+$table->addCell(2000, $cellRowSpan)->addText('E', null, $cellHCentered);
$table->addRow();
$table->addCell(null, $cellRowContinue);
-$table->addCell(2000, $cellVCentered)->addText(htmlspecialchars('C'), null, $cellHCentered);
-$table->addCell(2000, $cellVCentered)->addText(htmlspecialchars('D'), null, $cellHCentered);
+$table->addCell(2000, $cellVCentered)->addText('C', null, $cellHCentered);
+$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered);
$table->addCell(null, $cellRowContinue);
-// 4. Nested table
+/**
+ * 4. colspan (gridSpan) and rowspan (vMerge)
+ * ---------------------
+ * | | B | 1 |
+ * | A | |----|
+ * | | | 2 |
+ * | |---|----|----|
+ * | | C | D | 3 |
+ * ---------------------
+ * @see https://github.com/PHPOffice/PHPWord/issues/806
+ */
+$section->addPageBreak();
+$section->addText('Table with colspan and rowspan', $header);
+
+$styleTable = ['borderSize' => 6, 'borderColor' => '999999'];
+$phpWord->addTableStyle('Colspan Rowspan', $styleTable);
+$table = $section->addTable('Colspan Rowspan');
+
+$row = $table->addRow();
+
+$row->addCell(null, ['vMerge' => 'restart'])->addText('A');
+$row->addCell(null, ['gridSpan' => 2, 'vMerge' => 'restart',])->addText('B');
+$row->addCell()->addText('1');
+
+$row = $table->addRow();
+$row->addCell(null, ['vMerge' => 'continue']);
+$row->addCell(null, ['vMerge' => 'continue','gridSpan' => 2,]);
+$row->addCell()->addText('2');
+$row = $table->addRow();
+$row->addCell(null, ['vMerge' => 'continue']);
+$row->addCell()->addText('C');
+$row->addCell()->addText('D');
+$row->addCell()->addText('3');
+
+// 5. Nested table
$section->addTextBreak(2);
-$section->addText(htmlspecialchars('Nested table in a centered and 50% width table.'), $header);
+$section->addText('Nested table in a centered and 50% width table.', $header);
-$table = $section->addTable(array('width' => 50 * 50, 'unit' => 'pct', 'align' => 'center'));
+$table = $section->addTable(array('width' => 50 * 50, 'unit' => 'pct', 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER));
$cell = $table->addRow()->addCell();
-$cell->addText(htmlspecialchars('This cell contains nested table.'));
-$innerCell = $cell->addTable(array('align' => 'center'))->addRow()->addCell();
-$innerCell->addText(htmlspecialchars('Inside nested table'));
+$cell->addText('This cell contains nested table.');
+$innerCell = $cell->addTable(array('alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER))->addRow()->addCell();
+$innerCell->addText('Inside nested table');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php
index f3553bfef2..2541af86dc 100644
--- a/samples/Sample_10_EastAsianFontStyle.php
+++ b/samples/Sample_10_EastAsianFontStyle.php
@@ -7,7 +7,7 @@
$section = $phpWord->addSection();
$header = array('size' => 16, 'bold' => true);
//1.Use EastAisa FontStyle
-$section->addText(htmlspecialchars('中文楷体样式测试'), array('name' => '楷体', 'size' => 16, 'color' => '1B2232'));
+$section->addText('中文楷体样式测试', array('name' => '楷体', 'size' => 16, 'color' => '1B2232'));
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php
index 51082b6679..b99d81f8dd 100644
--- a/samples/Sample_12_HeaderFooter.php
+++ b/samples/Sample_12_HeaderFooter.php
@@ -15,50 +15,47 @@
$table->addRow();
$cell = $table->addCell(4500);
$textrun = $cell->addTextRun();
-$textrun->addText(htmlspecialchars('This is the header with '));
-$textrun->addLink('http://google.com', htmlspecialchars('link to Google'));
-$table->addCell(4500)->addImage(
- 'resources/PhpWord.png',
- array('width' => 80, 'height' => 80, 'align' => 'right')
-);
+$textrun->addText('This is the header with ');
+$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub');
+$table->addCell(4500)->addImage('resources/PhpWord.png', array('width' => 80, 'height' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END));
// Add header for all other pages
$subsequent = $section->addHeader();
-$subsequent->addText(htmlspecialchars('Subsequent pages in Section 1 will Have this!'));
+$subsequent->addText('Subsequent pages in Section 1 will Have this!');
$subsequent->addImage('resources/_mars.jpg', array('width' => 80, 'height' => 80));
// Add footer
$footer = $section->addFooter();
-$footer->addPreserveText(htmlspecialchars('Page {PAGE} of {NUMPAGES}.'), null, array('align' => 'center'));
-$footer->addLink('http://google.com', htmlspecialchars('Direct Google'));
+$footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', null, array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
+$footer->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub');
// Write some text
$section->addTextBreak();
-$section->addText(htmlspecialchars('Some text...'));
+$section->addText('Some text...');
// Create a second page
$section->addPageBreak();
// Write some text
$section->addTextBreak();
-$section->addText(htmlspecialchars('Some text...'));
+$section->addText('Some text...');
// Create a third page
$section->addPageBreak();
// Write some text
$section->addTextBreak();
-$section->addText(htmlspecialchars('Some text...'));
+$section->addText('Some text...');
// New portrait section
$section2 = $phpWord->addSection();
$sec2Header = $section2->addHeader();
-$sec2Header->addText(htmlspecialchars('All pages in Section 2 will Have this!'));
+$sec2Header->addText('All pages in Section 2 will Have this!');
// Write some text
$section2->addTextBreak();
-$section2->addText(htmlspecialchars('Some text...'));
+$section2->addText('Some text...');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php
index d13912119b..a3c2af23a9 100644
--- a/samples/Sample_13_Images.php
+++ b/samples/Sample_13_Images.php
@@ -7,17 +7,17 @@
// Begin code
$section = $phpWord->addSection();
-$section->addText(htmlspecialchars('Local image without any styles:'));
+$section->addText('Local image without any styles:');
$section->addImage('resources/_mars.jpg');
$section->addTextBreak(2);
-$section->addText(htmlspecialchars('Local image with styles:'));
-$section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'align' => 'center'));
+$section->addText('Local image with styles:');
+$section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
$section->addTextBreak(2);
// Remote image
$source = 'http://php.net/images/logos/php-med-trans-light.gif';
-$section->addText(htmlspecialchars("Remote image from: {$source}"));
+$section->addText("Remote image from: {$source}");
$section->addImage($source);
//Wrapping style
@@ -25,7 +25,7 @@
$wrappingStyles = array('inline', 'behind', 'infront', 'square', 'tight');
foreach ($wrappingStyles as $wrappingStyle) {
$section->addTextBreak(5);
- $section->addText(htmlspecialchars("Wrapping style {$wrappingStyle}"));
+ $section->addText("Wrapping style {$wrappingStyle}");
$section->addImage(
'resources/_earth.jpg',
array(
@@ -37,12 +37,12 @@
'wrappingStyle' => $wrappingStyle,
)
);
- $section->addText(htmlspecialchars($text));
+ $section->addText($text);
}
//Absolute positioning
$section->addTextBreak(3);
-$section->addText(htmlspecialchars('Absolute positioning: see top right corner of page'));
+$section->addText('Absolute positioning: see top right corner of page');
$section->addImage(
'resources/_mars.jpg',
array(
@@ -59,8 +59,8 @@
//Relative positioning
$section->addTextBreak(3);
-$section->addText(htmlspecialchars('Relative positioning: Horizontal position center relative to column,'));
-$section->addText(htmlspecialchars('Vertical position top relative to line'));
+$section->addText('Relative positioning: Horizontal position center relative to column,');
+$section->addText('Vertical position top relative to line');
$section->addImage(
'resources/_mars.jpg',
array(
diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php
index 3a29e3fdee..689ac3d3eb 100644
--- a/samples/Sample_14_ListItem.php
+++ b/samples/Sample_14_ListItem.php
@@ -5,15 +5,16 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-// Begin code
-$section = $phpWord->addSection();
+// Define styles
+$fontStyleName = 'myOwnStyle';
+$phpWord->addFontStyle($fontStyleName, array('color' => 'FF0000'));
-// Style definition
+$paragraphStyleName = 'P-Style';
+$phpWord->addParagraphStyle($paragraphStyleName, array('spaceAfter' => 95));
-$phpWord->addFontStyle('myOwnStyle', array('color' => 'FF0000'));
-$phpWord->addParagraphStyle('P-Style', array('spaceAfter' => 95));
+$multilevelNumberingStyleName = 'multilevel';
$phpWord->addNumberingStyle(
- 'multilevel',
+ $multilevelNumberingStyleName,
array(
'type' => 'multilevel',
'levels' => array(
@@ -22,56 +23,59 @@
),
)
);
-$predefinedMultilevel = array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED);
-// Lists
+$predefinedMultilevelStyle = array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED);
+
+// New section
+$section = $phpWord->addSection();
-$section->addText(htmlspecialchars('Multilevel list.'));
-$section->addListItem(htmlspecialchars('List Item I'), 0, null, 'multilevel');
-$section->addListItem(htmlspecialchars('List Item I.a'), 1, null, 'multilevel');
-$section->addListItem(htmlspecialchars('List Item I.b'), 1, null, 'multilevel');
-$section->addListItem(htmlspecialchars('List Item II'), 0, null, 'multilevel');
-$section->addListItem(htmlspecialchars('List Item II.a'), 1, null, 'multilevel');
-$section->addListItem(htmlspecialchars('List Item III'), 0, null, 'multilevel');
+// Lists
+$section->addText('Multilevel list.');
+$section->addListItem('List Item I', 0, null, $multilevelNumberingStyleName);
+$section->addListItem('List Item I.a', 1, null, $multilevelNumberingStyleName);
+$section->addListItem('List Item I.b', 1, null, $multilevelNumberingStyleName);
+$section->addListItem('List Item II', 0, null, $multilevelNumberingStyleName);
+$section->addListItem('List Item II.a', 1, null, $multilevelNumberingStyleName);
+$section->addListItem('List Item III', 0, null, $multilevelNumberingStyleName);
$section->addTextBreak(2);
-$section->addText(htmlspecialchars('Basic simple bulleted list.'));
-$section->addListItem(htmlspecialchars('List Item 1'));
-$section->addListItem(htmlspecialchars('List Item 2'));
-$section->addListItem(htmlspecialchars('List Item 3'));
+$section->addText('Basic simple bulleted list.');
+$section->addListItem('List Item 1');
+$section->addListItem('List Item 2');
+$section->addListItem('List Item 3');
$section->addTextBreak(2);
-$section->addText(htmlspecialchars('Continue from multilevel list above.'));
-$section->addListItem(htmlspecialchars('List Item IV'), 0, null, 'multilevel');
-$section->addListItem(htmlspecialchars('List Item IV.a'), 1, null, 'multilevel');
+$section->addText('Continue from multilevel list above.');
+$section->addListItem('List Item IV', 0, null, $multilevelNumberingStyleName);
+$section->addListItem('List Item IV.a', 1, null, $multilevelNumberingStyleName);
$section->addTextBreak(2);
-$section->addText(htmlspecialchars('Multilevel predefined list.'));
-$section->addListItem(htmlspecialchars('List Item 1'), 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style');
-$section->addListItem(htmlspecialchars('List Item 2'), 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style');
-$section->addListItem(htmlspecialchars('List Item 3'), 1, 'myOwnStyle', $predefinedMultilevel, 'P-Style');
-$section->addListItem(htmlspecialchars('List Item 4'), 1, 'myOwnStyle', $predefinedMultilevel, 'P-Style');
-$section->addListItem(htmlspecialchars('List Item 5'), 2, 'myOwnStyle', $predefinedMultilevel, 'P-Style');
-$section->addListItem(htmlspecialchars('List Item 6'), 1, 'myOwnStyle', $predefinedMultilevel, 'P-Style');
-$section->addListItem(htmlspecialchars('List Item 7'), 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style');
+$section->addText('Multilevel predefined list.');
+$section->addListItem('List Item 1', 0, $fontStyleName, $predefinedMultilevelStyle, $paragraphStyleName);
+$section->addListItem('List Item 2', 0, $fontStyleName, $predefinedMultilevelStyle, $paragraphStyleName);
+$section->addListItem('List Item 3', 1, $fontStyleName, $predefinedMultilevelStyle, $paragraphStyleName);
+$section->addListItem('List Item 4', 1, $fontStyleName, $predefinedMultilevelStyle, $paragraphStyleName);
+$section->addListItem('List Item 5', 2, $fontStyleName, $predefinedMultilevelStyle, $paragraphStyleName);
+$section->addListItem('List Item 6', 1, $fontStyleName, $predefinedMultilevelStyle, $paragraphStyleName);
+$section->addListItem('List Item 7', 0, $fontStyleName, $predefinedMultilevelStyle, $paragraphStyleName);
$section->addTextBreak(2);
-$section->addText(htmlspecialchars('List with inline formatting.'));
+$section->addText('List with inline formatting.');
$listItemRun = $section->addListItemRun();
-$listItemRun->addText(htmlspecialchars('List item 1'));
-$listItemRun->addText(htmlspecialchars(' in bold'), array('bold' => true));
+$listItemRun->addText('List item 1');
+$listItemRun->addText(' in bold', array('bold' => true));
$listItemRun = $section->addListItemRun();
-$listItemRun->addText(htmlspecialchars('List item 2'));
-$listItemRun->addText(htmlspecialchars(' in italic'), array('italic' => true));
+$listItemRun->addText('List item 2');
+$listItemRun->addText(' in italic', array('italic' => true));
$listItemRun = $section->addListItemRun();
-$listItemRun->addText(htmlspecialchars('List item 3'));
-$listItemRun->addText(htmlspecialchars(' underlined'), array('underline' => 'dash'));
+$listItemRun->addText('List item 3');
+$listItemRun->addText(' underlined', array('underline' => 'dash'));
$section->addTextBreak(2);
// Numbered heading
-
+$headingNumberingStyleName = 'headingNumbering';
$phpWord->addNumberingStyle(
- 'headingNumbering',
+ $headingNumberingStyleName,
array('type' => 'multilevel',
'levels' => array(
array('pStyle' => 'Heading1', 'format' => 'decimal', 'text' => '%1'),
@@ -80,13 +84,13 @@
),
)
);
-$phpWord->addTitleStyle(1, array('size' => 16), array('numStyle' => 'headingNumbering', 'numLevel' => 0));
-$phpWord->addTitleStyle(2, array('size' => 14), array('numStyle' => 'headingNumbering', 'numLevel' => 1));
-$phpWord->addTitleStyle(3, array('size' => 12), array('numStyle' => 'headingNumbering', 'numLevel' => 2));
+$phpWord->addTitleStyle(1, array('size' => 16), array('numStyle' => $headingNumberingStyleName, 'numLevel' => 0));
+$phpWord->addTitleStyle(2, array('size' => 14), array('numStyle' => $headingNumberingStyleName, 'numLevel' => 1));
+$phpWord->addTitleStyle(3, array('size' => 12), array('numStyle' => $headingNumberingStyleName, 'numLevel' => 2));
-$section->addTitle(htmlspecialchars('Heading 1'), 1);
-$section->addTitle(htmlspecialchars('Heading 2'), 2);
-$section->addTitle(htmlspecialchars('Heading 3'), 3);
+$section->addTitle('Heading 1', 1);
+$section->addTitle('Heading 2', 2);
+$section->addTitle('Heading 3', 3);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php
index dd06670e65..86c7973bc1 100644
--- a/samples/Sample_15_Link.php
+++ b/samples/Sample_15_Link.php
@@ -5,20 +5,22 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-// Begin code
+// Define styles
+$linkFontStyleName = 'myOwnLinStyle';
+$phpWord->addLinkStyle($linkFontStyleName, array('bold' => true, 'color' => '808000'));
+
+// New section
$section = $phpWord->addSection();
// Add hyperlink elements
$section->addLink(
- 'http://www.google.com',
- htmlspecialchars('Best search engine'),
+ 'https://github.com/PHPOffice/PHPWord',
+ 'PHPWord on GitHub',
array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)
);
$section->addTextBreak(2);
-
-$phpWord->addLinkStyle('myOwnLinkStyle', array('bold' => true, 'color' => '808000'));
-$section->addLink('http://www.bing.com', null, 'myOwnLinkStyle');
-$section->addLink('http://www.yahoo.com', null, 'myOwnLinkStyle');
+$section->addLink('http://www.bing.com', null, $linkFontStyleName);
+$section->addLink('http://www.yahoo.com', null, $linkFontStyleName);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php
index 2a216c2378..8b05b9e8ac 100644
--- a/samples/Sample_16_Object.php
+++ b/samples/Sample_16_Object.php
@@ -7,7 +7,7 @@
// Begin code
$section = $phpWord->addSection();
-$section->addText(htmlspecialchars('You can open this OLE object by double clicking on the icon:'));
+$section->addText('You can open this OLE object by double clicking on the icon:');
$section->addTextBreak(2);
$section->addObject('resources/_sheet.xls');
diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php
index 8f8889b83c..306595eb39 100644
--- a/samples/Sample_17_TitleTOC.php
+++ b/samples/Sample_17_TitleTOC.php
@@ -5,66 +5,63 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-// Begin code
+// New section
$section = $phpWord->addSection();
-// Define the TOC font style
-$fontStyle = array('spaceAfter' => 60, 'size' => 12);
-$fontStyle2 = array('size' => 10);
-
-// Add title styles
+// Define styles
+$fontStyle12 = array('spaceAfter' => 60, 'size' => 12);
+$fontStyle10 = array('size' => 10);
$phpWord->addTitleStyle(1, array('size' => 20, 'color' => '333333', 'bold' => true));
$phpWord->addTitleStyle(2, array('size' => 16, 'color' => '666666'));
$phpWord->addTitleStyle(3, array('size' => 14, 'italic' => true));
$phpWord->addTitleStyle(4, array('size' => 12));
// Add text elements
-$section->addText(htmlspecialchars('Table of contents 1'));
+$section->addText('Table of contents 1');
$section->addTextBreak(2);
// Add TOC #1
-$toc = $section->addTOC($fontStyle);
+$toc = $section->addTOC($fontStyle12);
$section->addTextBreak(2);
// Filler
-$section->addText(htmlspecialchars('Text between TOC'));
+$section->addText('Text between TOC');
$section->addTextBreak(2);
// Add TOC #1
-$section->addText(htmlspecialchars('Table of contents 2'));
+$section->addText('Table of contents 2');
$section->addTextBreak(2);
-$toc2 = $section->addTOC($fontStyle2);
+$toc2 = $section->addTOC($fontStyle10);
$toc2->setMinDepth(2);
$toc2->setMaxDepth(3);
-
// Add Titles
$section->addPageBreak();
-$section->addTitle(htmlspecialchars('Foo & Bar'), 1);
-$section->addText(htmlspecialchars('Some text...'));
+$section->addTitle('Foo n Bar', 1);
+$section->addText('Some text...');
$section->addTextBreak(2);
-$section->addTitle(htmlspecialchars('I am a Subtitle of Title 1'), 2);
+$section->addTitle('I am a Subtitle of Title 1', 2);
$section->addTextBreak(2);
-$section->addText(htmlspecialchars('Some more text...'));
+$section->addText('Some more text...');
$section->addTextBreak(2);
-$section->addTitle(htmlspecialchars('Another Title (Title 2)'), 1);
-$section->addText(htmlspecialchars('Some text...'));
+$section->addTitle('Another Title (Title 2)', 1);
+$section->addText('Some text...');
$section->addPageBreak();
-$section->addTitle(htmlspecialchars('I am Title 3'), 1);
-$section->addText(htmlspecialchars('And more text...'));
+$section->addTitle('I am Title 3', 1);
+$section->addText('And more text...');
$section->addTextBreak(2);
-$section->addTitle(htmlspecialchars('I am a Subtitle of Title 3'), 2);
-$section->addText(htmlspecialchars('Again and again, more text...'));
-$section->addTitle(htmlspecialchars('Subtitle 3.1.1'), 3);
-$section->addText(htmlspecialchars('Text'));
-$section->addTitle(htmlspecialchars('Subtitle 3.1.1.1'), 4);
-$section->addText(htmlspecialchars('Text'));
-$section->addTitle(htmlspecialchars('Subtitle 3.1.1.2'), 4);
-$section->addText(htmlspecialchars('Text'));
-$section->addTitle(htmlspecialchars('Subtitle 3.1.2'), 3);
-$section->addText(htmlspecialchars('Text'));
+$section->addTitle('I am a Subtitle of Title 3', 2);
+$section->addText('Again and again, more text...');
+$section->addTitle('Subtitle 3.1.1', 3);
+$section->addText('Text');
+$section->addTitle('Subtitle 3.1.1.1', 4);
+$section->addText('Text');
+$section->addTitle('Subtitle 3.1.1.2', 4);
+$section->addText('Text');
+$section->addTitle('Subtitle 3.1.2', 3);
+$section->addText('Text');
echo date('H:i:s'), ' Note: Please refresh TOC manually.', EOL;
diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php
index f630bdf22d..dbab2b7f26 100644
--- a/samples/Sample_18_Watermark.php
+++ b/samples/Sample_18_Watermark.php
@@ -6,11 +6,10 @@
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code
-
$section = $phpWord->addSection();
$header = $section->addHeader();
$header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55));
-$section->addText(htmlspecialchars('The header reference to the current section includes a watermark image.'));
+$section->addText('The header reference to the current section includes a watermark image.');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php
index fc0e5419b0..17e2b1cbd7 100644
--- a/samples/Sample_19_TextBreak.php
+++ b/samples/Sample_19_TextBreak.php
@@ -5,25 +5,31 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-// Begin code
-$fontStyle = array('size' => 24);
-$paragraphStyle = array('spacing' => 240, 'size' => 24);
-$phpWord->addFontStyle('fontStyle', array('size' => 9));
-$phpWord->addParagraphStyle('paragraphStyle', array('spacing' => 480));
-$fontStyle = array('size' => 24);
+// Define styles
+$fontStyle24 = array('size' => 24);
+$paragraphStyle24 = array('spacing' => 240, 'size' => 24);
+
+$fontStyleName = 'fontStyle';
+$phpWord->addFontStyle($fontStyleName, array('size' => 9));
+
+$paragraphStyleName = 'paragraphStyle';
+$phpWord->addParagraphStyle($paragraphStyleName, array('spacing' => 480));
+
+// New section
$section = $phpWord->addSection();
-$section->addText(htmlspecialchars('Text break with no style:'));
+
+$section->addText('Text break with no style:');
$section->addTextBreak();
-$section->addText(htmlspecialchars('Text break with defined font style:'));
-$section->addTextBreak(1, 'fontStyle');
-$section->addText(htmlspecialchars('Text break with defined paragraph style:'));
-$section->addTextBreak(1, null, 'paragraphStyle');
-$section->addText(htmlspecialchars('Text break with inline font style:'));
-$section->addTextBreak(1, $fontStyle);
-$section->addText(htmlspecialchars('Text break with inline paragraph style:'));
-$section->addTextBreak(1, null, $paragraphStyle);
-$section->addText(htmlspecialchars('Done.'));
+$section->addText('Text break with defined font style:');
+$section->addTextBreak(1, $fontStyleName);
+$section->addText('Text break with defined paragraph style:');
+$section->addTextBreak(1, null, $paragraphStyleName);
+$section->addText('Text break with inline font style:');
+$section->addTextBreak(1, $fontStyle24);
+$section->addText('Text break with inline paragraph style:');
+$section->addTextBreak(1, null, $paragraphStyle24);
+$section->addText('Done.');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_20_BGColor.php b/samples/Sample_20_BGColor.php
index ebee8544fa..628ae8902e 100644
--- a/samples/Sample_20_BGColor.php
+++ b/samples/Sample_20_BGColor.php
@@ -4,17 +4,16 @@
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
+
+// New section
$section = $phpWord->addSection();
$section->addText(
- htmlspecialchars('This is some text highlighted using fgColor (limited to 15 colors) '),
+ 'This is some text highlighted using fgColor (limited to 15 colors)',
array('fgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)
);
-$section->addText(
- htmlspecialchars('This one uses bgColor and is using hex value (0xfbbb10)'),
- array('bgColor' => 'fbbb10')
-);
-$section->addText(htmlspecialchars('Compatible with font colors'), array('color' => '0000ff', 'bgColor' => 'fbbb10'));
+$section->addText('This one uses bgColor and is using hex value (0xfbbb10)', array('bgColor' => 'fbbb10'));
+$section->addText('Compatible with font colors', array('color' => '0000ff', 'bgColor' => 'fbbb10'));
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_21_TableRowRules.php b/samples/Sample_21_TableRowRules.php
index df3162c33c..ca33de3bcd 100644
--- a/samples/Sample_21_TableRowRules.php
+++ b/samples/Sample_21_TableRowRules.php
@@ -4,30 +4,24 @@
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
+
+// New section
$section = $phpWord->addSection();
-$section->addText(htmlspecialchars('By default, when you insert an image, it adds a textbreak after its content.'));
+$section->addText('By default, when you insert an image, it adds a textbreak after its content.');
+$section->addText('If we want a simple border around an image, we wrap the image inside a table->row->cell');
$section->addText(
- htmlspecialchars('If we want a simple border around an image, we wrap the image inside a table->row->cell')
-);
-$section->addText(
- htmlspecialchars(
- 'On the image with the red border, even if we set the row height to the height of the image, '
- . 'the textbreak is still there:'
- )
+ 'On the image with the red border, even if we set the row height to the height of the image, '
+ . 'the textbreak is still there:'
);
$table1 = $section->addTable(array('cellMargin' => 0, 'cellMarginRight' => 0, 'cellMarginBottom' => 0, 'cellMarginLeft' => 0));
$table1->addRow(3750);
$cell1 = $table1->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => 'ff0000'));
-$cell1->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'align' => 'center'));
+$cell1->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
$section->addTextBreak();
-$section->addText(
- htmlspecialchars(
- "But if we set the rowStyle 'exactHeight' to true, the real row height is used, removing the textbreak:"
- )
-);
+$section->addText("But if we set the rowStyle 'exactHeight' to true, the real row height is used, removing the textbreak:");
$table2 = $section->addTable(
array(
@@ -39,13 +33,11 @@
);
$table2->addRow(3750, array('exactHeight' => true));
$cell2 = $table2->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => '00ff00'));
-$cell2->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'align' => 'center'));
+$cell2->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
$section->addTextBreak();
-$section->addText(
- htmlspecialchars('In this example, image is 250px height. Rows are calculated in twips, and 1px = 15twips.')
-);
-$section->addText(htmlspecialchars('So: $' . "table2->addRow(3750, array('exactHeight'=>true));"));
+$section->addText('In this example, image is 250px height. Rows are calculated in twips, and 1px = 15twips.');
+$section->addText('So: $' . "table2->addRow(3750, array('exactHeight'=>true));");
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_22_CheckBox.php b/samples/Sample_22_CheckBox.php
index b5d4a7a5a8..5a2ac3e2cc 100644
--- a/samples/Sample_22_CheckBox.php
+++ b/samples/Sample_22_CheckBox.php
@@ -5,14 +5,16 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
+// New section
$section = $phpWord->addSection();
-$section->addText(htmlspecialchars('Check box in section'));
-$section->addCheckBox('chkBox1', htmlspecialchars('Checkbox 1'));
-$section->addText(htmlspecialchars('Check box in table cell'));
+
+$section->addText('Check box in section');
+$section->addCheckBox('chkBox1', 'Checkbox 1');
+$section->addText('Check box in table cell');
$table = $section->addTable();
$table->addRow();
$cell = $table->addCell();
-$cell->addCheckBox('chkBox2', htmlspecialchars('Checkbox 2'));
+$cell->addCheckBox('chkBox2', 'Checkbox 2');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_25_TextBox.php b/samples/Sample_25_TextBox.php
index afeb863d1c..7655e25f9d 100644
--- a/samples/Sample_25_TextBox.php
+++ b/samples/Sample_25_TextBox.php
@@ -5,40 +5,41 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
+// New section
$section = $phpWord->addSection();
// In section
$textbox = $section->addTextBox(
array(
- 'align' => 'center',
+ 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER,
'width' => 400,
'height' => 150,
'borderSize' => 1,
'borderColor' => '#FF0000',
)
);
-$textbox->addText(htmlspecialchars('Text box content in section.'));
-$textbox->addText(htmlspecialchars('Another line.'));
+$textbox->addText('Text box content in section.');
+$textbox->addText('Another line.');
$cell = $textbox->addTable()->addRow()->addCell();
-$cell->addText(htmlspecialchars('Table inside textbox'));
+$cell->addText('Table inside textbox');
// Inside table
$section->addTextBreak(2);
$cell = $section->addTable()->addRow()->addCell(300);
$textbox = $cell->addTextBox(array('borderSize' => 1, 'borderColor' => '#0000FF', 'innerMargin' => 100));
-$textbox->addText(htmlspecialchars('Textbox inside table'));
+$textbox->addText('Textbox inside table');
// Inside header with textrun
$header = $section->addHeader();
$textbox = $header->addTextBox(array('width' => 600, 'borderSize' => 1, 'borderColor' => '#00FF00'));
$textrun = $textbox->addTextRun();
-$textrun->addText(htmlspecialchars('TextBox in header. TextBox can contain a TextRun '));
-$textrun->addText(htmlspecialchars('with bold text'), array('bold' => true));
-$textrun->addText(htmlspecialchars(', '));
-$textrun->addLink('http://www.google.com', htmlspecialchars('link'));
-$textrun->addText(htmlspecialchars(', and image '));
+$textrun->addText('TextBox in header. TextBox can contain a TextRun ');
+$textrun->addText('with bold text', array('bold' => true));
+$textrun->addText(', ');
+$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub');
+$textrun->addText(', and image ');
$textrun->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18));
-$textrun->addText(htmlspecialchars('.'));
+$textrun->addText('.');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_27_Field.php b/samples/Sample_27_Field.php
index 9bdbef8243..5774789561 100644
--- a/samples/Sample_27_Field.php
+++ b/samples/Sample_27_Field.php
@@ -5,24 +5,24 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-// Begin code
+// New section
$section = $phpWord->addSection();
// Add Field elements
// See Element/Field.php for all options
-$section->addText(htmlspecialchars('Date field:'));
+$section->addText('Date field:');
$section->addField('DATE', array('dateformat' => 'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat'));
-$section->addText(htmlspecialchars('Page field:'));
+$section->addText('Page field:');
$section->addField('PAGE', array('format' => 'ArabicDash'));
-$section->addText(htmlspecialchars('Number of pages field:'));
+$section->addText('Number of pages field:');
$section->addField('NUMPAGES', array('format' => 'Arabic', 'numformat' => '0,00'), array('PreserveFormat'));
-$textrun = $section->addTextRun(array('align' => 'center'));
-$textrun->addText(htmlspecialchars('This is the date of lunar calendar '));
+$textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
+$textrun->addText('This is the date of lunar calendar ');
$textrun->addField('DATE', array('dateformat' => 'd-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar'));
-$textrun->addText(htmlspecialchars(' written in a textrun.'));
+$textrun->addText(' written in a textrun.');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_29_Line.php b/samples/Sample_29_Line.php
index 8bb192cfc8..030308eef1 100644
--- a/samples/Sample_29_Line.php
+++ b/samples/Sample_29_Line.php
@@ -5,12 +5,12 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-// Begin code
+// New section
$section = $phpWord->addSection();
// Add Line elements
// See Element/Line.php for all options
-$section->addText(htmlspecialchars('Horizontal Line (Inline style):'));
+$section->addText('Horizontal Line (Inline style):');
$section->addLine(
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
@@ -18,7 +18,7 @@
'positioning' => 'absolute',
)
);
-$section->addText(htmlspecialchars('Vertical Line (Inline style):'));
+$section->addText('Vertical Line (Inline style):');
$section->addLine(
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
@@ -29,7 +29,7 @@
// Two text break
$section->addTextBreak(1);
-$section->addText(htmlspecialchars('Positioned Line (red):'));
+$section->addText('Positioned Line (red):');
$section->addLine(
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
@@ -44,7 +44,7 @@
)
);
-$section->addText(htmlspecialchars('Horizontal Formatted Line'));
+$section->addText('Horizontal Formatted Line');
$section->addLine(
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15),
diff --git a/samples/Sample_31_Shape.php b/samples/Sample_31_Shape.php
index 3df71b4cc8..33628fcea4 100644
--- a/samples/Sample_31_Shape.php
+++ b/samples/Sample_31_Shape.php
@@ -3,14 +3,16 @@
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
-
$phpWord = new \PhpOffice\PhpWord\PhpWord();
-$phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true));
+// New section
$section = $phpWord->addSection();
+// Define styles
+$phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true));
+
// Arc
-$section->addTitle(htmlspecialchars('Arc'), 1);
+$section->addTitle('Arc', 1);
$section->addShape(
'arc',
array(
@@ -21,7 +23,7 @@
);
// Curve
-$section->addTitle(htmlspecialchars('Curve'), 1);
+$section->addTitle('Curve', 1);
$section->addShape(
'curve',
array(
@@ -38,7 +40,7 @@
);
// Line
-$section->addTitle(htmlspecialchars('Line'), 1);
+$section->addTitle('Line', 1);
$section->addShape(
'line',
array(
@@ -54,7 +56,7 @@
);
// Polyline
-$section->addTitle(htmlspecialchars('Polyline'), 1);
+$section->addTitle('Polyline', 1);
$section->addShape(
'polyline',
array(
@@ -64,7 +66,7 @@
);
// Rectangle
-$section->addTitle(htmlspecialchars('Rectangle'), 1);
+$section->addTitle('Rectangle', 1);
$section->addShape(
'rect',
array(
@@ -77,7 +79,7 @@
);
// Oval
-$section->addTitle(htmlspecialchars('Oval'), 1);
+$section->addTitle('Oval', 1);
$section->addShape(
'oval',
array(
diff --git a/samples/Sample_32_Chart.php b/samples/Sample_32_Chart.php
index b61a646fde..2c6458ca4a 100644
--- a/samples/Sample_32_Chart.php
+++ b/samples/Sample_32_Chart.php
@@ -5,14 +5,15 @@
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
-
$phpWord = new \PhpOffice\PhpWord\PhpWord();
+
+// Define styles
$phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240));
$phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240));
// 2D charts
$section = $phpWord->addSection();
-$section->addTitle(htmlspecialchars('2D charts'), 1);
+$section->addTitle('2D charts', 1);
$section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous'));
$chartTypes = array('pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar');
@@ -38,7 +39,7 @@
// 3D charts
$section = $phpWord->addSection(array('breakType' => 'continuous'));
-$section->addTitle(htmlspecialchars('3D charts'), 1);
+$section->addTitle('3D charts', 1);
$section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous'));
$chartTypes = array('pie', 'bar', 'column', 'line', 'area');
diff --git a/samples/Sample_33_FormField.php b/samples/Sample_33_FormField.php
index 9f356810dc..a855d42a02 100644
--- a/samples/Sample_33_FormField.php
+++ b/samples/Sample_33_FormField.php
@@ -6,18 +6,19 @@
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->getProtection()->setEditing('forms');
+// New section
$section = $phpWord->addSection();
$textrun = $section->addTextRun();
-$textrun->addText(htmlspecialchars('Form fields can be added in a text run and can be in form of textinput '));
+$textrun->addText('Form fields can be added in a text run and can be in form of textinput ');
$textrun->addFormField('textinput')->setName('MyTextBox');
-$textrun->addText(htmlspecialchars(', checkbox '));
+$textrun->addText(', checkbox ');
$textrun->addFormField('checkbox')->setDefault(true);
-$textrun->addText(htmlspecialchars(', or dropdown '));
+$textrun->addText(', or dropdown ');
$textrun->addFormField('dropdown')->setEntries(array('Choice 1', 'Choice 2', 'Choice 3'));
-$textrun->addText(htmlspecialchars('. You have to set document protection to "forms" to enable dropdown.'));
+$textrun->addText('. You have to set document protection to "forms" to enable dropdown.');
-$section->addText(htmlspecialchars('They can also be added as a stand alone paragraph.'));
+$section->addText('They can also be added as a stand alone paragraph.');
$section->addFormField('textinput')->setValue('Your name');
// Save file
diff --git a/samples/Sample_34_SDT.php b/samples/Sample_34_SDT.php
index 19ac42fe34..a50422796e 100644
--- a/samples/Sample_34_SDT.php
+++ b/samples/Sample_34_SDT.php
@@ -5,18 +5,19 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
+// New section
$section = $phpWord->addSection();
$textrun = $section->addTextRun();
-$textrun->addText(htmlspecialchars('Combobox: '));
+$textrun->addText('Combobox: ');
$textrun->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
$textrun = $section->addTextRun();
-$textrun->addText(htmlspecialchars('Date: '));
+$textrun->addText('Date: ');
$textrun->addSDT('date');
$textrun = $section->addTextRun();
-$textrun->addText(htmlspecialchars('Drop down list: '));
+$textrun->addText('Drop down list: ');
$textrun->addSDT('dropDownList')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
// Save file
diff --git a/samples/Sample_35_InternalLink.php b/samples/Sample_35_InternalLink.php
index 1b907f8724..5ab7d9b4d9 100644
--- a/samples/Sample_35_InternalLink.php
+++ b/samples/Sample_35_InternalLink.php
@@ -6,13 +6,13 @@
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
-$section->addTitle(htmlspecialchars('This is page 1'), 1);
+$section->addTitle('This is page 1', 1);
$linkIsInternal = true;
-$section->addLink('MyBookmark', htmlspecialchars('Take me to page 3'), null, null, $linkIsInternal);
+$section->addLink('MyBookmark', 'Take me to page 3', null, null, $linkIsInternal);
$section->addPageBreak();
-$section->addTitle(htmlspecialchars('This is page 2'), 1);
+$section->addTitle('This is page 2', 1);
$section->addPageBreak();
-$section->addTitle(htmlspecialchars('This is page 3'), 1);
+$section->addTitle('This is page 3', 1);
$section->addBookmark('MyBookmark');
// Save file
diff --git a/samples/Sample_36_RTL.php b/samples/Sample_36_RTL.php
index ec326ae025..615557d78e 100644
--- a/samples/Sample_36_RTL.php
+++ b/samples/Sample_36_RTL.php
@@ -5,12 +5,14 @@
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
+// New section
$section = $phpWord->addSection();
+
$textrun = $section->addTextRun();
-$textrun->addText(htmlspecialchars('This is a Left to Right paragraph.'));
+$textrun->addText('This is a Left to Right paragraph.');
-$textrun = $section->addTextRun(array('align' => 'right'));
-$textrun->addText(htmlspecialchars('سلام این یک پاراگراف راست به چپ است'), array('rtl' => true));
+$textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END));
+$textrun->addText('سلام این یک پاراگراف راست به چپ است', array('rtl' => true));
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_Footer.php b/samples/Sample_Footer.php
index 95ac693fc3..2d89bfd253 100644
--- a/samples/Sample_Footer.php
+++ b/samples/Sample_Footer.php
@@ -1,7 +1,4 @@
');
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
define('IS_INDEX', SCRIPT_FILENAME == 'index');
-Autoloader::register();
Settings::loadConfig();
// Set writers
@@ -26,6 +20,9 @@
$writers['PDF'] = null;
}
+// Turn output escaping on
+Settings::setOutputEscapingEnabled(true);
+
// Return to the caller script when runs by CLI
if (CLI) {
return;
diff --git a/samples/resources/Sample_28_ReadRTF.rtf b/samples/resources/Sample_28_ReadRTF.rtf
index 6f9ac0f8b8..ccccc0e707 100644
--- a/samples/resources/Sample_28_ReadRTF.rtf
+++ b/samples/resources/Sample_28_ReadRTF.rtf
@@ -16,6 +16,6 @@
\pard\nowidctlpar\qc\sa100{\cf0\f0\fs32\b\i I am styled by both font and paragraph style.}\par
\pard\nowidctlpar{\cf1\f1\fs40\b\i\ul\strike\super I am inline styled.}\par
\par
-{\field {\*\fldinst {HYPERLINK "http://www.google.com"}}{\fldrslt {Google}}}\par
+{\field {\*\fldinst {HYPERLINK "https://github.com/PHPOffice/PHPWord"}}{\fldrslt {PHPWord on GitHub}}}\par
\par
}
\ No newline at end of file
diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php
deleted file mode 100644
index 68da845de3..0000000000
--- a/src/PhpWord/Autoloader.php
+++ /dev/null
@@ -1,58 +0,0 @@
-addImage($src, $style);
- }
-
/**
* Create textrun element
*
+ * @deprecated 0.10.0
+ *
* @param mixed $paragraphStyle
+ *
* @return \PhpOffice\PhpWord\Element\TextRun
- * @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function createTextRun($paragraphStyle = null)
@@ -274,9 +267,12 @@ public function createTextRun($paragraphStyle = null)
/**
* Create footnote element
*
+ * @deprecated 0.10.0
+ *
* @param mixed $paragraphStyle
+ *
* @return \PhpOffice\PhpWord\Element\Footnote
- * @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function createFootnote($paragraphStyle = null)
diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php
index 99a7a1becc..b0ed8ae27a 100644
--- a/src/PhpWord/Element/AbstractElement.php
+++ b/src/PhpWord/Element/AbstractElement.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -19,7 +19,6 @@
use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Style;
/**
* Element abstract class
@@ -378,8 +377,11 @@ protected function setNewStyle($styleObject, $styleValue = null, $returnObject =
* @param mixed $value
* @param array $enum
* @param mixed $default
+ *
* @return mixed
+ *
* @throws \InvalidArgumentException
+ *
* @todo Merge with the same method in AbstractStyle
*/
protected function setEnumVal($value = null, $enum = array(), $default = null)
diff --git a/src/PhpWord/Element/Bookmark.php b/src/PhpWord/Element/Bookmark.php
index d5b8ff6fba..c865893fad 100644
--- a/src/PhpWord/Element/Bookmark.php
+++ b/src/PhpWord/Element/Bookmark.php
@@ -11,14 +11,13 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\PhpWord\Shared\String;
-use PhpOffice\PhpWord\Style;
+use PhpOffice\Common\Text as CommonText;
/**
* Bookmark element
@@ -47,7 +46,7 @@ class Bookmark extends AbstractElement
public function __construct($name)
{
- $this->name = String::toUTF8($name);
+ $this->name = CommonText::toUTF8($name);
return $this;
}
diff --git a/src/PhpWord/Element/Cell.php b/src/PhpWord/Element/Cell.php
index cac37a7804..28e517fd83 100644
--- a/src/PhpWord/Element/Cell.php
+++ b/src/PhpWord/Element/Cell.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Chart.php b/src/PhpWord/Element/Chart.php
index 66c59ff52c..f98c1d7426 100644
--- a/src/PhpWord/Element/Chart.php
+++ b/src/PhpWord/Element/Chart.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php
index d3b2a3c6f4..3fc578ef37 100644
--- a/src/PhpWord/Element/CheckBox.php
+++ b/src/PhpWord/Element/CheckBox.php
@@ -11,13 +11,13 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\PhpWord\Shared\String;
+use PhpOffice\Common\Text as CommonText;
/**
* Check box element
@@ -56,7 +56,7 @@ public function __construct($name = null, $text = null, $fontStyle = null, $para
*/
public function setName($name)
{
- $this->name = String::toUTF8($name);
+ $this->name = CommonText::toUTF8($name);
return $this;
}
diff --git a/src/PhpWord/Element/Endnote.php b/src/PhpWord/Element/Endnote.php
index 1000055520..2d8e473179 100644
--- a/src/PhpWord/Element/Endnote.php
+++ b/src/PhpWord/Element/Endnote.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Field.php b/src/PhpWord/Element/Field.php
index 1eaa6f242f..48dc1d2eba 100644
--- a/src/PhpWord/Element/Field.php
+++ b/src/PhpWord/Element/Field.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -94,7 +94,9 @@ public function __construct($type = null, $properties = array(), $options = arra
* Set Field type
*
* @param string $type
+ *
* @return string
+ *
* @throws \InvalidArgumentException
*/
public function setType($type = null)
@@ -123,7 +125,9 @@ public function getType()
* Set Field properties
*
* @param array $properties
+ *
* @return self
+ *
* @throws \InvalidArgumentException
*/
public function setProperties($properties = array())
@@ -153,7 +157,9 @@ public function getProperties()
* Set Field options
*
* @param array $options
+ *
* @return self
+ *
* @throws \InvalidArgumentException
*/
public function setOptions($options = array())
diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php
index 8e19eaf7db..01c6d25c9e 100644
--- a/src/PhpWord/Element/Footer.php
+++ b/src/PhpWord/Element/Footer.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php
index 162a703ed5..73350bb785 100644
--- a/src/PhpWord/Element/Footnote.php
+++ b/src/PhpWord/Element/Footnote.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +20,7 @@
use PhpOffice\PhpWord\Style\Paragraph;
/**
- * Footnote element
+ * @codeCoverageIgnore
*/
class Footnote extends AbstractContainer
{
@@ -67,9 +67,9 @@ public function getParagraphStyle()
/**
* Get Footnote Reference ID
*
- * @return int
* @deprecated 0.10.0
- * @codeCoverageIgnore
+ *
+ * @return int
*/
public function getReferenceId()
{
@@ -79,9 +79,9 @@ public function getReferenceId()
/**
* Set Footnote Reference ID
*
- * @param int $rId
* @deprecated 0.10.0
- * @codeCoverageIgnore
+ *
+ * @param int $rId
*/
public function setReferenceId($rId)
{
diff --git a/src/PhpWord/Element/FormField.php b/src/PhpWord/Element/FormField.php
index 7bd61be1e7..c7cb44d240 100644
--- a/src/PhpWord/Element/FormField.php
+++ b/src/PhpWord/Element/FormField.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Header.php b/src/PhpWord/Element/Header.php
index feaa86e81a..d4afdb867f 100644
--- a/src/PhpWord/Element/Header.php
+++ b/src/PhpWord/Element/Header.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php
index cab2527a4e..2cce610d94 100644
--- a/src/PhpWord/Element/Image.php
+++ b/src/PhpWord/Element/Image.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -126,6 +126,7 @@ class Image extends AbstractElement
* @param string $source
* @param mixed $style
* @param boolean $watermark
+ *
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
*/
@@ -365,7 +366,9 @@ public function getImageStringData($base64 = false)
* Check memory image, supported type, image functions, and proportional width/height.
*
* @param string $source
+ *
* @return void
+ *
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
*/
@@ -425,7 +428,9 @@ private function setSourceType($source)
* @since 0.12.0 Throws CreateTemporaryFileException.
*
* @param string $source
+ *
* @return array|null
+ *
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
*/
private function getArchiveImageSize($source)
@@ -517,6 +522,7 @@ private function setProportionalSize($actualWidth, $actualHeight)
* Get is watermark
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getIsWatermark()
@@ -528,6 +534,7 @@ public function getIsWatermark()
* Get is memory image
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getIsMemImage()
diff --git a/src/PhpWord/Element/Line.php b/src/PhpWord/Element/Line.php
index b76ac4fb32..3e94a3a6bf 100644
--- a/src/PhpWord/Element/Line.php
+++ b/src/PhpWord/Element/Line.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php
index 9d0eb76662..4a72e167f0 100644
--- a/src/PhpWord/Element/Link.php
+++ b/src/PhpWord/Element/Link.php
@@ -11,13 +11,13 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\PhpWord\Shared\String;
+use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
@@ -78,8 +78,8 @@ class Link extends AbstractElement
*/
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
{
- $this->source = String::toUTF8($source);
- $this->text = is_null($text) ? $this->source : String::toUTF8($text);
+ $this->source = CommonText::toUTF8($source);
+ $this->text = is_null($text) ? $this->source : CommonText::toUTF8($text);
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
$this->internal = $internal;
@@ -129,8 +129,10 @@ public function getParagraphStyle()
/**
* Get link target
*
- * @return string
* @deprecated 0.12.0
+ *
+ * @return string
+ *
* @codeCoverageIgnore
*/
public function getTarget()
@@ -141,8 +143,10 @@ public function getTarget()
/**
* Get Link source
*
- * @return string
* @deprecated 0.10.0
+ *
+ * @return string
+ *
* @codeCoverageIgnore
*/
public function getLinkSrc()
@@ -153,8 +157,10 @@ public function getLinkSrc()
/**
* Get Link name
*
- * @return string
* @deprecated 0.10.0
+ *
+ * @return string
+ *
* @codeCoverageIgnore
*/
public function getLinkName()
diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php
index 4cb8d33952..25ace0905b 100644
--- a/src/PhpWord/Element/ListItem.php
+++ b/src/PhpWord/Element/ListItem.php
@@ -11,13 +11,13 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\PhpWord\Shared\String;
+use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
/**
@@ -57,7 +57,7 @@ class ListItem extends AbstractElement
*/
public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
{
- $this->textObject = new Text(String::toUTF8($text), $fontStyle, $paragraphStyle);
+ $this->textObject = new Text(CommonText::toUTF8($text), $fontStyle, $paragraphStyle);
$this->depth = $depth;
// Version >= 0.10.0 will pass numbering style name. Older version will use old method
diff --git a/src/PhpWord/Element/ListItemRun.php b/src/PhpWord/Element/ListItemRun.php
index 1b77830db3..53440db617 100644
--- a/src/PhpWord/Element/ListItemRun.php
+++ b/src/PhpWord/Element/ListItemRun.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
-* @copyright 2010-2014 PHPWord contributors
+* @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php
index 31943ba68a..7285030c0c 100644
--- a/src/PhpWord/Element/Object.php
+++ b/src/PhpWord/Element/Object.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -65,6 +65,7 @@ class Object extends AbstractElement
*
* @param string $source
* @param mixed $style
+ *
* @throws \PhpOffice\PhpWord\Exception\InvalidObjectException
*/
public function __construct($source, $style = null)
@@ -142,8 +143,10 @@ public function setImageRelationId($rId)
/**
* Get Object ID
*
- * @return int
* @deprecated 0.10.0
+ *
+ * @return int
+ *
* @codeCoverageIgnore
*/
public function getObjectId()
@@ -154,8 +157,10 @@ public function getObjectId()
/**
* Set Object ID
*
- * @param int $objId
* @deprecated 0.10.0
+ *
+ * @param int $objId
+ *
* @codeCoverageIgnore
*/
public function setObjectId($objId)
diff --git a/src/PhpWord/Element/PageBreak.php b/src/PhpWord/Element/PageBreak.php
index a1e7e998e8..d9d4bc641b 100644
--- a/src/PhpWord/Element/PageBreak.php
+++ b/src/PhpWord/Element/PageBreak.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php
index 44aef3b40e..65e17e35b5 100644
--- a/src/PhpWord/Element/PreserveText.php
+++ b/src/PhpWord/Element/PreserveText.php
@@ -11,13 +11,13 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\PhpWord\Shared\String;
+use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
@@ -61,7 +61,7 @@ public function __construct($text = null, $fontStyle = null, $paragraphStyle = n
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
- $this->text = String::toUTF8($text);
+ $this->text = CommonText::toUTF8($text);
$matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
if (isset($matches[0])) {
$this->text = $matches;
diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php
index e2df632551..05fde7e43d 100644
--- a/src/PhpWord/Element/Row.php
+++ b/src/PhpWord/Element/Row.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/SDT.php b/src/PhpWord/Element/SDT.php
index c69ed42772..58a477d92b 100644
--- a/src/PhpWord/Element/SDT.php
+++ b/src/PhpWord/Element/SDT.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php
index d746f69bb3..1e926d2f57 100644
--- a/src/PhpWord/Element/Section.php
+++ b/src/PhpWord/Element/Section.php
@@ -11,18 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Style\Section as SectionStyle;
-/**
- * Section
- */
class Section extends AbstractContainer
{
/**
@@ -82,6 +78,8 @@ public function setStyle($style = null)
* Get section style
*
* @return \PhpOffice\PhpWord\Style\Section
+ *
+ * @codeCoverageIgnore
*/
public function getStyle()
{
@@ -91,9 +89,11 @@ public function getStyle()
/**
* Add header
*
+ * @since 0.10.0
+ *
* @param string $type
+ *
* @return Header
- * @since 0.10.0
*/
public function addHeader($type = Header::AUTO)
{
@@ -103,9 +103,11 @@ public function addHeader($type = Header::AUTO)
/**
* Add footer
*
+ * @since 0.10.0
+ *
* @param string $type
+ *
* @return Footer
- * @since 0.10.0
*/
public function addFooter($type = Header::AUTO)
{
@@ -116,6 +118,8 @@ public function addFooter($type = Header::AUTO)
* Get header elements
*
* @return Header[]
+ *
+ * @codeCoverageIgnore
*/
public function getHeaders()
{
@@ -126,6 +130,8 @@ public function getHeaders()
* Get footer elements
*
* @return Footer[]
+ *
+ * @codeCoverageIgnore
*/
public function getFooters()
{
@@ -153,11 +159,14 @@ public function hasDifferentFirstPage()
/**
* Add header/footer
*
+ * @since 0.10.0
+ *
* @param string $type
* @param boolean $header
+ *
* @return Header|Footer
- * @throws \PhpOffice\PhpWord\Exception\Exception
- * @since 0.10.0
+ *
+ * @throws \Exception
*/
private function addHeaderFooter($type = Header::AUTO, $header = true)
{
@@ -175,7 +184,7 @@ private function addHeaderFooter($type = Header::AUTO, $header = true)
$collection[$index] = $container;
return $container;
} else {
- throw new Exception('Invalid header/footer type.');
+ throw new \Exception('Invalid header/footer type.');
}
}
@@ -183,8 +192,10 @@ private function addHeaderFooter($type = Header::AUTO, $header = true)
/**
* Set section style
*
- * @param array $settings
* @deprecated 0.12.0
+ *
+ * @param array $settings
+ *
* @codeCoverageIgnore
*/
public function setSettings($settings = null)
@@ -195,8 +206,10 @@ public function setSettings($settings = null)
/**
* Get section style
*
- * @return \PhpOffice\PhpWord\Style\Section
* @deprecated 0.12.0
+ *
+ * @return \PhpOffice\PhpWord\Style\Section
+ *
* @codeCoverageIgnore
*/
public function getSettings()
@@ -207,8 +220,10 @@ public function getSettings()
/**
* Create header
*
- * @return Header
* @deprecated 0.10.0
+ *
+ * @return Header
+ *
* @codeCoverageIgnore
*/
public function createHeader()
@@ -219,8 +234,10 @@ public function createHeader()
/**
* Create footer
*
- * @return Footer
* @deprecated 0.10.0
+ *
+ * @return Footer
+ *
* @codeCoverageIgnore
*/
public function createFooter()
@@ -231,8 +248,10 @@ public function createFooter()
/**
* Get footer
*
- * @return Footer
* @deprecated 0.10.0
+ *
+ * @return Footer
+ *
* @codeCoverageIgnore
*/
public function getFooter()
diff --git a/src/PhpWord/Element/Shape.php b/src/PhpWord/Element/Shape.php
index a7a96d1884..4717afb8f8 100644
--- a/src/PhpWord/Element/Shape.php
+++ b/src/PhpWord/Element/Shape.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/TOC.php b/src/PhpWord/Element/TOC.php
index a56d9ffe40..54ae384433 100644
--- a/src/PhpWord/Element/TOC.php
+++ b/src/PhpWord/Element/TOC.php
@@ -11,8 +11,8 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
- * @license http://www.gnu.org/licenses/lgpl.txt LGPL
+ * @copyright 2010-2016 PHPWord contributors
+ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php
index 5f0b8f7953..357af37ae5 100644
--- a/src/PhpWord/Element/Table.php
+++ b/src/PhpWord/Element/Table.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php
index 52fccb3f28..0de9cdeaf2 100644
--- a/src/PhpWord/Element/Text.php
+++ b/src/PhpWord/Element/Text.php
@@ -11,13 +11,13 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\PhpWord\Shared\String;
+use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
@@ -136,7 +136,7 @@ public function getParagraphStyle()
*/
public function setText($text)
{
- $this->text = String::toUTF8($text);
+ $this->text = CommonText::toUTF8($text);
return $this;
}
diff --git a/src/PhpWord/Element/TextBox.php b/src/PhpWord/Element/TextBox.php
index d929bf35db..4a1e51310b 100644
--- a/src/PhpWord/Element/TextBox.php
+++ b/src/PhpWord/Element/TextBox.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/TextBreak.php b/src/PhpWord/Element/TextBreak.php
index aa6ab582b2..893fa87531 100644
--- a/src/PhpWord/Element/TextBreak.php
+++ b/src/PhpWord/Element/TextBreak.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php
index c356cfa8e1..c2ce4f9981 100644
--- a/src/PhpWord/Element/TextRun.php
+++ b/src/PhpWord/Element/TextRun.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php
index cf1d49c81a..eabb1feb82 100644
--- a/src/PhpWord/Element/Title.php
+++ b/src/PhpWord/Element/Title.php
@@ -11,13 +11,13 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Element;
-use PhpOffice\PhpWord\Shared\String;
+use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Style;
/**
@@ -61,7 +61,7 @@ class Title extends AbstractElement
*/
public function __construct($text, $depth = 1)
{
- $this->text = String::toUTF8($text);
+ $this->text = CommonText::toUTF8($text);
$this->depth = $depth;
if (array_key_exists("Heading_{$this->depth}", Style::getStyles())) {
$this->style = "Heading{$this->depth}";
diff --git a/src/PhpWord/Escaper/AbstractEscaper.php b/src/PhpWord/Escaper/AbstractEscaper.php
new file mode 100644
index 0000000000..6ddcbb51b2
--- /dev/null
+++ b/src/PhpWord/Escaper/AbstractEscaper.php
@@ -0,0 +1,46 @@
+escapeSingleValue($item);
+ }
+ } else {
+ $input = $this->escapeSingleValue($input);
+ }
+
+ return $input;
+ }
+}
diff --git a/tests/PhpWord/Tests/Shared/XMLWriterTest.php b/src/PhpWord/Escaper/EscaperInterface.php
similarity index 54%
rename from tests/PhpWord/Tests/Shared/XMLWriterTest.php
rename to src/PhpWord/Escaper/EscaperInterface.php
index 08db39184f..c34cf370af 100644
--- a/tests/PhpWord/Tests/Shared/XMLWriterTest.php
+++ b/src/PhpWord/Escaper/EscaperInterface.php
@@ -11,30 +11,23 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
-namespace PhpOffice\PhpWord\Tests\Shared;
-
-use PhpOffice\PhpWord\Settings;
-use PhpOffice\PhpWord\Shared\XMLWriter;
+namespace PhpOffice\PhpWord\Escaper;
/**
- * Test class for PhpOffice\PhpWord\Shared\XMLWriter
+ * @since 0.13.0
+ *
+ * @codeCoverageIgnore
*/
-class XMLWriterTest extends \PHPUnit_Framework_TestCase
+interface EscaperInterface
{
/**
- * Test method exception
+ * @param mixed $input
*
- * @expectedException \BadMethodCallException
- * @expectedExceptionMessage Method 'foo' does not exists.
+ * @return mixed
*/
- public function testCallException()
- {
- Settings::setCompatibility(false);
- $object = new XMLWriter();
- $object->foo();
- }
+ public function escape($input);
}
diff --git a/src/PhpWord/Escaper/RegExp.php b/src/PhpWord/Escaper/RegExp.php
new file mode 100644
index 0000000000..de510bcf01
--- /dev/null
+++ b/src/PhpWord/Escaper/RegExp.php
@@ -0,0 +1,33 @@
+ $code || $code >= 80) {
+ return '{\u' . $code . '}';
+ } else {
+ return chr($code);
+ }
+ }
+
+ protected function escapeMultibyteCharacter($code)
+ {
+ return '\uc0{\u' . $code . '}';
+ }
+
+ /**
+ * @see http://www.randomchaos.com/documents/?source=php_and_unicode
+ */
+ protected function escapeSingleValue($input)
+ {
+ $escapedValue = '';
+
+ $numberOfBytes = 1;
+ $bytes = array();
+ for ($i = 0; $i < strlen($input); ++$i) {
+ $character = $input[$i];
+ $asciiCode = ord($character);
+
+ if ($asciiCode < 128) {
+ $escapedValue .= $this->escapeAsciiCharacter($asciiCode);
+ } else {
+ if (0 == count($bytes)) {
+ if ($asciiCode < 224) {
+ $numberOfBytes = 2;
+ } else if ($asciiCode < 240) {
+ $numberOfBytes = 3;
+ } else if ($asciiCode < 248) {
+ $numberOfBytes = 4;
+ }
+ }
+
+ $bytes[] = $asciiCode;
+
+ if ($numberOfBytes == count($bytes)) {
+ if (4 == $numberOfBytes) {
+ $multibyteCode = ($bytes[0] % 8) * 262144 + ($bytes[1] % 64) * 4096 + ($bytes[2] % 64) * 64 + ($bytes[3] % 64);
+ } elseif (3 == $numberOfBytes) {
+ $multibyteCode = ($bytes[0] % 16) * 4096 + ($bytes[1] % 64) * 64 + ($bytes[2] % 64);
+ } else {
+ $multibyteCode = ($bytes[0] % 32) * 64 + ($bytes[1] % 64);
+ }
+
+ if (65279 != $multibyteCode) {
+ $escapedValue .= $multibyteCode < 128 ? $this->escapeAsciiCharacter($multibyteCode) : $this->escapeMultibyteCharacter($multibyteCode);
+ }
+
+ $numberOfBytes = 1;
+ $bytes = array();
+ }
+ }
+ }
+
+ return $escapedValue;
+ }
+}
diff --git a/src/PhpWord/Escaper/Xml.php b/src/PhpWord/Escaper/Xml.php
new file mode 100644
index 0000000000..274cade5b0
--- /dev/null
+++ b/src/PhpWord/Escaper/Xml.php
@@ -0,0 +1,32 @@
+_SummaryInformation = $ole->getStream($ole->summaryInformation);
// Get Document Summary Information data
- $this->_DocumentSummaryInformation = $ole->getStream($ole->documentSummaryInformation);
+ $this->_DocumentSummaryInformation = $ole->getStream($ole->docSummaryInfos);
}
private function getNumInLcb($lcb, $iSize)
diff --git a/src/PhpWord/Reader/ODText.php b/src/PhpWord/Reader/ODText.php
index d992f7fd3c..e8c868861c 100644
--- a/src/PhpWord/Reader/ODText.php
+++ b/src/PhpWord/Reader/ODText.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Reader for ODText
diff --git a/src/PhpWord/Reader/ODText/AbstractPart.php b/src/PhpWord/Reader/ODText/AbstractPart.php
index 95f700847e..5ec2f22d7a 100644
--- a/src/PhpWord/Reader/ODText/AbstractPart.php
+++ b/src/PhpWord/Reader/ODText/AbstractPart.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php
index cf2fd65368..7362b02ca2 100644
--- a/src/PhpWord/Reader/ODText/Content.php
+++ b/src/PhpWord/Reader/ODText/Content.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\ODText;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Content reader
diff --git a/src/PhpWord/Reader/ODText/Meta.php b/src/PhpWord/Reader/ODText/Meta.php
index d08ce3a679..9533c38bd8 100644
--- a/src/PhpWord/Reader/ODText/Meta.php
+++ b/src/PhpWord/Reader/ODText/Meta.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\ODText;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Meta reader
diff --git a/src/PhpWord/Reader/RTF.php b/src/PhpWord/Reader/RTF.php
index 9d5d813bf4..b6d2e21eeb 100644
--- a/src/PhpWord/Reader/RTF.php
+++ b/src/PhpWord/Reader/RTF.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -31,7 +31,9 @@ class RTF extends AbstractReader implements ReaderInterface
* Loads PhpWord from file
*
* @param string $docFile
+ *
* @throws \Exception
+ *
* @return \PhpOffice\PhpWord\PhpWord
*/
public function load($docFile)
diff --git a/src/PhpWord/Reader/RTF/Document.php b/src/PhpWord/Reader/RTF/Document.php
index 3f63e3398e..4e0f2c3559 100644
--- a/src/PhpWord/Reader/RTF/Document.php
+++ b/src/PhpWord/Reader/RTF/Document.php
@@ -11,13 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\RTF;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\Jc;
/**
* RTF document reader
@@ -140,7 +141,7 @@ public function read(PhpWord $phpWord)
125 => 'markClosing', // }
92 => 'markBackslash', // \
10 => 'markNewline', // LF
- 13 => 'markNewline' // CR
+ 13 => 'markNewline', // CR
);
$this->phpWord = $phpWord;
@@ -159,7 +160,7 @@ public function read(PhpWord $phpWord)
$markerFunction = $markers[$ascii];
$this->$markerFunction();
} else {
- if ($this->isControl === false) { // Non control word: Push character
+ if (false === $this->isControl) { // Non control word: Push character
$this->pushText($char);
} else {
if (preg_match("/^[a-zA-Z0-9-]?$/", $char)) { // No delimiter: Buffer control
@@ -169,7 +170,7 @@ public function read(PhpWord $phpWord)
if ($this->isFirst) {
$this->isFirst = false;
} else {
- if ($char == ' ') { // Discard space as a control word delimiter
+ if (' ' == $char) { // Discard space as a control word delimiter
$this->flushControl(true);
}
}
@@ -255,12 +256,12 @@ private function flush($isControl = false)
*/
private function flushControl($isControl = false)
{
- if (preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match) === 1) {
+ if (1 === preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match)) {
list(, $control, $parameter) = $match;
$this->parseControl($control, $parameter);
}
- if ($isControl === true) {
+ if (true === $isControl) {
$this->setControl(false);
}
}
@@ -276,7 +277,7 @@ private function flushText()
if (isset($this->flags['property'])) { // Set property
$this->flags['value'] = $this->text;
} else { // Set text
- if ($this->flags['paragraph'] === true) {
+ if (true === $this->flags['paragraph']) {
$this->flags['paragraph'] = false;
$this->flags['text'] = $this->text;
}
@@ -311,9 +312,9 @@ private function setControl($value)
*/
private function pushText($char)
{
- if ($char == '<') {
+ if ('<' == $char) {
$this->text .= "<";
- } elseif ($char == '>') {
+ } elseif ('>' == $char) {
$this->text .= ">";
} else {
$this->text .= $char;
@@ -336,7 +337,7 @@ private function parseControl($control, $parameter)
'u' => array(self::STYL, 'font', 'underline', true),
'strike' => array(self::STYL, 'font', 'strikethrough',true),
'fs' => array(self::STYL, 'font', 'size', $parameter),
- 'qc' => array(self::STYL, 'paragraph', 'align', 'center'),
+ 'qc' => array(self::STYL, 'paragraph', 'alignment', Jc::CENTER),
'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter),
'fonttbl' => array(self::SKIP, 'fonttbl', null),
'colortbl' => array(self::SKIP, 'colortbl', null),
diff --git a/src/PhpWord/Reader/ReaderInterface.php b/src/PhpWord/Reader/ReaderInterface.php
index 361c413796..4f5231a767 100644
--- a/src/PhpWord/Reader/ReaderInterface.php
+++ b/src/PhpWord/Reader/ReaderInterface.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php
index ebe6c4f765..da20eb8763 100644
--- a/src/PhpWord/Reader/Word2007.php
+++ b/src/PhpWord/Reader/Word2007.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
use PhpOffice\PhpWord\Shared\ZipArchive;
/**
diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php
index 021bdba11e..f429ff7519 100644
--- a/src/PhpWord/Reader/Word2007/AbstractPart.php
+++ b/src/PhpWord/Reader/Word2007/AbstractPart.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\Word2007;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Abstract part reader
@@ -92,7 +92,7 @@ public function setRels($value)
/**
* Read w:p.
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $domNode
* @param mixed $parent
* @param string $docPart
@@ -122,16 +122,16 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, $pa
$instrText = $xmlReader->getValue('w:instrText', $node);
if ($xmlReader->elementExists('w:fldChar', $node)) {
$fldCharType = $xmlReader->getAttribute('w:fldCharType', $node, 'w:fldChar');
- if ($fldCharType == 'begin') {
+ if ('begin' == $fldCharType) {
$ignoreText = true;
- } elseif ($fldCharType == 'end') {
+ } elseif ('end' == $fldCharType) {
$ignoreText = false;
}
}
if (!is_null($instrText)) {
$textContent .= '{' . $instrText . '}';
} else {
- if ($ignoreText === false) {
+ if (false === $ignoreText) {
$textContent .= $xmlReader->getValue('w:t', $node);
}
}
@@ -163,7 +163,7 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, $pa
$runCount = $xmlReader->countElements('w:r', $domNode);
$linkCount = $xmlReader->countElements('w:hyperlink', $domNode);
$runLinkCount = $runCount + $linkCount;
- if ($runLinkCount == 0) {
+ if (0 == $runLinkCount) {
$parent->addTextBreak(null, $paragraphStyle);
} else {
$nodes = $xmlReader->getElements('*', $domNode);
@@ -183,7 +183,7 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, $pa
/**
* Read w:r.
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $domNode
* @param mixed $parent
* @param string $docPart
@@ -200,7 +200,7 @@ protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, $parent,
$fontStyle = $this->readFontStyle($xmlReader, $domNode);
// Link
- if ($domNode->nodeName == 'w:hyperlink') {
+ if ('w:hyperlink' == $domNode->nodeName) {
$rId = $xmlReader->getAttribute('r:id', $domNode);
$textContent = $xmlReader->getValue('w:r/w:t', $domNode);
$target = $this->getMediaTarget($docPart, $rId);
@@ -246,7 +246,7 @@ protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, $parent,
/**
* Read w:tbl.
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $domNode
* @param mixed $parent
* @param string $docPart
@@ -264,26 +264,26 @@ protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, $parent
$table = $parent->addTable($tblStyle);
$tblNodes = $xmlReader->getElements('*', $domNode);
foreach ($tblNodes as $tblNode) {
- if ($tblNode->nodeName == 'w:tblGrid') { // Column
+ if ('w:tblGrid' == $tblNode->nodeName) { // Column
// @todo Do something with table columns
- } elseif ($tblNode->nodeName == 'w:tr') { // Row
+ } elseif ('w:tr' == $tblNode->nodeName) { // Row
$rowHeight = $xmlReader->getAttribute('w:val', $tblNode, 'w:trPr/w:trHeight');
$rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight');
$rowHRule = $rowHRule == 'exact' ? true : false;
$rowStyle = array(
- 'tblHeader' => $xmlReader->elementExists('w:trPr/w:tblHeader', $tblNode),
- 'cantSplit' => $xmlReader->elementExists('w:trPr/w:cantSplit', $tblNode),
+ 'tblHeader' => $xmlReader->elementExists('w:trPr/w:tblHeader', $tblNode),
+ 'cantSplit' => $xmlReader->elementExists('w:trPr/w:cantSplit', $tblNode),
'exactHeight' => $rowHRule,
);
$row = $table->addRow($rowHeight, $rowStyle);
$rowNodes = $xmlReader->getElements('*', $tblNode);
foreach ($rowNodes as $rowNode) {
- if ($rowNode->nodeName == 'w:trPr') { // Row style
+ if ('w:trPr' == $rowNode->nodeName) { // Row style
// @todo Do something with row style
- } elseif ($rowNode->nodeName == 'w:tc') { // Cell
+ } elseif ('w:tc' == $rowNode->nodeName) { // Cell
$cellWidth = $xmlReader->getAttribute('w:w', $rowNode, 'w:tcPr/w:tcW');
$cellStyle = null;
$cellStyleNode = $xmlReader->getElement('w:tcPr', $rowNode);
@@ -294,7 +294,7 @@ protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, $parent
$cell = $row->addCell($cellWidth, $cellStyle);
$cellNodes = $xmlReader->getElements('*', $rowNode);
foreach ($cellNodes as $cellNode) {
- if ($cellNode->nodeName == 'w:p') { // Paragraph
+ if ('w:p' == $cellNode->nodeName) { // Paragraph
$this->readParagraph($xmlReader, $cellNode, $cell, $docPart);
}
}
@@ -307,7 +307,7 @@ protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, $parent
/**
* Read w:pPr.
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array|null
*/
@@ -320,7 +320,7 @@ protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode
$styleNode = $xmlReader->getElement('w:pPr', $domNode);
$styleDefs = array(
'styleName' => array(self::READ_VALUE, 'w:pStyle'),
- 'align' => array(self::READ_VALUE, 'w:jc'),
+ 'alignment' => array(self::READ_VALUE, 'w:jc'),
'basedOn' => array(self::READ_VALUE, 'w:basedOn'),
'next' => array(self::READ_VALUE, 'w:next'),
'indent' => array(self::READ_VALUE, 'w:ind', 'w:left'),
@@ -339,7 +339,7 @@ protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode
/**
* Read w:rPr
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array|null
*/
@@ -349,7 +349,7 @@ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode)
return null;
}
// Hyperlink has an extra w:r child
- if ($domNode->nodeName == 'w:hyperlink') {
+ if ('w:hyperlink' == $domNode->nodeName) {
$domNode = $xmlReader->getElement('w:r', $domNode);
}
if (!$xmlReader->elementExists('w:rPr', $domNode)) {
@@ -382,7 +382,7 @@ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode)
/**
* Read w:tblPr
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return string|array|null
* @todo Capture w:tblStylePr w:type="firstRow"
@@ -399,7 +399,6 @@ protected function readTableStyle(XMLReader $xmlReader, \DOMElement $domNode)
} else {
$styleNode = $xmlReader->getElement('w:tblPr', $domNode);
$styleDefs = array();
- // $styleDefs['styleName'] = array(self::READ_VALUE, 'w:tblStyle');
foreach ($margins as $side) {
$ucfSide = ucfirst($side);
$styleDefs["cellMargin$ucfSide"] = array(self::READ_VALUE, "w:tblCellMar/w:$side", 'w:w');
@@ -419,7 +418,7 @@ protected function readTableStyle(XMLReader $xmlReader, \DOMElement $domNode)
/**
* Read w:tcPr
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array
*/
@@ -439,7 +438,7 @@ private function readCellStyle(XMLReader $xmlReader, \DOMElement $domNode)
/**
* Read style definition
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $parentNode
* @param array $styleDefs
* @ignoreScrutinizerPatch
@@ -482,13 +481,13 @@ private function readStyleDef($method, $attributeValue, $expected)
{
$style = $attributeValue;
- if ($method == self::READ_SIZE) {
+ if (self::READ_SIZE == $method) {
$style = $attributeValue / 2;
- } elseif ($method == self::READ_TRUE) {
+ } elseif (self::READ_TRUE == $method) {
$style = true;
- } elseif ($method == self::READ_FALSE) {
+ } elseif (self::READ_FALSE == $method) {
$style = false;
- } elseif ($method == self::READ_EQUAL) {
+ } elseif (self::READ_EQUAL == $method) {
$style = $attributeValue == $expected;
}
diff --git a/src/PhpWord/Reader/Word2007/DocPropsApp.php b/src/PhpWord/Reader/Word2007/DocPropsApp.php
index ddbe474f1a..6b1410a56a 100644
--- a/src/PhpWord/Reader/Word2007/DocPropsApp.php
+++ b/src/PhpWord/Reader/Word2007/DocPropsApp.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php
index 54537525b6..417a93bd3f 100644
--- a/src/PhpWord/Reader/Word2007/DocPropsCore.php
+++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\Word2007;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Core properties reader
diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php
index eb725b2ec3..979a244197 100644
--- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php
+++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php
@@ -11,15 +11,15 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\Word2007;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\Metadata\DocInfo;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Custom properties reader
diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php
index e1beed0666..b89a99ad14 100644
--- a/src/PhpWord/Reader/Word2007/Document.php
+++ b/src/PhpWord/Reader/Word2007/Document.php
@@ -11,15 +11,15 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\Word2007;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Document reader
@@ -99,7 +99,7 @@ private function readHeaderFooter($settings, Section &$section)
/**
* Read w:sectPr
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $domNode
* @ignoreScrutinizerPatch
* @return array
@@ -142,7 +142,7 @@ private function readSectionStyle(XMLReader $xmlReader, \DOMElement $domNode)
/**
* Read w:p node.
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section
* @return void
@@ -172,7 +172,7 @@ private function readWPNode(XMLReader $xmlReader, \DOMElement $node, Section &$s
/**
* Read w:sectPr node.
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section
* @return void
diff --git a/src/PhpWord/Reader/Word2007/Endnotes.php b/src/PhpWord/Reader/Word2007/Endnotes.php
index c493c34790..7bcafc6a10 100644
--- a/src/PhpWord/Reader/Word2007/Endnotes.php
+++ b/src/PhpWord/Reader/Word2007/Endnotes.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php
index 6f6adc879e..3d85af716c 100644
--- a/src/PhpWord/Reader/Word2007/Footnotes.php
+++ b/src/PhpWord/Reader/Word2007/Footnotes.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\Word2007;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Footnotes reader
diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php
index 872d45033b..a00a630740 100644
--- a/src/PhpWord/Reader/Word2007/Numbering.php
+++ b/src/PhpWord/Reader/Word2007/Numbering.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\Word2007;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Numbering reader
@@ -90,7 +90,7 @@ public function read(PhpWord $phpWord)
/**
* Read numbering level definition from w:abstractNum and w:num
*
- * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
+ * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $subnode
* @param integer $levelId
* @return array
@@ -105,7 +105,7 @@ private function readLevel(XMLReader $xmlReader, \DOMElement $subnode, $levelId)
$level['restart'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlRestart');
$level['suffix'] = $xmlReader->getAttribute('w:val', $subnode, 'w:suff');
$level['text'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlText');
- $level['align'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlJc');
+ $level['alignment'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlJc');
$level['tab'] = $xmlReader->getAttribute('w:pos', $subnode, 'w:pPr/w:tabs/w:tab');
$level['left'] = $xmlReader->getAttribute('w:left', $subnode, 'w:pPr/w:ind');
$level['hanging'] = $xmlReader->getAttribute('w:hanging', $subnode, 'w:pPr/w:ind');
diff --git a/src/PhpWord/Reader/Word2007/Styles.php b/src/PhpWord/Reader/Word2007/Styles.php
index 299fe1df77..645c9830c2 100644
--- a/src/PhpWord/Reader/Word2007/Styles.php
+++ b/src/PhpWord/Reader/Word2007/Styles.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Reader\Word2007;
+use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Styles reader
diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php
index 67b1dbedbd..e049c46ed1 100644
--- a/src/PhpWord/Settings.php
+++ b/src/PhpWord/Settings.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -126,6 +126,14 @@ class Settings
*/
private static $tempDir = '';
+ /**
+ * Enables built-in output escaping mechanism.
+ * Default value is `false` for backward compatibility with versions below 0.13.0.
+ *
+ * @var bool
+ */
+ private static $outputEscapingEnabled = false;
+
/**
* Return the compatibility option used by the XMLWriter
*
@@ -282,6 +290,7 @@ public static function setMeasurementUnit($value)
* @since 0.12.0
*
* @param string $tempDir The user defined path to temporary directory.
+ *
* @return void
*/
public static function setTempDir($tempDir)
@@ -307,6 +316,30 @@ public static function getTempDir()
return $tempDir;
}
+ /**
+ * @since 0.13.0
+ *
+ * @return boolean
+ *
+ * @codeCoverageIgnore
+ */
+ public static function isOutputEscapingEnabled()
+ {
+ return self::$outputEscapingEnabled;
+ }
+
+ /**
+ * @since 0.13.0
+ *
+ * @param boolean $outputEscapingEnabled
+ *
+ * @codeCoverageIgnore
+ */
+ public static function setOutputEscapingEnabled($outputEscapingEnabled)
+ {
+ self::$outputEscapingEnabled = $outputEscapingEnabled;
+ }
+
/**
* Get default font name
*
@@ -407,6 +440,7 @@ public static function loadConfig($filename = null)
* Return the compatibility option used by the XMLWriter
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public static function getCompatibility()
diff --git a/src/PhpWord/Shared/Converter.php b/src/PhpWord/Shared/Converter.php
index c6727edd55..e5cb5b25f0 100644
--- a/src/PhpWord/Shared/Converter.php
+++ b/src/PhpWord/Shared/Converter.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
+ * @copyright 2010-2016 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php
deleted file mode 100644
index e3a33e5b69..0000000000
--- a/src/PhpWord/Shared/Drawing.php
+++ /dev/null
@@ -1,217 +0,0 @@
-' . $html . '