Merge branch 'develop' into feature/EnablePasswordProtection
This commit is contained in:
commit
7b30145270
|
|
@ -6,14 +6,18 @@ Thumbs.db
|
|||
Desktop.ini
|
||||
.idea
|
||||
_build
|
||||
/build
|
||||
phpunit.xml
|
||||
composer.lock
|
||||
composer.phar
|
||||
vendor
|
||||
/report
|
||||
/build
|
||||
/samples/resources
|
||||
/samples/results
|
||||
/.settings
|
||||
phpword.ini
|
||||
/.buildpath
|
||||
/.project
|
||||
/nbproject
|
||||
/.php_cs.cache
|
||||
|
|
|
|||
|
|
@ -0,0 +1,146 @@
|
|||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->notName('pclzip.lib.php')
|
||||
->notName('OLERead.php')
|
||||
->in('samples')
|
||||
->in('src')
|
||||
->in('tests');
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder($finder)
|
||||
->setRules(array(
|
||||
'array_syntax' => array('syntax' => 'long'),
|
||||
'binary_operator_spaces' => array('align_double_arrow' => true),
|
||||
'blank_line_after_namespace' => true,
|
||||
'blank_line_after_opening_tag' => false,
|
||||
'blank_line_before_return' => true,
|
||||
'braces' => true,
|
||||
'cast_spaces' => true,
|
||||
'class_definition' => true,
|
||||
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
|
||||
'combine_consecutive_unsets' => true,
|
||||
'concat_space' => array('spacing' => 'one'),
|
||||
'declare_equal_normalize' => true,
|
||||
'declare_strict_types' => false, // Too early to adopt strict types
|
||||
'dir_constant' => true,
|
||||
'elseif' => true,
|
||||
'encoding' => true,
|
||||
'ereg_to_preg' => true,
|
||||
'full_opening_tag' => true,
|
||||
'function_declaration' => true,
|
||||
'function_typehint_space' => true,
|
||||
'general_phpdoc_annotation_remove' => false, // No use for that
|
||||
'hash_to_slash_comment' => true,
|
||||
'header_comment' => false, // We don't use common header in all our files
|
||||
'heredoc_to_nowdoc' => false, // Not sure about this one
|
||||
'is_null' => false, // Risky
|
||||
'include' => true,
|
||||
'indentation_type' => true,
|
||||
'line_ending' => true,
|
||||
'linebreak_after_opening_tag' => true,
|
||||
'lowercase_cast' => true,
|
||||
'lowercase_constants' => true,
|
||||
'lowercase_keywords' => true,
|
||||
'mb_str_functions' => false, // No, too dangerous to change that
|
||||
'method_argument_space' => true,
|
||||
'method_separation' => true,
|
||||
'modernize_types_casting' => true,
|
||||
'native_function_casing' => true,
|
||||
'native_function_invocation'=> false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now
|
||||
'new_with_braces' => true,
|
||||
'no_alias_functions' => true,
|
||||
'no_blank_lines_after_class_opening' => true,
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
|
||||
'no_closing_tag' => true,
|
||||
'no_empty_comment' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_empty_statement' => true,
|
||||
'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'useTrait', 'curly_brace_block', 'parenthesis_brace_block', 'square_brace_block'),
|
||||
'no_leading_import_slash' => true,
|
||||
'no_leading_namespace_whitespace' => true,
|
||||
'no_mixed_echo_print' => true,
|
||||
'no_multiline_whitespace_around_double_arrow' => true,
|
||||
'no_multiline_whitespace_before_semicolons' => true,
|
||||
'no_php4_constructor' => true,
|
||||
'no_short_bool_cast' => true,
|
||||
'no_short_echo_tag' => true,
|
||||
'no_singleline_whitespace_before_semicolons' => true,
|
||||
'no_spaces_after_function_name' => true,
|
||||
'no_spaces_around_offset' => true,
|
||||
'no_spaces_inside_parenthesis' => true,
|
||||
'no_trailing_comma_in_list_call' => true,
|
||||
'no_trailing_comma_in_singleline_array' => true,
|
||||
'no_trailing_whitespace' => true,
|
||||
'no_trailing_whitespace_in_comment' => true,
|
||||
'no_unneeded_control_parentheses' => true,
|
||||
'no_unreachable_default_argument_value' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_useless_return' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'normalize_index_brace' => true,
|
||||
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
|
||||
'not_operator_with_successor_space' => false, // idem
|
||||
'object_operator_without_whitespace' => true,
|
||||
'ordered_class_elements' => false, // We prefer to keep some freedom
|
||||
'ordered_imports' => true,
|
||||
'php_unit_construct' => true,
|
||||
'php_unit_dedicate_assert' => true,
|
||||
'php_unit_fqcn_annotation' => true,
|
||||
'php_unit_strict' => false, // We sometime actually need assertEquals
|
||||
'phpdoc_add_missing_param_annotation' => true,
|
||||
'phpdoc_align' => false, // Waste of time
|
||||
'phpdoc_annotation_without_dot' => true,
|
||||
'phpdoc_indent' => true,
|
||||
'phpdoc_inline_tag' => true,
|
||||
'phpdoc_no_access' => true,
|
||||
'phpdoc_no_alias_tag' => true,
|
||||
'phpdoc_no_empty_return' => true,
|
||||
'phpdoc_no_package' => true,
|
||||
'phpdoc_no_useless_inheritdoc' => true,
|
||||
'phpdoc_order' => true,
|
||||
'phpdoc_return_self_reference' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_separation' => false,
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_summary' => false,
|
||||
'phpdoc_to_comment' => true,
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_types' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'pow_to_exponentiation' => false,
|
||||
'pre_increment' => false,
|
||||
'protected_to_private' => true,
|
||||
'psr0' => true,
|
||||
'psr4' => true,
|
||||
'random_api_migration' => false, // This breaks our unit tests
|
||||
'return_type_declaration' => true,
|
||||
'self_accessor' => true,
|
||||
'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
|
||||
'short_scalar_cast' => true,
|
||||
'silenced_deprecation_error' => true,
|
||||
'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null
|
||||
'single_blank_line_at_eof' => true,
|
||||
'single_blank_line_before_namespace' => true,
|
||||
'single_class_element_per_statement' => true,
|
||||
'single_import_per_statement' => true,
|
||||
'single_line_after_imports' => true,
|
||||
'single_quote' => true,
|
||||
'space_after_semicolon' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'strict_comparison' => false, // No, too dangerous to change that
|
||||
'strict_param' => false, // No, too dangerous to change that
|
||||
'switch_case_semicolon_to_colon' => true,
|
||||
'switch_case_space' => true,
|
||||
'ternary_operator_spaces' => true,
|
||||
'ternary_to_null_coalescing' => false, // Cannot use that with PHP 5.6
|
||||
'trailing_comma_in_multiline_array' => true,
|
||||
'trim_array_spaces' => false,
|
||||
'unary_operator_spaces' => true,
|
||||
'visibility_required' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
));
|
||||
32
.travis.yml
32
.travis.yml
|
|
@ -1,17 +1,28 @@
|
|||
language: php
|
||||
|
||||
dist: precise
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
- 7.1
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
env: COVERAGE=1
|
||||
allow_failures:
|
||||
- php: 7.0
|
||||
- php: hhvm
|
||||
- php: 7.1
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- vendor
|
||||
- $HOME/.composer/cache
|
||||
- .php-cs.cache
|
||||
|
||||
env:
|
||||
global:
|
||||
|
|
@ -23,6 +34,8 @@ before_install:
|
|||
- sudo apt-get install -y graphviz
|
||||
|
||||
before_script:
|
||||
## Deactivate xdebug if we don't do code coverage
|
||||
- if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini ; fi
|
||||
## Composer
|
||||
- composer self-update
|
||||
- composer install --prefer-source
|
||||
|
|
@ -32,19 +45,20 @@ before_script:
|
|||
|
||||
script:
|
||||
## PHP_CodeSniffer
|
||||
- ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
|
||||
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ; fi
|
||||
## PHP-CS-Fixer
|
||||
- if [ -n "$COVERAGE" ]; then ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run ; fi
|
||||
## PHP Mess Detector
|
||||
- ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
|
||||
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ; fi
|
||||
## PHPUnit
|
||||
- ./vendor/bin/phpunit -c ./ --coverage-text --coverage-html ./build/coverage
|
||||
- ./vendor/bin/phpunit -c ./ $(if [ -n "$COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi)
|
||||
## PHPLOC
|
||||
- ./vendor/bin/phploc src/
|
||||
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phploc src/ ; fi
|
||||
## PHPDocumentor
|
||||
- ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig"
|
||||
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" ; fi
|
||||
|
||||
after_script:
|
||||
## PHPDocumentor
|
||||
- bash .travis_shell_after_success.sh
|
||||
## Scrutinizer
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
|
||||
- if [ -n "$COVERAGE" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml ; fi
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ echo "TRAVIS_REPO_SLUG: $TRAVIS_REPO_SLUG"
|
|||
echo "TRAVIS_PHP_VERSION: $TRAVIS_PHP_VERSION"
|
||||
echo "TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST"
|
||||
|
||||
if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_PHP_VERSION" == "5.5" ]; then
|
||||
if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then
|
||||
|
||||
echo -e "Publishing PHPDoc...\n"
|
||||
|
||||
|
|
|
|||
37
CHANGELOG.md
37
CHANGELOG.md
|
|
@ -3,6 +3,42 @@ Change Log
|
|||
All notable changes to this project will be documented in this file.
|
||||
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
|
||||
- Support for paragraph textAlignment - @troosan #1165
|
||||
- Add support for HTML underline tag <u> in addHtml - @zNightFalLz #1186
|
||||
- Allow to change cell width unit - guillaume-ro-fr #986
|
||||
- Allow to change the line height rule @troosan
|
||||
|
||||
### 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, @aoloe #875
|
||||
- Fixed styles not being applied by HTML writer, better pdf output - @sarke #1047 #500 #1139
|
||||
- Fixed read docx error when document contains image from remote url - @FBnil #1173 #1176
|
||||
- Padded the $args array to remove error - @kaigoh #1150, @reformed #870
|
||||
- Fix incorrect image size between windows and mac - @bskrtich #874
|
||||
- Fix adding HTML table to document - @mogilvie @arivanbastos #324
|
||||
|
||||
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).
|
||||
|
|
@ -22,6 +58,7 @@ Manual installation feature has been dropped since the release. Please, use [Com
|
|||
- Improved error message for the case when `autoload.php` is not found. - @RomanSyroeshko #371
|
||||
- Renamed the `align` option of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles into `alignment`. - @RomanSyroeshko
|
||||
- Improved performance of `TemplateProcessor::setValue()`. - @kazitanvirahsan #614, #617
|
||||
- Fixed some HTML tags not rendering any output (p, header & table) - #257, #324 - @twmobius and @garethellis
|
||||
|
||||
### Deprecated
|
||||
- `getAlign` and `setAlign` methods of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles.
|
||||
|
|
|
|||
|
|
@ -12,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/).
|
||||
|
||||
If you have any questions, please ask on [StackOverFlow](https://stackoverflow.com/questions/tagged/phpword)
|
||||
|
||||
Read more about PHPWord:
|
||||
|
||||
- [Features](#features)
|
||||
|
|
@ -55,8 +57,7 @@ PHPWord requires the following:
|
|||
- PHP 5.3.3+
|
||||
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
|
||||
- [Zend\Escaper component](http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html)
|
||||
- Zend\Stdlib component
|
||||
- [Zend\Validator component](http://framework.zend.com/manual/current/en/modules/zend.validator.html)
|
||||
- [Zend\Stdlib component](http://framework.zend.com/manual/current/en/modules/zend.stdlib.hydrator.html)
|
||||
- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)
|
||||
- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images)
|
||||
- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write OOXML and ODF)
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2016 PHPWord contributors
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
},
|
||||
{
|
||||
"name": "Franck Lefevre",
|
||||
"homepage": "http://blog.rootslabs.net"
|
||||
"homepage": "https://rootslabs.net/blog/"
|
||||
},
|
||||
{
|
||||
"name": "Ivan Lanin",
|
||||
|
|
@ -29,23 +29,27 @@
|
|||
{
|
||||
"name": "Roman Syroeshko",
|
||||
"homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/"
|
||||
},
|
||||
{
|
||||
"name": "Antoine de Troostembergh"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"ext-xml": "*",
|
||||
"zendframework/zend-escaper": "2.4.*",
|
||||
"zendframework/zend-stdlib": "2.4.*",
|
||||
"zendframework/zend-validator": "2.4.*",
|
||||
"phpoffice/common": "0.2.*"
|
||||
"zendframework/zend-escaper": "^2.2",
|
||||
"zendframework/zend-stdlib": "^2.2",
|
||||
"phpoffice/common": "^0.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "3.7.*",
|
||||
"phpunit/phpunit": "^4.8.36",
|
||||
"phpdocumentor/phpdocumentor":"2.*",
|
||||
"squizlabs/php_codesniffer": "1.*",
|
||||
"twig/twig":"1.27",
|
||||
"squizlabs/php_codesniffer": "^2.7",
|
||||
"friendsofphp/php-cs-fixer": "^2.0",
|
||||
"phpmd/phpmd": "2.*",
|
||||
"phploc/phploc": "2.*",
|
||||
"dompdf/dompdf":"0.6.*",
|
||||
"dompdf/dompdf":"0.8.*",
|
||||
"tecnickcom/tcpdf": "6.*",
|
||||
"mpdf/mpdf": "5.*"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ master_doc = 'index'
|
|||
|
||||
# General information about the project.
|
||||
project = u'PHPWord'
|
||||
copyright = u'2014-2015, PHPWord Contributors'
|
||||
copyright = u'2014-2017, PHPWord Contributors'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.13.0'
|
||||
version = '0.14.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ html_theme = 'default'
|
|||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
#html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
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
|
||||
-------
|
||||
|
||||
|
|
|
|||
|
|
@ -135,12 +135,12 @@ Text breaks are empty new lines. To add text breaks, use the following syntax. A
|
|||
Page breaks
|
||||
~~~~~~~~~~~
|
||||
|
||||
There are two ways to insert a page breaks, using the ``addPageBreak``
|
||||
There are two ways to insert a page break, using the ``addPageBreak``
|
||||
method or using the ``pageBreakBefore`` style of paragraph.
|
||||
|
||||
:: code-block:: php
|
||||
.. code-block:: php
|
||||
|
||||
\\$section->addPageBreak();
|
||||
$section->addPageBreak();
|
||||
|
||||
Lists
|
||||
-----
|
||||
|
|
@ -159,7 +159,7 @@ Parameters:
|
|||
- ``$depth``. Depth of list item.
|
||||
- ``$fontStyle``. See :ref:`font-style`.
|
||||
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
|
||||
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\_Style\_ListItem.
|
||||
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\\Style\\ListItem.
|
||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||
|
||||
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``:
|
||||
|
||||
- ``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.
|
||||
- ``indent``. The indent factor of the titles in twips.
|
||||
|
||||
|
|
@ -333,11 +333,28 @@ On text:
|
|||
$footnote = $section->addFootnote();
|
||||
$footnote->addText('Footnote text.');
|
||||
|
||||
The footnote reference number will be displayed with decimal number
|
||||
starting from 1. This number use ``FooterReference`` style which you can
|
||||
redefine by ``addFontStyle`` method. Default value for this style is
|
||||
By default the footnote reference number will be displayed with decimal number
|
||||
starting from 1. This number uses the ``FooterReference`` style which you can
|
||||
redefine with the ``addFontStyle`` method. Default value for this style is
|
||||
``array('superScript' => true)``;
|
||||
|
||||
The footnote numbering can be controlled by setting the FootnoteProperties on the Section.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$fp = new PhpWord\SimpleType\FootnoteProperties();
|
||||
//sets the position of the footnote (pageBottom (default), beneathText, sectEnd, docEnd)
|
||||
$fp->setPos(FootnoteProperties::POSITION_DOC_END);
|
||||
//set the number format to use (decimal (default), upperRoman, upperLetter, ...)
|
||||
$fp->setNumFmt(FootnoteProperties::NUMBER_FORMAT_LOWER_ROMAN);
|
||||
//force starting at other than 1
|
||||
$fp->setNumStart(2);
|
||||
//when to restart counting (continuous (default), eachSect, eachPage)
|
||||
$fp->setNumRestart(FootnoteProperties::RESTART_NUMBER_EACH_PAGE);
|
||||
|
||||
//And finaly, set it on the Section
|
||||
$section->setFootnoteProperties($properties);
|
||||
|
||||
Checkboxes
|
||||
----------
|
||||
|
||||
|
|
@ -360,7 +377,35 @@ To be completed
|
|||
Fields
|
||||
------
|
||||
|
||||
To be completed
|
||||
Currently the following fields are supported:
|
||||
|
||||
- PAGE
|
||||
- NUMPAGES
|
||||
- DATE
|
||||
- XE
|
||||
- INDEX
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$section->addField($fieldType, [$properties], [$options], [$fieldText])
|
||||
|
||||
See ``\PhpOffice\PhpWord\Element\Field`` for list of properties and options available for each field type.
|
||||
Options which are not specifically defined can be added. Those must start with a ``\``.
|
||||
|
||||
For instance for the INDEX field, you can do the following (See `Index Field for list of available options <https://support.office.com/en-us/article/Field-codes-Index-field-adafcf4a-cb30-43f6-85c7-743da1635d9e?ui=en-US&rs=en-US&ad=US>`_ ):
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
//the $fieldText can be either a simple string
|
||||
$fieldText = 'The index value';
|
||||
|
||||
//or a 'TextRun', to be able to format the text you want in the index
|
||||
$fieldText = new TextRun();
|
||||
$fieldText->addText('My ');
|
||||
$fieldText->addText('bold index', ['bold' => true]);
|
||||
$fieldText->addText(' entry');
|
||||
|
||||
$section->addField('INDEX', array(), array('\\e " " \\h "A" \\c "3"'), $fieldText);
|
||||
|
||||
Line
|
||||
------
|
||||
|
|
@ -369,8 +414,8 @@ Line elements can be added to sections by using ``addLine``.
|
|||
|
||||
.. code-block:: php
|
||||
|
||||
$linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552);
|
||||
$section->addLine($lineStyle)
|
||||
$lineStyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552);
|
||||
$section->addLine($lineStyle);
|
||||
|
||||
Available line style attributes:
|
||||
|
||||
|
|
@ -382,3 +427,26 @@ Available line style attributes:
|
|||
- ``width``. Line-object width in pt.
|
||||
- ``height``. Line-object height in pt.
|
||||
- ``flip``. Flip the line element: true, false.
|
||||
|
||||
Comments
|
||||
---------
|
||||
|
||||
Comments can be added to a document by using ``addComment``.
|
||||
The comment can contain formatted text. Once the comment has been added, it can be linked to any element with ``setCommentStart``.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// first create a comment
|
||||
$comment= new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
|
||||
$comment->addText('Test', array('bold' => true));
|
||||
|
||||
// add it to the document
|
||||
$phpWord->addComment($comment);
|
||||
|
||||
$textrun = $section->addTextRun();
|
||||
$textrun->addText('This ');
|
||||
$text = $textrun->addText('is');
|
||||
// link the comment to the text you just created
|
||||
$text->setCommentStart($comment);
|
||||
|
||||
If no end is set for a comment using the ``setCommentEnd``, the comment will be ended automatically at the end of the element it is started on.
|
||||
|
|
@ -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 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
|
||||
affect the behavior of PHPWord. Below are the options.
|
||||
|
|
@ -109,8 +109,8 @@ Zip class
|
|||
By default, PHPWord uses `Zip extension <http://php.net/manual/en/book.zip.php>`__
|
||||
to deal with ZIP compressed archives and files inside them. If you can't have
|
||||
Zip extension installed on your server, you can use pure PHP library
|
||||
alternative, `PclZip <http://www.phpconcept.net/pclzip/>`__, which
|
||||
included with PHPWord.
|
||||
alternative, `PclZip <http://www.phpconcept.net/pclzip/>`__, which is
|
||||
included in PHPWord.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
|
@ -141,6 +141,94 @@ default font by using the following two functions:
|
|||
$phpWord->setDefaultFontName('Times New Roman');
|
||||
$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);
|
||||
|
||||
Mirroring the Page Margins
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Use mirror margins to set up facing pages for double-sided documents, such as books or magazines.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$phpWord->getSettings()->setMirrorMargins(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
|
||||
|
||||
$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
|
||||
--------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ Example:
|
|||
|
||||
{
|
||||
"require": {
|
||||
"phpoffice/phpword": "v0.13.*"
|
||||
"phpoffice/phpword": "v0.14.*"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ Features
|
|||
- Insert drawing shapes (arc, curve, line, polyline, rect, oval)
|
||||
- Insert charts (pie, doughnut, bar, line, area, scatter, radar)
|
||||
- Insert form fields (textinput, checkbox, and dropdown)
|
||||
- Insert comments
|
||||
- Create document from templates
|
||||
- Use XSL 1.0 style sheets to transform headers, main document part, and footers of an OOXML template
|
||||
- ... and many more features on progress
|
||||
|
|
@ -102,6 +103,8 @@ Writers
|
|||
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
||||
| | Endnote | ✓ | | | ✓ | |
|
||||
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
||||
| | Comments | ✓ | | | | |
|
||||
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
||||
| **Graphs** | 2D basic graphs | ✓ | | | | |
|
||||
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
||||
| | 2D advanced graphs | | | | | |
|
||||
|
|
@ -161,6 +164,8 @@ Readers
|
|||
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
||||
| | Endnote | ✓ | | | | |
|
||||
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
||||
| | Comments | | | | | |
|
||||
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
||||
| **Graphs** | 2D basic graphs | | | | | |
|
||||
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
||||
| | 2D advanced graphs | | | | | |
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ References
|
|||
==========
|
||||
|
||||
ISO/IEC 29500, Third edition, 2012-09-01
|
||||
---------------------
|
||||
----------------------------------------
|
||||
|
||||
- `Part 1: Fundamentals and Markup Language Reference
|
||||
<http://standards.iso.org/ittf/PubliclyAvailableStandards/c061750_ISO_IEC_29500-1_2012.zip>`__
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ Available Font style options:
|
|||
- ``color``. Font color, e.g. *FF0000*.
|
||||
- ``doubleStrikethrough``. Double strikethrough, *true* or *false*.
|
||||
- ``fgColor``. Font highlight color, e.g. *yellow*, *green*, *blue*.
|
||||
See ``\PhpOffice\PhpWord\Style\Font::FGCOLOR_...`` constants for more values
|
||||
- ``hint``. Font content type, *default*, *eastAsia*, or *cs*.
|
||||
- ``italic``. Italic, *true* or *false*.
|
||||
- ``name``. Font name, e.g. *Arial*.
|
||||
|
|
@ -54,7 +55,10 @@ Available Font style options:
|
|||
- ``strikethrough``. Strikethrough, *true* or *false*.
|
||||
- ``subScript``. Subscript, *true* or *false*.
|
||||
- ``superScript``. Superscript, *true* or *false*.
|
||||
- ``underline``. Underline, *dash*, *dotted*, etc.
|
||||
- ``underline``. Underline, *single*, *dash*, *dotted*, etc.
|
||||
See ``\PhpOffice\PhpWord\Style\Font::UNDERLINE_...`` constants for more values
|
||||
- ``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:
|
||||
|
||||
|
|
@ -64,7 +68,7 @@ Paragraph
|
|||
Available Paragraph style options:
|
||||
|
||||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||
- ``basedOn``. Parent style.
|
||||
- ``hanging``. Hanging by how much.
|
||||
- ``indent``. Indent by how much.
|
||||
|
|
@ -75,8 +79,15 @@ See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
|||
- ``pageBreakBefore``. Start paragraph on next page, *true* or *false*.
|
||||
- ``spaceBefore``. Space before paragraph.
|
||||
- ``spaceAfter``. Space after paragraph.
|
||||
- ``spacing``. Space between lines.
|
||||
- ``spacingLineRule``. Line Spacing Rule. *auto*, *exact*, *atLeast*
|
||||
- ``tabs``. Set of custom tab stops.
|
||||
- ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*.
|
||||
- ``contextualSpacing``. Ignore Spacing Above and Below When Using Identical Styles, *true* or *false*.
|
||||
- ``bidi``. Right to Left Paragraph Layout, *true* or *false*.
|
||||
- ``shading``. Paragraph Shading.
|
||||
- ``textAlignment``. Vertical Character Alignment on Line.
|
||||
See ``\PhpOffice\PhpWord\SimpleType\TextAlignment`` class for possible values.
|
||||
|
||||
.. _table-style:
|
||||
|
||||
|
|
@ -86,7 +97,7 @@ Table
|
|||
Available Table style options:
|
||||
|
||||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
|
||||
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
|
||||
- ``bgColor``. Background color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||
|
|
@ -105,7 +116,8 @@ Available Cell style options:
|
|||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||
- ``gridSpan``. Number of columns spanned.
|
||||
- ``textDirection(btLr|tbRl)``. Direction of text. You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
|
||||
- ``textDirection(btLr|tbRl)``. Direction of text.
|
||||
You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
|
||||
- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
|
||||
- ``vMerge``. *restart* or *continue*.
|
||||
- ``width``. Cell width in twips.
|
||||
|
|
@ -132,7 +144,7 @@ Numbering level
|
|||
Available NumberingLevel style options:
|
||||
|
||||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||
- ``font``. Font name.
|
||||
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
|
||||
- ``hanging``. See paragraph style.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
## PHP_CodeSniffer
|
||||
./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
|
||||
|
||||
## PHP-CS-Fixer
|
||||
./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
|
||||
|
||||
## PHP Mess Detector
|
||||
./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
|
||||
|
||||
## PHPUnit
|
||||
./vendor/bin/phpunit -c ./ --no-coverage
|
||||
|
||||
|
|
@ -1,9 +1,16 @@
|
|||
<?php
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
// New Word Document
|
||||
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->getSettings()->setThemeFontLang($languageEnGb);
|
||||
|
||||
$fontStyleName = 'rStyle';
|
||||
$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->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
|
||||
$section->addTextBreak(2);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ $phpWord->addParagraphStyle(
|
|||
new \PhpOffice\PhpWord\Style\Tab('left', 1550),
|
||||
new \PhpOffice\PhpWord\Style\Tab('center', 3200),
|
||||
new \PhpOffice\PhpWord\Style\Tab('right', 5300),
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
|
||||
use PhpOffice\PhpWord\SimpleType\NumberFormat;
|
||||
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
// New Word Document
|
||||
|
|
@ -42,11 +45,15 @@ $footnote->addText('But you can only put footnote in section, not in header or f
|
|||
|
||||
$section->addText(
|
||||
'You can also create the footnote directly from the section making it wrap in a paragraph '
|
||||
. 'like the footnote below this paragraph. But is is best used from within a textrun.'
|
||||
. 'like the footnote below this paragraph. But is best used from within a textrun.'
|
||||
);
|
||||
$footnote = $section->addFootnote();
|
||||
$footnote->addText('The reference for this is wrapped in its own line');
|
||||
|
||||
$footnoteProperties = new FootnoteProperties();
|
||||
$footnoteProperties->setNumFmt(NumberFormat::DECIMAL_ENCLOSED_CIRCLE);
|
||||
$section->setFootnoteProperties($footnoteProperties);
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
if (!CLI) {
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ for ($i = 1; $i <= 8; $i++) {
|
|||
$table->addCell(2000)->addText("Cell {$i}");
|
||||
$table->addCell(2000)->addText("Cell {$i}");
|
||||
$table->addCell(2000)->addText("Cell {$i}");
|
||||
$text = (0== $i % 2) ? 'X' : '';
|
||||
$text = (0 == $i % 2) ? 'X' : '';
|
||||
$table->addCell(500)->addText($text);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* 3. colspan (gridSpan) and rowspan (vMerge)
|
||||
* ---------------------
|
||||
* | | B | |
|
||||
|
|
@ -93,7 +93,7 @@ $table->addCell(2000, $cellVCentered)->addText('C', null, $cellHCentered);
|
|||
$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered);
|
||||
$table->addCell(null, $cellRowContinue);
|
||||
|
||||
/**
|
||||
/*
|
||||
* 4. colspan (gridSpan) and rowspan (vMerge)
|
||||
* ---------------------
|
||||
* | | B | 1 |
|
||||
|
|
@ -104,25 +104,26 @@ $table->addCell(null, $cellRowContinue);
|
|||
* ---------------------
|
||||
* @see https://github.com/PHPOffice/PHPWord/issues/806
|
||||
*/
|
||||
|
||||
$section->addPageBreak();
|
||||
$section->addText('Table with colspan and rowspan', $header);
|
||||
|
||||
$styleTable = ['borderSize' => 6, 'borderColor' => '999999'];
|
||||
$styleTable = array('borderSize' => 6, 'borderColor' => '999999');
|
||||
$phpWord->addTableStyle('Colspan Rowspan', $styleTable);
|
||||
$table = $section->addTable('Colspan Rowspan');
|
||||
|
||||
$row = $table->addRow();
|
||||
|
||||
$row->addCell(null, ['vMerge' => 'restart'])->addText('A');
|
||||
$row->addCell(null, ['gridSpan' => 2, 'vMerge' => 'restart',])->addText('B');
|
||||
$row->addCell(null, array('vMerge' => 'restart'))->addText('A');
|
||||
$row->addCell(null, array('gridSpan' => 2, 'vMerge' => 'restart'))->addText('B');
|
||||
$row->addCell()->addText('1');
|
||||
|
||||
$row = $table->addRow();
|
||||
$row->addCell(null, ['vMerge' => 'continue']);
|
||||
$row->addCell(null, ['vMerge' => 'continue','gridSpan' => 2,]);
|
||||
$row->addCell(null, array('vMerge' => 'continue'));
|
||||
$row->addCell(null, array('vMerge' => 'continue', 'gridSpan' => 2));
|
||||
$row->addCell()->addText('2');
|
||||
$row = $table->addRow();
|
||||
$row->addCell(null, ['vMerge' => 'continue']);
|
||||
$row->addCell(null, array('vMerge' => 'continue'));
|
||||
$row->addCell()->addText('C');
|
||||
$row->addCell()->addText('D');
|
||||
$row->addCell()->addText('3');
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|||
$section = $phpWord->addSection();
|
||||
$header = array('size' => 16, 'bold' => true);
|
||||
//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
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@ $source = 'http://php.net/images/logos/php-med-trans-light.gif';
|
|||
$section->addText("Remote image from: {$source}");
|
||||
$section->addImage($source);
|
||||
|
||||
// Image from string
|
||||
$source = 'resources/_mars.jpg';
|
||||
$fileContent = file_get_contents($source);
|
||||
$section->addText('Image from string');
|
||||
$section->addImage($fileContent);
|
||||
|
||||
//Wrapping style
|
||||
$text = str_repeat('Hello World! ', 15);
|
||||
$wrappingStyles = array('inline', 'behind', 'infront', 'square', 'tight');
|
||||
|
|
|
|||
|
|
@ -14,7 +14,35 @@ $html .= '<ul><li>Item 1</li><li>Item 2</li><ul><li>Item 2.1</li><li>Item 2.1</l
|
|||
$html .= '<p>Ordered (numbered) list:</p>';
|
||||
$html .= '<ol><li>Item 1</li><li>Item 2</li></ol>';
|
||||
|
||||
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);
|
||||
$html .= '<p>List with complex content:</p>';
|
||||
$html .= '<ul>
|
||||
<li>
|
||||
<span style="font-family: arial,helvetica,sans-serif;">
|
||||
<span style="font-size: 12px;">list item1</span>
|
||||
</span>
|
||||
</li>
|
||||
<li>
|
||||
<span style="font-family: arial,helvetica,sans-serif;">
|
||||
<span style="font-size: 12px;">list item2</span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>';
|
||||
|
||||
$html .= '<table style="width: 50%; border: 6px #0000FF double;">
|
||||
<thead>
|
||||
<tr style="background-color: #FF0000; text-align: center; color: #FFFFFF; font-weight: bold; ">
|
||||
<th style="width: 50pt">header a</th>
|
||||
<th style="width: 50">header b</th>
|
||||
<th style="background-color: #FFFF00; border-width: 12px"><span style="background-color: #00FF00;">header c</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td style="border-style: dotted;">1</td><td colspan="2">2</td></tr>
|
||||
<tr><td>4</td><td>5</td><td>6</td></tr>
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html, false, false);
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
use PhpOffice\PhpWord\Element\TextRun;
|
||||
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
// New Word document
|
||||
|
|
@ -14,10 +16,28 @@ $section->addText('Date field:');
|
|||
$section->addField('DATE', array('dateformat' => 'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat'));
|
||||
|
||||
$section->addText('Page field:');
|
||||
$section->addField('PAGE', array('format' => 'ArabicDash'));
|
||||
$section->addField('PAGE', array('format' => 'Arabic'));
|
||||
|
||||
$section->addText('Number of pages field:');
|
||||
$section->addField('NUMPAGES', array('format' => 'Arabic', 'numformat' => '0,00'), array('PreserveFormat'));
|
||||
$section->addField('NUMPAGES', array('numformat' => '0,00', 'format' => 'Arabic'), array('PreserveFormat'));
|
||||
|
||||
$textrun = $section->addTextRun();
|
||||
$textrun->addText('An index field is ');
|
||||
$textrun->addField('XE', array(), array('Italic'), 'My first index');
|
||||
$textrun->addText('here:');
|
||||
|
||||
$indexEntryText = new TextRun();
|
||||
$indexEntryText->addText('My ');
|
||||
$indexEntryText->addText('bold index', array('bold' => true));
|
||||
$indexEntryText->addText(' entry');
|
||||
|
||||
$textrun = $section->addTextRun();
|
||||
$textrun->addText('A complex index field is ');
|
||||
$textrun->addField('XE', array(), array('Bold'), $indexEntryText);
|
||||
$textrun->addText('here:');
|
||||
|
||||
$section->addText('The actual index:');
|
||||
$section->addField('INDEX', array(), array('\\e " "'), 'right click to update the index');
|
||||
|
||||
$textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
|
||||
$textrun->addText('This is the date of lunar calendar ');
|
||||
|
|
|
|||
|
|
@ -15,10 +15,16 @@ $textrun->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choi
|
|||
$textrun = $section->addTextRun();
|
||||
$textrun->addText('Date: ');
|
||||
$textrun->addSDT('date');
|
||||
$textrun->addTextBreak(1);
|
||||
$textrun->addText('Date with pre set value: ');
|
||||
$textrun->addSDT('date')->setValue('03/30/2017');
|
||||
$textrun->addTextBreak(1);
|
||||
$textrun->addText('Date with pre set value: ');
|
||||
$textrun->addSDT('date')->setValue('30.03.2017');
|
||||
|
||||
$textrun = $section->addTextRun();
|
||||
$textrun->addText('Drop down list: ');
|
||||
$textrun->addSDT('dropDownList')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
|
||||
$textrun->addSDT('dropDownList')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'))->setValue('Choice 1');
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
// New Word Document
|
||||
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
|
||||
// A comment
|
||||
$comment = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
|
||||
$comment->addText('Test', array('bold' => true));
|
||||
$phpWord->addComment($comment);
|
||||
|
||||
$section = $phpWord->addSection();
|
||||
|
||||
$textrun = $section->addTextRun();
|
||||
$textrun->addText('This ');
|
||||
$text = $textrun->addText('is');
|
||||
$text->setCommentRangeStart($comment);
|
||||
$textrun->addText(' a test');
|
||||
|
||||
$section->addTextBreak(2);
|
||||
|
||||
// Let's create a comment that we will link to a start element and an end element
|
||||
$commentWithStartAndEnd = new \PhpOffice\PhpWord\Element\Comment('Foo Bar', new \DateTime());
|
||||
$commentWithStartAndEnd->addText('A comment with a start and an end');
|
||||
$phpWord->addComment($commentWithStartAndEnd);
|
||||
|
||||
$textrunWithEnd = $section->addTextRun();
|
||||
$textrunWithEnd->addText('This ');
|
||||
$textToStartOn = $textrunWithEnd->addText('is', array('bold' => true));
|
||||
$textToStartOn->setCommentRangeStart($commentWithStartAndEnd);
|
||||
$textrunWithEnd->addText(' another', array('italic' => true));
|
||||
$textToEndOn = $textrunWithEnd->addText(' test');
|
||||
$textToEndOn->setCommentRangeEnd($commentWithStartAndEnd);
|
||||
|
||||
$section->addTextBreak(2);
|
||||
|
||||
// Let's add a comment on an image
|
||||
$commentOnImage = new \PhpOffice\PhpWord\Element\Comment('Mr Smart', new \DateTime());
|
||||
$imageComment = $commentOnImage->addTextRun();
|
||||
$imageComment->addText('Hey, Mars does look ');
|
||||
$imageComment->addText('red', array('color' => 'FF0000'));
|
||||
$phpWord->addComment($commentOnImage);
|
||||
$image = $section->addImage('resources/_mars.jpg');
|
||||
$image->setCommentRangeStart($commentOnImage);
|
||||
|
||||
$section->addTextBreak(2);
|
||||
|
||||
// We can also do things the other way round, link the comment to the element
|
||||
$anotherText = $section->addText('another text');
|
||||
|
||||
$comment1 = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
|
||||
$comment1->addText('Test', array('bold' => true));
|
||||
$comment1->setStartElement($anotherText);
|
||||
$comment1->setEndElement($anotherText);
|
||||
$phpWord->addComment($comment1);
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
if (!CLI) {
|
||||
include_once 'Sample_Footer.php';
|
||||
}
|
||||
|
|
@ -12,6 +12,12 @@ define('IS_INDEX', SCRIPT_FILENAME == 'index');
|
|||
|
||||
Settings::loadConfig();
|
||||
|
||||
$dompdfPath = $vendorDirPath . '/dompdf/dompdf';
|
||||
if (file_exists($dompdfPath)) {
|
||||
define('DOMPDF_ENABLE_AUTOLOAD', false);
|
||||
Settings::setPdfRenderer(Settings::PDF_RENDERER_DOMPDF, $vendorDirPath . '/dompdf/dompdf');
|
||||
}
|
||||
|
||||
// Set writers
|
||||
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf');
|
||||
|
||||
|
|
@ -89,8 +95,8 @@ function getEndingNotes($writers)
|
|||
|
||||
// Do not show execution time for index
|
||||
if (!IS_INDEX) {
|
||||
$result .= date('H:i:s') . " Done writing file(s)" . EOL;
|
||||
$result .= date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" . EOL;
|
||||
$result .= date('H:i:s') . ' Done writing file(s)' . EOL;
|
||||
$result .= date('H:i:s') . ' Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB' . EOL;
|
||||
}
|
||||
|
||||
// Return
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ $requirements = array(
|
|||
'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')),
|
||||
);
|
||||
if (!CLI) {
|
||||
?>
|
||||
?>
|
||||
<div class="jumbotron">
|
||||
<p>Welcome to PHPWord, a library written in pure PHP that provides a set of classes to write to and read from different document file formats, i.e. Office Open XML (.docx), Open Document Format (.odt), and Rich Text Format (.rtf).</p>
|
||||
<p> </p>
|
||||
|
|
@ -25,14 +25,14 @@ if (!CLI) {
|
|||
<?php
|
||||
}
|
||||
if (!CLI) {
|
||||
echo "<h3>Requirement check:</h3>";
|
||||
echo "<ul>";
|
||||
echo '<h3>Requirement check:</h3>';
|
||||
echo '<ul>';
|
||||
foreach ($requirements as $key => $value) {
|
||||
list($label, $result) = $value;
|
||||
$status = $result ? 'passed' : 'failed';
|
||||
echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
echo '</ul>';
|
||||
include_once 'Sample_Footer.php';
|
||||
} else {
|
||||
echo 'Requirement check:' . PHP_EOL;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -51,9 +51,9 @@ abstract class AbstractCollection
|
|||
{
|
||||
if (array_key_exists($index, $this->items)) {
|
||||
return $this->items[$index];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -61,7 +61,6 @@ abstract class AbstractCollection
|
|||
*
|
||||
* @param int $index
|
||||
* @param mixed $item
|
||||
* @return void
|
||||
*/
|
||||
public function setItem($index, $item)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
<?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.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
/**
|
||||
* Comments collection
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
class Comments extends AbstractCollection
|
||||
{
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,181 @@
|
|||
<?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.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\ComplexType;
|
||||
|
||||
use PhpOffice\PhpWord\SimpleType\NumberFormat;
|
||||
|
||||
/**
|
||||
* Footnote properties
|
||||
*
|
||||
* @see http://www.datypic.com/sc/ooxml/e-w_footnotePr-1.html
|
||||
*/
|
||||
final class FootnoteProperties
|
||||
{
|
||||
const RESTART_NUMBER_CONTINUOUS = 'continuous';
|
||||
const RESTART_NUMBER_EACH_SECTION = 'eachSect';
|
||||
const RESTART_NUMBER_EACH_PAGE = 'eachPage';
|
||||
|
||||
const POSITION_PAGE_BOTTOM = 'pageBottom';
|
||||
const POSITION_BENEATH_TEXT = 'beneathText';
|
||||
const POSITION_SECTION_END = 'sectEnd';
|
||||
const POSITION_DOC_END = 'docEnd';
|
||||
|
||||
/**
|
||||
* Footnote Positioning Location
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $pos;
|
||||
|
||||
/**
|
||||
* Footnote Numbering Format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $numFmt;
|
||||
|
||||
/**
|
||||
* Footnote and Endnote Numbering Starting Value
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $numStart;
|
||||
|
||||
/**
|
||||
* Footnote and Endnote Numbering Restart Location
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $numRestart;
|
||||
|
||||
/**
|
||||
* Get the Footnote Positioning Location
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPos()
|
||||
{
|
||||
return $this->pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd)
|
||||
*
|
||||
* @param string $pos
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
public function setPos($pos)
|
||||
{
|
||||
$position = array(
|
||||
self::POSITION_PAGE_BOTTOM,
|
||||
self::POSITION_BENEATH_TEXT,
|
||||
self::POSITION_SECTION_END,
|
||||
self::POSITION_DOC_END,
|
||||
);
|
||||
|
||||
if (in_array($pos, $position)) {
|
||||
$this->pos = $pos;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $position) . ' possible');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Footnote Numbering Format
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNumFmt()
|
||||
{
|
||||
return $this->numFmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Footnote Numbering Format
|
||||
*
|
||||
* @param string $numFmt One of NumberFormat
|
||||
* @return self
|
||||
*/
|
||||
public function setNumFmt($numFmt)
|
||||
{
|
||||
NumberFormat::validate($numFmt);
|
||||
$this->numFmt = $numFmt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Footnote Numbering Format
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getNumStart()
|
||||
{
|
||||
return $this->numStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Footnote Numbering Format
|
||||
*
|
||||
* @param float $numStart
|
||||
* @return self
|
||||
*/
|
||||
public function setNumStart($numStart)
|
||||
{
|
||||
$this->numStart = $numStart;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Footnote and Endnote Numbering Starting Value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNumRestart()
|
||||
{
|
||||
return $this->numRestart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage)
|
||||
*
|
||||
* @param string $numRestart
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
public function setNumRestart($numRestart)
|
||||
{
|
||||
$restartNumbers = array(
|
||||
self::RESTART_NUMBER_CONTINUOUS,
|
||||
self::RESTART_NUMBER_EACH_SECTION,
|
||||
self::RESTART_NUMBER_EACH_PAGE,
|
||||
);
|
||||
|
||||
if (in_array($numRestart, $restartNumbers)) {
|
||||
$this->numRestart = $numRestart;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
<?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.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 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 bool
|
||||
*/
|
||||
private $markup;
|
||||
|
||||
/**
|
||||
* Display Comments
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $comments;
|
||||
|
||||
/**
|
||||
* Display Content Revisions
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $insDel;
|
||||
|
||||
/**
|
||||
* Display Formatting Revisions
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $formatting;
|
||||
|
||||
/**
|
||||
* Display Ink Annotations
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $inkAnnotations;
|
||||
|
||||
/**
|
||||
* Get Display Visual Indicator Of Markup Area
|
||||
*
|
||||
* @return bool True if markup is shown
|
||||
*/
|
||||
public function hasMarkup()
|
||||
{
|
||||
return $this->markup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Display Visual Indicator Of Markup Area
|
||||
*
|
||||
* @param bool $markup
|
||||
* Set to true to show markup
|
||||
*/
|
||||
public function setMarkup($markup)
|
||||
{
|
||||
$this->markup = $markup === null ? true : $markup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Display Comments
|
||||
*
|
||||
* @return bool True if comments are shown
|
||||
*/
|
||||
public function hasComments()
|
||||
{
|
||||
return $this->comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Display Comments
|
||||
*
|
||||
* @param bool $comments
|
||||
* Set to true to show comments
|
||||
*/
|
||||
public function setComments($comments)
|
||||
{
|
||||
$this->comments = $comments === null ? true : $comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Display Content Revisions
|
||||
*
|
||||
* @return bool True if content revisions are shown
|
||||
*/
|
||||
public function hasInsDel()
|
||||
{
|
||||
return $this->insDel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Display Content Revisions
|
||||
*
|
||||
* @param bool $insDel
|
||||
* Set to true to show content revisions
|
||||
*/
|
||||
public function setInsDel($insDel)
|
||||
{
|
||||
$this->insDel = $insDel === null ? true : $insDel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Display Formatting Revisions
|
||||
*
|
||||
* @return bool True if formatting revisions are shown
|
||||
*/
|
||||
public function hasFormatting()
|
||||
{
|
||||
return $this->formatting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Display Formatting Revisions
|
||||
*
|
||||
* @param bool|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 bool True if ink annotations are shown
|
||||
*/
|
||||
public function hasInkAnnotations()
|
||||
{
|
||||
return $this->inkAnnotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Display Ink Annotations
|
||||
*
|
||||
* @param bool $inkAnnotations
|
||||
* Set to true to show ink annotations
|
||||
*/
|
||||
public function setInkAnnotations($inkAnnotations)
|
||||
{
|
||||
$this->inkAnnotations = $inkAnnotations === null ? true : $inkAnnotations;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ namespace PhpOffice\PhpWord\Element;
|
|||
* @method Text addText(string $text, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method TextRun addTextRun(mixed $pStyle = null)
|
||||
* @method Bookmark addBookmark(string $name)
|
||||
* @method Link addLink(string $target, string $text = null, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method Link addLink(string $target, string $text = null, mixed $fStyle = null, mixed $pStyle = null, boolean $internal = false)
|
||||
* @method PreserveText addPreserveText(string $text, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method void addTextBreak(int $count = 1, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method ListItem addListItem(string $txt, int $depth = 0, mixed $font = null, mixed $list = null, mixed $para = null)
|
||||
|
|
@ -37,9 +37,9 @@ namespace PhpOffice\PhpWord\Element;
|
|||
* @method PageBreak addPageBreak()
|
||||
* @method Table addTable(mixed $style = null)
|
||||
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false)
|
||||
* @method Object addObject(string $source, mixed $style = null)
|
||||
* @method \PhpOffice\PhpWord\Element\Object addObject(string $source, mixed $style = null)
|
||||
* @method TextBox addTextBox(mixed $style = null)
|
||||
* @method Field addField(string $type = null, array $properties = array(), array $options = array())
|
||||
* @method Field addField(string $type = null, array $properties = array(), array $options = array(), mixed $text = null)
|
||||
* @method Line addLine(mixed $lineStyle = null)
|
||||
* @method Shape addShape(string $type, mixed $style = null)
|
||||
* @method Chart addChart(string $type, array $categories, array $values, array $style = null)
|
||||
|
|
@ -58,7 +58,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
protected $elements = array();
|
||||
|
||||
/**
|
||||
* Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun
|
||||
* Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -83,7 +83,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object',
|
||||
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
|
||||
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
|
||||
'Chart', 'FormField', 'SDT'
|
||||
'Chart', 'FormField', 'SDT', 'Comment',
|
||||
);
|
||||
$functions = array();
|
||||
foreach ($elements as $element) {
|
||||
|
|
@ -98,16 +98,15 @@ abstract class AbstractContainer extends AbstractElement
|
|||
// Special case for TextBreak
|
||||
// @todo Remove the `$count` parameter in 1.0.0 to make this element similiar to other elements?
|
||||
if ($element == 'TextBreak') {
|
||||
@list($count, $fontStyle, $paragraphStyle) = $args; // Suppress error
|
||||
list($count, $fontStyle, $paragraphStyle) = array_pad($args, 3, null);
|
||||
if ($count === null) {
|
||||
$count = 1;
|
||||
}
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$this->addElement($element, $fontStyle, $paragraphStyle);
|
||||
}
|
||||
|
||||
// All other elements
|
||||
} else {
|
||||
// All other elements
|
||||
array_unshift($args, $element); // Prepend element name to the beginning of args array
|
||||
return call_user_func_array(array($this, 'addElement'), $args);
|
||||
}
|
||||
|
|
@ -158,8 +157,6 @@ abstract class AbstractContainer extends AbstractElement
|
|||
* Get all elements
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getElements()
|
||||
{
|
||||
|
|
@ -181,14 +178,13 @@ abstract class AbstractContainer extends AbstractElement
|
|||
*
|
||||
* @param string $method
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
* @return bool
|
||||
*/
|
||||
private function checkValidity($method)
|
||||
{
|
||||
$generalContainers = array(
|
||||
'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun',
|
||||
'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun', 'TrackChange',
|
||||
);
|
||||
|
||||
$validContainers = array(
|
||||
|
|
@ -203,7 +199,8 @@ abstract class AbstractContainer extends AbstractElement
|
|||
'Shape' => $generalContainers,
|
||||
'FormField' => $generalContainers,
|
||||
'SDT' => $generalContainers,
|
||||
'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
||||
'TrackChange' => $generalContainers,
|
||||
'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox', 'TrackChange'),
|
||||
'ListItem' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
||||
'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
||||
'Table' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
||||
|
|
@ -211,7 +208,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
'TextBox' => array('Section', 'Header', 'Footer', 'Cell'),
|
||||
'Footnote' => array('Section', 'TextRun', 'Cell'),
|
||||
'Endnote' => array('Section', 'TextRun', 'Cell'),
|
||||
'PreserveText' => array('Header', 'Footer', 'Cell'),
|
||||
'PreserveText' => array('Section', 'Header', 'Footer', 'Cell'),
|
||||
'Title' => array('Section'),
|
||||
'TOC' => array('Section'),
|
||||
'PageBreak' => array('Section'),
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ abstract class AbstractElement
|
|||
/**
|
||||
* Unique Id for element
|
||||
*
|
||||
* @var int
|
||||
* @var string
|
||||
*/
|
||||
protected $elementId;
|
||||
|
||||
|
|
@ -108,12 +108,26 @@ abstract class AbstractElement
|
|||
protected $mediaRelation = false;
|
||||
|
||||
/**
|
||||
* Is part of collection; true for Title, Footnote, Endnote, and Chart
|
||||
* Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $collectionRelation = false;
|
||||
|
||||
/**
|
||||
* The start position for the linked comment
|
||||
*
|
||||
* @var Comment
|
||||
*/
|
||||
protected $commentRangeStart;
|
||||
|
||||
/**
|
||||
* The end position for the linked comment
|
||||
*
|
||||
* @var Comment
|
||||
*/
|
||||
protected $commentRangeEnd;
|
||||
|
||||
/**
|
||||
* Get PhpWord
|
||||
*
|
||||
|
|
@ -128,7 +142,6 @@ abstract class AbstractElement
|
|||
* Set PhpWord as reference.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return void
|
||||
*/
|
||||
public function setPhpWord(PhpWord $phpWord = null)
|
||||
{
|
||||
|
|
@ -150,7 +163,6 @@ abstract class AbstractElement
|
|||
*
|
||||
* @param string $docPart
|
||||
* @param int $docPartId
|
||||
* @return void
|
||||
*/
|
||||
public function setDocPart($docPart, $docPartId = 1)
|
||||
{
|
||||
|
|
@ -207,7 +219,6 @@ abstract class AbstractElement
|
|||
* Set element index.
|
||||
*
|
||||
* @param int $value
|
||||
* @return void
|
||||
*/
|
||||
public function setElementIndex($value)
|
||||
{
|
||||
|
|
@ -217,7 +228,7 @@ abstract class AbstractElement
|
|||
/**
|
||||
* Get element unique ID
|
||||
*
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getElementId()
|
||||
{
|
||||
|
|
@ -226,8 +237,6 @@ abstract class AbstractElement
|
|||
|
||||
/**
|
||||
* Set element unique ID from 6 first digit of md5.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setElementId()
|
||||
{
|
||||
|
|
@ -248,7 +257,6 @@ abstract class AbstractElement
|
|||
* Set relation Id.
|
||||
*
|
||||
* @param int $value
|
||||
* @return void
|
||||
*/
|
||||
public function setRelationId($value)
|
||||
{
|
||||
|
|
@ -265,13 +273,60 @@ abstract class AbstractElement
|
|||
return $this->nestedLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment start
|
||||
*
|
||||
* @return Comment
|
||||
*/
|
||||
public function getCommentRangeStart()
|
||||
{
|
||||
return $this->commentRangeStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment start
|
||||
*
|
||||
* @param Comment $value
|
||||
*/
|
||||
public function setCommentRangeStart(Comment $value)
|
||||
{
|
||||
if ($this instanceof Comment) {
|
||||
throw new \InvalidArgumentException('Cannot set a Comment on a Comment');
|
||||
}
|
||||
$this->commentRangeStart = $value;
|
||||
$this->commentRangeStart->setStartElement($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment end
|
||||
*
|
||||
* @return Comment
|
||||
*/
|
||||
public function getCommentRangeEnd()
|
||||
{
|
||||
return $this->commentRangeEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment end
|
||||
*
|
||||
* @param Comment $value
|
||||
*/
|
||||
public function setCommentRangeEnd(Comment $value)
|
||||
{
|
||||
if ($this instanceof Comment) {
|
||||
throw new \InvalidArgumentException('Cannot set a Comment on a Comment');
|
||||
}
|
||||
$this->commentRangeEnd = $value;
|
||||
$this->commentRangeEnd->setEndElement($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent container
|
||||
*
|
||||
* Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $container
|
||||
* @return void
|
||||
*/
|
||||
public function setParentContainer(AbstractElement $container)
|
||||
{
|
||||
|
|
@ -300,8 +355,6 @@ abstract class AbstractElement
|
|||
*
|
||||
* - Image element needs to be passed to Media object
|
||||
* - Icon needs to be set for Object element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setMediaRelation()
|
||||
{
|
||||
|
|
@ -328,8 +381,6 @@ abstract class AbstractElement
|
|||
|
||||
/**
|
||||
* Set relation Id for elements that will be registered in the Collection subnamespaces.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setCollectionRelation()
|
||||
{
|
||||
|
|
@ -348,7 +399,7 @@ abstract class AbstractElement
|
|||
*/
|
||||
public function isInSection()
|
||||
{
|
||||
return ($this->docPart == 'Section');
|
||||
return $this->docPart == 'Section';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -378,9 +429,8 @@ abstract class AbstractElement
|
|||
* @param array $enum
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return mixed
|
||||
*
|
||||
* @todo Merge with the same method in AbstractStyle
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -45,9 +45,7 @@ class Bookmark extends AbstractElement
|
|||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
|
||||
$this->name = CommonText::toUTF8($name);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -83,7 +83,6 @@ class Chart extends AbstractElement
|
|||
* Set type.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setType($value)
|
||||
{
|
||||
|
|
@ -96,7 +95,6 @@ class Chart extends AbstractElement
|
|||
*
|
||||
* @param array $categories
|
||||
* @param array $values
|
||||
* @return void
|
||||
*/
|
||||
public function addSeries($categories, $values)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -40,7 +40,6 @@ class CheckBox extends Text
|
|||
* @param string $text
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
* @return self
|
||||
*/
|
||||
public function __construct($name = null, $text = null, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,121 @@
|
|||
<?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.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
* Comment element
|
||||
*/
|
||||
class Comment extends TrackChange
|
||||
{
|
||||
/**
|
||||
* Initials
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $initials;
|
||||
|
||||
/**
|
||||
* The Element where this comment starts
|
||||
*
|
||||
* @var AbstractElement
|
||||
*/
|
||||
private $startElement;
|
||||
|
||||
/**
|
||||
* The Element where this comment ends
|
||||
*
|
||||
* @var AbstractElement
|
||||
*/
|
||||
private $endElement;
|
||||
|
||||
/**
|
||||
* Is part of collection
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $collectionRelation = true;
|
||||
|
||||
/**
|
||||
* Create a new Comment Element
|
||||
*
|
||||
* @param string $author
|
||||
* @param \DateTime $date
|
||||
* @param string $initials
|
||||
*/
|
||||
public function __construct($author, $date = null, $initials = null)
|
||||
{
|
||||
parent::__construct($author, $date);
|
||||
$this->initials = $initials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Initials
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInitials()
|
||||
{
|
||||
return $this->initials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the element where this comment starts
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||
*/
|
||||
public function setStartElement(AbstractElement $value)
|
||||
{
|
||||
$this->startElement = $value;
|
||||
if ($value->getCommentRangeStart() == null) {
|
||||
$value->setCommentRangeStart($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element where this comment starts
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function getStartElement()
|
||||
{
|
||||
return $this->startElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the element where this comment ends
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||
*/
|
||||
public function setEndElement(AbstractElement $value)
|
||||
{
|
||||
$this->endElement = $value;
|
||||
if ($value->getCommentRangeEnd() == null) {
|
||||
$value->setCommentRangeEnd($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element where this comment ends
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function getEndElement()
|
||||
{
|
||||
return $this->endElement;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Element;
|
|||
* Field element
|
||||
*
|
||||
* @since 0.11.0
|
||||
* @link http://www.schemacentral.com/sc/ooxml/t-w_CT_SimpleField.html
|
||||
* @see http://www.schemacentral.com/sc/ooxml/t-w_CT_SimpleField.html
|
||||
*/
|
||||
class Field extends AbstractElement
|
||||
{
|
||||
|
|
@ -32,27 +32,36 @@ class Field extends AbstractElement
|
|||
* @var array
|
||||
*/
|
||||
protected $fieldsArray = array(
|
||||
'PAGE'=>array(
|
||||
'properties'=>array(
|
||||
'PAGE' => array(
|
||||
'properties' => array(
|
||||
'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
|
||||
),
|
||||
'options'=>array('PreserveFormat')
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
'NUMPAGES'=>array(
|
||||
'properties'=>array(
|
||||
'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
|
||||
'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%')
|
||||
'NUMPAGES' => array(
|
||||
'properties' => array(
|
||||
'format' => array('Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText',
|
||||
'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper', ),
|
||||
'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%'),
|
||||
),
|
||||
'options'=>array('PreserveFormat')
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
'DATE'=>array(
|
||||
'properties'=> array(
|
||||
'dateformat' =>array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd',
|
||||
'DATE' => array(
|
||||
'properties' => array(
|
||||
'dateformat' => array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd',
|
||||
'd-MMM-yy', 'd/M/yyyy', 'd MMM. yy', 'd/M/yy', 'MMM-yy', 'd-M-yyy H:mm', 'd-M-yyyy H:mm:ss',
|
||||
'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss')
|
||||
'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss', ),
|
||||
),
|
||||
'options' => array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat'),
|
||||
),
|
||||
'XE' => array(
|
||||
'properties' => array(),
|
||||
'options' => array('Bold', 'Italic'),
|
||||
),
|
||||
'INDEX' => array(
|
||||
'properties' => array(),
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
'options'=>array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat')
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
@ -62,6 +71,13 @@ class Field extends AbstractElement
|
|||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Field text
|
||||
*
|
||||
* @var TextRun | string
|
||||
*/
|
||||
protected $text;
|
||||
|
||||
/**
|
||||
* Field properties
|
||||
*
|
||||
|
|
@ -82,12 +98,14 @@ class Field extends AbstractElement
|
|||
* @param string $type
|
||||
* @param array $properties
|
||||
* @param array $options
|
||||
* @param TextRun | string $text
|
||||
*/
|
||||
public function __construct($type = null, $properties = array(), $options = array())
|
||||
public function __construct($type = null, $properties = array(), $options = array(), $text = null)
|
||||
{
|
||||
$this->setType($type);
|
||||
$this->setProperties($properties);
|
||||
$this->setOptions($options);
|
||||
$this->setText($text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -95,9 +113,8 @@ class Field extends AbstractElement
|
|||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return string
|
||||
*/
|
||||
public function setType($type = null)
|
||||
{
|
||||
|
|
@ -105,9 +122,10 @@ class Field extends AbstractElement
|
|||
if (isset($this->fieldsArray[$type])) {
|
||||
$this->type = $type;
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Invalid type");
|
||||
throw new \InvalidArgumentException("Invalid type '$type'");
|
||||
}
|
||||
}
|
||||
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
|
@ -126,20 +144,20 @@ class Field extends AbstractElement
|
|||
*
|
||||
* @param array $properties
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
public function setProperties($properties = array())
|
||||
{
|
||||
if (is_array($properties)) {
|
||||
foreach (array_keys($properties) as $propkey) {
|
||||
if (!(isset($this->fieldsArray[$this->type]['properties'][$propkey]))) {
|
||||
throw new \InvalidArgumentException("Invalid property");
|
||||
throw new \InvalidArgumentException("Invalid property '$propkey'");
|
||||
}
|
||||
}
|
||||
$this->properties = array_merge($this->properties, $properties);
|
||||
}
|
||||
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
|
|
@ -158,20 +176,20 @@ class Field extends AbstractElement
|
|||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
public function setOptions($options = array())
|
||||
{
|
||||
if (is_array($options)) {
|
||||
foreach (array_keys($options) as $optionkey) {
|
||||
if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey]))) {
|
||||
throw new \InvalidArgumentException("Invalid option");
|
||||
if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey])) && substr($optionkey, 0, 1) !== '\\') {
|
||||
throw new \InvalidArgumentException("Invalid option '$optionkey', possible values are " . implode(', ', $this->fieldsArray[$this->type]['options']));
|
||||
}
|
||||
}
|
||||
$this->options = array_merge($this->options, $options);
|
||||
}
|
||||
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
|
|
@ -184,4 +202,35 @@ class Field extends AbstractElement
|
|||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Field text
|
||||
*
|
||||
* @param string|TextRun $text
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return string|TextRun
|
||||
*/
|
||||
public function setText($text)
|
||||
{
|
||||
if (isset($text)) {
|
||||
if (is_string($text) || $text instanceof TextRun) {
|
||||
$this->text = $text;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid text');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Field text
|
||||
*
|
||||
* @return string|TextRun
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ class Footer extends AbstractContainer
|
|||
* Header/footer types constants
|
||||
*
|
||||
* @var string
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-wtype-4.html Header or Footer Type
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type
|
||||
*/
|
||||
const AUTO = 'default'; // default and odd pages
|
||||
const FIRST = 'first';
|
||||
|
|
@ -64,7 +64,6 @@ class Footer extends AbstractContainer
|
|||
* @since 0.10.0
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setType($value = self::AUTO)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -19,9 +19,6 @@ namespace PhpOffice\PhpWord\Element;
|
|||
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Footnote extends AbstractContainer
|
||||
{
|
||||
/**
|
||||
|
|
@ -68,6 +65,7 @@ class Footnote extends AbstractContainer
|
|||
* Get Footnote Reference ID
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
@ -80,6 +78,7 @@ class Footnote extends AbstractContainer
|
|||
* Set Footnote Reference ID
|
||||
*
|
||||
* @deprecated 0.10.0
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Element;
|
|||
* Form field element
|
||||
*
|
||||
* @since 0.12.0
|
||||
* @link http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html
|
||||
*/
|
||||
class FormField extends Text
|
||||
{
|
||||
|
|
@ -35,7 +35,7 @@ class FormField extends Text
|
|||
/**
|
||||
* Form field name
|
||||
*
|
||||
* @var string
|
||||
* @var string|bool|int
|
||||
*/
|
||||
private $name;
|
||||
|
||||
|
|
@ -70,10 +70,10 @@ class FormField extends Text
|
|||
* @param string $type
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
* @return self
|
||||
*/
|
||||
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
parent::__construct(null, $fontStyle, $paragraphStyle);
|
||||
$this->setType($type);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Is watermark
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $watermark;
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Is memory image
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $memoryImage;
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Image media index
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $mediaIndex;
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ class Image extends AbstractElement
|
|||
*
|
||||
* @param string $source
|
||||
* @param mixed $style
|
||||
* @param boolean $watermark
|
||||
* @param bool $watermark
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||
|
|
@ -183,7 +183,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Get is watermark
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isWatermark()
|
||||
{
|
||||
|
|
@ -193,7 +193,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Set is watermark
|
||||
*
|
||||
* @param boolean $value
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setIsWatermark($value)
|
||||
{
|
||||
|
|
@ -243,7 +243,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Get is memory image
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isMemImage()
|
||||
{
|
||||
|
|
@ -264,7 +264,6 @@ class Image extends AbstractElement
|
|||
* Set target file name.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setTarget($value)
|
||||
{
|
||||
|
|
@ -274,7 +273,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Get media index
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getMediaIndex()
|
||||
{
|
||||
|
|
@ -284,8 +283,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Set media index.
|
||||
*
|
||||
* @param integer $value
|
||||
* @return void
|
||||
* @param int $value
|
||||
*/
|
||||
public function setMediaIndex($value)
|
||||
{
|
||||
|
|
@ -340,6 +338,8 @@ class Image extends AbstractElement
|
|||
call_user_func($this->imageFunc, $imageResource);
|
||||
$imageBinary = ob_get_contents();
|
||||
ob_end_clean();
|
||||
} elseif ($this->sourceType == self::SOURCE_STRING) {
|
||||
$imageBinary = $this->source;
|
||||
} else {
|
||||
$fileHandle = fopen($actualSource, 'rb', false);
|
||||
if ($fileHandle !== false) {
|
||||
|
|
@ -366,33 +366,29 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Check memory image, supported type, image functions, and proportional width/height.
|
||||
*
|
||||
* @param string $source
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||
*/
|
||||
private function checkImage($source)
|
||||
private function checkImage()
|
||||
{
|
||||
$this->setSourceType($source);
|
||||
$this->setSourceType();
|
||||
|
||||
// Check image data
|
||||
if ($this->sourceType == self::SOURCE_ARCHIVE) {
|
||||
$imageData = $this->getArchiveImageSize($source);
|
||||
} else if ($this->sourceType == self::SOURCE_STRING) {
|
||||
$imageData = $this->getStringImageSize($source);
|
||||
$imageData = $this->getArchiveImageSize($this->source);
|
||||
} elseif ($this->sourceType == self::SOURCE_STRING) {
|
||||
$imageData = $this->getStringImageSize($this->source);
|
||||
} else {
|
||||
$imageData = @getimagesize($source);
|
||||
$imageData = @getimagesize($this->source);
|
||||
}
|
||||
if (!is_array($imageData)) {
|
||||
throw new InvalidImageException(sprintf('Invalid image: %s', $source));
|
||||
throw new InvalidImageException(sprintf('Invalid image: %s', $this->source));
|
||||
}
|
||||
list($actualWidth, $actualHeight, $imageType) = $imageData;
|
||||
|
||||
// Check image type support
|
||||
$supportedTypes = array(IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG);
|
||||
if ($this->sourceType != self::SOURCE_GD) {
|
||||
if ($this->sourceType != self::SOURCE_GD && $this->sourceType != self::SOURCE_STRING) {
|
||||
$supportedTypes = array_merge($supportedTypes, array(IMAGETYPE_BMP, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM));
|
||||
}
|
||||
if (!in_array($imageType, $supportedTypes)) {
|
||||
|
|
@ -407,22 +403,25 @@ class Image extends AbstractElement
|
|||
|
||||
/**
|
||||
* Set source type.
|
||||
*
|
||||
* @param string $source
|
||||
* @return void
|
||||
*/
|
||||
private function setSourceType($source)
|
||||
private function setSourceType()
|
||||
{
|
||||
if (stripos(strrev($source), strrev('.php')) === 0) {
|
||||
if (stripos(strrev($this->source), strrev('.php')) === 0) {
|
||||
$this->memoryImage = true;
|
||||
$this->sourceType = self::SOURCE_GD;
|
||||
} elseif (strpos($source, 'zip://') !== false) {
|
||||
} elseif (strpos($this->source, 'zip://') !== false) {
|
||||
$this->memoryImage = false;
|
||||
$this->sourceType = self::SOURCE_ARCHIVE;
|
||||
} elseif (filter_var($source, FILTER_VALIDATE_URL) !== false) {
|
||||
} elseif (filter_var($this->source, FILTER_VALIDATE_URL) !== false) {
|
||||
$this->memoryImage = true;
|
||||
if (strpos($this->source, 'https') === 0) {
|
||||
$fileContent = file_get_contents($this->source);
|
||||
$this->source = $fileContent;
|
||||
$this->sourceType = self::SOURCE_STRING;
|
||||
} else {
|
||||
$this->sourceType = self::SOURCE_GD;
|
||||
} elseif (@file_exists($source)) {
|
||||
}
|
||||
} elseif (@file_exists($this->source)) {
|
||||
$this->memoryImage = false;
|
||||
$this->sourceType = self::SOURCE_LOCAL;
|
||||
} else {
|
||||
|
|
@ -438,9 +437,9 @@ class Image extends AbstractElement
|
|||
*
|
||||
* @param string $source
|
||||
*
|
||||
* @return array|null
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
private function getArchiveImageSize($source)
|
||||
{
|
||||
|
|
@ -450,7 +449,7 @@ class Image extends AbstractElement
|
|||
|
||||
$tempFilename = tempnam(Settings::getTempDir(), 'PHPWordImage');
|
||||
if (false === $tempFilename) {
|
||||
throw new CreateTemporaryFileException();
|
||||
throw new CreateTemporaryFileException(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
|
@ -478,36 +477,36 @@ class Image extends AbstractElement
|
|||
*/
|
||||
private function getStringImageSize($source)
|
||||
{
|
||||
$result = false;
|
||||
if (!function_exists('getimagesizefromstring')) {
|
||||
$uri = 'data://application/octet-stream;base64,' . base64_encode($source);
|
||||
return @getimagesize($uri);
|
||||
$result = @getimagesize($uri);
|
||||
} else {
|
||||
return @getimagesizefromstring($source);
|
||||
$result = @getimagesizefromstring($source);
|
||||
}
|
||||
return false;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image functions and extensions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setFunctions()
|
||||
{
|
||||
switch ($this->imageType) {
|
||||
case 'image/png':
|
||||
$this->imageCreateFunc = 'imagecreatefrompng';
|
||||
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefrompng';
|
||||
$this->imageFunc = 'imagepng';
|
||||
$this->imageExtension = 'png';
|
||||
break;
|
||||
case 'image/gif':
|
||||
$this->imageCreateFunc = 'imagecreatefromgif';
|
||||
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefromgif';
|
||||
$this->imageFunc = 'imagegif';
|
||||
$this->imageExtension = 'gif';
|
||||
break;
|
||||
case 'image/jpeg':
|
||||
case 'image/jpg':
|
||||
$this->imageCreateFunc = 'imagecreatefromjpeg';
|
||||
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefromjpeg';
|
||||
$this->imageFunc = 'imagejpeg';
|
||||
$this->imageExtension = 'jpg';
|
||||
break;
|
||||
|
|
@ -525,9 +524,8 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Set proportional width/height if one dimension not available.
|
||||
*
|
||||
* @param integer $actualWidth
|
||||
* @param integer $actualHeight
|
||||
* @return void
|
||||
* @param int $actualWidth
|
||||
* @param int $actualHeight
|
||||
*/
|
||||
private function setProportionalSize($actualWidth, $actualHeight)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -75,6 +75,7 @@ class Link extends AbstractElement
|
|||
* @param string $text
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
* @param bool $internal
|
||||
*/
|
||||
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
|
||||
{
|
||||
|
|
@ -83,7 +84,6 @@ class Link extends AbstractElement
|
|||
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||
$this->internal = $internal;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -84,9 +84,9 @@ class Object extends AbstractElement
|
|||
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
|
||||
|
||||
return $this;
|
||||
} else {
|
||||
throw new InvalidObjectException();
|
||||
}
|
||||
|
||||
throw new InvalidObjectException();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -133,7 +133,6 @@ class Object extends AbstractElement
|
|||
* Set Image Relation ID.
|
||||
*
|
||||
* @param int $rId
|
||||
* @return void
|
||||
*/
|
||||
public function setImageRelationId($rId)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -47,14 +47,12 @@ class PreserveText extends AbstractElement
|
|||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Preserve Text Element
|
||||
*
|
||||
* @param string $text
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
* @return self
|
||||
*/
|
||||
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -45,16 +45,30 @@ class SDT extends Text
|
|||
*/
|
||||
private $listItems = array();
|
||||
|
||||
/**
|
||||
* Alias
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $alias;
|
||||
|
||||
/**
|
||||
* Tag
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tag;
|
||||
|
||||
/**
|
||||
* Create new instance
|
||||
*
|
||||
* @param string $type
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
* @return self
|
||||
*/
|
||||
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
parent::__construct(null, $fontStyle, $paragraphStyle);
|
||||
$this->setType($type);
|
||||
}
|
||||
|
||||
|
|
@ -127,4 +141,50 @@ class SDT extends Text
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tag
|
||||
*
|
||||
* @param string $tag
|
||||
* @return self
|
||||
*/
|
||||
public function setTag($tag)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alias
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlias()
|
||||
{
|
||||
return $this->alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alias
|
||||
*
|
||||
* @param string $alias
|
||||
* @return self
|
||||
*/
|
||||
public function setAlias($alias)
|
||||
{
|
||||
$this->alias = $alias;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,14 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
|
||||
use PhpOffice\PhpWord\Style\Section as SectionStyle;
|
||||
|
||||
class Section extends AbstractContainer
|
||||
|
|
@ -47,6 +48,13 @@ class Section extends AbstractContainer
|
|||
*/
|
||||
private $footers = array();
|
||||
|
||||
/**
|
||||
* The properties for the footnote of this section
|
||||
*
|
||||
* @var FootnoteProperties
|
||||
*/
|
||||
private $footnoteProperties;
|
||||
|
||||
/**
|
||||
* Create new instance
|
||||
*
|
||||
|
|
@ -65,7 +73,6 @@ class Section extends AbstractContainer
|
|||
* Set section style.
|
||||
*
|
||||
* @param array $style
|
||||
* @return void
|
||||
*/
|
||||
public function setStyle($style = null)
|
||||
{
|
||||
|
|
@ -78,8 +85,6 @@ class Section extends AbstractContainer
|
|||
* Get section style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Section
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
|
|
@ -118,8 +123,6 @@ class Section extends AbstractContainer
|
|||
* Get header elements
|
||||
*
|
||||
* @return Header[]
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
|
|
@ -130,21 +133,39 @@ class Section extends AbstractContainer
|
|||
* Get footer elements
|
||||
*
|
||||
* @return Footer[]
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getFooters()
|
||||
{
|
||||
return $this->footers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the footnote properties
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\FooterProperties
|
||||
*/
|
||||
public function getFootnotePropoperties()
|
||||
{
|
||||
return $this->footnoteProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the footnote properties
|
||||
*
|
||||
* @param FootnoteProperties $footnoteProperties
|
||||
*/
|
||||
public function setFootnoteProperties(FootnoteProperties $footnoteProperties = null)
|
||||
{
|
||||
$this->footnoteProperties = $footnoteProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is there a header for this section that is for the first page only?
|
||||
*
|
||||
* If any of the Header instances have a type of Header::FIRST then this method returns true.
|
||||
* False otherwise.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDifferentFirstPage()
|
||||
{
|
||||
|
|
@ -153,6 +174,12 @@ class Section extends AbstractContainer
|
|||
return true;
|
||||
}
|
||||
}
|
||||
foreach ($this->footers as $footer) {
|
||||
if ($footer->getType() == Header::FIRST) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -162,11 +189,11 @@ class Section extends AbstractContainer
|
|||
* @since 0.10.0
|
||||
*
|
||||
* @param string $type
|
||||
* @param boolean $header
|
||||
*
|
||||
* @return Header|Footer
|
||||
* @param bool $header
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return Header|Footer
|
||||
*/
|
||||
private function addHeaderFooter($type = Header::AUTO, $header = true)
|
||||
{
|
||||
|
|
@ -182,11 +209,10 @@ class Section extends AbstractContainer
|
|||
$container->setPhpWord($this->phpWord);
|
||||
|
||||
$collection[$index] = $container;
|
||||
return $container;
|
||||
} else {
|
||||
throw new \Exception('Invalid header/footer type.');
|
||||
}
|
||||
|
||||
return $container;
|
||||
}
|
||||
throw new \Exception('Invalid header/footer type.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -258,8 +284,8 @@ class Section extends AbstractContainer
|
|||
{
|
||||
if (empty($this->footers)) {
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
|
||||
return $this->footers[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ class TOC extends AbstractElement
|
|||
/**
|
||||
* Font style
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font|array|string
|
||||
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
|
|
@ -54,14 +54,13 @@ class TOC extends AbstractElement
|
|||
*/
|
||||
private $maxDepth = 9;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Table-of-Contents Element
|
||||
*
|
||||
* @param mixed $fontStyle
|
||||
* @param array $tocStyle
|
||||
* @param integer $minDepth
|
||||
* @param integer $maxDepth
|
||||
* @param int $minDepth
|
||||
* @param int $maxDepth
|
||||
*/
|
||||
public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9)
|
||||
{
|
||||
|
|
@ -121,7 +120,7 @@ class TOC extends AbstractElement
|
|||
/**
|
||||
* Get Font Style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font
|
||||
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||
*/
|
||||
public function getStyleFont()
|
||||
{
|
||||
|
|
@ -132,7 +131,6 @@ class TOC extends AbstractElement
|
|||
* Set max depth.
|
||||
*
|
||||
* @param int $value
|
||||
* @return void
|
||||
*/
|
||||
public function setMaxDepth($value)
|
||||
{
|
||||
|
|
@ -153,7 +151,6 @@ class TOC extends AbstractElement
|
|||
* Set min depth.
|
||||
*
|
||||
* @param int $value
|
||||
* @return void
|
||||
*/
|
||||
public function setMinDepth($value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -121,7 +121,6 @@ class Table extends AbstractElement
|
|||
* Set table width.
|
||||
*
|
||||
* @param int $width
|
||||
* @return void
|
||||
*/
|
||||
public function setWidth($width)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -105,12 +105,12 @@ class Text extends AbstractElement
|
|||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
if (is_array($style)) {
|
||||
$this->paragraphStyle = new Paragraph;
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
$this->paragraphStyle->setStyleByArray($style);
|
||||
} elseif ($style instanceof Paragraph) {
|
||||
$this->paragraphStyle = $style;
|
||||
} elseif (null === $style) {
|
||||
$this->paragraphStyle = new Paragraph;
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
} else {
|
||||
$this->paragraphStyle = $style;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -74,6 +74,7 @@ class TextBreak extends AbstractElement
|
|||
$this->fontStyle = $style;
|
||||
$this->setParagraphStyle($paragraphStyle);
|
||||
}
|
||||
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
|
|
@ -96,13 +97,14 @@ class TextBreak extends AbstractElement
|
|||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
if (is_array($style)) {
|
||||
$this->paragraphStyle = new Paragraph;
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
$this->paragraphStyle->setStyleByArray($style);
|
||||
} elseif ($style instanceof Paragraph) {
|
||||
$this->paragraphStyle = $style;
|
||||
} else {
|
||||
$this->paragraphStyle = $style;
|
||||
}
|
||||
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ class Title extends AbstractElement
|
|||
/**
|
||||
* Get depth
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getDepth()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
<?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.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
* TrackChange element
|
||||
*/
|
||||
class TrackChange extends AbstractContainer
|
||||
{
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'TrackChange';
|
||||
|
||||
/**
|
||||
* Author
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $author;
|
||||
|
||||
/**
|
||||
* Date
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* Create a new TrackChange Element
|
||||
*
|
||||
* @param string $author
|
||||
* @param \DateTime $date
|
||||
*/
|
||||
public function __construct($author, \DateTime $date = null)
|
||||
{
|
||||
$this->author = $author;
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TrackChange Author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TrackChange Date
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -28,9 +28,9 @@ class Rtf extends AbstractEscaper
|
|||
{
|
||||
if (20 > $code || $code >= 80) {
|
||||
return '{\u' . $code . '}';
|
||||
} else {
|
||||
return chr($code);
|
||||
}
|
||||
|
||||
return chr($code);
|
||||
}
|
||||
|
||||
protected function escapeMultibyteCharacter($code)
|
||||
|
|
@ -40,6 +40,7 @@ class Rtf extends AbstractEscaper
|
|||
|
||||
/**
|
||||
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||
* @param string $input
|
||||
*/
|
||||
protected function escapeSingleValue($input)
|
||||
{
|
||||
|
|
@ -57,9 +58,9 @@ class Rtf extends AbstractEscaper
|
|||
if (0 == count($bytes)) {
|
||||
if ($asciiCode < 224) {
|
||||
$numberOfBytes = 2;
|
||||
} else if ($asciiCode < 240) {
|
||||
} elseif ($asciiCode < 240) {
|
||||
$numberOfBytes = 3;
|
||||
} else if ($asciiCode < 248) {
|
||||
} elseif ($asciiCode < 248) {
|
||||
$numberOfBytes = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -23,10 +23,10 @@ namespace PhpOffice\PhpWord\Exception;
|
|||
final class CopyFileException extends Exception
|
||||
{
|
||||
/**
|
||||
* @param string $source The fully qualified source file name.
|
||||
* @param string $destination The fully qualified destination file name.
|
||||
* @param integer $code The user defined exception code.
|
||||
* @param \Exception $previous The previous exception used for the exception chaining.
|
||||
* @param string $source The fully qualified source file name
|
||||
* @param string $destination The fully qualified destination file name
|
||||
* @param int $code The user defined exception code
|
||||
* @param \Exception $previous The previous exception used for the exception chaining
|
||||
*/
|
||||
final public function __construct($source, $destination, $code = 0, \Exception $previous = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -23,8 +23,8 @@ namespace PhpOffice\PhpWord\Exception;
|
|||
final class CreateTemporaryFileException extends Exception
|
||||
{
|
||||
/**
|
||||
* @param integer $code The user defined exception code.
|
||||
* @param \Exception $previous The previous exception used for the exception chaining.
|
||||
* @param int $code The user defined exception code
|
||||
* @param \Exception $previous The previous exception used for the exception chaining
|
||||
*/
|
||||
final public function __construct($code = 0, \Exception $previous = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -29,9 +29,9 @@ abstract class IOFactory
|
|||
* @param PhpWord $phpWord
|
||||
* @param string $name
|
||||
*
|
||||
* @return WriterInterface
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return WriterInterface
|
||||
*/
|
||||
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
|
||||
{
|
||||
|
|
@ -49,9 +49,9 @@ abstract class IOFactory
|
|||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return ReaderInterface
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return ReaderInterface
|
||||
*/
|
||||
public static function createReader($name = 'Word2007')
|
||||
{
|
||||
|
|
@ -65,19 +65,19 @@ abstract class IOFactory
|
|||
* @param string $name
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
|
||||
*/
|
||||
private static function createObject($type, $name, $phpWord = null)
|
||||
{
|
||||
$class = "PhpOffice\\PhpWord\\{$type}\\{$name}";
|
||||
if (class_exists($class) && self::isConcreteClass($class)) {
|
||||
return new $class($phpWord);
|
||||
} else {
|
||||
}
|
||||
throw new Exception("\"{$name}\" is not a valid {$type}.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PhpWord from file
|
||||
*
|
||||
|
|
@ -89,8 +89,10 @@ abstract class IOFactory
|
|||
{
|
||||
/** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */
|
||||
$reader = self::createReader($readerName);
|
||||
|
||||
return $reader->load($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if it's a concrete class (not abstract nor interface)
|
||||
*
|
||||
|
|
@ -100,6 +102,7 @@ abstract class IOFactory
|
|||
private static function isConcreteClass($class)
|
||||
{
|
||||
$reflection = new \ReflectionClass($class);
|
||||
|
||||
return !$reflection->isAbstract() && !$reflection->isInterface();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -43,9 +43,9 @@ class Media
|
|||
* @param string $source
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function addElement($container, $mediaType, $source, Image $image = null)
|
||||
{
|
||||
|
|
@ -83,12 +83,10 @@ class Media
|
|||
$image->setTarget($target);
|
||||
$image->setMediaIndex($mediaTypeCount);
|
||||
break;
|
||||
|
||||
// Objects
|
||||
case 'object':
|
||||
$target = "{$container}_oleObject{$mediaTypeCount}.bin";
|
||||
break;
|
||||
|
||||
// Links
|
||||
case 'link':
|
||||
$target = $source;
|
||||
|
|
@ -100,23 +98,25 @@ class Media
|
|||
$mediaData['type'] = $mediaType;
|
||||
$mediaData['rID'] = $rId;
|
||||
self::$elements[$container][$mediaId] = $mediaData;
|
||||
|
||||
return $rId;
|
||||
} else {
|
||||
}
|
||||
|
||||
$mediaData = self::$elements[$container][$mediaId];
|
||||
if (!is_null($image)) {
|
||||
$image->setTarget($mediaData['target']);
|
||||
$image->setMediaIndex($mediaData['mediaIndex']);
|
||||
}
|
||||
|
||||
return $mediaData['rID'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media elements count
|
||||
*
|
||||
* @param string $container section|headerx|footerx|footnote|endnote
|
||||
* @param string $mediaType image|object|link
|
||||
* @return integer
|
||||
* @return int
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static function countElements($container, $mediaType = null)
|
||||
|
|
@ -157,14 +157,16 @@ class Media
|
|||
$elements[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
return $elements;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!isset(self::$elements[$container])) {
|
||||
return $elements;
|
||||
}
|
||||
|
||||
return self::getElementsByType($container, $type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get elements by media type
|
||||
|
|
@ -208,7 +210,7 @@ class Media
|
|||
* @param string $type
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -224,7 +226,7 @@ class Media
|
|||
*
|
||||
* @param string $linkSrc
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -256,7 +258,7 @@ class Media
|
|||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -270,11 +272,11 @@ class Media
|
|||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param integer $headerCount
|
||||
* @param int $headerCount
|
||||
* @param string $src
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -290,7 +292,7 @@ class Media
|
|||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -318,11 +320,11 @@ class Media
|
|||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param integer $footerCount
|
||||
* @param int $footerCount
|
||||
* @param string $src
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -338,7 +340,7 @@ class Media
|
|||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Metadata;
|
|||
* Compatibility setting class
|
||||
*
|
||||
* @since 0.12.0
|
||||
* @link http://www.datypic.com/sc/ooxml/t-w_CT_Compat.html
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_Compat.html
|
||||
*/
|
||||
class Compatibility
|
||||
{
|
||||
|
|
@ -33,7 +33,7 @@ class Compatibility
|
|||
* 15 = 2013
|
||||
*
|
||||
* @var int
|
||||
* @link http://msdn.microsoft.com/en-us/library/dd909048%28v=office.12%29.aspx
|
||||
* @see http://msdn.microsoft.com/en-us/library/dd909048%28v=office.12%29.aspx
|
||||
*/
|
||||
private $ooxmlVersion = 12;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ class DocInfo
|
|||
* Check if a Custom Property is defined
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isCustomPropertySet($propertyName)
|
||||
{
|
||||
|
|
@ -416,9 +416,9 @@ class DocInfo
|
|||
{
|
||||
if ($this->isCustomPropertySet($propertyName)) {
|
||||
return $this->customProperties[$propertyName]['value'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -431,9 +431,9 @@ class DocInfo
|
|||
{
|
||||
if ($this->isCustomPropertySet($propertyName)) {
|
||||
return $this->customProperties[$propertyName]['type'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -456,7 +456,7 @@ class DocInfo
|
|||
self::PROPERTY_TYPE_FLOAT,
|
||||
self::PROPERTY_TYPE_STRING,
|
||||
self::PROPERTY_TYPE_DATE,
|
||||
self::PROPERTY_TYPE_BOOLEAN
|
||||
self::PROPERTY_TYPE_BOOLEAN,
|
||||
);
|
||||
if (($propertyType === null) || (!in_array($propertyType, $propertyTypes))) {
|
||||
if ($propertyValue === null) {
|
||||
|
|
@ -467,6 +467,8 @@ class DocInfo
|
|||
$propertyType = self::PROPERTY_TYPE_INTEGER;
|
||||
} elseif (is_bool($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
|
||||
} elseif ($propertyValue instanceof \DateTime) {
|
||||
$propertyType = self::PROPERTY_TYPE_DATE;
|
||||
} else {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
}
|
||||
|
|
@ -474,8 +476,9 @@ class DocInfo
|
|||
|
||||
$this->customProperties[$propertyName] = array(
|
||||
'value' => $propertyValue,
|
||||
'type' => $propertyType
|
||||
'type' => $propertyType,
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Metadata;
|
|||
* Document protection class
|
||||
*
|
||||
* @since 0.12.0
|
||||
* @link http://www.datypic.com/sc/ooxml/t-w_CT_DocProtect.html
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_DocProtect.html
|
||||
*/
|
||||
class Protection
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ class Protection
|
|||
* Editing restriction none|readOnly|comments|trackedChanges|forms
|
||||
*
|
||||
* @var string
|
||||
* @link http://www.datypic.com/sc/ooxml/a-w_edit-1.html
|
||||
* @see http://www.datypic.com/sc/ooxml/a-w_edit-1.html
|
||||
*/
|
||||
private $editing;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,367 @@
|
|||
<?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.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 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\ComplexType\TrackChangesView;
|
||||
use PhpOffice\PhpWord\SimpleType\Zoom;
|
||||
use PhpOffice\PhpWord\Style\Language;
|
||||
|
||||
/**
|
||||
* Setting class
|
||||
*
|
||||
* @since 0.14.0
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_Settings.html
|
||||
*/
|
||||
class Settings
|
||||
{
|
||||
/**
|
||||
* Magnification Setting
|
||||
*
|
||||
* @see 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;
|
||||
|
||||
/**
|
||||
* Mirror Page Margins
|
||||
*
|
||||
* @see http://www.datypic.com/sc/ooxml/e-w_mirrorMargins-1.html
|
||||
* @var bool
|
||||
*/
|
||||
private $mirrorMargins;
|
||||
|
||||
/**
|
||||
* Hide spelling errors
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $hideSpellingErrors = false;
|
||||
|
||||
/**
|
||||
* Hide grammatical errors
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $hideGrammaticalErrors = false;
|
||||
|
||||
/**
|
||||
* Visibility of Annotation Types
|
||||
*
|
||||
* @var TrackChangesView
|
||||
*/
|
||||
private $revisionView;
|
||||
|
||||
/**
|
||||
* Track Revisions to Document
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $trackRevisions = false;
|
||||
|
||||
/**
|
||||
* Do Not Use Move Syntax When Tracking Revisions
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $doNotTrackMoves = false;
|
||||
|
||||
/**
|
||||
* Do Not Track Formatting Revisions When Tracking Revisions
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $doNotTrackFormatting = false;
|
||||
|
||||
/**
|
||||
* Spelling and Grammatical Checking State
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\ComplexType\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 bool
|
||||
*/
|
||||
public function hasHideSpellingErrors()
|
||||
{
|
||||
return $this->hideSpellingErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide spelling errors
|
||||
*
|
||||
* @param bool $hideSpellingErrors
|
||||
*/
|
||||
public function setHideSpellingErrors($hideSpellingErrors)
|
||||
{
|
||||
$this->hideSpellingErrors = $hideSpellingErrors === null ? true : $hideSpellingErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are grammatical errors hidden
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasHideGrammaticalErrors()
|
||||
{
|
||||
return $this->hideGrammaticalErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide grammatical errors
|
||||
*
|
||||
* @param bool $hideGrammaticalErrors
|
||||
*/
|
||||
public function setHideGrammaticalErrors($hideGrammaticalErrors)
|
||||
{
|
||||
$this->hideGrammaticalErrors = $hideGrammaticalErrors === null ? true : $hideGrammaticalErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEvenAndOddHeaders()
|
||||
{
|
||||
return $this->evenAndOddHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $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 bool
|
||||
*/
|
||||
public function hasTrackRevisions()
|
||||
{
|
||||
return $this->trackRevisions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $trackRevisions
|
||||
*/
|
||||
public function setTrackRevisions($trackRevisions)
|
||||
{
|
||||
$this->trackRevisions = $trackRevisions === null ? true : $trackRevisions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDoNotTrackMoves()
|
||||
{
|
||||
return $this->doNotTrackMoves;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $doNotTrackMoves
|
||||
*/
|
||||
public function setDoNotTrackMoves($doNotTrackMoves)
|
||||
{
|
||||
$this->doNotTrackMoves = $doNotTrackMoves === null ? true : $doNotTrackMoves;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDoNotTrackFormatting()
|
||||
{
|
||||
return $this->doNotTrackFormatting;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasMirrorMargins()
|
||||
{
|
||||
return $this->mirrorMargins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $mirrorMargins
|
||||
*/
|
||||
public function setMirrorMargins($mirrorMargins)
|
||||
{
|
||||
$this->mirrorMargins = $mirrorMargins;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -27,11 +27,13 @@ use PhpOffice\PhpWord\Exception\Exception;
|
|||
* @method Collection\Footnotes getFootnotes()
|
||||
* @method Collection\Endnotes getEndnotes()
|
||||
* @method Collection\Charts getCharts()
|
||||
* @method Collection\Comments getComments()
|
||||
* @method int addBookmark(Element\Bookmark $bookmark)
|
||||
* @method int addTitle(Element\Title $title)
|
||||
* @method int addFootnote(Element\Footnote $footnote)
|
||||
* @method int addEndnote(Element\Endnote $endnote)
|
||||
* @method int addChart(Element\Chart $chart)
|
||||
* @method int addComment(Element\Comment $comment)
|
||||
*
|
||||
* @method Style\Paragraph addParagraphStyle(string $styleName, array $styles)
|
||||
* @method Style\Font addFontStyle(string $styleName, mixed $fontStyle, mixed $paragraphStyle = null)
|
||||
|
|
@ -84,14 +86,14 @@ class PhpWord
|
|||
public function __construct()
|
||||
{
|
||||
// Collection
|
||||
$collections = array('Bookmarks', 'Titles', 'Footnotes', 'Endnotes', 'Charts');
|
||||
$collections = array('Bookmarks', 'Titles', 'Footnotes', 'Endnotes', 'Charts', 'Comments');
|
||||
foreach ($collections as $collection) {
|
||||
$class = 'PhpOffice\\PhpWord\\Collection\\' . $collection;
|
||||
$this->collections[$collection] = new $class();
|
||||
}
|
||||
|
||||
// Metadata
|
||||
$metadata = array('DocInfo', 'Protection', 'Compatibility');
|
||||
$metadata = array('DocInfo', 'Settings', 'Compatibility');
|
||||
foreach ($metadata as $meta) {
|
||||
$class = 'PhpOffice\\PhpWord\\Metadata\\' . $meta;
|
||||
$this->metadata[$meta] = new $class();
|
||||
|
|
@ -106,9 +108,9 @@ class PhpWord
|
|||
* @param mixed $function
|
||||
* @param mixed $args
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($function, $args)
|
||||
{
|
||||
|
|
@ -118,7 +120,7 @@ class PhpWord
|
|||
$addCollection = array();
|
||||
$addStyle = array();
|
||||
|
||||
$collections = array('Bookmark', 'Title', 'Footnote', 'Endnote', 'Chart');
|
||||
$collections = array('Bookmark', 'Title', 'Footnote', 'Endnote', 'Chart', 'Comment');
|
||||
foreach ($collections as $collection) {
|
||||
$getCollection[] = strtolower("get{$collection}s");
|
||||
$addCollection[] = strtolower("add{$collection}");
|
||||
|
|
@ -170,10 +172,12 @@ class PhpWord
|
|||
*
|
||||
* @return \PhpOffice\PhpWord\Metadata\Protection
|
||||
* @since 0.12.0
|
||||
* @deprecated Get the Document protection from PhpWord->getSettings()->getDocumentProtection();
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getProtection()
|
||||
{
|
||||
return $this->metadata['Protection'];
|
||||
return $this->getSettings()->getDocumentProtection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -187,6 +191,17 @@ class PhpWord
|
|||
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
|
||||
*
|
||||
|
|
@ -226,7 +241,6 @@ class PhpWord
|
|||
* Set default font name.
|
||||
*
|
||||
* @param string $fontName
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultFontName($fontName)
|
||||
{
|
||||
|
|
@ -236,7 +250,7 @@ class PhpWord
|
|||
/**
|
||||
* Get default font size
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultFontSize()
|
||||
{
|
||||
|
|
@ -247,7 +261,6 @@ class PhpWord
|
|||
* Set default font size.
|
||||
*
|
||||
* @param int $fontSize
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultFontSize($fontSize)
|
||||
{
|
||||
|
|
@ -270,21 +283,20 @@ class PhpWord
|
|||
*
|
||||
* @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead.
|
||||
*
|
||||
* @param string $filename Fully qualified filename.
|
||||
*
|
||||
* @return TemplateProcessor
|
||||
* @param string $filename Fully qualified filename
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return TemplateProcessor
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function loadTemplate($filename)
|
||||
{
|
||||
if (file_exists($filename)) {
|
||||
return new TemplateProcessor($filename);
|
||||
} else {
|
||||
throw new Exception("Template file {$filename} not found.");
|
||||
}
|
||||
throw new Exception("Template file {$filename} not found.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -310,7 +322,7 @@ class PhpWord
|
|||
$writer = IOFactory::createWriter($this, $format);
|
||||
|
||||
if ($download === true) {
|
||||
header("Content-Description: File Transfer");
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
header('Content-Type: ' . $mime[$format]);
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -62,6 +62,7 @@ abstract class AbstractReader implements ReaderInterface
|
|||
public function setReadDataOnly($value = true)
|
||||
{
|
||||
$this->readDataOnly = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -70,21 +71,21 @@ abstract class AbstractReader implements ReaderInterface
|
|||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return resource
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
protected function openFile($filename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($filename) || !is_readable($filename)) {
|
||||
throw new Exception("Could not open " . $filename . " for reading! File does not exist.");
|
||||
throw new Exception("Could not open $filename for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Open file
|
||||
$this->fileHandle = fopen($filename, 'r');
|
||||
if ($this->fileHandle === false) {
|
||||
throw new Exception("Could not open file " . $filename . " for reading.");
|
||||
throw new Exception("Could not open file $filename for reading.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -19,8 +19,8 @@ namespace PhpOffice\PhpWord\Reader;
|
|||
|
||||
use PhpOffice\Common\Drawing;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Shared\OLERead;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
||||
/**
|
||||
* Reader for Word97
|
||||
|
|
@ -164,13 +164,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$arrayCP[$inc] = self::getInt4d($data, $posMem);
|
||||
$posMem += 4;
|
||||
}
|
||||
|
||||
return $arrayCP;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @link http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx
|
||||
* @link https://igor.io/2012/09/24/binary-parsing.html
|
||||
* @see http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx
|
||||
* @see https://igor.io/2012/09/24/binary-parsing.html
|
||||
* @param string $data
|
||||
*/
|
||||
private function readFib($data)
|
||||
{
|
||||
|
|
@ -1095,6 +1096,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$this->arrayFib['lcbColorSchemeMapping'] = self::getInt4d($data, $pos);
|
||||
$pos += 4;
|
||||
}
|
||||
|
||||
return $pos;
|
||||
}
|
||||
|
||||
|
|
@ -1107,11 +1109,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$this->readRecordPlcfSed();
|
||||
|
||||
// reading paragraphs
|
||||
//@link https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L86
|
||||
//@see https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L86
|
||||
$this->readRecordPlcfBtePapx();
|
||||
|
||||
// reading character formattings
|
||||
//@link https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L94
|
||||
//@see https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L94
|
||||
$this->readRecordPlcfBteChpx();
|
||||
|
||||
$this->generatePhpWord();
|
||||
|
|
@ -1119,7 +1121,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
|
||||
/**
|
||||
* Section and information about them
|
||||
* @link : http://msdn.microsoft.com/en-us/library/dd924458%28v=office.12%29.aspx
|
||||
* @see : http://msdn.microsoft.com/en-us/library/dd924458%28v=office.12%29.aspx
|
||||
*/
|
||||
private function readRecordPlcfSed()
|
||||
{
|
||||
|
|
@ -1133,7 +1135,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$posMem += 4;
|
||||
|
||||
// PlcfSed : aSed
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd950194%28v=office.12%29.aspx
|
||||
//@see : http://msdn.microsoft.com/en-us/library/dd950194%28v=office.12%29.aspx
|
||||
$numSed = $this->getNumInLcb($this->arrayFib['lcbPlcfSed'], 12);
|
||||
|
||||
$aSed = array();
|
||||
|
|
@ -1164,7 +1166,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
|
||||
/**
|
||||
* Specifies the fonts that are used in the document
|
||||
* @link : http://msdn.microsoft.com/en-us/library/dd943880%28v=office.12%29.aspx
|
||||
* @see : http://msdn.microsoft.com/en-us/library/dd943880%28v=office.12%29.aspx
|
||||
*/
|
||||
private function readRecordSttbfFfn()
|
||||
{
|
||||
|
|
@ -1223,7 +1225,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
|
||||
/**
|
||||
* Paragraph and information about them
|
||||
* @link http://msdn.microsoft.com/en-us/library/dd908569%28v=office.12%29.aspx
|
||||
* @see http://msdn.microsoft.com/en-us/library/dd908569%28v=office.12%29.aspx
|
||||
*/
|
||||
private function readRecordPlcfBtePapx()
|
||||
{
|
||||
|
|
@ -1247,7 +1249,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
$arrayRGB = array();
|
||||
for ($inc = 1; $inc <= $numRun; $inc++) {
|
||||
// @link http://msdn.microsoft.com/en-us/library/dd925804(v=office.12).aspx
|
||||
// @see http://msdn.microsoft.com/en-us/library/dd925804(v=office.12).aspx
|
||||
$arrayRGB[$inc] = self::getInt1d($this->dataWorkDocument, $offset);
|
||||
$offset += 1;
|
||||
// reserved
|
||||
|
|
@ -1303,7 +1305,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL);
|
||||
print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL);
|
||||
print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc));
|
||||
switch(dechex($sprm_Sgc)) {
|
||||
switch (dechex($sprm_Sgc)) {
|
||||
case 0x01:
|
||||
print_r(' (Paragraph property)');
|
||||
break;
|
||||
|
|
@ -1322,12 +1324,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
print_r(PHP_EOL);
|
||||
print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL);
|
||||
switch(dechex($sprm_Spra)) {
|
||||
switch (dechex($sprm_Spra)) {
|
||||
case 0x0:
|
||||
$operand = self::getInt1d($this->dataWorkDocument, $offset);
|
||||
$offset += 1;
|
||||
$cb -= 1;
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
$operand = 'OFF';
|
||||
break;
|
||||
|
|
@ -1376,9 +1378,9 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
|
||||
//
|
||||
switch(dechex($sprm_Sgc)) {
|
||||
switch (dechex($sprm_Sgc)) {
|
||||
case 0x01: // Sprm is modifying a paragraph property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
case 0x0A: // sprmPIlvl
|
||||
print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
|
|
@ -1391,28 +1393,28 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
break;
|
||||
case 0x02: // Sprm is modifying a character property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x03: // Sprm is modifying a picture property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x04: // Sprm is modifying a section property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x05: // Sprm is modifying a table property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
|
|
@ -1426,7 +1428,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
} else {
|
||||
if ($istd > 0) {
|
||||
// @todo : Determining Properties of a Paragraph Style
|
||||
# @link http://msdn.microsoft.com/en-us/library/dd948631%28v=office.12%29.aspx
|
||||
# @see http://msdn.microsoft.com/en-us/library/dd948631%28v=office.12%29.aspx
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
@ -1435,7 +1437,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
|
||||
/**
|
||||
* Character formatting properties to text in a document
|
||||
* @link http://msdn.microsoft.com/en-us/library/dd907108%28v=office.12%29.aspx
|
||||
* @see http://msdn.microsoft.com/en-us/library/dd907108%28v=office.12%29.aspx
|
||||
*/
|
||||
private function readRecordPlcfBteChpx()
|
||||
{
|
||||
|
|
@ -1453,7 +1455,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$offset = $offsetBase;
|
||||
|
||||
// ChpxFkp
|
||||
// @link : http://msdn.microsoft.com/en-us/library/dd910989%28v=office.12%29.aspx
|
||||
// @see : http://msdn.microsoft.com/en-us/library/dd910989%28v=office.12%29.aspx
|
||||
$numRGFC = self::getInt1d($this->dataWorkDocument, $offset + 511);
|
||||
$arrayRGFC = array();
|
||||
for ($inc = 0; $inc <= $numRGFC; $inc++) {
|
||||
|
|
@ -1471,12 +1473,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
foreach ($arrayRGB as $keyRGB => $rgb) {
|
||||
$oStyle = new \stdClass();
|
||||
$oStyle->pos_start = $start;
|
||||
$oStyle->pos_len = (int)ceil((($arrayRGFC[$keyRGB] -1) - $arrayRGFC[$keyRGB -1]) / 2);
|
||||
$oStyle->pos_len = (int) ceil((($arrayRGFC[$keyRGB] - 1) - $arrayRGFC[$keyRGB - 1]) / 2);
|
||||
$start += $oStyle->pos_len;
|
||||
|
||||
if ($rgb > 0) {
|
||||
// Chp Structure
|
||||
// @link : http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
|
||||
// @see : http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
|
||||
$posRGB = $offsetBase + $rgb * 2;
|
||||
|
||||
$cb = self::getInt1d($this->dataWorkDocument, $posRGB);
|
||||
|
|
@ -1500,12 +1502,13 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$oSprm->f = ($sprm / 512) & 0x0001;
|
||||
$oSprm->sgc = ($sprm / 1024) & 0x0007;
|
||||
$oSprm->spra = ($sprm / 8192);
|
||||
|
||||
return $oSprm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @param integer $pos
|
||||
* @param int $pos
|
||||
* @param \stdClass $oSprm
|
||||
* @return array
|
||||
*/
|
||||
|
|
@ -1514,11 +1517,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$length = 0;
|
||||
$operand = null;
|
||||
|
||||
switch(dechex($oSprm->spra)) {
|
||||
switch (dechex($oSprm->spra)) {
|
||||
case 0x0:
|
||||
$operand = self::getInt1d($data, $pos);
|
||||
$length = 1;
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
$operand = false;
|
||||
break;
|
||||
|
|
@ -1564,10 +1567,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $data integer
|
||||
* @param $pos integer
|
||||
* @param $data int
|
||||
* @param $pos int
|
||||
* @param $cbNum int
|
||||
* @return \stdClass
|
||||
* @link http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
|
||||
* @see http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
|
||||
*/
|
||||
private function readPrl($data, $pos, $cbNum)
|
||||
{
|
||||
|
|
@ -1593,7 +1597,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$cbNum -= $arrayReturn['length'];
|
||||
$operand = $arrayReturn['operand'];
|
||||
|
||||
switch(dechex($oSprm->sgc)) {
|
||||
switch (dechex($oSprm->sgc)) {
|
||||
// Paragraph property
|
||||
case 0x01:
|
||||
break;
|
||||
|
|
@ -1602,7 +1606,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
if (!isset($oStylePrl->styleFont)) {
|
||||
$oStylePrl->styleFont = array();
|
||||
}
|
||||
switch($oSprm->isPmd) {
|
||||
switch ($oSprm->isPmd) {
|
||||
// sprmCFRMarkIns
|
||||
case 0x01:
|
||||
break;
|
||||
|
|
@ -1620,7 +1624,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCFItalic
|
||||
case 0x36:
|
||||
// By default, text is not italicized.
|
||||
switch($operand) {
|
||||
switch ($operand) {
|
||||
case false:
|
||||
case true:
|
||||
$oStylePrl->styleFont['italic'] = $operand;
|
||||
|
|
@ -1640,7 +1644,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCFBold
|
||||
case 0x35:
|
||||
// By default, text is not bold.
|
||||
switch($operand) {
|
||||
switch ($operand) {
|
||||
case false:
|
||||
case true:
|
||||
$oStylePrl->styleFont['bold'] = $operand;
|
||||
|
|
@ -1656,7 +1660,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCFStrike
|
||||
case 0x37:
|
||||
// By default, text is not struck through.
|
||||
switch($operand) {
|
||||
switch ($operand) {
|
||||
case false:
|
||||
case true:
|
||||
$oStylePrl->styleFont['strikethrough'] = $operand;
|
||||
|
|
@ -1671,7 +1675,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
break;
|
||||
// sprmCKul
|
||||
case 0x3E:
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
|
||||
break;
|
||||
|
|
@ -1694,7 +1698,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASH;
|
||||
break;
|
||||
case 0x09:
|
||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTHASH;
|
||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDASH;
|
||||
break;
|
||||
case 0x0A:
|
||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASH;
|
||||
|
|
@ -1709,7 +1713,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASHHEAVY;
|
||||
break;
|
||||
case 0x19:
|
||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTHASHHEAVY;
|
||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDASHHEAVY;
|
||||
break;
|
||||
case 0x1A:
|
||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASHHEAVY;
|
||||
|
|
@ -1732,9 +1736,9 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
break;
|
||||
// sprmCIco
|
||||
//@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
|
||||
//@see http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
|
||||
case 0x42:
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
case 0x01:
|
||||
$oStylePrl->styleFont['color'] = '000000';
|
||||
|
|
@ -1787,7 +1791,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
break;
|
||||
// sprmCHps
|
||||
case 0x43:
|
||||
$oStylePrl->styleFont['size'] = dechex($operand/2);
|
||||
$oStylePrl->styleFont['size'] = dechex($operand / 2);
|
||||
break;
|
||||
// sprmCIss
|
||||
case 0x48:
|
||||
|
|
@ -1838,7 +1842,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
case 0x61:
|
||||
break;
|
||||
// sprmCShd80
|
||||
//@link http://msdn.microsoft.com/en-us/library/dd923447%28v=office.12%29.aspx
|
||||
//@see http://msdn.microsoft.com/en-us/library/dd923447%28v=office.12%29.aspx
|
||||
case 0x66:
|
||||
// $operand = self::getInt2d($data, $pos);
|
||||
$pos += 2;
|
||||
|
|
@ -1848,7 +1852,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// $icoFore = ($operand >> 11) && bindec('11111');
|
||||
break;
|
||||
// sprmCCv
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd952824%28v=office.12%29.aspx
|
||||
//@see : http://msdn.microsoft.com/en-us/library/dd952824%28v=office.12%29.aspx
|
||||
case 0x70:
|
||||
$red = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
|
||||
$pos += 1;
|
||||
|
|
@ -1857,7 +1861,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$blue = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
|
||||
$pos += 1;
|
||||
$pos += 1;
|
||||
$oStylePrl->styleFont['color'] = $red.$green.$blue;
|
||||
$oStylePrl->styleFont['color'] = $red . $green . $blue;
|
||||
$cbNum -= 4;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1873,7 +1877,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
if (!isset($oStylePrl->styleSection)) {
|
||||
$oStylePrl->styleSection = array();
|
||||
}
|
||||
switch($oSprm->isPmd) {
|
||||
switch ($oSprm->isPmd) {
|
||||
// sprmSNfcPgn
|
||||
case 0x0E:
|
||||
// numbering format used for page numbers
|
||||
|
|
@ -1925,7 +1929,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
default:
|
||||
// print_r('@todo Section : 0x'.dechex($oSprm->isPmd));
|
||||
// print_r(PHP_EOL);
|
||||
|
||||
}
|
||||
break;
|
||||
// Table property
|
||||
|
|
@ -1951,7 +1954,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// HFD > clsid
|
||||
$sprmCPicLocation += 16;
|
||||
// HFD > hyperlink
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd909835%28v=office.12%29.aspx
|
||||
//@see : http://msdn.microsoft.com/en-us/library/dd909835%28v=office.12%29.aspx
|
||||
$streamVersion = self::getInt4d($this->dataData, $sprmCPicLocation);
|
||||
$sprmCPicLocation += 4;
|
||||
$data = self::getInt4d($this->dataData, $sprmCPicLocation);
|
||||
|
|
@ -2019,8 +2022,8 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}*/
|
||||
} else {
|
||||
// Pictures
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd925458%28v=office.12%29.aspx
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd926136%28v=office.12%29.aspx
|
||||
//@see : http://msdn.microsoft.com/en-us/library/dd925458%28v=office.12%29.aspx
|
||||
//@see : http://msdn.microsoft.com/en-us/library/dd926136%28v=office.12%29.aspx
|
||||
// PICF : lcb
|
||||
$sprmCPicLocation += 4;
|
||||
// PICF : cbHeader
|
||||
|
|
@ -2107,13 +2110,13 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$sprmCPicLocation += $shapeRH['recLen'];
|
||||
}
|
||||
// picture : rgfb
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd950560%28v=office.12%29.aspx
|
||||
//@see : http://msdn.microsoft.com/en-us/library/dd950560%28v=office.12%29.aspx
|
||||
$fileBlockRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
|
||||
while ($fileBlockRH['recType'] == 0xF007 || ($fileBlockRH['recType'] >= 0xF018 && $fileBlockRH['recType'] <= 0xF117)) {
|
||||
$sprmCPicLocation += 8;
|
||||
switch ($fileBlockRH['recType']) {
|
||||
// OfficeArtFBSE
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd944923%28v=office.12%29.aspx
|
||||
//@see : http://msdn.microsoft.com/en-us/library/dd944923%28v=office.12%29.aspx
|
||||
case 0xF007:
|
||||
// btWin32
|
||||
$sprmCPicLocation += 1;
|
||||
|
|
@ -2148,7 +2151,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
}
|
||||
// embeddedBlip
|
||||
//@link : http://msdn.microsoft.com/en-us/library/dd910081%28v=office.12%29.aspx
|
||||
//@see : http://msdn.microsoft.com/en-us/library/dd910081%28v=office.12%29.aspx
|
||||
$embeddedBlipRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
|
||||
switch ($embeddedBlipRH['recType']) {
|
||||
case self::OFFICEARTBLIPJPG:
|
||||
|
|
@ -2193,13 +2196,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
|
||||
$oStylePrl->length = $pos - $posStart;
|
||||
|
||||
return $oStylePrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a record header
|
||||
* @param string $stream
|
||||
* @param integer $pos
|
||||
* @param int $pos
|
||||
* @return array
|
||||
*/
|
||||
private function loadRecordHeader($stream, $pos)
|
||||
|
|
@ -2207,6 +2211,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$rec = self::getInt2d($stream, $pos);
|
||||
$recType = self::getInt2d($stream, $pos + 2);
|
||||
$recLen = self::getInt4d($stream, $pos + 4);
|
||||
|
||||
return array(
|
||||
'recVer' => ($rec >> 0) & bindec('1111'),
|
||||
'recInstance' => ($rec >> 4) & bindec('111111111111'),
|
||||
|
|
@ -2274,7 +2279,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
if (ord($sText[0]) == 1) {
|
||||
if (isset($oCharacters->style->image)) {
|
||||
$fileImage = tempnam(sys_get_temp_dir(), 'PHPWord_MsDoc').'.'.$oCharacters->style->image['format'];
|
||||
$fileImage = tempnam(sys_get_temp_dir(), 'PHPWord_MsDoc') . '.' . $oCharacters->style->image['format'];
|
||||
file_put_contents($fileImage, $oCharacters->style->image['data']);
|
||||
$oSection->addImage($fileImage, array('width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height']));
|
||||
// print_r('>addImage<'.$fileImage.'>'.EOL);
|
||||
|
|
@ -2285,7 +2290,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2310,7 +2314,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
*/
|
||||
public static function getInt2d($data, $pos)
|
||||
{
|
||||
return ord($data[$pos]) | (ord($data[$pos+1]) << 8);
|
||||
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2322,7 +2326,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
*/
|
||||
public static function getInt3d($data, $pos)
|
||||
{
|
||||
return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16);
|
||||
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2344,6 +2348,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
} else {
|
||||
$ord24 = ($or24 & 127) << 24;
|
||||
}
|
||||
return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $ord24;
|
||||
|
||||
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -58,7 +58,6 @@ class ODText extends AbstractReader implements ReaderInterface
|
|||
* @param string $partName
|
||||
* @param string $docFile
|
||||
* @param string $xmlFile
|
||||
* @return void
|
||||
*/
|
||||
private function readPart(PhpWord $phpWord, $relationships, $partName, $docFile, $xmlFile)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -31,7 +31,6 @@ class Content extends AbstractPart
|
|||
* Read content.xml.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return void
|
||||
*/
|
||||
public function read(PhpWord $phpWord)
|
||||
{
|
||||
|
|
@ -44,16 +43,13 @@ class Content extends AbstractPart
|
|||
foreach ($nodes as $node) {
|
||||
// $styleName = $xmlReader->getAttribute('text:style-name', $node);
|
||||
switch ($node->nodeName) {
|
||||
|
||||
case 'text:h': // Heading
|
||||
$depth = $xmlReader->getAttribute('text:outline-level', $node);
|
||||
$section->addTitle($node->nodeValue, $depth);
|
||||
break;
|
||||
|
||||
case 'text:p': // Paragraph
|
||||
$section->addText($node->nodeValue);
|
||||
break;
|
||||
|
||||
case 'text:list': // List
|
||||
$listItems = $xmlReader->getElements('text:list-item/text:p', $node);
|
||||
foreach ($listItems as $listItem) {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -31,7 +31,6 @@ class Meta extends AbstractPart
|
|||
* Read meta.xml.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return void
|
||||
* @todo Process property type
|
||||
*/
|
||||
public function read(PhpWord $phpWord)
|
||||
|
|
@ -70,9 +69,8 @@ class Meta extends AbstractPart
|
|||
if (in_array($property, array('Category', 'Company', 'Manager'))) {
|
||||
$method = "set{$property}";
|
||||
$docProps->$method($propertyNode->nodeValue);
|
||||
|
||||
// Set other custom properties
|
||||
} else {
|
||||
// Set other custom properties
|
||||
$docProps->setCustomProperty($property, $propertyNode->nodeValue);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
* 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
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -131,7 +131,6 @@ class Document
|
|||
* - Pushes every other character into the text queue
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return void
|
||||
* @todo Use `fread` stream for scalability
|
||||
*/
|
||||
public function read(PhpWord $phpWord)
|
||||
|
|
@ -163,7 +162,7 @@ class Document
|
|||
if (false === $this->isControl) { // Non control word: Push character
|
||||
$this->pushText($char);
|
||||
} else {
|
||||
if (preg_match("/^[a-zA-Z0-9-]?$/", $char)) { // No delimiter: Buffer control
|
||||
if (preg_match('/^[a-zA-Z0-9-]?$/', $char)) { // No delimiter: Buffer control
|
||||
$this->control .= $char;
|
||||
$this->isFirst = false;
|
||||
} else { // Delimiter found: Parse buffered control
|
||||
|
|
@ -184,8 +183,6 @@ class Document
|
|||
|
||||
/**
|
||||
* Mark opening braket `{` character.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function markOpening()
|
||||
{
|
||||
|
|
@ -195,8 +192,6 @@ class Document
|
|||
|
||||
/**
|
||||
* Mark closing braket `}` character.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function markClosing()
|
||||
{
|
||||
|
|
@ -206,8 +201,6 @@ class Document
|
|||
|
||||
/**
|
||||
* Mark backslash `\` character.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function markBackslash()
|
||||
{
|
||||
|
|
@ -223,8 +216,6 @@ class Document
|
|||
|
||||
/**
|
||||
* Mark newline character: Flush control word because it's not possible to span multiline.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function markNewline()
|
||||
{
|
||||
|
|
@ -237,7 +228,6 @@ class Document
|
|||
* Flush control word or text.
|
||||
*
|
||||
* @param bool $isControl
|
||||
* @return void
|
||||
*/
|
||||
private function flush($isControl = false)
|
||||
{
|
||||
|
|
@ -252,11 +242,10 @@ class Document
|
|||
* Flush control word.
|
||||
*
|
||||
* @param bool $isControl
|
||||
* @return void
|
||||
*/
|
||||
private function flushControl($isControl = false)
|
||||
{
|
||||
if (1 === preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match)) {
|
||||
if (1 === preg_match('/^([A-Za-z]+)(-?[0-9]*) ?$/', $this->control, $match)) {
|
||||
list(, $control, $parameter) = $match;
|
||||
$this->parseControl($control, $parameter);
|
||||
}
|
||||
|
|
@ -268,8 +257,6 @@ class Document
|
|||
|
||||
/**
|
||||
* Flush text in queue.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function flushText()
|
||||
{
|
||||
|
|
@ -296,7 +283,6 @@ class Document
|
|||
* Reset control word and first char state.
|
||||
*
|
||||
* @param bool $value
|
||||
* @return void
|
||||
*/
|
||||
private function setControl($value)
|
||||
{
|
||||
|
|
@ -308,14 +294,13 @@ class Document
|
|||
* Push text into queue.
|
||||
*
|
||||
* @param string $char
|
||||
* @return void
|
||||
*/
|
||||
private function pushText($char)
|
||||
{
|
||||
if ('<' == $char) {
|
||||
$this->text .= "<";
|
||||
$this->text .= '<';
|
||||
} elseif ('>' == $char) {
|
||||
$this->text .= ">";
|
||||
$this->text .= '>';
|
||||
} else {
|
||||
$this->text .= $char;
|
||||
}
|
||||
|
|
@ -326,7 +311,6 @@ class Document
|
|||
*
|
||||
* @param string $control
|
||||
* @param string $parameter
|
||||
* @return void
|
||||
*/
|
||||
private function parseControl($control, $parameter)
|
||||
{
|
||||
|
|
@ -335,7 +319,7 @@ class Document
|
|||
'b' => array(self::STYL, 'font', 'bold', true),
|
||||
'i' => array(self::STYL, 'font', 'italic', true),
|
||||
'u' => array(self::STYL, 'font', 'underline', true),
|
||||
'strike' => array(self::STYL, 'font', 'strikethrough',true),
|
||||
'strike' => array(self::STYL, 'font', 'strikethrough', true),
|
||||
'fs' => array(self::STYL, 'font', 'size', $parameter),
|
||||
'qc' => array(self::STYL, 'paragraph', 'alignment', Jc::CENTER),
|
||||
'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter),
|
||||
|
|
@ -366,7 +350,6 @@ class Document
|
|||
* Read paragraph.
|
||||
*
|
||||
* @param array $directives
|
||||
* @return void
|
||||
*/
|
||||
private function readParagraph($directives)
|
||||
{
|
||||
|
|
@ -379,7 +362,6 @@ class Document
|
|||
* Read style.
|
||||
*
|
||||
* @param array $directives
|
||||
* @return void
|
||||
*/
|
||||
private function readStyle($directives)
|
||||
{
|
||||
|
|
@ -391,7 +373,6 @@ class Document
|
|||
* Read skip.
|
||||
*
|
||||
* @param array $directives
|
||||
* @return void
|
||||
*/
|
||||
private function readSkip($directives)
|
||||
{
|
||||
|
|
@ -402,8 +383,6 @@ class Document
|
|||
|
||||
/**
|
||||
* Read text.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function readText()
|
||||
{
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue