Next round of refactoring of alignment-related functionality.

This commit is contained in:
Roman Syroeshko 2015-10-10 19:06:23 +04:00
parent 3a58c818bd
commit 94c0d02330
100 changed files with 1109 additions and 824 deletions

View File

@ -1,24 +1,28 @@
CHANGELOG Change Log
========= ==========
All notable changes to this project will be documented in this file.
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. This project adheres to [Semantic Versioning](http://semver.org/).
0.13.0 (unreleased) 0.13.0 (unreleased)
------------ -------------------
Place announcement text here. Place announcement text here.
### Changes ### Added
- Introduced ``\PhpOffice\PhpWord\SimpleType\ST_JcTable`` simple type. - @RomanSyroeshko - Introduced the ``\PhpOffice\PhpWord\SimpleType\ST_JcTable`` simple type. - @RomanSyroeshko
- Introduced ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` 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 - 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) 0.12.1 (30 August 2015)
------------------- -----------------------
Maintenance release. This release is focused primarily on ``TemplateProcessor``. Maintenance release. This release is focused primarily on ``TemplateProcessor``.
### Changes ### Changes
@ -33,7 +37,6 @@ Maintenance release. This release is focused primarily on ``TemplateProcessor``.
0.12.0 (3 January 2015) 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. 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 ### Features
@ -93,7 +96,6 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap
0.11.1 (2 June 2014) 0.11.1 (2 June 2014)
-------------------- --------------------
This is an immediate bugfix release for HTML reader. This is an immediate bugfix release for HTML reader.
- HTML Reader: `<p>` and header tags puts no output - @canyildiz @ivanlanin #257 - HTML Reader: `<p>` 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) 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. 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 ### 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) 0.10.1 (21 May 2014)
-------------------- --------------------
This is a bugfix release for `php-zip` requirement in Composer. This is a bugfix release for `php-zip` requirement in Composer.
- Change Composer requirements for php-zip from `require` to `suggest` - @bskrtich #246 - 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) 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. 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 ### Features
@ -261,7 +260,6 @@ This release marked heavy refactorings on internal code structure with the creat
0.9.1 (27 Mar 2014) 0.9.1 (27 Mar 2014)
------------------- -------------------
This is a bugfix release for PSR-4 compatibility. This is a bugfix release for PSR-4 compatibility.
- Fixed PSR-4 composer autoloader - @AntonTyutin - 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) 0.9.0 (26 Mar 2014)
------------------- -------------------
This release marked the transformation to namespaces (PHP 5.3+). This release marked the transformation to namespaces (PHP 5.3+).
### Features ### Features
@ -293,7 +290,6 @@ This release marked the transformation to namespaces (PHP 5.3+).
0.8.1 (17 Mar 2014) 0.8.1 (17 Mar 2014)
------------------- -------------------
This is a bugfix release for image detection functionality. This is a bugfix release for image detection functionality.
- Added fallback for computers that do not have exif_imagetype - @bskrtich, @gabrielbull - 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) 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. This release merged a lot of improvements from the community. Unit tests introduced in this release and has reached 90% code coverage.
### Features ### Features
@ -351,7 +346,6 @@ This release merged a lot of improvements from the community. Unit tests introdu
0.7.0 (28 Jan 2014) 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. 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 ### Features

View File

@ -1 +1 @@
0.12.0 0.13.0

View File

@ -77,17 +77,17 @@ qthelp:
@echo @echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:" ".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 "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PhpWord.qhc" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PHPWord.qhc"
devhelp: devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo @echo
@echo "Build finished." @echo "Build finished."
@echo "To view the help file:" @echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/PhpWord" @echo "# mkdir -p $$HOME/.local/share/devhelp/PHPWord"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PhpWord" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PHPWord"
@echo "# devhelp" @echo "# devhelp"
epub: epub:

View File

@ -40,15 +40,15 @@ source_suffix = '.rst'
master_doc = 'index' master_doc = 'index'
# General information about the project. # General information about the project.
project = u'PhpWord' project = u'PHPWord'
copyright = u'2014, PHPWord Contributors' copyright = u'2014-2015, PHPWord Contributors'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.12.0' version = '0.13.0'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = version release = version
@ -164,7 +164,7 @@ html_static_path = ['_static']
#html_file_suffix = None #html_file_suffix = None
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'PhpWorddoc' htmlhelp_basename = 'PHPWorddoc'
# -- Options for LaTeX output -------------------------------------------------- # -- Options for LaTeX output --------------------------------------------------
@ -183,8 +183,8 @@ latex_elements = {
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]). # (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [ latex_documents = [
('index', 'PhpWord.tex', u'PhpWord Documentation', ('index', 'PHPWord.tex', u'PHPWord Documentation',
u'The PhpWord Team', 'manual'), u'The PHPWord Team', 'manual'),
] ]
# The name of an image file (relative to this directory) to place at the top of # 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 # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
('index', 'PhpWord', u'PhpWord Documentation', ('index', 'PHPWord', u'PHPWord Documentation',
[u'The PhpWord Team'], 1) [u'The PHPWord Team'], 1)
] ]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
@ -227,8 +227,8 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
('index', 'PhpWord', u'PhpWord Documentation', ('index', 'PHPWord', u'PHPWord Documentation',
u'The PhpWord Team', 'PhpWord', 'One line description of project.', u'The PHPWord Team', 'PHPWord', 'One line description of project.',
'Miscellaneous'), 'Miscellaneous'),
] ]
@ -244,9 +244,9 @@ texinfo_documents = [
# -- Options for Epub output --------------------------------------------------- # -- Options for Epub output ---------------------------------------------------
# Bibliographic Dublin Core info. # Bibliographic Dublin Core info.
epub_title = u'PhpWord' epub_title = u'PHPWord'
epub_author = u'The PhpWord Team' epub_author = u'The PHPWord Team'
epub_publisher = u'The PhpWord Team' epub_publisher = u'The PHPWord Team'
epub_copyright = copyright epub_copyright = copyright
# The language of the text. It defaults to the language option # The language of the text. It defaults to the language option

View File

@ -50,115 +50,48 @@ column shows the containers while the rows lists the elements.
Legend: Legend:
- ``v`` Available - ``v``. Available.
- ``v*`` Available only when inside header/footer - ``v*``. Available only when inside header/footer.
- ``v**`` Available only when inside section - ``v**``. Available only when inside section.
- ``-`` Not available - ``-``. Not available.
- ``?`` Should be available - ``?``. Should be available.
Texts Texts
----- -----
Text can be added by using ``addText`` and ``addTextRun`` method. Text can be added by using ``addText`` and ``addTextRun`` method.
``addText`` is used for creating simple paragraphs that only contain ``addText`` is used for creating simple paragraphs that only contain texts with the same style.
texts with the same style. ``addTextRun`` is used for creating complex ``addTextRun`` is used for creating complex paragraphs that contain text with different style (some bold, other
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:
italics, etc) or other elements, e.g. images or links. The syntaxes are
as follow:
.. code-block:: php .. code-block:: php
$section->addText($text, [$fontStyle], [$paragraphStyle]); $section->addText($text, [$fontStyle], [$paragraphStyle]);
$textrun = $section->addTextRun([$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 For available styling options see :ref:`font-style` and :ref:`paragraph-style`.
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
Titles Titles
~~~~~~ ~~~~~~
If you want to structure your document or build table of contents, you If you want to structure your document or build table of contents, you need titles or headings.
need titles or headings. To add a title to the document, use the To add a title to the document, use the ``addTitleStyle`` and ``addTitle`` method.
``addTitleStyle`` and ``addTitle`` method.
.. code-block:: php .. code-block:: php
$phpWord->addTitleStyle($depth, [$fontStyle], [$paragraphStyle]); $phpWord->addTitleStyle($depth, [$fontStyle], [$paragraphStyle]);
$section->addTitle($text, [$depth]); $section->addTitle($text, [$depth]);
Its necessary to add a title style to your document because otherwise - ``depth``.
the title won't be detected as a real title. - ``$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 Links
~~~~~ ~~~~~
@ -169,16 +102,15 @@ You can add Hyperlinks to the document by using the function addLink:
$section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle]); $section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle]);
- ``$linkSrc`` The URL of the link. - ``$linkSrc``. The URL of the link.
- ``$linkName`` Placeholder of the URL that appears in the document. - ``$linkName``. Placeholder of the URL that appears in the document.
- ``$fontStyle`` See "Font style" section. - ``$fontStyle``. See :ref:`font-style`.
- ``$paragraphStyle`` See "Paragraph style" section. - ``$paragraphStyle``. See :ref:`paragraph-style`.
Preserve texts Preserve texts
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
The ``addPreserveText`` method is used to add a page number or page The ``addPreserveText`` method is used to add a page number or page count to headers or footers.
count to headers or footers.
.. code-block:: php .. code-block:: php
@ -190,16 +122,15 @@ Breaks
Text breaks Text breaks
~~~~~~~~~~~ ~~~~~~~~~~~
Text breaks are empty new lines. To add text breaks, use the following Text breaks are empty new lines. To add text breaks, use the following syntax. All parameters are optional.
syntax. All paramaters are optional.
.. code-block:: php .. code-block:: php
$section->addTextBreak([$breakCount], [$fontStyle], [$paragraphStyle]); $section->addTextBreak([$breakCount], [$fontStyle], [$paragraphStyle]);
- ``$breakCount`` How many lines - ``$breakCount``. How many lines.
- ``$fontStyle`` See "Font style" section. - ``$fontStyle``. See :ref:`font-style`.
- ``$paragraphStyle`` See "Paragraph style" section. - ``$paragraphStyle``. See :ref:`paragraph-style`.
Page breaks Page breaks
~~~~~~~~~~~ ~~~~~~~~~~~
@ -224,24 +155,24 @@ Basic usage:
Parameters: Parameters:
- ``$text`` Text that appears in the document. - ``$text``. Text that appears in the document.
- ``$depth`` Depth of list item. - ``$depth``. Depth of list item.
- ``$fontStyle`` See "Font style" section. - ``$fontStyle``. See :ref:`font-style`.
- ``$listStyle`` List style of the current element TYPE\_NUMBER, - ``$listStyle``. List style of the current element TYPE\_NUMBER,
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\_Style\_ListItem.
PHPWord\_Style\_ListItem. - ``$paragraphStyle``. See :ref:`paragraph-style`.
- ``$paragraphStyle`` See "Paragraph style" section.
Advanced usage: Advanced usage:
You can also create your own numbering style by changing the You can also create your own numbering style by changing the ``$listStyle`` parameter with the name of your numbering style.
``$listStyle`` parameter with the name of your numbering style.
.. code-block:: php .. code-block:: php
$phpWord->addNumberingStyle( $phpWord->addNumberingStyle(
'multilevel', 'multilevel',
array('type' => 'multilevel', 'levels' => array( array(
'type' => 'multilevel',
'levels' => array(
array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360), array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360),
array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720), array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
) )
@ -252,28 +183,12 @@ You can also create your own numbering style by changing the
$section->addListItem('List Item I.b', 1, null, 'multilevel'); $section->addListItem('List Item I.b', 1, null, 'multilevel');
$section->addListItem('List Item II', 0, null, 'multilevel'); $section->addListItem('List Item II', 0, null, 'multilevel');
Level styles: For available styling options see :ref:`numbering-level-style`.
- ``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
Tables Tables
------ ------
To add tables, rows, and cells, use the ``addTable``, ``addRow``, and To add tables, rows, and cells, use the ``addTable``, ``addRow``, and ``addCell`` methods:
``addCell`` methods:
.. code-block:: php .. code-block:: php
@ -294,39 +209,12 @@ Table style can be defined with ``addTableStyle``:
$phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle); $phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle);
$table = $section->addTable('myTable'); $table = $section->addTable('myTable');
Table, row, and cell styles For available styling options see :ref:`table-style`.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
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*
Cell span Cell span
~~~~~~~~~ ~~~~~~~~~
You can span a cell on multiple columns by using ``gridSpan`` or You can span a cell on multiple columns by using ``gridSpan`` or multiple rows by using ``vMerge``.
multiple rows by using ``vMerge``.
.. code-block:: php .. code-block:: php
@ -338,15 +226,14 @@ See ``Sample_09_Tables.php`` for more code sample.
Images Images
------ ------
To add an image, use the ``addImage`` method to sections, headers, To add an image, use the ``addImage`` method to sections, headers, footers, textruns, or table cells.
footers, textruns, or table cells.
.. code-block:: php .. code-block:: php
$section->addImage($src, [$style]); $section->addImage($src, [$style]);
- source String path to a local image or URL of a remote image - ``$src``. String path to a local image or URL of a remote image.
- styles Array fo styles for the image. See below. - ``$style``. See :ref:`image-style`.
Examples: Examples:
@ -368,19 +255,6 @@ Examples:
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();
$textrun->addImage('http://php.net/logo.jpg'); $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 Watermarks
~~~~~~~~~~ ~~~~~~~~~~
@ -408,25 +282,22 @@ Table of contents
----------------- -----------------
To add a table of contents (TOC), you can use the ``addTOC`` method. 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 Your TOC can only be generated if you have add at least one title (See "Titles").
"Titles").
.. code-block:: php .. code-block:: php
$section->addTOC([$fontStyle], [$tocStyle], [$minDepth], [$maxDepth]); $section->addTOC([$fontStyle], [$tocStyle], [$minDepth], [$maxDepth]);
- ``$fontStyle``: See font style section - ``$fontStyle``. See font style section.
- ``$tocStyle``: See available options below - ``$tocStyle``. See available options below.
- ``$minDepth``: Minimum depth of header to be shown. Default 1 - ``$minDepth``. Minimum depth of header to be shown. Default 1.
- ``$maxDepth``: Maximum depth of header to be shown. Default 9 - ``$maxDepth``. Maximum depth of header to be shown. Default 9.
Options for ``$tocStyle``: Options for ``$tocStyle``:
- ``tabLeader`` Fill type between the title text and the page number. - ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\_Style\_TOC.
Use the defined constants in PHPWord\_Style\_TOC. - ``tabPos``. The position of the tab where the page number appears in twips.
- ``tabPos`` The position of the tab where the page number appears in - ``indent``. The indent factor of the titles in twips.
twips.
- ``indent`` The indent factor of the titles in twips.
Footnotes & endnotes Footnotes & endnotes
-------------------- --------------------
@ -468,17 +339,16 @@ redefine by ``addFontStyle`` method. Default value for this style is
Checkboxes Checkboxes
---------- ----------
Checkbox elements can be added to sections or table cells by using Checkbox elements can be added to sections or table cells by using ``addCheckBox``.
``addCheckBox``.
.. code-block:: php .. code-block:: php
$section->addCheckBox($name, $text, [$fontStyle], [$paragraphStyle]) $section->addCheckBox($name, $text, [$fontStyle], [$paragraphStyle])
- ``$name`` Name of the check box. - ``$name``. Name of the check box.
- ``$text`` Text following the check box - ``$text``. Text to be displayed in the document.
- ``$fontStyle`` See "Font style" section. - ``$fontStyle``. See :ref:`font-style`.
- ``$paragraphStyle`` See "Paragraph style" section. - ``$paragraphStyle``. See :ref:`paragraph-style`.
Textboxes Textboxes
--------- ---------
@ -502,11 +372,11 @@ Line elements can be added to sections by using ``addLine``.
Available line style attributes: Available line style attributes:
- ``weight`` Line width in twips - ``weight``. Line width in twips.
- ``color`` Defines the color of stroke - ``color``. Defines the color of stroke.
- ``dash`` Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot - ``dash``. Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot.
- ``beginArrow`` Start type of arrow: block, open, classic, diamond, oval - ``beginArrow``. Start type of arrow: block, open, classic, diamond, oval.
- ``endArrow`` End type of arrow: block, open, classic, diamond, ovel - ``endArrow``. End type of arrow: block, open, classic, diamond, oval.
- ``width`` Line-object width in pt - ``width``. Line-object width in pt.
- ``height`` Line-object height in pt - ``height``. Line-object height in pt.
- ``flip`` Flip the line element: true, false - ``flip``. Flip the line element: true, false.

View File

@ -4,11 +4,9 @@ Frequently asked questions
========================== ==========================
How contribute to PHPWord? How contribute to PHPWord?
--------------------------- --------------------------
- Improve the documentation (`Sphinx Format <http://documentation-style-guide-sphinx.readthedocs.org/en/latest/index.html>`__) - Improve the documentation (`Sphinx Format <http://documentation-style-guide-sphinx.readthedocs.org/en/latest/index.html>`__)
Is this the same with PHPWord that I found in CodePlex? Is this the same with PHPWord that I found in CodePlex?
------------------------------------------------------- -------------------------------------------------------

View File

@ -184,4 +184,3 @@ points to twips.
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5)); $sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
// 2 cm right margin // 2 cm right margin
$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2)); $sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));

View File

@ -10,9 +10,7 @@ Mandatory:
- PHP 5.3+ - PHP 5.3+
- PHP `Zip <http://php.net/manual/en/book.zip.php>`__ extension - PHP `Zip <http://php.net/manual/en/book.zip.php>`__ extension
- PHP `XML - PHP `XML Parser <http://www.php.net/manual/en/xml.installation.php>`__ extension
Parser <http://www.php.net/manual/en/xml.installation.php>`__
extension
Optional PHP extensions: Optional PHP extensions:
@ -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. 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 .. code-block:: json
@ -56,8 +54,7 @@ Notice: All contributions must be done against the developer branch.
Manual install Manual install
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
To install manually, you change to the webserver directory of your file system . To install manually, you change to the web-server directory of your file system. Then you have 2 possibilities.
Then you have 2 possibilities.
1. `download PHPWord package from github <https://github.com/PHPOffice/PHPWord/archive/master.zip>`__. 1. `download PHPWord package from github <https://github.com/PHPOffice/PHPWord/archive/master.zip>`__.
Extract the package and put the contents to your machine. Extract the package and put the contents to your machine.

View File

@ -6,8 +6,7 @@ Recipes
Create float left image Create float left image
----------------------- -----------------------
Use absolute positioning relative to margin horizontally and to line Use absolute positioning relative to margin horizontally and to line vertically.
vertically.
.. code-block:: php .. code-block:: php

View File

@ -18,10 +18,8 @@ ISO/IEC 29500, Third edition, 2012-09-01
Formal specifications Formal specifications
--------------------- ---------------------
- `Oasis OpenDocument Standard Version - `Oasis OpenDocument Standard Version 1.2 <http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html>`__
1.2 <http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html>`__ - `Rich Text Format (RTF) Specification, version 1.9.1 <http://www.microsoft.com/en-us/download/details.aspx?id=10725>`__
- `Rich Text Format (RTF) Specification, version
1.9.1 <http://www.microsoft.com/en-us/download/details.aspx?id=10725>`__
Other resources Other resources
--------------- ---------------

View File

@ -3,132 +3,140 @@
Styles Styles
====== ======
.. _section-style:
Section Section
------- -------
Below are the available styles for section: Available Section style options:
- ``pageSizeW`` Page width in twips (the default is 11906/A4 size) - ``borderBottomColor``. Border bottom color.
- ``pageSizeH`` Page height in twips (the default is 16838/A4 size) - ``borderBottomSize``. Border bottom size (in twips).
- ``orientation`` Page orientation, i.e. 'portrait' (default) or - ``borderLeftColor``. Border left color.
'landscape' - ``borderLeftSize``. Border left size (in twips).
- ``marginTop`` Page margin top in twips - ``borderRightColor``. Border right color.
- ``marginLeft`` Page margin left in twips - ``borderRightSize``. Border right size (in twips).
- ``marginRight`` Page margin right in twips - ``borderTopColor``. Border top color.
- ``marginBottom`` Page margin bottom in twips - ``borderTopSize``. Border top size (in twips).
- ``borderTopSize`` Border top size in twips - ``breakType``. Section break type (nextPage, nextColumn, continuous, evenPage, oddPage).
- ``borderTopColor`` Border top color - ``colsNum``. Number of columns.
- ``borderLeftSize`` Border left size in twips - ``colsSpace``. Spacing between columns.
- ``borderLeftColor`` Border left color - ``footerHeight``. Spacing to bottom of footer.
- ``borderRightSize`` Border right size in twips - ``gutter``. Page gutter spacing.
- ``borderRightColor`` Border right color - ``headerHeight``. Spacing to top of header.
- ``borderBottomSize`` Border bottom size in twips - ``marginTop``. Page margin top (in twips).
- ``borderBottomColor`` Border bottom color - ``marginLeft``. Page margin left (in twips).
- ``headerHeight`` Spacing to top of header - ``marginRight``. Page margin right (in twips).
- ``footerHeight`` Spacing to bottom of footer - ``marginBottom``. Page margin bottom (in twips).
- ``gutter`` Page gutter spacing - ``orientation``. Page orientation (``portrait``, which is default, or ``landscape``).
- ``colsNum`` Number of columns - ``pageSizeH``. Page height (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
- ``colsSpace`` Spacing between columns - ``pageSizeW``. Page width (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
- ``breakType`` Section break type (nextPage, nextColumn, continuous,
evenPage, oddPage) .. _font-style:
Font Font
---- ----
Available font styles: Available Font style options:
- ``name`` Font name, e.g. *Arial* - ``allCaps``. All caps, *true* or *false*.
- ``size`` Font size, e.g. *20*, *22*, - ``bgColor``. Font background color, e.g. *FF0000*.
- ``hint`` Font content type, *default*, *eastAsia*, or *cs* - ``bold``. Bold, *true* or *false*.
- ``bold`` Bold, *true* or *false* - ``color``. Font color, e.g. *FF0000*.
- ``italic`` Italic, *true* or *false* - ``doubleStrikethrough``. Double strikethrough, *true* or *false*.
- ``superScript`` Superscript, *true* or *false* - ``fgColor``. Font highlight color, e.g. *yellow*, *green*, *blue*.
- ``subScript`` Subscript, *true* or *false* - ``hint``. Font content type, *default*, *eastAsia*, or *cs*.
- ``underline`` Underline, *dash*, *dotted*, etc. - ``italic``. Italic, *true* or *false*.
- ``strikethrough`` Strikethrough, *true* or *false* - ``name``. Font name, e.g. *Arial*.
- ``doubleStrikethrough`` Double strikethrough, *true* or *false* - ``rtl``. Right to Left language, *true* or *false*.
- ``color`` Font color, e.g. *FF0000* - ``size``. Font size, e.g. *20*, *22*.
- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue* - ``smallCaps``. Small caps, *true* or *false*.
- ``bgColor`` Font background color, e.g. *FF0000* - ``strikethrough``. Strikethrough, *true* or *false*.
- ``smallCaps`` Small caps, *true* or *false* - ``subScript``. Subscript, *true* or *false*.
- ``allCaps`` All caps, *true* or *false* - ``superScript``. Superscript, *true* or *false*.
- ``rtl`` Right to Left language, *true* or *false* - ``underline``. Underline, *dash*, *dotted*, etc.
.. _paragraph-style:
Paragraph Paragraph
--------- ---------
Available paragraph styles: Available Paragraph style options:
- ``alignment`` Paragraph alignment, *left*, *right* or *center* - ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` class for the details.
- ``spaceBefore`` Space before paragraph - ``basedOn``. Parent style.
- ``spaceAfter`` Space after paragraph - ``hanging``. Hanging by how much.
- ``indent`` Indent by how much - ``indent``. Indent by how much.
- ``hanging`` Hanging by how much - ``keepLines``. Keep all lines on one page, *true* or *false*.
- ``basedOn`` Parent style - ``keepNext``. Keep paragraph with next paragraph, *true* or *false*.
- ``next`` Style for next paragraph - ``lineHeight``. Text line height, e.g. *1.0*, *1.5*, etc.
- ``widowControl`` Allow first/last line to display on a separate page, - ``next``. Style for next paragraph.
*true* or *false* - ``pageBreakBefore``. Start paragraph on next page, *true* or *false*.
- ``keepNext`` Keep paragraph with next paragraph, *true* or *false* - ``spaceBefore``. Space before paragraph.
- ``keepLines`` Keep all lines on one page, *true* or *false* - ``spaceAfter``. Space after paragraph.
- ``pageBreakBefore`` Start paragraph on next page, *true* or *false* - ``tabs``. Set of custom tab stops.
- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect... - ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*.
- ``tabs`` Set of custom tab stops
.. _table-style:
Table Table
----- -----
Table styles: Available Table style options:
- ``width`` Table width in percent - ``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' - ``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'.
- ``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 - ``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*.
- ``cantSplit`` Table row cannot break across pages, *true* or *false* - ``exactHeight``. Row height is exact or at least.
- ``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 - ``bgColor``. Background color, e.g. '9966CC'.
- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom* - ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
- ``textDirection`` Direction of text - ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
- ``bgColor`` Background color, e.g. '9966CC' - ``gridSpan``. Number of columns spanned.
- ``border(Top|Right|Bottom|Left)Size`` Border size in twips - ``textDirection``. Direction of text.
- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC' - ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
- ``gridSpan`` Number of columns spanned - ``vMerge``. *restart* or *continue*.
- ``vMerge`` *restart* or *continue* - ``width``. Cell width in twips.
.. _image-style:
Image Image
----- -----
Available image styles: Available Image style options:
- ``width`` Width in pixels - ``alignment``. See ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` class for the details.
- ``height`` Height in pixels - ``height``. Height in pixels.
- ``align`` Image alignment, *left*, *right*, or *center* - ``marginLeft``. Left margin in inches, can be negative.
- ``marginTop`` Top margin in inches, can be negative - ``marginTop``. Top margin in inches, can be negative.
- ``marginLeft`` Left margin in inches, can be negative - ``width``. Width in pixels.
- ``wrappingStyle`` Wrapping style, *inline*, *square*, *tight*, - ``wrappingStyle``. Wrapping style, *inline*, *square*, *tight*, *behind*, or *infront*.
*behind*, or *infront*
.. _numbering-level-style:
Numbering level Numbering level
--------------- ---------------
- ``start`` Starting value Available NumberingLevel style options:
- ``format`` Numbering format
bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter - ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` class for the details.
- ``restart`` Restart numbering level symbol - ``font``. Font name.
- ``suffix`` Content between numbering symbol and paragraph text - ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
tab\|space\|nothing - ``hanging``. See paragraph style.
- ``text`` Numbering level text e.g. %1 for nonbullet or bullet - ``hint``. See font style.
character - ``left``. See paragraph style.
- ``align`` Numbering symbol align left\|center\|right\|both - ``restart``. Restart numbering level symbol.
- ``left`` See paragraph style - ``start``. Starting value.
- ``hanging`` See paragraph style - ``suffix``. Content between numbering symbol and paragraph text tab\|space\|nothing.
- ``tabPos`` See paragraph style - ``tabPos``. See paragraph style.
- ``font`` Font name - ``text``. Numbering level text e.g. %1 for nonbullet or bullet character.
- ``hint`` See font style

View File

@ -5,7 +5,7 @@ include_once 'Sample_Header.php';
echo date('H:i:s') , ' Create new PhpWord object' , EOL; echo date('H:i:s') , ' Create new PhpWord object' , EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true)); $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)); $phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
// New portrait section // New portrait section

View File

@ -6,7 +6,7 @@ echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->setDefaultParagraphStyle( $phpWord->setDefaultParagraphStyle(
array( array(
'alignment' => 'both', 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::BOTH,
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12), 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12),
'spacing' => 120, 'spacing' => 120,
) )

View File

@ -26,11 +26,11 @@ for ($r = 1; $r <= 8; $r++) {
$section->addTextBreak(1); $section->addTextBreak(1);
$section->addText(htmlspecialchars('Fancy table', ENT_COMPAT, 'UTF-8'), $header); $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'); $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
$styleCell = array('valign' => 'center'); $styleCell = array('valign' => 'center');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR); $styleCellBTLR = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
$fontStyle = array('bold' => true, 'align' => 'center'); $fontStyle = array('bold' => true);
$phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow); $phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow);
$table = $section->addTable('Fancy Table'); $table = $section->addTable('Fancy Table');
$table->addRow(900); $table->addRow(900);
@ -58,7 +58,7 @@ $styleTable = array('borderSize' => 6, 'borderColor' => '999999');
$cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center', 'bgColor' => 'FFFF00'); $cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center', 'bgColor' => 'FFFF00');
$cellRowContinue = array('vMerge' => 'continue'); $cellRowContinue = array('vMerge' => 'continue');
$cellColSpan = array('gridSpan' => 2, 'valign' => 'center'); $cellColSpan = array('gridSpan' => 2, 'valign' => 'center');
$cellHCentered = array('align' => 'center'); $cellHCentered = array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER);
$cellVCentered = array('valign' => 'center'); $cellVCentered = array('valign' => 'center');
$phpWord->addTableStyle('Colspan Rowspan', $styleTable); $phpWord->addTableStyle('Colspan Rowspan', $styleTable);
@ -89,10 +89,10 @@ $table->addCell(null, $cellRowContinue);
$section->addTextBreak(2); $section->addTextBreak(2);
$section->addText(htmlspecialchars('Nested table in a centered and 50% width table.', ENT_COMPAT, 'UTF-8'), $header); $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 = $table->addRow()->addCell();
$cell->addText(htmlspecialchars('This cell contains nested table.', ENT_COMPAT, 'UTF-8')); $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')); $innerCell->addText(htmlspecialchars('Inside nested table', ENT_COMPAT, 'UTF-8'));
// Save file // Save file

View File

@ -17,7 +17,7 @@ $cell = $table->addCell(4500);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText(htmlspecialchars('This is the header with ', ENT_COMPAT, 'UTF-8')); $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')); $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 // Add header for all other pages
$subsequent = $section->addHeader(); $subsequent = $section->addHeader();
@ -26,7 +26,7 @@ $subsequent->addImage('resources/_mars.jpg', array('width' => 80, 'height' => 80
// Add footer // Add footer
$footer = $section->addFooter(); $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')); $footer->addLink('https://github.com/PHPOffice/PHPWord', htmlspecialchars('PHPWord on GitHub', ENT_COMPAT, 'UTF-8'));
// Write some text // Write some text

View File

@ -12,7 +12,7 @@ $section->addImage('resources/_mars.jpg');
$section->addTextBreak(2); $section->addTextBreak(2);
$section->addText(htmlspecialchars('Local image with styles:', ENT_COMPAT, 'UTF-8')); $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); $section->addTextBreak(2);
// Remote image // Remote image

View File

@ -22,7 +22,7 @@ $section->addText(
$table1 = $section->addTable(array('cellMargin' => 0, 'cellMarginRight' => 0, 'cellMarginBottom' => 0, 'cellMarginLeft' => 0)); $table1 = $section->addTable(array('cellMargin' => 0, 'cellMarginRight' => 0, 'cellMarginBottom' => 0, 'cellMarginLeft' => 0));
$table1->addRow(3750); $table1->addRow(3750);
$cell1 = $table1->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => 'ff0000')); $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->addTextBreak();
$section->addText( $section->addText(
@ -43,7 +43,7 @@ $table2 = $section->addTable(
); );
$table2->addRow(3750, array('exactHeight' => true)); $table2->addRow(3750, array('exactHeight' => true));
$cell2 = $table2->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => '00ff00')); $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->addTextBreak();
$section->addText( $section->addText(

View File

@ -10,7 +10,7 @@ $section = $phpWord->addSection();
// In section // In section
$textbox = $section->addTextBox( $textbox = $section->addTextBox(
array( array(
'align' => 'center', 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER,
'width' => 400, 'width' => 400,
'height' => 150, 'height' => 150,
'borderSize' => 1, 'borderSize' => 1,

View File

@ -19,7 +19,7 @@ $section->addField('PAGE', array('format' => 'ArabicDash'));
$section->addText(htmlspecialchars('Number of pages field:', ENT_COMPAT, 'UTF-8')); $section->addText(htmlspecialchars('Number of pages field:', ENT_COMPAT, 'UTF-8'));
$section->addField('NUMPAGES', array('format' => 'Arabic', 'numformat' => '0,00'), array('PreserveFormat')); $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->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->addField('DATE', array('dateformat' => 'd-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar'));
$textrun->addText(htmlspecialchars(' written in a textrun.', ENT_COMPAT, 'UTF-8')); $textrun->addText(htmlspecialchars(' written in a textrun.', ENT_COMPAT, 'UTF-8'));

View File

@ -9,7 +9,7 @@ $section = $phpWord->addSection();
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();
$textrun->addText(htmlspecialchars('This is a Left to Right paragraph.', ENT_COMPAT, 'UTF-8')); $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)); $textrun->addText(htmlspecialchars('سلام این یک پاراگراف راست به چپ است', ENT_COMPAT, 'UTF-8'), array('rtl' => true));
// Save file // Save file

View File

@ -178,7 +178,9 @@ abstract class AbstractContainer extends AbstractElement
* Check if a method is allowed for the current container * Check if a method is allowed for the current container
* *
* @param string $method * @param string $method
*
* @return bool * @return bool
*
* @throws \BadMethodCallException * @throws \BadMethodCallException
*/ */
private function checkValidity($method) private function checkValidity($method)
@ -247,10 +249,13 @@ abstract class AbstractContainer extends AbstractElement
/** /**
* Add memory image element * Add memory image element
* *
* @deprecated 0.9.0
*
* @param string $src * @param string $src
* @param mixed $style * @param mixed $style
*
* @return \PhpOffice\PhpWord\Element\Image * @return \PhpOffice\PhpWord\Element\Image
* @deprecated 0.9.0 *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function addMemoryImage($src, $style = null) public function addMemoryImage($src, $style = null)
@ -261,9 +266,12 @@ abstract class AbstractContainer extends AbstractElement
/** /**
* Create textrun element * Create textrun element
* *
* @param mixed $paragraphStyle
* @return \PhpOffice\PhpWord\Element\TextRun
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param mixed $paragraphStyle
*
* @return \PhpOffice\PhpWord\Element\TextRun
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function createTextRun($paragraphStyle = null) public function createTextRun($paragraphStyle = null)
@ -274,9 +282,12 @@ abstract class AbstractContainer extends AbstractElement
/** /**
* Create footnote element * Create footnote element
* *
* @param mixed $paragraphStyle
* @return \PhpOffice\PhpWord\Element\Footnote
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param mixed $paragraphStyle
*
* @return \PhpOffice\PhpWord\Element\Footnote
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function createFootnote($paragraphStyle = null) public function createFootnote($paragraphStyle = null)

View File

@ -378,8 +378,11 @@ abstract class AbstractElement
* @param mixed $value * @param mixed $value
* @param array $enum * @param array $enum
* @param mixed $default * @param mixed $default
*
* @return mixed * @return mixed
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*
* @todo Merge with the same method in AbstractStyle * @todo Merge with the same method in AbstractStyle
*/ */
protected function setEnumVal($value = null, $enum = array(), $default = null) protected function setEnumVal($value = null, $enum = array(), $default = null)

View File

@ -94,7 +94,9 @@ class Field extends AbstractElement
* Set Field type * Set Field type
* *
* @param string $type * @param string $type
*
* @return string * @return string
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function setType($type = null) public function setType($type = null)
@ -123,7 +125,9 @@ class Field extends AbstractElement
* Set Field properties * Set Field properties
* *
* @param array $properties * @param array $properties
*
* @return self * @return self
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function setProperties($properties = array()) public function setProperties($properties = array())
@ -153,7 +157,9 @@ class Field extends AbstractElement
* Set Field options * Set Field options
* *
* @param array $options * @param array $options
*
* @return self * @return self
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function setOptions($options = array()) public function setOptions($options = array())

View File

@ -67,8 +67,10 @@ class Footnote extends AbstractContainer
/** /**
* Get Footnote Reference ID * Get Footnote Reference ID
* *
* @return int
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @return int
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getReferenceId() public function getReferenceId()
@ -79,8 +81,10 @@ class Footnote extends AbstractContainer
/** /**
* Set Footnote Reference ID * Set Footnote Reference ID
* *
* @param int $rId
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param int $rId
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function setReferenceId($rId) public function setReferenceId($rId)

View File

@ -126,6 +126,7 @@ class Image extends AbstractElement
* @param string $source * @param string $source
* @param mixed $style * @param mixed $style
* @param boolean $watermark * @param boolean $watermark
*
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException * @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException * @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
*/ */
@ -365,7 +366,9 @@ class Image extends AbstractElement
* Check memory image, supported type, image functions, and proportional width/height. * Check memory image, supported type, image functions, and proportional width/height.
* *
* @param string $source * @param string $source
*
* @return void * @return void
*
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException * @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException * @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
*/ */
@ -425,7 +428,9 @@ class Image extends AbstractElement
* @since 0.12.0 Throws CreateTemporaryFileException. * @since 0.12.0 Throws CreateTemporaryFileException.
* *
* @param string $source * @param string $source
*
* @return array|null * @return array|null
*
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
*/ */
private function getArchiveImageSize($source) private function getArchiveImageSize($source)
@ -517,6 +522,7 @@ class Image extends AbstractElement
* Get is watermark * Get is watermark
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getIsWatermark() public function getIsWatermark()
@ -528,6 +534,7 @@ class Image extends AbstractElement
* Get is memory image * Get is memory image
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getIsMemImage() public function getIsMemImage()

View File

@ -129,8 +129,10 @@ class Link extends AbstractElement
/** /**
* Get link target * Get link target
* *
* @return string
* @deprecated 0.12.0 * @deprecated 0.12.0
*
* @return string
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getTarget() public function getTarget()
@ -141,8 +143,10 @@ class Link extends AbstractElement
/** /**
* Get Link source * Get Link source
* *
* @return string
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @return string
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getLinkSrc() public function getLinkSrc()
@ -153,8 +157,10 @@ class Link extends AbstractElement
/** /**
* Get Link name * Get Link name
* *
* @return string
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @return string
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getLinkName() public function getLinkName()

View File

@ -65,6 +65,7 @@ class Object extends AbstractElement
* *
* @param string $source * @param string $source
* @param mixed $style * @param mixed $style
*
* @throws \PhpOffice\PhpWord\Exception\InvalidObjectException * @throws \PhpOffice\PhpWord\Exception\InvalidObjectException
*/ */
public function __construct($source, $style = null) public function __construct($source, $style = null)
@ -142,8 +143,10 @@ class Object extends AbstractElement
/** /**
* Get Object ID * Get Object ID
* *
* @return int
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @return int
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getObjectId() public function getObjectId()
@ -154,8 +157,10 @@ class Object extends AbstractElement
/** /**
* Set Object ID * Set Object ID
* *
* @param int $objId
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param int $objId
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function setObjectId($objId) public function setObjectId($objId)

View File

@ -153,11 +153,14 @@ class Section extends AbstractContainer
/** /**
* Add header/footer * Add header/footer
* *
* @since 0.10.0
*
* @param string $type * @param string $type
* @param boolean $header * @param boolean $header
*
* @return Header|Footer * @return Header|Footer
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
* @since 0.10.0
*/ */
private function addHeaderFooter($type = Header::AUTO, $header = true) private function addHeaderFooter($type = Header::AUTO, $header = true)
{ {
@ -183,8 +186,10 @@ class Section extends AbstractContainer
/** /**
* Set section style * Set section style
* *
* @param array $settings
* @deprecated 0.12.0 * @deprecated 0.12.0
*
* @param array $settings
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function setSettings($settings = null) public function setSettings($settings = null)
@ -195,8 +200,10 @@ class Section extends AbstractContainer
/** /**
* Get section style * Get section style
* *
* @return \PhpOffice\PhpWord\Style\Section
* @deprecated 0.12.0 * @deprecated 0.12.0
*
* @return \PhpOffice\PhpWord\Style\Section
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getSettings() public function getSettings()
@ -207,8 +214,10 @@ class Section extends AbstractContainer
/** /**
* Create header * Create header
* *
* @return Header
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @return Header
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function createHeader() public function createHeader()
@ -219,8 +228,10 @@ class Section extends AbstractContainer
/** /**
* Create footer * Create footer
* *
* @return Footer
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @return Footer
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function createFooter() public function createFooter()
@ -231,8 +242,10 @@ class Section extends AbstractContainer
/** /**
* Get footer * Get footer
* *
* @return Footer
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @return Footer
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getFooter() public function getFooter()

View File

@ -20,7 +20,9 @@ abstract class IOFactory
* *
* @param PhpWord $phpWord * @param PhpWord $phpWord
* @param string $name * @param string $name
*
* @return WriterInterface * @return WriterInterface
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public static function createWriter(PhpWord $phpWord, $name = 'Word2007') public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
@ -38,7 +40,9 @@ abstract class IOFactory
* Create new reader * Create new reader
* *
* @param string $name * @param string $name
*
* @return ReaderInterface * @return ReaderInterface
*
* @throws Exception * @throws Exception
*/ */
public static function createReader($name = 'Word2007') public static function createReader($name = 'Word2007')
@ -52,7 +56,9 @@ abstract class IOFactory
* @param string $type * @param string $type
* @param string $name * @param string $name
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
*
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface * @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
private static function createObject($type, $name, $phpWord = null) private static function createObject($type, $name, $phpWord = null)

View File

@ -35,14 +35,17 @@ class Media
/** /**
* Add new media element * Add new media element
* *
* @since 0.10.0
* @since 0.9.2
*
* @param string $container section|headerx|footerx|footnote|endnote * @param string $container section|headerx|footerx|footnote|endnote
* @param string $mediaType image|object|link * @param string $mediaType image|object|link
* @param string $source * @param string $source
* @param \PhpOffice\PhpWord\Element\Image $image * @param \PhpOffice\PhpWord\Element\Image $image
*
* @return integer * @return integer
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
* @since 0.9.2
* @since 0.10.0
*/ */
public static function addElement($container, $mediaType, $source, Image $image = null) public static function addElement($container, $mediaType, $source, Image $image = null)
{ {
@ -199,11 +202,14 @@ class Media
/** /**
* Add new Section Media Element * Add new Section Media Element
* *
* @deprecated 0.10.0
*
* @param string $src * @param string $src
* @param string $type * @param string $type
* @param \PhpOffice\PhpWord\Element\Image $image * @param \PhpOffice\PhpWord\Element\Image $image
*
* @return integer * @return integer
* @deprecated 0.10.0 *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function addSectionMediaElement($src, $type, Image $image = null) public static function addSectionMediaElement($src, $type, Image $image = null)
@ -214,9 +220,12 @@ class Media
/** /**
* Add new Section Link Element * Add new Section Link Element
* *
* @param string $linkSrc
* @return integer
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param string $linkSrc
*
* @return integer
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function addSectionLinkElement($linkSrc) public static function addSectionLinkElement($linkSrc)
@ -227,9 +236,12 @@ class Media
/** /**
* Get Section Media Elements * Get Section Media Elements
* *
* @param string $key
* @return array
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param string $key
*
* @return array
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function getSectionMediaElements($key = null) public static function getSectionMediaElements($key = null)
@ -240,9 +252,12 @@ class Media
/** /**
* Get Section Media Elements Count * Get Section Media Elements Count
* *
* @param string $key
* @return integer
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param string $key
*
* @return integer
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function countSectionMediaElements($key = null) public static function countSectionMediaElements($key = null)
@ -253,11 +268,14 @@ class Media
/** /**
* Add new Header Media Element * Add new Header Media Element
* *
* @deprecated 0.10.0
*
* @param integer $headerCount * @param integer $headerCount
* @param string $src * @param string $src
* @param \PhpOffice\PhpWord\Element\Image $image * @param \PhpOffice\PhpWord\Element\Image $image
*
* @return integer * @return integer
* @deprecated 0.10.0 *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function addHeaderMediaElement($headerCount, $src, Image $image = null) public static function addHeaderMediaElement($headerCount, $src, Image $image = null)
@ -268,9 +286,12 @@ class Media
/** /**
* Get Header Media Elements Count * Get Header Media Elements Count
* *
* @param string $key
* @return integer
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param string $key
*
* @return integer
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function countHeaderMediaElements($key) public static function countHeaderMediaElements($key)
@ -281,8 +302,10 @@ class Media
/** /**
* Get Header Media Elements * Get Header Media Elements
* *
* @return array
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @return array
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function getHeaderMediaElements() public static function getHeaderMediaElements()
@ -293,11 +316,14 @@ class Media
/** /**
* Add new Footer Media Element * Add new Footer Media Element
* *
* @deprecated 0.10.0
*
* @param integer $footerCount * @param integer $footerCount
* @param string $src * @param string $src
* @param \PhpOffice\PhpWord\Element\Image $image * @param \PhpOffice\PhpWord\Element\Image $image
*
* @return integer * @return integer
* @deprecated 0.10.0 *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function addFooterMediaElement($footerCount, $src, Image $image = null) public static function addFooterMediaElement($footerCount, $src, Image $image = null)
@ -308,9 +334,12 @@ class Media
/** /**
* Get Footer Media Elements Count * Get Footer Media Elements Count
* *
* @param string $key
* @return integer
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param string $key
*
* @return integer
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function countFooterMediaElements($key) public static function countFooterMediaElements($key)
@ -321,8 +350,10 @@ class Media
/** /**
* Get Footer Media Elements * Get Footer Media Elements
* *
* @return array
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @return array
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function getFooterMediaElements() public static function getFooterMediaElements()

View File

@ -45,8 +45,9 @@ class PhpWord
/** /**
* Default font settings * Default font settings
* *
* @const string|int
* @deprecated 0.11.0 Use Settings constants * @deprecated 0.11.0 Use Settings constants
*
* @const string|int
*/ */
const DEFAULT_FONT_NAME = Settings::DEFAULT_FONT_NAME; const DEFAULT_FONT_NAME = Settings::DEFAULT_FONT_NAME;
const DEFAULT_FONT_SIZE = Settings::DEFAULT_FONT_SIZE; const DEFAULT_FONT_SIZE = Settings::DEFAULT_FONT_SIZE;
@ -100,11 +101,14 @@ class PhpWord
/** /**
* Dynamic function call to reduce static dependency * Dynamic function call to reduce static dependency
* *
* @since 0.12.0
*
* @param mixed $function * @param mixed $function
* @param mixed $args * @param mixed $args
* @throws \BadMethodCallException *
* @return mixed * @return mixed
* @since 0.12.0 *
* @throws \BadMethodCallException
*/ */
public function __call($function, $args) public function __call($function, $args)
{ {
@ -267,8 +271,12 @@ class PhpWord
* @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead. * @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead.
* *
* @param string $filename Fully qualified filename. * @param string $filename Fully qualified filename.
*
* @return TemplateProcessor * @return TemplateProcessor
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*
* @codeCoverageIgnore
*/ */
public function loadTemplate($filename) public function loadTemplate($filename)
{ {
@ -319,9 +327,12 @@ class PhpWord
/** /**
* Create new section * Create new section
* *
* @param array $settings
* @return \PhpOffice\PhpWord\Element\Section
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @param array $settings
*
* @return \PhpOffice\PhpWord\Element\Section
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function createSection($settings = null) public function createSection($settings = null)
@ -332,8 +343,10 @@ class PhpWord
/** /**
* Get document properties object * Get document properties object
* *
* @return \PhpOffice\PhpWord\Metadata\DocInfo
* @deprecated 0.12.0 * @deprecated 0.12.0
*
* @return \PhpOffice\PhpWord\Metadata\DocInfo
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getDocumentProperties() public function getDocumentProperties()
@ -344,9 +357,12 @@ class PhpWord
/** /**
* Set document properties object * Set document properties object
* *
* @param \PhpOffice\PhpWord\Metadata\DocInfo $documentProperties
* @return self
* @deprecated 0.12.0 * @deprecated 0.12.0
*
* @param \PhpOffice\PhpWord\Metadata\DocInfo $documentProperties
*
* @return self
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function setDocumentProperties($documentProperties) public function setDocumentProperties($documentProperties)

View File

@ -68,7 +68,9 @@ abstract class AbstractReader implements ReaderInterface
* Open file for reading * Open file for reading
* *
* @param string $filename * @param string $filename
*
* @return resource * @return resource
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
protected function openFile($filename) protected function openFile($filename)
@ -110,6 +112,7 @@ abstract class AbstractReader implements ReaderInterface
* Read data only? * Read data only?
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getReadDataOnly() public function getReadDataOnly()

View File

@ -31,7 +31,9 @@ class HTML extends AbstractReader implements ReaderInterface
* Loads PhpWord from file * Loads PhpWord from file
* *
* @param string $docFile * @param string $docFile
*
* @throws \Exception * @throws \Exception
*
* @return \PhpOffice\PhpWord\PhpWord * @return \PhpOffice\PhpWord\PhpWord
*/ */
public function load($docFile) public function load($docFile)

View File

@ -31,7 +31,9 @@ class RTF extends AbstractReader implements ReaderInterface
* Loads PhpWord from file * Loads PhpWord from file
* *
* @param string $docFile * @param string $docFile
*
* @throws \Exception * @throws \Exception
*
* @return \PhpOffice\PhpWord\PhpWord * @return \PhpOffice\PhpWord\PhpWord
*/ */
public function load($docFile) public function load($docFile)

View File

@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Reader\RTF; namespace PhpOffice\PhpWord\Reader\RTF;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
/** /**
* RTF document reader * RTF document reader
@ -140,7 +141,7 @@ class Document
125 => 'markClosing', // } 125 => 'markClosing', // }
92 => 'markBackslash', // \ 92 => 'markBackslash', // \
10 => 'markNewline', // LF 10 => 'markNewline', // LF
13 => 'markNewline' // CR 13 => 'markNewline', // CR
); );
$this->phpWord = $phpWord; $this->phpWord = $phpWord;
@ -159,7 +160,7 @@ class Document
$markerFunction = $markers[$ascii]; $markerFunction = $markers[$ascii];
$this->$markerFunction(); $this->$markerFunction();
} else { } else {
if ($this->isControl === false) { // Non control word: Push character if (false === $this->isControl) { // Non control word: Push character
$this->pushText($char); $this->pushText($char);
} else { } else {
if (preg_match("/^[a-zA-Z0-9-]?$/", $char)) { // No delimiter: Buffer control if (preg_match("/^[a-zA-Z0-9-]?$/", $char)) { // No delimiter: Buffer control
@ -169,7 +170,7 @@ class Document
if ($this->isFirst) { if ($this->isFirst) {
$this->isFirst = false; $this->isFirst = false;
} else { } else {
if ($char == ' ') { // Discard space as a control word delimiter if (' ' == $char) { // Discard space as a control word delimiter
$this->flushControl(true); $this->flushControl(true);
} }
} }
@ -255,12 +256,12 @@ class Document
*/ */
private function flushControl($isControl = false) private function flushControl($isControl = false)
{ {
if (preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match) === 1) { if (1 === preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match)) {
list(, $control, $parameter) = $match; list(, $control, $parameter) = $match;
$this->parseControl($control, $parameter); $this->parseControl($control, $parameter);
} }
if ($isControl === true) { if (true === $isControl) {
$this->setControl(false); $this->setControl(false);
} }
} }
@ -276,7 +277,7 @@ class Document
if (isset($this->flags['property'])) { // Set property if (isset($this->flags['property'])) { // Set property
$this->flags['value'] = $this->text; $this->flags['value'] = $this->text;
} else { // Set text } else { // Set text
if ($this->flags['paragraph'] === true) { if (true === $this->flags['paragraph']) {
$this->flags['paragraph'] = false; $this->flags['paragraph'] = false;
$this->flags['text'] = $this->text; $this->flags['text'] = $this->text;
} }
@ -311,9 +312,9 @@ class Document
*/ */
private function pushText($char) private function pushText($char)
{ {
if ($char == '<') { if ('<' == $char) {
$this->text .= "&lt;"; $this->text .= "&lt;";
} elseif ($char == '>') { } elseif ('>' == $char) {
$this->text .= "&gt;"; $this->text .= "&gt;";
} else { } else {
$this->text .= $char; $this->text .= $char;
@ -336,7 +337,7 @@ class Document
'u' => array(self::STYL, 'font', 'underline', true), 'u' => array(self::STYL, 'font', 'underline', true),
'strike' => array(self::STYL, 'font', 'strikethrough',true), 'strike' => array(self::STYL, 'font', 'strikethrough',true),
'fs' => array(self::STYL, 'font', 'size', $parameter), '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), 'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter),
'fonttbl' => array(self::SKIP, 'fonttbl', null), 'fonttbl' => array(self::SKIP, 'fonttbl', null),
'colortbl' => array(self::SKIP, 'colortbl', null), 'colortbl' => array(self::SKIP, 'colortbl', null),

View File

@ -122,16 +122,16 @@ abstract class AbstractPart
$instrText = $xmlReader->getValue('w:instrText', $node); $instrText = $xmlReader->getValue('w:instrText', $node);
if ($xmlReader->elementExists('w:fldChar', $node)) { if ($xmlReader->elementExists('w:fldChar', $node)) {
$fldCharType = $xmlReader->getAttribute('w:fldCharType', $node, 'w:fldChar'); $fldCharType = $xmlReader->getAttribute('w:fldCharType', $node, 'w:fldChar');
if ($fldCharType == 'begin') { if ('begin' == $fldCharType) {
$ignoreText = true; $ignoreText = true;
} elseif ($fldCharType == 'end') { } elseif ('end' == $fldCharType) {
$ignoreText = false; $ignoreText = false;
} }
} }
if (!is_null($instrText)) { if (!is_null($instrText)) {
$textContent .= '{' . $instrText . '}'; $textContent .= '{' . $instrText . '}';
} else { } else {
if ($ignoreText === false) { if (false === $ignoreText) {
$textContent .= $xmlReader->getValue('w:t', $node); $textContent .= $xmlReader->getValue('w:t', $node);
} }
} }
@ -163,7 +163,7 @@ abstract class AbstractPart
$runCount = $xmlReader->countElements('w:r', $domNode); $runCount = $xmlReader->countElements('w:r', $domNode);
$linkCount = $xmlReader->countElements('w:hyperlink', $domNode); $linkCount = $xmlReader->countElements('w:hyperlink', $domNode);
$runLinkCount = $runCount + $linkCount; $runLinkCount = $runCount + $linkCount;
if ($runLinkCount == 0) { if (0 == $runLinkCount) {
$parent->addTextBreak(null, $paragraphStyle); $parent->addTextBreak(null, $paragraphStyle);
} else { } else {
$nodes = $xmlReader->getElements('*', $domNode); $nodes = $xmlReader->getElements('*', $domNode);
@ -200,7 +200,7 @@ abstract class AbstractPart
$fontStyle = $this->readFontStyle($xmlReader, $domNode); $fontStyle = $this->readFontStyle($xmlReader, $domNode);
// Link // Link
if ($domNode->nodeName == 'w:hyperlink') { if ('w:hyperlink' == $domNode->nodeName) {
$rId = $xmlReader->getAttribute('r:id', $domNode); $rId = $xmlReader->getAttribute('r:id', $domNode);
$textContent = $xmlReader->getValue('w:r/w:t', $domNode); $textContent = $xmlReader->getValue('w:r/w:t', $domNode);
$target = $this->getMediaTarget($docPart, $rId); $target = $this->getMediaTarget($docPart, $rId);
@ -264,10 +264,10 @@ abstract class AbstractPart
$table = $parent->addTable($tblStyle); $table = $parent->addTable($tblStyle);
$tblNodes = $xmlReader->getElements('*', $domNode); $tblNodes = $xmlReader->getElements('*', $domNode);
foreach ($tblNodes as $tblNode) { foreach ($tblNodes as $tblNode) {
if ($tblNode->nodeName == 'w:tblGrid') { // Column if ('w:tblGrid' == $tblNode->nodeName) { // Column
// @todo Do something with table columns // @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'); $rowHeight = $xmlReader->getAttribute('w:val', $tblNode, 'w:trPr/w:trHeight');
$rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight'); $rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight');
$rowHRule = $rowHRule == 'exact' ? true : false; $rowHRule = $rowHRule == 'exact' ? true : false;
@ -280,10 +280,10 @@ abstract class AbstractPart
$row = $table->addRow($rowHeight, $rowStyle); $row = $table->addRow($rowHeight, $rowStyle);
$rowNodes = $xmlReader->getElements('*', $tblNode); $rowNodes = $xmlReader->getElements('*', $tblNode);
foreach ($rowNodes as $rowNode) { foreach ($rowNodes as $rowNode) {
if ($rowNode->nodeName == 'w:trPr') { // Row style if ('w:trPr' == $rowNode->nodeName) { // Row style
// @todo Do something with 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'); $cellWidth = $xmlReader->getAttribute('w:w', $rowNode, 'w:tcPr/w:tcW');
$cellStyle = null; $cellStyle = null;
$cellStyleNode = $xmlReader->getElement('w:tcPr', $rowNode); $cellStyleNode = $xmlReader->getElement('w:tcPr', $rowNode);
@ -294,7 +294,7 @@ abstract class AbstractPart
$cell = $row->addCell($cellWidth, $cellStyle); $cell = $row->addCell($cellWidth, $cellStyle);
$cellNodes = $xmlReader->getElements('*', $rowNode); $cellNodes = $xmlReader->getElements('*', $rowNode);
foreach ($cellNodes as $cellNode) { foreach ($cellNodes as $cellNode) {
if ($cellNode->nodeName == 'w:p') { // Paragraph if ('w:p' == $cellNode->nodeName) { // Paragraph
$this->readParagraph($xmlReader, $cellNode, $cell, $docPart); $this->readParagraph($xmlReader, $cellNode, $cell, $docPart);
} }
} }
@ -320,7 +320,7 @@ abstract class AbstractPart
$styleNode = $xmlReader->getElement('w:pPr', $domNode); $styleNode = $xmlReader->getElement('w:pPr', $domNode);
$styleDefs = array( $styleDefs = array(
'styleName' => array(self::READ_VALUE, 'w:pStyle'), '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'), 'basedOn' => array(self::READ_VALUE, 'w:basedOn'),
'next' => array(self::READ_VALUE, 'w:next'), 'next' => array(self::READ_VALUE, 'w:next'),
'indent' => array(self::READ_VALUE, 'w:ind', 'w:left'), 'indent' => array(self::READ_VALUE, 'w:ind', 'w:left'),
@ -349,7 +349,7 @@ abstract class AbstractPart
return null; return null;
} }
// Hyperlink has an extra w:r child // Hyperlink has an extra w:r child
if ($domNode->nodeName == 'w:hyperlink') { if ('w:hyperlink' == $domNode->nodeName) {
$domNode = $xmlReader->getElement('w:r', $domNode); $domNode = $xmlReader->getElement('w:r', $domNode);
} }
if (!$xmlReader->elementExists('w:rPr', $domNode)) { if (!$xmlReader->elementExists('w:rPr', $domNode)) {
@ -399,7 +399,6 @@ abstract class AbstractPart
} else { } else {
$styleNode = $xmlReader->getElement('w:tblPr', $domNode); $styleNode = $xmlReader->getElement('w:tblPr', $domNode);
$styleDefs = array(); $styleDefs = array();
// $styleDefs['styleName'] = array(self::READ_VALUE, 'w:tblStyle');
foreach ($margins as $side) { foreach ($margins as $side) {
$ucfSide = ucfirst($side); $ucfSide = ucfirst($side);
$styleDefs["cellMargin$ucfSide"] = array(self::READ_VALUE, "w:tblCellMar/w:$side", 'w:w'); $styleDefs["cellMargin$ucfSide"] = array(self::READ_VALUE, "w:tblCellMar/w:$side", 'w:w');
@ -482,13 +481,13 @@ abstract class AbstractPart
{ {
$style = $attributeValue; $style = $attributeValue;
if ($method == self::READ_SIZE) { if (self::READ_SIZE == $method) {
$style = $attributeValue / 2; $style = $attributeValue / 2;
} elseif ($method == self::READ_TRUE) { } elseif (self::READ_TRUE == $method) {
$style = true; $style = true;
} elseif ($method == self::READ_FALSE) { } elseif (self::READ_FALSE == $method) {
$style = false; $style = false;
} elseif ($method == self::READ_EQUAL) { } elseif (self::READ_EQUAL == $method) {
$style = $attributeValue == $expected; $style = $attributeValue == $expected;
} }

View File

@ -105,7 +105,7 @@ class Numbering extends AbstractPart
$level['restart'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlRestart'); $level['restart'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlRestart');
$level['suffix'] = $xmlReader->getAttribute('w:val', $subnode, 'w:suff'); $level['suffix'] = $xmlReader->getAttribute('w:val', $subnode, 'w:suff');
$level['text'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlText'); $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['tab'] = $xmlReader->getAttribute('w:pos', $subnode, 'w:pPr/w:tabs/w:tab');
$level['left'] = $xmlReader->getAttribute('w:left', $subnode, 'w:pPr/w:ind'); $level['left'] = $xmlReader->getAttribute('w:left', $subnode, 'w:pPr/w:ind');
$level['hanging'] = $xmlReader->getAttribute('w:hanging', $subnode, 'w:pPr/w:ind'); $level['hanging'] = $xmlReader->getAttribute('w:hanging', $subnode, 'w:pPr/w:ind');

View File

@ -407,6 +407,7 @@ class Settings
* Return the compatibility option used by the XMLWriter * Return the compatibility option used by the XMLWriter
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public static function getCompatibility() public static function getCompatibility()

View File

@ -21,6 +21,7 @@ namespace PhpOffice\PhpWord\Shared;
* DEPRECATED: Common font functions; Use 'Converter' * DEPRECATED: Common font functions; Use 'Converter'
* *
* @deprecated 0.12.0 * @deprecated 0.12.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class Font class Font

View File

@ -51,7 +51,7 @@ class Html
$html = str_replace('&', '&amp;', $html); $html = str_replace('&', '&amp;', $html);
$html = str_replace(array('_lt_', '_gt_', '_amp_'), array('&lt;', '&gt;', '&amp;'), $html); $html = str_replace(array('_lt_', '_gt_', '_amp_'), array('&lt;', '&gt;', '&amp;'), $html);
if ($fullHTML === false) { if (false === $fullHTML) {
$html = '<body>' . $html . '</body>'; $html = '<body>' . $html . '</body>';
} }
@ -73,7 +73,7 @@ class Html
*/ */
protected static function parseInlineStyle($node, $styles = array()) 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) $attributes = $node->attributes; // get all the attributes(eg: id, class)
foreach ($attributes as $attribute) { foreach ($attributes as $attribute) {
@ -173,7 +173,7 @@ class Html
*/ */
private static function parseChildNodes($node, $element, $styles, $data) private static function parseChildNodes($node, $element, $styles, $data)
{ {
if ($node->nodeName != 'li') { if ('li' != $node->nodeName) {
$cNodes = $node->childNodes; $cNodes = $node->childNodes;
if (count($cNodes) > 0) { if (count($cNodes) > 0) {
foreach ($cNodes as $cNode) { foreach ($cNodes as $cNode) {
@ -361,7 +361,7 @@ class Html
} }
break; break;
case 'text-align': case 'text-align':
$styles['align'] = $cValue; $styles['alignment'] = $cValue; // todo: any mapping?
break; break;
case 'color': case 'color':
$styles['color'] = trim($cValue, "#"); $styles['color'] = trim($cValue, "#");

View File

@ -62,6 +62,7 @@ class OLERead
* Read the file * Read the file
* *
* @param $sFileName string Filename * @param $sFileName string Filename
*
* @throws Exception * @throws Exception
*/ */
public function read($sFileName) public function read($sFileName)

View File

@ -45,7 +45,9 @@ class XMLReader
* *
* @param string $zipFile * @param string $zipFile
* @param string $xmlFile * @param string $xmlFile
*
* @return \DOMDocument|false * @return \DOMDocument|false
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public function getDomFromZip($zipFile, $xmlFile) public function getDomFromZip($zipFile, $xmlFile)

View File

@ -107,6 +107,7 @@ class XMLWriter
* *
* @param mixed $function * @param mixed $function
* @param mixed $args * @param mixed $args
*
* @throws \BadMethodCallException * @throws \BadMethodCallException
*/ */
public function __call($function, $args) public function __call($function, $args)

View File

@ -151,7 +151,9 @@ class ZipArchive
* Close the active archive * Close the active archive
* *
* @return bool * @return bool
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*
* @codeCoverageIgnore Can't find any test case. Uncomment when found. * @codeCoverageIgnore Can't find any test case. Uncomment when found.
*/ */
public function close() public function close()

View File

@ -0,0 +1,57 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2014 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\SimpleType;
/**
* Horizontal Alignment Type.
*
* @since 0.13.0
*/
final class ST_Jc
{
const START = 'start';
const CENTER = 'center';
const END = 'end';
const BOTH = 'both';
const MEDIUM_KASHIDA = 'mediumKashida';
const DISTRIBUTE = 'distribute';
const NUM_TAB = 'numTab';
const HIGH_KASHIDA = 'highKashida';
const LOW_KASHIDA = 'lowKashida';
const THAI_DISTRIBUTE = 'thaiDistribute';
/**
* @since 0.13.0
*
* @return string[]
*/
final public static function getAllowedValues()
{
return array(
self::START,
self::CENTER,
self::END,
self::MEDIUM_KASHIDA,
self::DISTRIBUTE,
self::NUM_TAB,
self::HIGH_KASHIDA,
self::LOW_KASHIDA,
self::THAI_DISTRIBUTE,
);
}
}

View File

@ -15,32 +15,26 @@
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Writer\Word2007\Style; namespace PhpOffice\PhpWord\SimpleType;
/** /**
* Alignment style writer * Table Alignment Type.
* *
* @since 0.11.0 * @since 0.13.0
*/ */
class Alignment extends AbstractStyle final class ST_JcTable
{ {
const START = 'start';
const CENTER = 'center';
const END = 'end';
/** /**
* Write style. * @since 0.13.0
* *
* @return void * @return string[]
*/ */
public function write() final public static function getAllowedValues()
{ {
$style = $this->getStyle(); return array(self::START, self::CENTER, self::END);
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
}
} }
} }

View File

@ -278,7 +278,9 @@ abstract class AbstractStyle
* @param mixed $value * @param mixed $value
* @param array $enum * @param array $enum
* @param mixed $default * @param mixed $default
*
* @return mixed * @return mixed
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
protected function setEnumVal($value = null, $enum = array(), $default = null) protected function setEnumVal($value = null, $enum = array(), $default = null)
@ -337,9 +339,12 @@ abstract class AbstractStyle
/** /**
* Set style using associative array * Set style using associative array
* *
* @param array $style
* @return self
* @deprecated 0.11.0 * @deprecated 0.11.0
*
* @param array $style
*
* @return self
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function setArrayStyle(array $style = array()) public function setArrayStyle(array $style = array())

View File

@ -1,78 +0,0 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2014 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
* Alignment style
*
* @link http://www.schemacentral.com/sc/ooxml/t-w_CT_Jc.html
* @since 0.11.0
*/
class Alignment extends AbstractStyle
{
/**
* @const string Alignment http://www.schemacentral.com/sc/ooxml/t-w_ST_Jc.html
*/
const ALIGN_LEFT = 'left'; // Align left
const ALIGN_RIGHT = 'right'; // Align right
const ALIGN_CENTER = 'center'; // Align center
const ALIGN_BOTH = 'both'; // Align both
const ALIGN_JUSTIFY = 'justify'; // Alias for align both
/**
* @var string Alignment
*/
private $value = null;
/**
* Create a new instance
*
* @param array $style
*/
public function __construct($style = array())
{
$this->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;
}
}

View File

@ -240,6 +240,7 @@ class Cell extends Border
* Get default border color * Get default border color
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getDefaultBorderColor() public function getDefaultBorderColor()

View File

@ -787,6 +787,7 @@ class Font extends AbstractStyle
* Get bold * Get bold
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getBold() public function getBold()
@ -798,6 +799,7 @@ class Font extends AbstractStyle
* Get italic * Get italic
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getItalic() public function getItalic()
@ -809,6 +811,7 @@ class Font extends AbstractStyle
* Get superscript * Get superscript
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getSuperScript() public function getSuperScript()
@ -820,6 +823,7 @@ class Font extends AbstractStyle
* Get subscript * Get subscript
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getSubScript() public function getSubScript()
@ -831,6 +835,7 @@ class Font extends AbstractStyle
* Get strikethrough * Get strikethrough
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getStrikethrough() public function getStrikethrough()
@ -842,6 +847,7 @@ class Font extends AbstractStyle
* Get paragraph style * Get paragraph style
* *
* @deprecated 0.11.0 * @deprecated 0.11.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getParagraphStyle() public function getParagraphStyle()

View File

@ -17,6 +17,8 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
/** /**
* Frame defines the size and position of an object * Frame defines the size and position of an object
* *
@ -88,11 +90,9 @@ class Frame extends AbstractStyle
const WRAP_INFRONT = 'infront'; const WRAP_INFRONT = 'infront';
/** /**
* Alignment * @var string
*
* @var \PhpOffice\PhpWord\Style\Alignment
*/ */
private $alignment; private $alignment = '';
/** /**
* Unit * Unit
@ -178,31 +178,59 @@ class Frame extends AbstractStyle
*/ */
public function __construct($style = array()) public function __construct($style = array())
{ {
$this->alignment = new Alignment();
$this->setStyleByArray($style); $this->setStyleByArray($style);
} }
/** /**
* Get alignment * @since 0.13.0
* *
* @return string * @return string
*/ */
public function getAlign() public function getAlignment()
{ {
return $this->alignment->getValue(); return $this->alignment;
} }
/** /**
* Set alignment * @since 0.13.0
* *
* @param string $value * @param string $value
*
* @return self * @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) public function setAlign($value = null)
{ {
$this->alignment->setValue($value); return $this->setAlignment($value);
return $this;
} }
/** /**

View File

@ -133,7 +133,9 @@ class Image extends Frame
* Set wrapping style * Set wrapping style
* *
* @param string $wrappingStyle * @param string $wrappingStyle
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*
* @return self * @return self
*/ */
public function setWrappingStyle($wrappingStyle) public function setWrappingStyle($wrappingStyle)
@ -157,7 +159,9 @@ class Image extends Frame
* Set positioning type * Set positioning type
* *
* @param string $positioning * @param string $positioning
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*
* @return self * @return self
*/ */
public function setPositioning($positioning) public function setPositioning($positioning)
@ -181,7 +185,9 @@ class Image extends Frame
* Set horizontal alignment * Set horizontal alignment
* *
* @param string $alignment * @param string $alignment
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*
* @return self * @return self
*/ */
public function setPosHorizontal($alignment) public function setPosHorizontal($alignment)
@ -205,7 +211,9 @@ class Image extends Frame
* Set vertical alignment * Set vertical alignment
* *
* @param string $alignment * @param string $alignment
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*
* @return self * @return self
*/ */
public function setPosVertical($alignment) public function setPosVertical($alignment)
@ -229,7 +237,9 @@ class Image extends Frame
* Set horizontal relation * Set horizontal relation
* *
* @param string $relto * @param string $relto
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*
* @return self * @return self
*/ */
public function setPosHorizontalRel($relto) public function setPosHorizontalRel($relto)
@ -253,7 +263,9 @@ class Image extends Frame
* Set vertical relation * Set vertical relation
* *
* @param string $relto * @param string $relto
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*
* @return self * @return self
*/ */
public function setPosVerticalRel($relto) public function setPosVerticalRel($relto)

View File

@ -155,7 +155,7 @@ class ListItem extends AbstractStyle
} }
// Property mapping for numbering level information // 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 // Legacy level information
$listTypeStyles = array( $listTypeStyles = array(

View File

@ -81,12 +81,9 @@ class NumberingLevel extends AbstractStyle
private $text; private $text;
/** /**
* Align left|center|right|both
*
* @var string * @var string
* @link http://www.schemacentral.com/sc/ooxml/e-w_lvlJc-1.html
*/ */
private $align; private $alignment;
/** /**
* Left * Left
@ -281,26 +278,55 @@ class NumberingLevel extends AbstractStyle
} }
/** /**
* Get align * @since 0.13.0
* *
* @return string * @return string
*/ */
public function getAlign() public function getAlignment()
{ {
return $this->align; return $this->alignment;
} }
/** /**
* Set align * @since 0.13.0
* *
* @param string $value * @param string $value
*
* @return self * @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) public function setAlign($value)
{ {
$enum = array('left', 'center', 'right', 'both'); return $this->setAlignment($value);
$this->align = $this->setEnumVal($value, $enum, $this->align);
return $this;
} }
/** /**

View File

@ -19,13 +19,13 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Exception\InvalidStyleException; use PhpOffice\PhpWord\Exception\InvalidStyleException;
use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\String;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
/** /**
* Paragraph style * Paragraph style
* *
* OOXML: * OOXML:
* - General: alignment, outline level * - General: alignment, outline level
* - Alignment: left, right, center, both
* - Indentation: left, right, firstline, hanging * - Indentation: left, right, firstline, hanging
* - Spacing: before, after, line spacing * - Spacing: before, after, line spacing
* - Pagination: widow control, keep next, keep line, page break before * - Pagination: widow control, keep next, keep line, page break before
@ -77,11 +77,9 @@ class Paragraph extends Border
private $next; private $next;
/** /**
* Alignment * @var string
*
* @var \PhpOffice\PhpWord\Style\Alignment
*/ */
private $alignment; private $alignment = '';
/** /**
* Indentation * Indentation
@ -170,9 +168,9 @@ class Paragraph extends Border
public function setStyleValue($key, $value) public function setStyleValue($key, $value)
{ {
$key = String::removeUnderscorePrefix($key); $key = String::removeUnderscorePrefix($key);
if ($key == 'indent' || $key == 'hanging') { if ('indent' == $key || 'hanging' == $key) {
$value = $value * 720; $value = $value * 720;
} elseif ($key == 'spacing') { } elseif ('spacing' == $key) {
$value += 240; // because line height of 1 matches 240 twips $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() public function getAlignment()
{ {
@ -226,18 +224,47 @@ class Paragraph extends Border
} }
/** /**
* Set alignment * @since 0.13.0
* *
* @param string $value * @param string $value
*
* @return self * @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; 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 * Get parent style ID
* *
@ -451,7 +478,9 @@ class Paragraph extends Border
* Set the line height * Set the line height
* *
* @param int|float|string $lineHeight * @param int|float|string $lineHeight
*
* @return self * @return self
*
* @throws \PhpOffice\PhpWord\Exception\InvalidStyleException * @throws \PhpOffice\PhpWord\Exception\InvalidStyleException
*/ */
public function setLineHeight($lineHeight) public function setLineHeight($lineHeight)
@ -636,6 +665,7 @@ class Paragraph extends Border
* Get allow first/last line to display on a separate page setting * Get allow first/last line to display on a separate page setting
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getWidowControl() public function getWidowControl()
@ -647,6 +677,7 @@ class Paragraph extends Border
* Get keep paragraph with next paragraph setting * Get keep paragraph with next paragraph setting
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getKeepNext() public function getKeepNext()
@ -658,6 +689,7 @@ class Paragraph extends Border
* Get keep all lines on one page setting * Get keep all lines on one page setting
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getKeepLines() public function getKeepLines()
@ -669,6 +701,7 @@ class Paragraph extends Border
* Get start paragraph on next page setting * Get start paragraph on next page setting
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getPageBreakBefore() public function getPageBreakBefore()

View File

@ -125,6 +125,7 @@ class Row extends AbstractStyle
* Get tblHeader * Get tblHeader
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getTblHeader() public function getTblHeader()
@ -136,6 +137,7 @@ class Row extends AbstractStyle
* Get cantSplit * Get cantSplit
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getCantSplit() public function getCantSplit()
@ -147,6 +149,7 @@ class Row extends AbstractStyle
* Get exactHeight * Get exactHeight
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getExactHeight() public function getExactHeight()

View File

@ -35,14 +35,14 @@ class Section extends Border
* *
* @const int|float * @const int|float
*/ */
const DEFAULT_WIDTH = 11870; // In twip const DEFAULT_WIDTH = 11870; // In twips.
const DEFAULT_HEIGHT = 16787; // In twip const DEFAULT_HEIGHT = 16787; // In twips.
const DEFAULT_MARGIN = 1440; // In twip const DEFAULT_MARGIN = 1440; // In twips.
const DEFAULT_GUTTER = 0; // In twip const DEFAULT_GUTTER = 0; // In twips.
const DEFAULT_HEADER_HEIGHT = 720; // In twip const DEFAULT_HEADER_HEIGHT = 720; // In twips.
const DEFAULT_FOOTER_HEIGHT = 720; // In twip const DEFAULT_FOOTER_HEIGHT = 720; // In twips.
const DEFAULT_COLUMN_COUNT = 1; const DEFAULT_COLUMN_COUNT = 1;
const DEFAULT_COLUMN_SPACING = 720; // In twip const DEFAULT_COLUMN_SPACING = 720; // In twips.
/** /**
* Page Orientation * Page Orientation

View File

@ -25,8 +25,9 @@ class TOC extends Tab
/** /**
* Tab leader types for backward compatibility * Tab leader types for backward compatibility
* *
* @const string
* @deprecated 0.11.0 * @deprecated 0.11.0
*
* @const string
*/ */
const TABLEADER_DOT = self::TAB_LEADER_DOT; const TABLEADER_DOT = self::TAB_LEADER_DOT;
const TABLEADER_UNDERSCORE = self::TAB_LEADER_UNDERSCORE; const TABLEADER_UNDERSCORE = self::TAB_LEADER_UNDERSCORE;

View File

@ -17,9 +17,8 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
/** use PhpOffice\PhpWord\SimpleType\ST_JcTable;
* Table style
*/
class Table extends Border class Table extends Border
{ {
/** /**
@ -107,9 +106,9 @@ class Table extends Border
private $shading; private $shading;
/** /**
* @var \PhpOffice\PhpWord\Style\Alignment Alignment * @var string
*/ */
private $alignment; private $alignment = '';
/** /**
* @var int|float Width value * @var int|float Width value
@ -129,8 +128,6 @@ class Table extends Border
*/ */
public function __construct($tableStyle = null, $firstRowStyle = null) public function __construct($tableStyle = null, $firstRowStyle = null)
{ {
$this->alignment = new Alignment();
// Clone first row from table style, but with certain properties disabled // Clone first row from table style, but with certain properties disabled
if ($firstRowStyle !== null && is_array($firstRowStyle)) { if ($firstRowStyle !== null && is_array($firstRowStyle)) {
$this->firstRowStyle = clone $this; $this->firstRowStyle = clone $this;
@ -494,26 +491,55 @@ class Table extends Border
} }
/** /**
* Get alignment * @since 0.13.0
* *
* @return string * @return string
*/ */
public function getAlign() public function getAlignment()
{ {
return $this->alignment->getValue(); return $this->alignment;
} }
/** /**
* Set alignment * @since 0.13.0
* *
* @param string $value * @param string $value
*
* @return self * @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) public function setAlign($value = null)
{ {
$this->alignment->setValue($value); return $this->setAlignment($value);
return $this;
} }
/** /**
@ -574,7 +600,7 @@ class Table extends Border
*/ */
private function getTableOnlyProperty($property) private function getTableOnlyProperty($property)
{ {
if ($this->isFirstRow === false) { if (false === $this->isFirstRow) {
return $this->$property; return $this->$property;
} }
@ -594,8 +620,8 @@ class Table extends Border
*/ */
private function setTableOnlyProperty($property, $value, $isNumeric = true) private function setTableOnlyProperty($property, $value, $isNumeric = true)
{ {
if ($this->isFirstRow === false) { if (false === $this->isFirstRow) {
if ($isNumeric === true) { if (true === $isNumeric) {
$this->$property = $this->setNumericVal($value, $this->$property); $this->$property = $this->setNumericVal($value, $this->$property);
} else { } else {
$this->$property = $value; $this->$property = $value;

View File

@ -18,7 +18,9 @@
namespace PhpOffice\PhpWord; 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 class Template extends TemplateProcessor
{ {

View File

@ -97,6 +97,7 @@ abstract class AbstractWriter implements WriterInterface
* Get PhpWord object * Get PhpWord object
* *
* @return \PhpOffice\PhpWord\PhpWord * @return \PhpOffice\PhpWord\PhpWord
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public function getPhpWord() public function getPhpWord()
@ -150,7 +151,9 @@ abstract class AbstractWriter implements WriterInterface
* *
* @param bool $value * @param bool $value
* @param string $directory * @param string $directory
*
* @return self * @return self
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public function setUseDiskCaching($value = false, $directory = null) public function setUseDiskCaching($value = false, $directory = null)
@ -234,6 +237,7 @@ abstract class AbstractWriter implements WriterInterface
* Cleanup temporary file. * Cleanup temporary file.
* *
* @return void * @return void
*
* @throws \PhpOffice\PhpWord\Exception\CopyFileException * @throws \PhpOffice\PhpWord\Exception\CopyFileException
*/ */
protected function cleanupTempFile() protected function cleanupTempFile()
@ -267,7 +271,9 @@ abstract class AbstractWriter implements WriterInterface
* Get ZipArchive object * Get ZipArchive object
* *
* @param string $filename * @param string $filename
*
* @return \PhpOffice\PhpWord\Shared\ZipArchive * @return \PhpOffice\PhpWord\Shared\ZipArchive
*
* @throws \Exception * @throws \Exception
*/ */
protected function getZipArchive($filename) protected function getZipArchive($filename)
@ -295,10 +301,13 @@ abstract class AbstractWriter implements WriterInterface
/** /**
* Open file for writing * Open file for writing
* *
* @param string $filename
* @return resource
* @throws \Exception
* @since 0.11.0 * @since 0.11.0
*
* @param string $filename
*
* @return resource
*
* @throws \Exception
*/ */
protected function openFile($filename) protected function openFile($filename)
{ {
@ -423,6 +432,7 @@ abstract class AbstractWriter implements WriterInterface
* Get use disk caching status * Get use disk caching status
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function getUseDiskCaching() public function getUseDiskCaching()

View File

@ -64,7 +64,9 @@ class HTML extends AbstractWriter implements WriterInterface
* Save PhpWord to file. * Save PhpWord to file.
* *
* @param string $filename * @param string $filename
*
* @return void * @return void
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public function save($filename = null) public function save($filename = null)
@ -127,8 +129,10 @@ class HTML extends AbstractWriter implements WriterInterface
/** /**
* Write document * Write document
* *
* @return string
* @deprecated 0.11.0 * @deprecated 0.11.0
*
* @return string
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function writeDocument() public function writeDocument()

View File

@ -56,6 +56,7 @@ abstract class AbstractPart
* Get parent writer * Get parent writer
* *
* @return \PhpOffice\PhpWord\Writer\AbstractWriter * @return \PhpOffice\PhpWord\Writer\AbstractWriter
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public function getParentWriter() public function getParentWriter()

View File

@ -38,10 +38,8 @@ class Paragraph extends AbstractStyle
$css = array(); $css = array();
// Alignment // Alignment
$alignment = $style->getAlignment(); if ('' !== $style->getAlignment()) {
if (!is_null($alignment)) { $css['text-align'] = $style->getAlignment(); // todo: convert OpenXml to Html values
$alignmentValue = $alignment->getValue();
$css['text-align'] = $this->getValueIf(!is_null($alignmentValue), $alignmentValue);
} }
// Spacing // Spacing

View File

@ -39,6 +39,7 @@ class PDF
* Instantiate a new renderer of the configured type within this container class * Instantiate a new renderer of the configured type within this container class
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public function __construct(PhpWord $phpWord) public function __construct(PhpWord $phpWord)

View File

@ -77,6 +77,7 @@ abstract class AbstractRenderer extends HTML
* Create new instance * Create new instance
* *
* @param PhpWord $phpWord PhpWord object * @param PhpWord $phpWord PhpWord object
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public function __construct(PhpWord $phpWord) public function __construct(PhpWord $phpWord)
@ -169,7 +170,9 @@ abstract class AbstractRenderer extends HTML
* Save PhpWord to PDF file, pre-save * Save PhpWord to PDF file, pre-save
* *
* @param string $filename Name of the file to save as * @param string $filename Name of the file to save as
*
* @return resource * @return resource
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
protected function prepareForSave($filename = null) protected function prepareForSave($filename = null)
@ -190,7 +193,9 @@ abstract class AbstractRenderer extends HTML
* Save PhpWord to PDF file, post-save * Save PhpWord to PDF file, post-save
* *
* @param resource $fileHandle * @param resource $fileHandle
*
* @return void * @return void
*
* @throws Exception * @throws Exception
*/ */
protected function restoreStateAfterSave($fileHandle) protected function restoreStateAfterSave($fileHandle)

View File

@ -58,7 +58,9 @@ class RTF extends AbstractWriter implements WriterInterface
* Save content to file. * Save content to file.
* *
* @param string $filename * @param string $filename
*
* @return void * @return void
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public function save($filename = null) public function save($filename = null)

View File

@ -17,7 +17,7 @@
namespace PhpOffice\PhpWord\Writer\RTF\Style; namespace PhpOffice\PhpWord\Writer\RTF\Style;
use PhpOffice\PhpWord\Style\Alignment; use PhpOffice\PhpWord\SimpleType\ST_Jc;
/** /**
* RTF paragraph style writer * RTF paragraph style writer
@ -48,13 +48,12 @@ class Paragraph extends AbstractStyle
} }
$alignments = array( $alignments = array(
Alignment::ALIGN_LEFT => '\ql', ST_Jc::START => '\ql',
Alignment::ALIGN_RIGHT => '\qr', ST_Jc::END => '\qr',
Alignment::ALIGN_CENTER => '\qc', ST_Jc::CENTER => '\qc',
Alignment::ALIGN_BOTH => '\qj', ST_Jc::BOTH => '\qj',
); );
$alignment = $style->getAlignment();
$spaceAfter = $style->getSpaceAfter(); $spaceAfter = $style->getSpaceAfter();
$spaceBefore = $style->getSpaceBefore(); $spaceBefore = $style->getSpaceBefore();
@ -62,8 +61,8 @@ class Paragraph extends AbstractStyle
if ($this->nestedLevel == 0) { if ($this->nestedLevel == 0) {
$content .= '\pard\nowidctlpar '; $content .= '\pard\nowidctlpar ';
} }
if (!is_null($alignment) && isset($alignments[$alignment->getValue()])) { if (isset($alignments[$style->getAlignment()])) {
$content .= $alignments[$alignment->getValue()]; $content .= $alignments[$style->getAlignment()];
} }
$content .= $this->getValueIf($spaceBefore !== null, '\sb' . $spaceBefore); $content .= $this->getValueIf($spaceBefore !== null, '\sb' . $spaceBefore);
$content .= $this->getValueIf($spaceAfter !== null, '\sa' . $spaceAfter); $content .= $this->getValueIf($spaceAfter !== null, '\sa' . $spaceAfter);

View File

@ -0,0 +1,60 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2014 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
/**
* @since 0.13.0
*/
class ParagraphAlignment
{
private $name = 'w:jc';
private $attributes = array();
/**
* @since 0.13.0
*
* @param string $value Any value provided by ST_Jc simple type.
*
* @see \PhpOffice\PhpWord\SimpleType\Jc For the allowed values of $value parameter.
*/
final public function __construct($value)
{
$this->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;
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2014 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
/**
* @since 0.13.0
*/
class TableAlignment
{
private $name = 'w:jc';
private $attributes = array();
/**
* @since 0.13.0
*
* @param string $value Any value provided by ST_JcTable simple type.
*
* @see \PhpOffice\PhpWord\SimpleType\JcTable For the allowed values of $value parameter.
*/
final public function __construct($value)
{
$this->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;
}
}

View File

@ -60,6 +60,7 @@ abstract class AbstractPart
* Get parent writer * Get parent writer
* *
* @return \PhpOffice\PhpWord\Writer\AbstractWriter * @return \PhpOffice\PhpWord\Writer\AbstractWriter
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
public function getParentWriter() public function getParentWriter()

View File

@ -18,9 +18,9 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Numbering as NumberingStyle; use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
use PhpOffice\PhpWord\Style\NumberingLevel; use PhpOffice\PhpWord\Style\NumberingLevel;
use PhpOffice\PhpWord\Style;
/** /**
* Word2007 numbering part writer: word/numbering.xml * Word2007 numbering part writer: word/numbering.xml
@ -114,7 +114,7 @@ class Numbering extends AbstractPart
'pStyle' => 'pStyle', 'pStyle' => 'pStyle',
'suffix' => 'suff', 'suffix' => 'suff',
'text' => 'lvlText', 'text' => 'lvlText',
'align' => 'lvlJc' 'alignment' => 'lvlJc'
); );
foreach ($properties as $property => $nodeName) { foreach ($properties as $property => $nodeName) {
$getMethod = "get{$property}"; $getMethod = "get{$property}";

View File

@ -108,7 +108,9 @@ class Rels extends AbstractPart
* @param string $type Relationship type * @param string $type Relationship type
* @param string $target Relationship target * @param string $target Relationship target
* @param string $targetMode Relationship target mode * @param string $targetMode Relationship target mode
*
* @return void * @return void
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*/ */
private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '') private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '')

View File

@ -18,8 +18,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style; namespace PhpOffice\PhpWord\Writer\Word2007\Style;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle;
use PhpOffice\PhpWord\Style\Frame as FrameStyle; use PhpOffice\PhpWord\Style\Frame as FrameStyle;
use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
/** /**
* Frame style writer * Frame style writer
@ -89,13 +89,21 @@ class Frame extends AbstractStyle
$xmlWriter = $this->getXmlWriter(); $xmlWriter = $this->getXmlWriter();
$xmlWriter->startElement('w:pPr'); $xmlWriter->startElement('w:pPr');
$styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign())));
$styleWriter->write(); if ('' !== $style->getAlignment()) {
$xmlWriter->endElement(); // w:pPr $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\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Frame $style * @param \PhpOffice\PhpWord\Style\Frame $style

View File

@ -20,6 +20,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
/** /**
* Paragraph style writer * 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']['keepLines'] === true, 'w:keepLines', 'w:val', '1');
$xmlWriter->writeElementIf($styles['pagination']['pageBreak'] === true, 'w:pageBreakBefore', '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 // Child style: alignment, indentation, spacing, and shading
$this->writeChildStyle($xmlWriter, 'Alignment', $styles['alignment']);
$this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']); $this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']);
$this->writeChildStyle($xmlWriter, 'Spacing', $styles['spacing']); $this->writeChildStyle($xmlWriter, 'Spacing', $styles['spacing']);
$this->writeChildStyle($xmlWriter, 'Shading', $styles['shading']); $this->writeChildStyle($xmlWriter, 'Shading', $styles['shading']);

View File

@ -18,8 +18,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style; namespace PhpOffice\PhpWord\Writer\Word2007\Style;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle;
use PhpOffice\PhpWord\Style\Table as TableStyle; use PhpOffice\PhpWord\Style\Table as TableStyle;
use PhpOffice\PhpWord\Writer\Word2007\Element\TableAlignment;
/** /**
* Table style writer * Table style writer
@ -50,7 +50,7 @@ class Table extends AbstractStyle
$xmlWriter->startElement('w:tblStyle'); $xmlWriter->startElement('w:tblStyle');
$xmlWriter->writeAttribute('w:val', $style); $xmlWriter->writeAttribute('w:val', $style);
$xmlWriter->endElement(); $xmlWriter->endElement();
if ($this->width !== null) { if (null !== $this->width) {
$this->writeWidth($xmlWriter, $this->width, 'pct'); $this->writeWidth($xmlWriter, $this->width, 'pct');
} }
$xmlWriter->endElement(); $xmlWriter->endElement();
@ -69,9 +69,15 @@ class Table extends AbstractStyle
// w:tblPr // w:tblPr
$xmlWriter->startElement('w:tblPr'); $xmlWriter->startElement('w:tblPr');
// Alignment // Table alignment
$styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign()))); if ('' !== $style->getAlignment()) {
$styleWriter->write(); $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->writeWidth($xmlWriter, $style->getWidth(), $style->getUnit());
$this->writeMargin($xmlWriter, $style); $this->writeMargin($xmlWriter, $style);
@ -174,7 +180,7 @@ class Table extends AbstractStyle
*/ */
private function writeShading(XMLWriter $xmlWriter, TableStyle $style) private function writeShading(XMLWriter $xmlWriter, TableStyle $style)
{ {
if ($style->getShading() !== null) { if (null !== $style->getShading()) {
$xmlWriter->startElement('w:tcPr'); $xmlWriter->startElement('w:tcPr');
$styleWriter = new Shading($xmlWriter, $style->getShading()); $styleWriter = new Shading($xmlWriter, $style->getShading());

View File

@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Element; namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Element\CheckBox; use PhpOffice\PhpWord\Element\CheckBox;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Font; 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'); $oCheckBox = new CheckBox(htmlspecialchars('chkBox', ENT_COMPAT, 'UTF-8'), htmlspecialchars('CheckBox', ENT_COMPAT, 'UTF-8'), 'fontStyle', 'paragraphStyle');
$this->assertEquals('paragraphStyle', $oCheckBox->getParagraphStyle()); $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()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oCheckBox->getParagraphStyle());
} }
} }

View File

@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Element; namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Element\Image; use PhpOffice\PhpWord\Element\Image;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
/** /**
* Test class for PhpOffice\PhpWord\Element\Image * Test class for PhpOffice\PhpWord\Element\Image
@ -54,7 +55,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
array( array(
'width' => 210, 'width' => 210,
'height' => 210, 'height' => 210,
'align' => 'center', 'alignment' => ST_Jc::CENTER,
'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND, 'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND,
) )
); );
@ -97,7 +98,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
{ {
$oImage = new Image( $oImage = new Image(
__DIR__ . '/../_files/images/earth.jpg', __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()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle());

View File

@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Element; namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Element\PreserveText; use PhpOffice\PhpWord\Element\PreserveText;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
/** /**
* Test class for PhpOffice\PhpWord\Element\PreserveText * Test class for PhpOffice\PhpWord\Element\PreserveText
@ -58,7 +59,7 @@ class PreserveTextTest extends \PHPUnit_Framework_TestCase
$oPreserveText = new PreserveText( $oPreserveText = new PreserveText(
htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), htmlspecialchars('text', ENT_COMPAT, 'UTF-8'),
array('size' => 16, 'color' => '1B2232'), 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\\Font', $oPreserveText->getFontStyle());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oPreserveText->getParagraphStyle()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oPreserveText->getParagraphStyle());

View File

@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Element; namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Element\Text;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Font; 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'); $oText = new Text(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), 'fontStyle', 'paragraphStyle');
$this->assertEquals('paragraphStyle', $oText->getParagraphStyle()); $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()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
} }
} }

View File

@ -18,6 +18,7 @@
namespace PhpOffice\PhpWord\Tests\Style; namespace PhpOffice\PhpWord\Tests\Style;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Tests\TestHelperDOCX; use PhpOffice\PhpWord\Tests\TestHelperDOCX;
@ -41,7 +42,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
*/ */
public function testInitiation() 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->assertEquals(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), $object->getStyleType());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle());
@ -157,7 +158,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
*/ */
public function testLineHeightFloatval() public function testLineHeightFloatval()
{ {
$object = new Font(null, array('align' => 'center')); $object = new Font(null, array('alignment' => ST_Jc::CENTER));
$object->setLineHeight('1.5pt'); $object->setLineHeight('1.5pt');
$this->assertEquals(1.5, $object->getLineHeight()); $this->assertEquals(1.5, $object->getLineHeight());
} }

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Style; namespace PhpOffice\PhpWord\Tests\Style;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Image; use PhpOffice\PhpWord\Style\Image;
/** /**
@ -37,7 +38,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
$properties = array( $properties = array(
'width' => 200, 'width' => 200,
'height' => 200, 'height' => 200,
'align' => 'left', 'alignment' => ST_Jc::START,
'marginTop' => 240, 'marginTop' => 240,
'marginLeft' => 240, 'marginLeft' => 240,
'wrappingStyle' => 'inline', 'wrappingStyle' => 'inline',
@ -60,7 +61,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
$properties = array( $properties = array(
'width' => 200, 'width' => 200,
'height' => 200, 'height' => 200,
'align' => 'left', 'alignment' => ST_Jc::START,
'marginTop' => 240, 'marginTop' => 240,
'marginLeft' => 240, 'marginLeft' => 240,
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Style; namespace PhpOffice\PhpWord\Tests\Style;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\NumberingLevel; use PhpOffice\PhpWord\Style\NumberingLevel;
/** /**
@ -41,7 +42,7 @@ class NumberingLevelTest extends \PHPUnit_Framework_TestCase
'pStyle' => 'pStyle', 'pStyle' => 'pStyle',
'suffix' => 'space', 'suffix' => 'space',
'text' => '%1.', 'text' => '%1.',
'align' => 'left', 'alignment' => ST_Jc::START,
'left' => 360, 'left' => 360,
'hanging' => 360, 'hanging' => 360,
'tabPos' => 360, 'tabPos' => 360,

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Style; namespace PhpOffice\PhpWord\Tests\Style;
use PhpOffice\PhpWord\SimpleType\ST_JcTable;
use PhpOffice\PhpWord\Style\Table; use PhpOffice\PhpWord\Style\Table;
/** /**
@ -74,7 +75,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
'cellMarginLeft' => 240, 'cellMarginLeft' => 240,
'cellMarginRight' => 240, 'cellMarginRight' => 240,
'cellMarginBottom' => 240, 'cellMarginBottom' => 240,
'align' => 'center', 'alignment' => ST_JcTable::CENTER,
'width' => 100, 'width' => 100,
'unit' => 'pct', 'unit' => 'pct',
); );

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Style; namespace PhpOffice\PhpWord\Tests\Style;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\TextBox; use PhpOffice\PhpWord\Style\TextBox;
/** /**
@ -37,7 +38,7 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
$properties = array( $properties = array(
'width' => 200, 'width' => 200,
'height' => 200, 'height' => 200,
'align' => 'left', 'alignment' => ST_Jc::START,
'marginTop' => 240, 'marginTop' => 240,
'marginLeft' => 240, 'marginLeft' => 240,
'wrappingStyle' => 'inline', 'wrappingStyle' => 'inline',
@ -71,7 +72,7 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
$properties = array( $properties = array(
'width' => 200, 'width' => 200,
'height' => 200, 'height' => 200,
'align' => 'left', 'alignment' => ST_Jc::START,
'marginTop' => 240, 'marginTop' => 240,
'marginLeft' => 240, 'marginLeft' => 240,
'wrappingStyle' => 'inline', 'wrappingStyle' => 'inline',
@ -132,10 +133,11 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
*/ */
public function testSetGetAlign() public function testSetGetAlign()
{ {
$expected = 'left'; $textBox = new TextBox();
$object = new TextBox();
$object->setAlign($expected); $expectedAlignment = ST_Jc::START;
$this->assertEquals($expected, $object->getAlign()); $textBox->setAlignment($expectedAlignment);
$this->assertEquals($expectedAlignment, $textBox->getAlignment());
} }
/** /**

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests; namespace PhpOffice\PhpWord\Tests;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
/** /**
@ -44,7 +45,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
*/ */
public function testStyles() public function testStyles()
{ {
$paragraph = array('align' => 'center'); $paragraph = array('alignment' => ST_Jc::CENTER);
$font = array('italic' => true, '_bold' => true); $font = array('italic' => true, '_bold' => true);
$table = array('bgColor' => 'CCCCCC'); $table = array('bgColor' => 'CCCCCC');
$styles = array( $styles = array(
@ -82,7 +83,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
*/ */
public function testDefaultParagraphStyle() public function testDefaultParagraphStyle()
{ {
$paragraph = array('align' => 'center'); $paragraph = array('alignment' => ST_Jc::CENTER);
Style::setDefaultParagraphStyle($paragraph); Style::setDefaultParagraphStyle($paragraph);

View File

@ -70,11 +70,13 @@ final class TemplateProcessorTest extends \PHPUnit_Framework_TestCase
/** /**
* XSL stylesheet can be applied. * XSL stylesheet can be applied.
* *
* @param string $actualDocumentFqfn * @test
* @throws \Exception
* @covers ::applyXslStyleSheet * @covers ::applyXslStyleSheet
* @depends testTemplateCanBeSavedInTemporaryLocation * @depends testTemplateCanBeSavedInTemporaryLocation
* @test *
* @param string $actualDocumentFqfn
*
* @throws \Exception
*/ */
final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn) final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn)
{ {

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer; namespace PhpOffice\PhpWord\Tests\Writer;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Writer\HTML; use PhpOffice\PhpWord\Writer\HTML;
/** /**
@ -69,7 +70,7 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
'Font', 'Font',
array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000') 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 = $phpWord->addSection();
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph'); $section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
$section->addTextBreak(); $section->addTextBreak();
@ -90,7 +91,7 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
$section = $phpWord->addSection(); $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->addText(htmlspecialchars('Test 3', ENT_COMPAT, 'UTF-8'));
$textrun->addTextBreak(); $textrun->addTextBreak();

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX; use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/** /**
@ -51,7 +52,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
$phpWord->setDefaultFontName('Verdana'); $phpWord->setDefaultFontName('Verdana');
$phpWord->addFontStyle('Font', array('size' => 11)); $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)); $phpWord->addTableStyle('tblStyle', array('width' => 100));
$section = $phpWord->addSection(array('colsNum' => 2)); $section = $phpWord->addSection(array('colsNum' => 2));

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer; namespace PhpOffice\PhpWord\Tests\Writer;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Writer\ODText; use PhpOffice\PhpWord\Writer\ODText;
/** /**
@ -71,7 +72,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addFontStyle('Font', array('size' => 11));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font'); $section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font');
$section->addTextBreak(); $section->addTextBreak();

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer; namespace PhpOffice\PhpWord\Tests\Writer;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Writer\RTF; use PhpOffice\PhpWord\Writer\RTF;
/** /**
@ -62,7 +63,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
'Font', 'Font',
array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => '00FF00') 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 = $phpWord->addSection();
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph'); $section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
$section->addTextBreak(); $section->addTextBreak();

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Tests\TestHelperDOCX; use PhpOffice\PhpWord\Tests\TestHelperDOCX;
@ -90,7 +91,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
'borderColor' => '#FF0', '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->addListItemRun()->addText(htmlspecialchars('List item run 1', ENT_COMPAT, 'UTF-8'));
$section->addField( $section->addField(
'DATE', 'DATE',
@ -157,7 +158,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$phpWord->addParagraphStyle( $phpWord->addParagraphStyle(
'pStyle', 'pStyle',
array( array(
'align' => 'center', 'alignment' => ST_Jc::CENTER,
'tabs' => $tabs, 'tabs' => $tabs,
'shading' => array('fill' => 'FFFF99'), 'shading' => array('fill' => 'FFFF99'),
'borderSize' => 4, 'borderSize' => 4,
@ -176,11 +177,11 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
); // Style #2 ); // Style #2
$phpWord->addTitleStyle(1, array('color' => '333333', 'doubleStrikethrough' => true)); // Style #3 $phpWord->addTitleStyle(1, array('color' => '333333', 'doubleStrikethrough' => true)); // Style #3
$phpWord->addTableStyle('tStyle', array('borderSize' => 1)); $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 = $phpWord->addSection();
$section->addListItem(htmlspecialchars('List Item', ENT_COMPAT, 'UTF-8'), 0, null, null, 'pStyle'); // Style #5 $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->addTOC($fontStyle);
$section->addTitle(htmlspecialchars('Title 1', ENT_COMPAT, 'UTF-8'), 1); $section->addTitle(htmlspecialchars('Title 1', ENT_COMPAT, 'UTF-8'), 1);
$section->addTOC('fStyle'); $section->addTOC('fStyle');
@ -230,7 +231,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
public function testWriteTextRun() public function testWriteTextRun()
{ {
$pStyle = 'pStyle'; $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'; $imageSrc = __DIR__ . '/../../../_files/images/earth.jpg';
$phpWord = new PhpWord(); $phpWord = new PhpWord();
@ -241,7 +242,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$textrun->addTextBreak(); $textrun->addTextBreak();
$textrun = $section->addTextRun($aStyle); $textrun = $section->addTextRun($aStyle);
$textrun->addLink('https://github.com/PHPOffice/PHPWord'); $textrun->addLink('https://github.com/PHPOffice/PHPWord');
$textrun->addImage($imageSrc, array('align' => 'center')); $textrun->addImage($imageSrc, array('alignment' => ST_Jc::CENTER));
$textrun->addFootnote(); $textrun->addFootnote();
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
@ -258,7 +259,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$fontStyleArray = array('bold' => true); $fontStyleArray = array('bold' => true);
$fontStyleName = 'Font Style'; $fontStyleName = 'Font Style';
$paragraphStyleArray = array('align' => 'center'); $paragraphStyleArray = array('alignment' => ST_Jc::CENTER);
$paragraphStyleName = 'Paragraph Style'; $paragraphStyleName = 'Paragraph Style';
$expected = 'PHPWord on GitHub'; $expected = 'PHPWord on GitHub';
@ -292,7 +293,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$footer = $section->addFooter(); $footer = $section->addFooter();
$fontStyleArray = array('bold' => true); $fontStyleArray = array('bold' => true);
$fontStyleName = 'Font'; $fontStyleName = 'Font';
$paragraphStyleArray = array('align' => 'right'); $paragraphStyleArray = array('alignment' => ST_Jc::END);
$paragraphStyleName = 'Paragraph'; $paragraphStyleName = 'Paragraph';
$footer->addPreserveText(htmlspecialchars('Page {PAGE}', ENT_COMPAT, 'UTF-8')); $footer->addPreserveText(htmlspecialchars('Page {PAGE}', ENT_COMPAT, 'UTF-8'));
@ -337,7 +338,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
public function testWriteImage() public function testWriteImage()
{ {
$phpWord = new PhpWord(); $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'); $wraps = array('inline', 'behind', 'infront', 'square', 'tight');
$section = $phpWord->addSection(); $section = $phpWord->addSection();
foreach ($wraps as $wrap) { foreach ($wraps as $wrap) {
@ -421,7 +422,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$attributes = array( $attributes = array(
'alignment' => 'right', 'alignment' => ST_Jc::END,
'widowControl' => false, 'widowControl' => false,
'keepNext' => true, 'keepNext' => true,
'keepLines' => true, 'keepLines' => true,

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX; use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/** /**
@ -40,14 +41,14 @@ class FootnotesTest extends \PHPUnit_Framework_TestCase
public function testWriteFootnotes() public function testWriteFootnotes()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addParagraphStyle('pStyle', array('align' => 'left')); $phpWord->addParagraphStyle('pStyle', array('alignment' => ST_Jc::START));
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$section->addText(htmlspecialchars('Text', ENT_COMPAT, 'UTF-8')); $section->addText(htmlspecialchars('Text', ENT_COMPAT, 'UTF-8'));
$footnote1 = $section->addFootnote('pStyle'); $footnote1 = $section->addFootnote('pStyle');
$footnote1->addText(htmlspecialchars('Footnote', ENT_COMPAT, 'UTF-8')); $footnote1->addText(htmlspecialchars('Footnote', ENT_COMPAT, 'UTF-8'));
$footnote1->addTextBreak(); $footnote1->addTextBreak();
$footnote1->addLink('https://github.com/PHPOffice/PHPWord'); $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')); $footnote2->addText(htmlspecialchars('Endnote', ENT_COMPAT, 'UTF-8'));
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX; use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/** /**
@ -55,7 +56,7 @@ class NumberingTest extends \PHPUnit_Framework_TestCase
'restart' => 1, 'restart' => 1,
'suffix' => 'space', 'suffix' => 'space',
'text' => '%1.', 'text' => '%1.',
'align' => 'left', 'alignment' => ST_Jc::START,
'left' => 360, 'left' => 360,
'hanging' => 360, 'hanging' => 360,
'tabPos' => 360, 'tabPos' => 360,

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX; use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/** /**
@ -42,20 +43,12 @@ class StylesTest extends \PHPUnit_Framework_TestCase
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$pStyle = array('align' => 'both'); $pStyle = array('alignment' => ST_Jc::BOTH);
$pBase = array('basedOn' => 'Normal'); $pBase = array('basedOn' => 'Normal');
$pNew = array('basedOn' => 'Base Style', 'next' => 'Normal'); $pNew = array('basedOn' => 'Base Style', 'next' => 'Normal');
$rStyle = array('size' => 20); $rStyle = array('size' => 20);
$tStyle = array( $tStyle = array('bgColor' => 'FF0000', 'cellMargin' => 120, 'borderSize' => 120);
'bgColor' => 'FF0000', $firstRowStyle = array('bgColor' => '0000FF', 'borderSize' => 120, 'borderColor' => '00FF00');
'cellMargin' => 120,
'borderSize' => 120,
);
$firstRowStyle = array(
'bgColor' => '0000FF',
'borderSize' => 120,
'borderColor' => '00FF00',
);
$phpWord->setDefaultParagraphStyle($pStyle); $phpWord->setDefaultParagraphStyle($pStyle);
$phpWord->addParagraphStyle('Base Style', $pBase); $phpWord->addParagraphStyle('Base Style', $pBase);
$phpWord->addParagraphStyle('New Style', $pNew); $phpWord->addParagraphStyle('New Style', $pNew);

View File

@ -29,7 +29,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
public function testEmptyStyles() public function testEmptyStyles()
{ {
$styles = array( $styles = array(
'Alignment', 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering', 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering',
'Paragraph', 'Row', 'Section', 'Shading', 'Spacing', 'Tab', 'Table', 'Paragraph', 'Row', 'Section', 'Shading', 'Spacing', 'Tab', 'Table',
'TextBox', 'Line', 'Shape', 'Frame', 'Outline', 'Fill', 'Shadow', 'Extrusion', 'TextBox', 'Line', 'Shape', 'Frame', 'Outline', 'Fill', 'Shadow', 'Extrusion',
); );

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Tests\Writer; namespace PhpOffice\PhpWord\Tests\Writer;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\ST_Jc;
use PhpOffice\PhpWord\Tests\TestHelperDOCX; use PhpOffice\PhpWord\Tests\TestHelperDOCX;
use PhpOffice\PhpWord\Writer\Word2007; 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'; $remoteImage = 'http://php.net//images/logos/php-med-trans-light.gif';
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addFontStyle('Font', array('size' => 11));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph'); $section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
$section->addTextBreak(); $section->addTextBreak();

View File

@ -41,7 +41,9 @@ class TestHelperDOCX
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @param string $writerName * @param string $writerName
*
* @return \PhpOffice\PhpWord\Tests\XmlDocument * @return \PhpOffice\PhpWord\Tests\XmlDocument
*
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
*/ */
public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007') public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007')