Next round of refactoring of alignment-related functionality.
This commit is contained in:
parent
3a58c818bd
commit
94c0d02330
38
CHANGELOG.md
38
CHANGELOG.md
|
|
@ -1,24 +1,28 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub.
|
||||
Change Log
|
||||
==========
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
0.13.0 (unreleased)
|
||||
------------
|
||||
|
||||
-------------------
|
||||
Place announcement text here.
|
||||
|
||||
### Changes
|
||||
- Introduced ``\PhpOffice\PhpWord\SimpleType\ST_JcTable`` simple type. - @RomanSyroeshko
|
||||
- Introduced ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` simple type. - @RomanSyroeshko
|
||||
### Added
|
||||
- Introduced the ``\PhpOffice\PhpWord\SimpleType\ST_JcTable`` simple type. - @RomanSyroeshko
|
||||
- Introduced the ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` simple type. - @RomanSyroeshko
|
||||
|
||||
### Changed
|
||||
- Improved error message for the case when ``autoload.php`` is not found. - @RomanSyroeshko #371
|
||||
- Renamed ``align`` option of ``NumberingLevel``, ``Frame``, ``Table``, and ``Paragraph`` styles into ``alignment``. Accessor and mutator methods renamed too. - @RomanSyroeshko
|
||||
- Renamed the ``align`` option of ``NumberingLevel``, ``Frame``, ``Table``, and ``Paragraph`` styles into ``alignment``. - @RomanSyroeshko
|
||||
|
||||
### Deprecated
|
||||
- ``getAlign`` and ``setAlign`` methods of ``NumberingLevel``, ``Frame``, ``Table``, and ``Paragraph`` styles.
|
||||
Use the correspondent ``getAlignment`` and ``setAlignment`` methods instead.
|
||||
|
||||
|
||||
|
||||
0.12.1 (30 August 2015)
|
||||
-------------------
|
||||
|
||||
-----------------------
|
||||
Maintenance release. This release is focused primarily on ``TemplateProcessor``.
|
||||
|
||||
### Changes
|
||||
|
|
@ -33,7 +37,6 @@ Maintenance release. This release is focused primarily on ``TemplateProcessor``.
|
|||
|
||||
0.12.0 (3 January 2015)
|
||||
-----------------------
|
||||
|
||||
This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. Basic MsDoc reader is introduced.
|
||||
|
||||
### Features
|
||||
|
|
@ -93,7 +96,6 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap
|
|||
|
||||
0.11.1 (2 June 2014)
|
||||
--------------------
|
||||
|
||||
This is an immediate bugfix release for HTML reader.
|
||||
|
||||
- HTML Reader: `<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)
|
||||
--------------------
|
||||
|
||||
This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four new elements were added: TextBox, ListItemRun, Field, and Line. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemented. RTF and HTML reader were initiated.
|
||||
|
||||
### Features
|
||||
|
|
@ -167,7 +168,6 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four
|
|||
|
||||
0.10.1 (21 May 2014)
|
||||
--------------------
|
||||
|
||||
This is a bugfix release for `php-zip` requirement in Composer.
|
||||
|
||||
- Change Composer requirements for php-zip from `require` to `suggest` - @bskrtich #246
|
||||
|
|
@ -176,7 +176,6 @@ This is a bugfix release for `php-zip` requirement in Composer.
|
|||
|
||||
0.10.0 (4 May 2014)
|
||||
-------------------
|
||||
|
||||
This release marked heavy refactorings on internal code structure with the creation of some abstract classes to reduce code duplication. `Element` subnamespace is introduced in this release to replace `Section`. Word2007 reader capability is greatly enhanced. Endnote is introduced. List numbering is now customizable. Basic HTML and PDF writing support is enabled. Basic ODText reader is introduced.
|
||||
|
||||
### Features
|
||||
|
|
@ -261,7 +260,6 @@ This release marked heavy refactorings on internal code structure with the creat
|
|||
|
||||
0.9.1 (27 Mar 2014)
|
||||
-------------------
|
||||
|
||||
This is a bugfix release for PSR-4 compatibility.
|
||||
|
||||
- Fixed PSR-4 composer autoloader - @AntonTyutin
|
||||
|
|
@ -270,7 +268,6 @@ This is a bugfix release for PSR-4 compatibility.
|
|||
|
||||
0.9.0 (26 Mar 2014)
|
||||
-------------------
|
||||
|
||||
This release marked the transformation to namespaces (PHP 5.3+).
|
||||
|
||||
### Features
|
||||
|
|
@ -293,7 +290,6 @@ This release marked the transformation to namespaces (PHP 5.3+).
|
|||
|
||||
0.8.1 (17 Mar 2014)
|
||||
-------------------
|
||||
|
||||
This is a bugfix release for image detection functionality.
|
||||
|
||||
- Added fallback for computers that do not have exif_imagetype - @bskrtich, @gabrielbull
|
||||
|
|
@ -302,7 +298,6 @@ This is a bugfix release for image detection functionality.
|
|||
|
||||
0.8.0 (15 Mar 2014)
|
||||
-------------------
|
||||
|
||||
This release merged a lot of improvements from the community. Unit tests introduced in this release and has reached 90% code coverage.
|
||||
|
||||
### Features
|
||||
|
|
@ -351,7 +346,6 @@ This release merged a lot of improvements from the community. Unit tests introdu
|
|||
|
||||
0.7.0 (28 Jan 2014)
|
||||
-------------------
|
||||
|
||||
This is the first release after a long development hiatus in [CodePlex](https://phpword.codeplex.com/). This release initialized ODT and RTF Writer, along with some other new features for the existing Word2007 Writer, e.g. tab, multiple header, rowspan and colspan. [Composer](https://packagist.org/packages/phpoffice/phpword) and [Travis](https://travis-ci.org/PHPOffice/PHPWord) were added.
|
||||
|
||||
### Features
|
||||
|
|
|
|||
|
|
@ -77,17 +77,17 @@ qthelp:
|
|||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PhpWord.qhcp"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PHPWord.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PhpWord.qhc"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PHPWord.qhc"
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/PhpWord"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PhpWord"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/PHPWord"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PHPWord"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
|
|
|
|||
26
docs/conf.py
26
docs/conf.py
|
|
@ -40,15 +40,15 @@ source_suffix = '.rst'
|
|||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'PhpWord'
|
||||
copyright = u'2014, PHPWord Contributors'
|
||||
project = u'PHPWord'
|
||||
copyright = u'2014-2015, PHPWord Contributors'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.12.0'
|
||||
version = '0.13.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ html_static_path = ['_static']
|
|||
#html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'PhpWorddoc'
|
||||
htmlhelp_basename = 'PHPWorddoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
|
@ -183,8 +183,8 @@ latex_elements = {
|
|||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'PhpWord.tex', u'PhpWord Documentation',
|
||||
u'The PhpWord Team', 'manual'),
|
||||
('index', 'PHPWord.tex', u'PHPWord Documentation',
|
||||
u'The PHPWord Team', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
|
@ -213,8 +213,8 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'PhpWord', u'PhpWord Documentation',
|
||||
[u'The PhpWord Team'], 1)
|
||||
('index', 'PHPWord', u'PHPWord Documentation',
|
||||
[u'The PHPWord Team'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
|
@ -227,8 +227,8 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'PhpWord', u'PhpWord Documentation',
|
||||
u'The PhpWord Team', 'PhpWord', 'One line description of project.',
|
||||
('index', 'PHPWord', u'PHPWord Documentation',
|
||||
u'The PHPWord Team', 'PHPWord', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
|
@ -244,9 +244,9 @@ texinfo_documents = [
|
|||
# -- Options for Epub output ---------------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = u'PhpWord'
|
||||
epub_author = u'The PhpWord Team'
|
||||
epub_publisher = u'The PhpWord Team'
|
||||
epub_title = u'PHPWord'
|
||||
epub_author = u'The PHPWord Team'
|
||||
epub_publisher = u'The PHPWord Team'
|
||||
epub_copyright = copyright
|
||||
|
||||
# The language of the text. It defaults to the language option
|
||||
|
|
|
|||
|
|
@ -50,115 +50,48 @@ column shows the containers while the rows lists the elements.
|
|||
|
||||
Legend:
|
||||
|
||||
- ``v`` Available
|
||||
- ``v*`` Available only when inside header/footer
|
||||
- ``v**`` Available only when inside section
|
||||
- ``-`` Not available
|
||||
- ``?`` Should be available
|
||||
- ``v``. Available.
|
||||
- ``v*``. Available only when inside header/footer.
|
||||
- ``v**``. Available only when inside section.
|
||||
- ``-``. Not available.
|
||||
- ``?``. Should be available.
|
||||
|
||||
Texts
|
||||
-----
|
||||
|
||||
Text can be added by using ``addText`` and ``addTextRun`` method.
|
||||
``addText`` is used for creating simple paragraphs that only contain
|
||||
texts with the same style. ``addTextRun`` is used for creating complex
|
||||
paragraphs that contain text with different style (some bold, other
|
||||
italics, etc) or other elements, e.g. images or links. The syntaxes are
|
||||
as follow:
|
||||
``addText`` is used for creating simple paragraphs that only contain texts with the same style.
|
||||
``addTextRun`` is used for creating complex paragraphs that contain text with different style (some bold, other
|
||||
italics, etc) or other elements, e.g. images or links. The syntaxes are as follow:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$section->addText($text, [$fontStyle], [$paragraphStyle]);
|
||||
$textrun = $section->addTextRun([$paragraphStyle]);
|
||||
|
||||
Text styles
|
||||
~~~~~~~~~~~
|
||||
- ``$text``. Text to be displayed in the document.
|
||||
- ``$fontStyle``. See :ref:`font-style`.
|
||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||
|
||||
You can use the ``$fontStyle`` and ``$paragraphStyle`` variable to
|
||||
define text formatting. There are 2 options to style the inserted text
|
||||
elements, i.e. inline style by using array or defined style by adding
|
||||
style definition.
|
||||
|
||||
Inline style examples:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$fontStyle = array('name' => 'Times New Roman', 'size' => 9);
|
||||
$paragraphStyle = array('alignment' => 'both');
|
||||
$section->addText('I am simple paragraph', $fontStyle, $paragraphStyle);
|
||||
|
||||
$textrun = $section->addTextRun();
|
||||
$textrun->addText('I am bold', array('bold' => true));
|
||||
$textrun->addText('I am italic', array('italic' => true));
|
||||
$textrun->addText('I am colored', array('color' => 'AACC00'));
|
||||
|
||||
Defined style examples:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$fontStyle = array('color' => '006699', 'size' => 18, 'bold' => true);
|
||||
$phpWord->addFontStyle('fStyle', $fontStyle);
|
||||
$text = $section->addText('Hello world!', 'fStyle');
|
||||
|
||||
$paragraphStyle = array('alignment' => 'center');
|
||||
$phpWord->addParagraphStyle('pStyle', $paragraphStyle);
|
||||
$text = $section->addText('Hello world!', 'pStyle');
|
||||
|
||||
Font style
|
||||
^^^^^^^^^^
|
||||
|
||||
Available font styles:
|
||||
|
||||
- ``name`` Font name, e.g. *Arial*
|
||||
- ``size`` Font size, e.g. *20*, *22*,
|
||||
- ``hint`` Font content type, *default*, *eastAsia*, or *cs*
|
||||
- ``bold`` Bold, *true* or *false*
|
||||
- ``italic`` Italic, *true* or *false*
|
||||
- ``superScript`` Superscript, *true* or *false*
|
||||
- ``subScript`` Subscript, *true* or *false*
|
||||
- ``underline`` Underline, *dash*, *dotted*, etc.
|
||||
- ``strikethrough`` Strikethrough, *true* or *false*
|
||||
- ``doubleStrikethrough`` Double strikethrough, *true* or *false*
|
||||
- ``color`` Font color, e.g. *FF0000*
|
||||
- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue*
|
||||
- ``bgColor`` Font background color, e.g. *FF0000*
|
||||
- ``smallCaps`` Small caps, *true* or *false*
|
||||
- ``allCaps`` All caps, *true* or *false*
|
||||
|
||||
Paragraph style
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Available paragraph styles:
|
||||
|
||||
- ``alignment`` Paragraph alignment, *left*, *right* or *center*
|
||||
- ``spaceBefore`` Space before paragraph
|
||||
- ``spaceAfter`` Space after paragraph
|
||||
- ``indent`` Indent by how much
|
||||
- ``hanging`` Hanging by how much
|
||||
- ``basedOn`` Parent style
|
||||
- ``next`` Style for next paragraph
|
||||
- ``widowControl`` Allow first/last line to display on a separate page,
|
||||
*true* or *false*
|
||||
- ``keepNext`` Keep paragraph with next paragraph, *true* or *false*
|
||||
- ``keepLines`` Keep all lines on one page, *true* or *false*
|
||||
- ``pageBreakBefore`` Start paragraph on next page, *true* or *false*
|
||||
- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect...
|
||||
- ``tabs`` Set of custom tab stops
|
||||
For available styling options see :ref:`font-style` and :ref:`paragraph-style`.
|
||||
|
||||
Titles
|
||||
~~~~~~
|
||||
|
||||
If you want to structure your document or build table of contents, you
|
||||
need titles or headings. To add a title to the document, use the
|
||||
``addTitleStyle`` and ``addTitle`` method.
|
||||
If you want to structure your document or build table of contents, you need titles or headings.
|
||||
To add a title to the document, use the ``addTitleStyle`` and ``addTitle`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$phpWord->addTitleStyle($depth, [$fontStyle], [$paragraphStyle]);
|
||||
$section->addTitle($text, [$depth]);
|
||||
|
||||
Its necessary to add a title style to your document because otherwise
|
||||
the title won't be detected as a real title.
|
||||
- ``depth``.
|
||||
- ``$fontStyle``. See :ref:`font-style`.
|
||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||
- ``$text``. Text to be displayed in the document.
|
||||
|
||||
It's necessary to add a title style to your document because otherwise the title won't be detected as a real title.
|
||||
|
||||
Links
|
||||
~~~~~
|
||||
|
|
@ -169,16 +102,15 @@ You can add Hyperlinks to the document by using the function addLink:
|
|||
|
||||
$section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle]);
|
||||
|
||||
- ``$linkSrc`` The URL of the link.
|
||||
- ``$linkName`` Placeholder of the URL that appears in the document.
|
||||
- ``$fontStyle`` See "Font style" section.
|
||||
- ``$paragraphStyle`` See "Paragraph style" section.
|
||||
- ``$linkSrc``. The URL of the link.
|
||||
- ``$linkName``. Placeholder of the URL that appears in the document.
|
||||
- ``$fontStyle``. See :ref:`font-style`.
|
||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||
|
||||
Preserve texts
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
The ``addPreserveText`` method is used to add a page number or page
|
||||
count to headers or footers.
|
||||
The ``addPreserveText`` method is used to add a page number or page count to headers or footers.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
|
@ -190,16 +122,15 @@ Breaks
|
|||
Text breaks
|
||||
~~~~~~~~~~~
|
||||
|
||||
Text breaks are empty new lines. To add text breaks, use the following
|
||||
syntax. All paramaters are optional.
|
||||
Text breaks are empty new lines. To add text breaks, use the following syntax. All parameters are optional.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$section->addTextBreak([$breakCount], [$fontStyle], [$paragraphStyle]);
|
||||
|
||||
- ``$breakCount`` How many lines
|
||||
- ``$fontStyle`` See "Font style" section.
|
||||
- ``$paragraphStyle`` See "Paragraph style" section.
|
||||
- ``$breakCount``. How many lines.
|
||||
- ``$fontStyle``. See :ref:`font-style`.
|
||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||
|
||||
Page breaks
|
||||
~~~~~~~~~~~
|
||||
|
|
@ -224,24 +155,24 @@ Basic usage:
|
|||
|
||||
Parameters:
|
||||
|
||||
- ``$text`` Text that appears in the document.
|
||||
- ``$depth`` Depth of list item.
|
||||
- ``$fontStyle`` See "Font style" section.
|
||||
- ``$listStyle`` List style of the current element TYPE\_NUMBER,
|
||||
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in
|
||||
PHPWord\_Style\_ListItem.
|
||||
- ``$paragraphStyle`` See "Paragraph style" section.
|
||||
- ``$text``. Text that appears in the document.
|
||||
- ``$depth``. Depth of list item.
|
||||
- ``$fontStyle``. See :ref:`font-style`.
|
||||
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
|
||||
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\_Style\_ListItem.
|
||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||
|
||||
Advanced usage:
|
||||
|
||||
You can also create your own numbering style by changing the
|
||||
``$listStyle`` parameter with the name of your numbering style.
|
||||
You can also create your own numbering style by changing the ``$listStyle`` parameter with the name of your numbering style.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$phpWord->addNumberingStyle(
|
||||
'multilevel',
|
||||
array('type' => 'multilevel', 'levels' => array(
|
||||
array(
|
||||
'type' => 'multilevel',
|
||||
'levels' => array(
|
||||
array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360),
|
||||
array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
|
||||
)
|
||||
|
|
@ -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 II', 0, null, 'multilevel');
|
||||
|
||||
Level styles:
|
||||
|
||||
- ``start`` Starting value
|
||||
- ``format`` Numbering format
|
||||
bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter
|
||||
- ``restart`` Restart numbering level symbol
|
||||
- ``suffix`` Content between numbering symbol and paragraph text
|
||||
tab\|space\|nothing
|
||||
- ``text`` Numbering level text e.g. %1 for nonbullet or bullet
|
||||
character
|
||||
- ``align`` Numbering symbol align left\|center\|right\|both
|
||||
- ``left`` See paragraph style
|
||||
- ``hanging`` See paragraph style
|
||||
- ``tabPos`` See paragraph style
|
||||
- ``font`` Font name
|
||||
- ``hint`` See font style
|
||||
For available styling options see :ref:`numbering-level-style`.
|
||||
|
||||
Tables
|
||||
------
|
||||
|
||||
To add tables, rows, and cells, use the ``addTable``, ``addRow``, and
|
||||
``addCell`` methods:
|
||||
To add tables, rows, and cells, use the ``addTable``, ``addRow``, and ``addCell`` methods:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
|
@ -294,39 +209,12 @@ Table style can be defined with ``addTableStyle``:
|
|||
$phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle);
|
||||
$table = $section->addTable('myTable');
|
||||
|
||||
Table, row, and cell styles
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Table styles:
|
||||
|
||||
- ``width`` Table width in percent
|
||||
- ``bgColor`` Background color, e.g. '9966CC'
|
||||
- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
|
||||
- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
|
||||
- ``cellMargin(Top|Right|Bottom|Left)`` Cell margin in twips
|
||||
|
||||
Row styles:
|
||||
|
||||
- ``tblHeader`` Repeat table row on every new page, *true* or *false*
|
||||
- ``cantSplit`` Table row cannot break across pages, *true* or *false*
|
||||
- ``exactHeight`` Row height is exact or at least
|
||||
|
||||
Cell styles:
|
||||
|
||||
- ``width`` Cell width in twips
|
||||
- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom*
|
||||
- ``textDirection`` Direction of text
|
||||
- ``bgColor`` Background color, e.g. '9966CC'
|
||||
- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
|
||||
- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
|
||||
- ``gridSpan`` Number of columns spanned
|
||||
- ``vMerge`` *restart* or *continue*
|
||||
For available styling options see :ref:`table-style`.
|
||||
|
||||
Cell span
|
||||
~~~~~~~~~
|
||||
|
||||
You can span a cell on multiple columns by using ``gridSpan`` or
|
||||
multiple rows by using ``vMerge``.
|
||||
You can span a cell on multiple columns by using ``gridSpan`` or multiple rows by using ``vMerge``.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
|
@ -338,15 +226,14 @@ See ``Sample_09_Tables.php`` for more code sample.
|
|||
Images
|
||||
------
|
||||
|
||||
To add an image, use the ``addImage`` method to sections, headers,
|
||||
footers, textruns, or table cells.
|
||||
To add an image, use the ``addImage`` method to sections, headers, footers, textruns, or table cells.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$section->addImage($src, [$style]);
|
||||
|
||||
- source String path to a local image or URL of a remote image
|
||||
- styles Array fo styles for the image. See below.
|
||||
- ``$src``. String path to a local image or URL of a remote image.
|
||||
- ``$style``. See :ref:`image-style`.
|
||||
|
||||
Examples:
|
||||
|
||||
|
|
@ -368,19 +255,6 @@ Examples:
|
|||
$textrun = $section->addTextRun();
|
||||
$textrun->addImage('http://php.net/logo.jpg');
|
||||
|
||||
Image styles
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Available image styles:
|
||||
|
||||
- ``width`` Width in pixels
|
||||
- ``height`` Height in pixels
|
||||
- ``align`` Image alignment, *left*, *right*, or *center*
|
||||
- ``marginTop`` Top margin in inches, can be negative
|
||||
- ``marginLeft`` Left margin in inches, can be negative
|
||||
- ``wrappingStyle`` Wrapping style, *inline*, *square*, *tight*,
|
||||
*behind*, or *infront*
|
||||
|
||||
Watermarks
|
||||
~~~~~~~~~~
|
||||
|
||||
|
|
@ -408,25 +282,22 @@ Table of contents
|
|||
-----------------
|
||||
|
||||
To add a table of contents (TOC), you can use the ``addTOC`` method.
|
||||
Your TOC can only be generated if you have add at least one title (See
|
||||
"Titles").
|
||||
Your TOC can only be generated if you have add at least one title (See "Titles").
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$section->addTOC([$fontStyle], [$tocStyle], [$minDepth], [$maxDepth]);
|
||||
|
||||
- ``$fontStyle``: See font style section
|
||||
- ``$tocStyle``: See available options below
|
||||
- ``$minDepth``: Minimum depth of header to be shown. Default 1
|
||||
- ``$maxDepth``: Maximum depth of header to be shown. Default 9
|
||||
- ``$fontStyle``. See font style section.
|
||||
- ``$tocStyle``. See available options below.
|
||||
- ``$minDepth``. Minimum depth of header to be shown. Default 1.
|
||||
- ``$maxDepth``. Maximum depth of header to be shown. Default 9.
|
||||
|
||||
Options for ``$tocStyle``:
|
||||
|
||||
- ``tabLeader`` Fill type between the title text and the page number.
|
||||
Use the defined constants in PHPWord\_Style\_TOC.
|
||||
- ``tabPos`` The position of the tab where the page number appears in
|
||||
twips.
|
||||
- ``indent`` The indent factor of the titles in twips.
|
||||
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\_Style\_TOC.
|
||||
- ``tabPos``. The position of the tab where the page number appears in twips.
|
||||
- ``indent``. The indent factor of the titles in twips.
|
||||
|
||||
Footnotes & endnotes
|
||||
--------------------
|
||||
|
|
@ -468,17 +339,16 @@ redefine by ``addFontStyle`` method. Default value for this style is
|
|||
Checkboxes
|
||||
----------
|
||||
|
||||
Checkbox elements can be added to sections or table cells by using
|
||||
``addCheckBox``.
|
||||
Checkbox elements can be added to sections or table cells by using ``addCheckBox``.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$section->addCheckBox($name, $text, [$fontStyle], [$paragraphStyle])
|
||||
|
||||
- ``$name`` Name of the check box.
|
||||
- ``$text`` Text following the check box
|
||||
- ``$fontStyle`` See "Font style" section.
|
||||
- ``$paragraphStyle`` See "Paragraph style" section.
|
||||
- ``$name``. Name of the check box.
|
||||
- ``$text``. Text to be displayed in the document.
|
||||
- ``$fontStyle``. See :ref:`font-style`.
|
||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||
|
||||
Textboxes
|
||||
---------
|
||||
|
|
@ -502,11 +372,11 @@ Line elements can be added to sections by using ``addLine``.
|
|||
|
||||
Available line style attributes:
|
||||
|
||||
- ``weight`` Line width in twips
|
||||
- ``color`` Defines the color of stroke
|
||||
- ``dash`` Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot
|
||||
- ``beginArrow`` Start type of arrow: block, open, classic, diamond, oval
|
||||
- ``endArrow`` End type of arrow: block, open, classic, diamond, ovel
|
||||
- ``width`` Line-object width in pt
|
||||
- ``height`` Line-object height in pt
|
||||
- ``flip`` Flip the line element: true, false
|
||||
- ``weight``. Line width in twips.
|
||||
- ``color``. Defines the color of stroke.
|
||||
- ``dash``. Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot.
|
||||
- ``beginArrow``. Start type of arrow: block, open, classic, diamond, oval.
|
||||
- ``endArrow``. End type of arrow: block, open, classic, diamond, oval.
|
||||
- ``width``. Line-object width in pt.
|
||||
- ``height``. Line-object height in pt.
|
||||
- ``flip``. Flip the line element: true, false.
|
||||
|
|
@ -4,11 +4,9 @@ Frequently asked questions
|
|||
==========================
|
||||
|
||||
How contribute to PHPWord?
|
||||
---------------------------
|
||||
|
||||
--------------------------
|
||||
- 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?
|
||||
-------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -184,4 +184,3 @@ points to twips.
|
|||
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
|
||||
// 2 cm right margin
|
||||
$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,7 @@ Mandatory:
|
|||
|
||||
- PHP 5.3+
|
||||
- PHP `Zip <http://php.net/manual/en/book.zip.php>`__ extension
|
||||
- PHP `XML
|
||||
Parser <http://www.php.net/manual/en/xml.installation.php>`__
|
||||
extension
|
||||
- PHP `XML Parser <http://www.php.net/manual/en/xml.installation.php>`__ extension
|
||||
|
||||
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.
|
||||
Notice: All contributions must be done against the developer branch.
|
||||
Notice: all contributions must be done against the developer branch.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
|
@ -56,8 +54,7 @@ Notice: All contributions must be done against the developer branch.
|
|||
Manual install
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
To install manually, you change to the webserver directory of your file system .
|
||||
Then you have 2 possibilities.
|
||||
To install manually, you change to the web-server directory of your file system. Then you have 2 possibilities.
|
||||
|
||||
1. `download PHPWord package from github <https://github.com/PHPOffice/PHPWord/archive/master.zip>`__.
|
||||
Extract the package and put the contents to your machine.
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ Recipes
|
|||
Create float left image
|
||||
-----------------------
|
||||
|
||||
Use absolute positioning relative to margin horizontally and to line
|
||||
vertically.
|
||||
Use absolute positioning relative to margin horizontally and to line vertically.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,8 @@ ISO/IEC 29500, Third edition, 2012-09-01
|
|||
Formal specifications
|
||||
---------------------
|
||||
|
||||
- `Oasis OpenDocument Standard Version
|
||||
1.2 <http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html>`__
|
||||
- `Rich Text Format (RTF) Specification, version
|
||||
1.9.1 <http://www.microsoft.com/en-us/download/details.aspx?id=10725>`__
|
||||
- `Oasis OpenDocument Standard Version 1.2 <http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html>`__
|
||||
- `Rich Text Format (RTF) Specification, version 1.9.1 <http://www.microsoft.com/en-us/download/details.aspx?id=10725>`__
|
||||
|
||||
Other resources
|
||||
---------------
|
||||
|
|
|
|||
202
docs/styles.rst
202
docs/styles.rst
|
|
@ -3,132 +3,140 @@
|
|||
Styles
|
||||
======
|
||||
|
||||
.. _section-style:
|
||||
|
||||
Section
|
||||
-------
|
||||
|
||||
Below are the available styles for section:
|
||||
Available Section style options:
|
||||
|
||||
- ``pageSizeW`` Page width in twips (the default is 11906/A4 size)
|
||||
- ``pageSizeH`` Page height in twips (the default is 16838/A4 size)
|
||||
- ``orientation`` Page orientation, i.e. 'portrait' (default) or
|
||||
'landscape'
|
||||
- ``marginTop`` Page margin top in twips
|
||||
- ``marginLeft`` Page margin left in twips
|
||||
- ``marginRight`` Page margin right in twips
|
||||
- ``marginBottom`` Page margin bottom in twips
|
||||
- ``borderTopSize`` Border top size in twips
|
||||
- ``borderTopColor`` Border top color
|
||||
- ``borderLeftSize`` Border left size in twips
|
||||
- ``borderLeftColor`` Border left color
|
||||
- ``borderRightSize`` Border right size in twips
|
||||
- ``borderRightColor`` Border right color
|
||||
- ``borderBottomSize`` Border bottom size in twips
|
||||
- ``borderBottomColor`` Border bottom color
|
||||
- ``headerHeight`` Spacing to top of header
|
||||
- ``footerHeight`` Spacing to bottom of footer
|
||||
- ``gutter`` Page gutter spacing
|
||||
- ``colsNum`` Number of columns
|
||||
- ``colsSpace`` Spacing between columns
|
||||
- ``breakType`` Section break type (nextPage, nextColumn, continuous,
|
||||
evenPage, oddPage)
|
||||
- ``borderBottomColor``. Border bottom color.
|
||||
- ``borderBottomSize``. Border bottom size (in twips).
|
||||
- ``borderLeftColor``. Border left color.
|
||||
- ``borderLeftSize``. Border left size (in twips).
|
||||
- ``borderRightColor``. Border right color.
|
||||
- ``borderRightSize``. Border right size (in twips).
|
||||
- ``borderTopColor``. Border top color.
|
||||
- ``borderTopSize``. Border top size (in twips).
|
||||
- ``breakType``. Section break type (nextPage, nextColumn, continuous, evenPage, oddPage).
|
||||
- ``colsNum``. Number of columns.
|
||||
- ``colsSpace``. Spacing between columns.
|
||||
- ``footerHeight``. Spacing to bottom of footer.
|
||||
- ``gutter``. Page gutter spacing.
|
||||
- ``headerHeight``. Spacing to top of header.
|
||||
- ``marginTop``. Page margin top (in twips).
|
||||
- ``marginLeft``. Page margin left (in twips).
|
||||
- ``marginRight``. Page margin right (in twips).
|
||||
- ``marginBottom``. Page margin bottom (in twips).
|
||||
- ``orientation``. Page orientation (``portrait``, which is default, or ``landscape``).
|
||||
- ``pageSizeH``. Page height (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
||||
- ``pageSizeW``. Page width (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
||||
|
||||
.. _font-style:
|
||||
|
||||
Font
|
||||
----
|
||||
|
||||
Available font styles:
|
||||
Available Font style options:
|
||||
|
||||
- ``name`` Font name, e.g. *Arial*
|
||||
- ``size`` Font size, e.g. *20*, *22*,
|
||||
- ``hint`` Font content type, *default*, *eastAsia*, or *cs*
|
||||
- ``bold`` Bold, *true* or *false*
|
||||
- ``italic`` Italic, *true* or *false*
|
||||
- ``superScript`` Superscript, *true* or *false*
|
||||
- ``subScript`` Subscript, *true* or *false*
|
||||
- ``underline`` Underline, *dash*, *dotted*, etc.
|
||||
- ``strikethrough`` Strikethrough, *true* or *false*
|
||||
- ``doubleStrikethrough`` Double strikethrough, *true* or *false*
|
||||
- ``color`` Font color, e.g. *FF0000*
|
||||
- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue*
|
||||
- ``bgColor`` Font background color, e.g. *FF0000*
|
||||
- ``smallCaps`` Small caps, *true* or *false*
|
||||
- ``allCaps`` All caps, *true* or *false*
|
||||
- ``rtl`` Right to Left language, *true* or *false*
|
||||
- ``allCaps``. All caps, *true* or *false*.
|
||||
- ``bgColor``. Font background color, e.g. *FF0000*.
|
||||
- ``bold``. Bold, *true* or *false*.
|
||||
- ``color``. Font color, e.g. *FF0000*.
|
||||
- ``doubleStrikethrough``. Double strikethrough, *true* or *false*.
|
||||
- ``fgColor``. Font highlight color, e.g. *yellow*, *green*, *blue*.
|
||||
- ``hint``. Font content type, *default*, *eastAsia*, or *cs*.
|
||||
- ``italic``. Italic, *true* or *false*.
|
||||
- ``name``. Font name, e.g. *Arial*.
|
||||
- ``rtl``. Right to Left language, *true* or *false*.
|
||||
- ``size``. Font size, e.g. *20*, *22*.
|
||||
- ``smallCaps``. Small caps, *true* or *false*.
|
||||
- ``strikethrough``. Strikethrough, *true* or *false*.
|
||||
- ``subScript``. Subscript, *true* or *false*.
|
||||
- ``superScript``. Superscript, *true* or *false*.
|
||||
- ``underline``. Underline, *dash*, *dotted*, etc.
|
||||
|
||||
.. _paragraph-style:
|
||||
|
||||
Paragraph
|
||||
---------
|
||||
|
||||
Available paragraph styles:
|
||||
Available Paragraph style options:
|
||||
|
||||
- ``alignment`` Paragraph alignment, *left*, *right* or *center*
|
||||
- ``spaceBefore`` Space before paragraph
|
||||
- ``spaceAfter`` Space after paragraph
|
||||
- ``indent`` Indent by how much
|
||||
- ``hanging`` Hanging by how much
|
||||
- ``basedOn`` Parent style
|
||||
- ``next`` Style for next paragraph
|
||||
- ``widowControl`` Allow first/last line to display on a separate page,
|
||||
*true* or *false*
|
||||
- ``keepNext`` Keep paragraph with next paragraph, *true* or *false*
|
||||
- ``keepLines`` Keep all lines on one page, *true* or *false*
|
||||
- ``pageBreakBefore`` Start paragraph on next page, *true* or *false*
|
||||
- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect...
|
||||
- ``tabs`` Set of custom tab stops
|
||||
- ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` class for the details.
|
||||
- ``basedOn``. Parent style.
|
||||
- ``hanging``. Hanging by how much.
|
||||
- ``indent``. Indent by how much.
|
||||
- ``keepLines``. Keep all lines on one page, *true* or *false*.
|
||||
- ``keepNext``. Keep paragraph with next paragraph, *true* or *false*.
|
||||
- ``lineHeight``. Text line height, e.g. *1.0*, *1.5*, etc.
|
||||
- ``next``. Style for next paragraph.
|
||||
- ``pageBreakBefore``. Start paragraph on next page, *true* or *false*.
|
||||
- ``spaceBefore``. Space before paragraph.
|
||||
- ``spaceAfter``. Space after paragraph.
|
||||
- ``tabs``. Set of custom tab stops.
|
||||
- ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*.
|
||||
|
||||
.. _table-style:
|
||||
|
||||
Table
|
||||
-----
|
||||
|
||||
Table styles:
|
||||
Available Table style options:
|
||||
|
||||
- ``width`` Table width in percent
|
||||
- ``bgColor`` Background color, e.g. '9966CC'
|
||||
- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
|
||||
- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
|
||||
- ``cellMargin(Top|Right|Bottom|Left)`` Cell margin in twips
|
||||
- ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\ST_JcTable`` class for the details.
|
||||
- ``bgColor``. Background color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||
- ``cellMargin(Top|Right|Bottom|Left)``. Cell margin in twips.
|
||||
- ``width``. Table width in percent.
|
||||
|
||||
Row styles:
|
||||
Available Row style options:
|
||||
|
||||
- ``tblHeader`` Repeat table row on every new page, *true* or *false*
|
||||
- ``cantSplit`` Table row cannot break across pages, *true* or *false*
|
||||
- ``exactHeight`` Row height is exact or at least
|
||||
- ``cantSplit``. Table row cannot break across pages, *true* or *false*.
|
||||
- ``exactHeight``. Row height is exact or at least.
|
||||
- ``tblHeader``. Repeat table row on every new page, *true* or *false*.
|
||||
|
||||
Cell styles:
|
||||
Available Cell style options:
|
||||
|
||||
- ``width`` Cell width in twips
|
||||
- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom*
|
||||
- ``textDirection`` Direction of text
|
||||
- ``bgColor`` Background color, e.g. '9966CC'
|
||||
- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
|
||||
- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
|
||||
- ``gridSpan`` Number of columns spanned
|
||||
- ``vMerge`` *restart* or *continue*
|
||||
- ``bgColor``. Background color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||
- ``gridSpan``. Number of columns spanned.
|
||||
- ``textDirection``. Direction of text.
|
||||
- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
|
||||
- ``vMerge``. *restart* or *continue*.
|
||||
- ``width``. Cell width in twips.
|
||||
|
||||
.. _image-style:
|
||||
|
||||
Image
|
||||
-----
|
||||
|
||||
Available image styles:
|
||||
Available Image style options:
|
||||
|
||||
- ``width`` Width in pixels
|
||||
- ``height`` Height in pixels
|
||||
- ``align`` Image alignment, *left*, *right*, or *center*
|
||||
- ``marginTop`` Top margin in inches, can be negative
|
||||
- ``marginLeft`` Left margin in inches, can be negative
|
||||
- ``wrappingStyle`` Wrapping style, *inline*, *square*, *tight*,
|
||||
*behind*, or *infront*
|
||||
- ``alignment``. See ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` class for the details.
|
||||
- ``height``. Height in pixels.
|
||||
- ``marginLeft``. Left margin in inches, can be negative.
|
||||
- ``marginTop``. Top margin in inches, can be negative.
|
||||
- ``width``. Width in pixels.
|
||||
- ``wrappingStyle``. Wrapping style, *inline*, *square*, *tight*, *behind*, or *infront*.
|
||||
|
||||
.. _numbering-level-style:
|
||||
|
||||
Numbering level
|
||||
---------------
|
||||
|
||||
- ``start`` Starting value
|
||||
- ``format`` Numbering format
|
||||
bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter
|
||||
- ``restart`` Restart numbering level symbol
|
||||
- ``suffix`` Content between numbering symbol and paragraph text
|
||||
tab\|space\|nothing
|
||||
- ``text`` Numbering level text e.g. %1 for nonbullet or bullet
|
||||
character
|
||||
- ``align`` Numbering symbol align left\|center\|right\|both
|
||||
- ``left`` See paragraph style
|
||||
- ``hanging`` See paragraph style
|
||||
- ``tabPos`` See paragraph style
|
||||
- ``font`` Font name
|
||||
- ``hint`` See font style
|
||||
Available NumberingLevel style options:
|
||||
|
||||
- ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\ST_Jc`` class for the details.
|
||||
- ``font``. Font name.
|
||||
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
|
||||
- ``hanging``. See paragraph style.
|
||||
- ``hint``. See font style.
|
||||
- ``left``. See paragraph style.
|
||||
- ``restart``. Restart numbering level symbol.
|
||||
- ``start``. Starting value.
|
||||
- ``suffix``. Content between numbering symbol and paragraph text tab\|space\|nothing.
|
||||
- ``tabPos``. See paragraph style.
|
||||
- ``text``. Numbering level text e.g. %1 for nonbullet or bullet character.
|
||||
|
|
@ -5,7 +5,7 @@ include_once 'Sample_Header.php';
|
|||
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
$phpWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
|
||||
$phpWord->addParagraphStyle('pStyle', array('alignment' => 'center', 'spaceAfter' => 100));
|
||||
$phpWord->addParagraphStyle('pStyle', array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER, 'spaceAfter' => 100));
|
||||
$phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
|
||||
|
||||
// New portrait section
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ echo date('H:i:s'), ' Create new PhpWord object', EOL;
|
|||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
$phpWord->setDefaultParagraphStyle(
|
||||
array(
|
||||
'alignment' => 'both',
|
||||
'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::BOTH,
|
||||
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12),
|
||||
'spacing' => 120,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ for ($r = 1; $r <= 8; $r++) {
|
|||
$section->addTextBreak(1);
|
||||
$section->addText(htmlspecialchars('Fancy table', ENT_COMPAT, 'UTF-8'), $header);
|
||||
|
||||
$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80);
|
||||
$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_JcTable::CENTER);
|
||||
$styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
|
||||
$styleCell = array('valign' => 'center');
|
||||
$styleCellBTLR = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
|
||||
$fontStyle = array('bold' => true, 'align' => 'center');
|
||||
$fontStyle = array('bold' => true);
|
||||
$phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow);
|
||||
$table = $section->addTable('Fancy Table');
|
||||
$table->addRow(900);
|
||||
|
|
@ -58,7 +58,7 @@ $styleTable = array('borderSize' => 6, 'borderColor' => '999999');
|
|||
$cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center', 'bgColor' => 'FFFF00');
|
||||
$cellRowContinue = array('vMerge' => 'continue');
|
||||
$cellColSpan = array('gridSpan' => 2, 'valign' => 'center');
|
||||
$cellHCentered = array('align' => 'center');
|
||||
$cellHCentered = array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER);
|
||||
$cellVCentered = array('valign' => 'center');
|
||||
|
||||
$phpWord->addTableStyle('Colspan Rowspan', $styleTable);
|
||||
|
|
@ -89,10 +89,10 @@ $table->addCell(null, $cellRowContinue);
|
|||
$section->addTextBreak(2);
|
||||
$section->addText(htmlspecialchars('Nested table in a centered and 50% width table.', ENT_COMPAT, 'UTF-8'), $header);
|
||||
|
||||
$table = $section->addTable(array('width' => 50 * 50, 'unit' => 'pct', 'align' => 'center'));
|
||||
$table = $section->addTable(array('width' => 50 * 50, 'unit' => 'pct', 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_JcTable::CENTER));
|
||||
$cell = $table->addRow()->addCell();
|
||||
$cell->addText(htmlspecialchars('This cell contains nested table.', ENT_COMPAT, 'UTF-8'));
|
||||
$innerCell = $cell->addTable(array('align' => 'center'))->addRow()->addCell();
|
||||
$innerCell = $cell->addTable(array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_JcTable::CENTER))->addRow()->addCell();
|
||||
$innerCell->addText(htmlspecialchars('Inside nested table', ENT_COMPAT, 'UTF-8'));
|
||||
|
||||
// Save file
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ $cell = $table->addCell(4500);
|
|||
$textrun = $cell->addTextRun();
|
||||
$textrun->addText(htmlspecialchars('This is the header with ', ENT_COMPAT, 'UTF-8'));
|
||||
$textrun->addLink('https://github.com/PHPOffice/PHPWord', htmlspecialchars('PHPWord on GitHub', ENT_COMPAT, 'UTF-8'));
|
||||
$table->addCell(4500)->addImage('resources/PhpWord.png', array('width' => 80, 'height' => 80, 'align' => 'right'));
|
||||
$table->addCell(4500)->addImage('resources/PhpWord.png', array('width' => 80, 'height' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::END));
|
||||
|
||||
// Add header for all other pages
|
||||
$subsequent = $section->addHeader();
|
||||
|
|
@ -26,7 +26,7 @@ $subsequent->addImage('resources/_mars.jpg', array('width' => 80, 'height' => 80
|
|||
|
||||
// Add footer
|
||||
$footer = $section->addFooter();
|
||||
$footer->addPreserveText(htmlspecialchars('Page {PAGE} of {NUMPAGES}.', ENT_COMPAT, 'UTF-8'), null, array('alignment' => 'center'));
|
||||
$footer->addPreserveText(htmlspecialchars('Page {PAGE} of {NUMPAGES}.', ENT_COMPAT, 'UTF-8'), null, array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER));
|
||||
$footer->addLink('https://github.com/PHPOffice/PHPWord', htmlspecialchars('PHPWord on GitHub', ENT_COMPAT, 'UTF-8'));
|
||||
|
||||
// Write some text
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ $section->addImage('resources/_mars.jpg');
|
|||
$section->addTextBreak(2);
|
||||
|
||||
$section->addText(htmlspecialchars('Local image with styles:', ENT_COMPAT, 'UTF-8'));
|
||||
$section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'align' => 'center'));
|
||||
$section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER));
|
||||
$section->addTextBreak(2);
|
||||
|
||||
// Remote image
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ $section->addText(
|
|||
$table1 = $section->addTable(array('cellMargin' => 0, 'cellMarginRight' => 0, 'cellMarginBottom' => 0, 'cellMarginLeft' => 0));
|
||||
$table1->addRow(3750);
|
||||
$cell1 = $table1->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => 'ff0000'));
|
||||
$cell1->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'align' => 'center'));
|
||||
$cell1->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER));
|
||||
|
||||
$section->addTextBreak();
|
||||
$section->addText(
|
||||
|
|
@ -43,7 +43,7 @@ $table2 = $section->addTable(
|
|||
);
|
||||
$table2->addRow(3750, array('exactHeight' => true));
|
||||
$cell2 = $table2->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => '00ff00'));
|
||||
$cell2->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'align' => 'center'));
|
||||
$cell2->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER));
|
||||
|
||||
$section->addTextBreak();
|
||||
$section->addText(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ $section = $phpWord->addSection();
|
|||
// In section
|
||||
$textbox = $section->addTextBox(
|
||||
array(
|
||||
'align' => 'center',
|
||||
'alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER,
|
||||
'width' => 400,
|
||||
'height' => 150,
|
||||
'borderSize' => 1,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ $section->addField('PAGE', array('format' => 'ArabicDash'));
|
|||
$section->addText(htmlspecialchars('Number of pages field:', ENT_COMPAT, 'UTF-8'));
|
||||
$section->addField('NUMPAGES', array('format' => 'Arabic', 'numformat' => '0,00'), array('PreserveFormat'));
|
||||
|
||||
$textrun = $section->addTextRun(array('align' => 'center'));
|
||||
$textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::CENTER));
|
||||
$textrun->addText(htmlspecialchars('This is the date of lunar calendar ', ENT_COMPAT, 'UTF-8'));
|
||||
$textrun->addField('DATE', array('dateformat' => 'd-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar'));
|
||||
$textrun->addText(htmlspecialchars(' written in a textrun.', ENT_COMPAT, 'UTF-8'));
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ $section = $phpWord->addSection();
|
|||
$textrun = $section->addTextRun();
|
||||
$textrun->addText(htmlspecialchars('This is a Left to Right paragraph.', ENT_COMPAT, 'UTF-8'));
|
||||
|
||||
$textrun = $section->addTextRun(array('align' => 'right'));
|
||||
$textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\ST_Jc::END));
|
||||
$textrun->addText(htmlspecialchars('سلام این یک پاراگراف راست به چپ است', ENT_COMPAT, 'UTF-8'), array('rtl' => true));
|
||||
|
||||
// Save file
|
||||
|
|
|
|||
|
|
@ -178,7 +178,9 @@ abstract class AbstractContainer extends AbstractElement
|
|||
* Check if a method is allowed for the current container
|
||||
*
|
||||
* @param string $method
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
private function checkValidity($method)
|
||||
|
|
@ -247,10 +249,13 @@ abstract class AbstractContainer extends AbstractElement
|
|||
/**
|
||||
* Add memory image element
|
||||
*
|
||||
* @deprecated 0.9.0
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Image
|
||||
* @deprecated 0.9.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function addMemoryImage($src, $style = null)
|
||||
|
|
@ -261,9 +266,12 @@ abstract class AbstractContainer extends AbstractElement
|
|||
/**
|
||||
* Create textrun element
|
||||
*
|
||||
* @param mixed $paragraphStyle
|
||||
* @return \PhpOffice\PhpWord\Element\TextRun
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param mixed $paragraphStyle
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\TextRun
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function createTextRun($paragraphStyle = null)
|
||||
|
|
@ -274,9 +282,12 @@ abstract class AbstractContainer extends AbstractElement
|
|||
/**
|
||||
* Create footnote element
|
||||
*
|
||||
* @param mixed $paragraphStyle
|
||||
* @return \PhpOffice\PhpWord\Element\Footnote
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param mixed $paragraphStyle
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Footnote
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function createFootnote($paragraphStyle = null)
|
||||
|
|
|
|||
|
|
@ -378,8 +378,11 @@ abstract class AbstractElement
|
|||
* @param mixed $value
|
||||
* @param array $enum
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @todo Merge with the same method in AbstractStyle
|
||||
*/
|
||||
protected function setEnumVal($value = null, $enum = array(), $default = null)
|
||||
|
|
|
|||
|
|
@ -94,7 +94,9 @@ class Field extends AbstractElement
|
|||
* Set Field type
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setType($type = null)
|
||||
|
|
@ -123,7 +125,9 @@ class Field extends AbstractElement
|
|||
* Set Field properties
|
||||
*
|
||||
* @param array $properties
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setProperties($properties = array())
|
||||
|
|
@ -153,7 +157,9 @@ class Field extends AbstractElement
|
|||
* Set Field options
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setOptions($options = array())
|
||||
|
|
|
|||
|
|
@ -67,8 +67,10 @@ class Footnote extends AbstractContainer
|
|||
/**
|
||||
* Get Footnote Reference ID
|
||||
*
|
||||
* @return int
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getReferenceId()
|
||||
|
|
@ -79,8 +81,10 @@ class Footnote extends AbstractContainer
|
|||
/**
|
||||
* Set Footnote Reference ID
|
||||
*
|
||||
* @param int $rId
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param int $rId
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setReferenceId($rId)
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ class Image extends AbstractElement
|
|||
* @param string $source
|
||||
* @param mixed $style
|
||||
* @param boolean $watermark
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||
*/
|
||||
|
|
@ -365,7 +366,9 @@ class Image extends AbstractElement
|
|||
* Check memory image, supported type, image functions, and proportional width/height.
|
||||
*
|
||||
* @param string $source
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||
*/
|
||||
|
|
@ -425,7 +428,9 @@ class Image extends AbstractElement
|
|||
* @since 0.12.0 Throws CreateTemporaryFileException.
|
||||
*
|
||||
* @param string $source
|
||||
*
|
||||
* @return array|null
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
|
||||
*/
|
||||
private function getArchiveImageSize($source)
|
||||
|
|
@ -517,6 +522,7 @@ class Image extends AbstractElement
|
|||
* Get is watermark
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getIsWatermark()
|
||||
|
|
@ -528,6 +534,7 @@ class Image extends AbstractElement
|
|||
* Get is memory image
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getIsMemImage()
|
||||
|
|
|
|||
|
|
@ -129,8 +129,10 @@ class Link extends AbstractElement
|
|||
/**
|
||||
* Get link target
|
||||
*
|
||||
* @return string
|
||||
* @deprecated 0.12.0
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getTarget()
|
||||
|
|
@ -141,8 +143,10 @@ class Link extends AbstractElement
|
|||
/**
|
||||
* Get Link source
|
||||
*
|
||||
* @return string
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getLinkSrc()
|
||||
|
|
@ -153,8 +157,10 @@ class Link extends AbstractElement
|
|||
/**
|
||||
* Get Link name
|
||||
*
|
||||
* @return string
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getLinkName()
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class Object extends AbstractElement
|
|||
*
|
||||
* @param string $source
|
||||
* @param mixed $style
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidObjectException
|
||||
*/
|
||||
public function __construct($source, $style = null)
|
||||
|
|
@ -142,8 +143,10 @@ class Object extends AbstractElement
|
|||
/**
|
||||
* Get Object ID
|
||||
*
|
||||
* @return int
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getObjectId()
|
||||
|
|
@ -154,8 +157,10 @@ class Object extends AbstractElement
|
|||
/**
|
||||
* Set Object ID
|
||||
*
|
||||
* @param int $objId
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param int $objId
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setObjectId($objId)
|
||||
|
|
|
|||
|
|
@ -153,11 +153,14 @@ class Section extends AbstractContainer
|
|||
/**
|
||||
* Add header/footer
|
||||
*
|
||||
* @since 0.10.0
|
||||
*
|
||||
* @param string $type
|
||||
* @param boolean $header
|
||||
*
|
||||
* @return Header|Footer
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
* @since 0.10.0
|
||||
*/
|
||||
private function addHeaderFooter($type = Header::AUTO, $header = true)
|
||||
{
|
||||
|
|
@ -183,8 +186,10 @@ class Section extends AbstractContainer
|
|||
/**
|
||||
* Set section style
|
||||
*
|
||||
* @param array $settings
|
||||
* @deprecated 0.12.0
|
||||
*
|
||||
* @param array $settings
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setSettings($settings = null)
|
||||
|
|
@ -195,8 +200,10 @@ class Section extends AbstractContainer
|
|||
/**
|
||||
* Get section style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Section
|
||||
* @deprecated 0.12.0
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Section
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getSettings()
|
||||
|
|
@ -207,8 +214,10 @@ class Section extends AbstractContainer
|
|||
/**
|
||||
* Create header
|
||||
*
|
||||
* @return Header
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @return Header
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function createHeader()
|
||||
|
|
@ -219,8 +228,10 @@ class Section extends AbstractContainer
|
|||
/**
|
||||
* Create footer
|
||||
*
|
||||
* @return Footer
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @return Footer
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function createFooter()
|
||||
|
|
@ -231,8 +242,10 @@ class Section extends AbstractContainer
|
|||
/**
|
||||
* Get footer
|
||||
*
|
||||
* @return Footer
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @return Footer
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getFooter()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ abstract class IOFactory
|
|||
*
|
||||
* @param PhpWord $phpWord
|
||||
* @param string $name
|
||||
*
|
||||
* @return WriterInterface
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
|
||||
|
|
@ -38,7 +40,9 @@ abstract class IOFactory
|
|||
* Create new reader
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return ReaderInterface
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function createReader($name = 'Word2007')
|
||||
|
|
@ -52,7 +56,9 @@ abstract class IOFactory
|
|||
* @param string $type
|
||||
* @param string $name
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
private static function createObject($type, $name, $phpWord = null)
|
||||
|
|
|
|||
|
|
@ -35,14 +35,17 @@ class Media
|
|||
/**
|
||||
* Add new media element
|
||||
*
|
||||
* @since 0.10.0
|
||||
* @since 0.9.2
|
||||
*
|
||||
* @param string $container section|headerx|footerx|footnote|endnote
|
||||
* @param string $mediaType image|object|link
|
||||
* @param string $source
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
* @since 0.9.2
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static function addElement($container, $mediaType, $source, Image $image = null)
|
||||
{
|
||||
|
|
@ -199,11 +202,14 @@ class Media
|
|||
/**
|
||||
* Add new Section Media Element
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $type
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function addSectionMediaElement($src, $type, Image $image = null)
|
||||
|
|
@ -214,9 +220,12 @@ class Media
|
|||
/**
|
||||
* Add new Section Link Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @return integer
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param string $linkSrc
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function addSectionLinkElement($linkSrc)
|
||||
|
|
@ -227,9 +236,12 @@ class Media
|
|||
/**
|
||||
* Get Section Media Elements
|
||||
*
|
||||
* @param string $key
|
||||
* @return array
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function getSectionMediaElements($key = null)
|
||||
|
|
@ -240,9 +252,12 @@ class Media
|
|||
/**
|
||||
* Get Section Media Elements Count
|
||||
*
|
||||
* @param string $key
|
||||
* @return integer
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function countSectionMediaElements($key = null)
|
||||
|
|
@ -253,11 +268,14 @@ class Media
|
|||
/**
|
||||
* Add new Header Media Element
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param integer $headerCount
|
||||
* @param string $src
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function addHeaderMediaElement($headerCount, $src, Image $image = null)
|
||||
|
|
@ -268,9 +286,12 @@ class Media
|
|||
/**
|
||||
* Get Header Media Elements Count
|
||||
*
|
||||
* @param string $key
|
||||
* @return integer
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function countHeaderMediaElements($key)
|
||||
|
|
@ -281,8 +302,10 @@ class Media
|
|||
/**
|
||||
* Get Header Media Elements
|
||||
*
|
||||
* @return array
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function getHeaderMediaElements()
|
||||
|
|
@ -293,11 +316,14 @@ class Media
|
|||
/**
|
||||
* Add new Footer Media Element
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param integer $footerCount
|
||||
* @param string $src
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function addFooterMediaElement($footerCount, $src, Image $image = null)
|
||||
|
|
@ -308,9 +334,12 @@ class Media
|
|||
/**
|
||||
* Get Footer Media Elements Count
|
||||
*
|
||||
* @param string $key
|
||||
* @return integer
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function countFooterMediaElements($key)
|
||||
|
|
@ -321,8 +350,10 @@ class Media
|
|||
/**
|
||||
* Get Footer Media Elements
|
||||
*
|
||||
* @return array
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function getFooterMediaElements()
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ class PhpWord
|
|||
/**
|
||||
* Default font settings
|
||||
*
|
||||
* @const string|int
|
||||
* @deprecated 0.11.0 Use Settings constants
|
||||
*
|
||||
* @const string|int
|
||||
*/
|
||||
const DEFAULT_FONT_NAME = Settings::DEFAULT_FONT_NAME;
|
||||
const DEFAULT_FONT_SIZE = Settings::DEFAULT_FONT_SIZE;
|
||||
|
|
@ -100,11 +101,14 @@ class PhpWord
|
|||
/**
|
||||
* Dynamic function call to reduce static dependency
|
||||
*
|
||||
* @since 0.12.0
|
||||
*
|
||||
* @param mixed $function
|
||||
* @param mixed $args
|
||||
* @throws \BadMethodCallException
|
||||
*
|
||||
* @return mixed
|
||||
* @since 0.12.0
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __call($function, $args)
|
||||
{
|
||||
|
|
@ -267,8 +271,12 @@ class PhpWord
|
|||
* @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead.
|
||||
*
|
||||
* @param string $filename Fully qualified filename.
|
||||
*
|
||||
* @return TemplateProcessor
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function loadTemplate($filename)
|
||||
{
|
||||
|
|
@ -319,9 +327,12 @@ class PhpWord
|
|||
/**
|
||||
* Create new section
|
||||
*
|
||||
* @param array $settings
|
||||
* @return \PhpOffice\PhpWord\Element\Section
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param array $settings
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\Section
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function createSection($settings = null)
|
||||
|
|
@ -332,8 +343,10 @@ class PhpWord
|
|||
/**
|
||||
* Get document properties object
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Metadata\DocInfo
|
||||
* @deprecated 0.12.0
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Metadata\DocInfo
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getDocumentProperties()
|
||||
|
|
@ -344,9 +357,12 @@ class PhpWord
|
|||
/**
|
||||
* Set document properties object
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Metadata\DocInfo $documentProperties
|
||||
* @return self
|
||||
* @deprecated 0.12.0
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Metadata\DocInfo $documentProperties
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setDocumentProperties($documentProperties)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,9 @@ abstract class AbstractReader implements ReaderInterface
|
|||
* Open file for reading
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return resource
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
protected function openFile($filename)
|
||||
|
|
@ -110,6 +112,7 @@ abstract class AbstractReader implements ReaderInterface
|
|||
* Read data only?
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getReadDataOnly()
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ class HTML extends AbstractReader implements ReaderInterface
|
|||
* Loads PhpWord from file
|
||||
*
|
||||
* @param string $docFile
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\PhpWord
|
||||
*/
|
||||
public function load($docFile)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ class RTF extends AbstractReader implements ReaderInterface
|
|||
* Loads PhpWord from file
|
||||
*
|
||||
* @param string $docFile
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\PhpWord
|
||||
*/
|
||||
public function load($docFile)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
namespace PhpOffice\PhpWord\Reader\RTF;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
|
||||
/**
|
||||
* RTF document reader
|
||||
|
|
@ -140,7 +141,7 @@ class Document
|
|||
125 => 'markClosing', // }
|
||||
92 => 'markBackslash', // \
|
||||
10 => 'markNewline', // LF
|
||||
13 => 'markNewline' // CR
|
||||
13 => 'markNewline', // CR
|
||||
);
|
||||
|
||||
$this->phpWord = $phpWord;
|
||||
|
|
@ -159,7 +160,7 @@ class Document
|
|||
$markerFunction = $markers[$ascii];
|
||||
$this->$markerFunction();
|
||||
} else {
|
||||
if ($this->isControl === false) { // Non control word: Push character
|
||||
if (false === $this->isControl) { // Non control word: Push character
|
||||
$this->pushText($char);
|
||||
} else {
|
||||
if (preg_match("/^[a-zA-Z0-9-]?$/", $char)) { // No delimiter: Buffer control
|
||||
|
|
@ -169,7 +170,7 @@ class Document
|
|||
if ($this->isFirst) {
|
||||
$this->isFirst = false;
|
||||
} else {
|
||||
if ($char == ' ') { // Discard space as a control word delimiter
|
||||
if (' ' == $char) { // Discard space as a control word delimiter
|
||||
$this->flushControl(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -255,12 +256,12 @@ class Document
|
|||
*/
|
||||
private function flushControl($isControl = false)
|
||||
{
|
||||
if (preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match) === 1) {
|
||||
if (1 === preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match)) {
|
||||
list(, $control, $parameter) = $match;
|
||||
$this->parseControl($control, $parameter);
|
||||
}
|
||||
|
||||
if ($isControl === true) {
|
||||
if (true === $isControl) {
|
||||
$this->setControl(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -276,7 +277,7 @@ class Document
|
|||
if (isset($this->flags['property'])) { // Set property
|
||||
$this->flags['value'] = $this->text;
|
||||
} else { // Set text
|
||||
if ($this->flags['paragraph'] === true) {
|
||||
if (true === $this->flags['paragraph']) {
|
||||
$this->flags['paragraph'] = false;
|
||||
$this->flags['text'] = $this->text;
|
||||
}
|
||||
|
|
@ -311,9 +312,9 @@ class Document
|
|||
*/
|
||||
private function pushText($char)
|
||||
{
|
||||
if ($char == '<') {
|
||||
if ('<' == $char) {
|
||||
$this->text .= "<";
|
||||
} elseif ($char == '>') {
|
||||
} elseif ('>' == $char) {
|
||||
$this->text .= ">";
|
||||
} else {
|
||||
$this->text .= $char;
|
||||
|
|
@ -336,7 +337,7 @@ class Document
|
|||
'u' => array(self::STYL, 'font', 'underline', true),
|
||||
'strike' => array(self::STYL, 'font', 'strikethrough',true),
|
||||
'fs' => array(self::STYL, 'font', 'size', $parameter),
|
||||
'qc' => array(self::STYL, 'paragraph', 'align', 'center'),
|
||||
'qc' => array(self::STYL, 'paragraph', 'alignment', ST_Jc::CENTER),
|
||||
'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter),
|
||||
'fonttbl' => array(self::SKIP, 'fonttbl', null),
|
||||
'colortbl' => array(self::SKIP, 'colortbl', null),
|
||||
|
|
|
|||
|
|
@ -122,16 +122,16 @@ abstract class AbstractPart
|
|||
$instrText = $xmlReader->getValue('w:instrText', $node);
|
||||
if ($xmlReader->elementExists('w:fldChar', $node)) {
|
||||
$fldCharType = $xmlReader->getAttribute('w:fldCharType', $node, 'w:fldChar');
|
||||
if ($fldCharType == 'begin') {
|
||||
if ('begin' == $fldCharType) {
|
||||
$ignoreText = true;
|
||||
} elseif ($fldCharType == 'end') {
|
||||
} elseif ('end' == $fldCharType) {
|
||||
$ignoreText = false;
|
||||
}
|
||||
}
|
||||
if (!is_null($instrText)) {
|
||||
$textContent .= '{' . $instrText . '}';
|
||||
} else {
|
||||
if ($ignoreText === false) {
|
||||
if (false === $ignoreText) {
|
||||
$textContent .= $xmlReader->getValue('w:t', $node);
|
||||
}
|
||||
}
|
||||
|
|
@ -163,7 +163,7 @@ abstract class AbstractPart
|
|||
$runCount = $xmlReader->countElements('w:r', $domNode);
|
||||
$linkCount = $xmlReader->countElements('w:hyperlink', $domNode);
|
||||
$runLinkCount = $runCount + $linkCount;
|
||||
if ($runLinkCount == 0) {
|
||||
if (0 == $runLinkCount) {
|
||||
$parent->addTextBreak(null, $paragraphStyle);
|
||||
} else {
|
||||
$nodes = $xmlReader->getElements('*', $domNode);
|
||||
|
|
@ -200,7 +200,7 @@ abstract class AbstractPart
|
|||
$fontStyle = $this->readFontStyle($xmlReader, $domNode);
|
||||
|
||||
// Link
|
||||
if ($domNode->nodeName == 'w:hyperlink') {
|
||||
if ('w:hyperlink' == $domNode->nodeName) {
|
||||
$rId = $xmlReader->getAttribute('r:id', $domNode);
|
||||
$textContent = $xmlReader->getValue('w:r/w:t', $domNode);
|
||||
$target = $this->getMediaTarget($docPart, $rId);
|
||||
|
|
@ -264,10 +264,10 @@ abstract class AbstractPart
|
|||
$table = $parent->addTable($tblStyle);
|
||||
$tblNodes = $xmlReader->getElements('*', $domNode);
|
||||
foreach ($tblNodes as $tblNode) {
|
||||
if ($tblNode->nodeName == 'w:tblGrid') { // Column
|
||||
if ('w:tblGrid' == $tblNode->nodeName) { // Column
|
||||
// @todo Do something with table columns
|
||||
|
||||
} elseif ($tblNode->nodeName == 'w:tr') { // Row
|
||||
} elseif ('w:tr' == $tblNode->nodeName) { // Row
|
||||
$rowHeight = $xmlReader->getAttribute('w:val', $tblNode, 'w:trPr/w:trHeight');
|
||||
$rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight');
|
||||
$rowHRule = $rowHRule == 'exact' ? true : false;
|
||||
|
|
@ -280,10 +280,10 @@ abstract class AbstractPart
|
|||
$row = $table->addRow($rowHeight, $rowStyle);
|
||||
$rowNodes = $xmlReader->getElements('*', $tblNode);
|
||||
foreach ($rowNodes as $rowNode) {
|
||||
if ($rowNode->nodeName == 'w:trPr') { // Row style
|
||||
if ('w:trPr' == $rowNode->nodeName) { // Row style
|
||||
// @todo Do something with row style
|
||||
|
||||
} elseif ($rowNode->nodeName == 'w:tc') { // Cell
|
||||
} elseif ('w:tc' == $rowNode->nodeName) { // Cell
|
||||
$cellWidth = $xmlReader->getAttribute('w:w', $rowNode, 'w:tcPr/w:tcW');
|
||||
$cellStyle = null;
|
||||
$cellStyleNode = $xmlReader->getElement('w:tcPr', $rowNode);
|
||||
|
|
@ -294,7 +294,7 @@ abstract class AbstractPart
|
|||
$cell = $row->addCell($cellWidth, $cellStyle);
|
||||
$cellNodes = $xmlReader->getElements('*', $rowNode);
|
||||
foreach ($cellNodes as $cellNode) {
|
||||
if ($cellNode->nodeName == 'w:p') { // Paragraph
|
||||
if ('w:p' == $cellNode->nodeName) { // Paragraph
|
||||
$this->readParagraph($xmlReader, $cellNode, $cell, $docPart);
|
||||
}
|
||||
}
|
||||
|
|
@ -320,7 +320,7 @@ abstract class AbstractPart
|
|||
$styleNode = $xmlReader->getElement('w:pPr', $domNode);
|
||||
$styleDefs = array(
|
||||
'styleName' => array(self::READ_VALUE, 'w:pStyle'),
|
||||
'align' => array(self::READ_VALUE, 'w:jc'),
|
||||
'alignment' => array(self::READ_VALUE, 'w:jc'),
|
||||
'basedOn' => array(self::READ_VALUE, 'w:basedOn'),
|
||||
'next' => array(self::READ_VALUE, 'w:next'),
|
||||
'indent' => array(self::READ_VALUE, 'w:ind', 'w:left'),
|
||||
|
|
@ -349,7 +349,7 @@ abstract class AbstractPart
|
|||
return null;
|
||||
}
|
||||
// Hyperlink has an extra w:r child
|
||||
if ($domNode->nodeName == 'w:hyperlink') {
|
||||
if ('w:hyperlink' == $domNode->nodeName) {
|
||||
$domNode = $xmlReader->getElement('w:r', $domNode);
|
||||
}
|
||||
if (!$xmlReader->elementExists('w:rPr', $domNode)) {
|
||||
|
|
@ -399,7 +399,6 @@ abstract class AbstractPart
|
|||
} else {
|
||||
$styleNode = $xmlReader->getElement('w:tblPr', $domNode);
|
||||
$styleDefs = array();
|
||||
// $styleDefs['styleName'] = array(self::READ_VALUE, 'w:tblStyle');
|
||||
foreach ($margins as $side) {
|
||||
$ucfSide = ucfirst($side);
|
||||
$styleDefs["cellMargin$ucfSide"] = array(self::READ_VALUE, "w:tblCellMar/w:$side", 'w:w');
|
||||
|
|
@ -482,13 +481,13 @@ abstract class AbstractPart
|
|||
{
|
||||
$style = $attributeValue;
|
||||
|
||||
if ($method == self::READ_SIZE) {
|
||||
if (self::READ_SIZE == $method) {
|
||||
$style = $attributeValue / 2;
|
||||
} elseif ($method == self::READ_TRUE) {
|
||||
} elseif (self::READ_TRUE == $method) {
|
||||
$style = true;
|
||||
} elseif ($method == self::READ_FALSE) {
|
||||
} elseif (self::READ_FALSE == $method) {
|
||||
$style = false;
|
||||
} elseif ($method == self::READ_EQUAL) {
|
||||
} elseif (self::READ_EQUAL == $method) {
|
||||
$style = $attributeValue == $expected;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class Numbering extends AbstractPart
|
|||
$level['restart'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlRestart');
|
||||
$level['suffix'] = $xmlReader->getAttribute('w:val', $subnode, 'w:suff');
|
||||
$level['text'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlText');
|
||||
$level['align'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlJc');
|
||||
$level['alignment'] = $xmlReader->getAttribute('w:val', $subnode, 'w:lvlJc');
|
||||
$level['tab'] = $xmlReader->getAttribute('w:pos', $subnode, 'w:pPr/w:tabs/w:tab');
|
||||
$level['left'] = $xmlReader->getAttribute('w:left', $subnode, 'w:pPr/w:ind');
|
||||
$level['hanging'] = $xmlReader->getAttribute('w:hanging', $subnode, 'w:pPr/w:ind');
|
||||
|
|
|
|||
|
|
@ -407,6 +407,7 @@ class Settings
|
|||
* Return the compatibility option used by the XMLWriter
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function getCompatibility()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ namespace PhpOffice\PhpWord\Shared;
|
|||
* DEPRECATED: Common font functions; Use 'Converter'
|
||||
*
|
||||
* @deprecated 0.12.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Font
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Html
|
|||
$html = str_replace('&', '&', $html);
|
||||
$html = str_replace(array('_lt_', '_gt_', '_amp_'), array('<', '>', '&'), $html);
|
||||
|
||||
if ($fullHTML === false) {
|
||||
if (false === $fullHTML) {
|
||||
$html = '<body>' . $html . '</body>';
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ class Html
|
|||
*/
|
||||
protected static function parseInlineStyle($node, $styles = array())
|
||||
{
|
||||
if ($node->nodeType == XML_ELEMENT_NODE) {
|
||||
if (XML_ELEMENT_NODE == $node->nodeType) {
|
||||
$attributes = $node->attributes; // get all the attributes(eg: id, class)
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
|
|
@ -173,7 +173,7 @@ class Html
|
|||
*/
|
||||
private static function parseChildNodes($node, $element, $styles, $data)
|
||||
{
|
||||
if ($node->nodeName != 'li') {
|
||||
if ('li' != $node->nodeName) {
|
||||
$cNodes = $node->childNodes;
|
||||
if (count($cNodes) > 0) {
|
||||
foreach ($cNodes as $cNode) {
|
||||
|
|
@ -361,7 +361,7 @@ class Html
|
|||
}
|
||||
break;
|
||||
case 'text-align':
|
||||
$styles['align'] = $cValue;
|
||||
$styles['alignment'] = $cValue; // todo: any mapping?
|
||||
break;
|
||||
case 'color':
|
||||
$styles['color'] = trim($cValue, "#");
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ class OLERead
|
|||
* Read the file
|
||||
*
|
||||
* @param $sFileName string Filename
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function read($sFileName)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ class XMLReader
|
|||
*
|
||||
* @param string $zipFile
|
||||
* @param string $xmlFile
|
||||
*
|
||||
* @return \DOMDocument|false
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function getDomFromZip($zipFile, $xmlFile)
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ class XMLWriter
|
|||
*
|
||||
* @param mixed $function
|
||||
* @param mixed $args
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __call($function, $args)
|
||||
|
|
|
|||
|
|
@ -151,7 +151,9 @@ class ZipArchive
|
|||
* Close the active archive
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @codeCoverageIgnore Can't find any test case. Uncomment when found.
|
||||
*/
|
||||
public function close()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,32 +15,26 @@
|
|||
* @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();
|
||||
if (!$style instanceof \PhpOffice\PhpWord\Style\Alignment) {
|
||||
return;
|
||||
}
|
||||
$value = $style->getValue();
|
||||
if ($value !== null) {
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
$xmlWriter->startElement('w:jc');
|
||||
$xmlWriter->writeAttribute('w:val', $value);
|
||||
$xmlWriter->endElement(); // w:jc
|
||||
}
|
||||
return array(self::START, self::CENTER, self::END);
|
||||
}
|
||||
}
|
||||
|
|
@ -278,7 +278,9 @@ abstract class AbstractStyle
|
|||
* @param mixed $value
|
||||
* @param array $enum
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function setEnumVal($value = null, $enum = array(), $default = null)
|
||||
|
|
@ -337,9 +339,12 @@ abstract class AbstractStyle
|
|||
/**
|
||||
* Set style using associative array
|
||||
*
|
||||
* @param array $style
|
||||
* @return self
|
||||
* @deprecated 0.11.0
|
||||
*
|
||||
* @param array $style
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setArrayStyle(array $style = array())
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -240,6 +240,7 @@ class Cell extends Border
|
|||
* Get default border color
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getDefaultBorderColor()
|
||||
|
|
|
|||
|
|
@ -787,6 +787,7 @@ class Font extends AbstractStyle
|
|||
* Get bold
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getBold()
|
||||
|
|
@ -798,6 +799,7 @@ class Font extends AbstractStyle
|
|||
* Get italic
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getItalic()
|
||||
|
|
@ -809,6 +811,7 @@ class Font extends AbstractStyle
|
|||
* Get superscript
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getSuperScript()
|
||||
|
|
@ -820,6 +823,7 @@ class Font extends AbstractStyle
|
|||
* Get subscript
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getSubScript()
|
||||
|
|
@ -831,6 +835,7 @@ class Font extends AbstractStyle
|
|||
* Get strikethrough
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getStrikethrough()
|
||||
|
|
@ -842,6 +847,7 @@ class Font extends AbstractStyle
|
|||
* Get paragraph style
|
||||
*
|
||||
* @deprecated 0.11.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Style;
|
||||
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
|
||||
/**
|
||||
* Frame defines the size and position of an object
|
||||
*
|
||||
|
|
@ -88,11 +90,9 @@ class Frame extends AbstractStyle
|
|||
const WRAP_INFRONT = 'infront';
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Alignment
|
||||
* @var string
|
||||
*/
|
||||
private $alignment;
|
||||
private $alignment = '';
|
||||
|
||||
/**
|
||||
* Unit
|
||||
|
|
@ -178,31 +178,59 @@ class Frame extends AbstractStyle
|
|||
*/
|
||||
public function __construct($style = array())
|
||||
{
|
||||
$this->alignment = new Alignment();
|
||||
$this->setStyleByArray($style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlign()
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->alignment->getValue();
|
||||
return $this->alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAlignment($value)
|
||||
{
|
||||
if (in_array($value, ST_Jc::getAllowedValues(), true)) {
|
||||
$this->alignment = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 0.13.0 Use the `getAlignment` method instead.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getAlign()
|
||||
{
|
||||
return $this->getAlignment();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 0.13.0 Use the `setAlignment` method instead.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setAlign($value = null)
|
||||
{
|
||||
$this->alignment->setValue($value);
|
||||
|
||||
return $this;
|
||||
return $this->setAlignment($value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -133,7 +133,9 @@ class Image extends Frame
|
|||
* Set wrapping style
|
||||
*
|
||||
* @param string $wrappingStyle
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setWrappingStyle($wrappingStyle)
|
||||
|
|
@ -157,7 +159,9 @@ class Image extends Frame
|
|||
* Set positioning type
|
||||
*
|
||||
* @param string $positioning
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPositioning($positioning)
|
||||
|
|
@ -181,7 +185,9 @@ class Image extends Frame
|
|||
* Set horizontal alignment
|
||||
*
|
||||
* @param string $alignment
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPosHorizontal($alignment)
|
||||
|
|
@ -205,7 +211,9 @@ class Image extends Frame
|
|||
* Set vertical alignment
|
||||
*
|
||||
* @param string $alignment
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPosVertical($alignment)
|
||||
|
|
@ -229,7 +237,9 @@ class Image extends Frame
|
|||
* Set horizontal relation
|
||||
*
|
||||
* @param string $relto
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPosHorizontalRel($relto)
|
||||
|
|
@ -253,7 +263,9 @@ class Image extends Frame
|
|||
* Set vertical relation
|
||||
*
|
||||
* @param string $relto
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPosVerticalRel($relto)
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ class ListItem extends AbstractStyle
|
|||
}
|
||||
|
||||
// Property mapping for numbering level information
|
||||
$properties = array('start', 'format', 'text', 'align', 'tabPos', 'left', 'hanging', 'font', 'hint');
|
||||
$properties = array('start', 'format', 'text', 'alignment', 'tabPos', 'left', 'hanging', 'font', 'hint');
|
||||
|
||||
// Legacy level information
|
||||
$listTypeStyles = array(
|
||||
|
|
|
|||
|
|
@ -81,12 +81,9 @@ class NumberingLevel extends AbstractStyle
|
|||
private $text;
|
||||
|
||||
/**
|
||||
* Align left|center|right|both
|
||||
*
|
||||
* @var string
|
||||
* @link http://www.schemacentral.com/sc/ooxml/e-w_lvlJc-1.html
|
||||
*/
|
||||
private $align;
|
||||
private $alignment;
|
||||
|
||||
/**
|
||||
* Left
|
||||
|
|
@ -281,26 +278,55 @@ class NumberingLevel extends AbstractStyle
|
|||
}
|
||||
|
||||
/**
|
||||
* Get align
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlign()
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->align;
|
||||
return $this->alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set align
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAlignment($value)
|
||||
{
|
||||
if (in_array($value, Jc::getAllowedValues(), true)) {
|
||||
$this->alignment = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 0.13.0 Use the `getAlignment` method instead.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getAlign()
|
||||
{
|
||||
return $this->getAlignment();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 0.13.0 Use the `setAlignment` method instead.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setAlign($value)
|
||||
{
|
||||
$enum = array('left', 'center', 'right', 'both');
|
||||
$this->align = $this->setEnumVal($value, $enum, $this->align);
|
||||
return $this;
|
||||
return $this->setAlignment($value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ namespace PhpOffice\PhpWord\Style;
|
|||
|
||||
use PhpOffice\PhpWord\Exception\InvalidStyleException;
|
||||
use PhpOffice\PhpWord\Shared\String;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* OOXML:
|
||||
* - General: alignment, outline level
|
||||
* - Alignment: left, right, center, both
|
||||
* - Indentation: left, right, firstline, hanging
|
||||
* - Spacing: before, after, line spacing
|
||||
* - Pagination: widow control, keep next, keep line, page break before
|
||||
|
|
@ -77,11 +77,9 @@ class Paragraph extends Border
|
|||
private $next;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Alignment
|
||||
* @var string
|
||||
*/
|
||||
private $alignment;
|
||||
private $alignment = '';
|
||||
|
||||
/**
|
||||
* Indentation
|
||||
|
|
@ -170,9 +168,9 @@ class Paragraph extends Border
|
|||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$key = String::removeUnderscorePrefix($key);
|
||||
if ($key == 'indent' || $key == 'hanging') {
|
||||
if ('indent' == $key || 'hanging' == $key) {
|
||||
$value = $value * 720;
|
||||
} elseif ($key == 'spacing') {
|
||||
} elseif ('spacing' == $key) {
|
||||
$value += 240; // because line height of 1 matches 240 twips
|
||||
}
|
||||
|
||||
|
|
@ -216,9 +214,9 @@ class Paragraph extends Border
|
|||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Alignment
|
||||
* @return string
|
||||
*/
|
||||
public function getAlignment()
|
||||
{
|
||||
|
|
@ -226,18 +224,47 @@ class Paragraph extends Border
|
|||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAlignment($value = null)
|
||||
public function setAlignment($value)
|
||||
{
|
||||
$this->setObjectVal(array('value' => $value), 'Alignment', $this->alignment);
|
||||
if (in_array($value, ST_Jc::getAllowedValues(), true)) {
|
||||
$this->alignment = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 0.13.0 Use the `getAlignment` method instead.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getAlign()
|
||||
{
|
||||
return $this->getAlignment();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 0.13.0 Use the `setAlignment` method instead.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setAlign($value = null)
|
||||
{
|
||||
return $this->setAlignment($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent style ID
|
||||
*
|
||||
|
|
@ -451,7 +478,9 @@ class Paragraph extends Border
|
|||
* Set the line height
|
||||
*
|
||||
* @param int|float|string $lineHeight
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidStyleException
|
||||
*/
|
||||
public function setLineHeight($lineHeight)
|
||||
|
|
@ -636,6 +665,7 @@ class Paragraph extends Border
|
|||
* Get allow first/last line to display on a separate page setting
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getWidowControl()
|
||||
|
|
@ -647,6 +677,7 @@ class Paragraph extends Border
|
|||
* Get keep paragraph with next paragraph setting
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getKeepNext()
|
||||
|
|
@ -658,6 +689,7 @@ class Paragraph extends Border
|
|||
* Get keep all lines on one page setting
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getKeepLines()
|
||||
|
|
@ -669,6 +701,7 @@ class Paragraph extends Border
|
|||
* Get start paragraph on next page setting
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getPageBreakBefore()
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ class Row extends AbstractStyle
|
|||
* Get tblHeader
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getTblHeader()
|
||||
|
|
@ -136,6 +137,7 @@ class Row extends AbstractStyle
|
|||
* Get cantSplit
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getCantSplit()
|
||||
|
|
@ -147,6 +149,7 @@ class Row extends AbstractStyle
|
|||
* Get exactHeight
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getExactHeight()
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ class Section extends Border
|
|||
*
|
||||
* @const int|float
|
||||
*/
|
||||
const DEFAULT_WIDTH = 11870; // In twip
|
||||
const DEFAULT_HEIGHT = 16787; // In twip
|
||||
const DEFAULT_MARGIN = 1440; // In twip
|
||||
const DEFAULT_GUTTER = 0; // In twip
|
||||
const DEFAULT_HEADER_HEIGHT = 720; // In twip
|
||||
const DEFAULT_FOOTER_HEIGHT = 720; // In twip
|
||||
const DEFAULT_WIDTH = 11870; // In twips.
|
||||
const DEFAULT_HEIGHT = 16787; // In twips.
|
||||
const DEFAULT_MARGIN = 1440; // In twips.
|
||||
const DEFAULT_GUTTER = 0; // In twips.
|
||||
const DEFAULT_HEADER_HEIGHT = 720; // In twips.
|
||||
const DEFAULT_FOOTER_HEIGHT = 720; // In twips.
|
||||
const DEFAULT_COLUMN_COUNT = 1;
|
||||
const DEFAULT_COLUMN_SPACING = 720; // In twip
|
||||
const DEFAULT_COLUMN_SPACING = 720; // In twips.
|
||||
|
||||
/**
|
||||
* Page Orientation
|
||||
|
|
|
|||
|
|
@ -25,8 +25,9 @@ class TOC extends Tab
|
|||
/**
|
||||
* Tab leader types for backward compatibility
|
||||
*
|
||||
* @const string
|
||||
* @deprecated 0.11.0
|
||||
*
|
||||
* @const string
|
||||
*/
|
||||
const TABLEADER_DOT = self::TAB_LEADER_DOT;
|
||||
const TABLEADER_UNDERSCORE = self::TAB_LEADER_UNDERSCORE;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Style;
|
||||
|
||||
/**
|
||||
* Table style
|
||||
*/
|
||||
use PhpOffice\PhpWord\SimpleType\ST_JcTable;
|
||||
|
||||
class Table extends Border
|
||||
{
|
||||
/**
|
||||
|
|
@ -107,9 +106,9 @@ class Table extends Border
|
|||
private $shading;
|
||||
|
||||
/**
|
||||
* @var \PhpOffice\PhpWord\Style\Alignment Alignment
|
||||
* @var string
|
||||
*/
|
||||
private $alignment;
|
||||
private $alignment = '';
|
||||
|
||||
/**
|
||||
* @var int|float Width value
|
||||
|
|
@ -129,8 +128,6 @@ class Table extends Border
|
|||
*/
|
||||
public function __construct($tableStyle = null, $firstRowStyle = null)
|
||||
{
|
||||
$this->alignment = new Alignment();
|
||||
|
||||
// Clone first row from table style, but with certain properties disabled
|
||||
if ($firstRowStyle !== null && is_array($firstRowStyle)) {
|
||||
$this->firstRowStyle = clone $this;
|
||||
|
|
@ -494,26 +491,55 @@ class Table extends Border
|
|||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlign()
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->alignment->getValue();
|
||||
return $this->alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAlignment($value)
|
||||
{
|
||||
if (in_array($value, ST_JcTable::getAllowedValues(), true)) {
|
||||
$this->alignment = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 0.13.0 Use the `getAlignment` method instead.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getAlign()
|
||||
{
|
||||
return $this->getAlignment();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 0.13.0 Use the `setAlignment` method instead.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setAlign($value = null)
|
||||
{
|
||||
$this->alignment->setValue($value);
|
||||
|
||||
return $this;
|
||||
return $this->setAlignment($value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -574,7 +600,7 @@ class Table extends Border
|
|||
*/
|
||||
private function getTableOnlyProperty($property)
|
||||
{
|
||||
if ($this->isFirstRow === false) {
|
||||
if (false === $this->isFirstRow) {
|
||||
return $this->$property;
|
||||
}
|
||||
|
||||
|
|
@ -594,8 +620,8 @@ class Table extends Border
|
|||
*/
|
||||
private function setTableOnlyProperty($property, $value, $isNumeric = true)
|
||||
{
|
||||
if ($this->isFirstRow === false) {
|
||||
if ($isNumeric === true) {
|
||||
if (false === $this->isFirstRow) {
|
||||
if (true === $isNumeric) {
|
||||
$this->$property = $this->setNumericVal($value, $this->$property);
|
||||
} else {
|
||||
$this->$property = $value;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
namespace PhpOffice\PhpWord;
|
||||
|
||||
/**
|
||||
* @deprecated 0.12.0 Use \PhpOffice\PhpWord\TemplateProcessor instead.
|
||||
* @deprecated 0.12.0 Use `\PhpOffice\PhpWord\TemplateProcessor` instead.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Template extends TemplateProcessor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ abstract class AbstractWriter implements WriterInterface
|
|||
* Get PhpWord object
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\PhpWord
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function getPhpWord()
|
||||
|
|
@ -150,7 +151,9 @@ abstract class AbstractWriter implements WriterInterface
|
|||
*
|
||||
* @param bool $value
|
||||
* @param string $directory
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function setUseDiskCaching($value = false, $directory = null)
|
||||
|
|
@ -234,6 +237,7 @@ abstract class AbstractWriter implements WriterInterface
|
|||
* Cleanup temporary file.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\CopyFileException
|
||||
*/
|
||||
protected function cleanupTempFile()
|
||||
|
|
@ -267,7 +271,9 @@ abstract class AbstractWriter implements WriterInterface
|
|||
* Get ZipArchive object
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Shared\ZipArchive
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getZipArchive($filename)
|
||||
|
|
@ -295,10 +301,13 @@ abstract class AbstractWriter implements WriterInterface
|
|||
/**
|
||||
* Open file for writing
|
||||
*
|
||||
* @param string $filename
|
||||
* @return resource
|
||||
* @throws \Exception
|
||||
* @since 0.11.0
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return resource
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function openFile($filename)
|
||||
{
|
||||
|
|
@ -423,6 +432,7 @@ abstract class AbstractWriter implements WriterInterface
|
|||
* Get use disk caching status
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getUseDiskCaching()
|
||||
|
|
|
|||
|
|
@ -64,7 +64,9 @@ class HTML extends AbstractWriter implements WriterInterface
|
|||
* Save PhpWord to file.
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function save($filename = null)
|
||||
|
|
@ -127,8 +129,10 @@ class HTML extends AbstractWriter implements WriterInterface
|
|||
/**
|
||||
* Write document
|
||||
*
|
||||
* @return string
|
||||
* @deprecated 0.11.0
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function writeDocument()
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ abstract class AbstractPart
|
|||
* Get parent writer
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Writer\AbstractWriter
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function getParentWriter()
|
||||
|
|
|
|||
|
|
@ -38,10 +38,8 @@ class Paragraph extends AbstractStyle
|
|||
$css = array();
|
||||
|
||||
// Alignment
|
||||
$alignment = $style->getAlignment();
|
||||
if (!is_null($alignment)) {
|
||||
$alignmentValue = $alignment->getValue();
|
||||
$css['text-align'] = $this->getValueIf(!is_null($alignmentValue), $alignmentValue);
|
||||
if ('' !== $style->getAlignment()) {
|
||||
$css['text-align'] = $style->getAlignment(); // todo: convert OpenXml to Html values
|
||||
}
|
||||
|
||||
// Spacing
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class PDF
|
|||
* Instantiate a new renderer of the configured type within this container class
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function __construct(PhpWord $phpWord)
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ abstract class AbstractRenderer extends HTML
|
|||
* Create new instance
|
||||
*
|
||||
* @param PhpWord $phpWord PhpWord object
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function __construct(PhpWord $phpWord)
|
||||
|
|
@ -169,7 +170,9 @@ abstract class AbstractRenderer extends HTML
|
|||
* Save PhpWord to PDF file, pre-save
|
||||
*
|
||||
* @param string $filename Name of the file to save as
|
||||
*
|
||||
* @return resource
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
protected function prepareForSave($filename = null)
|
||||
|
|
@ -190,7 +193,9 @@ abstract class AbstractRenderer extends HTML
|
|||
* Save PhpWord to PDF file, post-save
|
||||
*
|
||||
* @param resource $fileHandle
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function restoreStateAfterSave($fileHandle)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@ class RTF extends AbstractWriter implements WriterInterface
|
|||
* Save content to file.
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function save($filename = null)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\RTF\Style;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Alignment;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
|
||||
/**
|
||||
* RTF paragraph style writer
|
||||
|
|
@ -48,13 +48,12 @@ class Paragraph extends AbstractStyle
|
|||
}
|
||||
|
||||
$alignments = array(
|
||||
Alignment::ALIGN_LEFT => '\ql',
|
||||
Alignment::ALIGN_RIGHT => '\qr',
|
||||
Alignment::ALIGN_CENTER => '\qc',
|
||||
Alignment::ALIGN_BOTH => '\qj',
|
||||
ST_Jc::START => '\ql',
|
||||
ST_Jc::END => '\qr',
|
||||
ST_Jc::CENTER => '\qc',
|
||||
ST_Jc::BOTH => '\qj',
|
||||
);
|
||||
|
||||
$alignment = $style->getAlignment();
|
||||
$spaceAfter = $style->getSpaceAfter();
|
||||
$spaceBefore = $style->getSpaceBefore();
|
||||
|
||||
|
|
@ -62,8 +61,8 @@ class Paragraph extends AbstractStyle
|
|||
if ($this->nestedLevel == 0) {
|
||||
$content .= '\pard\nowidctlpar ';
|
||||
}
|
||||
if (!is_null($alignment) && isset($alignments[$alignment->getValue()])) {
|
||||
$content .= $alignments[$alignment->getValue()];
|
||||
if (isset($alignments[$style->getAlignment()])) {
|
||||
$content .= $alignments[$style->getAlignment()];
|
||||
}
|
||||
$content .= $this->getValueIf($spaceBefore !== null, '\sb' . $spaceBefore);
|
||||
$content .= $this->getValueIf($spaceAfter !== null, '\sa' . $spaceAfter);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -60,6 +60,7 @@ abstract class AbstractPart
|
|||
* Get parent writer
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Writer\AbstractWriter
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function getParentWriter()
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
|
||||
use PhpOffice\PhpWord\Style\NumberingLevel;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
||||
/**
|
||||
* Word2007 numbering part writer: word/numbering.xml
|
||||
|
|
@ -114,7 +114,7 @@ class Numbering extends AbstractPart
|
|||
'pStyle' => 'pStyle',
|
||||
'suffix' => 'suff',
|
||||
'text' => 'lvlText',
|
||||
'align' => 'lvlJc'
|
||||
'alignment' => 'lvlJc'
|
||||
);
|
||||
foreach ($properties as $property => $nodeName) {
|
||||
$getMethod = "get{$property}";
|
||||
|
|
|
|||
|
|
@ -108,7 +108,9 @@ class Rels extends AbstractPart
|
|||
* @param string $type Relationship type
|
||||
* @param string $target Relationship target
|
||||
* @param string $targetMode Relationship target mode
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '')
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle;
|
||||
use PhpOffice\PhpWord\Style\Frame as FrameStyle;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
|
||||
|
||||
/**
|
||||
* Frame style writer
|
||||
|
|
@ -89,13 +89,21 @@ class Frame extends AbstractStyle
|
|||
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
$xmlWriter->startElement('w:pPr');
|
||||
$styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign())));
|
||||
$styleWriter->write();
|
||||
$xmlWriter->endElement(); // w:pPr
|
||||
|
||||
if ('' !== $style->getAlignment()) {
|
||||
$paragraphAlignment = new ParagraphAlignment($style->getAlignment());
|
||||
$xmlWriter->startElement($paragraphAlignment->getName());
|
||||
foreach ($paragraphAlignment->getAttributes() as $attributeName => $attributeValue) {
|
||||
$xmlWriter->writeAttribute($attributeName, $attributeValue);
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write alignment.
|
||||
* Write wrap.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param \PhpOffice\PhpWord\Style\Frame $style
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
|||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Element\ParagraphAlignment;
|
||||
|
||||
/**
|
||||
* Paragraph style writer
|
||||
|
|
@ -96,8 +97,17 @@ class Paragraph extends AbstractStyle
|
|||
$xmlWriter->writeElementIf($styles['pagination']['keepLines'] === true, 'w:keepLines', 'w:val', '1');
|
||||
$xmlWriter->writeElementIf($styles['pagination']['pageBreak'] === true, 'w:pageBreakBefore', 'w:val', '1');
|
||||
|
||||
// Paragraph alignment
|
||||
if ('' !== $styles['alignment']) {
|
||||
$paragraphAlignment = new ParagraphAlignment($styles['alignment']);
|
||||
$xmlWriter->startElement($paragraphAlignment->getName());
|
||||
foreach ($paragraphAlignment->getAttributes() as $attributeName => $attributeValue) {
|
||||
$xmlWriter->writeAttribute($attributeName, $attributeValue);
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
// Child style: alignment, indentation, spacing, and shading
|
||||
$this->writeChildStyle($xmlWriter, 'Alignment', $styles['alignment']);
|
||||
$this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']);
|
||||
$this->writeChildStyle($xmlWriter, 'Spacing', $styles['spacing']);
|
||||
$this->writeChildStyle($xmlWriter, 'Shading', $styles['shading']);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle;
|
||||
use PhpOffice\PhpWord\Style\Table as TableStyle;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Element\TableAlignment;
|
||||
|
||||
/**
|
||||
* Table style writer
|
||||
|
|
@ -50,7 +50,7 @@ class Table extends AbstractStyle
|
|||
$xmlWriter->startElement('w:tblStyle');
|
||||
$xmlWriter->writeAttribute('w:val', $style);
|
||||
$xmlWriter->endElement();
|
||||
if ($this->width !== null) {
|
||||
if (null !== $this->width) {
|
||||
$this->writeWidth($xmlWriter, $this->width, 'pct');
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
|
|
@ -69,9 +69,15 @@ class Table extends AbstractStyle
|
|||
// w:tblPr
|
||||
$xmlWriter->startElement('w:tblPr');
|
||||
|
||||
// Alignment
|
||||
$styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign())));
|
||||
$styleWriter->write();
|
||||
// Table alignment
|
||||
if ('' !== $style->getAlignment()) {
|
||||
$tableAlignment = new TableAlignment($style->getAlignment());
|
||||
$xmlWriter->startElement($tableAlignment->getName());
|
||||
foreach ($tableAlignment->getAttributes() as $attributeName => $attributeValue) {
|
||||
$xmlWriter->writeAttribute($attributeName, $attributeValue);
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
$this->writeWidth($xmlWriter, $style->getWidth(), $style->getUnit());
|
||||
$this->writeMargin($xmlWriter, $style);
|
||||
|
|
@ -174,7 +180,7 @@ class Table extends AbstractStyle
|
|||
*/
|
||||
private function writeShading(XMLWriter $xmlWriter, TableStyle $style)
|
||||
{
|
||||
if ($style->getShading() !== null) {
|
||||
if (null !== $style->getShading()) {
|
||||
$xmlWriter->startElement('w:tcPr');
|
||||
|
||||
$styleWriter = new Shading($xmlWriter, $style->getShading());
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Element\CheckBox;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
|
||||
/**
|
||||
|
|
@ -81,7 +82,7 @@ class CheckBoxTest extends \PHPUnit_Framework_TestCase
|
|||
$oCheckBox = new CheckBox(htmlspecialchars('chkBox', ENT_COMPAT, 'UTF-8'), htmlspecialchars('CheckBox', ENT_COMPAT, 'UTF-8'), 'fontStyle', 'paragraphStyle');
|
||||
$this->assertEquals('paragraphStyle', $oCheckBox->getParagraphStyle());
|
||||
|
||||
$oCheckBox->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
|
||||
$oCheckBox->setParagraphStyle(array('alignment' => ST_Jc::CENTER, 'spaceAfter' => 100));
|
||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oCheckBox->getParagraphStyle());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Image;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Element\Image
|
||||
|
|
@ -54,7 +55,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
|
|||
array(
|
||||
'width' => 210,
|
||||
'height' => 210,
|
||||
'align' => 'center',
|
||||
'alignment' => ST_Jc::CENTER,
|
||||
'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND,
|
||||
)
|
||||
);
|
||||
|
|
@ -97,7 +98,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$oImage = new Image(
|
||||
__DIR__ . '/../_files/images/earth.jpg',
|
||||
array('height' => 210, 'align' => 'center')
|
||||
array('height' => 210, 'alignment' => ST_Jc::CENTER)
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle());
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Element\PreserveText;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Element\PreserveText
|
||||
|
|
@ -58,7 +59,7 @@ class PreserveTextTest extends \PHPUnit_Framework_TestCase
|
|||
$oPreserveText = new PreserveText(
|
||||
htmlspecialchars('text', ENT_COMPAT, 'UTF-8'),
|
||||
array('size' => 16, 'color' => '1B2232'),
|
||||
array('alignment' => 'center')
|
||||
array('alignment' => ST_Jc::CENTER)
|
||||
);
|
||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oPreserveText->getFontStyle());
|
||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oPreserveText->getParagraphStyle());
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Text;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
|
||||
/**
|
||||
|
|
@ -80,7 +81,7 @@ class TextTest extends \PHPUnit_Framework_TestCase
|
|||
$oText = new Text(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), 'fontStyle', 'paragraphStyle');
|
||||
$this->assertEquals('paragraphStyle', $oText->getParagraphStyle());
|
||||
|
||||
$oText->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
|
||||
$oText->setParagraphStyle(array('alignment' => ST_Jc::CENTER, 'spaceAfter' => 100));
|
||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Style;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInitiation()
|
||||
{
|
||||
$object = new Font(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), array('align' => 'both'));
|
||||
$object = new Font(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), array('alignment' => ST_Jc::BOTH));
|
||||
|
||||
$this->assertEquals(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), $object->getStyleType());
|
||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle());
|
||||
|
|
@ -157,7 +158,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testLineHeightFloatval()
|
||||
{
|
||||
$object = new Font(null, array('align' => 'center'));
|
||||
$object = new Font(null, array('alignment' => ST_Jc::CENTER));
|
||||
$object->setLineHeight('1.5pt');
|
||||
$this->assertEquals(1.5, $object->getLineHeight());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Tests\Style;
|
||||
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Style\Image;
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +38,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
|
|||
$properties = array(
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
'align' => 'left',
|
||||
'alignment' => ST_Jc::START,
|
||||
'marginTop' => 240,
|
||||
'marginLeft' => 240,
|
||||
'wrappingStyle' => 'inline',
|
||||
|
|
@ -60,7 +61,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
|
|||
$properties = array(
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
'align' => 'left',
|
||||
'alignment' => ST_Jc::START,
|
||||
'marginTop' => 240,
|
||||
'marginLeft' => 240,
|
||||
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Tests\Style;
|
||||
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Style\NumberingLevel;
|
||||
|
||||
/**
|
||||
|
|
@ -41,7 +42,7 @@ class NumberingLevelTest extends \PHPUnit_Framework_TestCase
|
|||
'pStyle' => 'pStyle',
|
||||
'suffix' => 'space',
|
||||
'text' => '%1.',
|
||||
'align' => 'left',
|
||||
'alignment' => ST_Jc::START,
|
||||
'left' => 360,
|
||||
'hanging' => 360,
|
||||
'tabPos' => 360,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Tests\Style;
|
||||
|
||||
use PhpOffice\PhpWord\SimpleType\ST_JcTable;
|
||||
use PhpOffice\PhpWord\Style\Table;
|
||||
|
||||
/**
|
||||
|
|
@ -74,7 +75,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
|||
'cellMarginLeft' => 240,
|
||||
'cellMarginRight' => 240,
|
||||
'cellMarginBottom' => 240,
|
||||
'align' => 'center',
|
||||
'alignment' => ST_JcTable::CENTER,
|
||||
'width' => 100,
|
||||
'unit' => 'pct',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Tests\Style;
|
||||
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Style\TextBox;
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +38,7 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
|
|||
$properties = array(
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
'align' => 'left',
|
||||
'alignment' => ST_Jc::START,
|
||||
'marginTop' => 240,
|
||||
'marginLeft' => 240,
|
||||
'wrappingStyle' => 'inline',
|
||||
|
|
@ -71,7 +72,7 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
|
|||
$properties = array(
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
'align' => 'left',
|
||||
'alignment' => ST_Jc::START,
|
||||
'marginTop' => 240,
|
||||
'marginLeft' => 240,
|
||||
'wrappingStyle' => 'inline',
|
||||
|
|
@ -132,10 +133,11 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testSetGetAlign()
|
||||
{
|
||||
$expected = 'left';
|
||||
$object = new TextBox();
|
||||
$object->setAlign($expected);
|
||||
$this->assertEquals($expected, $object->getAlign());
|
||||
$textBox = new TextBox();
|
||||
|
||||
$expectedAlignment = ST_Jc::START;
|
||||
$textBox->setAlignment($expectedAlignment);
|
||||
$this->assertEquals($expectedAlignment, $textBox->getAlignment());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Tests;
|
||||
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
||||
/**
|
||||
|
|
@ -44,7 +45,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testStyles()
|
||||
{
|
||||
$paragraph = array('align' => 'center');
|
||||
$paragraph = array('alignment' => ST_Jc::CENTER);
|
||||
$font = array('italic' => true, '_bold' => true);
|
||||
$table = array('bgColor' => 'CCCCCC');
|
||||
$styles = array(
|
||||
|
|
@ -82,7 +83,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testDefaultParagraphStyle()
|
||||
{
|
||||
$paragraph = array('align' => 'center');
|
||||
$paragraph = array('alignment' => ST_Jc::CENTER);
|
||||
|
||||
Style::setDefaultParagraphStyle($paragraph);
|
||||
|
||||
|
|
|
|||
|
|
@ -70,11 +70,13 @@ final class TemplateProcessorTest extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* XSL stylesheet can be applied.
|
||||
*
|
||||
* @param string $actualDocumentFqfn
|
||||
* @throws \Exception
|
||||
* @test
|
||||
* @covers ::applyXslStyleSheet
|
||||
* @depends testTemplateCanBeSavedInTemporaryLocation
|
||||
* @test
|
||||
*
|
||||
* @param string $actualDocumentFqfn
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Writer;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Writer\HTML;
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +70,7 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
|
|||
'Font',
|
||||
array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000')
|
||||
);
|
||||
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center', 'spaceAfter' => 20, 'spaceBefore' => 20));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER, 'spaceAfter' => 20, 'spaceBefore' => 20));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
|
||||
$section->addTextBreak();
|
||||
|
|
@ -90,7 +91,7 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$section = $phpWord->addSection();
|
||||
|
||||
$textrun = $section->addTextRun(array('align' => 'center'));
|
||||
$textrun = $section->addTextRun(array('alignment' => ST_Jc::CENTER));
|
||||
$textrun->addText(htmlspecialchars('Test 3', ENT_COMPAT, 'UTF-8'));
|
||||
$textrun->addTextBreak();
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
|
|
@ -51,7 +52,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$phpWord->setDefaultFontName('Verdana');
|
||||
$phpWord->addFontStyle('Font', array('size' => 11));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
|
||||
$phpWord->addTableStyle('tblStyle', array('width' => 100));
|
||||
|
||||
$section = $phpWord->addSection(array('colsNum' => 2));
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Writer;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Writer\ODText;
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +72,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addFontStyle('Font', array('size' => 11));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font');
|
||||
$section->addTextBreak();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Writer;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Writer\RTF;
|
||||
|
||||
/**
|
||||
|
|
@ -62,7 +63,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
|
|||
'Font',
|
||||
array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => '00FF00')
|
||||
);
|
||||
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
|
||||
$section->addTextBreak();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
|
|
@ -90,7 +91,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
'borderColor' => '#FF0',
|
||||
)
|
||||
);
|
||||
$section->addTextBox(array('wrappingStyle' => 'tight', 'positioning' => 'absolute', 'align' => 'center'));
|
||||
$section->addTextBox(array('wrappingStyle' => 'tight', 'positioning' => 'absolute', 'alignment' => ST_Jc::CENTER));
|
||||
$section->addListItemRun()->addText(htmlspecialchars('List item run 1', ENT_COMPAT, 'UTF-8'));
|
||||
$section->addField(
|
||||
'DATE',
|
||||
|
|
@ -157,7 +158,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
$phpWord->addParagraphStyle(
|
||||
'pStyle',
|
||||
array(
|
||||
'align' => 'center',
|
||||
'alignment' => ST_Jc::CENTER,
|
||||
'tabs' => $tabs,
|
||||
'shading' => array('fill' => 'FFFF99'),
|
||||
'borderSize' => 4,
|
||||
|
|
@ -176,11 +177,11 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
); // Style #2
|
||||
$phpWord->addTitleStyle(1, array('color' => '333333', 'doubleStrikethrough' => true)); // Style #3
|
||||
$phpWord->addTableStyle('tStyle', array('borderSize' => 1));
|
||||
$fontStyle = new Font('text', array('align' => 'center'));
|
||||
$fontStyle = new Font('text', array('alignment' => ST_Jc::CENTER));
|
||||
|
||||
$section = $phpWord->addSection();
|
||||
$section->addListItem(htmlspecialchars('List Item', ENT_COMPAT, 'UTF-8'), 0, null, null, 'pStyle'); // Style #5
|
||||
$section->addObject($objectSrc, array('align' => 'center'));
|
||||
$section->addObject($objectSrc, array('alignment' => ST_Jc::CENTER));
|
||||
$section->addTOC($fontStyle);
|
||||
$section->addTitle(htmlspecialchars('Title 1', ENT_COMPAT, 'UTF-8'), 1);
|
||||
$section->addTOC('fStyle');
|
||||
|
|
@ -230,7 +231,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
public function testWriteTextRun()
|
||||
{
|
||||
$pStyle = 'pStyle';
|
||||
$aStyle = array('align' => 'justify', 'spaceBefore' => 120, 'spaceAfter' => 120);
|
||||
$aStyle = array('alignment' => ST_Jc::BOTH, 'spaceBefore' => 120, 'spaceAfter' => 120);
|
||||
$imageSrc = __DIR__ . '/../../../_files/images/earth.jpg';
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
|
|
@ -241,7 +242,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
$textrun->addTextBreak();
|
||||
$textrun = $section->addTextRun($aStyle);
|
||||
$textrun->addLink('https://github.com/PHPOffice/PHPWord');
|
||||
$textrun->addImage($imageSrc, array('align' => 'center'));
|
||||
$textrun->addImage($imageSrc, array('alignment' => ST_Jc::CENTER));
|
||||
$textrun->addFootnote();
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
|
|
@ -258,7 +259,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
$section = $phpWord->addSection();
|
||||
$fontStyleArray = array('bold' => true);
|
||||
$fontStyleName = 'Font Style';
|
||||
$paragraphStyleArray = array('align' => 'center');
|
||||
$paragraphStyleArray = array('alignment' => ST_Jc::CENTER);
|
||||
$paragraphStyleName = 'Paragraph Style';
|
||||
|
||||
$expected = 'PHPWord on GitHub';
|
||||
|
|
@ -292,7 +293,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
$footer = $section->addFooter();
|
||||
$fontStyleArray = array('bold' => true);
|
||||
$fontStyleName = 'Font';
|
||||
$paragraphStyleArray = array('align' => 'right');
|
||||
$paragraphStyleArray = array('alignment' => ST_Jc::END);
|
||||
$paragraphStyleName = 'Paragraph';
|
||||
|
||||
$footer->addPreserveText(htmlspecialchars('Page {PAGE}', ENT_COMPAT, 'UTF-8'));
|
||||
|
|
@ -337,7 +338,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
public function testWriteImage()
|
||||
{
|
||||
$phpWord = new PhpWord();
|
||||
$styles = array('align' => 'left', 'width' => 40, 'height' => 40, 'marginTop' => -1, 'marginLeft' => -1);
|
||||
$styles = array('alignment' => ST_Jc::START, 'width' => 40, 'height' => 40, 'marginTop' => -1, 'marginLeft' => -1);
|
||||
$wraps = array('inline', 'behind', 'infront', 'square', 'tight');
|
||||
$section = $phpWord->addSection();
|
||||
foreach ($wraps as $wrap) {
|
||||
|
|
@ -421,7 +422,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
$phpWord = new PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
$attributes = array(
|
||||
'alignment' => 'right',
|
||||
'alignment' => ST_Jc::END,
|
||||
'widowControl' => false,
|
||||
'keepNext' => true,
|
||||
'keepLines' => true,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
|
|
@ -40,14 +41,14 @@ class FootnotesTest extends \PHPUnit_Framework_TestCase
|
|||
public function testWriteFootnotes()
|
||||
{
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addParagraphStyle('pStyle', array('align' => 'left'));
|
||||
$phpWord->addParagraphStyle('pStyle', array('alignment' => ST_Jc::START));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addText(htmlspecialchars('Text', ENT_COMPAT, 'UTF-8'));
|
||||
$footnote1 = $section->addFootnote('pStyle');
|
||||
$footnote1->addText(htmlspecialchars('Footnote', ENT_COMPAT, 'UTF-8'));
|
||||
$footnote1->addTextBreak();
|
||||
$footnote1->addLink('https://github.com/PHPOffice/PHPWord');
|
||||
$footnote2 = $section->addEndnote(array('align' => 'left'));
|
||||
$footnote2 = $section->addEndnote(array('alignment' => ST_Jc::START));
|
||||
$footnote2->addText(htmlspecialchars('Endnote', ENT_COMPAT, 'UTF-8'));
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
|
|
@ -55,7 +56,7 @@ class NumberingTest extends \PHPUnit_Framework_TestCase
|
|||
'restart' => 1,
|
||||
'suffix' => 'space',
|
||||
'text' => '%1.',
|
||||
'align' => 'left',
|
||||
'alignment' => ST_Jc::START,
|
||||
'left' => 360,
|
||||
'hanging' => 360,
|
||||
'tabPos' => 360,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
|
|
@ -42,20 +43,12 @@ class StylesTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$phpWord = new PhpWord();
|
||||
|
||||
$pStyle = array('align' => 'both');
|
||||
$pStyle = array('alignment' => ST_Jc::BOTH);
|
||||
$pBase = array('basedOn' => 'Normal');
|
||||
$pNew = array('basedOn' => 'Base Style', 'next' => 'Normal');
|
||||
$rStyle = array('size' => 20);
|
||||
$tStyle = array(
|
||||
'bgColor' => 'FF0000',
|
||||
'cellMargin' => 120,
|
||||
'borderSize' => 120,
|
||||
);
|
||||
$firstRowStyle = array(
|
||||
'bgColor' => '0000FF',
|
||||
'borderSize' => 120,
|
||||
'borderColor' => '00FF00',
|
||||
);
|
||||
$tStyle = array('bgColor' => 'FF0000', 'cellMargin' => 120, 'borderSize' => 120);
|
||||
$firstRowStyle = array('bgColor' => '0000FF', 'borderSize' => 120, 'borderColor' => '00FF00');
|
||||
$phpWord->setDefaultParagraphStyle($pStyle);
|
||||
$phpWord->addParagraphStyle('Base Style', $pBase);
|
||||
$phpWord->addParagraphStyle('New Style', $pNew);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
|
|||
public function testEmptyStyles()
|
||||
{
|
||||
$styles = array(
|
||||
'Alignment', 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering',
|
||||
'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering',
|
||||
'Paragraph', 'Row', 'Section', 'Shading', 'Spacing', 'Tab', 'Table',
|
||||
'TextBox', 'Line', 'Shape', 'Frame', 'Outline', 'Fill', 'Shadow', 'Extrusion',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
namespace PhpOffice\PhpWord\Tests\Writer;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\ST_Jc;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
use PhpOffice\PhpWord\Writer\Word2007;
|
||||
|
||||
|
|
@ -77,7 +78,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
|
|||
$remoteImage = 'http://php.net//images/logos/php-med-trans-light.gif';
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addFontStyle('Font', array('size' => 11));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('alignment' => ST_Jc::CENTER));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
|
||||
$section->addTextBreak();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ class TestHelperDOCX
|
|||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @param string $writerName
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Tests\XmlDocument
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
|
||||
*/
|
||||
public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007')
|
||||
|
|
|
|||
Loading…
Reference in New Issue