Merge remote-tracking branch 'origin/develop' into develop
Conflicts: samples/Sample_27_Field.php src/PhpWord/Element/AbstractElement.php src/PhpWord/Element/Comment.php src/PhpWord/Element/TrackChange.php src/PhpWord/Writer/Word2007/Element/AbstractElement.php tests/PhpWord/Writer/Word2007/Part/StylesTest.php
This commit is contained in:
commit
a4df134a4c
@ -1,17 +1,19 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
|
dist: precise
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.3
|
- 5.3
|
||||||
- 5.4
|
- 5.4
|
||||||
- 5.5
|
- 5.5
|
||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
- hhvm
|
## - hhvm
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
- php: hhvm
|
## - php: hhvm
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|||||||
27
CHANGELOG.md
27
CHANGELOG.md
@ -3,6 +3,33 @@ Change Log
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
v0.14.0 (?? ???? 2017)
|
||||||
|
----------------------
|
||||||
|
This release fixes several bugs and adds some new features.
|
||||||
|
This is the last version to support PHP 5.3
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Possibility to control the footnote numbering - @troosan #1068
|
||||||
|
- Image creation from string - @troosan #937
|
||||||
|
- Introduced the `\PhpOffice\PhpWord\SimpleType\NumberFormat` simple type. - @troosan
|
||||||
|
- Support for ContextualSpacing - @postHawk #1088
|
||||||
|
- Possiblity to hide spelling and/or grammatical errors - @troosan #542
|
||||||
|
- Possiblity to set default document language as well as changing the language for each text element - @troosan #1108
|
||||||
|
- Support for Comments - @troosan #1067
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Loosen dependency to Zend
|
||||||
|
- Images are not being printed when generating PDF - @hubertinio #1074 #431
|
||||||
|
- Fixed some PHP 7 warnings - @ likeuntomurphy #927
|
||||||
|
- Fixed Word 97 reader - @alsofronie @Benpxpx @mario-rivera #912 #920 #892
|
||||||
|
- Fixed image loading over https - @troosan #988
|
||||||
|
- Impossibility to set different even and odd page headers - @troosan #981
|
||||||
|
- Fixed Word2007 reader where unnecessary paragraphs were being created - @donghaobo #1043 #620
|
||||||
|
- Fixed Word2007 reader where margins were not being read correctly - @slowprog #885 #1008
|
||||||
|
- Impossible to add element PreserveText in Section - @rvanlaak #452
|
||||||
|
- Added missing options for numbering format - @troosan #1041
|
||||||
|
- Fixed impossibility to set a different footer for first page - @ctrlaltca #1116
|
||||||
|
|
||||||
v0.13.0 (31 July 2016)
|
v0.13.0 (31 July 2016)
|
||||||
-------------------
|
-------------------
|
||||||
This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).
|
This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
# 
|
# 
|
||||||
|
|
||||||
## :mag_right: PHPWord is looking for a new maintainer :crown: :pencil: ([#948](https://github.com/PHPOffice/PHPWord/issues/948))
|
|
||||||
|
|
||||||
[](https://packagist.org/packages/phpoffice/phpword)
|
[](https://packagist.org/packages/phpoffice/phpword)
|
||||||
[](https://travis-ci.org/PHPOffice/PHPWord)
|
[](https://travis-ci.org/PHPOffice/PHPWord)
|
||||||
[](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/)
|
[](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/)
|
||||||
@ -14,6 +12,8 @@ PHPWord is a library written in pure PHP that provides a set of classes to write
|
|||||||
|
|
||||||
PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/).
|
PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/).
|
||||||
|
|
||||||
|
If you have any questions, please ask on [StackOverFlow](https://stackoverflow.com/questions/tagged/phpword)
|
||||||
|
|
||||||
Read more about PHPWord:
|
Read more about PHPWord:
|
||||||
|
|
||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
@ -57,8 +57,7 @@ PHPWord requires the following:
|
|||||||
- PHP 5.3.3+
|
- PHP 5.3.3+
|
||||||
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
|
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
|
||||||
- [Zend\Escaper component](http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html)
|
- [Zend\Escaper component](http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html)
|
||||||
- Zend\Stdlib component
|
- [Zend\Stdlib component](http://framework.zend.com/manual/current/en/modules/zend.stdlib.hydrator.html)
|
||||||
- [Zend\Validator component](http://framework.zend.com/manual/current/en/modules/zend.validator.html)
|
|
||||||
- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)
|
- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)
|
||||||
- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images)
|
- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images)
|
||||||
- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write OOXML and ODF)
|
- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write OOXML and ODF)
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Franck Lefevre",
|
"name": "Franck Lefevre",
|
||||||
"homepage": "http://blog.rootslabs.net"
|
"homepage": "https://rootslabs.net/blog/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Ivan Lanin",
|
"name": "Ivan Lanin",
|
||||||
@ -34,10 +34,9 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.3",
|
"php": ">=5.3.3",
|
||||||
"ext-xml": "*",
|
"ext-xml": "*",
|
||||||
"zendframework/zend-escaper": "2.4.*",
|
"zendframework/zend-escaper": "^2.2",
|
||||||
"zendframework/zend-stdlib": "2.4.*",
|
"zendframework/zend-stdlib": "^2.2",
|
||||||
"zendframework/zend-validator": "2.4.*",
|
"phpoffice/common": "^0.2"
|
||||||
"phpoffice/common": "0.2.*"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "3.7.*",
|
"phpunit/phpunit": "3.7.*",
|
||||||
|
|||||||
@ -98,6 +98,12 @@ that are available for the footer. See "Footer" section for detail.
|
|||||||
Additionally, only inside of the header reference you can add watermarks
|
Additionally, only inside of the header reference you can add watermarks
|
||||||
or background pictures. See "Watermarks" section.
|
or background pictures. See "Watermarks" section.
|
||||||
|
|
||||||
|
You can pass an optional parameter to specify where the header/footer should be applied, it can be
|
||||||
|
|
||||||
|
- ``Footer::AUTO`` default, all pages except if overridden by first or even
|
||||||
|
- ``Footer::FIRST`` each first page of the section
|
||||||
|
- ``Footer::EVEN`` each even page of the section. Will only be applied if the evenAndOddHeaders is set to true in phpWord->settings
|
||||||
|
|
||||||
Footers
|
Footers
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|||||||
@ -158,8 +158,8 @@ Parameters:
|
|||||||
- ``$text``. Text that appears in the document.
|
- ``$text``. Text that appears in the document.
|
||||||
- ``$depth``. Depth of list item.
|
- ``$depth``. Depth of list item.
|
||||||
- ``$fontStyle``. See :ref:`font-style`.
|
- ``$fontStyle``. See :ref:`font-style`.
|
||||||
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
|
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
|
||||||
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\_Style\_ListItem.
|
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\\Style\\ListItem.
|
||||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||||
|
|
||||||
Advanced usage:
|
Advanced usage:
|
||||||
@ -297,7 +297,7 @@ Your TOC can only be generated if you have add at least one title (See "Titles")
|
|||||||
|
|
||||||
Options for ``$tocStyle``:
|
Options for ``$tocStyle``:
|
||||||
|
|
||||||
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\_Style\_TOC.
|
- ``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.
|
- ``tabPos``. The position of the tab where the page number appears in twips.
|
||||||
- ``indent``. The indent factor of the titles in twips.
|
- ``indent``. The indent factor of the titles in twips.
|
||||||
|
|
||||||
|
|||||||
107
docs/general.rst
107
docs/general.rst
@ -80,8 +80,8 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
|
|||||||
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
|
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
|
||||||
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
||||||
|
|
||||||
Settings
|
PHPWord Settings
|
||||||
--------
|
----------------
|
||||||
|
|
||||||
The ``PhpOffice\PhpWord\Settings`` class provides some options that will
|
The ``PhpOffice\PhpWord\Settings`` class provides some options that will
|
||||||
affect the behavior of PHPWord. Below are the options.
|
affect the behavior of PHPWord. Below are the options.
|
||||||
@ -130,17 +130,6 @@ To turn it on set ``outputEscapingEnabled`` option to ``true`` in your PHPWord c
|
|||||||
|
|
||||||
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
|
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
|
||||||
|
|
||||||
Spelling and grammatical checks
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
By default spelling and grammatical errors are shown as soon as you open a word document.
|
|
||||||
For big documents this can slow down the opening of the document. You can hide the spelling and/or grammatical errors with:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
|
|
||||||
\PhpOffice\PhpWord\Settings::setSpellingErrorsHidden(true);
|
|
||||||
\PhpOffice\PhpWord\Settings::setGrammaticalErrorsHidden(true);
|
|
||||||
|
|
||||||
Default font
|
Default font
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
@ -152,6 +141,85 @@ default font by using the following two functions:
|
|||||||
$phpWord->setDefaultFontName('Times New Roman');
|
$phpWord->setDefaultFontName('Times New Roman');
|
||||||
$phpWord->setDefaultFontSize(12);
|
$phpWord->setDefaultFontSize(12);
|
||||||
|
|
||||||
|
Document settings
|
||||||
|
-----------------
|
||||||
|
Settings for the generated document can be set using ``$phpWord->getSettings()``
|
||||||
|
|
||||||
|
Magnification Setting
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
The default zoom value is 100 percent. This can be changed either to another percentage
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setZoom(75);
|
||||||
|
|
||||||
|
Or to predefined values ``fullPage``, ``bestFit``, ``textFit``
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setZoom(Zoom::BEST_FIT);
|
||||||
|
|
||||||
|
Spelling and grammatical checks
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
By default spelling and grammatical errors are shown as soon as you open a word document.
|
||||||
|
For big documents this can slow down the opening of the document. You can hide the spelling and/or grammatical errors with:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setHideGrammaticalErrors(true);
|
||||||
|
$phpWord->getSettings()->setHideSpellingErrors(true);
|
||||||
|
|
||||||
|
You can also specify the status of the spell and grammar checks, marking spelling or grammar as dirty will force a re-check when opening the document.
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$proofState = new ProofState();
|
||||||
|
$proofState->setGrammar(ProofState::CLEAN);
|
||||||
|
$proofState->setSpelling(ProofState::DIRTY);
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setProofState(proofState);
|
||||||
|
|
||||||
|
Track Revisions
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
Track changes can be activated using ``setTrackRevisions``, you can furture specify
|
||||||
|
|
||||||
|
- Not to use move syntax, instead moved items will be seen as deleted in one place and added in another
|
||||||
|
- Not track formatting revisions
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setTrackRevisions(true);
|
||||||
|
$phpWord->getSettings()->setDoNotTrackMoves(true);
|
||||||
|
$phpWord->getSettings()->setDoNotTrackFormatting(true);
|
||||||
|
|
||||||
|
Decimal Symbol
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
The default symbol to represent a decimal figure is the ``.`` in english. In french you might want to change it to ``,`` for instance.
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setDecimalSymbol(',');
|
||||||
|
|
||||||
|
Document Language
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
The default language of the document can be change with the following.
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setThemeFontLang(new Language(Language::FR_BE));
|
||||||
|
|
||||||
|
``Languge`` has 3 parameters, one for Latin languages, one for East Asian languages and one for Complex (Bi-Directional) languages.
|
||||||
|
A couple of language codes are provided in the ``PhpOffice\PhpWord\ComplexType\Language`` class but any valid code/ID can be used.
|
||||||
|
|
||||||
|
In case you are generating an RTF document the Language need to be set differently.
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$lang = new Language();
|
||||||
|
$lang->setLangId(Language::EN_GB_ID);
|
||||||
|
$phpWord->getSettings()->setThemeFontLang($lang);
|
||||||
|
|
||||||
Document information
|
Document information
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
@ -194,16 +262,3 @@ points to twips.
|
|||||||
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
|
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
|
||||||
// 2 cm right margin
|
// 2 cm right margin
|
||||||
$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));
|
$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));
|
||||||
|
|
||||||
Language
|
|
||||||
--------
|
|
||||||
|
|
||||||
You can hide spelling errors:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
\PhpOffice\PhpWord\Settings::setSpellingErrorsHidden(true);
|
|
||||||
|
|
||||||
And hide grammatical errors:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
\PhpOffice\PhpWord\Settings::setGrammaticalErrorsHidden(true);
|
|
||||||
|
|||||||
@ -55,6 +55,8 @@ Available Font style options:
|
|||||||
- ``subScript``. Subscript, *true* or *false*.
|
- ``subScript``. Subscript, *true* or *false*.
|
||||||
- ``superScript``. Superscript, *true* or *false*.
|
- ``superScript``. Superscript, *true* or *false*.
|
||||||
- ``underline``. Underline, *dash*, *dotted*, etc.
|
- ``underline``. Underline, *dash*, *dotted*, etc.
|
||||||
|
- ``lang``. Language, either a language code like *en-US*, *fr-BE*, etc. or an object (or as an array) if you need to set eastAsian or bidirectional languages
|
||||||
|
See ``\PhpOffice\PhpWord\Style\Language`` class for some language codes.
|
||||||
|
|
||||||
.. _paragraph-style:
|
.. _paragraph-style:
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ Paragraph
|
|||||||
Available Paragraph style options:
|
Available Paragraph style options:
|
||||||
|
|
||||||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||||
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||||
- ``basedOn``. Parent style.
|
- ``basedOn``. Parent style.
|
||||||
- ``hanging``. Hanging by how much.
|
- ``hanging``. Hanging by how much.
|
||||||
- ``indent``. Indent by how much.
|
- ``indent``. Indent by how much.
|
||||||
@ -87,7 +89,7 @@ Table
|
|||||||
Available Table style options:
|
Available Table style options:
|
||||||
|
|
||||||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||||
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
|
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
|
||||||
- ``bgColor``. Background color, e.g. '9966CC'.
|
- ``bgColor``. Background color, e.g. '9966CC'.
|
||||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||||
@ -106,7 +108,8 @@ Available Cell style options:
|
|||||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||||
- ``gridSpan``. Number of columns spanned.
|
- ``gridSpan``. Number of columns spanned.
|
||||||
- ``textDirection(btLr|tbRl)``. Direction of text. You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
|
- ``textDirection(btLr|tbRl)``. Direction of text.
|
||||||
|
You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
|
||||||
- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
|
- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
|
||||||
- ``vMerge``. *restart* or *continue*.
|
- ``vMerge``. *restart* or *continue*.
|
||||||
- ``width``. Cell width in twips.
|
- ``width``. Cell width in twips.
|
||||||
@ -133,7 +136,7 @@ Numbering level
|
|||||||
Available NumberingLevel style options:
|
Available NumberingLevel style options:
|
||||||
|
|
||||||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||||
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||||
- ``font``. Font name.
|
- ``font``. Font name.
|
||||||
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
|
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
|
||||||
- ``hanging``. See paragraph style.
|
- ``hanging``. See paragraph style.
|
||||||
|
|||||||
@ -1,9 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
|
|
||||||
include_once 'Sample_Header.php';
|
include_once 'Sample_Header.php';
|
||||||
|
|
||||||
// New Word Document
|
// New Word Document
|
||||||
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
|
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
|
||||||
|
|
||||||
|
$languageEnGb = new \PhpOffice\PhpWord\Style\Language(\PhpOffice\PhpWord\Style\Language::EN_GB);
|
||||||
|
|
||||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
$phpWord->getSettings()->setThemeFontLang($languageEnGb);
|
||||||
|
|
||||||
$fontStyleName = 'rStyle';
|
$fontStyleName = 'rStyle';
|
||||||
$phpWord->addFontStyle($fontStyleName, array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
|
$phpWord->addFontStyle($fontStyleName, array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
|
||||||
@ -20,6 +27,10 @@ $section = $phpWord->addSection();
|
|||||||
$section->addTitle('Welcome to PhpWord', 1);
|
$section->addTitle('Welcome to PhpWord', 1);
|
||||||
$section->addText('Hello World!');
|
$section->addText('Hello World!');
|
||||||
|
|
||||||
|
// $pStyle = new Font();
|
||||||
|
// $pStyle->setLang()
|
||||||
|
$section->addText('Ce texte-ci est en français.', array('lang' => \PhpOffice\PhpWord\Style\Language::FR_BE));
|
||||||
|
|
||||||
// Two text break
|
// Two text break
|
||||||
$section->addTextBreak(2);
|
$section->addTextBreak(2);
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$header = array('size' => 16, 'bold' => true);
|
$header = array('size' => 16, 'bold' => true);
|
||||||
//1.Use EastAisa FontStyle
|
//1.Use EastAisa FontStyle
|
||||||
$section->addText('中文楷体样式测试', array('name' => '楷体', 'size' => 16, 'color' => '1B2232'));
|
$section->addText('中文楷体样式测试', array('name' => '楷体', 'size' => 16, 'color' => '1B2232', 'lang' => array('latin' => 'en-US', 'eastAsia' => 'zh-CN')));
|
||||||
|
|
||||||
// Save file
|
// Save file
|
||||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||||
|
|||||||
@ -28,7 +28,7 @@ $textrun->addText('here:');
|
|||||||
|
|
||||||
$indexEntryText = new TextRun();
|
$indexEntryText = new TextRun();
|
||||||
$indexEntryText->addText('My ');
|
$indexEntryText->addText('My ');
|
||||||
$indexEntryText->addText('bold index', ['bold' => true]);
|
$indexEntryText->addText('bold index', array('bold' => true));
|
||||||
$indexEntryText->addText(' entry');
|
$indexEntryText->addText(' entry');
|
||||||
|
|
||||||
$textrun = $section->addTextRun();
|
$textrun = $section->addTextRun();
|
||||||
|
|||||||
@ -65,7 +65,7 @@ final class FootnoteProperties
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Footnote Positioning Location
|
* Get the Footnote Positioning Location
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPos()
|
public function getPos()
|
||||||
@ -75,7 +75,7 @@ final class FootnoteProperties
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd)
|
* Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd)
|
||||||
*
|
*
|
||||||
* @param string $pos
|
* @param string $pos
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return self
|
* @return self
|
||||||
@ -99,7 +99,7 @@ final class FootnoteProperties
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Footnote Numbering Format
|
* Get the Footnote Numbering Format
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getNumFmt()
|
public function getNumFmt()
|
||||||
@ -109,7 +109,7 @@ final class FootnoteProperties
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Footnote Numbering Format
|
* Set the Footnote Numbering Format
|
||||||
*
|
*
|
||||||
* @param string $numFmt One of NumberFormat
|
* @param string $numFmt One of NumberFormat
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
@ -122,7 +122,7 @@ final class FootnoteProperties
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Footnote Numbering Format
|
* Get the Footnote Numbering Format
|
||||||
*
|
*
|
||||||
* @return double
|
* @return double
|
||||||
*/
|
*/
|
||||||
public function getNumStart()
|
public function getNumStart()
|
||||||
@ -132,7 +132,7 @@ final class FootnoteProperties
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Footnote Numbering Format
|
* Set the Footnote Numbering Format
|
||||||
*
|
*
|
||||||
* @param double $numStart
|
* @param double $numStart
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
@ -144,7 +144,7 @@ final class FootnoteProperties
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Footnote and Endnote Numbering Starting Value
|
* Get the Footnote and Endnote Numbering Starting Value
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getNumRestart()
|
public function getNumRestart()
|
||||||
@ -154,7 +154,7 @@ final class FootnoteProperties
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage)
|
* Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage)
|
||||||
*
|
*
|
||||||
* @param string $numRestart
|
* @param string $numRestart
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return self
|
* @return self
|
||||||
|
|||||||
104
src/PhpWord/ComplexType/ProofState.php
Normal file
104
src/PhpWord/ComplexType/ProofState.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
namespace PhpOffice\PhpWord\ComplexType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spelling and Grammatical Checking State
|
||||||
|
*
|
||||||
|
* @see http://www.datypic.com/sc/ooxml/e-w_proofState-1.html
|
||||||
|
*/
|
||||||
|
final class ProofState
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Completed
|
||||||
|
*/
|
||||||
|
const CLEAN = 'clean';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Not Completed
|
||||||
|
*/
|
||||||
|
const DIRTY = 'dirty';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spell Checking State
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $spelling;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grammatical Checking State
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $grammar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Spell Checking State (dirty or clean)
|
||||||
|
*
|
||||||
|
* @param string $spelling
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setSpelling($spelling)
|
||||||
|
{
|
||||||
|
if ($spelling == self::CLEAN || $spelling == self::DIRTY) {
|
||||||
|
$this->spelling = $spelling;
|
||||||
|
} else {
|
||||||
|
throw new \InvalidArgumentException("Invalid value, dirty or clean possible");
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Spell Checking State
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSpelling()
|
||||||
|
{
|
||||||
|
return $this->spelling;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Grammatical Checking State (dirty or clean)
|
||||||
|
*
|
||||||
|
* @param string $grammar
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setGrammar($grammar)
|
||||||
|
{
|
||||||
|
if ($grammar == self::CLEAN || $grammar == self::DIRTY) {
|
||||||
|
$this->grammar = $grammar;
|
||||||
|
} else {
|
||||||
|
throw new \InvalidArgumentException("Invalid value, dirty or clean possible");
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Grammatical Checking State
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getGrammar()
|
||||||
|
{
|
||||||
|
return $this->grammar;
|
||||||
|
}
|
||||||
|
}
|
||||||
166
src/PhpWord/ComplexType/TrackChangesView.php
Normal file
166
src/PhpWord/ComplexType/TrackChangesView.php
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
namespace PhpOffice\PhpWord\ComplexType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visibility of Annotation Types
|
||||||
|
*
|
||||||
|
* @see http://www.datypic.com/sc/ooxml/e-w_revisionView-1.html
|
||||||
|
*/
|
||||||
|
final class TrackChangesView
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Visual Indicator Of Markup Area
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $markup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Comments
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $comments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Content Revisions
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $insDel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Formatting Revisions
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $formatting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Ink Annotations
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $inkAnnotations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Display Visual Indicator Of Markup Area
|
||||||
|
*
|
||||||
|
* @return boolean True if markup is shown
|
||||||
|
*/
|
||||||
|
public function hasMarkup()
|
||||||
|
{
|
||||||
|
return $this->markup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Display Visual Indicator Of Markup Area
|
||||||
|
*
|
||||||
|
* @param boolean $markup
|
||||||
|
* Set to true to show markup
|
||||||
|
*/
|
||||||
|
public function setMarkup($markup)
|
||||||
|
{
|
||||||
|
$this->markup = $markup === null ? true : $markup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Display Comments
|
||||||
|
*
|
||||||
|
* @return boolean True if comments are shown
|
||||||
|
*/
|
||||||
|
public function hasComments()
|
||||||
|
{
|
||||||
|
return $this->comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Display Comments
|
||||||
|
*
|
||||||
|
* @param boolean $comments
|
||||||
|
* Set to true to show comments
|
||||||
|
*/
|
||||||
|
public function setComments($comments)
|
||||||
|
{
|
||||||
|
$this->comments = $comments === null ? true : $comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Display Content Revisions
|
||||||
|
*
|
||||||
|
* @return boolean True if content revisions are shown
|
||||||
|
*/
|
||||||
|
public function hasInsDel()
|
||||||
|
{
|
||||||
|
return $this->insDel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Display Content Revisions
|
||||||
|
*
|
||||||
|
* @param boolean $insDel
|
||||||
|
* Set to true to show content revisions
|
||||||
|
*/
|
||||||
|
public function setInsDel($insDel)
|
||||||
|
{
|
||||||
|
$this->insDel = $insDel === null ? true : $insDel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Display Formatting Revisions
|
||||||
|
*
|
||||||
|
* @return boolean True if formatting revisions are shown
|
||||||
|
*/
|
||||||
|
public function hasFormatting()
|
||||||
|
{
|
||||||
|
return $this->formatting;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Display Formatting Revisions
|
||||||
|
*
|
||||||
|
* @param boolean|null $formatting
|
||||||
|
* Set to true to show formatting revisions
|
||||||
|
*/
|
||||||
|
public function setFormatting($formatting = null)
|
||||||
|
{
|
||||||
|
$this->formatting = $formatting === null ? true : $formatting;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Display Ink Annotations
|
||||||
|
*
|
||||||
|
* @return boolean True if ink annotations are shown
|
||||||
|
*/
|
||||||
|
public function hasInkAnnotations()
|
||||||
|
{
|
||||||
|
return $this->inkAnnotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Display Ink Annotations
|
||||||
|
*
|
||||||
|
* @param boolean $inkAnnotations
|
||||||
|
* Set to true to show ink annotations
|
||||||
|
*/
|
||||||
|
public function setInkAnnotations($inkAnnotations)
|
||||||
|
{
|
||||||
|
$this->inkAnnotations = $inkAnnotations === null ? true : $inkAnnotations;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -212,7 +212,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||||||
'TextBox' => array('Section', 'Header', 'Footer', 'Cell'),
|
'TextBox' => array('Section', 'Header', 'Footer', 'Cell'),
|
||||||
'Footnote' => array('Section', 'TextRun', 'Cell'),
|
'Footnote' => array('Section', 'TextRun', 'Cell'),
|
||||||
'Endnote' => array('Section', 'TextRun', 'Cell'),
|
'Endnote' => array('Section', 'TextRun', 'Cell'),
|
||||||
'PreserveText' => array('Header', 'Footer', 'Cell'),
|
'PreserveText' => array('Section', 'Header', 'Footer', 'Cell'),
|
||||||
'Title' => array('Section'),
|
'Title' => array('Section'),
|
||||||
'TOC' => array('Section'),
|
'TOC' => array('Section'),
|
||||||
'PageBreak' => array('Section'),
|
'PageBreak' => array('Section'),
|
||||||
|
|||||||
@ -116,14 +116,14 @@ abstract class AbstractElement
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The start position for the linked comment
|
* The start position for the linked comment
|
||||||
*
|
*
|
||||||
* @var Comment
|
* @var Comment
|
||||||
*/
|
*/
|
||||||
protected $commentRangeStart;
|
protected $commentRangeStart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The end position for the linked comment
|
* The end position for the linked comment
|
||||||
*
|
*
|
||||||
* @var Comment
|
* @var Comment
|
||||||
*/
|
*/
|
||||||
protected $commentRangeEnd;
|
protected $commentRangeEnd;
|
||||||
@ -231,7 +231,7 @@ abstract class AbstractElement
|
|||||||
/**
|
/**
|
||||||
* Get element unique ID
|
* Get element unique ID
|
||||||
*
|
*
|
||||||
* @return string
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getElementId()
|
public function getElementId()
|
||||||
{
|
{
|
||||||
@ -291,7 +291,7 @@ abstract class AbstractElement
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set comment start
|
* Set comment start
|
||||||
*
|
*
|
||||||
* @param Comment $value
|
* @param Comment $value
|
||||||
*/
|
*/
|
||||||
public function setCommentRangeStart(Comment $value)
|
public function setCommentRangeStart(Comment $value)
|
||||||
|
|||||||
@ -45,9 +45,7 @@ class Bookmark extends AbstractElement
|
|||||||
*/
|
*/
|
||||||
public function __construct($name)
|
public function __construct($name)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->name = CommonText::toUTF8($name);
|
$this->name = CommonText::toUTF8($name);
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -40,7 +40,6 @@ class CheckBox extends Text
|
|||||||
* @param string $text
|
* @param string $text
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function __construct($name = null, $text = null, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($name = null, $text = null, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -31,14 +31,14 @@ class Comment extends TrackChange
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The Element where this comment starts
|
* The Element where this comment starts
|
||||||
*
|
*
|
||||||
* @var AbstractElement
|
* @var AbstractElement
|
||||||
*/
|
*/
|
||||||
private $startElement;
|
private $startElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Element where this comment ends
|
* The Element where this comment ends
|
||||||
*
|
*
|
||||||
* @var AbstractElement
|
* @var AbstractElement
|
||||||
*/
|
*/
|
||||||
private $endElement;
|
private $endElement;
|
||||||
@ -61,7 +61,6 @@ class Comment extends TrackChange
|
|||||||
{
|
{
|
||||||
parent::__construct($author, $date);
|
parent::__construct($author, $date);
|
||||||
$this->initials = $initials;
|
$this->initials = $initials;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +75,7 @@ class Comment extends TrackChange
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the element where this comment starts
|
* Sets the element where this comment starts
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||||
*/
|
*/
|
||||||
public function setStartElement(AbstractElement $value)
|
public function setStartElement(AbstractElement $value)
|
||||||
@ -89,7 +88,7 @@ class Comment extends TrackChange
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the element where this comment starts
|
* Get the element where this comment starts
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||||
*/
|
*/
|
||||||
public function getStartElement()
|
public function getStartElement()
|
||||||
@ -99,7 +98,7 @@ class Comment extends TrackChange
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the element where this comment ends
|
* Sets the element where this comment ends
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||||
*/
|
*/
|
||||||
public function setEndElement(AbstractElement $value)
|
public function setEndElement(AbstractElement $value)
|
||||||
@ -112,7 +111,7 @@ class Comment extends TrackChange
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the element where this comment ends
|
* Get the element where this comment ends
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||||
*/
|
*/
|
||||||
public function getEndElement()
|
public function getEndElement()
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class Footer extends AbstractContainer
|
|||||||
* Header/footer types constants
|
* Header/footer types constants
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-wtype-4.html Header or Footer Type
|
* @link http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type
|
||||||
*/
|
*/
|
||||||
const AUTO = 'default'; // default and odd pages
|
const AUTO = 'default'; // default and odd pages
|
||||||
const FIRST = 'first';
|
const FIRST = 'first';
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class FormField extends Text
|
|||||||
/**
|
/**
|
||||||
* Form field name
|
* Form field name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string|bool|int
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
@ -70,7 +70,6 @@ class FormField extends Text
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -476,9 +476,9 @@ class Image extends AbstractElement
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get image size from string
|
* get image size from string
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
|
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
|
||||||
*/
|
*/
|
||||||
private function getStringImageSize($source)
|
private function getStringImageSize($source)
|
||||||
|
|||||||
@ -83,7 +83,6 @@ class Link extends AbstractElement
|
|||||||
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
||||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
$this->internal = $internal;
|
$this->internal = $internal;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -54,7 +54,6 @@ class PreserveText extends AbstractElement
|
|||||||
* @param string $text
|
* @param string $text
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,7 +51,6 @@ class SDT extends Text
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class Section extends AbstractContainer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The properties for the footnote of this section
|
* The properties for the footnote of this section
|
||||||
*
|
*
|
||||||
* @var FootnoteProperties
|
* @var FootnoteProperties
|
||||||
*/
|
*/
|
||||||
private $footnoteProperties;
|
private $footnoteProperties;
|
||||||
@ -148,7 +148,7 @@ class Section extends AbstractContainer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the footnote properties
|
* Get the footnote properties
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Element\FooterProperties
|
* @return \PhpOffice\PhpWord\Element\FooterProperties
|
||||||
*/
|
*/
|
||||||
public function getFootnotePropoperties()
|
public function getFootnotePropoperties()
|
||||||
@ -158,7 +158,7 @@ class Section extends AbstractContainer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the footnote properties
|
* Set the footnote properties
|
||||||
*
|
*
|
||||||
* @param FootnoteProperties $footnoteProperties
|
* @param FootnoteProperties $footnoteProperties
|
||||||
*/
|
*/
|
||||||
public function setFootnoteProperties(FootnoteProperties $footnoteProperties = null)
|
public function setFootnoteProperties(FootnoteProperties $footnoteProperties = null)
|
||||||
@ -181,6 +181,11 @@ class Section extends AbstractContainer
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach ($this->footers as $footer) {
|
||||||
|
if ($footer->getType() == Header::FIRST) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +219,6 @@ class Section extends AbstractContainer
|
|||||||
} else {
|
} else {
|
||||||
throw new \Exception('Invalid header/footer type.');
|
throw new \Exception('Invalid header/footer type.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class TOC extends AbstractElement
|
|||||||
/**
|
/**
|
||||||
* Font style
|
* Font style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Font|array|string
|
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||||
*/
|
*/
|
||||||
private $fontStyle;
|
private $fontStyle;
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ class TOC extends AbstractElement
|
|||||||
/**
|
/**
|
||||||
* Get Font Style
|
* Get Font Style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Font
|
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||||
*/
|
*/
|
||||||
public function getStyleFont()
|
public function getStyleFont()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -45,7 +45,7 @@ class TrackChange extends AbstractContainer
|
|||||||
* Create a new TrackChange Element
|
* Create a new TrackChange Element
|
||||||
*
|
*
|
||||||
* @param string $author
|
* @param string $author
|
||||||
* @param DateTime $date
|
* @param \DateTime $date
|
||||||
*/
|
*/
|
||||||
public function __construct($author, \DateTime $date)
|
public function __construct($author, \DateTime $date)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
abstract class AbstractEscaper implements EscaperInterface
|
abstract class AbstractEscaper implements EscaperInterface
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
interface EscaperInterface
|
interface EscaperInterface
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
class RegExp extends AbstractEscaper
|
class RegExp extends AbstractEscaper
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
class Rtf extends AbstractEscaper
|
class Rtf extends AbstractEscaper
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
class Xml extends AbstractEscaper
|
class Xml extends AbstractEscaper
|
||||||
|
|||||||
341
src/PhpWord/Metadata/Settings.php
Normal file
341
src/PhpWord/Metadata/Settings.php
Normal file
@ -0,0 +1,341 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
namespace PhpOffice\PhpWord\Metadata;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\ComplexType\ProofState;
|
||||||
|
use PhpOffice\PhpWord\SimpleType\Zoom;
|
||||||
|
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
||||||
|
use PhpOffice\PhpWord\Style\Language;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting class
|
||||||
|
*
|
||||||
|
* @since 0.14.0
|
||||||
|
* @link http://www.datypic.com/sc/ooxml/t-w_CT_Settings.html
|
||||||
|
*/
|
||||||
|
class Settings
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magnification Setting
|
||||||
|
*
|
||||||
|
* @link http://www.datypic.com/sc/ooxml/e-w_zoom-1.html
|
||||||
|
* @var mixed either integer, in which case it treated as a percent, or one of PhpOffice\PhpWord\SimpleType\Zoom
|
||||||
|
*/
|
||||||
|
private $zoom = 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide spelling errors
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $hideSpellingErrors = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide grammatical errors
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $hideGrammaticalErrors = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visibility of Annotation Types
|
||||||
|
*
|
||||||
|
* @var TrackChangesView
|
||||||
|
*/
|
||||||
|
private $revisionView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Track Revisions to Document
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $trackRevisions = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do Not Use Move Syntax When Tracking Revisions
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $doNotTrackMoves = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do Not Track Formatting Revisions When Tracking Revisions
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $doNotTrackFormatting = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spelling and Grammatical Checking State
|
||||||
|
*
|
||||||
|
* @var \PhpOffice\PhpWord\Metadata\ProofState
|
||||||
|
*/
|
||||||
|
private $proofState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Document Editing Restrictions
|
||||||
|
*
|
||||||
|
* @var \PhpOffice\PhpWord\Metadata\Protection
|
||||||
|
*/
|
||||||
|
private $documentProtection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables different header for odd and even pages.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $evenAndOddHeaders = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Theme Font Languages
|
||||||
|
*
|
||||||
|
* @var Language
|
||||||
|
*/
|
||||||
|
private $themeFontLang;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Radix Point for Field Code Evaluation
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $decimalSymbol = '.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Protection
|
||||||
|
*/
|
||||||
|
public function getDocumentProtection()
|
||||||
|
{
|
||||||
|
if ($this->documentProtection == null) {
|
||||||
|
$this->documentProtection = new Protection();
|
||||||
|
}
|
||||||
|
return $this->documentProtection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Protection $documentProtection
|
||||||
|
*/
|
||||||
|
public function setDocumentProtection($documentProtection)
|
||||||
|
{
|
||||||
|
$this->documentProtection = $documentProtection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ProofState
|
||||||
|
*/
|
||||||
|
public function getProofState()
|
||||||
|
{
|
||||||
|
if ($this->proofState == null) {
|
||||||
|
$this->proofState = new ProofState();
|
||||||
|
}
|
||||||
|
return $this->proofState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ProofState $proofState
|
||||||
|
*/
|
||||||
|
public function setProofState($proofState)
|
||||||
|
{
|
||||||
|
$this->proofState = $proofState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Are spelling errors hidden
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasHideSpellingErrors()
|
||||||
|
{
|
||||||
|
return $this->hideSpellingErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide spelling errors
|
||||||
|
*
|
||||||
|
* @param boolean $hideSpellingErrors
|
||||||
|
*/
|
||||||
|
public function setHideSpellingErrors($hideSpellingErrors)
|
||||||
|
{
|
||||||
|
$this->hideSpellingErrors = $hideSpellingErrors === null ? true : $hideSpellingErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Are grammatical errors hidden
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasHideGrammaticalErrors()
|
||||||
|
{
|
||||||
|
return $this->hideGrammaticalErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide grammatical errors
|
||||||
|
*
|
||||||
|
* @param boolean $hideGrammaticalErrors
|
||||||
|
*/
|
||||||
|
public function setHideGrammaticalErrors($hideGrammaticalErrors)
|
||||||
|
{
|
||||||
|
$this->hideGrammaticalErrors = $hideGrammaticalErrors === null ? true : $hideGrammaticalErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasEvenAndOddHeaders()
|
||||||
|
{
|
||||||
|
return $this->evenAndOddHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $evenAndOddHeaders
|
||||||
|
*/
|
||||||
|
public function setEvenAndOddHeaders($evenAndOddHeaders)
|
||||||
|
{
|
||||||
|
$this->evenAndOddHeaders = $evenAndOddHeaders === null ? true : $evenAndOddHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Visibility of Annotation Types
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\ComplexType\TrackChangesView
|
||||||
|
*/
|
||||||
|
public function getRevisionView()
|
||||||
|
{
|
||||||
|
return $this->revisionView;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Visibility of Annotation Types
|
||||||
|
*
|
||||||
|
* @param TrackChangesView $trackChangesView
|
||||||
|
*/
|
||||||
|
public function setRevisionView(TrackChangesView $trackChangesView = null)
|
||||||
|
{
|
||||||
|
$this->revisionView = $trackChangesView;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasTrackRevisions()
|
||||||
|
{
|
||||||
|
return $this->trackRevisions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $trackRevisions
|
||||||
|
*/
|
||||||
|
public function setTrackRevisions($trackRevisions)
|
||||||
|
{
|
||||||
|
$this->trackRevisions = $trackRevisions === null ? true : $trackRevisions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasDoNotTrackMoves()
|
||||||
|
{
|
||||||
|
return $this->doNotTrackMoves;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $doNotTrackMoves
|
||||||
|
*/
|
||||||
|
public function setDoNotTrackMoves($doNotTrackMoves)
|
||||||
|
{
|
||||||
|
$this->doNotTrackMoves = $doNotTrackMoves === null ? true : $doNotTrackMoves;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function hasDoNotTrackFormatting()
|
||||||
|
{
|
||||||
|
return $this->doNotTrackFormatting;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $doNotTrackFormatting
|
||||||
|
*/
|
||||||
|
public function setDoNotTrackFormatting($doNotTrackFormatting)
|
||||||
|
{
|
||||||
|
$this->doNotTrackFormatting = $doNotTrackFormatting === null ? true : $doNotTrackFormatting;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getZoom()
|
||||||
|
{
|
||||||
|
return $this->zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $zoom
|
||||||
|
*/
|
||||||
|
public function setZoom($zoom)
|
||||||
|
{
|
||||||
|
if (is_numeric($zoom)) {
|
||||||
|
// zoom is a percentage
|
||||||
|
$this->zoom = $zoom;
|
||||||
|
} else {
|
||||||
|
Zoom::validate($zoom);
|
||||||
|
$this->zoom = $zoom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Language
|
||||||
|
*
|
||||||
|
* @return Language
|
||||||
|
*/
|
||||||
|
public function getThemeFontLang()
|
||||||
|
{
|
||||||
|
return $this->themeFontLang;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the Language for this document
|
||||||
|
*
|
||||||
|
* @param Language $themeFontLang
|
||||||
|
*/
|
||||||
|
public function setThemeFontLang($themeFontLang)
|
||||||
|
{
|
||||||
|
$this->themeFontLang = $themeFontLang;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Radix Point for Field Code Evaluation
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDecimalSymbol()
|
||||||
|
{
|
||||||
|
return $this->decimalSymbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the Radix Point for Field Code Evaluation
|
||||||
|
*
|
||||||
|
* @param string $decimalSymbol
|
||||||
|
*/
|
||||||
|
public function setDecimalSymbol($decimalSymbol)
|
||||||
|
{
|
||||||
|
$this->decimalSymbol = $decimalSymbol;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -93,7 +93,7 @@ class PhpWord
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
$metadata = array('DocInfo', 'Protection', 'Compatibility');
|
$metadata = array('DocInfo', 'Settings', 'Compatibility');
|
||||||
foreach ($metadata as $meta) {
|
foreach ($metadata as $meta) {
|
||||||
$class = 'PhpOffice\\PhpWord\\Metadata\\' . $meta;
|
$class = 'PhpOffice\\PhpWord\\Metadata\\' . $meta;
|
||||||
$this->metadata[$meta] = new $class();
|
$this->metadata[$meta] = new $class();
|
||||||
@ -172,10 +172,12 @@ class PhpWord
|
|||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Metadata\Protection
|
* @return \PhpOffice\PhpWord\Metadata\Protection
|
||||||
* @since 0.12.0
|
* @since 0.12.0
|
||||||
|
* @deprecated Get the Document protection from PhpWord->getSettings()->getDocumentProtection();
|
||||||
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function getProtection()
|
public function getProtection()
|
||||||
{
|
{
|
||||||
return $this->metadata['Protection'];
|
return $this->getSettings()->getDocumentProtection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,6 +191,17 @@ class PhpWord
|
|||||||
return $this->metadata['Compatibility'];
|
return $this->metadata['Compatibility'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get compatibility
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Metadata\Settings
|
||||||
|
* @since 0.14.0
|
||||||
|
*/
|
||||||
|
public function getSettings()
|
||||||
|
{
|
||||||
|
return $this->metadata['Settings'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all sections
|
* Get all sections
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1303,7 +1303,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL);
|
print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL);
|
||||||
print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL);
|
print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL);
|
||||||
print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc));
|
print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc));
|
||||||
switch(dechex($sprm_Sgc)) {
|
switch (dechex($sprm_Sgc)) {
|
||||||
case 0x01:
|
case 0x01:
|
||||||
print_r(' (Paragraph property)');
|
print_r(' (Paragraph property)');
|
||||||
break;
|
break;
|
||||||
@ -1322,12 +1322,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
}
|
}
|
||||||
print_r(PHP_EOL);
|
print_r(PHP_EOL);
|
||||||
print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL);
|
print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL);
|
||||||
switch(dechex($sprm_Spra)) {
|
switch (dechex($sprm_Spra)) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
$operand = self::getInt1d($this->dataWorkDocument, $offset);
|
$operand = self::getInt1d($this->dataWorkDocument, $offset);
|
||||||
$offset += 1;
|
$offset += 1;
|
||||||
$cb -= 1;
|
$cb -= 1;
|
||||||
switch(dechex($operand)) {
|
switch (dechex($operand)) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
$operand = 'OFF';
|
$operand = 'OFF';
|
||||||
break;
|
break;
|
||||||
@ -1376,9 +1376,9 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
switch(dechex($sprm_Sgc)) {
|
switch (dechex($sprm_Sgc)) {
|
||||||
case 0x01: // Sprm is modifying a paragraph property.
|
case 0x01: // Sprm is modifying a paragraph property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
case 0x0A: // sprmPIlvl
|
case 0x0A: // sprmPIlvl
|
||||||
print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL);
|
print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
@ -1391,28 +1391,28 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x02: // Sprm is modifying a character property.
|
case 0x02: // Sprm is modifying a character property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
default:
|
default:
|
||||||
print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x03: // Sprm is modifying a picture property.
|
case 0x03: // Sprm is modifying a picture property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
default:
|
default:
|
||||||
print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x04: // Sprm is modifying a section property.
|
case 0x04: // Sprm is modifying a section property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
default:
|
default:
|
||||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x05: // Sprm is modifying a table property.
|
case 0x05: // Sprm is modifying a table property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
default:
|
default:
|
||||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
@ -1514,11 +1514,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
$length = 0;
|
$length = 0;
|
||||||
$operand = null;
|
$operand = null;
|
||||||
|
|
||||||
switch(dechex($oSprm->spra)) {
|
switch (dechex($oSprm->spra)) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
$operand = self::getInt1d($data, $pos);
|
$operand = self::getInt1d($data, $pos);
|
||||||
$length = 1;
|
$length = 1;
|
||||||
switch(dechex($operand)) {
|
switch (dechex($operand)) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
$operand = false;
|
$operand = false;
|
||||||
break;
|
break;
|
||||||
@ -1593,7 +1593,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
$cbNum -= $arrayReturn['length'];
|
$cbNum -= $arrayReturn['length'];
|
||||||
$operand = $arrayReturn['operand'];
|
$operand = $arrayReturn['operand'];
|
||||||
|
|
||||||
switch(dechex($oSprm->sgc)) {
|
switch (dechex($oSprm->sgc)) {
|
||||||
// Paragraph property
|
// Paragraph property
|
||||||
case 0x01:
|
case 0x01:
|
||||||
break;
|
break;
|
||||||
@ -1602,7 +1602,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
if (!isset($oStylePrl->styleFont)) {
|
if (!isset($oStylePrl->styleFont)) {
|
||||||
$oStylePrl->styleFont = array();
|
$oStylePrl->styleFont = array();
|
||||||
}
|
}
|
||||||
switch($oSprm->isPmd) {
|
switch ($oSprm->isPmd) {
|
||||||
// sprmCFRMarkIns
|
// sprmCFRMarkIns
|
||||||
case 0x01:
|
case 0x01:
|
||||||
break;
|
break;
|
||||||
@ -1620,7 +1620,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
// sprmCFItalic
|
// sprmCFItalic
|
||||||
case 0x36:
|
case 0x36:
|
||||||
// By default, text is not italicized.
|
// By default, text is not italicized.
|
||||||
switch($operand) {
|
switch ($operand) {
|
||||||
case false:
|
case false:
|
||||||
case true:
|
case true:
|
||||||
$oStylePrl->styleFont['italic'] = $operand;
|
$oStylePrl->styleFont['italic'] = $operand;
|
||||||
@ -1640,7 +1640,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
// sprmCFBold
|
// sprmCFBold
|
||||||
case 0x35:
|
case 0x35:
|
||||||
// By default, text is not bold.
|
// By default, text is not bold.
|
||||||
switch($operand) {
|
switch ($operand) {
|
||||||
case false:
|
case false:
|
||||||
case true:
|
case true:
|
||||||
$oStylePrl->styleFont['bold'] = $operand;
|
$oStylePrl->styleFont['bold'] = $operand;
|
||||||
@ -1656,7 +1656,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
// sprmCFStrike
|
// sprmCFStrike
|
||||||
case 0x37:
|
case 0x37:
|
||||||
// By default, text is not struck through.
|
// By default, text is not struck through.
|
||||||
switch($operand) {
|
switch ($operand) {
|
||||||
case false:
|
case false:
|
||||||
case true:
|
case true:
|
||||||
$oStylePrl->styleFont['strikethrough'] = $operand;
|
$oStylePrl->styleFont['strikethrough'] = $operand;
|
||||||
@ -1671,7 +1671,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
break;
|
break;
|
||||||
// sprmCKul
|
// sprmCKul
|
||||||
case 0x3E:
|
case 0x3E:
|
||||||
switch(dechex($operand)) {
|
switch (dechex($operand)) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
|
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
|
||||||
break;
|
break;
|
||||||
@ -1734,7 +1734,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
// sprmCIco
|
// sprmCIco
|
||||||
//@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
|
//@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
|
||||||
case 0x42:
|
case 0x42:
|
||||||
switch(dechex($operand)) {
|
switch (dechex($operand)) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
case 0x01:
|
case 0x01:
|
||||||
$oStylePrl->styleFont['color'] = '000000';
|
$oStylePrl->styleFont['color'] = '000000';
|
||||||
@ -1873,7 +1873,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
if (!isset($oStylePrl->styleSection)) {
|
if (!isset($oStylePrl->styleSection)) {
|
||||||
$oStylePrl->styleSection = array();
|
$oStylePrl->styleSection = array();
|
||||||
}
|
}
|
||||||
switch($oSprm->isPmd) {
|
switch ($oSprm->isPmd) {
|
||||||
// sprmSNfcPgn
|
// sprmSNfcPgn
|
||||||
case 0x0E:
|
case 0x0E:
|
||||||
// numbering format used for page numbers
|
// numbering format used for page numbers
|
||||||
@ -1925,7 +1925,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
default:
|
default:
|
||||||
// print_r('@todo Section : 0x'.dechex($oSprm->isPmd));
|
// print_r('@todo Section : 0x'.dechex($oSprm->isPmd));
|
||||||
// print_r(PHP_EOL);
|
// print_r(PHP_EOL);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Table property
|
// Table property
|
||||||
@ -2285,7 +2284,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,6 @@ class Content extends AbstractPart
|
|||||||
foreach ($nodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
// $styleName = $xmlReader->getAttribute('text:style-name', $node);
|
// $styleName = $xmlReader->getAttribute('text:style-name', $node);
|
||||||
switch ($node->nodeName) {
|
switch ($node->nodeName) {
|
||||||
|
|
||||||
case 'text:h': // Heading
|
case 'text:h': // Heading
|
||||||
$depth = $xmlReader->getAttribute('text:outline-level', $node);
|
$depth = $xmlReader->getAttribute('text:outline-level', $node);
|
||||||
$section->addTitle($node->nodeValue, $depth);
|
$section->addTitle($node->nodeValue, $depth);
|
||||||
|
|||||||
@ -55,6 +55,7 @@ class Word2007 extends AbstractReader implements ReaderInterface
|
|||||||
array('stepPart' => 'document', 'stepItems' => array(
|
array('stepPart' => 'document', 'stepItems' => array(
|
||||||
'endnotes' => 'Endnotes',
|
'endnotes' => 'Endnotes',
|
||||||
'footnotes' => 'Footnotes',
|
'footnotes' => 'Footnotes',
|
||||||
|
'settings' => 'Settings',
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -93,7 +94,6 @@ class Word2007 extends AbstractReader implements ReaderInterface
|
|||||||
$part->setRels($relationships);
|
$part->setRels($relationships);
|
||||||
$part->read($phpWord);
|
$part->read($phpWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -263,7 +263,6 @@ abstract class AbstractPart
|
|||||||
foreach ($tblNodes as $tblNode) {
|
foreach ($tblNodes as $tblNode) {
|
||||||
if ('w:tblGrid' == $tblNode->nodeName) { // Column
|
if ('w:tblGrid' == $tblNode->nodeName) { // Column
|
||||||
// @todo Do something with table columns
|
// @todo Do something with table columns
|
||||||
|
|
||||||
} elseif ('w:tr' == $tblNode->nodeName) { // Row
|
} elseif ('w:tr' == $tblNode->nodeName) { // Row
|
||||||
$rowHeight = $xmlReader->getAttribute('w:val', $tblNode, 'w:trPr/w:trHeight');
|
$rowHeight = $xmlReader->getAttribute('w:val', $tblNode, 'w:trPr/w:trHeight');
|
||||||
$rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight');
|
$rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight');
|
||||||
@ -279,7 +278,6 @@ abstract class AbstractPart
|
|||||||
foreach ($rowNodes as $rowNode) {
|
foreach ($rowNodes as $rowNode) {
|
||||||
if ('w:trPr' == $rowNode->nodeName) { // Row style
|
if ('w:trPr' == $rowNode->nodeName) { // Row style
|
||||||
// @todo Do something with row style
|
// @todo Do something with row style
|
||||||
|
|
||||||
} elseif ('w:tc' == $rowNode->nodeName) { // Cell
|
} elseif ('w:tc' == $rowNode->nodeName) { // Cell
|
||||||
$cellWidth = $xmlReader->getAttribute('w:w', $rowNode, 'w:tcPr/w:tcW');
|
$cellWidth = $xmlReader->getAttribute('w:w', $rowNode, 'w:tcPr/w:tcW');
|
||||||
$cellStyle = null;
|
$cellStyle = null;
|
||||||
@ -316,18 +314,20 @@ abstract class AbstractPart
|
|||||||
|
|
||||||
$styleNode = $xmlReader->getElement('w:pPr', $domNode);
|
$styleNode = $xmlReader->getElement('w:pPr', $domNode);
|
||||||
$styleDefs = array(
|
$styleDefs = array(
|
||||||
'styleName' => array(self::READ_VALUE, 'w:pStyle'),
|
'styleName' => array(self::READ_VALUE, 'w:pStyle'),
|
||||||
'alignment' => array(self::READ_VALUE, 'w:jc'),
|
'alignment' => array(self::READ_VALUE, 'w:jc'),
|
||||||
'basedOn' => array(self::READ_VALUE, 'w:basedOn'),
|
'basedOn' => array(self::READ_VALUE, 'w:basedOn'),
|
||||||
'next' => array(self::READ_VALUE, 'w:next'),
|
'next' => array(self::READ_VALUE, 'w:next'),
|
||||||
'indent' => array(self::READ_VALUE, 'w:ind', 'w:left'),
|
'indent' => array(self::READ_VALUE, 'w:ind', 'w:left'),
|
||||||
'hanging' => array(self::READ_VALUE, 'w:ind', 'w:hanging'),
|
'hanging' => array(self::READ_VALUE, 'w:ind', 'w:hanging'),
|
||||||
'spaceAfter' => array(self::READ_VALUE, 'w:spacing', 'w:after'),
|
'spaceAfter' => array(self::READ_VALUE, 'w:spacing', 'w:after'),
|
||||||
'spaceBefore' => array(self::READ_VALUE, 'w:spacing', 'w:before'),
|
'spaceBefore' => array(self::READ_VALUE, 'w:spacing', 'w:before'),
|
||||||
'widowControl' => array(self::READ_FALSE, 'w:widowControl'),
|
'widowControl' => array(self::READ_FALSE, 'w:widowControl'),
|
||||||
'keepNext' => array(self::READ_TRUE, 'w:keepNext'),
|
'keepNext' => array(self::READ_TRUE, 'w:keepNext'),
|
||||||
'keepLines' => array(self::READ_TRUE, 'w:keepLines'),
|
'keepLines' => array(self::READ_TRUE, 'w:keepLines'),
|
||||||
'pageBreakBefore' => array(self::READ_TRUE, 'w:pageBreakBefore'),
|
'pageBreakBefore' => array(self::READ_TRUE, 'w:pageBreakBefore'),
|
||||||
|
'contextualSpacing' => array(self::READ_TRUE, 'w:contextualSpacing'),
|
||||||
|
'bidi' => array(self::READ_TRUE, 'w:bidi'),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->readStyleDefs($xmlReader, $styleNode, $styleDefs);
|
return $this->readStyleDefs($xmlReader, $styleNode, $styleDefs);
|
||||||
@ -371,6 +371,9 @@ abstract class AbstractPart
|
|||||||
'subScript' => array(self::READ_EQUAL, 'w:vertAlign', 'w:val', 'subscript'),
|
'subScript' => array(self::READ_EQUAL, 'w:vertAlign', 'w:val', 'subscript'),
|
||||||
'fgColor' => array(self::READ_VALUE, 'w:highlight'),
|
'fgColor' => array(self::READ_VALUE, 'w:highlight'),
|
||||||
'rtl' => array(self::READ_TRUE, 'w:rtl'),
|
'rtl' => array(self::READ_TRUE, 'w:rtl'),
|
||||||
|
'font-latin' => array(self::READ_VALUE, 'w:font', 'w:val'),
|
||||||
|
'font-eastAsia' => array(self::READ_VALUE, 'w:font', 'w:eastAsia'),
|
||||||
|
'font-bidi' => array(self::READ_VALUE, 'w:font', 'w:bidi'),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->readStyleDefs($xmlReader, $styleNode, $styleDefs);
|
return $this->readStyleDefs($xmlReader, $styleNode, $styleDefs);
|
||||||
|
|||||||
163
src/PhpWord/Reader/Word2007/Settings.php
Normal file
163
src/PhpWord/Reader/Word2007/Settings.php
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||||
|
|
||||||
|
use PhpOffice\Common\XMLReader;
|
||||||
|
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
||||||
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Style\Language;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings reader
|
||||||
|
*
|
||||||
|
* @since 0.14.0
|
||||||
|
*/
|
||||||
|
class Settings extends AbstractPart
|
||||||
|
{
|
||||||
|
|
||||||
|
private static $booleanProperties = array('hideSpellingErrors', 'hideGrammaticalErrors', 'trackRevisions', 'doNotTrackMoves', 'doNotTrackFormatting', 'evenAndOddHeaders');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read settings.xml.
|
||||||
|
*
|
||||||
|
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function read(PhpWord $phpWord)
|
||||||
|
{
|
||||||
|
$xmlReader = new XMLReader();
|
||||||
|
$xmlReader->getDomFromZip($this->docFile, $this->xmlFile);
|
||||||
|
|
||||||
|
$docSettings = $phpWord->getSettings();
|
||||||
|
|
||||||
|
$nodes = $xmlReader->getElements('*');
|
||||||
|
if ($nodes->length > 0) {
|
||||||
|
foreach ($nodes as $node) {
|
||||||
|
$name = str_replace('w:', '', $node->nodeName);
|
||||||
|
$value = $xmlReader->getAttribute('w:val', $node);
|
||||||
|
$method = 'set' . $name;
|
||||||
|
|
||||||
|
if (in_array($name, $this::$booleanProperties)) {
|
||||||
|
if ($value == 'false') {
|
||||||
|
$docSettings->$method(false);
|
||||||
|
} else {
|
||||||
|
$docSettings->$method(true);
|
||||||
|
}
|
||||||
|
} else if (method_exists($this, $method)) {
|
||||||
|
$this->$method($xmlReader, $phpWord, $node);
|
||||||
|
} else if (method_exists($docSettings, $method)) {
|
||||||
|
$docSettings->$method($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the document Language
|
||||||
|
*
|
||||||
|
* @param XMLReader $xmlReader
|
||||||
|
* @param PhpWord $phpWord
|
||||||
|
* @param \DOMNode $node
|
||||||
|
*/
|
||||||
|
protected function setThemeFontLang(XMLReader $xmlReader, PhpWord $phpWord, \DOMElement $node)
|
||||||
|
{
|
||||||
|
|
||||||
|
$val = $xmlReader->getAttribute('w:val', $node);
|
||||||
|
$eastAsia = $xmlReader->getAttribute('w:eastAsia', $node);
|
||||||
|
$bidi = $xmlReader->getAttribute('w:bidi', $node);
|
||||||
|
|
||||||
|
$themeFontLang = new Language();
|
||||||
|
$themeFontLang->setLatin($val);
|
||||||
|
$themeFontLang->setLatin($eastAsia);
|
||||||
|
$themeFontLang->setLatin($bidi);
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setThemeFontLang($themeFontLang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the document protection
|
||||||
|
*
|
||||||
|
* @param XMLReader $xmlReader
|
||||||
|
* @param PhpWord $phpWord
|
||||||
|
* @param \DOMNode $node
|
||||||
|
*/
|
||||||
|
protected function setDocumentProtection(XMLReader $xmlReader, PhpWord $phpWord, \DOMElement $node)
|
||||||
|
{
|
||||||
|
$documentProtection = $phpWord->getSettings()->getDocumentProtection();
|
||||||
|
|
||||||
|
$edit = $xmlReader->getAttribute('w:edit', $node);
|
||||||
|
$documentProtection->setEditing($edit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the proof state
|
||||||
|
*
|
||||||
|
* @param XMLReader $xmlReader
|
||||||
|
* @param PhpWord $phpWord
|
||||||
|
* @param \DOMNode $node
|
||||||
|
*/
|
||||||
|
protected function setProofState(XMLReader $xmlReader, PhpWord $phpWord, \DOMElement $node)
|
||||||
|
{
|
||||||
|
$proofState = $phpWord->getSettings()->getProofState();
|
||||||
|
|
||||||
|
$spelling = $xmlReader->getAttribute('w:spelling', $node);
|
||||||
|
$grammar = $xmlReader->getAttribute('w:grammar', $node);
|
||||||
|
|
||||||
|
if ($spelling !== null) {
|
||||||
|
$proofState->setSpelling($spelling);
|
||||||
|
}
|
||||||
|
if ($grammar !== null) {
|
||||||
|
$proofState->setGrammar($grammar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the proof state
|
||||||
|
*
|
||||||
|
* @param XMLReader $xmlReader
|
||||||
|
* @param PhpWord $phpWord
|
||||||
|
* @param \DOMNode $node
|
||||||
|
*/
|
||||||
|
protected function setZoom(XMLReader $xmlReader, PhpWord $phpWord, \DOMElement $node)
|
||||||
|
{
|
||||||
|
$percent = $xmlReader->getAttribute('w:percent', $node);
|
||||||
|
$val = $xmlReader->getAttribute('w:val', $node);
|
||||||
|
|
||||||
|
if ($percent !== null || $val !== null) {
|
||||||
|
$phpWord->getSettings()->setZoom($percent === null ? $val : $percent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Revision view
|
||||||
|
*
|
||||||
|
* @param XMLReader $xmlReader
|
||||||
|
* @param PhpWord $phpWord
|
||||||
|
* @param \DOMNode $node
|
||||||
|
*/
|
||||||
|
protected function setRevisionView(XMLReader $xmlReader, PhpWord $phpWord, \DOMElement $node)
|
||||||
|
{
|
||||||
|
$revisionView = new TrackChangesView();
|
||||||
|
$revisionView->setMarkup($xmlReader->getAttribute('w:markup', $node));
|
||||||
|
$revisionView->setComments($xmlReader->getAttribute('w:comments', $node));
|
||||||
|
$revisionView->setInsDel($xmlReader->getAttribute('w:insDel', $node));
|
||||||
|
$revisionView->setFormatting($xmlReader->getAttribute('w:formatting', $node));
|
||||||
|
$revisionView->setInkAnnotations($xmlReader->getAttribute('w:inkAnnotations', $node));
|
||||||
|
$phpWord->getSettings()->setRevisionView($revisionView);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -49,7 +49,6 @@ class Styles extends AbstractPart
|
|||||||
preg_match('/Heading(\d)/', $name, $headingMatches);
|
preg_match('/Heading(\d)/', $name, $headingMatches);
|
||||||
// $default = ($xmlReader->getAttribute('w:default', $node) == 1);
|
// $default = ($xmlReader->getAttribute('w:default', $node) == 1);
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
|
||||||
case 'paragraph':
|
case 'paragraph':
|
||||||
$paragraphStyle = $this->readParagraphStyle($xmlReader, $node);
|
$paragraphStyle = $this->readParagraphStyle($xmlReader, $node);
|
||||||
$fontStyle = $this->readFontStyle($xmlReader, $node);
|
$fontStyle = $this->readFontStyle($xmlReader, $node);
|
||||||
|
|||||||
@ -119,18 +119,6 @@ class Settings
|
|||||||
*/
|
*/
|
||||||
private static $defaultFontSize = self::DEFAULT_FONT_SIZE;
|
private static $defaultFontSize = self::DEFAULT_FONT_SIZE;
|
||||||
|
|
||||||
/**
|
|
||||||
* Hide spelling errors
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private static $spellingErrorsHidden = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hide grammatical errors
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private static $grammaticalErrorsHidden = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user defined temporary directory.
|
* The user defined temporary directory.
|
||||||
*
|
*
|
||||||
@ -146,13 +134,6 @@ class Settings
|
|||||||
*/
|
*/
|
||||||
private static $outputEscapingEnabled = false;
|
private static $outputEscapingEnabled = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables different header for odd and even pages.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private static $evenAndOddHeaders = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the compatibility option used by the XMLWriter
|
* Return the compatibility option used by the XMLWriter
|
||||||
*
|
*
|
||||||
@ -337,7 +318,7 @@ class Settings
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
@ -349,7 +330,7 @@ class Settings
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @param boolean $outputEscapingEnabled
|
* @param boolean $outputEscapingEnabled
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
@ -359,22 +340,6 @@ class Settings
|
|||||||
self::$outputEscapingEnabled = $outputEscapingEnabled;
|
self::$outputEscapingEnabled = $outputEscapingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function isEvenAndOddHeaders()
|
|
||||||
{
|
|
||||||
return self::$evenAndOddHeaders;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param boolean $evenAndOddHeaders
|
|
||||||
*/
|
|
||||||
public static function setEvenAndOddHeaders($evenAndOddHeaders)
|
|
||||||
{
|
|
||||||
self::$evenAndOddHeaders = $evenAndOddHeaders;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get default font name
|
* Get default font name
|
||||||
*
|
*
|
||||||
@ -428,46 +393,6 @@ class Settings
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Are spelling errors hidden
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function isSpellingErrorsHidden()
|
|
||||||
{
|
|
||||||
return self::$spellingErrorsHidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hide spelling errors
|
|
||||||
*
|
|
||||||
* @param boolean $spellingErrorsHidden
|
|
||||||
*/
|
|
||||||
public static function setSpellingErrorsHidden($spellingErrorsHidden)
|
|
||||||
{
|
|
||||||
self::$spellingErrorsHidden = $spellingErrorsHidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Are grammatical errors hidden
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function isGrammaticalErrorsHidden()
|
|
||||||
{
|
|
||||||
return self::$grammaticalErrorsHidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hide grammatical errors
|
|
||||||
*
|
|
||||||
* @param boolean $grammaticalErrorsHidden
|
|
||||||
*/
|
|
||||||
public static function setGrammaticalErrorsHidden($grammaticalErrorsHidden)
|
|
||||||
{
|
|
||||||
self::$grammaticalErrorsHidden = $grammaticalErrorsHidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load setting from phpword.yml or phpword.yml.dist
|
* Load setting from phpword.yml or phpword.yml.dist
|
||||||
*
|
*
|
||||||
|
|||||||
@ -19,16 +19,39 @@ abstract class AbstractEnum
|
|||||||
return self::$constCacheArray[$calledClass];
|
return self::$constCacheArray[$calledClass];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all values for this enum
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public static function values()
|
public static function values()
|
||||||
{
|
{
|
||||||
return array_values(self::getConstants());
|
return array_values(self::getConstants());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function validate($value)
|
/**
|
||||||
|
* Returns true the value is valid for this enum
|
||||||
|
*
|
||||||
|
* @param strign $value
|
||||||
|
* @return boolean true if value is valid
|
||||||
|
*/
|
||||||
|
public static function isValid($value)
|
||||||
{
|
{
|
||||||
$values = array_values(self::getConstants());
|
$values = array_values(self::getConstants());
|
||||||
if (!in_array($value, $values, true)) {
|
return in_array($value, $values, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates that the value passed is a valid value
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @throws \InvalidArgumentException if the value passed is not valid for this enum
|
||||||
|
*/
|
||||||
|
public static function validate($value)
|
||||||
|
{
|
||||||
|
if (!self::isValid($value)) {
|
||||||
$calledClass = get_called_class();
|
$calledClass = get_called_class();
|
||||||
|
$values = array_values(self::getConstants());
|
||||||
throw new \InvalidArgumentException("$value is not a valid value for $calledClass, possible values are " . implode(', ', $values));
|
throw new \InvalidArgumentException("$value is not a valid value for $calledClass, possible values are " . implode(', ', $values));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -294,7 +294,6 @@ class OLERead
|
|||||||
|
|
||||||
$offset += self::PROPERTY_STORAGE_BLOCK_SIZE;
|
$offset += self::PROPERTY_STORAGE_BLOCK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
namespace PhpOffice\PhpWord\SimpleType;
|
namespace PhpOffice\PhpWord\SimpleType;
|
||||||
|
|
||||||
use Zend\Validator\InArray;
|
use PhpOffice\PhpWord\Shared\AbstractEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Horizontal Alignment Type.
|
* Horizontal Alignment Type.
|
||||||
@ -28,10 +28,11 @@ use Zend\Validator\InArray;
|
|||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @see \PhpOffice\PhpWord\SimpleType\JcTable For table alignment modes available since ISO/IEC-29500:2008.
|
* @see \PhpOffice\PhpWord\SimpleType\JcTable For table alignment modes available since ISO/IEC-29500:2008.
|
||||||
|
* @link http://www.datypic.com/sc/ooxml/t-w_ST_Jc.html
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
final class Jc
|
final class Jc extends AbstractEnum
|
||||||
{
|
{
|
||||||
const START = 'start';
|
const START = 'start';
|
||||||
const CENTER = 'center';
|
const CENTER = 'center';
|
||||||
@ -65,34 +66,4 @@ final class Jc
|
|||||||
* @deprecated 0.13.0 For documents based on ISO/IEC 29500:2008 and later use `BOTH` instead.
|
* @deprecated 0.13.0 For documents based on ISO/IEC 29500:2008 and later use `BOTH` instead.
|
||||||
*/
|
*/
|
||||||
const JUSTIFY = 'justify';
|
const JUSTIFY = 'justify';
|
||||||
|
|
||||||
/**
|
|
||||||
* @since 0.13.0
|
|
||||||
*
|
|
||||||
* @return \Zend\Validator\InArray
|
|
||||||
*/
|
|
||||||
final public static function getValidator()
|
|
||||||
{
|
|
||||||
// todo: consider caching validator instances.
|
|
||||||
return new InArray(
|
|
||||||
array (
|
|
||||||
'haystack' => array(
|
|
||||||
self::START,
|
|
||||||
self::CENTER,
|
|
||||||
self::END,
|
|
||||||
self::BOTH,
|
|
||||||
self::MEDIUM_KASHIDA,
|
|
||||||
self::DISTRIBUTE,
|
|
||||||
self::NUM_TAB,
|
|
||||||
self::HIGH_KASHIDA,
|
|
||||||
self::LOW_KASHIDA,
|
|
||||||
self::THAI_DISTRIBUTE,
|
|
||||||
self::LEFT,
|
|
||||||
self::RIGHT,
|
|
||||||
self::JUSTIFY,
|
|
||||||
),
|
|
||||||
'strict' => InArray::COMPARE_STRICT,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
namespace PhpOffice\PhpWord\SimpleType;
|
namespace PhpOffice\PhpWord\SimpleType;
|
||||||
|
|
||||||
use Zend\Validator\InArray;
|
use PhpOffice\PhpWord\Shared\AbstractEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table Alignment Type.
|
* Table Alignment Type.
|
||||||
@ -28,25 +28,9 @@ use Zend\Validator\InArray;
|
|||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
final class JcTable
|
final class JcTable extends AbstractEnum
|
||||||
{
|
{
|
||||||
const START = 'start';
|
const START = 'start';
|
||||||
const CENTER = 'center';
|
const CENTER = 'center';
|
||||||
const END = 'end';
|
const END = 'end';
|
||||||
|
|
||||||
/**
|
|
||||||
* @since 0.13.0
|
|
||||||
*
|
|
||||||
* @return \Zend\Validator\InArray
|
|
||||||
*/
|
|
||||||
final public static function getValidator()
|
|
||||||
{
|
|
||||||
// todo: consider caching validator instances.
|
|
||||||
return new InArray(
|
|
||||||
array (
|
|
||||||
'haystack' => array(self::START, self::CENTER, self::END),
|
|
||||||
'strict' => InArray::COMPARE_STRICT,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,8 +25,6 @@ use PhpOffice\PhpWord\Shared\AbstractEnum;
|
|||||||
* @since 0.14.0
|
* @since 0.14.0
|
||||||
*
|
*
|
||||||
* @see http://www.datypic.com/sc/ooxml/t-w_ST_NumberFormat.html.
|
* @see http://www.datypic.com/sc/ooxml/t-w_ST_NumberFormat.html.
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
final class NumberFormat extends AbstractEnum
|
final class NumberFormat extends AbstractEnum
|
||||||
{
|
{
|
||||||
|
|||||||
42
src/PhpWord/SimpleType/Zoom.php
Normal file
42
src/PhpWord/SimpleType/Zoom.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\SimpleType;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Shared\AbstractEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magnification Preset Values
|
||||||
|
*
|
||||||
|
* @since 0.14.0
|
||||||
|
*
|
||||||
|
* @see http://www.datypic.com/sc/ooxml/t-w_ST_Zoom.html
|
||||||
|
*/
|
||||||
|
final class Zoom extends AbstractEnum
|
||||||
|
{
|
||||||
|
//No Preset Magnification
|
||||||
|
const NONE = 'none';
|
||||||
|
|
||||||
|
//Display One Full Page
|
||||||
|
const FULL_PAGE = 'fullPage';
|
||||||
|
|
||||||
|
//Display Page Width
|
||||||
|
const BEST_FIT = 'bestFit';
|
||||||
|
|
||||||
|
//Display Text Width
|
||||||
|
const TEXT_FIT = 'textFit';
|
||||||
|
}
|
||||||
@ -329,7 +329,7 @@ abstract class AbstractStyle
|
|||||||
protected function setPairedVal(&$property, &$pairProperty, $value)
|
protected function setPairedVal(&$property, &$pairProperty, $value)
|
||||||
{
|
{
|
||||||
$property = $this->setBoolVal($value, $property);
|
$property = $this->setBoolVal($value, $property);
|
||||||
if ($value == true) {
|
if ($value === true) {
|
||||||
$pairProperty = false;
|
$pairProperty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -223,11 +223,17 @@ class Font extends AbstractStyle
|
|||||||
private $shading;
|
private $shading;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Right to left languages
|
* Right to left languages
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $rtl = false;
|
private $rtl = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Languages
|
||||||
|
* @var \PhpOffice\PhpWord\Style\Language
|
||||||
|
*/
|
||||||
|
private $lang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new font style
|
* Create new font style
|
||||||
*
|
*
|
||||||
@ -276,6 +282,7 @@ class Font extends AbstractStyle
|
|||||||
'paragraph' => $this->getParagraph(),
|
'paragraph' => $this->getParagraph(),
|
||||||
'rtl' => $this->isRTL(),
|
'rtl' => $this->isRTL(),
|
||||||
'shading' => $this->getShading(),
|
'shading' => $this->getShading(),
|
||||||
|
'lang' => $this->getLang(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $styles;
|
return $styles;
|
||||||
@ -783,6 +790,32 @@ class Font extends AbstractStyle
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get language
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Language
|
||||||
|
*/
|
||||||
|
public function getLang()
|
||||||
|
{
|
||||||
|
return $this->lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set language
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setLang($value = null)
|
||||||
|
{
|
||||||
|
if (is_string($value) && $value != '') {
|
||||||
|
$value = new Language($value);
|
||||||
|
}
|
||||||
|
$this->setObjectVal($value, 'Language', $this->lang);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get bold
|
* Get bold
|
||||||
*
|
*
|
||||||
|
|||||||
@ -200,7 +200,7 @@ class Frame extends AbstractStyle
|
|||||||
*/
|
*/
|
||||||
public function setAlignment($value)
|
public function setAlignment($value)
|
||||||
{
|
{
|
||||||
if (Jc::getValidator()->isValid($value)) {
|
if (Jc::isValid($value)) {
|
||||||
$this->alignment = $value;
|
$this->alignment = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
218
src/PhpWord/Style/Language.php
Normal file
218
src/PhpWord/Style/Language.php
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language
|
||||||
|
* A couple of predefined values are defined here, see the websites below for more values
|
||||||
|
*
|
||||||
|
* @see http://www.datypic.com/sc/ooxml/t-w_CT_Language.html
|
||||||
|
* @see https://technet.microsoft.com/en-us/library/cc287874(v=office.12).aspx
|
||||||
|
*/
|
||||||
|
final class Language extends AbstractStyle
|
||||||
|
{
|
||||||
|
|
||||||
|
const EN_US = 'en-US';
|
||||||
|
const EN_US_ID = 1033;
|
||||||
|
|
||||||
|
const EN_GB = 'en-GB';
|
||||||
|
const EN_GB_ID = 2057;
|
||||||
|
|
||||||
|
const FR_FR = 'fr-FR';
|
||||||
|
const FR_FR_ID = 1036;
|
||||||
|
|
||||||
|
const FR_BE = 'fr-BE';
|
||||||
|
const FR_BE_ID = 2060;
|
||||||
|
|
||||||
|
const ES_ES = 'es-ES';
|
||||||
|
const ES_ES_ID = 3082;
|
||||||
|
|
||||||
|
const DE_DE = 'de-DE';
|
||||||
|
const DE_DE_ID = 1031;
|
||||||
|
|
||||||
|
const HE_IL = 'he-IL';
|
||||||
|
const HE_IL_ID = 1037;
|
||||||
|
|
||||||
|
const JA_JP = 'ja-JP';
|
||||||
|
const JA_JP_ID = 1041;
|
||||||
|
|
||||||
|
const KO_KR = 'ko-KR';
|
||||||
|
const KO_KR_ID = 1042;
|
||||||
|
|
||||||
|
const ZH_CN = 'zh-CN';
|
||||||
|
const ZH_CN_ID = 2052;
|
||||||
|
|
||||||
|
const HI_IN = 'hi-IN';
|
||||||
|
const HI_IN_ID = 1081;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language ID, used for RTF document generation
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @see https://technet.microsoft.com/en-us/library/cc179219.aspx
|
||||||
|
*/
|
||||||
|
private $langId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Latin Language
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $latin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* East Asian Language
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $eastAsia;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complex Script Language
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $bidirectional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string|null $latin
|
||||||
|
* @param string|null $eastAsia
|
||||||
|
* @param string|null $bidirectional
|
||||||
|
*/
|
||||||
|
public function __construct($latin = null, $eastAsia = null, $bidirectional = null)
|
||||||
|
{
|
||||||
|
if (!empty($latin)) {
|
||||||
|
$this->setLatin($latin);
|
||||||
|
}
|
||||||
|
if (!empty($eastAsia)) {
|
||||||
|
$this->setEastAsia($eastAsia);
|
||||||
|
}
|
||||||
|
if (!empty($bidirectional)) {
|
||||||
|
$this->setBidirectional($bidirectional);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Latin Language
|
||||||
|
*
|
||||||
|
* @param string $latin
|
||||||
|
* The value for the latin language
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setLatin($latin)
|
||||||
|
{
|
||||||
|
$this->validateLocale($latin);
|
||||||
|
$this->latin = $latin;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Latin Language
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getLatin()
|
||||||
|
{
|
||||||
|
return $this->latin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Language ID
|
||||||
|
*
|
||||||
|
* @param int $langId
|
||||||
|
* The value for the language ID
|
||||||
|
* @return self
|
||||||
|
* @see https://technet.microsoft.com/en-us/library/cc287874(v=office.12).aspx
|
||||||
|
*/
|
||||||
|
public function setLangId($langId)
|
||||||
|
{
|
||||||
|
$this->langId = $langId;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Language ID
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getLangId()
|
||||||
|
{
|
||||||
|
return $this->langId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the East Asian Language
|
||||||
|
*
|
||||||
|
* @param string $eastAsia
|
||||||
|
* The value for the east asian language
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setEastAsia($eastAsia)
|
||||||
|
{
|
||||||
|
$this->validateLocale($eastAsia);
|
||||||
|
$this->eastAsia = $eastAsia;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the East Asian Language
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getEastAsia()
|
||||||
|
{
|
||||||
|
return $this->eastAsia;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Complex Script Language
|
||||||
|
*
|
||||||
|
* @param string $bidirectional
|
||||||
|
* The value for the complex script language
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setBidirectional($bidirectional)
|
||||||
|
{
|
||||||
|
$this->validateLocale($bidirectional);
|
||||||
|
$this->bidirectional = $bidirectional;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Complex Script Language
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getBidirectional()
|
||||||
|
{
|
||||||
|
return $this->bidirectional;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates that the language passed is in the format xx-xx
|
||||||
|
*
|
||||||
|
* @param string $locale
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private function validateLocale($locale)
|
||||||
|
{
|
||||||
|
if ($locale !== null && strstr($locale, '-') === false) {
|
||||||
|
throw new \InvalidArgumentException($locale . ' is not a valid language code');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -247,11 +247,12 @@ class ListItem extends AbstractStyle
|
|||||||
|
|
||||||
// Populate style and register to global Style register
|
// Populate style and register to global Style register
|
||||||
$style = $listTypeStyles[$this->listType];
|
$style = $listTypeStyles[$this->listType];
|
||||||
|
$numProperties = count($properties);
|
||||||
foreach ($style['levels'] as $key => $value) {
|
foreach ($style['levels'] as $key => $value) {
|
||||||
$level = array();
|
$level = array();
|
||||||
$levelProperties = explode(', ', $value);
|
$levelProperties = explode(', ', $value);
|
||||||
$level['level'] = $key;
|
$level['level'] = $key;
|
||||||
for ($i = 0; $i < count($properties); $i++) {
|
for ($i = 0; $i < $numProperties; $i++) {
|
||||||
$property = $properties[$i];
|
$property = $properties[$i];
|
||||||
$level[$property] = $levelProperties[$i];
|
$level[$property] = $levelProperties[$i];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,7 +85,7 @@ class NumberingLevel extends AbstractStyle
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Justification, w:lvlJc
|
* Justification, w:lvlJc
|
||||||
*
|
*
|
||||||
* @var string, one of PhpOffice\PhpWord\SimpleType\Jc
|
* @var string, one of PhpOffice\PhpWord\SimpleType\Jc
|
||||||
*/
|
*/
|
||||||
private $alignment = '';
|
private $alignment = '';
|
||||||
@ -300,7 +300,7 @@ class NumberingLevel extends AbstractStyle
|
|||||||
*/
|
*/
|
||||||
public function setAlignment($value)
|
public function setAlignment($value)
|
||||||
{
|
{
|
||||||
if (Jc::getValidator()->isValid($value)) {
|
if (Jc::isValid($value)) {
|
||||||
$this->alignment = $value;
|
$this->alignment = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -165,6 +165,13 @@ class Paragraph extends Border
|
|||||||
*/
|
*/
|
||||||
private $contextualSpacing = false;
|
private $contextualSpacing = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Right to Left Paragraph Layout
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $bidi = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Style value
|
* Set Style value
|
||||||
*
|
*
|
||||||
@ -216,6 +223,7 @@ class Paragraph extends Border
|
|||||||
'tabs' => $this->getTabs(),
|
'tabs' => $this->getTabs(),
|
||||||
'shading' => $this->getShading(),
|
'shading' => $this->getShading(),
|
||||||
'contextualSpacing' => $this->hasContextualSpacing(),
|
'contextualSpacing' => $this->hasContextualSpacing(),
|
||||||
|
'bidi' => $this->isBidi(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $styles;
|
return $styles;
|
||||||
@ -240,7 +248,7 @@ class Paragraph extends Border
|
|||||||
*/
|
*/
|
||||||
public function setAlignment($value)
|
public function setAlignment($value)
|
||||||
{
|
{
|
||||||
if (Jc::getValidator()->isValid($value)) {
|
if (Jc::isValid($value)) {
|
||||||
$this->alignment = $value;
|
$this->alignment = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,10 +747,10 @@ class Paragraph extends Border
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get contextualSpacing
|
* Get contextualSpacing
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasContextualSpacing()
|
public function hasContextualSpacing()
|
||||||
@ -752,7 +760,7 @@ class Paragraph extends Border
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set contextualSpacing
|
* Set contextualSpacing
|
||||||
*
|
*
|
||||||
* @param bool $contextualSpacing
|
* @param bool $contextualSpacing
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
@ -762,4 +770,28 @@ class Paragraph extends Border
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get bidirectional
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isBidi()
|
||||||
|
{
|
||||||
|
return $this->bidi;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set bidi
|
||||||
|
*
|
||||||
|
* @param bool $bidi
|
||||||
|
* Set to true to write from right to left
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setBidi($bidi)
|
||||||
|
{
|
||||||
|
$this->bidi = $bidi;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -510,7 +510,7 @@ class Table extends Border
|
|||||||
*/
|
*/
|
||||||
public function setAlignment($value)
|
public function setAlignment($value)
|
||||||
{
|
{
|
||||||
if (JcTable::getValidator()->isValid($value) || Jc::getValidator()->isValid($value)) {
|
if (JcTable::isValid($value) || Jc::isValid($value)) {
|
||||||
$this->alignment = $value;
|
$this->alignment = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -183,7 +183,8 @@ class TextBox extends Image
|
|||||||
{
|
{
|
||||||
$hasInnerMargins = false;
|
$hasInnerMargins = false;
|
||||||
$margins = $this->getInnerMargin();
|
$margins = $this->getInnerMargin();
|
||||||
for ($i = 0; $i < count($margins); $i++) {
|
$numMargins = count($margins);
|
||||||
|
for ($i = 0; $i < $numMargins; $i++) {
|
||||||
if ($margins[$i] !== null) {
|
if ($margins[$i] !== null) {
|
||||||
$hasInnerMargins = true;
|
$hasInnerMargins = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,7 +147,7 @@ class TemplateProcessor
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies XSL style sheet to template's parts.
|
* Applies XSL style sheet to template's parts.
|
||||||
*
|
*
|
||||||
* Note: since the method doesn't make any guess on logic of the provided XSL style sheet,
|
* Note: since the method doesn't make any guess on logic of the provided XSL style sheet,
|
||||||
* make sure that output is correctly escaped. Otherwise you may get broken document.
|
* make sure that output is correctly escaped. Otherwise you may get broken document.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -48,7 +48,7 @@ abstract class AbstractPart
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
|
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setParentWriter(AbstractWriter $writer = null)
|
public function setParentWriter(AbstractWriter $writer = null)
|
||||||
|
|||||||
@ -81,22 +81,27 @@ class Styles extends AbstractPart
|
|||||||
$xmlWriter->writeAttribute('style:writing-mode', 'page');
|
$xmlWriter->writeAttribute('style:writing-mode', 'page');
|
||||||
$xmlWriter->endElement(); // style:paragraph-properties
|
$xmlWriter->endElement(); // style:paragraph-properties
|
||||||
|
|
||||||
|
$language = $this->getParentWriter()->getPhpWord()->getSettings()->getThemeFontLang();
|
||||||
|
$latinLang = $language != null && is_string($language->getLatin()) ? explode('-', $language->getLatin()) : array('fr', 'FR');
|
||||||
|
$asianLang = $language != null && is_string($language->getEastAsia()) ? explode('-', $language->getEastAsia()) : array('zh', 'CN');
|
||||||
|
$complexLang = $language != null && is_string($language->getBidirectional()) ? explode('-', $language->getBidirectional()) : array('hi', 'IN');
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
$xmlWriter->startElement('style:text-properties');
|
$xmlWriter->startElement('style:text-properties');
|
||||||
$xmlWriter->writeAttribute('style:use-window-font-color', 'true');
|
$xmlWriter->writeAttribute('style:use-window-font-color', 'true');
|
||||||
$xmlWriter->writeAttribute('style:font-name', Settings::getDefaultFontName());
|
$xmlWriter->writeAttribute('style:font-name', Settings::getDefaultFontName());
|
||||||
$xmlWriter->writeAttribute('fo:font-size', Settings::getDefaultFontSize() . 'pt');
|
$xmlWriter->writeAttribute('fo:font-size', Settings::getDefaultFontSize() . 'pt');
|
||||||
$xmlWriter->writeAttribute('fo:language', 'fr');
|
$xmlWriter->writeAttribute('fo:language', $latinLang[0]);
|
||||||
$xmlWriter->writeAttribute('fo:country', 'FR');
|
$xmlWriter->writeAttribute('fo:country', $latinLang[1]);
|
||||||
$xmlWriter->writeAttribute('style:letter-kerning', 'true');
|
$xmlWriter->writeAttribute('style:letter-kerning', 'true');
|
||||||
$xmlWriter->writeAttribute('style:font-name-asian', Settings::getDefaultFontName() . '2');
|
$xmlWriter->writeAttribute('style:font-name-asian', Settings::getDefaultFontName() . '2');
|
||||||
$xmlWriter->writeAttribute('style:font-size-asian', Settings::getDefaultFontSize() . 'pt');
|
$xmlWriter->writeAttribute('style:font-size-asian', Settings::getDefaultFontSize() . 'pt');
|
||||||
$xmlWriter->writeAttribute('style:language-asian', 'zh');
|
$xmlWriter->writeAttribute('style:language-asian', $asianLang[0]);
|
||||||
$xmlWriter->writeAttribute('style:country-asian', 'CN');
|
$xmlWriter->writeAttribute('style:country-asian', $asianLang[1]);
|
||||||
$xmlWriter->writeAttribute('style:font-name-complex', Settings::getDefaultFontName() . '2');
|
$xmlWriter->writeAttribute('style:font-name-complex', Settings::getDefaultFontName() . '2');
|
||||||
$xmlWriter->writeAttribute('style:font-size-complex', Settings::getDefaultFontSize() . 'pt');
|
$xmlWriter->writeAttribute('style:font-size-complex', Settings::getDefaultFontSize() . 'pt');
|
||||||
$xmlWriter->writeAttribute('style:language-complex', 'hi');
|
$xmlWriter->writeAttribute('style:language-complex', $complexLang[0]);
|
||||||
$xmlWriter->writeAttribute('style:country-complex', 'IN');
|
$xmlWriter->writeAttribute('style:country-complex', $complexLang[1]);
|
||||||
$xmlWriter->writeAttribute('fo:hyphenate', 'false');
|
$xmlWriter->writeAttribute('fo:hyphenate', 'false');
|
||||||
$xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
|
$xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
|
||||||
$xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
|
$xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
|
||||||
|
|||||||
@ -48,7 +48,7 @@ abstract class AbstractPart
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
|
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setParentWriter(AbstractWriter $writer = null)
|
public function setParentWriter(AbstractWriter $writer = null)
|
||||||
|
|||||||
@ -86,6 +86,10 @@ class Document extends AbstractPart
|
|||||||
*/
|
*/
|
||||||
private function writeFormatting()
|
private function writeFormatting()
|
||||||
{
|
{
|
||||||
|
$docSettings = $this->getParentWriter()->getPhpWord()->getSettings();
|
||||||
|
// Applies a language to a text run (defaults to 1036 : French (France))
|
||||||
|
$langId = $docSettings->getThemeFontLang() != null && $docSettings->getThemeFontLang()->getLangId() != null ? $docSettings->getThemeFontLang()->getLangId() : 1036;
|
||||||
|
|
||||||
$content = '';
|
$content = '';
|
||||||
|
|
||||||
$content .= '\deftab720'; // Set the default tab size (720 twips)
|
$content .= '\deftab720'; // Set the default tab size (720 twips)
|
||||||
@ -94,7 +98,7 @@ class Document extends AbstractPart
|
|||||||
$content .= '\uc1'; // Set the numberof bytes that follows a unicode character
|
$content .= '\uc1'; // Set the numberof bytes that follows a unicode character
|
||||||
$content .= '\pard'; // Resets to default paragraph properties.
|
$content .= '\pard'; // Resets to default paragraph properties.
|
||||||
$content .= '\nowidctlpar'; // No widow/orphan control
|
$content .= '\nowidctlpar'; // No widow/orphan control
|
||||||
$content .= '\lang1036'; // Applies a language to a text run (1036 : French (France))
|
$content .= '\lang' . $langId;
|
||||||
$content .= '\kerning1'; // Point size (in half-points) above which to kern character pairs
|
$content .= '\kerning1'; // Point size (in half-points) above which to kern character pairs
|
||||||
$content .= '\fs' . (Settings::getDefaultFontSize() * 2); // Set the font size in half-points
|
$content .= '\fs' . (Settings::getDefaultFontSize() * 2); // Set the font size in half-points
|
||||||
$content .= PHP_EOL;
|
$content .= PHP_EOL;
|
||||||
|
|||||||
@ -134,7 +134,6 @@ abstract class AbstractElement
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->xmlWriter->writeElementBlock('w:commentRangeStart', array('w:id' => $comment->getElementId()));
|
$this->xmlWriter->writeElementBlock('w:commentRangeStart', array('w:id' => $comment->getElementId()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -213,7 +213,6 @@ class Chart extends AbstractPart
|
|||||||
$xmlWriter->endElement(); // c:ser
|
$xmlWriter->endElement(); // c:ser
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Settings as DocumentSettings;
|
use PhpOffice\PhpWord\ComplexType\ProofState;
|
||||||
|
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
||||||
|
use PhpOffice\PhpWord\Style\Language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Word2007 settings part writer: word/settings.xml
|
* Word2007 settings part writer: word/settings.xml
|
||||||
@ -99,17 +101,16 @@ class Settings extends AbstractPart
|
|||||||
*/
|
*/
|
||||||
private function getSettings()
|
private function getSettings()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var \PhpOffice\PhpWord\Metadata\Settings $documentSettings */
|
||||||
|
$documentSettings = $this->getParentWriter()->getPhpWord()->getSettings();
|
||||||
|
|
||||||
// Default settings
|
// Default settings
|
||||||
$this->settings = array(
|
$this->settings = array(
|
||||||
'w:zoom' => array('@attributes' => array('w:percent' => '100')),
|
|
||||||
'w:defaultTabStop' => array('@attributes' => array('w:val' => '708')),
|
'w:defaultTabStop' => array('@attributes' => array('w:val' => '708')),
|
||||||
'w:hyphenationZone' => array('@attributes' => array('w:val' => '425')),
|
'w:hyphenationZone' => array('@attributes' => array('w:val' => '425')),
|
||||||
'w:characterSpacingControl' => array('@attributes' => array('w:val' => 'doNotCompress')),
|
'w:characterSpacingControl' => array('@attributes' => array('w:val' => 'doNotCompress')),
|
||||||
'w:evenAndOddHeaders' => array('@attributes' => array('w:val' => DocumentSettings::isEvenAndOddHeaders() ? 'true': 'false')),
|
'w:decimalSymbol' => array('@attributes' => array('w:val' => $documentSettings->getDecimalSymbol())),
|
||||||
'w:themeFontLang' => array('@attributes' => array('w:val' => 'en-US')),
|
|
||||||
'w:hideSpellingErrors' => array('@attributes' => array('w:val' => DocumentSettings::isSpellingErrorsHidden() ? 'true' : 'false')),
|
|
||||||
'w:hideGrammaticalErrors' => array('@attributes' => array('w:val' => DocumentSettings::isGrammaticalErrorsHidden() ? 'true' : 'false')),
|
|
||||||
'w:decimalSymbol' => array('@attributes' => array('w:val' => '.')),
|
|
||||||
'w:listSeparator' => array('@attributes' => array('w:val' => ';')),
|
'w:listSeparator' => array('@attributes' => array('w:val' => ';')),
|
||||||
'w:compat' => array(),
|
'w:compat' => array(),
|
||||||
'm:mathPr' => array(
|
'm:mathPr' => array(
|
||||||
@ -143,29 +144,121 @@ class Settings extends AbstractPart
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Other settings
|
$this->setOnOffValue('w:hideSpellingErrors', $documentSettings->hasHideSpellingErrors());
|
||||||
$this->getProtection();
|
$this->setOnOffValue('w:hideGrammaticalErrors', $documentSettings->hasHideGrammaticalErrors());
|
||||||
|
$this->setOnOffValue('w:trackRevisions', $documentSettings->hasTrackRevisions());
|
||||||
|
$this->setOnOffValue('w:doNotTrackMoves', $documentSettings->hasDoNotTrackMoves());
|
||||||
|
$this->setOnOffValue('w:doNotTrackFormatting', $documentSettings->hasDoNotTrackFormatting());
|
||||||
|
$this->setOnOffValue('w:evenAndOddHeaders', $documentSettings->hasEvenAndOddHeaders());
|
||||||
|
|
||||||
|
$this->setThemeFontLang($documentSettings->getThemeFontLang());
|
||||||
|
$this->setRevisionView($documentSettings->getRevisionView());
|
||||||
|
$this->setDocumentProtection($documentSettings->getDocumentProtection());
|
||||||
|
$this->setProofState($documentSettings->getProofState());
|
||||||
|
$this->setZoom($documentSettings->getZoom());
|
||||||
$this->getCompatibility();
|
$this->getCompatibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a boolean attribute to the settings array
|
||||||
|
*
|
||||||
|
* @param string $settingName
|
||||||
|
* @param boolean $booleanValue
|
||||||
|
*/
|
||||||
|
private function setOnOffValue($settingName, $booleanValue)
|
||||||
|
{
|
||||||
|
if ($booleanValue !== null && is_bool($booleanValue)) {
|
||||||
|
if ($booleanValue) {
|
||||||
|
$this->settings[$settingName] = array('@attributes' => array());
|
||||||
|
} else {
|
||||||
|
$this->settings[$settingName] = array('@attributes' => array('w:val' => 'false'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get protection settings.
|
* Get protection settings.
|
||||||
*
|
*
|
||||||
|
* @param \PhpOffice\PhpWord\Metadata\Protection $documentProtection
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function getProtection()
|
private function setDocumentProtection($documentProtection)
|
||||||
{
|
{
|
||||||
$protection = $this->getParentWriter()->getPhpWord()->getProtection();
|
if ($documentProtection != null && $documentProtection->getEditing() !== null) {
|
||||||
if ($protection->getEditing() !== null) {
|
|
||||||
$this->settings['w:documentProtection'] = array(
|
$this->settings['w:documentProtection'] = array(
|
||||||
'@attributes' => array(
|
'@attributes' => array(
|
||||||
'w:enforcement' => 1,
|
'w:enforcement' => 1,
|
||||||
'w:edit' => $protection->getEditing(),
|
'w:edit' => $documentProtection->getEditing(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Proof state
|
||||||
|
*
|
||||||
|
* @param ProofState $proofState
|
||||||
|
*/
|
||||||
|
private function setProofState(ProofState $proofState = null)
|
||||||
|
{
|
||||||
|
if ($proofState != null && $proofState->getGrammar() !== null && $proofState->getSpelling() !== null) {
|
||||||
|
$this->settings['w:proofState'] = array(
|
||||||
|
'@attributes' => array(
|
||||||
|
'w:spelling' => $proofState->getSpelling(),
|
||||||
|
'w:grammar' => $proofState->getGrammar()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Revision View
|
||||||
|
*
|
||||||
|
* @param TrackChangesView $trackChangesView
|
||||||
|
*/
|
||||||
|
private function setRevisionView(TrackChangesView $trackChangesView = null)
|
||||||
|
{
|
||||||
|
if ($trackChangesView != null) {
|
||||||
|
$revisionView['w:markup'] = $trackChangesView->hasMarkup() ? 'true': 'false';
|
||||||
|
$revisionView['w:comments'] = $trackChangesView->hasComments() ? 'true': 'false';
|
||||||
|
$revisionView['w:insDel'] = $trackChangesView->hasInsDel() ? 'true': 'false';
|
||||||
|
$revisionView['w:formatting'] = $trackChangesView->hasFormatting() ? 'true': 'false';
|
||||||
|
$revisionView['w:inkAnnotations'] = $trackChangesView->hasInkAnnotations() ? 'true': 'false';
|
||||||
|
|
||||||
|
$this->settings['w:revisionView'] = array('@attributes' => $revisionView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the language
|
||||||
|
*
|
||||||
|
* @param Language $language
|
||||||
|
*/
|
||||||
|
private function setThemeFontLang(Language $language = null)
|
||||||
|
{
|
||||||
|
$latinLanguage = ($language == null || $language->getLatin() === null) ? 'en-US' : $language->getLatin();
|
||||||
|
$lang = array();
|
||||||
|
$lang['w:val'] = $latinLanguage;
|
||||||
|
if ($language != null) {
|
||||||
|
$lang['w:eastAsia'] = $language->getEastAsia() === null ? 'x-none' : $language->getEastAsia();
|
||||||
|
$lang['w:bidi'] = $language->getBidirectional() === null ? 'x-none' : $language->getBidirectional();
|
||||||
|
}
|
||||||
|
$this->settings['w:themeFontLang'] = array('@attributes' => $lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the magnification
|
||||||
|
*
|
||||||
|
* @param mixed $zoom
|
||||||
|
*/
|
||||||
|
private function setZoom($zoom = null)
|
||||||
|
{
|
||||||
|
if ($zoom !== null) {
|
||||||
|
$attr = is_int($zoom) ? 'w:percent' : 'w:val';
|
||||||
|
$this->settings['w:zoom'] = array('@attributes' => array($attr => $zoom));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get compatibility setting.
|
* Get compatibility setting.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -85,6 +85,8 @@ class Styles extends AbstractPart
|
|||||||
{
|
{
|
||||||
$fontName = PhpWordSettings::getDefaultFontName();
|
$fontName = PhpWordSettings::getDefaultFontName();
|
||||||
$fontSize = PhpWordSettings::getDefaultFontSize();
|
$fontSize = PhpWordSettings::getDefaultFontSize();
|
||||||
|
$language = $this->getParentWriter()->getPhpWord()->getSettings()->getThemeFontLang();
|
||||||
|
$latinLanguage = ($language == null || $language->getLatin() === null) ? 'en-US' : $language->getLatin();
|
||||||
|
|
||||||
// Default font
|
// Default font
|
||||||
$xmlWriter->startElement('w:docDefaults');
|
$xmlWriter->startElement('w:docDefaults');
|
||||||
@ -102,6 +104,13 @@ class Styles extends AbstractPart
|
|||||||
$xmlWriter->startElement('w:szCs');
|
$xmlWriter->startElement('w:szCs');
|
||||||
$xmlWriter->writeAttribute('w:val', $fontSize * 2);
|
$xmlWriter->writeAttribute('w:val', $fontSize * 2);
|
||||||
$xmlWriter->endElement(); // w:szCs
|
$xmlWriter->endElement(); // w:szCs
|
||||||
|
$xmlWriter->startElement('w:lang');
|
||||||
|
$xmlWriter->writeAttribute('w:val', $latinLanguage);
|
||||||
|
if ($language != null) {
|
||||||
|
$xmlWriter->writeAttributeIf($language->getEastAsia() !== null, 'w:eastAsia', $language->getEastAsia());
|
||||||
|
$xmlWriter->writeAttributeIf($language->getBidirectional() !== null, 'w:bidi', $language->getBidirectional());
|
||||||
|
}
|
||||||
|
$xmlWriter->endElement(); // w:lang
|
||||||
$xmlWriter->endElement(); // w:rPr
|
$xmlWriter->endElement(); // w:rPr
|
||||||
$xmlWriter->endElement(); // w:rPrDefault
|
$xmlWriter->endElement(); // w:rPrDefault
|
||||||
$xmlWriter->endElement(); // w:docDefaults
|
$xmlWriter->endElement(); // w:docDefaults
|
||||||
|
|||||||
@ -71,7 +71,7 @@ abstract class AbstractStyle
|
|||||||
/**
|
/**
|
||||||
* Get Style
|
* Get Style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\AbstractStyle
|
* @return string|\PhpOffice\PhpWord\Style\AbstractStyle
|
||||||
*/
|
*/
|
||||||
protected function getStyle()
|
protected function getStyle()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -86,6 +86,16 @@ class Font extends AbstractStyle
|
|||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Language
|
||||||
|
$language = $style->getLang();
|
||||||
|
if ($language != null && ($language->getLatin() !== null || $language->getEastAsia() !== null || $language->getBidirectional() !== null)) {
|
||||||
|
$xmlWriter->startElement('w:lang');
|
||||||
|
$xmlWriter->writeAttributeIf($language->getLatin() !== null, 'w:val', $language->getLatin());
|
||||||
|
$xmlWriter->writeAttributeIf($language->getEastAsia() !== null, 'w:eastAsia', $language->getEastAsia());
|
||||||
|
$xmlWriter->writeAttributeIf($language->getBidirectional() !== null, 'w:bidi', $language->getBidirectional());
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
$color = $style->getColor();
|
$color = $style->getColor();
|
||||||
$xmlWriter->writeElementIf($color !== null, 'w:color', 'w:val', $color);
|
$xmlWriter->writeElementIf($color !== null, 'w:color', 'w:val', $color);
|
||||||
|
|||||||
@ -106,7 +106,10 @@ class Paragraph extends AbstractStyle
|
|||||||
}
|
}
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Right to left
|
||||||
|
$xmlWriter->writeElementIf($styles['bidi'] === true, 'w:bidi');
|
||||||
|
|
||||||
//Paragraph contextualSpacing
|
//Paragraph contextualSpacing
|
||||||
$xmlWriter->writeElementIf($styles['contextualSpacing'] === true, 'w:contextualSpacing');
|
$xmlWriter->writeElementIf($styles['contextualSpacing'] === true, 'w:contextualSpacing');
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,9 @@ use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
|
|||||||
use PhpOffice\PhpWord\SimpleType\NumberFormat;
|
use PhpOffice\PhpWord\SimpleType\NumberFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for PhpOffice\PhpWord\SimpleType\FootnoteProperties
|
* Test class for PhpOffice\PhpWord\ComplexType\FootnoteProperties
|
||||||
*
|
*
|
||||||
* @coversDefaultClass \PhpOffice\PhpWord\SimpleType\FootnoteProperties
|
* @coversDefaultClass \PhpOffice\PhpWord\ComplexType\FootnoteProperties
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
|
class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -47,7 +47,7 @@ class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test throws exception if wrong position given
|
* Test throws exception if wrong position given
|
||||||
*
|
*
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testWrongPos()
|
public function testWrongPos()
|
||||||
@ -58,7 +58,7 @@ class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test throws exception if wrong number format given
|
* Test throws exception if wrong number format given
|
||||||
*
|
*
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testWrongNumFmt()
|
public function testWrongNumFmt()
|
||||||
@ -69,7 +69,7 @@ class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test throws exception if wrong number restart given
|
* Test throws exception if wrong number restart given
|
||||||
*
|
*
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testWrongNumRestart()
|
public function testWrongNumRestart()
|
||||||
|
|||||||
61
tests/PhpWord/ComplexType/ProofStateTest.php
Normal file
61
tests/PhpWord/ComplexType/ProofStateTest.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
namespace PhpOffice\PhpWord\ComplexType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for PhpOffice\PhpWord\ComplexType\ProofState
|
||||||
|
*
|
||||||
|
* @coversDefaultClass \PhpOffice\PhpWord\ComplexType\ProofState
|
||||||
|
*/
|
||||||
|
class ProofStateTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getters and setters
|
||||||
|
*/
|
||||||
|
public function testGetSet()
|
||||||
|
{
|
||||||
|
$pState= new ProofState();
|
||||||
|
$pState->setGrammar(ProofState::CLEAN);
|
||||||
|
$pState->setSpelling(ProofState::DIRTY);
|
||||||
|
|
||||||
|
$this->assertEquals(ProofState::CLEAN, $pState->getGrammar());
|
||||||
|
$this->assertEquals(ProofState::DIRTY, $pState->getSpelling());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test throws exception if wrong grammar proof state value given
|
||||||
|
*
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testWrongGrammar()
|
||||||
|
{
|
||||||
|
$pState = new ProofState();
|
||||||
|
$pState->setGrammar('Wrong');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test throws exception if wrong spelling proof state value given
|
||||||
|
*
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testWrongSpelling()
|
||||||
|
{
|
||||||
|
$pState= new ProofState();
|
||||||
|
$pState->setSpelling('Wrong');
|
||||||
|
}
|
||||||
|
}
|
||||||
138
tests/PhpWord/Metadata/SettingsTest.php
Normal file
138
tests/PhpWord/Metadata/SettingsTest.php
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Metadata;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\ComplexType\ProofState;
|
||||||
|
use PhpOffice\PhpWord\SimpleType\Zoom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for PhpOffice\PhpWord\Metadata\Settings
|
||||||
|
*
|
||||||
|
* @runTestsInSeparateProcesses
|
||||||
|
*/
|
||||||
|
class SettingsTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* EvenAndOddHeaders
|
||||||
|
*/
|
||||||
|
public function testSetEvenAndOddHeaders()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setEvenAndOddHeaders(true);
|
||||||
|
$this->assertEquals(true, $oSettings->hasEvenAndOddHeaders());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HideGrammaticalErrors
|
||||||
|
*/
|
||||||
|
public function testHideGrammaticalErrors()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setHideGrammaticalErrors(true);
|
||||||
|
$this->assertEquals(true, $oSettings->hasHideGrammaticalErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HideSpellingErrors
|
||||||
|
*/
|
||||||
|
public function testHideSpellingErrors()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setHideSpellingErrors(true);
|
||||||
|
$this->assertEquals(true, $oSettings->hasHideSpellingErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DocumentProtection
|
||||||
|
*/
|
||||||
|
public function testDocumentProtection()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setDocumentProtection(new Protection());
|
||||||
|
$this->assertNotNull($oSettings->getDocumentProtection());
|
||||||
|
|
||||||
|
$oSettings->getDocumentProtection()->setEditing('trackedChanges');
|
||||||
|
$this->assertEquals('trackedChanges', $oSettings->getDocumentProtection()->getEditing());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TrackRevistions
|
||||||
|
*/
|
||||||
|
public function testTrackRevisions()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setTrackRevisions(true);
|
||||||
|
$this->assertEquals(true, $oSettings->hasTrackRevisions());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DoNotTrackFormatting
|
||||||
|
*/
|
||||||
|
public function testDoNotTrackFormatting()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setDoNotTrackFormatting(true);
|
||||||
|
$this->assertEquals(true, $oSettings->hasDoNotTrackFormatting());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DoNotTrackMoves
|
||||||
|
*/
|
||||||
|
public function testDoNotTrackMoves()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setDoNotTrackMoves(true);
|
||||||
|
$this->assertEquals(true, $oSettings->hasDoNotTrackMoves());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProofState
|
||||||
|
*/
|
||||||
|
public function testProofState()
|
||||||
|
{
|
||||||
|
$proofState = new ProofState();
|
||||||
|
$proofState->setGrammar(ProofState::CLEAN);
|
||||||
|
$proofState->setSpelling(ProofState::DIRTY);
|
||||||
|
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setProofState($proofState);
|
||||||
|
$this->assertNotNull($oSettings->getProofState());
|
||||||
|
$this->assertEquals(ProofState::CLEAN, $oSettings->getProofState()->getGrammar());
|
||||||
|
$this->assertEquals(ProofState::DIRTY, $oSettings->getProofState()->getSpelling());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zoom as percentage
|
||||||
|
*/
|
||||||
|
public function testZoomPercentage()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setZoom(75);
|
||||||
|
$this->assertEquals(75, $oSettings->getZoom());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zoom as string
|
||||||
|
*/
|
||||||
|
public function testZoomEnum()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setZoom(Zoom::FULL_PAGE);
|
||||||
|
$this->assertEquals('fullPage', $oSettings->getZoom());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -99,7 +99,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
|||||||
$phpWord->$method($styleId, array());
|
$phpWord->$method($styleId, array());
|
||||||
$this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$value}", Style::getStyle($styleId));
|
$this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$value}", Style::getStyle($styleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
59
tests/PhpWord/Reader/MsDocTest.php
Normal file
59
tests/PhpWord/Reader/MsDocTest.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Reader;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\IOFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for PhpOffice\PhpWord\Reader\MsDoc
|
||||||
|
*
|
||||||
|
* @coversDefaultClass \PhpOffice\PhpWord\Reader\MsDoc
|
||||||
|
* @runTestsInSeparateProcesses
|
||||||
|
*/
|
||||||
|
class MsDocTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test canRead() method
|
||||||
|
*/
|
||||||
|
public function testCanRead()
|
||||||
|
{
|
||||||
|
$object = new MsDoc();
|
||||||
|
$filename = __DIR__ . '/../_files/documents/reader.doc';
|
||||||
|
$this->assertTrue($object->canRead($filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can read exception
|
||||||
|
*/
|
||||||
|
public function testCanReadFailed()
|
||||||
|
{
|
||||||
|
$object = new MsDoc();
|
||||||
|
$filename = __DIR__ . '/../_files/documents/foo.doc';
|
||||||
|
$this->assertFalse($object->canRead($filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load
|
||||||
|
*/
|
||||||
|
public function testLoad()
|
||||||
|
{
|
||||||
|
$filename = __DIR__ . '/../_files/documents/reader.doc';
|
||||||
|
$phpWord = IOFactory::load($filename, 'MsDoc');
|
||||||
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $phpWord);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -114,30 +114,6 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertFalse(Settings::setDefaultFontSize(null));
|
$this->assertFalse(Settings::setDefaultFontSize(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test set/get spelling and grammar
|
|
||||||
*/
|
|
||||||
public function testSetGetSpellingGrammar()
|
|
||||||
{
|
|
||||||
$this->assertFalse(Settings::isSpellingErrorsHidden());
|
|
||||||
Settings::setSpellingErrorsHidden(true);
|
|
||||||
$this->assertTrue(Settings::isSpellingErrorsHidden());
|
|
||||||
|
|
||||||
$this->assertFalse(Settings::isGrammaticalErrorsHidden());
|
|
||||||
Settings::setGrammaticalErrorsHidden(true);
|
|
||||||
$this->assertTrue(Settings::isGrammaticalErrorsHidden());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test set/get even and odd headers
|
|
||||||
*/
|
|
||||||
public function testSetGetEvenAndOddHeaders()
|
|
||||||
{
|
|
||||||
$this->assertFalse(Settings::isEvenAndOddHeaders());
|
|
||||||
Settings::setEvenAndOddHeaders(true);
|
|
||||||
$this->assertTrue(Settings::isEvenAndOddHeaders());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test load config
|
* Test load config
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -74,6 +74,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
|
|||||||
'scale' => null,
|
'scale' => null,
|
||||||
'spacing' => null,
|
'spacing' => null,
|
||||||
'kerning' => null,
|
'kerning' => null,
|
||||||
|
'lang' => null,
|
||||||
);
|
);
|
||||||
foreach ($attributes as $key => $default) {
|
foreach ($attributes as $key => $default) {
|
||||||
$get = is_bool($default) ? "is{$key}" : "get{$key}";
|
$get = is_bool($default) ? "is{$key}" : "get{$key}";
|
||||||
|
|||||||
62
tests/PhpWord/Style/LanguageTest.php
Normal file
62
tests/PhpWord/Style/LanguageTest.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?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-2016 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for PhpOffice\PhpWord\Style\Language
|
||||||
|
*
|
||||||
|
* @coversDefaultClass \PhpOffice\PhpWord\Style\Language
|
||||||
|
*/
|
||||||
|
class LanguageTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test get/set
|
||||||
|
*/
|
||||||
|
public function testGetSetProperties()
|
||||||
|
{
|
||||||
|
$object = new Language();
|
||||||
|
$properties = array(
|
||||||
|
'latin' => array(null, 'fr-BE'),
|
||||||
|
'eastAsia' => array(null, 'ja-JP'),
|
||||||
|
'bidirectional' => array(null, 'ar-SA'),
|
||||||
|
'langId' => array(null, 1036),
|
||||||
|
);
|
||||||
|
foreach ($properties as $property => $value) {
|
||||||
|
list($default, $expected) = $value;
|
||||||
|
$get = "get{$property}";
|
||||||
|
$set = "set{$property}";
|
||||||
|
|
||||||
|
$this->assertEquals($default, $object->$get()); // Default value
|
||||||
|
|
||||||
|
$object->$set($expected);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $object->$get()); // New value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test throws exception if wrong locale is given
|
||||||
|
*
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testWrongLanguage()
|
||||||
|
{
|
||||||
|
$language = new Language();
|
||||||
|
$language->setLatin('fr');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -80,6 +80,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
|
|||||||
'keepLines' => true,
|
'keepLines' => true,
|
||||||
'pageBreakBefore' => true,
|
'pageBreakBefore' => true,
|
||||||
'contextualSpacing' => true,
|
'contextualSpacing' => true,
|
||||||
|
'bidi' => true,
|
||||||
);
|
);
|
||||||
foreach ($attributes as $key => $value) {
|
foreach ($attributes as $key => $value) {
|
||||||
$get = $this->findGetter($key, $value, $object);
|
$get = $this->findGetter($key, $value, $object);
|
||||||
|
|||||||
@ -16,9 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
use PhpOffice\PhpWord\TestHelperDOCX;
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
use PhpOffice\PhpWord\SimpleType\Zoom;
|
||||||
|
use PhpOffice\PhpWord\Style\Language;
|
||||||
|
use PhpOffice\PhpWord\TestHelperDOCX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Settings
|
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Settings
|
||||||
@ -41,7 +44,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testDocumentProtection()
|
public function testDocumentProtection()
|
||||||
{
|
{
|
||||||
$phpWord = new PhpWord();
|
$phpWord = new PhpWord();
|
||||||
$phpWord->getProtection()->setEditing('forms');
|
$phpWord->getSettings()->getDocumentProtection()->setEditing('forms');
|
||||||
|
|
||||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
@ -71,7 +74,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Test language
|
* Test language
|
||||||
*/
|
*/
|
||||||
public function testLanguage()
|
public function testDefaultLanguage()
|
||||||
{
|
{
|
||||||
$phpWord = new PhpWord();
|
$phpWord = new PhpWord();
|
||||||
|
|
||||||
@ -86,13 +89,33 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('en-US', $element->getAttribute('w:val'));
|
$this->assertEquals('en-US', $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test language
|
||||||
|
*/
|
||||||
|
public function testLanguage()
|
||||||
|
{
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$phpWord->getSettings()->setThemeFontLang(new Language(Language::DE_DE, Language::KO_KR, Language::HE_IL));
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$file = 'word/settings.xml';
|
||||||
|
|
||||||
|
$path = '/w:settings/w:themeFontLang';
|
||||||
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
$element = $doc->getElement($path, $file);
|
||||||
|
|
||||||
|
$this->assertEquals(Language::DE_DE, $element->getAttribute('w:val'));
|
||||||
|
$this->assertEquals(Language::KO_KR, $element->getAttribute('w:eastAsia'));
|
||||||
|
$this->assertEquals(Language::HE_IL, $element->getAttribute('w:bidi'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test spelling
|
* Test spelling
|
||||||
*/
|
*/
|
||||||
public function testSpelling()
|
public function testSpelling()
|
||||||
{
|
{
|
||||||
$phpWord = new PhpWord();
|
$phpWord = new PhpWord();
|
||||||
Settings::setSpellingErrorsHidden(true);
|
$phpWord->getSettings()->setHideSpellingErrors(true);
|
||||||
|
|
||||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
@ -102,7 +125,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($doc->elementExists($path, $file));
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
$element = $doc->getElement($path, $file);
|
$element = $doc->getElement($path, $file);
|
||||||
|
|
||||||
$this->assertEquals('true', $element->getAttribute('w:val'));
|
$this->assertNotEquals('false', $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +134,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testEvenAndOddHeaders()
|
public function testEvenAndOddHeaders()
|
||||||
{
|
{
|
||||||
$phpWord = new PhpWord();
|
$phpWord = new PhpWord();
|
||||||
Settings::setEvenAndOddHeaders(true);
|
$phpWord->getSettings()->setEvenAndOddHeaders(true);
|
||||||
|
|
||||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
@ -121,6 +144,125 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($doc->elementExists($path, $file));
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
|
||||||
$element = $doc->getElement($path, $file);
|
$element = $doc->getElement($path, $file);
|
||||||
$this->assertEquals('true', $element->getAttribute('w:val'));
|
$this->assertNotEquals('false', $element->getAttribute('w:val'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test zoom percentage
|
||||||
|
*/
|
||||||
|
public function testZoomPercentage()
|
||||||
|
{
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$phpWord->getSettings()->setZoom(75);
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$file = 'word/settings.xml';
|
||||||
|
|
||||||
|
$path = '/w:settings/w:zoom';
|
||||||
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
|
||||||
|
$element = $doc->getElement($path, $file);
|
||||||
|
$this->assertEquals('75', $element->getAttribute('w:percent'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test zoom value
|
||||||
|
*/
|
||||||
|
public function testZoomValue()
|
||||||
|
{
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$phpWord->getSettings()->setZoom(Zoom::FULL_PAGE);
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$file = 'word/settings.xml';
|
||||||
|
|
||||||
|
$path = '/w:settings/w:zoom';
|
||||||
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
|
||||||
|
$element = $doc->getElement($path, $file);
|
||||||
|
$this->assertEquals('fullPage', $element->getAttribute('w:val'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Revision View
|
||||||
|
*/
|
||||||
|
public function testRevisionView()
|
||||||
|
{
|
||||||
|
$trackChangesView = new TrackChangesView();
|
||||||
|
$trackChangesView->setFormatting(false);
|
||||||
|
$trackChangesView->setComments(true);
|
||||||
|
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$phpWord->getSettings()->setRevisionView($trackChangesView);
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$file = 'word/settings.xml';
|
||||||
|
|
||||||
|
$path = '/w:settings/w:revisionView';
|
||||||
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
|
||||||
|
$element = $doc->getElement($path, $file);
|
||||||
|
$this->assertEquals('false', $element->getAttribute('w:formatting'));
|
||||||
|
$this->assertEquals('true', $element->getAttribute('w:comments'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test track Revisions
|
||||||
|
*/
|
||||||
|
public function testTrackRevisions()
|
||||||
|
{
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$phpWord->getSettings()->setTrackRevisions(true);
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$file = 'word/settings.xml';
|
||||||
|
|
||||||
|
$path = '/w:settings/w:trackRevisions';
|
||||||
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
|
||||||
|
$element = $doc->getElement($path, $file);
|
||||||
|
$this->assertNotEquals('false', $element->getAttribute('w:val'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test doNotTrackMoves
|
||||||
|
*/
|
||||||
|
public function testDoNotTrackMoves()
|
||||||
|
{
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$phpWord->getSettings()->setDoNotTrackMoves(true);
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$file = 'word/settings.xml';
|
||||||
|
|
||||||
|
$path = '/w:settings/w:doNotTrackMoves';
|
||||||
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
|
||||||
|
$element = $doc->getElement($path, $file);
|
||||||
|
$this->assertNotEquals('false', $element->getAttribute('w:val'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test DoNotTrackFormatting
|
||||||
|
*/
|
||||||
|
public function testDoNotTrackFormatting()
|
||||||
|
{
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$phpWord->getSettings()->setDoNotTrackFormatting(true);
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$file = 'word/settings.xml';
|
||||||
|
|
||||||
|
$path = '/w:settings/w:doNotTrackFormatting';
|
||||||
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
|
||||||
|
$element = $doc->getElement($path, $file);
|
||||||
|
$this->assertNotEquals('false', $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,7 +115,8 @@ class StylesTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($element);
|
$this->assertNull($element);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFontStyleBasedOnOtherFontStyle() {
|
public function testFontStyleBasedOnOtherFontStyle()
|
||||||
|
{
|
||||||
$phpWord = new PhpWord();
|
$phpWord = new PhpWord();
|
||||||
|
|
||||||
$styleGenerationP = new Paragraph();
|
$styleGenerationP = new Paragraph();
|
||||||
|
|||||||
BIN
tests/PhpWord/_files/documents/reader.doc
Normal file
BIN
tests/PhpWord/_files/documents/reader.doc
Normal file
Binary file not shown.
Binary file not shown.
@ -96,7 +96,6 @@ class XmlDocument
|
|||||||
|
|
||||||
if (null === $this->xpath) {
|
if (null === $this->xpath) {
|
||||||
$this->xpath = new \DOMXpath($this->dom);
|
$this->xpath = new \DOMXpath($this->dom);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->xpath->query($path);
|
return $this->xpath->query($path);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user