diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3cc3ff99..3e6385ba 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,24 +1,28 @@
-CHANGELOG
-=========
-
-This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub.
+Change Log
+==========
+All notable changes to this project will be documented in this file.
+This project adheres to [Semantic Versioning](http://semver.org/).
0.13.0 (unreleased)
-------------
-
+-------------------
Place announcement text here.
-### Changes
-- Introduced ``\PhpOffice\PhpWord\SimpleType\ST_JcTable`` simple type. - @RomanSyroeshko
-- Introduced ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` simple type. - @RomanSyroeshko
+### Added
+- Introduced the ``\PhpOffice\PhpWord\SimpleType\ST_JcTable`` simple type. - @RomanSyroeshko
+- Introduced the ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` simple type. - @RomanSyroeshko
+
+### Changed
- Improved error message for the case when ``autoload.php`` is not found. - @RomanSyroeshko #371
-- Renamed ``align`` option of ``NumberingLevel``, ``Frame``, ``Table``, and ``Paragraph`` styles into ``alignment``. Accessor and mutator methods renamed too. - @RomanSyroeshko
+- Renamed the ``align`` option of ``NumberingLevel``, ``Frame``, ``Table``, and ``Paragraph`` styles into ``alignment``. - @RomanSyroeshko
+
+### Deprecated
+- ``getAlign`` and ``setAlign`` methods of ``NumberingLevel``, ``Frame``, ``Table``, and ``Paragraph`` styles.
+Use the correspondent ``getAlignment`` and ``setAlignment`` methods instead.
0.12.1 (30 August 2015)
--------------------
-
+-----------------------
Maintenance release. This release is focused primarily on ``TemplateProcessor``.
### Changes
@@ -33,7 +37,6 @@ Maintenance release. This release is focused primarily on ``TemplateProcessor``.
0.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
@@ -93,7 +96,6 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap
0.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
@@ -102,7 +104,6 @@ This is an immediate bugfix release for HTML reader.
0.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
@@ -167,7 +168,6 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four
0.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
@@ -176,7 +176,6 @@ This is a bugfix release for `php-zip` requirement in Composer.
0.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
@@ -261,7 +260,6 @@ This release marked heavy refactorings on internal code structure with the creat
0.9.1 (27 Mar 2014)
-------------------
-
This is a bugfix release for PSR-4 compatibility.
- Fixed PSR-4 composer autoloader - @AntonTyutin
@@ -270,7 +268,6 @@ This is a bugfix release for PSR-4 compatibility.
0.9.0 (26 Mar 2014)
-------------------
-
This release marked the transformation to namespaces (PHP 5.3+).
### Features
@@ -293,7 +290,6 @@ This release marked the transformation to namespaces (PHP 5.3+).
0.8.1 (17 Mar 2014)
-------------------
-
This is a bugfix release for image detection functionality.
- Added fallback for computers that do not have exif_imagetype - @bskrtich, @gabrielbull
@@ -302,7 +298,6 @@ This is a bugfix release for image detection functionality.
0.8.0 (15 Mar 2014)
-------------------
-
This release merged a lot of improvements from the community. Unit tests introduced in this release and has reached 90% code coverage.
### Features
@@ -351,7 +346,6 @@ This release merged a lot of improvements from the community. Unit tests introdu
0.7.0 (28 Jan 2014)
-------------------
-
This is the first release after a long development hiatus in [CodePlex](https://phpword.codeplex.com/). This release initialized ODT and RTF Writer, along with some other new features for the existing Word2007 Writer, e.g. tab, multiple header, rowspan and colspan. [Composer](https://packagist.org/packages/phpoffice/phpword) and [Travis](https://travis-ci.org/PHPOffice/PHPWord) were added.
### Features
@@ -375,4 +369,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/VERSION b/VERSION
index d33c3a21..51de3305 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.12.0
\ No newline at end of file
+0.13.0
\ No newline at end of file
diff --git a/docs/Makefile b/docs/Makefile
index 5631b060..bd38cd5d 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 de645350..e9b1c59e 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -40,15 +40,15 @@ source_suffix = '.rst'
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_static_path = ['_static']
#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 @@ latex_elements = {
# 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 @@ latex_documents = [
# 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 @@ man_pages = [
# (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 @@ texinfo_documents = [
# -- 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 0b4eb08c..d68ee035 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
-~~~~~~~~~~~
+- ``$text``. Text to be displayed in the document.
+- ``$fontStyle``. See :ref:`font-style`.
+- ``$paragraphStyle``. See :ref:`paragraph-style`.
-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('alignment' => '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:
-
-.. code-block:: php
-
- $fontStyle = array('color' => '006699', 'size' => 18, 'bold' => true);
- $phpWord->addFontStyle('fStyle', $fontStyle);
- $text = $section->addText('Hello world!', 'fStyle');
-
- $paragraphStyle = array('alignment' => '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:
-
-- ``alignment`` 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 79652ae0..19fca105 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 64298928..4e350cd0 100644
--- a/docs/general.rst
+++ b/docs/general.rst
@@ -184,4 +184,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 65995904..d05464bf 100644
--- a/docs/installing.rst
+++ b/docs/installing.rst
@@ -8,17 +8,15 @@ Requirements
Mandatory:
-- PHP 5.3+
-- PHP `Zip `__ extension
-- PHP `XML
- Parser `__
- extension
+- PHP 5.3+
+- PHP `Zip `__ extension
+- PHP `XML Parser `__ extension
Optional PHP extensions:
-- `GD `__
-- `XMLWriter `__
-- `XSL `__
+- `GD `__
+- `XMLWriter `__
+- `XSL `__
Installation
------------
@@ -42,7 +40,7 @@ To install via Composer, add the following lines to your
}
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.
.. code-block:: json
@@ -56,8 +54,7 @@ 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.
+To install manually, you change to the web-server 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.
diff --git a/docs/intro.rst b/docs/intro.rst
index d2decd7c..8e3d2d05 100644
--- a/docs/intro.rst
+++ b/docs/intro.rst
@@ -24,35 +24,35 @@ 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 main document part of OOXML
+ template
+- ... and many more features on progress
File formats
------------
@@ -183,13 +183,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 0be6b4e0..5042cded 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 20aa1ed0..9c4e06a8 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/styles.rst b/docs/styles.rst
index ffb9e087..6c8638c5 100644
--- a/docs/styles.rst
+++ b/docs/styles.rst
@@ -3,132 +3,140 @@
Styles
======
+.. _section-style:
+
Section
-------
-Below are the available styles for section:
+Available Section style options:
-- ``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)
+- ``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:
+Available Font style options:
-- ``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*
+- ``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:
+Available Paragraph style options:
-- ``alignment`` 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
+- ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\ST_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:
-- ``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
+- ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\ST_JcTable`` class 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.
-Row styles:
+Available Row style options:
-- ``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
+- ``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*.
-Cell styles:
+Available Cell style options:
-- ``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*
+- ``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``. Direction of text.
+- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
+- ``vMerge``. *restart* or *continue*.
+- ``width``. Cell width in twips.
+
+.. _image-style:
Image
-----
-Available image styles:
+Available Image style options:
-- ``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*
+- ``alignment``. See ``\PhpOffice\PhpWord\SimpleType\ST_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*.
+
+.. _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 provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\ST_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.
\ No newline at end of file
diff --git a/docs/writersreaders.rst b/docs/writersreaders.rst
index 34a0805a..33aacc72 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/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php
index 67276b6a..b35af8dc 100644
--- a/samples/Sample_01_SimpleText.php
+++ b/samples/Sample_01_SimpleText.php
@@ -5,7 +5,7 @@ include_once 'Sample_Header.php';
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('alignment' => 'center', 'spaceAfter' => 100));
+$phpWord->addParagraphStyle('pStyle', array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER, 'spaceAfter' => 100));
$phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
// New portrait section
diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php
index 4b6338d7..f0dc80f1 100644
--- a/samples/Sample_08_ParagraphPagination.php
+++ b/samples/Sample_08_ParagraphPagination.php
@@ -6,7 +6,7 @@ echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->setDefaultParagraphStyle(
array(
- 'alignment' => 'both',
+ 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::BOTH,
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12),
'spacing' => 120,
)
diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php
index 241efcb9..3e6cb670 100644
--- a/samples/Sample_09_Tables.php
+++ b/samples/Sample_09_Tables.php
@@ -26,11 +26,11 @@ for ($r = 1; $r <= 8; $r++) {
$section->addTextBreak(1);
$section->addText(htmlspecialchars('Fancy table', ENT_COMPAT, 'UTF-8'), $header);
-$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80);
+$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_JcTable::CENTER);
$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');
+$fontStyle = array('bold' => true);
$phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow);
$table = $section->addTable('Fancy Table');
$table->addRow(900);
@@ -58,7 +58,7 @@ $styleTable = 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\ST_Jc::CENTER);
$cellVCentered = array('valign' => 'center');
$phpWord->addTableStyle('Colspan Rowspan', $styleTable);
@@ -89,10 +89,10 @@ $table->addCell(null, $cellRowContinue);
$section->addTextBreak(2);
$section->addText(htmlspecialchars('Nested table in a centered and 50% width table.', ENT_COMPAT, 'UTF-8'), $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\ST_JcTable::CENTER));
$cell = $table->addRow()->addCell();
$cell->addText(htmlspecialchars('This cell contains nested table.', ENT_COMPAT, 'UTF-8'));
-$innerCell = $cell->addTable(array('align' => 'center'))->addRow()->addCell();
+$innerCell = $cell->addTable(array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_JcTable::CENTER))->addRow()->addCell();
$innerCell->addText(htmlspecialchars('Inside nested table', ENT_COMPAT, 'UTF-8'));
// Save file
diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php
index df06453a..cb29bf9e 100644
--- a/samples/Sample_12_HeaderFooter.php
+++ b/samples/Sample_12_HeaderFooter.php
@@ -17,7 +17,7 @@ $cell = $table->addCell(4500);
$textrun = $cell->addTextRun();
$textrun->addText(htmlspecialchars('This is the header with ', ENT_COMPAT, 'UTF-8'));
$textrun->addLink('https://github.com/PHPOffice/PHPWord', htmlspecialchars('PHPWord on GitHub', ENT_COMPAT, 'UTF-8'));
-$table->addCell(4500)->addImage('resources/PhpWord.png', array('width' => 80, 'height' => 80, 'align' => 'right'));
+$table->addCell(4500)->addImage('resources/PhpWord.png', array('width' => 80, 'height' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::END));
// Add header for all other pages
$subsequent = $section->addHeader();
@@ -26,7 +26,7 @@ $subsequent->addImage('resources/_mars.jpg', array('width' => 80, 'height' => 80
// Add footer
$footer = $section->addFooter();
-$footer->addPreserveText(htmlspecialchars('Page {PAGE} of {NUMPAGES}.', ENT_COMPAT, 'UTF-8'), null, array('alignment' => 'center'));
+$footer->addPreserveText(htmlspecialchars('Page {PAGE} of {NUMPAGES}.', ENT_COMPAT, 'UTF-8'), null, array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER));
$footer->addLink('https://github.com/PHPOffice/PHPWord', htmlspecialchars('PHPWord on GitHub', ENT_COMPAT, 'UTF-8'));
// Write some text
diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php
index f24dbfba..a5e2eece 100644
--- a/samples/Sample_13_Images.php
+++ b/samples/Sample_13_Images.php
@@ -12,7 +12,7 @@ $section->addImage('resources/_mars.jpg');
$section->addTextBreak(2);
$section->addText(htmlspecialchars('Local image with styles:', ENT_COMPAT, 'UTF-8'));
-$section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'align' => 'center'));
+$section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER));
$section->addTextBreak(2);
// Remote image
diff --git a/samples/Sample_21_TableRowRules.php b/samples/Sample_21_TableRowRules.php
index f22b6165..162f1c74 100644
--- a/samples/Sample_21_TableRowRules.php
+++ b/samples/Sample_21_TableRowRules.php
@@ -22,7 +22,7 @@ $section->addText(
$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\ST_Jc::CENTER));
$section->addTextBreak();
$section->addText(
@@ -43,7 +43,7 @@ $table2 = $section->addTable(
);
$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\ST_Jc::CENTER));
$section->addTextBreak();
$section->addText(
diff --git a/samples/Sample_25_TextBox.php b/samples/Sample_25_TextBox.php
index ebd597d2..3925a256 100644
--- a/samples/Sample_25_TextBox.php
+++ b/samples/Sample_25_TextBox.php
@@ -10,7 +10,7 @@ $section = $phpWord->addSection();
// In section
$textbox = $section->addTextBox(
array(
- 'align' => 'center',
+ 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER,
'width' => 400,
'height' => 150,
'borderSize' => 1,
diff --git a/samples/Sample_27_Field.php b/samples/Sample_27_Field.php
index 165a3e8c..2cab80fd 100644
--- a/samples/Sample_27_Field.php
+++ b/samples/Sample_27_Field.php
@@ -19,7 +19,7 @@ $section->addField('PAGE', array('format' => 'ArabicDash'));
$section->addText(htmlspecialchars('Number of pages field:', ENT_COMPAT, 'UTF-8'));
$section->addField('NUMPAGES', array('format' => 'Arabic', 'numformat' => '0,00'), array('PreserveFormat'));
-$textrun = $section->addTextRun(array('align' => 'center'));
+$textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER));
$textrun->addText(htmlspecialchars('This is the date of lunar calendar ', ENT_COMPAT, 'UTF-8'));
$textrun->addField('DATE', array('dateformat' => 'd-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar'));
$textrun->addText(htmlspecialchars(' written in a textrun.', ENT_COMPAT, 'UTF-8'));
diff --git a/samples/Sample_36_RTL.php b/samples/Sample_36_RTL.php
index 486e8d6d..ee023fd4 100644
--- a/samples/Sample_36_RTL.php
+++ b/samples/Sample_36_RTL.php
@@ -9,7 +9,7 @@ $section = $phpWord->addSection();
$textrun = $section->addTextRun();
$textrun->addText(htmlspecialchars('This is a Left to Right paragraph.', ENT_COMPAT, 'UTF-8'));
-$textrun = $section->addTextRun(array('align' => 'right'));
+$textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::END));
$textrun->addText(htmlspecialchars('سلام این یک پاراگراف راست به چپ است', ENT_COMPAT, 'UTF-8'), array('rtl' => true));
// Save file
diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php
index 57d646a0..9ab96a6a 100644
--- a/src/PhpWord/Element/AbstractContainer.php
+++ b/src/PhpWord/Element/AbstractContainer.php
@@ -178,7 +178,9 @@ abstract class AbstractContainer extends AbstractElement
* Check if a method is allowed for the current container
*
* @param string $method
+ *
* @return bool
+ *
* @throws \BadMethodCallException
*/
private function checkValidity($method)
@@ -247,10 +249,13 @@ abstract class AbstractContainer extends AbstractElement
/**
* Add memory image element
*
+ * @deprecated 0.9.0
+ *
* @param string $src
* @param mixed $style
+ *
* @return \PhpOffice\PhpWord\Element\Image
- * @deprecated 0.9.0
+ *
* @codeCoverageIgnore
*/
public function addMemoryImage($src, $style = null)
@@ -261,9 +266,12 @@ abstract class AbstractContainer extends AbstractElement
/**
* Create textrun element
*
- * @param mixed $paragraphStyle
- * @return \PhpOffice\PhpWord\Element\TextRun
* @deprecated 0.10.0
+ *
+ * @param mixed $paragraphStyle
+ *
+ * @return \PhpOffice\PhpWord\Element\TextRun
+ *
* @codeCoverageIgnore
*/
public function createTextRun($paragraphStyle = null)
@@ -274,9 +282,12 @@ abstract class AbstractContainer extends AbstractElement
/**
* Create footnote element
*
- * @param mixed $paragraphStyle
- * @return \PhpOffice\PhpWord\Element\Footnote
* @deprecated 0.10.0
+ *
+ * @param mixed $paragraphStyle
+ *
+ * @return \PhpOffice\PhpWord\Element\Footnote
+ *
* @codeCoverageIgnore
*/
public function createFootnote($paragraphStyle = null)
diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php
index 99a7a1be..68044e02 100644
--- a/src/PhpWord/Element/AbstractElement.php
+++ b/src/PhpWord/Element/AbstractElement.php
@@ -378,8 +378,11 @@ abstract class AbstractElement
* @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/Field.php b/src/PhpWord/Element/Field.php
index 1eaa6f24..8c612252 100644
--- a/src/PhpWord/Element/Field.php
+++ b/src/PhpWord/Element/Field.php
@@ -94,7 +94,9 @@ class Field extends AbstractElement
* Set Field type
*
* @param string $type
+ *
* @return string
+ *
* @throws \InvalidArgumentException
*/
public function setType($type = null)
@@ -123,7 +125,9 @@ class Field extends AbstractElement
* Set Field properties
*
* @param array $properties
+ *
* @return self
+ *
* @throws \InvalidArgumentException
*/
public function setProperties($properties = array())
@@ -153,7 +157,9 @@ class Field extends AbstractElement
* Set Field options
*
* @param array $options
+ *
* @return self
+ *
* @throws \InvalidArgumentException
*/
public function setOptions($options = array())
diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php
index 162a703e..34bdf3c6 100644
--- a/src/PhpWord/Element/Footnote.php
+++ b/src/PhpWord/Element/Footnote.php
@@ -67,8 +67,10 @@ class Footnote extends AbstractContainer
/**
* Get Footnote Reference ID
*
- * @return int
* @deprecated 0.10.0
+ *
+ * @return int
+ *
* @codeCoverageIgnore
*/
public function getReferenceId()
@@ -79,8 +81,10 @@ class Footnote extends AbstractContainer
/**
* Set Footnote Reference ID
*
- * @param int $rId
* @deprecated 0.10.0
+ *
+ * @param int $rId
+ *
* @codeCoverageIgnore
*/
public function setReferenceId($rId)
diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php
index cab2527a..b0b2967e 100644
--- a/src/PhpWord/Element/Image.php
+++ b/src/PhpWord/Element/Image.php
@@ -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 @@ class Image extends AbstractElement
* 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 @@ class Image extends AbstractElement
* @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 @@ class Image extends AbstractElement
* Get is watermark
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getIsWatermark()
@@ -528,6 +534,7 @@ class Image extends AbstractElement
* Get is memory image
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getIsMemImage()
diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php
index 9d0eb766..0359f415 100644
--- a/src/PhpWord/Element/Link.php
+++ b/src/PhpWord/Element/Link.php
@@ -129,8 +129,10 @@ class Link extends AbstractElement
/**
* Get link target
*
- * @return string
* @deprecated 0.12.0
+ *
+ * @return string
+ *
* @codeCoverageIgnore
*/
public function getTarget()
@@ -141,8 +143,10 @@ class Link extends AbstractElement
/**
* Get Link source
*
- * @return string
* @deprecated 0.10.0
+ *
+ * @return string
+ *
* @codeCoverageIgnore
*/
public function getLinkSrc()
@@ -153,8 +157,10 @@ class Link extends AbstractElement
/**
* Get Link name
*
- * @return string
* @deprecated 0.10.0
+ *
+ * @return string
+ *
* @codeCoverageIgnore
*/
public function getLinkName()
diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php
index 31943ba6..2721f8c2 100644
--- a/src/PhpWord/Element/Object.php
+++ b/src/PhpWord/Element/Object.php
@@ -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 @@ class Object extends AbstractElement
/**
* Get Object ID
*
- * @return int
* @deprecated 0.10.0
+ *
+ * @return int
+ *
* @codeCoverageIgnore
*/
public function getObjectId()
@@ -154,8 +157,10 @@ class Object extends AbstractElement
/**
* Set Object ID
*
- * @param int $objId
* @deprecated 0.10.0
+ *
+ * @param int $objId
+ *
* @codeCoverageIgnore
*/
public function setObjectId($objId)
diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php
index d746f69b..ea547475 100644
--- a/src/PhpWord/Element/Section.php
+++ b/src/PhpWord/Element/Section.php
@@ -153,11 +153,14 @@ class Section extends AbstractContainer
/**
* 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
*/
private function addHeaderFooter($type = Header::AUTO, $header = true)
{
@@ -183,8 +186,10 @@ class Section extends AbstractContainer
/**
* Set section style
*
- * @param array $settings
* @deprecated 0.12.0
+ *
+ * @param array $settings
+ *
* @codeCoverageIgnore
*/
public function setSettings($settings = null)
@@ -195,8 +200,10 @@ class Section extends AbstractContainer
/**
* Get section style
*
- * @return \PhpOffice\PhpWord\Style\Section
* @deprecated 0.12.0
+ *
+ * @return \PhpOffice\PhpWord\Style\Section
+ *
* @codeCoverageIgnore
*/
public function getSettings()
@@ -207,8 +214,10 @@ class Section extends AbstractContainer
/**
* Create header
*
- * @return Header
* @deprecated 0.10.0
+ *
+ * @return Header
+ *
* @codeCoverageIgnore
*/
public function createHeader()
@@ -219,8 +228,10 @@ class Section extends AbstractContainer
/**
* Create footer
*
- * @return Footer
* @deprecated 0.10.0
+ *
+ * @return Footer
+ *
* @codeCoverageIgnore
*/
public function createFooter()
@@ -231,8 +242,10 @@ class Section extends AbstractContainer
/**
* Get footer
*
- * @return Footer
* @deprecated 0.10.0
+ *
+ * @return Footer
+ *
* @codeCoverageIgnore
*/
public function getFooter()
diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php
index ab46b87e..f50ee807 100644
--- a/src/PhpWord/IOFactory.php
+++ b/src/PhpWord/IOFactory.php
@@ -20,7 +20,9 @@ abstract class IOFactory
*
* @param PhpWord $phpWord
* @param string $name
+ *
* @return WriterInterface
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
@@ -38,7 +40,9 @@ abstract class IOFactory
* Create new reader
*
* @param string $name
+ *
* @return ReaderInterface
+ *
* @throws Exception
*/
public static function createReader($name = 'Word2007')
@@ -52,7 +56,9 @@ abstract class IOFactory
* @param string $type
* @param string $name
* @param \PhpOffice\PhpWord\PhpWord $phpWord
+ *
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
private static function createObject($type, $name, $phpWord = null)
diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php
index 59735cea..baed1fbf 100644
--- a/src/PhpWord/Media.php
+++ b/src/PhpWord/Media.php
@@ -35,14 +35,17 @@ class Media
/**
* Add new media element
*
+ * @since 0.10.0
+ * @since 0.9.2
+ *
* @param string $container section|headerx|footerx|footnote|endnote
* @param string $mediaType image|object|link
* @param string $source
* @param \PhpOffice\PhpWord\Element\Image $image
+ *
* @return integer
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
- * @since 0.9.2
- * @since 0.10.0
*/
public static function addElement($container, $mediaType, $source, Image $image = null)
{
@@ -199,11 +202,14 @@ class Media
/**
* Add new Section Media Element
*
+ * @deprecated 0.10.0
+ *
* @param string $src
* @param string $type
* @param \PhpOffice\PhpWord\Element\Image $image
+ *
* @return integer
- * @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public static function addSectionMediaElement($src, $type, Image $image = null)
@@ -214,9 +220,12 @@ class Media
/**
* Add new Section Link Element
*
- * @param string $linkSrc
- * @return integer
* @deprecated 0.10.0
+ *
+ * @param string $linkSrc
+ *
+ * @return integer
+ *
* @codeCoverageIgnore
*/
public static function addSectionLinkElement($linkSrc)
@@ -227,9 +236,12 @@ class Media
/**
* Get Section Media Elements
*
- * @param string $key
- * @return array
* @deprecated 0.10.0
+ *
+ * @param string $key
+ *
+ * @return array
+ *
* @codeCoverageIgnore
*/
public static function getSectionMediaElements($key = null)
@@ -240,9 +252,12 @@ class Media
/**
* Get Section Media Elements Count
*
- * @param string $key
- * @return integer
* @deprecated 0.10.0
+ *
+ * @param string $key
+ *
+ * @return integer
+ *
* @codeCoverageIgnore
*/
public static function countSectionMediaElements($key = null)
@@ -253,11 +268,14 @@ class Media
/**
* Add new Header Media Element
*
+ * @deprecated 0.10.0
+ *
* @param integer $headerCount
* @param string $src
* @param \PhpOffice\PhpWord\Element\Image $image
+ *
* @return integer
- * @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public static function addHeaderMediaElement($headerCount, $src, Image $image = null)
@@ -268,9 +286,12 @@ class Media
/**
* Get Header Media Elements Count
*
- * @param string $key
- * @return integer
* @deprecated 0.10.0
+ *
+ * @param string $key
+ *
+ * @return integer
+ *
* @codeCoverageIgnore
*/
public static function countHeaderMediaElements($key)
@@ -281,8 +302,10 @@ class Media
/**
* Get Header Media Elements
*
- * @return array
* @deprecated 0.10.0
+ *
+ * @return array
+ *
* @codeCoverageIgnore
*/
public static function getHeaderMediaElements()
@@ -293,11 +316,14 @@ class Media
/**
* Add new Footer Media Element
*
+ * @deprecated 0.10.0
+ *
* @param integer $footerCount
* @param string $src
* @param \PhpOffice\PhpWord\Element\Image $image
+ *
* @return integer
- * @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public static function addFooterMediaElement($footerCount, $src, Image $image = null)
@@ -308,9 +334,12 @@ class Media
/**
* Get Footer Media Elements Count
*
- * @param string $key
- * @return integer
* @deprecated 0.10.0
+ *
+ * @param string $key
+ *
+ * @return integer
+ *
* @codeCoverageIgnore
*/
public static function countFooterMediaElements($key)
@@ -321,8 +350,10 @@ class Media
/**
* Get Footer Media Elements
*
- * @return array
* @deprecated 0.10.0
+ *
+ * @return array
+ *
* @codeCoverageIgnore
*/
public static function getFooterMediaElements()
diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php
index 99c95c79..cbd87edb 100644
--- a/src/PhpWord/PhpWord.php
+++ b/src/PhpWord/PhpWord.php
@@ -45,8 +45,9 @@ class PhpWord
/**
* Default font settings
*
- * @const string|int
* @deprecated 0.11.0 Use Settings constants
+ *
+ * @const string|int
*/
const DEFAULT_FONT_NAME = Settings::DEFAULT_FONT_NAME;
const DEFAULT_FONT_SIZE = Settings::DEFAULT_FONT_SIZE;
@@ -100,11 +101,14 @@ class PhpWord
/**
* Dynamic function call to reduce static dependency
*
+ * @since 0.12.0
+ *
* @param mixed $function
* @param mixed $args
- * @throws \BadMethodCallException
+ *
* @return mixed
- * @since 0.12.0
+ *
+ * @throws \BadMethodCallException
*/
public function __call($function, $args)
{
@@ -267,8 +271,12 @@ class PhpWord
* @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead.
*
* @param string $filename Fully qualified filename.
+ *
* @return TemplateProcessor
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
+ * @codeCoverageIgnore
*/
public function loadTemplate($filename)
{
@@ -319,9 +327,12 @@ class PhpWord
/**
* Create new section
*
- * @param array $settings
- * @return \PhpOffice\PhpWord\Element\Section
* @deprecated 0.10.0
+ *
+ * @param array $settings
+ *
+ * @return \PhpOffice\PhpWord\Element\Section
+ *
* @codeCoverageIgnore
*/
public function createSection($settings = null)
@@ -332,8 +343,10 @@ class PhpWord
/**
* Get document properties object
*
- * @return \PhpOffice\PhpWord\Metadata\DocInfo
* @deprecated 0.12.0
+ *
+ * @return \PhpOffice\PhpWord\Metadata\DocInfo
+ *
* @codeCoverageIgnore
*/
public function getDocumentProperties()
@@ -344,9 +357,12 @@ class PhpWord
/**
* Set document properties object
*
- * @param \PhpOffice\PhpWord\Metadata\DocInfo $documentProperties
- * @return self
* @deprecated 0.12.0
+ *
+ * @param \PhpOffice\PhpWord\Metadata\DocInfo $documentProperties
+ *
+ * @return self
+ *
* @codeCoverageIgnore
*/
public function setDocumentProperties($documentProperties)
diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php
index c08914e5..977dc5d9 100644
--- a/src/PhpWord/Reader/AbstractReader.php
+++ b/src/PhpWord/Reader/AbstractReader.php
@@ -68,7 +68,9 @@ abstract class AbstractReader implements ReaderInterface
* Open file for reading
*
* @param string $filename
+ *
* @return resource
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
protected function openFile($filename)
@@ -110,6 +112,7 @@ abstract class AbstractReader implements ReaderInterface
* Read data only?
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getReadDataOnly()
diff --git a/src/PhpWord/Reader/HTML.php b/src/PhpWord/Reader/HTML.php
index a6582a3f..83c38af1 100644
--- a/src/PhpWord/Reader/HTML.php
+++ b/src/PhpWord/Reader/HTML.php
@@ -31,7 +31,9 @@ class HTML 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.php b/src/PhpWord/Reader/RTF.php
index 9d5d813b..3dff864f 100644
--- a/src/PhpWord/Reader/RTF.php
+++ b/src/PhpWord/Reader/RTF.php
@@ -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 3f63e339..d33b5396 100644
--- a/src/PhpWord/Reader/RTF/Document.php
+++ b/src/PhpWord/Reader/RTF/Document.php
@@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Reader\RTF;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
/**
* RTF document reader
@@ -140,7 +141,7 @@ class Document
125 => 'markClosing', // }
92 => 'markBackslash', // \
10 => 'markNewline', // LF
- 13 => 'markNewline' // CR
+ 13 => 'markNewline', // CR
);
$this->phpWord = $phpWord;
@@ -159,7 +160,7 @@ class Document
$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 @@ class Document
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 @@ class Document
*/
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 @@ class Document
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 @@ class Document
*/
private function pushText($char)
{
- if ($char == '<') {
+ if ('<' == $char) {
$this->text .= "<";
- } elseif ($char == '>') {
+ } elseif ('>' == $char) {
$this->text .= ">";
} else {
$this->text .= $char;
@@ -336,7 +337,7 @@ class Document
'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', ST_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/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php
index 021bdba1..bf523f26 100644
--- a/src/PhpWord/Reader/Word2007/AbstractPart.php
+++ b/src/PhpWord/Reader/Word2007/AbstractPart.php
@@ -122,16 +122,16 @@ abstract class AbstractPart
$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 @@ abstract class AbstractPart
$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);
@@ -200,7 +200,7 @@ abstract class AbstractPart
$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);
@@ -264,26 +264,26 @@ abstract class AbstractPart
$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 @@ abstract class AbstractPart
$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);
}
}
@@ -320,7 +320,7 @@ abstract class AbstractPart
$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'),
@@ -349,7 +349,7 @@ abstract class AbstractPart
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)) {
@@ -399,7 +399,6 @@ abstract class AbstractPart
} 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');
@@ -482,13 +481,13 @@ abstract class AbstractPart
{
$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/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php
index 872d4503..f1144b1a 100644
--- a/src/PhpWord/Reader/Word2007/Numbering.php
+++ b/src/PhpWord/Reader/Word2007/Numbering.php
@@ -105,7 +105,7 @@ class Numbering extends AbstractPart
$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/Settings.php b/src/PhpWord/Settings.php
index 67b1dbed..14fa9077 100644
--- a/src/PhpWord/Settings.php
+++ b/src/PhpWord/Settings.php
@@ -407,6 +407,7 @@ class Settings
* Return the compatibility option used by the XMLWriter
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public static function getCompatibility()
diff --git a/src/PhpWord/Shared/Font.php b/src/PhpWord/Shared/Font.php
index 231b0bbd..473ef0e4 100644
--- a/src/PhpWord/Shared/Font.php
+++ b/src/PhpWord/Shared/Font.php
@@ -21,6 +21,7 @@ namespace PhpOffice\PhpWord\Shared;
* DEPRECATED: Common font functions; Use 'Converter'
*
* @deprecated 0.12.0
+ *
* @codeCoverageIgnore
*/
class Font
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index 2b4acd05..cdc88b43 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -51,7 +51,7 @@ class Html
$html = str_replace('&', '&', $html);
$html = str_replace(array('_lt_', '_gt_', '_amp_'), array('<', '>', '&'), $html);
- if ($fullHTML === false) {
+ if (false === $fullHTML) {
$html = '' . $html . '';
}
@@ -73,7 +73,7 @@ class Html
*/
protected static function parseInlineStyle($node, $styles = array())
{
- if ($node->nodeType == XML_ELEMENT_NODE) {
+ if (XML_ELEMENT_NODE == $node->nodeType) {
$attributes = $node->attributes; // get all the attributes(eg: id, class)
foreach ($attributes as $attribute) {
@@ -173,7 +173,7 @@ class Html
*/
private static function parseChildNodes($node, $element, $styles, $data)
{
- if ($node->nodeName != 'li') {
+ if ('li' != $node->nodeName) {
$cNodes = $node->childNodes;
if (count($cNodes) > 0) {
foreach ($cNodes as $cNode) {
@@ -361,7 +361,7 @@ class Html
}
break;
case 'text-align':
- $styles['align'] = $cValue;
+ $styles['alignment'] = $cValue; // todo: any mapping?
break;
case 'color':
$styles['color'] = trim($cValue, "#");
diff --git a/src/PhpWord/Shared/OLERead.php b/src/PhpWord/Shared/OLERead.php
index 82815afc..b833c4bd 100644
--- a/src/PhpWord/Shared/OLERead.php
+++ b/src/PhpWord/Shared/OLERead.php
@@ -62,6 +62,7 @@ class OLERead
* Read the file
*
* @param $sFileName string Filename
+ *
* @throws Exception
*/
public function read($sFileName)
diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php
index ca6869eb..6af1ca9b 100644
--- a/src/PhpWord/Shared/XMLReader.php
+++ b/src/PhpWord/Shared/XMLReader.php
@@ -45,7 +45,9 @@ class XMLReader
*
* @param string $zipFile
* @param string $xmlFile
+ *
* @return \DOMDocument|false
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function getDomFromZip($zipFile, $xmlFile)
diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php
index 2134f62a..26dbcc34 100644
--- a/src/PhpWord/Shared/XMLWriter.php
+++ b/src/PhpWord/Shared/XMLWriter.php
@@ -107,6 +107,7 @@ class XMLWriter
*
* @param mixed $function
* @param mixed $args
+ *
* @throws \BadMethodCallException
*/
public function __call($function, $args)
diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php
index 157959e8..c6701692 100644
--- a/src/PhpWord/Shared/ZipArchive.php
+++ b/src/PhpWord/Shared/ZipArchive.php
@@ -151,7 +151,9 @@ class ZipArchive
* Close the active archive
*
* @return bool
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
* @codeCoverageIgnore Can't find any test case. Uncomment when found.
*/
public function close()
diff --git a/src/PhpWord/SimpleType/ST_Jc.php b/src/PhpWord/SimpleType/ST_Jc.php
new file mode 100644
index 00000000..5558133c
--- /dev/null
+++ b/src/PhpWord/SimpleType/ST_Jc.php
@@ -0,0 +1,57 @@
+getStyle();
- if (!$style instanceof \PhpOffice\PhpWord\Style\Alignment) {
- return;
- }
- $value = $style->getValue();
- if ($value !== null) {
- $xmlWriter = $this->getXmlWriter();
- $xmlWriter->startElement('w:jc');
- $xmlWriter->writeAttribute('w:val', $value);
- $xmlWriter->endElement(); // w:jc
- }
+ return array(self::START, self::CENTER, self::END);
}
}
diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php
index ab1a1ee7..482712e3 100644
--- a/src/PhpWord/Style/AbstractStyle.php
+++ b/src/PhpWord/Style/AbstractStyle.php
@@ -278,7 +278,9 @@ abstract class AbstractStyle
* @param mixed $value
* @param array $enum
* @param mixed $default
+ *
* @return mixed
+ *
* @throws \InvalidArgumentException
*/
protected function setEnumVal($value = null, $enum = array(), $default = null)
@@ -337,9 +339,12 @@ abstract class AbstractStyle
/**
* Set style using associative array
*
- * @param array $style
- * @return self
* @deprecated 0.11.0
+ *
+ * @param array $style
+ *
+ * @return self
+ *
* @codeCoverageIgnore
*/
public function setArrayStyle(array $style = array())
diff --git a/src/PhpWord/Style/Alignment.php b/src/PhpWord/Style/Alignment.php
deleted file mode 100644
index 3beabe37..00000000
--- a/src/PhpWord/Style/Alignment.php
+++ /dev/null
@@ -1,78 +0,0 @@
-setStyleByArray($style);
- }
-
- /**
- * Get alignment
- *
- * @return string
- */
- public function getValue()
- {
- return $this->value;
- }
-
- /**
- * Set alignment
- *
- * @param string $value
- * @return self
- */
- public function setValue($value = null)
- {
- if (strtolower($value) == self::ALIGN_JUSTIFY) {
- $value = self::ALIGN_BOTH;
- }
- $enum = array(self::ALIGN_LEFT, self::ALIGN_RIGHT, self::ALIGN_CENTER, self::ALIGN_BOTH, self::ALIGN_JUSTIFY);
- $this->value = $this->setEnumVal($value, $enum, $this->value);
-
- return $this;
- }
-}
diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php
index 11290c87..bef56390 100644
--- a/src/PhpWord/Style/Cell.php
+++ b/src/PhpWord/Style/Cell.php
@@ -240,6 +240,7 @@ class Cell extends Border
* Get default border color
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getDefaultBorderColor()
diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php
index 8980258b..000f59fd 100644
--- a/src/PhpWord/Style/Font.php
+++ b/src/PhpWord/Style/Font.php
@@ -787,6 +787,7 @@ class Font extends AbstractStyle
* Get bold
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getBold()
@@ -798,6 +799,7 @@ class Font extends AbstractStyle
* Get italic
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getItalic()
@@ -809,6 +811,7 @@ class Font extends AbstractStyle
* Get superscript
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getSuperScript()
@@ -820,6 +823,7 @@ class Font extends AbstractStyle
* Get subscript
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getSubScript()
@@ -831,6 +835,7 @@ class Font extends AbstractStyle
* Get strikethrough
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getStrikethrough()
@@ -842,6 +847,7 @@ class Font extends AbstractStyle
* Get paragraph style
*
* @deprecated 0.11.0
+ *
* @codeCoverageIgnore
*/
public function getParagraphStyle()
diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php
index 5fef5f01..e1c7d52c 100644
--- a/src/PhpWord/Style/Frame.php
+++ b/src/PhpWord/Style/Frame.php
@@ -17,6 +17,8 @@
namespace PhpOffice\PhpWord\Style;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
+
/**
* Frame defines the size and position of an object
*
@@ -88,11 +90,9 @@ class Frame extends AbstractStyle
const WRAP_INFRONT = 'infront';
/**
- * Alignment
- *
- * @var \PhpOffice\PhpWord\Style\Alignment
+ * @var string
*/
- private $alignment;
+ private $alignment = '';
/**
* Unit
@@ -178,31 +178,59 @@ class Frame extends AbstractStyle
*/
public function __construct($style = array())
{
- $this->alignment = new Alignment();
$this->setStyleByArray($style);
}
/**
- * Get alignment
+ * @since 0.13.0
*
* @return string
*/
- public function getAlign()
+ public function getAlignment()
{
- return $this->alignment->getValue();
+ return $this->alignment;
}
/**
- * Set alignment
+ * @since 0.13.0
*
* @param string $value
+ *
* @return self
*/
+ public function setAlignment($value)
+ {
+ if (in_array($value, ST_Jc::getAllowedValues(), true)) {
+ $this->alignment = $value;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @deprecated 0.13.0 Use the `getAlignment` method instead.
+ *
+ * @return string
+ *
+ * @codeCoverageIgnore
+ */
+ public function getAlign()
+ {
+ return $this->getAlignment();
+ }
+
+ /**
+ * @deprecated 0.13.0 Use the `setAlignment` method instead.
+ *
+ * @param string $value
+ *
+ * @return self
+ *
+ * @codeCoverageIgnore
+ */
public function setAlign($value = null)
{
- $this->alignment->setValue($value);
-
- return $this;
+ return $this->setAlignment($value);
}
/**
diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php
index babfa679..5308a3ba 100644
--- a/src/PhpWord/Style/Image.php
+++ b/src/PhpWord/Style/Image.php
@@ -133,7 +133,9 @@ class Image extends Frame
* Set wrapping style
*
* @param string $wrappingStyle
+ *
* @throws \InvalidArgumentException
+ *
* @return self
*/
public function setWrappingStyle($wrappingStyle)
@@ -157,7 +159,9 @@ class Image extends Frame
* Set positioning type
*
* @param string $positioning
+ *
* @throws \InvalidArgumentException
+ *
* @return self
*/
public function setPositioning($positioning)
@@ -181,7 +185,9 @@ class Image extends Frame
* Set horizontal alignment
*
* @param string $alignment
+ *
* @throws \InvalidArgumentException
+ *
* @return self
*/
public function setPosHorizontal($alignment)
@@ -205,7 +211,9 @@ class Image extends Frame
* Set vertical alignment
*
* @param string $alignment
+ *
* @throws \InvalidArgumentException
+ *
* @return self
*/
public function setPosVertical($alignment)
@@ -229,7 +237,9 @@ class Image extends Frame
* Set horizontal relation
*
* @param string $relto
+ *
* @throws \InvalidArgumentException
+ *
* @return self
*/
public function setPosHorizontalRel($relto)
@@ -253,7 +263,9 @@ class Image extends Frame
* Set vertical relation
*
* @param string $relto
+ *
* @throws \InvalidArgumentException
+ *
* @return self
*/
public function setPosVerticalRel($relto)
diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php
index a689c691..6583f74d 100644
--- a/src/PhpWord/Style/ListItem.php
+++ b/src/PhpWord/Style/ListItem.php
@@ -155,7 +155,7 @@ class ListItem extends AbstractStyle
}
// Property mapping for numbering level information
- $properties = array('start', 'format', 'text', 'align', 'tabPos', 'left', 'hanging', 'font', 'hint');
+ $properties = array('start', 'format', 'text', 'alignment', 'tabPos', 'left', 'hanging', 'font', 'hint');
// Legacy level information
$listTypeStyles = array(
diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php
index 32e61c89..420287da 100644
--- a/src/PhpWord/Style/NumberingLevel.php
+++ b/src/PhpWord/Style/NumberingLevel.php
@@ -81,12 +81,9 @@ class NumberingLevel extends AbstractStyle
private $text;
/**
- * Align left|center|right|both
- *
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/e-w_lvlJc-1.html
*/
- private $align;
+ private $alignment;
/**
* Left
@@ -281,26 +278,55 @@ class NumberingLevel extends AbstractStyle
}
/**
- * Get align
+ * @since 0.13.0
*
* @return string
*/
- public function getAlign()
+ public function getAlignment()
{
- return $this->align;
+ return $this->alignment;
}
/**
- * Set align
+ * @since 0.13.0
*
* @param string $value
+ *
* @return self
*/
+ public function setAlignment($value)
+ {
+ if (in_array($value, Jc::getAllowedValues(), true)) {
+ $this->alignment = $value;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @deprecated 0.13.0 Use the `getAlignment` method instead.
+ *
+ * @return string
+ *
+ * @codeCoverageIgnore
+ */
+ public function getAlign()
+ {
+ return $this->getAlignment();
+ }
+
+ /**
+ * @deprecated 0.13.0 Use the `setAlignment` method instead.
+ *
+ * @param string $value
+ *
+ * @return self
+ *
+ * @codeCoverageIgnore
+ */
public function setAlign($value)
{
- $enum = array('left', 'center', 'right', 'both');
- $this->align = $this->setEnumVal($value, $enum, $this->align);
- return $this;
+ return $this->setAlignment($value);
}
/**
diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php
index ff89b9d5..ba2a6ac2 100644
--- a/src/PhpWord/Style/Paragraph.php
+++ b/src/PhpWord/Style/Paragraph.php
@@ -19,13 +19,13 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Exception\InvalidStyleException;
use PhpOffice\PhpWord\Shared\String;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
/**
* Paragraph style
*
* OOXML:
* - General: alignment, outline level
- * - Alignment: left, right, center, both
* - Indentation: left, right, firstline, hanging
* - Spacing: before, after, line spacing
* - Pagination: widow control, keep next, keep line, page break before
@@ -77,11 +77,9 @@ class Paragraph extends Border
private $next;
/**
- * Alignment
- *
- * @var \PhpOffice\PhpWord\Style\Alignment
+ * @var string
*/
- private $alignment;
+ private $alignment = '';
/**
* Indentation
@@ -170,9 +168,9 @@ class Paragraph extends Border
public function setStyleValue($key, $value)
{
$key = String::removeUnderscorePrefix($key);
- if ($key == 'indent' || $key == 'hanging') {
+ if ('indent' == $key || 'hanging' == $key) {
$value = $value * 720;
- } elseif ($key == 'spacing') {
+ } elseif ('spacing' == $key) {
$value += 240; // because line height of 1 matches 240 twips
}
@@ -216,9 +214,9 @@ class Paragraph extends Border
}
/**
- * Get alignment
+ * @since 0.13.0
*
- * @return \PhpOffice\PhpWord\Style\Alignment
+ * @return string
*/
public function getAlignment()
{
@@ -226,18 +224,47 @@ class Paragraph extends Border
}
/**
- * Set alignment
+ * @since 0.13.0
*
* @param string $value
+ *
* @return self
*/
- public function setAlignment($value = null)
+ public function setAlignment($value)
{
- $this->setObjectVal(array('value' => $value), 'Alignment', $this->alignment);
+ if (in_array($value, ST_Jc::getAllowedValues(), true)) {
+ $this->alignment = $value;
+ }
return $this;
}
+ /**
+ * @deprecated 0.13.0 Use the `getAlignment` method instead.
+ *
+ * @return string
+ *
+ * @codeCoverageIgnore
+ */
+ public function getAlign()
+ {
+ return $this->getAlignment();
+ }
+
+ /**
+ * @deprecated 0.13.0 Use the `setAlignment` method instead.
+ *
+ * @param string $value
+ *
+ * @return self
+ *
+ * @codeCoverageIgnore
+ */
+ public function setAlign($value = null)
+ {
+ return $this->setAlignment($value);
+ }
+
/**
* Get parent style ID
*
@@ -451,7 +478,9 @@ class Paragraph extends Border
* Set the line height
*
* @param int|float|string $lineHeight
+ *
* @return self
+ *
* @throws \PhpOffice\PhpWord\Exception\InvalidStyleException
*/
public function setLineHeight($lineHeight)
@@ -636,6 +665,7 @@ class Paragraph extends Border
* Get allow first/last line to display on a separate page setting
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getWidowControl()
@@ -647,6 +677,7 @@ class Paragraph extends Border
* Get keep paragraph with next paragraph setting
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getKeepNext()
@@ -658,6 +689,7 @@ class Paragraph extends Border
* Get keep all lines on one page setting
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getKeepLines()
@@ -669,6 +701,7 @@ class Paragraph extends Border
* Get start paragraph on next page setting
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getPageBreakBefore()
diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php
index 45897aed..d88af652 100644
--- a/src/PhpWord/Style/Row.php
+++ b/src/PhpWord/Style/Row.php
@@ -125,6 +125,7 @@ class Row extends AbstractStyle
* Get tblHeader
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getTblHeader()
@@ -136,6 +137,7 @@ class Row extends AbstractStyle
* Get cantSplit
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getCantSplit()
@@ -147,6 +149,7 @@ class Row extends AbstractStyle
* Get exactHeight
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getExactHeight()
diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php
index 128e8e6b..b81e4393 100644
--- a/src/PhpWord/Style/Section.php
+++ b/src/PhpWord/Style/Section.php
@@ -35,14 +35,14 @@ class Section extends Border
*
* @const int|float
*/
- const DEFAULT_WIDTH = 11870; // In twip
- const DEFAULT_HEIGHT = 16787; // In twip
- const DEFAULT_MARGIN = 1440; // In twip
- const DEFAULT_GUTTER = 0; // In twip
- const DEFAULT_HEADER_HEIGHT = 720; // In twip
- const DEFAULT_FOOTER_HEIGHT = 720; // In twip
+ const DEFAULT_WIDTH = 11870; // In twips.
+ const DEFAULT_HEIGHT = 16787; // In twips.
+ const DEFAULT_MARGIN = 1440; // In twips.
+ const DEFAULT_GUTTER = 0; // In twips.
+ const DEFAULT_HEADER_HEIGHT = 720; // In twips.
+ const DEFAULT_FOOTER_HEIGHT = 720; // In twips.
const DEFAULT_COLUMN_COUNT = 1;
- const DEFAULT_COLUMN_SPACING = 720; // In twip
+ const DEFAULT_COLUMN_SPACING = 720; // In twips.
/**
* Page Orientation
diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php
index 52855652..8f6022cf 100644
--- a/src/PhpWord/Style/TOC.php
+++ b/src/PhpWord/Style/TOC.php
@@ -25,8 +25,9 @@ class TOC extends Tab
/**
* Tab leader types for backward compatibility
*
- * @const string
* @deprecated 0.11.0
+ *
+ * @const string
*/
const TABLEADER_DOT = self::TAB_LEADER_DOT;
const TABLEADER_UNDERSCORE = self::TAB_LEADER_UNDERSCORE;
diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php
index 24f50667..c92df68a 100644
--- a/src/PhpWord/Style/Table.php
+++ b/src/PhpWord/Style/Table.php
@@ -17,9 +17,8 @@
namespace PhpOffice\PhpWord\Style;
-/**
- * Table style
- */
+use PhpOffice\PhpWord\SimpleType\ST_JcTable;
+
class Table extends Border
{
/**
@@ -107,9 +106,9 @@ class Table extends Border
private $shading;
/**
- * @var \PhpOffice\PhpWord\Style\Alignment Alignment
+ * @var string
*/
- private $alignment;
+ private $alignment = '';
/**
* @var int|float Width value
@@ -129,8 +128,6 @@ class Table extends Border
*/
public function __construct($tableStyle = null, $firstRowStyle = null)
{
- $this->alignment = new Alignment();
-
// Clone first row from table style, but with certain properties disabled
if ($firstRowStyle !== null && is_array($firstRowStyle)) {
$this->firstRowStyle = clone $this;
@@ -494,26 +491,55 @@ class Table extends Border
}
/**
- * Get alignment
+ * @since 0.13.0
*
* @return string
*/
- public function getAlign()
+ public function getAlignment()
{
- return $this->alignment->getValue();
+ return $this->alignment;
}
/**
- * Set alignment
+ * @since 0.13.0
*
* @param string $value
+ *
* @return self
*/
+ public function setAlignment($value)
+ {
+ if (in_array($value, ST_JcTable::getAllowedValues(), true)) {
+ $this->alignment = $value;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @deprecated 0.13.0 Use the `getAlignment` method instead.
+ *
+ * @return string
+ *
+ * @codeCoverageIgnore
+ */
+ public function getAlign()
+ {
+ return $this->getAlignment();
+ }
+
+ /**
+ * @deprecated 0.13.0 Use the `setAlignment` method instead.
+ *
+ * @param string $value
+ *
+ * @return self
+ *
+ * @codeCoverageIgnore
+ */
public function setAlign($value = null)
{
- $this->alignment->setValue($value);
-
- return $this;
+ return $this->setAlignment($value);
}
/**
@@ -574,7 +600,7 @@ class Table extends Border
*/
private function getTableOnlyProperty($property)
{
- if ($this->isFirstRow === false) {
+ if (false === $this->isFirstRow) {
return $this->$property;
}
@@ -594,8 +620,8 @@ class Table extends Border
*/
private function setTableOnlyProperty($property, $value, $isNumeric = true)
{
- if ($this->isFirstRow === false) {
- if ($isNumeric === true) {
+ if (false === $this->isFirstRow) {
+ if (true === $isNumeric) {
$this->$property = $this->setNumericVal($value, $this->$property);
} else {
$this->$property = $value;
diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php
index f6ad790e..81e31864 100644
--- a/src/PhpWord/Template.php
+++ b/src/PhpWord/Template.php
@@ -18,7 +18,9 @@
namespace PhpOffice\PhpWord;
/**
- * @deprecated 0.12.0 Use \PhpOffice\PhpWord\TemplateProcessor instead.
+ * @deprecated 0.12.0 Use `\PhpOffice\PhpWord\TemplateProcessor` instead.
+ *
+ * @codeCoverageIgnore
*/
class Template extends TemplateProcessor
{
diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php
index 599d8a6f..686a4b18 100644
--- a/src/PhpWord/Writer/AbstractWriter.php
+++ b/src/PhpWord/Writer/AbstractWriter.php
@@ -97,6 +97,7 @@ abstract class AbstractWriter implements WriterInterface
* Get PhpWord object
*
* @return \PhpOffice\PhpWord\PhpWord
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function getPhpWord()
@@ -150,7 +151,9 @@ abstract class AbstractWriter implements WriterInterface
*
* @param bool $value
* @param string $directory
+ *
* @return self
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function setUseDiskCaching($value = false, $directory = null)
@@ -234,6 +237,7 @@ abstract class AbstractWriter implements WriterInterface
* Cleanup temporary file.
*
* @return void
+ *
* @throws \PhpOffice\PhpWord\Exception\CopyFileException
*/
protected function cleanupTempFile()
@@ -267,7 +271,9 @@ abstract class AbstractWriter implements WriterInterface
* Get ZipArchive object
*
* @param string $filename
+ *
* @return \PhpOffice\PhpWord\Shared\ZipArchive
+ *
* @throws \Exception
*/
protected function getZipArchive($filename)
@@ -295,10 +301,13 @@ abstract class AbstractWriter implements WriterInterface
/**
* Open file for writing
*
- * @param string $filename
- * @return resource
- * @throws \Exception
* @since 0.11.0
+ *
+ * @param string $filename
+ *
+ * @return resource
+ *
+ * @throws \Exception
*/
protected function openFile($filename)
{
@@ -423,6 +432,7 @@ abstract class AbstractWriter implements WriterInterface
* Get use disk caching status
*
* @deprecated 0.10.0
+ *
* @codeCoverageIgnore
*/
public function getUseDiskCaching()
diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php
index 5c58acfc..7c9aaf1f 100644
--- a/src/PhpWord/Writer/HTML.php
+++ b/src/PhpWord/Writer/HTML.php
@@ -64,7 +64,9 @@ class HTML extends AbstractWriter implements WriterInterface
* Save PhpWord to file.
*
* @param string $filename
+ *
* @return void
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function save($filename = null)
@@ -127,8 +129,10 @@ class HTML extends AbstractWriter implements WriterInterface
/**
* Write document
*
- * @return string
* @deprecated 0.11.0
+ *
+ * @return string
+ *
* @codeCoverageIgnore
*/
public function writeDocument()
diff --git a/src/PhpWord/Writer/HTML/Part/AbstractPart.php b/src/PhpWord/Writer/HTML/Part/AbstractPart.php
index 124cc15a..c63424fd 100644
--- a/src/PhpWord/Writer/HTML/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/HTML/Part/AbstractPart.php
@@ -56,6 +56,7 @@ abstract class AbstractPart
* Get parent writer
*
* @return \PhpOffice\PhpWord\Writer\AbstractWriter
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function getParentWriter()
diff --git a/src/PhpWord/Writer/HTML/Style/Paragraph.php b/src/PhpWord/Writer/HTML/Style/Paragraph.php
index 0d7df22d..4604e374 100644
--- a/src/PhpWord/Writer/HTML/Style/Paragraph.php
+++ b/src/PhpWord/Writer/HTML/Style/Paragraph.php
@@ -38,10 +38,8 @@ class Paragraph extends AbstractStyle
$css = array();
// Alignment
- $alignment = $style->getAlignment();
- if (!is_null($alignment)) {
- $alignmentValue = $alignment->getValue();
- $css['text-align'] = $this->getValueIf(!is_null($alignmentValue), $alignmentValue);
+ if ('' !== $style->getAlignment()) {
+ $css['text-align'] = $style->getAlignment(); // todo: convert OpenXml to Html values
}
// Spacing
diff --git a/src/PhpWord/Writer/PDF.php b/src/PhpWord/Writer/PDF.php
index 17865563..2d3429c5 100644
--- a/src/PhpWord/Writer/PDF.php
+++ b/src/PhpWord/Writer/PDF.php
@@ -39,6 +39,7 @@ class PDF
* Instantiate a new renderer of the configured type within this container class
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function __construct(PhpWord $phpWord)
diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php
index 572e4b1d..679d9500 100644
--- a/src/PhpWord/Writer/PDF/AbstractRenderer.php
+++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php
@@ -77,6 +77,7 @@ abstract class AbstractRenderer extends HTML
* Create new instance
*
* @param PhpWord $phpWord PhpWord object
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function __construct(PhpWord $phpWord)
@@ -169,7 +170,9 @@ abstract class AbstractRenderer extends HTML
* Save PhpWord to PDF file, pre-save
*
* @param string $filename Name of the file to save as
+ *
* @return resource
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
protected function prepareForSave($filename = null)
@@ -190,7 +193,9 @@ abstract class AbstractRenderer extends HTML
* Save PhpWord to PDF file, post-save
*
* @param resource $fileHandle
+ *
* @return void
+ *
* @throws Exception
*/
protected function restoreStateAfterSave($fileHandle)
diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php
index 58210c99..ae1fa243 100644
--- a/src/PhpWord/Writer/RTF.php
+++ b/src/PhpWord/Writer/RTF.php
@@ -58,7 +58,9 @@ class RTF extends AbstractWriter implements WriterInterface
* Save content to file.
*
* @param string $filename
+ *
* @return void
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function save($filename = null)
diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php
index fc74b1dd..aed59c94 100644
--- a/src/PhpWord/Writer/RTF/Style/Paragraph.php
+++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php
@@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\RTF\Style;
-use PhpOffice\PhpWord\Style\Alignment;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
/**
* RTF paragraph style writer
@@ -48,13 +48,12 @@ class Paragraph extends AbstractStyle
}
$alignments = array(
- Alignment::ALIGN_LEFT => '\ql',
- Alignment::ALIGN_RIGHT => '\qr',
- Alignment::ALIGN_CENTER => '\qc',
- Alignment::ALIGN_BOTH => '\qj',
+ ST_Jc::START => '\ql',
+ ST_Jc::END => '\qr',
+ ST_Jc::CENTER => '\qc',
+ ST_Jc::BOTH => '\qj',
);
- $alignment = $style->getAlignment();
$spaceAfter = $style->getSpaceAfter();
$spaceBefore = $style->getSpaceBefore();
@@ -62,8 +61,8 @@ class Paragraph extends AbstractStyle
if ($this->nestedLevel == 0) {
$content .= '\pard\nowidctlpar ';
}
- if (!is_null($alignment) && isset($alignments[$alignment->getValue()])) {
- $content .= $alignments[$alignment->getValue()];
+ if (isset($alignments[$style->getAlignment()])) {
+ $content .= $alignments[$style->getAlignment()];
}
$content .= $this->getValueIf($spaceBefore !== null, '\sb' . $spaceBefore);
$content .= $this->getValueIf($spaceAfter !== null, '\sa' . $spaceAfter);
diff --git a/src/PhpWord/Writer/Word2007/Element/ParagraphAlignment.php b/src/PhpWord/Writer/Word2007/Element/ParagraphAlignment.php
new file mode 100644
index 00000000..1c2650e2
--- /dev/null
+++ b/src/PhpWord/Writer/Word2007/Element/ParagraphAlignment.php
@@ -0,0 +1,60 @@
+attributes['w:val'] = $value;
+ }
+
+ /**
+ * @since 0.13.0
+ *
+ * @return string
+ */
+ final public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @since 0.13.0
+ *
+ * @return string[]
+ */
+ final public function getAttributes()
+ {
+ return $this->attributes;
+ }
+}
diff --git a/src/PhpWord/Writer/Word2007/Element/TableAlignment.php b/src/PhpWord/Writer/Word2007/Element/TableAlignment.php
new file mode 100644
index 00000000..c13be632
--- /dev/null
+++ b/src/PhpWord/Writer/Word2007/Element/TableAlignment.php
@@ -0,0 +1,60 @@
+attributes['w:val'] = $value;
+ }
+
+ /**
+ * @since 0.13.0
+ *
+ * @return string
+ */
+ final public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @since 0.13.0
+ *
+ * @return string[]
+ */
+ final public function getAttributes()
+ {
+ return $this->attributes;
+ }
+}
diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
index e26853d7..71a268d9 100644
--- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
@@ -60,6 +60,7 @@ abstract class AbstractPart
* Get parent writer
*
* @return \PhpOffice\PhpWord\Writer\AbstractWriter
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function getParentWriter()
diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php
index bbb8eeb4..742aecc2 100644
--- a/src/PhpWord/Writer/Word2007/Part/Numbering.php
+++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php
@@ -18,9 +18,9 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
+use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
use PhpOffice\PhpWord\Style\NumberingLevel;
-use PhpOffice\PhpWord\Style;
/**
* Word2007 numbering part writer: word/numbering.xml
@@ -108,13 +108,13 @@ class Numbering extends AbstractPart
// Numbering level properties
$properties = array(
- 'start' => 'start',
- 'format' => 'numFmt',
- 'restart' => 'lvlRestart',
- 'pStyle' => 'pStyle',
- 'suffix' => 'suff',
- 'text' => 'lvlText',
- 'align' => 'lvlJc'
+ 'start' => 'start',
+ 'format' => 'numFmt',
+ 'restart' => 'lvlRestart',
+ 'pStyle' => 'pStyle',
+ 'suffix' => 'suff',
+ 'text' => 'lvlText',
+ 'alignment' => 'lvlJc'
);
foreach ($properties as $property => $nodeName) {
$getMethod = "get{$property}";
diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php
index 9a7f444b..8327f5c9 100644
--- a/src/PhpWord/Writer/Word2007/Part/Rels.php
+++ b/src/PhpWord/Writer/Word2007/Part/Rels.php
@@ -108,7 +108,9 @@ class Rels extends AbstractPart
* @param string $type Relationship type
* @param string $target Relationship target
* @param string $targetMode Relationship target mode
+ *
* @return void
+ *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '')
diff --git a/src/PhpWord/Writer/Word2007/Style/Frame.php b/src/PhpWord/Writer/Word2007/Style/Frame.php
index 28ebeaf5..ec6c1be5 100644
--- a/src/PhpWord/Writer/Word2007/Style/Frame.php
+++ b/src/PhpWord/Writer/Word2007/Style/Frame.php
@@ -18,8 +18,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
use PhpOffice\PhpWord\Shared\XMLWriter;
-use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle;
use PhpOffice\PhpWord\Style\Frame as FrameStyle;
+use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
/**
* Frame style writer
@@ -89,13 +89,21 @@ class Frame extends AbstractStyle
$xmlWriter = $this->getXmlWriter();
$xmlWriter->startElement('w:pPr');
- $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign())));
- $styleWriter->write();
- $xmlWriter->endElement(); // w:pPr
+
+ if ('' !== $style->getAlignment()) {
+ $paragraphAlignment = new ParagraphAlignment($style->getAlignment());
+ $xmlWriter->startElement($paragraphAlignment->getName());
+ foreach ($paragraphAlignment->getAttributes() as $attributeName => $attributeValue) {
+ $xmlWriter->writeAttribute($attributeName, $attributeValue);
+ }
+ $xmlWriter->endElement();
+ }
+
+ $xmlWriter->endElement();
}
/**
- * Write alignment.
+ * Write wrap.
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Frame $style
diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php
index f9a49bba..cd25fdc8 100644
--- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php
+++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php
@@ -20,6 +20,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
+use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
/**
* Paragraph style writer
@@ -96,8 +97,17 @@ class Paragraph extends AbstractStyle
$xmlWriter->writeElementIf($styles['pagination']['keepLines'] === true, 'w:keepLines', 'w:val', '1');
$xmlWriter->writeElementIf($styles['pagination']['pageBreak'] === true, 'w:pageBreakBefore', 'w:val', '1');
+ // Paragraph alignment
+ if ('' !== $styles['alignment']) {
+ $paragraphAlignment = new ParagraphAlignment($styles['alignment']);
+ $xmlWriter->startElement($paragraphAlignment->getName());
+ foreach ($paragraphAlignment->getAttributes() as $attributeName => $attributeValue) {
+ $xmlWriter->writeAttribute($attributeName, $attributeValue);
+ }
+ $xmlWriter->endElement();
+ }
+
// Child style: alignment, indentation, spacing, and shading
- $this->writeChildStyle($xmlWriter, 'Alignment', $styles['alignment']);
$this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']);
$this->writeChildStyle($xmlWriter, 'Spacing', $styles['spacing']);
$this->writeChildStyle($xmlWriter, 'Shading', $styles['shading']);
diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php
index 8bbad107..08eec00e 100644
--- a/src/PhpWord/Writer/Word2007/Style/Table.php
+++ b/src/PhpWord/Writer/Word2007/Style/Table.php
@@ -18,8 +18,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
use PhpOffice\PhpWord\Shared\XMLWriter;
-use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle;
use PhpOffice\PhpWord\Style\Table as TableStyle;
+use PhpOffice\PhpWord\Writer\Word2007\Element\TableAlignment;
/**
* Table style writer
@@ -50,7 +50,7 @@ class Table extends AbstractStyle
$xmlWriter->startElement('w:tblStyle');
$xmlWriter->writeAttribute('w:val', $style);
$xmlWriter->endElement();
- if ($this->width !== null) {
+ if (null !== $this->width) {
$this->writeWidth($xmlWriter, $this->width, 'pct');
}
$xmlWriter->endElement();
@@ -69,9 +69,15 @@ class Table extends AbstractStyle
// w:tblPr
$xmlWriter->startElement('w:tblPr');
- // Alignment
- $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign())));
- $styleWriter->write();
+ // Table alignment
+ if ('' !== $style->getAlignment()) {
+ $tableAlignment = new TableAlignment($style->getAlignment());
+ $xmlWriter->startElement($tableAlignment->getName());
+ foreach ($tableAlignment->getAttributes() as $attributeName => $attributeValue) {
+ $xmlWriter->writeAttribute($attributeName, $attributeValue);
+ }
+ $xmlWriter->endElement();
+ }
$this->writeWidth($xmlWriter, $style->getWidth(), $style->getUnit());
$this->writeMargin($xmlWriter, $style);
@@ -174,7 +180,7 @@ class Table extends AbstractStyle
*/
private function writeShading(XMLWriter $xmlWriter, TableStyle $style)
{
- if ($style->getShading() !== null) {
+ if (null !== $style->getShading()) {
$xmlWriter->startElement('w:tcPr');
$styleWriter = new Shading($xmlWriter, $style->getShading());
diff --git a/tests/PhpWord/Tests/Element/CheckBoxTest.php b/tests/PhpWord/Tests/Element/CheckBoxTest.php
index 942c908d..0e9b9682 100644
--- a/tests/PhpWord/Tests/Element/CheckBoxTest.php
+++ b/tests/PhpWord/Tests/Element/CheckBoxTest.php
@@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Element\CheckBox;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Font;
/**
@@ -81,7 +82,7 @@ class CheckBoxTest extends \PHPUnit_Framework_TestCase
$oCheckBox = new CheckBox(htmlspecialchars('chkBox', ENT_COMPAT, 'UTF-8'), htmlspecialchars('CheckBox', ENT_COMPAT, 'UTF-8'), 'fontStyle', 'paragraphStyle');
$this->assertEquals('paragraphStyle', $oCheckBox->getParagraphStyle());
- $oCheckBox->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
+ $oCheckBox->setParagraphStyle(array('alignment' => ST_Jc::CENTER, 'spaceAfter' => 100));
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oCheckBox->getParagraphStyle());
}
}
diff --git a/tests/PhpWord/Tests/Element/ImageTest.php b/tests/PhpWord/Tests/Element/ImageTest.php
index e73abb2a..7e8ef94c 100644
--- a/tests/PhpWord/Tests/Element/ImageTest.php
+++ b/tests/PhpWord/Tests/Element/ImageTest.php
@@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Element\Image;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
/**
* Test class for PhpOffice\PhpWord\Element\Image
@@ -54,7 +55,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
array(
'width' => 210,
'height' => 210,
- 'align' => 'center',
+ 'alignment' => ST_Jc::CENTER,
'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND,
)
);
@@ -97,7 +98,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
{
$oImage = new Image(
__DIR__ . '/../_files/images/earth.jpg',
- array('height' => 210, 'align' => 'center')
+ array('height' => 210, 'alignment' => ST_Jc::CENTER)
);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle());
diff --git a/tests/PhpWord/Tests/Element/PreserveTextTest.php b/tests/PhpWord/Tests/Element/PreserveTextTest.php
index 05cfded3..36a0e572 100644
--- a/tests/PhpWord/Tests/Element/PreserveTextTest.php
+++ b/tests/PhpWord/Tests/Element/PreserveTextTest.php
@@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Element\PreserveText;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
/**
* Test class for PhpOffice\PhpWord\Element\PreserveText
@@ -58,7 +59,7 @@ class PreserveTextTest extends \PHPUnit_Framework_TestCase
$oPreserveText = new PreserveText(
htmlspecialchars('text', ENT_COMPAT, 'UTF-8'),
array('size' => 16, 'color' => '1B2232'),
- array('alignment' => 'center')
+ array('alignment' => ST_Jc::CENTER)
);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oPreserveText->getFontStyle());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oPreserveText->getParagraphStyle());
diff --git a/tests/PhpWord/Tests/Element/TextTest.php b/tests/PhpWord/Tests/Element/TextTest.php
index 3112dbfa..34f742a2 100644
--- a/tests/PhpWord/Tests/Element/TextTest.php
+++ b/tests/PhpWord/Tests/Element/TextTest.php
@@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Element\Text;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Font;
/**
@@ -80,7 +81,7 @@ class TextTest extends \PHPUnit_Framework_TestCase
$oText = new Text(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), 'fontStyle', 'paragraphStyle');
$this->assertEquals('paragraphStyle', $oText->getParagraphStyle());
- $oText->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
+ $oText->setParagraphStyle(array('alignment' => ST_Jc::CENTER, 'spaceAfter' => 100));
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
}
}
diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php
index 23b2eae4..24255c39 100644
--- a/tests/PhpWord/Tests/Style/FontTest.php
+++ b/tests/PhpWord/Tests/Style/FontTest.php
@@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Style;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
@@ -41,7 +42,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
*/
public function testInitiation()
{
- $object = new Font(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), array('align' => 'both'));
+ $object = new Font(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), array('alignment' => ST_Jc::BOTH));
$this->assertEquals(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), $object->getStyleType());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle());
@@ -157,7 +158,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
*/
public function testLineHeightFloatval()
{
- $object = new Font(null, array('align' => 'center'));
+ $object = new Font(null, array('alignment' => ST_Jc::CENTER));
$object->setLineHeight('1.5pt');
$this->assertEquals(1.5, $object->getLineHeight());
}
diff --git a/tests/PhpWord/Tests/Style/ImageTest.php b/tests/PhpWord/Tests/Style/ImageTest.php
index 08ec9a99..741bd4b3 100644
--- a/tests/PhpWord/Tests/Style/ImageTest.php
+++ b/tests/PhpWord/Tests/Style/ImageTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Style;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Image;
/**
@@ -37,7 +38,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
$properties = array(
'width' => 200,
'height' => 200,
- 'align' => 'left',
+ 'alignment' => ST_Jc::START,
'marginTop' => 240,
'marginLeft' => 240,
'wrappingStyle' => 'inline',
@@ -60,7 +61,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
$properties = array(
'width' => 200,
'height' => 200,
- 'align' => 'left',
+ 'alignment' => ST_Jc::START,
'marginTop' => 240,
'marginLeft' => 240,
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
diff --git a/tests/PhpWord/Tests/Style/NumberingLevelTest.php b/tests/PhpWord/Tests/Style/NumberingLevelTest.php
index 69864bdc..e7522057 100644
--- a/tests/PhpWord/Tests/Style/NumberingLevelTest.php
+++ b/tests/PhpWord/Tests/Style/NumberingLevelTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Style;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\NumberingLevel;
/**
@@ -34,19 +35,19 @@ class NumberingLevelTest extends \PHPUnit_Framework_TestCase
$object = new NumberingLevel();
$attributes = array(
- 'level' => 1,
- 'start' => 1,
- 'format' => 'decimal',
- 'restart' => 1,
- 'pStyle' => 'pStyle',
- 'suffix' => 'space',
- 'text' => '%1.',
- 'align' => 'left',
- 'left' => 360,
- 'hanging' => 360,
- 'tabPos' => 360,
- 'font' => 'Arial',
- 'hint' => 'default',
+ 'level' => 1,
+ 'start' => 1,
+ 'format' => 'decimal',
+ 'restart' => 1,
+ 'pStyle' => 'pStyle',
+ 'suffix' => 'space',
+ 'text' => '%1.',
+ 'alignment' => ST_Jc::START,
+ 'left' => 360,
+ 'hanging' => 360,
+ 'tabPos' => 360,
+ 'font' => 'Arial',
+ 'hint' => 'default',
);
foreach ($attributes as $key => $value) {
$set = "set{$key}";
diff --git a/tests/PhpWord/Tests/Style/TableTest.php b/tests/PhpWord/Tests/Style/TableTest.php
index e63d8678..f81211a6 100644
--- a/tests/PhpWord/Tests/Style/TableTest.php
+++ b/tests/PhpWord/Tests/Style/TableTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Style;
+use PhpOffice\PhpWord\SimpleType\ST_JcTable;
use PhpOffice\PhpWord\Style\Table;
/**
@@ -74,7 +75,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
'cellMarginLeft' => 240,
'cellMarginRight' => 240,
'cellMarginBottom' => 240,
- 'align' => 'center',
+ 'alignment' => ST_JcTable::CENTER,
'width' => 100,
'unit' => 'pct',
);
diff --git a/tests/PhpWord/Tests/Style/TextBoxTest.php b/tests/PhpWord/Tests/Style/TextBoxTest.php
index eb1a31a4..3334f1e5 100644
--- a/tests/PhpWord/Tests/Style/TextBoxTest.php
+++ b/tests/PhpWord/Tests/Style/TextBoxTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Style;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\TextBox;
/**
@@ -37,7 +38,7 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
$properties = array(
'width' => 200,
'height' => 200,
- 'align' => 'left',
+ 'alignment' => ST_Jc::START,
'marginTop' => 240,
'marginLeft' => 240,
'wrappingStyle' => 'inline',
@@ -71,7 +72,7 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
$properties = array(
'width' => 200,
'height' => 200,
- 'align' => 'left',
+ 'alignment' => ST_Jc::START,
'marginTop' => 240,
'marginLeft' => 240,
'wrappingStyle' => 'inline',
@@ -132,10 +133,11 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
*/
public function testSetGetAlign()
{
- $expected = 'left';
- $object = new TextBox();
- $object->setAlign($expected);
- $this->assertEquals($expected, $object->getAlign());
+ $textBox = new TextBox();
+
+ $expectedAlignment = ST_Jc::START;
+ $textBox->setAlignment($expectedAlignment);
+ $this->assertEquals($expectedAlignment, $textBox->getAlignment());
}
/**
diff --git a/tests/PhpWord/Tests/StyleTest.php b/tests/PhpWord/Tests/StyleTest.php
index 261de31c..b2d02242 100644
--- a/tests/PhpWord/Tests/StyleTest.php
+++ b/tests/PhpWord/Tests/StyleTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style;
/**
@@ -44,7 +45,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
*/
public function testStyles()
{
- $paragraph = array('align' => 'center');
+ $paragraph = array('alignment' => ST_Jc::CENTER);
$font = array('italic' => true, '_bold' => true);
$table = array('bgColor' => 'CCCCCC');
$styles = array(
@@ -82,7 +83,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
*/
public function testDefaultParagraphStyle()
{
- $paragraph = array('align' => 'center');
+ $paragraph = array('alignment' => ST_Jc::CENTER);
Style::setDefaultParagraphStyle($paragraph);
diff --git a/tests/PhpWord/Tests/TemplateProcessorTest.php b/tests/PhpWord/Tests/TemplateProcessorTest.php
index f75f7d3b..3683bb79 100644
--- a/tests/PhpWord/Tests/TemplateProcessorTest.php
+++ b/tests/PhpWord/Tests/TemplateProcessorTest.php
@@ -70,11 +70,13 @@ final class TemplateProcessorTest extends \PHPUnit_Framework_TestCase
/**
* XSL stylesheet can be applied.
*
- * @param string $actualDocumentFqfn
- * @throws \Exception
+ * @test
* @covers ::applyXslStyleSheet
* @depends testTemplateCanBeSavedInTemporaryLocation
- * @test
+ *
+ * @param string $actualDocumentFqfn
+ *
+ * @throws \Exception
*/
final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn)
{
diff --git a/tests/PhpWord/Tests/Writer/HTMLTest.php b/tests/PhpWord/Tests/Writer/HTMLTest.php
index 7bdfc710..eca06326 100644
--- a/tests/PhpWord/Tests/Writer/HTMLTest.php
+++ b/tests/PhpWord/Tests/Writer/HTMLTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Writer\HTML;
/**
@@ -69,7 +70,7 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
'Font',
array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000')
);
- $phpWord->addParagraphStyle('Paragraph', array('align' => 'center', 'spaceAfter' => 20, 'spaceBefore' => 20));
+ $phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER, 'spaceAfter' => 20, 'spaceBefore' => 20));
$section = $phpWord->addSection();
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
$section->addTextBreak();
@@ -90,7 +91,7 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
$section = $phpWord->addSection();
- $textrun = $section->addTextRun(array('align' => 'center'));
+ $textrun = $section->addTextRun(array('alignment' => ST_Jc::CENTER));
$textrun->addText(htmlspecialchars('Test 3', ENT_COMPAT, 'UTF-8'));
$textrun->addTextBreak();
diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php
index 33ffd176..b34737c9 100644
--- a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php
+++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/**
@@ -51,7 +52,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
$phpWord->setDefaultFontName('Verdana');
$phpWord->addFontStyle('Font', array('size' => 11));
- $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
+ $phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
$phpWord->addTableStyle('tblStyle', array('width' => 100));
$section = $phpWord->addSection(array('colsNum' => 2));
diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php
index 8bf8eb02..b474ae04 100644
--- a/tests/PhpWord/Tests/Writer/ODTextTest.php
+++ b/tests/PhpWord/Tests/Writer/ODTextTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Writer\ODText;
/**
@@ -71,7 +72,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord();
$phpWord->addFontStyle('Font', array('size' => 11));
- $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
+ $phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
$section = $phpWord->addSection();
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font');
$section->addTextBreak();
diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php
index a469e936..ffa70871 100644
--- a/tests/PhpWord/Tests/Writer/RTFTest.php
+++ b/tests/PhpWord/Tests/Writer/RTFTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Writer\RTF;
/**
@@ -62,7 +63,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
'Font',
array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => '00FF00')
);
- $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
+ $phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
$section = $phpWord->addSection();
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
$section->addTextBreak();
diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php
index 6c68ec75..8ad43b7e 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
@@ -90,7 +91,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
'borderColor' => '#FF0',
)
);
- $section->addTextBox(array('wrappingStyle' => 'tight', 'positioning' => 'absolute', 'align' => 'center'));
+ $section->addTextBox(array('wrappingStyle' => 'tight', 'positioning' => 'absolute', 'alignment' => ST_Jc::CENTER));
$section->addListItemRun()->addText(htmlspecialchars('List item run 1', ENT_COMPAT, 'UTF-8'));
$section->addField(
'DATE',
@@ -157,7 +158,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$phpWord->addParagraphStyle(
'pStyle',
array(
- 'align' => 'center',
+ 'alignment' => ST_Jc::CENTER,
'tabs' => $tabs,
'shading' => array('fill' => 'FFFF99'),
'borderSize' => 4,
@@ -176,11 +177,11 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
); // Style #2
$phpWord->addTitleStyle(1, array('color' => '333333', 'doubleStrikethrough' => true)); // Style #3
$phpWord->addTableStyle('tStyle', array('borderSize' => 1));
- $fontStyle = new Font('text', array('align' => 'center'));
+ $fontStyle = new Font('text', array('alignment' => ST_Jc::CENTER));
$section = $phpWord->addSection();
$section->addListItem(htmlspecialchars('List Item', ENT_COMPAT, 'UTF-8'), 0, null, null, 'pStyle'); // Style #5
- $section->addObject($objectSrc, array('align' => 'center'));
+ $section->addObject($objectSrc, array('alignment' => ST_Jc::CENTER));
$section->addTOC($fontStyle);
$section->addTitle(htmlspecialchars('Title 1', ENT_COMPAT, 'UTF-8'), 1);
$section->addTOC('fStyle');
@@ -230,7 +231,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
public function testWriteTextRun()
{
$pStyle = 'pStyle';
- $aStyle = array('align' => 'justify', 'spaceBefore' => 120, 'spaceAfter' => 120);
+ $aStyle = array('alignment' => ST_Jc::BOTH, 'spaceBefore' => 120, 'spaceAfter' => 120);
$imageSrc = __DIR__ . '/../../../_files/images/earth.jpg';
$phpWord = new PhpWord();
@@ -241,7 +242,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$textrun->addTextBreak();
$textrun = $section->addTextRun($aStyle);
$textrun->addLink('https://github.com/PHPOffice/PHPWord');
- $textrun->addImage($imageSrc, array('align' => 'center'));
+ $textrun->addImage($imageSrc, array('alignment' => ST_Jc::CENTER));
$textrun->addFootnote();
$doc = TestHelperDOCX::getDocument($phpWord);
@@ -258,7 +259,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$section = $phpWord->addSection();
$fontStyleArray = array('bold' => true);
$fontStyleName = 'Font Style';
- $paragraphStyleArray = array('align' => 'center');
+ $paragraphStyleArray = array('alignment' => ST_Jc::CENTER);
$paragraphStyleName = 'Paragraph Style';
$expected = 'PHPWord on GitHub';
@@ -292,7 +293,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$footer = $section->addFooter();
$fontStyleArray = array('bold' => true);
$fontStyleName = 'Font';
- $paragraphStyleArray = array('align' => 'right');
+ $paragraphStyleArray = array('alignment' => ST_Jc::END);
$paragraphStyleName = 'Paragraph';
$footer->addPreserveText(htmlspecialchars('Page {PAGE}', ENT_COMPAT, 'UTF-8'));
@@ -337,7 +338,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
public function testWriteImage()
{
$phpWord = new PhpWord();
- $styles = array('align' => 'left', 'width' => 40, 'height' => 40, 'marginTop' => -1, 'marginLeft' => -1);
+ $styles = array('alignment' => ST_Jc::START, 'width' => 40, 'height' => 40, 'marginTop' => -1, 'marginLeft' => -1);
$wraps = array('inline', 'behind', 'infront', 'square', 'tight');
$section = $phpWord->addSection();
foreach ($wraps as $wrap) {
@@ -421,7 +422,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord();
$section = $phpWord->addSection();
$attributes = array(
- 'alignment' => 'right',
+ 'alignment' => ST_Jc::END,
'widowControl' => false,
'keepNext' => true,
'keepLines' => true,
diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php
index 86e87dd1..67c2909f 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/**
@@ -40,14 +41,14 @@ class FootnotesTest extends \PHPUnit_Framework_TestCase
public function testWriteFootnotes()
{
$phpWord = new PhpWord();
- $phpWord->addParagraphStyle('pStyle', array('align' => 'left'));
+ $phpWord->addParagraphStyle('pStyle', array('alignment' => ST_Jc::START));
$section = $phpWord->addSection();
$section->addText(htmlspecialchars('Text', ENT_COMPAT, 'UTF-8'));
$footnote1 = $section->addFootnote('pStyle');
$footnote1->addText(htmlspecialchars('Footnote', ENT_COMPAT, 'UTF-8'));
$footnote1->addTextBreak();
$footnote1->addLink('https://github.com/PHPOffice/PHPWord');
- $footnote2 = $section->addEndnote(array('align' => 'left'));
+ $footnote2 = $section->addEndnote(array('alignment' => ST_Jc::START));
$footnote2->addText(htmlspecialchars('Endnote', ENT_COMPAT, 'UTF-8'));
$doc = TestHelperDOCX::getDocument($phpWord);
diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php
index 4f67571b..0d4b5e05 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/**
@@ -50,17 +51,17 @@ class NumberingTest extends \PHPUnit_Framework_TestCase
'type' => 'multilevel',
'levels' => array(
array(
- 'start' => 1,
- 'format' => 'decimal',
- 'restart' => 1,
- 'suffix' => 'space',
- 'text' => '%1.',
- 'align' => 'left',
- 'left' => 360,
- 'hanging' => 360,
- 'tabPos' => 360,
- 'font' => 'Arial',
- 'hint' => 'default',
+ 'start' => 1,
+ 'format' => 'decimal',
+ 'restart' => 1,
+ 'suffix' => 'space',
+ 'text' => '%1.',
+ 'alignment' => ST_Jc::START,
+ 'left' => 360,
+ 'hanging' => 360,
+ 'tabPos' => 360,
+ 'font' => 'Arial',
+ 'hint' => 'default',
),
)
)
diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php
index 36d65af6..225aab66 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/**
@@ -42,20 +43,12 @@ class StylesTest extends \PHPUnit_Framework_TestCase
{
$phpWord = new PhpWord();
- $pStyle = array('align' => 'both');
+ $pStyle = array('alignment' => ST_Jc::BOTH);
$pBase = array('basedOn' => 'Normal');
$pNew = array('basedOn' => 'Base Style', 'next' => 'Normal');
$rStyle = array('size' => 20);
- $tStyle = array(
- 'bgColor' => 'FF0000',
- 'cellMargin' => 120,
- 'borderSize' => 120,
- );
- $firstRowStyle = array(
- 'bgColor' => '0000FF',
- 'borderSize' => 120,
- 'borderColor' => '00FF00',
- );
+ $tStyle = array('bgColor' => 'FF0000', 'cellMargin' => 120, 'borderSize' => 120);
+ $firstRowStyle = array('bgColor' => '0000FF', 'borderSize' => 120, 'borderColor' => '00FF00');
$phpWord->setDefaultParagraphStyle($pStyle);
$phpWord->addParagraphStyle('Base Style', $pBase);
$phpWord->addParagraphStyle('New Style', $pNew);
diff --git a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php
index 8dd229c3..1650e115 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php
@@ -29,7 +29,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
public function testEmptyStyles()
{
$styles = array(
- 'Alignment', 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering',
+ 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering',
'Paragraph', 'Row', 'Section', 'Shading', 'Spacing', 'Tab', 'Table',
'TextBox', 'Line', 'Shape', 'Frame', 'Outline', 'Fill', 'Shadow', 'Extrusion',
);
diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php
index c08f279f..b6a5d085 100644
--- a/tests/PhpWord/Tests/Writer/Word2007Test.php
+++ b/tests/PhpWord/Tests/Writer/Word2007Test.php
@@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer;
use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
use PhpOffice\PhpWord\Writer\Word2007;
@@ -77,7 +78,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
$remoteImage = 'http://php.net//images/logos/php-med-trans-light.gif';
$phpWord = new PhpWord();
$phpWord->addFontStyle('Font', array('size' => 11));
- $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
+ $phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
$section = $phpWord->addSection();
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
$section->addTextBreak();
diff --git a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php
index 49a7e716..b27f9a99 100644
--- a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php
+++ b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php
@@ -41,7 +41,9 @@ class TestHelperDOCX
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
* @param string $writerName
+ *
* @return \PhpOffice\PhpWord\Tests\XmlDocument
+ *
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
*/
public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007')