Merge branch 'develop' into feature/EnablePasswordProtection
This commit is contained in:
commit
7b30145270
|
|
@ -6,14 +6,18 @@ Thumbs.db
|
||||||
Desktop.ini
|
Desktop.ini
|
||||||
.idea
|
.idea
|
||||||
_build
|
_build
|
||||||
|
/build
|
||||||
phpunit.xml
|
phpunit.xml
|
||||||
composer.lock
|
composer.lock
|
||||||
composer.phar
|
composer.phar
|
||||||
vendor
|
vendor
|
||||||
/report
|
/report
|
||||||
|
/build
|
||||||
/samples/resources
|
/samples/resources
|
||||||
/samples/results
|
/samples/results
|
||||||
/.settings
|
/.settings
|
||||||
phpword.ini
|
phpword.ini
|
||||||
/.buildpath
|
/.buildpath
|
||||||
/.project
|
/.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
|
language: php
|
||||||
|
|
||||||
|
dist: precise
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.3
|
- 5.3
|
||||||
- 5.4
|
- 5.4
|
||||||
- 5.5
|
- 5.5
|
||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
- hhvm
|
- 7.1
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
|
include:
|
||||||
|
- php: 5.6
|
||||||
|
env: COVERAGE=1
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
- php: hhvm
|
- php: 7.1
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- vendor
|
||||||
|
- $HOME/.composer/cache
|
||||||
|
- .php-cs.cache
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|
@ -23,6 +34,8 @@ before_install:
|
||||||
- sudo apt-get install -y graphviz
|
- sudo apt-get install -y graphviz
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
## Deactivate xdebug if we don't do code coverage
|
||||||
|
- if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini ; fi
|
||||||
## Composer
|
## Composer
|
||||||
- composer self-update
|
- composer self-update
|
||||||
- composer install --prefer-source
|
- composer install --prefer-source
|
||||||
|
|
@ -32,19 +45,20 @@ before_script:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
## PHP_CodeSniffer
|
## 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
|
## 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
|
## 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
|
## PHPLOC
|
||||||
- ./vendor/bin/phploc src/
|
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phploc src/ ; fi
|
||||||
## PHPDocumentor
|
## 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:
|
after_script:
|
||||||
## PHPDocumentor
|
## PHPDocumentor
|
||||||
- bash .travis_shell_after_success.sh
|
- bash .travis_shell_after_success.sh
|
||||||
## Scrutinizer
|
## Scrutinizer
|
||||||
- wget https://scrutinizer-ci.com/ocular.phar
|
- 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
|
||||||
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ echo "TRAVIS_REPO_SLUG: $TRAVIS_REPO_SLUG"
|
||||||
echo "TRAVIS_PHP_VERSION: $TRAVIS_PHP_VERSION"
|
echo "TRAVIS_PHP_VERSION: $TRAVIS_PHP_VERSION"
|
||||||
echo "TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST"
|
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"
|
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.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
v0.14.0 (?? ???? 2017)
|
||||||
|
----------------------
|
||||||
|
This release fixes several bugs and adds some new features.
|
||||||
|
This is the last version to support PHP 5.3
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Possibility to control the footnote numbering - @troosan #1068
|
||||||
|
- Image creation from string - @troosan #937
|
||||||
|
- Introduced the `\PhpOffice\PhpWord\SimpleType\NumberFormat` simple type. - @troosan
|
||||||
|
- Support for ContextualSpacing - @postHawk #1088
|
||||||
|
- Possiblity to hide spelling and/or grammatical errors - @troosan #542
|
||||||
|
- Possiblity to set default document language as well as changing the language for each text element - @troosan #1108
|
||||||
|
- Support for Comments - @troosan #1067
|
||||||
|
- 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)
|
v0.13.0 (31 July 2016)
|
||||||
-------------------
|
-------------------
|
||||||
This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).
|
This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).
|
||||||
|
|
@ -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
|
- 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
|
- Renamed the `align` option of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles into `alignment`. - @RomanSyroeshko
|
||||||
- Improved performance of `TemplateProcessor::setValue()`. - @kazitanvirahsan #614, #617
|
- 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
|
### Deprecated
|
||||||
- `getAlign` and `setAlign` methods of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles.
|
- `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/).
|
PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/).
|
||||||
|
|
||||||
|
If you have any questions, please ask on [StackOverFlow](https://stackoverflow.com/questions/tagged/phpword)
|
||||||
|
|
||||||
Read more about PHPWord:
|
Read more about PHPWord:
|
||||||
|
|
||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
|
|
@ -55,8 +57,7 @@ PHPWord requires the following:
|
||||||
- PHP 5.3.3+
|
- PHP 5.3.3+
|
||||||
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
|
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
|
||||||
- [Zend\Escaper component](http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html)
|
- [Zend\Escaper component](http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html)
|
||||||
- Zend\Stdlib component
|
- [Zend\Stdlib component](http://framework.zend.com/manual/current/en/modules/zend.stdlib.hydrator.html)
|
||||||
- [Zend\Validator component](http://framework.zend.com/manual/current/en/modules/zend.validator.html)
|
|
||||||
- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)
|
- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)
|
||||||
- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images)
|
- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images)
|
||||||
- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write OOXML and ODF)
|
- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write OOXML and ODF)
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Franck Lefevre",
|
"name": "Franck Lefevre",
|
||||||
"homepage": "http://blog.rootslabs.net"
|
"homepage": "https://rootslabs.net/blog/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Ivan Lanin",
|
"name": "Ivan Lanin",
|
||||||
|
|
@ -29,23 +29,27 @@
|
||||||
{
|
{
|
||||||
"name": "Roman Syroeshko",
|
"name": "Roman Syroeshko",
|
||||||
"homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/"
|
"homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Antoine de Troostembergh"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.3",
|
"php": ">=5.3.3",
|
||||||
"ext-xml": "*",
|
"ext-xml": "*",
|
||||||
"zendframework/zend-escaper": "2.4.*",
|
"zendframework/zend-escaper": "^2.2",
|
||||||
"zendframework/zend-stdlib": "2.4.*",
|
"zendframework/zend-stdlib": "^2.2",
|
||||||
"zendframework/zend-validator": "2.4.*",
|
"phpoffice/common": "^0.2"
|
||||||
"phpoffice/common": "0.2.*"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "3.7.*",
|
"phpunit/phpunit": "^4.8.36",
|
||||||
"phpdocumentor/phpdocumentor":"2.*",
|
"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.*",
|
"phpmd/phpmd": "2.*",
|
||||||
"phploc/phploc": "2.*",
|
"phploc/phploc": "2.*",
|
||||||
"dompdf/dompdf":"0.6.*",
|
"dompdf/dompdf":"0.8.*",
|
||||||
"tecnickcom/tcpdf": "6.*",
|
"tecnickcom/tcpdf": "6.*",
|
||||||
"mpdf/mpdf": "5.*"
|
"mpdf/mpdf": "5.*"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,14 @@ master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'PHPWord'
|
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
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '0.13.0'
|
version = '0.14.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = version
|
release = version
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ html_theme = 'default'
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# 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,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# 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,
|
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||||
# using the given strftime format.
|
# 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
|
Additionally, only inside of the header reference you can add watermarks
|
||||||
or background pictures. See "Watermarks" section.
|
or background pictures. See "Watermarks" section.
|
||||||
|
|
||||||
|
You can pass an optional parameter to specify where the header/footer should be applied, it can be
|
||||||
|
|
||||||
|
- ``Footer::AUTO`` default, all pages except if overridden by first or even
|
||||||
|
- ``Footer::FIRST`` each first page of the section
|
||||||
|
- ``Footer::EVEN`` each even page of the section. Will only be applied if the evenAndOddHeaders is set to true in phpWord->settings
|
||||||
|
|
||||||
Footers
|
Footers
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,12 +135,12 @@ Text breaks are empty new lines. To add text breaks, use the following syntax. A
|
||||||
Page breaks
|
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.
|
method or using the ``pageBreakBefore`` style of paragraph.
|
||||||
|
|
||||||
:: code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
\\$section->addPageBreak();
|
$section->addPageBreak();
|
||||||
|
|
||||||
Lists
|
Lists
|
||||||
-----
|
-----
|
||||||
|
|
@ -158,8 +158,8 @@ Parameters:
|
||||||
- ``$text``. Text that appears in the document.
|
- ``$text``. Text that appears in the document.
|
||||||
- ``$depth``. Depth of list item.
|
- ``$depth``. Depth of list item.
|
||||||
- ``$fontStyle``. See :ref:`font-style`.
|
- ``$fontStyle``. See :ref:`font-style`.
|
||||||
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
|
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
|
||||||
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\_Style\_ListItem.
|
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\\Style\\ListItem.
|
||||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||||
|
|
||||||
Advanced usage:
|
Advanced usage:
|
||||||
|
|
@ -297,7 +297,7 @@ Your TOC can only be generated if you have add at least one title (See "Titles")
|
||||||
|
|
||||||
Options for ``$tocStyle``:
|
Options for ``$tocStyle``:
|
||||||
|
|
||||||
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\_Style\_TOC.
|
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\\Style\\TOC.
|
||||||
- ``tabPos``. The position of the tab where the page number appears in twips.
|
- ``tabPos``. The position of the tab where the page number appears in twips.
|
||||||
- ``indent``. The indent factor of the titles in twips.
|
- ``indent``. The indent factor of the titles in twips.
|
||||||
|
|
||||||
|
|
@ -333,11 +333,28 @@ On text:
|
||||||
$footnote = $section->addFootnote();
|
$footnote = $section->addFootnote();
|
||||||
$footnote->addText('Footnote text.');
|
$footnote->addText('Footnote text.');
|
||||||
|
|
||||||
The footnote reference number will be displayed with decimal number
|
By default the footnote reference number will be displayed with decimal number
|
||||||
starting from 1. This number use ``FooterReference`` style which you can
|
starting from 1. This number uses the ``FooterReference`` style which you can
|
||||||
redefine by ``addFontStyle`` method. Default value for this style is
|
redefine with the ``addFontStyle`` method. Default value for this style is
|
||||||
``array('superScript' => true)``;
|
``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
|
Checkboxes
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
@ -360,7 +377,35 @@ To be completed
|
||||||
Fields
|
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
|
Line
|
||||||
------
|
------
|
||||||
|
|
@ -369,8 +414,8 @@ Line elements can be added to sections by using ``addLine``.
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
$linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552);
|
$lineStyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552);
|
||||||
$section->addLine($lineStyle)
|
$section->addLine($lineStyle);
|
||||||
|
|
||||||
Available line style attributes:
|
Available line style attributes:
|
||||||
|
|
||||||
|
|
@ -381,4 +426,27 @@ Available line style attributes:
|
||||||
- ``endArrow``. End type of arrow: block, open, classic, diamond, oval.
|
- ``endArrow``. End type of arrow: block, open, classic, diamond, oval.
|
||||||
- ``width``. Line-object width in pt.
|
- ``width``. Line-object width in pt.
|
||||||
- ``height``. Line-object height in pt.
|
- ``height``. Line-object height in pt.
|
||||||
- ``flip``. Flip the line element: true, false.
|
- ``flip``. Flip the line element: true, false.
|
||||||
|
|
||||||
|
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 RTF, because it's not XML-based and requires a different example. */
|
||||||
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
||||||
|
|
||||||
Settings
|
PHPWord Settings
|
||||||
--------
|
----------------
|
||||||
|
|
||||||
The ``PhpOffice\PhpWord\Settings`` class provides some options that will
|
The ``PhpOffice\PhpWord\Settings`` class provides some options that will
|
||||||
affect the behavior of PHPWord. Below are the options.
|
affect the behavior of PHPWord. Below are the options.
|
||||||
|
|
@ -109,8 +109,8 @@ Zip class
|
||||||
By default, PHPWord uses `Zip extension <http://php.net/manual/en/book.zip.php>`__
|
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
|
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
|
Zip extension installed on your server, you can use pure PHP library
|
||||||
alternative, `PclZip <http://www.phpconcept.net/pclzip/>`__, which
|
alternative, `PclZip <http://www.phpconcept.net/pclzip/>`__, which is
|
||||||
included with PHPWord.
|
included in PHPWord.
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
|
|
@ -141,6 +141,94 @@ default font by using the following two functions:
|
||||||
$phpWord->setDefaultFontName('Times New Roman');
|
$phpWord->setDefaultFontName('Times New Roman');
|
||||||
$phpWord->setDefaultFontSize(12);
|
$phpWord->setDefaultFontSize(12);
|
||||||
|
|
||||||
|
Document settings
|
||||||
|
-----------------
|
||||||
|
Settings for the generated document can be set using ``$phpWord->getSettings()``
|
||||||
|
|
||||||
|
Magnification Setting
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
The default zoom value is 100 percent. This can be changed either to another percentage
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setZoom(75);
|
||||||
|
|
||||||
|
Or to predefined values ``fullPage``, ``bestFit``, ``textFit``
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setZoom(Zoom::BEST_FIT);
|
||||||
|
|
||||||
|
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
|
Document information
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ Example:
|
||||||
|
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"phpoffice/phpword": "v0.13.*"
|
"phpoffice/phpword": "v0.14.*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ Features
|
||||||
- Insert drawing shapes (arc, curve, line, polyline, rect, oval)
|
- Insert drawing shapes (arc, curve, line, polyline, rect, oval)
|
||||||
- Insert charts (pie, doughnut, bar, line, area, scatter, radar)
|
- Insert charts (pie, doughnut, bar, line, area, scatter, radar)
|
||||||
- Insert form fields (textinput, checkbox, and dropdown)
|
- Insert form fields (textinput, checkbox, and dropdown)
|
||||||
|
- Insert comments
|
||||||
- Create document from templates
|
- Create document from templates
|
||||||
- Use XSL 1.0 style sheets to transform headers, main document part, and footers of an OOXML template
|
- Use XSL 1.0 style sheets to transform headers, main document part, and footers of an OOXML template
|
||||||
- ... and many more features on progress
|
- ... and many more features on progress
|
||||||
|
|
@ -102,6 +103,8 @@ Writers
|
||||||
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
||||||
| | Endnote | ✓ | | | ✓ | |
|
| | Endnote | ✓ | | | ✓ | |
|
||||||
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
||||||
|
| | Comments | ✓ | | | | |
|
||||||
|
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
||||||
| **Graphs** | 2D basic graphs | ✓ | | | | |
|
| **Graphs** | 2D basic graphs | ✓ | | | | |
|
||||||
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
+---------------------------+----------------------+--------+-------+-------+--------+-------+
|
||||||
| | 2D advanced graphs | | | | | |
|
| | 2D advanced graphs | | | | | |
|
||||||
|
|
@ -161,6 +164,8 @@ Readers
|
||||||
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
||||||
| | Endnote | ✓ | | | | |
|
| | Endnote | ✓ | | | | |
|
||||||
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
||||||
|
| | Comments | | | | | |
|
||||||
|
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
||||||
| **Graphs** | 2D basic graphs | | | | | |
|
| **Graphs** | 2D basic graphs | | | | | |
|
||||||
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
+---------------------------+----------------------+--------+-------+-------+-------+-------+
|
||||||
| | 2D advanced graphs | | | | | |
|
| | 2D advanced graphs | | | | | |
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ References
|
||||||
==========
|
==========
|
||||||
|
|
||||||
ISO/IEC 29500, Third edition, 2012-09-01
|
ISO/IEC 29500, Third edition, 2012-09-01
|
||||||
---------------------
|
----------------------------------------
|
||||||
|
|
||||||
- `Part 1: Fundamentals and Markup Language Reference
|
- `Part 1: Fundamentals and Markup Language Reference
|
||||||
<http://standards.iso.org/ittf/PubliclyAvailableStandards/c061750_ISO_IEC_29500-1_2012.zip>`__
|
<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*.
|
- ``color``. Font color, e.g. *FF0000*.
|
||||||
- ``doubleStrikethrough``. Double strikethrough, *true* or *false*.
|
- ``doubleStrikethrough``. Double strikethrough, *true* or *false*.
|
||||||
- ``fgColor``. Font highlight color, e.g. *yellow*, *green*, *blue*.
|
- ``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*.
|
- ``hint``. Font content type, *default*, *eastAsia*, or *cs*.
|
||||||
- ``italic``. Italic, *true* or *false*.
|
- ``italic``. Italic, *true* or *false*.
|
||||||
- ``name``. Font name, e.g. *Arial*.
|
- ``name``. Font name, e.g. *Arial*.
|
||||||
|
|
@ -54,7 +55,10 @@ Available Font style options:
|
||||||
- ``strikethrough``. Strikethrough, *true* or *false*.
|
- ``strikethrough``. Strikethrough, *true* or *false*.
|
||||||
- ``subScript``. Subscript, *true* or *false*.
|
- ``subScript``. Subscript, *true* or *false*.
|
||||||
- ``superScript``. Superscript, *true* or *false*.
|
- ``superScript``. Superscript, *true* or *false*.
|
||||||
- ``underline``. Underline, *dash*, *dotted*, etc.
|
- ``underline``. Underline, *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:
|
.. _paragraph-style:
|
||||||
|
|
||||||
|
|
@ -64,7 +68,7 @@ Paragraph
|
||||||
Available Paragraph style options:
|
Available Paragraph style options:
|
||||||
|
|
||||||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||||
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||||
- ``basedOn``. Parent style.
|
- ``basedOn``. Parent style.
|
||||||
- ``hanging``. Hanging by how much.
|
- ``hanging``. Hanging by how much.
|
||||||
- ``indent``. Indent by how much.
|
- ``indent``. Indent by how much.
|
||||||
|
|
@ -75,8 +79,15 @@ See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||||
- ``pageBreakBefore``. Start paragraph on next page, *true* or *false*.
|
- ``pageBreakBefore``. Start paragraph on next page, *true* or *false*.
|
||||||
- ``spaceBefore``. Space before paragraph.
|
- ``spaceBefore``. Space before paragraph.
|
||||||
- ``spaceAfter``. Space after paragraph.
|
- ``spaceAfter``. Space after paragraph.
|
||||||
|
- ``spacing``. Space between lines.
|
||||||
|
- ``spacingLineRule``. Line Spacing Rule. *auto*, *exact*, *atLeast*
|
||||||
- ``tabs``. Set of custom tab stops.
|
- ``tabs``. Set of custom tab stops.
|
||||||
- ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*.
|
- ``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:
|
.. _table-style:
|
||||||
|
|
||||||
|
|
@ -86,7 +97,7 @@ Table
|
||||||
Available Table style options:
|
Available Table style options:
|
||||||
|
|
||||||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||||
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
|
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
|
||||||
- ``bgColor``. Background color, e.g. '9966CC'.
|
- ``bgColor``. Background color, e.g. '9966CC'.
|
||||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||||
|
|
@ -105,7 +116,8 @@ Available Cell style options:
|
||||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||||
- ``gridSpan``. Number of columns spanned.
|
- ``gridSpan``. Number of columns spanned.
|
||||||
- ``textDirection(btLr|tbRl)``. Direction of text. You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
|
- ``textDirection(btLr|tbRl)``. Direction of text.
|
||||||
|
You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
|
||||||
- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
|
- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
|
||||||
- ``vMerge``. *restart* or *continue*.
|
- ``vMerge``. *restart* or *continue*.
|
||||||
- ``width``. Cell width in twips.
|
- ``width``. Cell width in twips.
|
||||||
|
|
@ -132,7 +144,7 @@ Numbering level
|
||||||
Available NumberingLevel style options:
|
Available NumberingLevel style options:
|
||||||
|
|
||||||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||||
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||||
- ``font``. Font name.
|
- ``font``. Font name.
|
||||||
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
|
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
|
||||||
- ``hanging``. See paragraph style.
|
- ``hanging``. See paragraph style.
|
||||||
|
|
|
||||||
|
|
@ -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
|
<?php
|
||||||
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
|
|
||||||
include_once 'Sample_Header.php';
|
include_once 'Sample_Header.php';
|
||||||
|
|
||||||
// New Word Document
|
// New Word Document
|
||||||
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
|
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
|
||||||
|
|
||||||
|
$languageEnGb = new \PhpOffice\PhpWord\Style\Language(\PhpOffice\PhpWord\Style\Language::EN_GB);
|
||||||
|
|
||||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
$phpWord->getSettings()->setThemeFontLang($languageEnGb);
|
||||||
|
|
||||||
$fontStyleName = 'rStyle';
|
$fontStyleName = 'rStyle';
|
||||||
$phpWord->addFontStyle($fontStyleName, array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
|
$phpWord->addFontStyle($fontStyleName, array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
|
||||||
|
|
@ -20,6 +27,10 @@ $section = $phpWord->addSection();
|
||||||
$section->addTitle('Welcome to PhpWord', 1);
|
$section->addTitle('Welcome to PhpWord', 1);
|
||||||
$section->addText('Hello World!');
|
$section->addText('Hello World!');
|
||||||
|
|
||||||
|
// $pStyle = new Font();
|
||||||
|
// $pStyle->setLang()
|
||||||
|
$section->addText('Ce texte-ci est en français.', array('lang' => \PhpOffice\PhpWord\Style\Language::FR_BE));
|
||||||
|
|
||||||
// Two text break
|
// Two text break
|
||||||
$section->addTextBreak(2);
|
$section->addTextBreak(2);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ $phpWord->addParagraphStyle(
|
||||||
new \PhpOffice\PhpWord\Style\Tab('left', 1550),
|
new \PhpOffice\PhpWord\Style\Tab('left', 1550),
|
||||||
new \PhpOffice\PhpWord\Style\Tab('center', 3200),
|
new \PhpOffice\PhpWord\Style\Tab('center', 3200),
|
||||||
new \PhpOffice\PhpWord\Style\Tab('right', 5300),
|
new \PhpOffice\PhpWord\Style\Tab('right', 5300),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
|
||||||
|
use PhpOffice\PhpWord\SimpleType\NumberFormat;
|
||||||
|
|
||||||
include_once 'Sample_Header.php';
|
include_once 'Sample_Header.php';
|
||||||
|
|
||||||
// New Word Document
|
// New Word Document
|
||||||
|
|
@ -42,11 +45,15 @@ $footnote->addText('But you can only put footnote in section, not in header or f
|
||||||
|
|
||||||
$section->addText(
|
$section->addText(
|
||||||
'You can also create the footnote directly from the section making it wrap in a paragraph '
|
'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 = $section->addFootnote();
|
||||||
$footnote->addText('The reference for this is wrapped in its own line');
|
$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
|
// Save file
|
||||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||||
if (!CLI) {
|
if (!CLI) {
|
||||||
|
|
|
||||||
|
|
@ -1,62 +1,62 @@
|
||||||
<?php
|
<?php
|
||||||
include_once 'Sample_Header.php';
|
include_once 'Sample_Header.php';
|
||||||
|
|
||||||
// Template processor instance creation
|
// Template processor instance creation
|
||||||
echo date('H:i:s'), ' Creating new TemplateProcessor instance...', EOL;
|
echo date('H:i:s'), ' Creating new TemplateProcessor instance...', EOL;
|
||||||
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
|
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
|
||||||
|
|
||||||
// Variables on different parts of document
|
// Variables on different parts of document
|
||||||
$templateProcessor->setValue('weekday', date('l')); // On section/content
|
$templateProcessor->setValue('weekday', date('l')); // On section/content
|
||||||
$templateProcessor->setValue('time', date('H:i')); // On footer
|
$templateProcessor->setValue('time', date('H:i')); // On footer
|
||||||
$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
|
$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
|
||||||
|
|
||||||
// Simple table
|
// Simple table
|
||||||
$templateProcessor->cloneRow('rowValue', 10);
|
$templateProcessor->cloneRow('rowValue', 10);
|
||||||
|
|
||||||
$templateProcessor->setValue('rowValue#1', 'Sun');
|
$templateProcessor->setValue('rowValue#1', 'Sun');
|
||||||
$templateProcessor->setValue('rowValue#2', 'Mercury');
|
$templateProcessor->setValue('rowValue#2', 'Mercury');
|
||||||
$templateProcessor->setValue('rowValue#3', 'Venus');
|
$templateProcessor->setValue('rowValue#3', 'Venus');
|
||||||
$templateProcessor->setValue('rowValue#4', 'Earth');
|
$templateProcessor->setValue('rowValue#4', 'Earth');
|
||||||
$templateProcessor->setValue('rowValue#5', 'Mars');
|
$templateProcessor->setValue('rowValue#5', 'Mars');
|
||||||
$templateProcessor->setValue('rowValue#6', 'Jupiter');
|
$templateProcessor->setValue('rowValue#6', 'Jupiter');
|
||||||
$templateProcessor->setValue('rowValue#7', 'Saturn');
|
$templateProcessor->setValue('rowValue#7', 'Saturn');
|
||||||
$templateProcessor->setValue('rowValue#8', 'Uranus');
|
$templateProcessor->setValue('rowValue#8', 'Uranus');
|
||||||
$templateProcessor->setValue('rowValue#9', 'Neptun');
|
$templateProcessor->setValue('rowValue#9', 'Neptun');
|
||||||
$templateProcessor->setValue('rowValue#10', 'Pluto');
|
$templateProcessor->setValue('rowValue#10', 'Pluto');
|
||||||
|
|
||||||
$templateProcessor->setValue('rowNumber#1', '1');
|
$templateProcessor->setValue('rowNumber#1', '1');
|
||||||
$templateProcessor->setValue('rowNumber#2', '2');
|
$templateProcessor->setValue('rowNumber#2', '2');
|
||||||
$templateProcessor->setValue('rowNumber#3', '3');
|
$templateProcessor->setValue('rowNumber#3', '3');
|
||||||
$templateProcessor->setValue('rowNumber#4', '4');
|
$templateProcessor->setValue('rowNumber#4', '4');
|
||||||
$templateProcessor->setValue('rowNumber#5', '5');
|
$templateProcessor->setValue('rowNumber#5', '5');
|
||||||
$templateProcessor->setValue('rowNumber#6', '6');
|
$templateProcessor->setValue('rowNumber#6', '6');
|
||||||
$templateProcessor->setValue('rowNumber#7', '7');
|
$templateProcessor->setValue('rowNumber#7', '7');
|
||||||
$templateProcessor->setValue('rowNumber#8', '8');
|
$templateProcessor->setValue('rowNumber#8', '8');
|
||||||
$templateProcessor->setValue('rowNumber#9', '9');
|
$templateProcessor->setValue('rowNumber#9', '9');
|
||||||
$templateProcessor->setValue('rowNumber#10', '10');
|
$templateProcessor->setValue('rowNumber#10', '10');
|
||||||
|
|
||||||
// Table with a spanned cell
|
// Table with a spanned cell
|
||||||
$templateProcessor->cloneRow('userId', 3);
|
$templateProcessor->cloneRow('userId', 3);
|
||||||
|
|
||||||
$templateProcessor->setValue('userId#1', '1');
|
$templateProcessor->setValue('userId#1', '1');
|
||||||
$templateProcessor->setValue('userFirstName#1', 'James');
|
$templateProcessor->setValue('userFirstName#1', 'James');
|
||||||
$templateProcessor->setValue('userName#1', 'Taylor');
|
$templateProcessor->setValue('userName#1', 'Taylor');
|
||||||
$templateProcessor->setValue('userPhone#1', '+1 428 889 773');
|
$templateProcessor->setValue('userPhone#1', '+1 428 889 773');
|
||||||
|
|
||||||
$templateProcessor->setValue('userId#2', '2');
|
$templateProcessor->setValue('userId#2', '2');
|
||||||
$templateProcessor->setValue('userFirstName#2', 'Robert');
|
$templateProcessor->setValue('userFirstName#2', 'Robert');
|
||||||
$templateProcessor->setValue('userName#2', 'Bell');
|
$templateProcessor->setValue('userName#2', 'Bell');
|
||||||
$templateProcessor->setValue('userPhone#2', '+1 428 889 774');
|
$templateProcessor->setValue('userPhone#2', '+1 428 889 774');
|
||||||
|
|
||||||
$templateProcessor->setValue('userId#3', '3');
|
$templateProcessor->setValue('userId#3', '3');
|
||||||
$templateProcessor->setValue('userFirstName#3', 'Michael');
|
$templateProcessor->setValue('userFirstName#3', 'Michael');
|
||||||
$templateProcessor->setValue('userName#3', 'Ray');
|
$templateProcessor->setValue('userName#3', 'Ray');
|
||||||
$templateProcessor->setValue('userPhone#3', '+1 428 889 775');
|
$templateProcessor->setValue('userPhone#3', '+1 428 889 775');
|
||||||
|
|
||||||
echo date('H:i:s'), ' Saving the result document...', EOL;
|
echo date('H:i:s'), ' Saving the result document...', EOL;
|
||||||
$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
|
$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
|
||||||
|
|
||||||
echo getEndingNotes(array('Word2007' => 'docx'));
|
echo getEndingNotes(array('Word2007' => 'docx'));
|
||||||
if (!CLI) {
|
if (!CLI) {
|
||||||
include_once 'Sample_Footer.php';
|
include_once 'Sample_Footer.php';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ $section->addText(
|
||||||
'Below are the samples on how to control your paragraph '
|
'Below are the samples on how to control your paragraph '
|
||||||
. 'pagination. See "Line and Page Break" tab on paragraph properties '
|
. 'pagination. See "Line and Page Break" tab on paragraph properties '
|
||||||
. 'window to see the attribute set by these controls.',
|
. 'window to see the attribute set by these controls.',
|
||||||
array('bold' => true),
|
array('bold' => true),
|
||||||
array('space' => array('before' => 360, 'after' => 480))
|
array('space' => array('before' => 360, 'after' => 480))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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}");
|
$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);
|
$table->addCell(500)->addText($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* 3. colspan (gridSpan) and rowspan (vMerge)
|
* 3. colspan (gridSpan) and rowspan (vMerge)
|
||||||
* ---------------------
|
* ---------------------
|
||||||
* | | B | |
|
* | | B | |
|
||||||
|
|
@ -93,7 +93,7 @@ $table->addCell(2000, $cellVCentered)->addText('C', null, $cellHCentered);
|
||||||
$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered);
|
$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered);
|
||||||
$table->addCell(null, $cellRowContinue);
|
$table->addCell(null, $cellRowContinue);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* 4. colspan (gridSpan) and rowspan (vMerge)
|
* 4. colspan (gridSpan) and rowspan (vMerge)
|
||||||
* ---------------------
|
* ---------------------
|
||||||
* | | B | 1 |
|
* | | B | 1 |
|
||||||
|
|
@ -104,25 +104,26 @@ $table->addCell(null, $cellRowContinue);
|
||||||
* ---------------------
|
* ---------------------
|
||||||
* @see https://github.com/PHPOffice/PHPWord/issues/806
|
* @see https://github.com/PHPOffice/PHPWord/issues/806
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$section->addPageBreak();
|
$section->addPageBreak();
|
||||||
$section->addText('Table with colspan and rowspan', $header);
|
$section->addText('Table with colspan and rowspan', $header);
|
||||||
|
|
||||||
$styleTable = ['borderSize' => 6, 'borderColor' => '999999'];
|
$styleTable = array('borderSize' => 6, 'borderColor' => '999999');
|
||||||
$phpWord->addTableStyle('Colspan Rowspan', $styleTable);
|
$phpWord->addTableStyle('Colspan Rowspan', $styleTable);
|
||||||
$table = $section->addTable('Colspan Rowspan');
|
$table = $section->addTable('Colspan Rowspan');
|
||||||
|
|
||||||
$row = $table->addRow();
|
$row = $table->addRow();
|
||||||
|
|
||||||
$row->addCell(null, ['vMerge' => 'restart'])->addText('A');
|
$row->addCell(null, array('vMerge' => 'restart'))->addText('A');
|
||||||
$row->addCell(null, ['gridSpan' => 2, 'vMerge' => 'restart',])->addText('B');
|
$row->addCell(null, array('gridSpan' => 2, 'vMerge' => 'restart'))->addText('B');
|
||||||
$row->addCell()->addText('1');
|
$row->addCell()->addText('1');
|
||||||
|
|
||||||
$row = $table->addRow();
|
$row = $table->addRow();
|
||||||
$row->addCell(null, ['vMerge' => 'continue']);
|
$row->addCell(null, array('vMerge' => 'continue'));
|
||||||
$row->addCell(null, ['vMerge' => 'continue','gridSpan' => 2,]);
|
$row->addCell(null, array('vMerge' => 'continue', 'gridSpan' => 2));
|
||||||
$row->addCell()->addText('2');
|
$row->addCell()->addText('2');
|
||||||
$row = $table->addRow();
|
$row = $table->addRow();
|
||||||
$row->addCell(null, ['vMerge' => 'continue']);
|
$row->addCell(null, array('vMerge' => 'continue'));
|
||||||
$row->addCell()->addText('C');
|
$row->addCell()->addText('C');
|
||||||
$row->addCell()->addText('D');
|
$row->addCell()->addText('D');
|
||||||
$row->addCell()->addText('3');
|
$row->addCell()->addText('3');
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$header = array('size' => 16, 'bold' => true);
|
$header = array('size' => 16, 'bold' => true);
|
||||||
//1.Use EastAisa FontStyle
|
//1.Use EastAisa FontStyle
|
||||||
$section->addText('中文楷体样式测试', array('name' => '楷体', 'size' => 16, 'color' => '1B2232'));
|
$section->addText('中文楷体样式测试', array('name' => '楷体', 'size' => 16, 'color' => '1B2232', 'lang' => array('latin' => 'en-US', 'eastAsia' => 'zh-CN')));
|
||||||
|
|
||||||
// Save file
|
// Save file
|
||||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,12 @@ $source = 'http://php.net/images/logos/php-med-trans-light.gif';
|
||||||
$section->addText("Remote image from: {$source}");
|
$section->addText("Remote image from: {$source}");
|
||||||
$section->addImage($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
|
//Wrapping style
|
||||||
$text = str_repeat('Hello World! ', 15);
|
$text = str_repeat('Hello World! ', 15);
|
||||||
$wrappingStyles = array('inline', 'behind', 'infront', 'square', 'tight');
|
$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 .= '<p>Ordered (numbered) list:</p>';
|
||||||
$html .= '<ol><li>Item 1</li><li>Item 2</li></ol>';
|
$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
|
// Save file
|
||||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
use PhpOffice\PhpWord\Element\TextRun;
|
||||||
|
|
||||||
include_once 'Sample_Header.php';
|
include_once 'Sample_Header.php';
|
||||||
|
|
||||||
// New Word document
|
// 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->addField('DATE', array('dateformat' => 'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat'));
|
||||||
|
|
||||||
$section->addText('Page field:');
|
$section->addText('Page field:');
|
||||||
$section->addField('PAGE', array('format' => 'ArabicDash'));
|
$section->addField('PAGE', array('format' => 'Arabic'));
|
||||||
|
|
||||||
$section->addText('Number of pages field:');
|
$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 = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
|
||||||
$textrun->addText('This is the date of lunar calendar ');
|
$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 = $section->addTextRun();
|
||||||
$textrun->addText('Date: ');
|
$textrun->addText('Date: ');
|
||||||
$textrun->addSDT('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 = $section->addTextRun();
|
||||||
$textrun->addText('Drop down list: ');
|
$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
|
// Save file
|
||||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
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();
|
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
|
// Set writers
|
||||||
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf');
|
$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
|
// Do not show execution time for index
|
||||||
if (!IS_INDEX) {
|
if (!IS_INDEX) {
|
||||||
$result .= date('H:i:s') . " Done writing file(s)" . 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;
|
$result .= date('H:i:s') . ' Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB' . EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ $requirements = array(
|
||||||
'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')),
|
'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')),
|
||||||
);
|
);
|
||||||
if (!CLI) {
|
if (!CLI) {
|
||||||
?>
|
?>
|
||||||
<div class="jumbotron">
|
<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>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>
|
<p> </p>
|
||||||
|
|
@ -25,14 +25,14 @@ if (!CLI) {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if (!CLI) {
|
if (!CLI) {
|
||||||
echo "<h3>Requirement check:</h3>";
|
echo '<h3>Requirement check:</h3>';
|
||||||
echo "<ul>";
|
echo '<ul>';
|
||||||
foreach ($requirements as $key => $value) {
|
foreach ($requirements as $key => $value) {
|
||||||
list($label, $result) = $value;
|
list($label, $result) = $value;
|
||||||
$status = $result ? 'passed' : 'failed';
|
$status = $result ? 'passed' : 'failed';
|
||||||
echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>";
|
echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>";
|
||||||
}
|
}
|
||||||
echo "</ul>";
|
echo '</ul>';
|
||||||
include_once 'Sample_Footer.php';
|
include_once 'Sample_Footer.php';
|
||||||
} else {
|
} else {
|
||||||
echo 'Requirement check:' . PHP_EOL;
|
echo 'Requirement check:' . PHP_EOL;
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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)) {
|
if (array_key_exists($index, $this->items)) {
|
||||||
return $this->items[$index];
|
return $this->items[$index];
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -61,7 +61,6 @@ abstract class AbstractCollection
|
||||||
*
|
*
|
||||||
* @param int $index
|
* @param int $index
|
||||||
* @param mixed $item
|
* @param mixed $item
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setItem($index, $item)
|
public function setItem($index, $item)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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 Text addText(string $text, mixed $fStyle = null, mixed $pStyle = null)
|
||||||
* @method TextRun addTextRun(mixed $pStyle = null)
|
* @method TextRun addTextRun(mixed $pStyle = null)
|
||||||
* @method Bookmark addBookmark(string $name)
|
* @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 PreserveText addPreserveText(string $text, mixed $fStyle = null, mixed $pStyle = null)
|
||||||
* @method void addTextBreak(int $count = 1, 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)
|
* @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 PageBreak addPageBreak()
|
||||||
* @method Table addTable(mixed $style = null)
|
* @method Table addTable(mixed $style = null)
|
||||||
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false)
|
* @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 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 Line addLine(mixed $lineStyle = null)
|
||||||
* @method Shape addShape(string $type, mixed $style = null)
|
* @method Shape addShape(string $type, mixed $style = null)
|
||||||
* @method Chart addChart(string $type, array $categories, array $values, array $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();
|
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
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
|
@ -83,7 +83,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||||
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object',
|
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object',
|
||||||
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
|
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
|
||||||
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
|
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
|
||||||
'Chart', 'FormField', 'SDT'
|
'Chart', 'FormField', 'SDT', 'Comment',
|
||||||
);
|
);
|
||||||
$functions = array();
|
$functions = array();
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
|
|
@ -98,16 +98,15 @@ abstract class AbstractContainer extends AbstractElement
|
||||||
// Special case for TextBreak
|
// Special case for TextBreak
|
||||||
// @todo Remove the `$count` parameter in 1.0.0 to make this element similiar to other elements?
|
// @todo Remove the `$count` parameter in 1.0.0 to make this element similiar to other elements?
|
||||||
if ($element == 'TextBreak') {
|
if ($element == 'TextBreak') {
|
||||||
@list($count, $fontStyle, $paragraphStyle) = $args; // Suppress error
|
list($count, $fontStyle, $paragraphStyle) = array_pad($args, 3, null);
|
||||||
if ($count === null) {
|
if ($count === null) {
|
||||||
$count = 1;
|
$count = 1;
|
||||||
}
|
}
|
||||||
for ($i = 1; $i <= $count; $i++) {
|
for ($i = 1; $i <= $count; $i++) {
|
||||||
$this->addElement($element, $fontStyle, $paragraphStyle);
|
$this->addElement($element, $fontStyle, $paragraphStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// All other elements
|
|
||||||
} else {
|
} else {
|
||||||
|
// All other elements
|
||||||
array_unshift($args, $element); // Prepend element name to the beginning of args array
|
array_unshift($args, $element); // Prepend element name to the beginning of args array
|
||||||
return call_user_func_array(array($this, 'addElement'), $args);
|
return call_user_func_array(array($this, 'addElement'), $args);
|
||||||
}
|
}
|
||||||
|
|
@ -158,8 +157,6 @@ abstract class AbstractContainer extends AbstractElement
|
||||||
* Get all elements
|
* Get all elements
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
public function getElements()
|
public function getElements()
|
||||||
{
|
{
|
||||||
|
|
@ -181,14 +178,13 @@ abstract class AbstractContainer extends AbstractElement
|
||||||
*
|
*
|
||||||
* @param string $method
|
* @param string $method
|
||||||
*
|
*
|
||||||
* @return bool
|
|
||||||
*
|
|
||||||
* @throws \BadMethodCallException
|
* @throws \BadMethodCallException
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function checkValidity($method)
|
private function checkValidity($method)
|
||||||
{
|
{
|
||||||
$generalContainers = array(
|
$generalContainers = array(
|
||||||
'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun',
|
'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun', 'TrackChange',
|
||||||
);
|
);
|
||||||
|
|
||||||
$validContainers = array(
|
$validContainers = array(
|
||||||
|
|
@ -203,7 +199,8 @@ abstract class AbstractContainer extends AbstractElement
|
||||||
'Shape' => $generalContainers,
|
'Shape' => $generalContainers,
|
||||||
'FormField' => $generalContainers,
|
'FormField' => $generalContainers,
|
||||||
'SDT' => $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'),
|
'ListItem' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
||||||
'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
||||||
'Table' => 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'),
|
'TextBox' => array('Section', 'Header', 'Footer', 'Cell'),
|
||||||
'Footnote' => array('Section', 'TextRun', 'Cell'),
|
'Footnote' => array('Section', 'TextRun', 'Cell'),
|
||||||
'Endnote' => array('Section', 'TextRun', 'Cell'),
|
'Endnote' => array('Section', 'TextRun', 'Cell'),
|
||||||
'PreserveText' => array('Header', 'Footer', 'Cell'),
|
'PreserveText' => array('Section', 'Header', 'Footer', 'Cell'),
|
||||||
'Title' => array('Section'),
|
'Title' => array('Section'),
|
||||||
'TOC' => array('Section'),
|
'TOC' => array('Section'),
|
||||||
'PageBreak' => array('Section'),
|
'PageBreak' => array('Section'),
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ abstract class AbstractElement
|
||||||
/**
|
/**
|
||||||
* Unique Id for element
|
* Unique Id for element
|
||||||
*
|
*
|
||||||
* @var int
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $elementId;
|
protected $elementId;
|
||||||
|
|
||||||
|
|
@ -108,12 +108,26 @@ abstract class AbstractElement
|
||||||
protected $mediaRelation = false;
|
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
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $collectionRelation = false;
|
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
|
* Get PhpWord
|
||||||
*
|
*
|
||||||
|
|
@ -128,7 +142,6 @@ abstract class AbstractElement
|
||||||
* Set PhpWord as reference.
|
* Set PhpWord as reference.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setPhpWord(PhpWord $phpWord = null)
|
public function setPhpWord(PhpWord $phpWord = null)
|
||||||
{
|
{
|
||||||
|
|
@ -150,7 +163,6 @@ abstract class AbstractElement
|
||||||
*
|
*
|
||||||
* @param string $docPart
|
* @param string $docPart
|
||||||
* @param int $docPartId
|
* @param int $docPartId
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setDocPart($docPart, $docPartId = 1)
|
public function setDocPart($docPart, $docPartId = 1)
|
||||||
{
|
{
|
||||||
|
|
@ -207,7 +219,6 @@ abstract class AbstractElement
|
||||||
* Set element index.
|
* Set element index.
|
||||||
*
|
*
|
||||||
* @param int $value
|
* @param int $value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setElementIndex($value)
|
public function setElementIndex($value)
|
||||||
{
|
{
|
||||||
|
|
@ -217,7 +228,7 @@ abstract class AbstractElement
|
||||||
/**
|
/**
|
||||||
* Get element unique ID
|
* Get element unique ID
|
||||||
*
|
*
|
||||||
* @return string
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getElementId()
|
public function getElementId()
|
||||||
{
|
{
|
||||||
|
|
@ -226,8 +237,6 @@ abstract class AbstractElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set element unique ID from 6 first digit of md5.
|
* Set element unique ID from 6 first digit of md5.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setElementId()
|
public function setElementId()
|
||||||
{
|
{
|
||||||
|
|
@ -248,7 +257,6 @@ abstract class AbstractElement
|
||||||
* Set relation Id.
|
* Set relation Id.
|
||||||
*
|
*
|
||||||
* @param int $value
|
* @param int $value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setRelationId($value)
|
public function setRelationId($value)
|
||||||
{
|
{
|
||||||
|
|
@ -265,13 +273,60 @@ abstract class AbstractElement
|
||||||
return $this->nestedLevel;
|
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
|
* Set parent container
|
||||||
*
|
*
|
||||||
* Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
|
* Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $container
|
* @param \PhpOffice\PhpWord\Element\AbstractElement $container
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setParentContainer(AbstractElement $container)
|
public function setParentContainer(AbstractElement $container)
|
||||||
{
|
{
|
||||||
|
|
@ -300,8 +355,6 @@ abstract class AbstractElement
|
||||||
*
|
*
|
||||||
* - Image element needs to be passed to Media object
|
* - Image element needs to be passed to Media object
|
||||||
* - Icon needs to be set for Object element
|
* - Icon needs to be set for Object element
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private function setMediaRelation()
|
private function setMediaRelation()
|
||||||
{
|
{
|
||||||
|
|
@ -328,8 +381,6 @@ abstract class AbstractElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set relation Id for elements that will be registered in the Collection subnamespaces.
|
* Set relation Id for elements that will be registered in the Collection subnamespaces.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private function setCollectionRelation()
|
private function setCollectionRelation()
|
||||||
{
|
{
|
||||||
|
|
@ -348,7 +399,7 @@ abstract class AbstractElement
|
||||||
*/
|
*/
|
||||||
public function isInSection()
|
public function isInSection()
|
||||||
{
|
{
|
||||||
return ($this->docPart == 'Section');
|
return $this->docPart == 'Section';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -378,9 +429,8 @@ abstract class AbstractElement
|
||||||
* @param array $enum
|
* @param array $enum
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
*
|
*
|
||||||
* @return mixed
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @todo Merge with the same method in AbstractStyle
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -45,9 +45,7 @@ class Bookmark extends AbstractElement
|
||||||
*/
|
*/
|
||||||
public function __construct($name)
|
public function __construct($name)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->name = CommonText::toUTF8($name);
|
$this->name = CommonText::toUTF8($name);
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -83,7 +83,6 @@ class Chart extends AbstractElement
|
||||||
* Set type.
|
* Set type.
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setType($value)
|
public function setType($value)
|
||||||
{
|
{
|
||||||
|
|
@ -96,7 +95,6 @@ class Chart extends AbstractElement
|
||||||
*
|
*
|
||||||
* @param array $categories
|
* @param array $categories
|
||||||
* @param array $values
|
* @param array $values
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function addSeries($categories, $values)
|
public function addSeries($categories, $values)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -40,7 +40,6 @@ class CheckBox extends Text
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function __construct($name = null, $text = null, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($name = null, $text = null, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Element;
|
||||||
* Field element
|
* Field element
|
||||||
*
|
*
|
||||||
* @since 0.11.0
|
* @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
|
class Field extends AbstractElement
|
||||||
{
|
{
|
||||||
|
|
@ -32,27 +32,36 @@ class Field extends AbstractElement
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fieldsArray = array(
|
protected $fieldsArray = array(
|
||||||
'PAGE'=>array(
|
'PAGE' => array(
|
||||||
'properties'=>array(
|
'properties' => array(
|
||||||
'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
|
'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
|
||||||
),
|
),
|
||||||
'options'=>array('PreserveFormat')
|
'options' => array('PreserveFormat'),
|
||||||
),
|
),
|
||||||
'NUMPAGES'=>array(
|
'NUMPAGES' => array(
|
||||||
'properties'=>array(
|
'properties' => array(
|
||||||
'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
|
'format' => array('Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText',
|
||||||
'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%')
|
'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(
|
'DATE' => array(
|
||||||
'properties'=> array(
|
'properties' => array(
|
||||||
'dateformat' =>array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd',
|
'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',
|
'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')
|
'options' => array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat'),
|
||||||
)
|
),
|
||||||
|
'XE' => array(
|
||||||
|
'properties' => array(),
|
||||||
|
'options' => array('Bold', 'Italic'),
|
||||||
|
),
|
||||||
|
'INDEX' => array(
|
||||||
|
'properties' => array(),
|
||||||
|
'options' => array('PreserveFormat'),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,6 +71,13 @@ class Field extends AbstractElement
|
||||||
*/
|
*/
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field text
|
||||||
|
*
|
||||||
|
* @var TextRun | string
|
||||||
|
*/
|
||||||
|
protected $text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field properties
|
* Field properties
|
||||||
*
|
*
|
||||||
|
|
@ -82,12 +98,14 @@ class Field extends AbstractElement
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param array $properties
|
* @param array $properties
|
||||||
* @param array $options
|
* @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->setType($type);
|
||||||
$this->setProperties($properties);
|
$this->setProperties($properties);
|
||||||
$this->setOptions($options);
|
$this->setOptions($options);
|
||||||
|
$this->setText($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -95,9 +113,8 @@ class Field extends AbstractElement
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
*
|
*
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function setType($type = null)
|
public function setType($type = null)
|
||||||
{
|
{
|
||||||
|
|
@ -105,9 +122,10 @@ class Field extends AbstractElement
|
||||||
if (isset($this->fieldsArray[$type])) {
|
if (isset($this->fieldsArray[$type])) {
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException("Invalid type");
|
throw new \InvalidArgumentException("Invalid type '$type'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,20 +144,20 @@ class Field extends AbstractElement
|
||||||
*
|
*
|
||||||
* @param array $properties
|
* @param array $properties
|
||||||
*
|
*
|
||||||
* @return self
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setProperties($properties = array())
|
public function setProperties($properties = array())
|
||||||
{
|
{
|
||||||
if (is_array($properties)) {
|
if (is_array($properties)) {
|
||||||
foreach (array_keys($properties) as $propkey) {
|
foreach (array_keys($properties) as $propkey) {
|
||||||
if (!(isset($this->fieldsArray[$this->type]['properties'][$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);
|
$this->properties = array_merge($this->properties, $properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->properties;
|
return $this->properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,20 +176,20 @@ class Field extends AbstractElement
|
||||||
*
|
*
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
*
|
||||||
* @return self
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setOptions($options = array())
|
public function setOptions($options = array())
|
||||||
{
|
{
|
||||||
if (is_array($options)) {
|
if (is_array($options)) {
|
||||||
foreach (array_keys($options) as $optionkey) {
|
foreach (array_keys($options) as $optionkey) {
|
||||||
if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey]))) {
|
if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey])) && substr($optionkey, 0, 1) !== '\\') {
|
||||||
throw new \InvalidArgumentException("Invalid option");
|
throw new \InvalidArgumentException("Invalid option '$optionkey', possible values are " . implode(', ', $this->fieldsArray[$this->type]['options']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->options = array_merge($this->options, $options);
|
$this->options = array_merge($this->options, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->options;
|
return $this->options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,4 +202,35 @@ class Field extends AbstractElement
|
||||||
{
|
{
|
||||||
return $this->options;
|
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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -26,11 +26,11 @@ class Footer extends AbstractContainer
|
||||||
* Header/footer types constants
|
* Header/footer types constants
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-wtype-4.html Header or Footer Type
|
* @see http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type
|
||||||
*/
|
*/
|
||||||
const AUTO = 'default'; // default and odd pages
|
const AUTO = 'default'; // default and odd pages
|
||||||
const FIRST = 'first';
|
const FIRST = 'first';
|
||||||
const EVEN = 'even';
|
const EVEN = 'even';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Container type
|
* @var string Container type
|
||||||
|
|
@ -64,7 +64,6 @@ class Footer extends AbstractContainer
|
||||||
* @since 0.10.0
|
* @since 0.10.0
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setType($value = self::AUTO)
|
public function setType($value = self::AUTO)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -19,9 +19,6 @@ namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
|
|
||||||
/**
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class Footnote extends AbstractContainer
|
class Footnote extends AbstractContainer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
@ -68,6 +65,7 @@ class Footnote extends AbstractContainer
|
||||||
* Get Footnote Reference ID
|
* Get Footnote Reference ID
|
||||||
*
|
*
|
||||||
* @deprecated 0.10.0
|
* @deprecated 0.10.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
|
@ -80,6 +78,7 @@ class Footnote extends AbstractContainer
|
||||||
* Set Footnote Reference ID
|
* Set Footnote Reference ID
|
||||||
*
|
*
|
||||||
* @deprecated 0.10.0
|
* @deprecated 0.10.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
* @param int $rId
|
* @param int $rId
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Element;
|
||||||
* Form field element
|
* Form field element
|
||||||
*
|
*
|
||||||
* @since 0.12.0
|
* @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
|
class FormField extends Text
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +35,7 @@ class FormField extends Text
|
||||||
/**
|
/**
|
||||||
* Form field name
|
* Form field name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string|bool|int
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
|
|
@ -70,10 +70,10 @@ class FormField extends Text
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
|
parent::__construct(null, $fontStyle, $paragraphStyle);
|
||||||
$this->setType($type);
|
$this->setType($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Is watermark
|
* Is watermark
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $watermark;
|
private $watermark;
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Is memory image
|
* Is memory image
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $memoryImage;
|
private $memoryImage;
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Image media index
|
* Image media index
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $mediaIndex;
|
private $mediaIndex;
|
||||||
|
|
||||||
|
|
@ -126,7 +126,7 @@ class Image extends AbstractElement
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param mixed $style
|
* @param mixed $style
|
||||||
* @param boolean $watermark
|
* @param bool $watermark
|
||||||
*
|
*
|
||||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||||
|
|
@ -183,7 +183,7 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Get is watermark
|
* Get is watermark
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isWatermark()
|
public function isWatermark()
|
||||||
{
|
{
|
||||||
|
|
@ -193,7 +193,7 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Set is watermark
|
* Set is watermark
|
||||||
*
|
*
|
||||||
* @param boolean $value
|
* @param bool $value
|
||||||
*/
|
*/
|
||||||
public function setIsWatermark($value)
|
public function setIsWatermark($value)
|
||||||
{
|
{
|
||||||
|
|
@ -243,7 +243,7 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Get is memory image
|
* Get is memory image
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isMemImage()
|
public function isMemImage()
|
||||||
{
|
{
|
||||||
|
|
@ -264,7 +264,6 @@ class Image extends AbstractElement
|
||||||
* Set target file name.
|
* Set target file name.
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setTarget($value)
|
public function setTarget($value)
|
||||||
{
|
{
|
||||||
|
|
@ -274,7 +273,7 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Get media index
|
* Get media index
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getMediaIndex()
|
public function getMediaIndex()
|
||||||
{
|
{
|
||||||
|
|
@ -284,8 +283,7 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Set media index.
|
* Set media index.
|
||||||
*
|
*
|
||||||
* @param integer $value
|
* @param int $value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setMediaIndex($value)
|
public function setMediaIndex($value)
|
||||||
{
|
{
|
||||||
|
|
@ -340,6 +338,8 @@ class Image extends AbstractElement
|
||||||
call_user_func($this->imageFunc, $imageResource);
|
call_user_func($this->imageFunc, $imageResource);
|
||||||
$imageBinary = ob_get_contents();
|
$imageBinary = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
} elseif ($this->sourceType == self::SOURCE_STRING) {
|
||||||
|
$imageBinary = $this->source;
|
||||||
} else {
|
} else {
|
||||||
$fileHandle = fopen($actualSource, 'rb', false);
|
$fileHandle = fopen($actualSource, 'rb', false);
|
||||||
if ($fileHandle !== false) {
|
if ($fileHandle !== false) {
|
||||||
|
|
@ -366,33 +366,29 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Check memory image, supported type, image functions, and proportional width/height.
|
* Check memory image, supported type, image functions, and proportional width/height.
|
||||||
*
|
*
|
||||||
* @param string $source
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||||
*/
|
*/
|
||||||
private function checkImage($source)
|
private function checkImage()
|
||||||
{
|
{
|
||||||
$this->setSourceType($source);
|
$this->setSourceType();
|
||||||
|
|
||||||
// Check image data
|
// Check image data
|
||||||
if ($this->sourceType == self::SOURCE_ARCHIVE) {
|
if ($this->sourceType == self::SOURCE_ARCHIVE) {
|
||||||
$imageData = $this->getArchiveImageSize($source);
|
$imageData = $this->getArchiveImageSize($this->source);
|
||||||
} else if ($this->sourceType == self::SOURCE_STRING) {
|
} elseif ($this->sourceType == self::SOURCE_STRING) {
|
||||||
$imageData = $this->getStringImageSize($source);
|
$imageData = $this->getStringImageSize($this->source);
|
||||||
} else {
|
} else {
|
||||||
$imageData = @getimagesize($source);
|
$imageData = @getimagesize($this->source);
|
||||||
}
|
}
|
||||||
if (!is_array($imageData)) {
|
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;
|
list($actualWidth, $actualHeight, $imageType) = $imageData;
|
||||||
|
|
||||||
// Check image type support
|
// Check image type support
|
||||||
$supportedTypes = array(IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG);
|
$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));
|
$supportedTypes = array_merge($supportedTypes, array(IMAGETYPE_BMP, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM));
|
||||||
}
|
}
|
||||||
if (!in_array($imageType, $supportedTypes)) {
|
if (!in_array($imageType, $supportedTypes)) {
|
||||||
|
|
@ -407,22 +403,25 @@ class Image extends AbstractElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set source type.
|
* 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->memoryImage = true;
|
||||||
$this->sourceType = self::SOURCE_GD;
|
$this->sourceType = self::SOURCE_GD;
|
||||||
} elseif (strpos($source, 'zip://') !== false) {
|
} elseif (strpos($this->source, 'zip://') !== false) {
|
||||||
$this->memoryImage = false;
|
$this->memoryImage = false;
|
||||||
$this->sourceType = self::SOURCE_ARCHIVE;
|
$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;
|
$this->memoryImage = true;
|
||||||
$this->sourceType = self::SOURCE_GD;
|
if (strpos($this->source, 'https') === 0) {
|
||||||
} elseif (@file_exists($source)) {
|
$fileContent = file_get_contents($this->source);
|
||||||
|
$this->source = $fileContent;
|
||||||
|
$this->sourceType = self::SOURCE_STRING;
|
||||||
|
} else {
|
||||||
|
$this->sourceType = self::SOURCE_GD;
|
||||||
|
}
|
||||||
|
} elseif (@file_exists($this->source)) {
|
||||||
$this->memoryImage = false;
|
$this->memoryImage = false;
|
||||||
$this->sourceType = self::SOURCE_LOCAL;
|
$this->sourceType = self::SOURCE_LOCAL;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -438,9 +437,9 @@ class Image extends AbstractElement
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
*
|
*
|
||||||
* @return array|null
|
|
||||||
*
|
|
||||||
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
|
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
|
||||||
|
*
|
||||||
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
private function getArchiveImageSize($source)
|
private function getArchiveImageSize($source)
|
||||||
{
|
{
|
||||||
|
|
@ -450,7 +449,7 @@ class Image extends AbstractElement
|
||||||
|
|
||||||
$tempFilename = tempnam(Settings::getTempDir(), 'PHPWordImage');
|
$tempFilename = tempnam(Settings::getTempDir(), 'PHPWordImage');
|
||||||
if (false === $tempFilename) {
|
if (false === $tempFilename) {
|
||||||
throw new CreateTemporaryFileException();
|
throw new CreateTemporaryFileException(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
|
|
@ -471,43 +470,43 @@ class Image extends AbstractElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get image size from string
|
* get image size from string
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
|
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
|
||||||
*/
|
*/
|
||||||
private function getStringImageSize($source)
|
private function getStringImageSize($source)
|
||||||
{
|
{
|
||||||
|
$result = false;
|
||||||
if (!function_exists('getimagesizefromstring')) {
|
if (!function_exists('getimagesizefromstring')) {
|
||||||
$uri = 'data://application/octet-stream;base64,' . base64_encode($source);
|
$uri = 'data://application/octet-stream;base64,' . base64_encode($source);
|
||||||
return @getimagesize($uri);
|
$result = @getimagesize($uri);
|
||||||
} else {
|
} else {
|
||||||
return @getimagesizefromstring($source);
|
$result = @getimagesizefromstring($source);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set image functions and extensions.
|
* Set image functions and extensions.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private function setFunctions()
|
private function setFunctions()
|
||||||
{
|
{
|
||||||
switch ($this->imageType) {
|
switch ($this->imageType) {
|
||||||
case 'image/png':
|
case 'image/png':
|
||||||
$this->imageCreateFunc = 'imagecreatefrompng';
|
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefrompng';
|
||||||
$this->imageFunc = 'imagepng';
|
$this->imageFunc = 'imagepng';
|
||||||
$this->imageExtension = 'png';
|
$this->imageExtension = 'png';
|
||||||
break;
|
break;
|
||||||
case 'image/gif':
|
case 'image/gif':
|
||||||
$this->imageCreateFunc = 'imagecreatefromgif';
|
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefromgif';
|
||||||
$this->imageFunc = 'imagegif';
|
$this->imageFunc = 'imagegif';
|
||||||
$this->imageExtension = 'gif';
|
$this->imageExtension = 'gif';
|
||||||
break;
|
break;
|
||||||
case 'image/jpeg':
|
case 'image/jpeg':
|
||||||
case 'image/jpg':
|
case 'image/jpg':
|
||||||
$this->imageCreateFunc = 'imagecreatefromjpeg';
|
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefromjpeg';
|
||||||
$this->imageFunc = 'imagejpeg';
|
$this->imageFunc = 'imagejpeg';
|
||||||
$this->imageExtension = 'jpg';
|
$this->imageExtension = 'jpg';
|
||||||
break;
|
break;
|
||||||
|
|
@ -525,9 +524,8 @@ class Image extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Set proportional width/height if one dimension not available.
|
* Set proportional width/height if one dimension not available.
|
||||||
*
|
*
|
||||||
* @param integer $actualWidth
|
* @param int $actualWidth
|
||||||
* @param integer $actualHeight
|
* @param int $actualHeight
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private function setProportionalSize($actualWidth, $actualHeight)
|
private function setProportionalSize($actualWidth, $actualHeight)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -75,6 +75,7 @@ class Link extends AbstractElement
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
|
* @param bool $internal
|
||||||
*/
|
*/
|
||||||
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
|
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->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
||||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
$this->internal = $internal;
|
$this->internal = $internal;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -74,10 +74,10 @@ class ListItemRun extends TextRun
|
||||||
return $this->style;
|
return $this->style;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get ListItem depth.
|
* Get ListItem depth.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getDepth()
|
public function getDepth()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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");
|
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
} else {
|
|
||||||
throw new InvalidObjectException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new InvalidObjectException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -133,7 +133,6 @@ class Object extends AbstractElement
|
||||||
* Set Image Relation ID.
|
* Set Image Relation ID.
|
||||||
*
|
*
|
||||||
* @param int $rId
|
* @param int $rId
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setImageRelationId($rId)
|
public function setImageRelationId($rId)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -47,14 +47,12 @@ class PreserveText extends AbstractElement
|
||||||
*/
|
*/
|
||||||
private $paragraphStyle;
|
private $paragraphStyle;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Preserve Text Element
|
* Create a new Preserve Text Element
|
||||||
*
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -45,16 +45,30 @@ class SDT extends Text
|
||||||
*/
|
*/
|
||||||
private $listItems = array();
|
private $listItems = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $alias;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tag
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new instance
|
* Create new instance
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($type, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
|
parent::__construct(null, $fontStyle, $paragraphStyle);
|
||||||
$this->setType($type);
|
$this->setType($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,4 +141,50 @@ class SDT extends Text
|
||||||
|
|
||||||
return $this;
|
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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
|
||||||
use PhpOffice\PhpWord\Style\Section as SectionStyle;
|
use PhpOffice\PhpWord\Style\Section as SectionStyle;
|
||||||
|
|
||||||
class Section extends AbstractContainer
|
class Section extends AbstractContainer
|
||||||
|
|
@ -47,6 +48,13 @@ class Section extends AbstractContainer
|
||||||
*/
|
*/
|
||||||
private $footers = array();
|
private $footers = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The properties for the footnote of this section
|
||||||
|
*
|
||||||
|
* @var FootnoteProperties
|
||||||
|
*/
|
||||||
|
private $footnoteProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new instance
|
* Create new instance
|
||||||
*
|
*
|
||||||
|
|
@ -65,7 +73,6 @@ class Section extends AbstractContainer
|
||||||
* Set section style.
|
* Set section style.
|
||||||
*
|
*
|
||||||
* @param array $style
|
* @param array $style
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setStyle($style = null)
|
public function setStyle($style = null)
|
||||||
{
|
{
|
||||||
|
|
@ -78,8 +85,6 @@ class Section extends AbstractContainer
|
||||||
* Get section style
|
* Get section style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Section
|
* @return \PhpOffice\PhpWord\Style\Section
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
public function getStyle()
|
public function getStyle()
|
||||||
{
|
{
|
||||||
|
|
@ -118,8 +123,6 @@ class Section extends AbstractContainer
|
||||||
* Get header elements
|
* Get header elements
|
||||||
*
|
*
|
||||||
* @return Header[]
|
* @return Header[]
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
public function getHeaders()
|
public function getHeaders()
|
||||||
{
|
{
|
||||||
|
|
@ -130,21 +133,39 @@ class Section extends AbstractContainer
|
||||||
* Get footer elements
|
* Get footer elements
|
||||||
*
|
*
|
||||||
* @return Footer[]
|
* @return Footer[]
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
public function getFooters()
|
public function getFooters()
|
||||||
{
|
{
|
||||||
return $this->footers;
|
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?
|
* 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.
|
* If any of the Header instances have a type of Header::FIRST then this method returns true.
|
||||||
* False otherwise.
|
* False otherwise.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasDifferentFirstPage()
|
public function hasDifferentFirstPage()
|
||||||
{
|
{
|
||||||
|
|
@ -153,6 +174,12 @@ class Section extends AbstractContainer
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach ($this->footers as $footer) {
|
||||||
|
if ($footer->getType() == Header::FIRST) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,11 +189,11 @@ class Section extends AbstractContainer
|
||||||
* @since 0.10.0
|
* @since 0.10.0
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param boolean $header
|
* @param bool $header
|
||||||
*
|
|
||||||
* @return Header|Footer
|
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @return Header|Footer
|
||||||
*/
|
*/
|
||||||
private function addHeaderFooter($type = Header::AUTO, $header = true)
|
private function addHeaderFooter($type = Header::AUTO, $header = true)
|
||||||
{
|
{
|
||||||
|
|
@ -182,11 +209,10 @@ class Section extends AbstractContainer
|
||||||
$container->setPhpWord($this->phpWord);
|
$container->setPhpWord($this->phpWord);
|
||||||
|
|
||||||
$collection[$index] = $container;
|
$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)) {
|
if (empty($this->footers)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
|
||||||
return $this->footers[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->footers[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ class TOC extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Font style
|
* Font style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Font|array|string
|
* @var \PhpOffice\PhpWord\Style\Font|string
|
||||||
*/
|
*/
|
||||||
private $fontStyle;
|
private $fontStyle;
|
||||||
|
|
||||||
|
|
@ -54,14 +54,13 @@ class TOC extends AbstractElement
|
||||||
*/
|
*/
|
||||||
private $maxDepth = 9;
|
private $maxDepth = 9;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Table-of-Contents Element
|
* Create a new Table-of-Contents Element
|
||||||
*
|
*
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param array $tocStyle
|
* @param array $tocStyle
|
||||||
* @param integer $minDepth
|
* @param int $minDepth
|
||||||
* @param integer $maxDepth
|
* @param int $maxDepth
|
||||||
*/
|
*/
|
||||||
public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9)
|
public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9)
|
||||||
{
|
{
|
||||||
|
|
@ -121,7 +120,7 @@ class TOC extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Get Font Style
|
* Get Font Style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Font
|
* @return \PhpOffice\PhpWord\Style\Font|string
|
||||||
*/
|
*/
|
||||||
public function getStyleFont()
|
public function getStyleFont()
|
||||||
{
|
{
|
||||||
|
|
@ -132,7 +131,6 @@ class TOC extends AbstractElement
|
||||||
* Set max depth.
|
* Set max depth.
|
||||||
*
|
*
|
||||||
* @param int $value
|
* @param int $value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setMaxDepth($value)
|
public function setMaxDepth($value)
|
||||||
{
|
{
|
||||||
|
|
@ -153,7 +151,6 @@ class TOC extends AbstractElement
|
||||||
* Set min depth.
|
* Set min depth.
|
||||||
*
|
*
|
||||||
* @param int $value
|
* @param int $value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setMinDepth($value)
|
public function setMinDepth($value)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -121,7 +121,6 @@ class Table extends AbstractElement
|
||||||
* Set table width.
|
* Set table width.
|
||||||
*
|
*
|
||||||
* @param int $width
|
* @param int $width
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setWidth($width)
|
public function setWidth($width)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -105,12 +105,12 @@ class Text extends AbstractElement
|
||||||
public function setParagraphStyle($style = null)
|
public function setParagraphStyle($style = null)
|
||||||
{
|
{
|
||||||
if (is_array($style)) {
|
if (is_array($style)) {
|
||||||
$this->paragraphStyle = new Paragraph;
|
$this->paragraphStyle = new Paragraph();
|
||||||
$this->paragraphStyle->setStyleByArray($style);
|
$this->paragraphStyle->setStyleByArray($style);
|
||||||
} elseif ($style instanceof Paragraph) {
|
} elseif ($style instanceof Paragraph) {
|
||||||
$this->paragraphStyle = $style;
|
$this->paragraphStyle = $style;
|
||||||
} elseif (null === $style) {
|
} elseif (null === $style) {
|
||||||
$this->paragraphStyle = new Paragraph;
|
$this->paragraphStyle = new Paragraph();
|
||||||
} else {
|
} else {
|
||||||
$this->paragraphStyle = $style;
|
$this->paragraphStyle = $style;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -74,6 +74,7 @@ class TextBreak extends AbstractElement
|
||||||
$this->fontStyle = $style;
|
$this->fontStyle = $style;
|
||||||
$this->setParagraphStyle($paragraphStyle);
|
$this->setParagraphStyle($paragraphStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->fontStyle;
|
return $this->fontStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,13 +97,14 @@ class TextBreak extends AbstractElement
|
||||||
public function setParagraphStyle($style = null)
|
public function setParagraphStyle($style = null)
|
||||||
{
|
{
|
||||||
if (is_array($style)) {
|
if (is_array($style)) {
|
||||||
$this->paragraphStyle = new Paragraph;
|
$this->paragraphStyle = new Paragraph();
|
||||||
$this->paragraphStyle->setStyleByArray($style);
|
$this->paragraphStyle->setStyleByArray($style);
|
||||||
} elseif ($style instanceof Paragraph) {
|
} elseif ($style instanceof Paragraph) {
|
||||||
$this->paragraphStyle = $style;
|
$this->paragraphStyle = $style;
|
||||||
} else {
|
} else {
|
||||||
$this->paragraphStyle = $style;
|
$this->paragraphStyle = $style;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->paragraphStyle;
|
return $this->paragraphStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ class Title extends AbstractElement
|
||||||
/**
|
/**
|
||||||
* Get depth
|
* Get depth
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getDepth()
|
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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
abstract class AbstractEscaper implements EscaperInterface
|
abstract class AbstractEscaper implements EscaperInterface
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
interface EscaperInterface
|
interface EscaperInterface
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
class RegExp extends AbstractEscaper
|
class RegExp extends AbstractEscaper
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
class Rtf extends AbstractEscaper
|
class Rtf extends AbstractEscaper
|
||||||
|
|
@ -28,9 +28,9 @@ class Rtf extends AbstractEscaper
|
||||||
{
|
{
|
||||||
if (20 > $code || $code >= 80) {
|
if (20 > $code || $code >= 80) {
|
||||||
return '{\u' . $code . '}';
|
return '{\u' . $code . '}';
|
||||||
} else {
|
|
||||||
return chr($code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return chr($code);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function escapeMultibyteCharacter($code)
|
protected function escapeMultibyteCharacter($code)
|
||||||
|
|
@ -40,6 +40,7 @@ class Rtf extends AbstractEscaper
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
|
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||||
|
* @param string $input
|
||||||
*/
|
*/
|
||||||
protected function escapeSingleValue($input)
|
protected function escapeSingleValue($input)
|
||||||
{
|
{
|
||||||
|
|
@ -57,9 +58,9 @@ class Rtf extends AbstractEscaper
|
||||||
if (0 == count($bytes)) {
|
if (0 == count($bytes)) {
|
||||||
if ($asciiCode < 224) {
|
if ($asciiCode < 224) {
|
||||||
$numberOfBytes = 2;
|
$numberOfBytes = 2;
|
||||||
} else if ($asciiCode < 240) {
|
} elseif ($asciiCode < 240) {
|
||||||
$numberOfBytes = 3;
|
$numberOfBytes = 3;
|
||||||
} else if ($asciiCode < 248) {
|
} elseif ($asciiCode < 248) {
|
||||||
$numberOfBytes = 4;
|
$numberOfBytes = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 0.13.0
|
* @since 0.13.0
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
class Xml extends AbstractEscaper
|
class Xml extends AbstractEscaper
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -23,10 +23,10 @@ namespace PhpOffice\PhpWord\Exception;
|
||||||
final class CopyFileException extends Exception
|
final class CopyFileException extends Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string $source The fully qualified source file name.
|
* @param string $source The fully qualified source file name
|
||||||
* @param string $destination The fully qualified destination file name.
|
* @param string $destination The fully qualified destination file name
|
||||||
* @param integer $code The user defined exception code.
|
* @param int $code The user defined exception code
|
||||||
* @param \Exception $previous The previous exception used for the exception chaining.
|
* @param \Exception $previous The previous exception used for the exception chaining
|
||||||
*/
|
*/
|
||||||
final public function __construct($source, $destination, $code = 0, \Exception $previous = null)
|
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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -23,8 +23,8 @@ namespace PhpOffice\PhpWord\Exception;
|
||||||
final class CreateTemporaryFileException extends Exception
|
final class CreateTemporaryFileException extends Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param integer $code The user defined exception code.
|
* @param int $code The user defined exception code
|
||||||
* @param \Exception $previous The previous exception used for the exception chaining.
|
* @param \Exception $previous The previous exception used for the exception chaining
|
||||||
*/
|
*/
|
||||||
final public function __construct($code = 0, \Exception $previous = null)
|
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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -29,9 +29,9 @@ abstract class IOFactory
|
||||||
* @param PhpWord $phpWord
|
* @param PhpWord $phpWord
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return WriterInterface
|
|
||||||
*
|
|
||||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||||
|
*
|
||||||
|
* @return WriterInterface
|
||||||
*/
|
*/
|
||||||
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
|
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
|
||||||
{
|
{
|
||||||
|
|
@ -49,9 +49,9 @@ abstract class IOFactory
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return ReaderInterface
|
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
*
|
||||||
|
* @return ReaderInterface
|
||||||
*/
|
*/
|
||||||
public static function createReader($name = 'Word2007')
|
public static function createReader($name = 'Word2007')
|
||||||
{
|
{
|
||||||
|
|
@ -65,19 +65,19 @@ abstract class IOFactory
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
|
|
||||||
*
|
|
||||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
|
||||||
*/
|
*/
|
||||||
private static function createObject($type, $name, $phpWord = null)
|
private static function createObject($type, $name, $phpWord = null)
|
||||||
{
|
{
|
||||||
$class = "PhpOffice\\PhpWord\\{$type}\\{$name}";
|
$class = "PhpOffice\\PhpWord\\{$type}\\{$name}";
|
||||||
if (class_exists($class) && self::isConcreteClass($class)) {
|
if (class_exists($class) && self::isConcreteClass($class)) {
|
||||||
return new $class($phpWord);
|
return new $class($phpWord);
|
||||||
} else {
|
|
||||||
throw new Exception("\"{$name}\" is not a valid {$type}.");
|
|
||||||
}
|
}
|
||||||
|
throw new Exception("\"{$name}\" is not a valid {$type}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PhpWord from file
|
* Loads PhpWord from file
|
||||||
*
|
*
|
||||||
|
|
@ -89,8 +89,10 @@ abstract class IOFactory
|
||||||
{
|
{
|
||||||
/** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */
|
/** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */
|
||||||
$reader = self::createReader($readerName);
|
$reader = self::createReader($readerName);
|
||||||
|
|
||||||
return $reader->load($filename);
|
return $reader->load($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if it's a concrete class (not abstract nor interface)
|
* Check if it's a concrete class (not abstract nor interface)
|
||||||
*
|
*
|
||||||
|
|
@ -100,6 +102,7 @@ abstract class IOFactory
|
||||||
private static function isConcreteClass($class)
|
private static function isConcreteClass($class)
|
||||||
{
|
{
|
||||||
$reflection = new \ReflectionClass($class);
|
$reflection = new \ReflectionClass($class);
|
||||||
|
|
||||||
return !$reflection->isAbstract() && !$reflection->isInterface();
|
return !$reflection->isAbstract() && !$reflection->isInterface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -43,9 +43,9 @@ class Media
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||||
*
|
*
|
||||||
* @return integer
|
|
||||||
*
|
|
||||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function addElement($container, $mediaType, $source, Image $image = null)
|
public static function addElement($container, $mediaType, $source, Image $image = null)
|
||||||
{
|
{
|
||||||
|
|
@ -83,12 +83,10 @@ class Media
|
||||||
$image->setTarget($target);
|
$image->setTarget($target);
|
||||||
$image->setMediaIndex($mediaTypeCount);
|
$image->setMediaIndex($mediaTypeCount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Objects
|
// Objects
|
||||||
case 'object':
|
case 'object':
|
||||||
$target = "{$container}_oleObject{$mediaTypeCount}.bin";
|
$target = "{$container}_oleObject{$mediaTypeCount}.bin";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Links
|
// Links
|
||||||
case 'link':
|
case 'link':
|
||||||
$target = $source;
|
$target = $source;
|
||||||
|
|
@ -100,15 +98,17 @@ class Media
|
||||||
$mediaData['type'] = $mediaType;
|
$mediaData['type'] = $mediaType;
|
||||||
$mediaData['rID'] = $rId;
|
$mediaData['rID'] = $rId;
|
||||||
self::$elements[$container][$mediaId] = $mediaData;
|
self::$elements[$container][$mediaId] = $mediaData;
|
||||||
|
|
||||||
return $rId;
|
return $rId;
|
||||||
} else {
|
|
||||||
$mediaData = self::$elements[$container][$mediaId];
|
|
||||||
if (!is_null($image)) {
|
|
||||||
$image->setTarget($mediaData['target']);
|
|
||||||
$image->setMediaIndex($mediaData['mediaIndex']);
|
|
||||||
}
|
|
||||||
return $mediaData['rID'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$mediaData = self::$elements[$container][$mediaId];
|
||||||
|
if (!is_null($image)) {
|
||||||
|
$image->setTarget($mediaData['target']);
|
||||||
|
$image->setMediaIndex($mediaData['mediaIndex']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $mediaData['rID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -116,7 +116,7 @@ class Media
|
||||||
*
|
*
|
||||||
* @param string $container section|headerx|footerx|footnote|endnote
|
* @param string $container section|headerx|footerx|footnote|endnote
|
||||||
* @param string $mediaType image|object|link
|
* @param string $mediaType image|object|link
|
||||||
* @return integer
|
* @return int
|
||||||
* @since 0.10.0
|
* @since 0.10.0
|
||||||
*/
|
*/
|
||||||
public static function countElements($container, $mediaType = null)
|
public static function countElements($container, $mediaType = null)
|
||||||
|
|
@ -157,13 +157,15 @@ class Media
|
||||||
$elements[$key] = $val;
|
$elements[$key] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $elements;
|
return $elements;
|
||||||
} else {
|
|
||||||
if (!isset(self::$elements[$container])) {
|
|
||||||
return $elements;
|
|
||||||
}
|
|
||||||
return self::getElementsByType($container, $type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset(self::$elements[$container])) {
|
||||||
|
return $elements;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::getElementsByType($container, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -208,7 +210,7 @@ class Media
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
|
|
@ -224,7 +226,7 @@ class Media
|
||||||
*
|
*
|
||||||
* @param string $linkSrc
|
* @param string $linkSrc
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
|
|
@ -256,7 +258,7 @@ class Media
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
|
|
@ -270,11 +272,11 @@ class Media
|
||||||
*
|
*
|
||||||
* @deprecated 0.10.0
|
* @deprecated 0.10.0
|
||||||
*
|
*
|
||||||
* @param integer $headerCount
|
* @param int $headerCount
|
||||||
* @param string $src
|
* @param string $src
|
||||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
|
|
@ -290,7 +292,7 @@ class Media
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
|
|
@ -318,11 +320,11 @@ class Media
|
||||||
*
|
*
|
||||||
* @deprecated 0.10.0
|
* @deprecated 0.10.0
|
||||||
*
|
*
|
||||||
* @param integer $footerCount
|
* @param int $footerCount
|
||||||
* @param string $src
|
* @param string $src
|
||||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
|
|
@ -338,7 +340,7 @@ class Media
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Metadata;
|
||||||
* Compatibility setting class
|
* Compatibility setting class
|
||||||
*
|
*
|
||||||
* @since 0.12.0
|
* @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
|
class Compatibility
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +33,7 @@ class Compatibility
|
||||||
* 15 = 2013
|
* 15 = 2013
|
||||||
*
|
*
|
||||||
* @var int
|
* @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;
|
private $ooxmlVersion = 12;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -119,17 +119,17 @@ class DocInfo
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->creator = '';
|
$this->creator = '';
|
||||||
$this->lastModifiedBy = $this->creator;
|
$this->lastModifiedBy = $this->creator;
|
||||||
$this->created = time();
|
$this->created = time();
|
||||||
$this->modified = time();
|
$this->modified = time();
|
||||||
$this->title = '';
|
$this->title = '';
|
||||||
$this->subject = '';
|
$this->subject = '';
|
||||||
$this->description = '';
|
$this->description = '';
|
||||||
$this->keywords = '';
|
$this->keywords = '';
|
||||||
$this->category = '';
|
$this->category = '';
|
||||||
$this->company = '';
|
$this->company = '';
|
||||||
$this->manager = '';
|
$this->manager = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -399,7 +399,7 @@ class DocInfo
|
||||||
* Check if a Custom Property is defined
|
* Check if a Custom Property is defined
|
||||||
*
|
*
|
||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isCustomPropertySet($propertyName)
|
public function isCustomPropertySet($propertyName)
|
||||||
{
|
{
|
||||||
|
|
@ -416,9 +416,9 @@ class DocInfo
|
||||||
{
|
{
|
||||||
if ($this->isCustomPropertySet($propertyName)) {
|
if ($this->isCustomPropertySet($propertyName)) {
|
||||||
return $this->customProperties[$propertyName]['value'];
|
return $this->customProperties[$propertyName]['value'];
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -431,9 +431,9 @@ class DocInfo
|
||||||
{
|
{
|
||||||
if ($this->isCustomPropertySet($propertyName)) {
|
if ($this->isCustomPropertySet($propertyName)) {
|
||||||
return $this->customProperties[$propertyName]['type'];
|
return $this->customProperties[$propertyName]['type'];
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -456,7 +456,7 @@ class DocInfo
|
||||||
self::PROPERTY_TYPE_FLOAT,
|
self::PROPERTY_TYPE_FLOAT,
|
||||||
self::PROPERTY_TYPE_STRING,
|
self::PROPERTY_TYPE_STRING,
|
||||||
self::PROPERTY_TYPE_DATE,
|
self::PROPERTY_TYPE_DATE,
|
||||||
self::PROPERTY_TYPE_BOOLEAN
|
self::PROPERTY_TYPE_BOOLEAN,
|
||||||
);
|
);
|
||||||
if (($propertyType === null) || (!in_array($propertyType, $propertyTypes))) {
|
if (($propertyType === null) || (!in_array($propertyType, $propertyTypes))) {
|
||||||
if ($propertyValue === null) {
|
if ($propertyValue === null) {
|
||||||
|
|
@ -467,6 +467,8 @@ class DocInfo
|
||||||
$propertyType = self::PROPERTY_TYPE_INTEGER;
|
$propertyType = self::PROPERTY_TYPE_INTEGER;
|
||||||
} elseif (is_bool($propertyValue)) {
|
} elseif (is_bool($propertyValue)) {
|
||||||
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
|
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
|
||||||
|
} elseif ($propertyValue instanceof \DateTime) {
|
||||||
|
$propertyType = self::PROPERTY_TYPE_DATE;
|
||||||
} else {
|
} else {
|
||||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||||
}
|
}
|
||||||
|
|
@ -474,8 +476,9 @@ class DocInfo
|
||||||
|
|
||||||
$this->customProperties[$propertyName] = array(
|
$this->customProperties[$propertyName] = array(
|
||||||
'value' => $propertyValue,
|
'value' => $propertyValue,
|
||||||
'type' => $propertyType
|
'type' => $propertyType,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Metadata;
|
||||||
* Document protection class
|
* Document protection class
|
||||||
*
|
*
|
||||||
* @since 0.12.0
|
* @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
|
class Protection
|
||||||
{
|
{
|
||||||
|
|
@ -29,7 +29,7 @@ class Protection
|
||||||
* Editing restriction none|readOnly|comments|trackedChanges|forms
|
* Editing restriction none|readOnly|comments|trackedChanges|forms
|
||||||
*
|
*
|
||||||
* @var string
|
* @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;
|
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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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\Footnotes getFootnotes()
|
||||||
* @method Collection\Endnotes getEndnotes()
|
* @method Collection\Endnotes getEndnotes()
|
||||||
* @method Collection\Charts getCharts()
|
* @method Collection\Charts getCharts()
|
||||||
|
* @method Collection\Comments getComments()
|
||||||
* @method int addBookmark(Element\Bookmark $bookmark)
|
* @method int addBookmark(Element\Bookmark $bookmark)
|
||||||
* @method int addTitle(Element\Title $title)
|
* @method int addTitle(Element\Title $title)
|
||||||
* @method int addFootnote(Element\Footnote $footnote)
|
* @method int addFootnote(Element\Footnote $footnote)
|
||||||
* @method int addEndnote(Element\Endnote $endnote)
|
* @method int addEndnote(Element\Endnote $endnote)
|
||||||
* @method int addChart(Element\Chart $chart)
|
* @method int addChart(Element\Chart $chart)
|
||||||
|
* @method int addComment(Element\Comment $comment)
|
||||||
*
|
*
|
||||||
* @method Style\Paragraph addParagraphStyle(string $styleName, array $styles)
|
* @method Style\Paragraph addParagraphStyle(string $styleName, array $styles)
|
||||||
* @method Style\Font addFontStyle(string $styleName, mixed $fontStyle, mixed $paragraphStyle = null)
|
* @method Style\Font addFontStyle(string $styleName, mixed $fontStyle, mixed $paragraphStyle = null)
|
||||||
|
|
@ -84,14 +86,14 @@ class PhpWord
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Collection
|
// Collection
|
||||||
$collections = array('Bookmarks', 'Titles', 'Footnotes', 'Endnotes', 'Charts');
|
$collections = array('Bookmarks', 'Titles', 'Footnotes', 'Endnotes', 'Charts', 'Comments');
|
||||||
foreach ($collections as $collection) {
|
foreach ($collections as $collection) {
|
||||||
$class = 'PhpOffice\\PhpWord\\Collection\\' . $collection;
|
$class = 'PhpOffice\\PhpWord\\Collection\\' . $collection;
|
||||||
$this->collections[$collection] = new $class();
|
$this->collections[$collection] = new $class();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
$metadata = array('DocInfo', 'Protection', 'Compatibility');
|
$metadata = array('DocInfo', 'Settings', 'Compatibility');
|
||||||
foreach ($metadata as $meta) {
|
foreach ($metadata as $meta) {
|
||||||
$class = 'PhpOffice\\PhpWord\\Metadata\\' . $meta;
|
$class = 'PhpOffice\\PhpWord\\Metadata\\' . $meta;
|
||||||
$this->metadata[$meta] = new $class();
|
$this->metadata[$meta] = new $class();
|
||||||
|
|
@ -106,9 +108,9 @@ class PhpWord
|
||||||
* @param mixed $function
|
* @param mixed $function
|
||||||
* @param mixed $args
|
* @param mixed $args
|
||||||
*
|
*
|
||||||
* @return mixed
|
|
||||||
*
|
|
||||||
* @throws \BadMethodCallException
|
* @throws \BadMethodCallException
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function __call($function, $args)
|
public function __call($function, $args)
|
||||||
{
|
{
|
||||||
|
|
@ -118,7 +120,7 @@ class PhpWord
|
||||||
$addCollection = array();
|
$addCollection = array();
|
||||||
$addStyle = array();
|
$addStyle = array();
|
||||||
|
|
||||||
$collections = array('Bookmark', 'Title', 'Footnote', 'Endnote', 'Chart');
|
$collections = array('Bookmark', 'Title', 'Footnote', 'Endnote', 'Chart', 'Comment');
|
||||||
foreach ($collections as $collection) {
|
foreach ($collections as $collection) {
|
||||||
$getCollection[] = strtolower("get{$collection}s");
|
$getCollection[] = strtolower("get{$collection}s");
|
||||||
$addCollection[] = strtolower("add{$collection}");
|
$addCollection[] = strtolower("add{$collection}");
|
||||||
|
|
@ -170,10 +172,12 @@ class PhpWord
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Metadata\Protection
|
* @return \PhpOffice\PhpWord\Metadata\Protection
|
||||||
* @since 0.12.0
|
* @since 0.12.0
|
||||||
|
* @deprecated Get the Document protection from PhpWord->getSettings()->getDocumentProtection();
|
||||||
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function getProtection()
|
public function getProtection()
|
||||||
{
|
{
|
||||||
return $this->metadata['Protection'];
|
return $this->getSettings()->getDocumentProtection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -187,6 +191,17 @@ class PhpWord
|
||||||
return $this->metadata['Compatibility'];
|
return $this->metadata['Compatibility'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get compatibility
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Metadata\Settings
|
||||||
|
* @since 0.14.0
|
||||||
|
*/
|
||||||
|
public function getSettings()
|
||||||
|
{
|
||||||
|
return $this->metadata['Settings'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all sections
|
* Get all sections
|
||||||
*
|
*
|
||||||
|
|
@ -226,7 +241,6 @@ class PhpWord
|
||||||
* Set default font name.
|
* Set default font name.
|
||||||
*
|
*
|
||||||
* @param string $fontName
|
* @param string $fontName
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setDefaultFontName($fontName)
|
public function setDefaultFontName($fontName)
|
||||||
{
|
{
|
||||||
|
|
@ -236,7 +250,7 @@ class PhpWord
|
||||||
/**
|
/**
|
||||||
* Get default font size
|
* Get default font size
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getDefaultFontSize()
|
public function getDefaultFontSize()
|
||||||
{
|
{
|
||||||
|
|
@ -247,7 +261,6 @@ class PhpWord
|
||||||
* Set default font size.
|
* Set default font size.
|
||||||
*
|
*
|
||||||
* @param int $fontSize
|
* @param int $fontSize
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setDefaultFontSize($fontSize)
|
public function setDefaultFontSize($fontSize)
|
||||||
{
|
{
|
||||||
|
|
@ -270,21 +283,20 @@ class PhpWord
|
||||||
*
|
*
|
||||||
* @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead.
|
* @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead.
|
||||||
*
|
*
|
||||||
* @param string $filename Fully qualified filename.
|
* @param string $filename Fully qualified filename
|
||||||
*
|
|
||||||
* @return TemplateProcessor
|
|
||||||
*
|
*
|
||||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||||
*
|
*
|
||||||
|
* @return TemplateProcessor
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function loadTemplate($filename)
|
public function loadTemplate($filename)
|
||||||
{
|
{
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
return new TemplateProcessor($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);
|
$writer = IOFactory::createWriter($this, $format);
|
||||||
|
|
||||||
if ($download === true) {
|
if ($download === true) {
|
||||||
header("Content-Description: File Transfer");
|
header('Content-Description: File Transfer');
|
||||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||||
header('Content-Type: ' . $mime[$format]);
|
header('Content-Type: ' . $mime[$format]);
|
||||||
header('Content-Transfer-Encoding: binary');
|
header('Content-Transfer-Encoding: binary');
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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)
|
public function setReadDataOnly($value = true)
|
||||||
{
|
{
|
||||||
$this->readDataOnly = $value;
|
$this->readDataOnly = $value;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,21 +71,21 @@ abstract class AbstractReader implements ReaderInterface
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
*
|
*
|
||||||
* @return resource
|
|
||||||
*
|
|
||||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||||
|
*
|
||||||
|
* @return resource
|
||||||
*/
|
*/
|
||||||
protected function openFile($filename)
|
protected function openFile($filename)
|
||||||
{
|
{
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
if (!file_exists($filename) || !is_readable($filename)) {
|
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
|
// Open file
|
||||||
$this->fileHandle = fopen($filename, 'r');
|
$this->fileHandle = fopen($filename, 'r');
|
||||||
if ($this->fileHandle === false) {
|
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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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\Common\Drawing;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
use PhpOffice\PhpWord\Style;
|
|
||||||
use PhpOffice\PhpWord\Shared\OLERead;
|
use PhpOffice\PhpWord\Shared\OLERead;
|
||||||
|
use PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reader for Word97
|
* Reader for Word97
|
||||||
|
|
@ -164,13 +164,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$arrayCP[$inc] = self::getInt4d($data, $posMem);
|
$arrayCP[$inc] = self::getInt4d($data, $posMem);
|
||||||
$posMem += 4;
|
$posMem += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $arrayCP;
|
return $arrayCP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @see http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx
|
||||||
* @link http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx
|
* @see https://igor.io/2012/09/24/binary-parsing.html
|
||||||
* @link https://igor.io/2012/09/24/binary-parsing.html
|
* @param string $data
|
||||||
*/
|
*/
|
||||||
private function readFib($data)
|
private function readFib($data)
|
||||||
{
|
{
|
||||||
|
|
@ -1095,6 +1096,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$this->arrayFib['lcbColorSchemeMapping'] = self::getInt4d($data, $pos);
|
$this->arrayFib['lcbColorSchemeMapping'] = self::getInt4d($data, $pos);
|
||||||
$pos += 4;
|
$pos += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pos;
|
return $pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1107,11 +1109,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$this->readRecordPlcfSed();
|
$this->readRecordPlcfSed();
|
||||||
|
|
||||||
// reading paragraphs
|
// 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();
|
$this->readRecordPlcfBtePapx();
|
||||||
|
|
||||||
// reading character formattings
|
// 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->readRecordPlcfBteChpx();
|
||||||
|
|
||||||
$this->generatePhpWord();
|
$this->generatePhpWord();
|
||||||
|
|
@ -1119,7 +1121,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section and information about them
|
* 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()
|
private function readRecordPlcfSed()
|
||||||
{
|
{
|
||||||
|
|
@ -1133,7 +1135,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$posMem += 4;
|
$posMem += 4;
|
||||||
|
|
||||||
// PlcfSed : aSed
|
// 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);
|
$numSed = $this->getNumInLcb($this->arrayFib['lcbPlcfSed'], 12);
|
||||||
|
|
||||||
$aSed = array();
|
$aSed = array();
|
||||||
|
|
@ -1164,7 +1166,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the fonts that are used in the document
|
* 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()
|
private function readRecordSttbfFfn()
|
||||||
{
|
{
|
||||||
|
|
@ -1215,7 +1217,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
$this->arrayFonts[] = array(
|
$this->arrayFonts[] = array(
|
||||||
'main' => $xszFfn,
|
'main' => $xszFfn,
|
||||||
'alt' => $xszAlt,
|
'alt' => $xszAlt,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1223,7 +1225,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paragraph and information about them
|
* 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()
|
private function readRecordPlcfBtePapx()
|
||||||
{
|
{
|
||||||
|
|
@ -1247,7 +1249,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
$arrayRGB = array();
|
$arrayRGB = array();
|
||||||
for ($inc = 1; $inc <= $numRun; $inc++) {
|
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);
|
$arrayRGB[$inc] = self::getInt1d($this->dataWorkDocument, $offset);
|
||||||
$offset += 1;
|
$offset += 1;
|
||||||
// reserved
|
// reserved
|
||||||
|
|
@ -1303,7 +1305,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL);
|
print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL);
|
||||||
print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL);
|
print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL);
|
||||||
print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc));
|
print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc));
|
||||||
switch(dechex($sprm_Sgc)) {
|
switch (dechex($sprm_Sgc)) {
|
||||||
case 0x01:
|
case 0x01:
|
||||||
print_r(' (Paragraph property)');
|
print_r(' (Paragraph property)');
|
||||||
break;
|
break;
|
||||||
|
|
@ -1322,12 +1324,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
print_r(PHP_EOL);
|
print_r(PHP_EOL);
|
||||||
print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL);
|
print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL);
|
||||||
switch(dechex($sprm_Spra)) {
|
switch (dechex($sprm_Spra)) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
$operand = self::getInt1d($this->dataWorkDocument, $offset);
|
$operand = self::getInt1d($this->dataWorkDocument, $offset);
|
||||||
$offset += 1;
|
$offset += 1;
|
||||||
$cb -= 1;
|
$cb -= 1;
|
||||||
switch(dechex($operand)) {
|
switch (dechex($operand)) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
$operand = 'OFF';
|
$operand = 'OFF';
|
||||||
break;
|
break;
|
||||||
|
|
@ -1376,9 +1378,9 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
switch(dechex($sprm_Sgc)) {
|
switch (dechex($sprm_Sgc)) {
|
||||||
case 0x01: // Sprm is modifying a paragraph property.
|
case 0x01: // Sprm is modifying a paragraph property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
case 0x0A: // sprmPIlvl
|
case 0x0A: // sprmPIlvl
|
||||||
print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL);
|
print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
|
|
@ -1391,28 +1393,28 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x02: // Sprm is modifying a character property.
|
case 0x02: // Sprm is modifying a character property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
default:
|
default:
|
||||||
print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x03: // Sprm is modifying a picture property.
|
case 0x03: // Sprm is modifying a picture property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
default:
|
default:
|
||||||
print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x04: // Sprm is modifying a section property.
|
case 0x04: // Sprm is modifying a section property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
default:
|
default:
|
||||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x05: // Sprm is modifying a table property.
|
case 0x05: // Sprm is modifying a table property.
|
||||||
switch($sprm_IsPmd) {
|
switch ($sprm_IsPmd) {
|
||||||
default:
|
default:
|
||||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||||
break;
|
break;
|
||||||
|
|
@ -1426,7 +1428,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
} else {
|
} else {
|
||||||
if ($istd > 0) {
|
if ($istd > 0) {
|
||||||
// @todo : Determining Properties of a Paragraph Style
|
// @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
|
* 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()
|
private function readRecordPlcfBteChpx()
|
||||||
{
|
{
|
||||||
|
|
@ -1453,7 +1455,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$offset = $offsetBase;
|
$offset = $offsetBase;
|
||||||
|
|
||||||
// ChpxFkp
|
// 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);
|
$numRGFC = self::getInt1d($this->dataWorkDocument, $offset + 511);
|
||||||
$arrayRGFC = array();
|
$arrayRGFC = array();
|
||||||
for ($inc = 0; $inc <= $numRGFC; $inc++) {
|
for ($inc = 0; $inc <= $numRGFC; $inc++) {
|
||||||
|
|
@ -1471,12 +1473,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
foreach ($arrayRGB as $keyRGB => $rgb) {
|
foreach ($arrayRGB as $keyRGB => $rgb) {
|
||||||
$oStyle = new \stdClass();
|
$oStyle = new \stdClass();
|
||||||
$oStyle->pos_start = $start;
|
$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;
|
$start += $oStyle->pos_len;
|
||||||
|
|
||||||
if ($rgb > 0) {
|
if ($rgb > 0) {
|
||||||
// Chp Structure
|
// 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;
|
$posRGB = $offsetBase + $rgb * 2;
|
||||||
|
|
||||||
$cb = self::getInt1d($this->dataWorkDocument, $posRGB);
|
$cb = self::getInt1d($this->dataWorkDocument, $posRGB);
|
||||||
|
|
@ -1500,12 +1502,13 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$oSprm->f = ($sprm / 512) & 0x0001;
|
$oSprm->f = ($sprm / 512) & 0x0001;
|
||||||
$oSprm->sgc = ($sprm / 1024) & 0x0007;
|
$oSprm->sgc = ($sprm / 1024) & 0x0007;
|
||||||
$oSprm->spra = ($sprm / 8192);
|
$oSprm->spra = ($sprm / 8192);
|
||||||
|
|
||||||
return $oSprm;
|
return $oSprm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $data
|
* @param string $data
|
||||||
* @param integer $pos
|
* @param int $pos
|
||||||
* @param \stdClass $oSprm
|
* @param \stdClass $oSprm
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|
@ -1514,11 +1517,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$length = 0;
|
$length = 0;
|
||||||
$operand = null;
|
$operand = null;
|
||||||
|
|
||||||
switch(dechex($oSprm->spra)) {
|
switch (dechex($oSprm->spra)) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
$operand = self::getInt1d($data, $pos);
|
$operand = self::getInt1d($data, $pos);
|
||||||
$length = 1;
|
$length = 1;
|
||||||
switch(dechex($operand)) {
|
switch (dechex($operand)) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
$operand = false;
|
$operand = false;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1558,16 +1561,17 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'length' => $length,
|
'length' => $length,
|
||||||
'operand' => $operand,
|
'operand' => $operand,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data integer
|
* @param $data int
|
||||||
* @param $pos integer
|
* @param $pos int
|
||||||
|
* @param $cbNum int
|
||||||
* @return \stdClass
|
* @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)
|
private function readPrl($data, $pos, $cbNum)
|
||||||
{
|
{
|
||||||
|
|
@ -1593,7 +1597,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$cbNum -= $arrayReturn['length'];
|
$cbNum -= $arrayReturn['length'];
|
||||||
$operand = $arrayReturn['operand'];
|
$operand = $arrayReturn['operand'];
|
||||||
|
|
||||||
switch(dechex($oSprm->sgc)) {
|
switch (dechex($oSprm->sgc)) {
|
||||||
// Paragraph property
|
// Paragraph property
|
||||||
case 0x01:
|
case 0x01:
|
||||||
break;
|
break;
|
||||||
|
|
@ -1602,7 +1606,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
if (!isset($oStylePrl->styleFont)) {
|
if (!isset($oStylePrl->styleFont)) {
|
||||||
$oStylePrl->styleFont = array();
|
$oStylePrl->styleFont = array();
|
||||||
}
|
}
|
||||||
switch($oSprm->isPmd) {
|
switch ($oSprm->isPmd) {
|
||||||
// sprmCFRMarkIns
|
// sprmCFRMarkIns
|
||||||
case 0x01:
|
case 0x01:
|
||||||
break;
|
break;
|
||||||
|
|
@ -1620,7 +1624,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
// sprmCFItalic
|
// sprmCFItalic
|
||||||
case 0x36:
|
case 0x36:
|
||||||
// By default, text is not italicized.
|
// By default, text is not italicized.
|
||||||
switch($operand) {
|
switch ($operand) {
|
||||||
case false:
|
case false:
|
||||||
case true:
|
case true:
|
||||||
$oStylePrl->styleFont['italic'] = $operand;
|
$oStylePrl->styleFont['italic'] = $operand;
|
||||||
|
|
@ -1640,7 +1644,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
// sprmCFBold
|
// sprmCFBold
|
||||||
case 0x35:
|
case 0x35:
|
||||||
// By default, text is not bold.
|
// By default, text is not bold.
|
||||||
switch($operand) {
|
switch ($operand) {
|
||||||
case false:
|
case false:
|
||||||
case true:
|
case true:
|
||||||
$oStylePrl->styleFont['bold'] = $operand;
|
$oStylePrl->styleFont['bold'] = $operand;
|
||||||
|
|
@ -1656,7 +1660,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
// sprmCFStrike
|
// sprmCFStrike
|
||||||
case 0x37:
|
case 0x37:
|
||||||
// By default, text is not struck through.
|
// By default, text is not struck through.
|
||||||
switch($operand) {
|
switch ($operand) {
|
||||||
case false:
|
case false:
|
||||||
case true:
|
case true:
|
||||||
$oStylePrl->styleFont['strikethrough'] = $operand;
|
$oStylePrl->styleFont['strikethrough'] = $operand;
|
||||||
|
|
@ -1671,7 +1675,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
break;
|
break;
|
||||||
// sprmCKul
|
// sprmCKul
|
||||||
case 0x3E:
|
case 0x3E:
|
||||||
switch(dechex($operand)) {
|
switch (dechex($operand)) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
|
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1694,7 +1698,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASH;
|
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASH;
|
||||||
break;
|
break;
|
||||||
case 0x09:
|
case 0x09:
|
||||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTHASH;
|
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDASH;
|
||||||
break;
|
break;
|
||||||
case 0x0A:
|
case 0x0A:
|
||||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASH;
|
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASH;
|
||||||
|
|
@ -1709,7 +1713,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASHHEAVY;
|
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASHHEAVY;
|
||||||
break;
|
break;
|
||||||
case 0x19:
|
case 0x19:
|
||||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTHASHHEAVY;
|
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDASHHEAVY;
|
||||||
break;
|
break;
|
||||||
case 0x1A:
|
case 0x1A:
|
||||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASHHEAVY;
|
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASHHEAVY;
|
||||||
|
|
@ -1732,9 +1736,9 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// sprmCIco
|
// 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:
|
case 0x42:
|
||||||
switch(dechex($operand)) {
|
switch (dechex($operand)) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
case 0x01:
|
case 0x01:
|
||||||
$oStylePrl->styleFont['color'] = '000000';
|
$oStylePrl->styleFont['color'] = '000000';
|
||||||
|
|
@ -1787,7 +1791,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
break;
|
break;
|
||||||
// sprmCHps
|
// sprmCHps
|
||||||
case 0x43:
|
case 0x43:
|
||||||
$oStylePrl->styleFont['size'] = dechex($operand/2);
|
$oStylePrl->styleFont['size'] = dechex($operand / 2);
|
||||||
break;
|
break;
|
||||||
// sprmCIss
|
// sprmCIss
|
||||||
case 0x48:
|
case 0x48:
|
||||||
|
|
@ -1838,7 +1842,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
case 0x61:
|
case 0x61:
|
||||||
break;
|
break;
|
||||||
// sprmCShd80
|
// 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:
|
case 0x66:
|
||||||
// $operand = self::getInt2d($data, $pos);
|
// $operand = self::getInt2d($data, $pos);
|
||||||
$pos += 2;
|
$pos += 2;
|
||||||
|
|
@ -1848,7 +1852,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
// $icoFore = ($operand >> 11) && bindec('11111');
|
// $icoFore = ($operand >> 11) && bindec('11111');
|
||||||
break;
|
break;
|
||||||
// sprmCCv
|
// 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:
|
case 0x70:
|
||||||
$red = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
|
$red = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
|
||||||
$pos += 1;
|
$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);
|
$blue = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
|
||||||
$pos += 1;
|
$pos += 1;
|
||||||
$pos += 1;
|
$pos += 1;
|
||||||
$oStylePrl->styleFont['color'] = $red.$green.$blue;
|
$oStylePrl->styleFont['color'] = $red . $green . $blue;
|
||||||
$cbNum -= 4;
|
$cbNum -= 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -1873,7 +1877,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
if (!isset($oStylePrl->styleSection)) {
|
if (!isset($oStylePrl->styleSection)) {
|
||||||
$oStylePrl->styleSection = array();
|
$oStylePrl->styleSection = array();
|
||||||
}
|
}
|
||||||
switch($oSprm->isPmd) {
|
switch ($oSprm->isPmd) {
|
||||||
// sprmSNfcPgn
|
// sprmSNfcPgn
|
||||||
case 0x0E:
|
case 0x0E:
|
||||||
// numbering format used for page numbers
|
// numbering format used for page numbers
|
||||||
|
|
@ -1925,7 +1929,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
default:
|
default:
|
||||||
// print_r('@todo Section : 0x'.dechex($oSprm->isPmd));
|
// print_r('@todo Section : 0x'.dechex($oSprm->isPmd));
|
||||||
// print_r(PHP_EOL);
|
// print_r(PHP_EOL);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Table property
|
// Table property
|
||||||
|
|
@ -1951,7 +1954,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
// HFD > clsid
|
// HFD > clsid
|
||||||
$sprmCPicLocation += 16;
|
$sprmCPicLocation += 16;
|
||||||
// HFD > hyperlink
|
// 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);
|
$streamVersion = self::getInt4d($this->dataData, $sprmCPicLocation);
|
||||||
$sprmCPicLocation += 4;
|
$sprmCPicLocation += 4;
|
||||||
$data = self::getInt4d($this->dataData, $sprmCPicLocation);
|
$data = self::getInt4d($this->dataData, $sprmCPicLocation);
|
||||||
|
|
@ -2019,8 +2022,8 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}*/
|
}*/
|
||||||
} else {
|
} else {
|
||||||
// Pictures
|
// Pictures
|
||||||
//@link : http://msdn.microsoft.com/en-us/library/dd925458%28v=office.12%29.aspx
|
//@see : 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/dd926136%28v=office.12%29.aspx
|
||||||
// PICF : lcb
|
// PICF : lcb
|
||||||
$sprmCPicLocation += 4;
|
$sprmCPicLocation += 4;
|
||||||
// PICF : cbHeader
|
// PICF : cbHeader
|
||||||
|
|
@ -2107,13 +2110,13 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$sprmCPicLocation += $shapeRH['recLen'];
|
$sprmCPicLocation += $shapeRH['recLen'];
|
||||||
}
|
}
|
||||||
// picture : rgfb
|
// 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);
|
$fileBlockRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
|
||||||
while ($fileBlockRH['recType'] == 0xF007 || ($fileBlockRH['recType'] >= 0xF018 && $fileBlockRH['recType'] <= 0xF117)) {
|
while ($fileBlockRH['recType'] == 0xF007 || ($fileBlockRH['recType'] >= 0xF018 && $fileBlockRH['recType'] <= 0xF117)) {
|
||||||
$sprmCPicLocation += 8;
|
$sprmCPicLocation += 8;
|
||||||
switch ($fileBlockRH['recType']) {
|
switch ($fileBlockRH['recType']) {
|
||||||
// OfficeArtFBSE
|
// 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:
|
case 0xF007:
|
||||||
// btWin32
|
// btWin32
|
||||||
$sprmCPicLocation += 1;
|
$sprmCPicLocation += 1;
|
||||||
|
|
@ -2148,7 +2151,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// embeddedBlip
|
// 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);
|
$embeddedBlipRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
|
||||||
switch ($embeddedBlipRH['recType']) {
|
switch ($embeddedBlipRH['recType']) {
|
||||||
case self::OFFICEARTBLIPJPG:
|
case self::OFFICEARTBLIPJPG:
|
||||||
|
|
@ -2193,13 +2196,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$oStylePrl->length = $pos - $posStart;
|
$oStylePrl->length = $pos - $posStart;
|
||||||
|
|
||||||
return $oStylePrl;
|
return $oStylePrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a record header
|
* Read a record header
|
||||||
* @param string $stream
|
* @param string $stream
|
||||||
* @param integer $pos
|
* @param int $pos
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function loadRecordHeader($stream, $pos)
|
private function loadRecordHeader($stream, $pos)
|
||||||
|
|
@ -2207,11 +2211,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
$rec = self::getInt2d($stream, $pos);
|
$rec = self::getInt2d($stream, $pos);
|
||||||
$recType = self::getInt2d($stream, $pos + 2);
|
$recType = self::getInt2d($stream, $pos + 2);
|
||||||
$recLen = self::getInt4d($stream, $pos + 4);
|
$recLen = self::getInt4d($stream, $pos + 4);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'recVer' => ($rec >> 0) & bindec('1111'),
|
'recVer' => ($rec >> 0) & bindec('1111'),
|
||||||
'recInstance' => ($rec >> 4) & bindec('111111111111'),
|
'recInstance' => ($rec >> 4) & bindec('111111111111'),
|
||||||
'recType' => $recType,
|
'recType' => $recType,
|
||||||
'recLen' => $recLen,
|
'recLen' => $recLen,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2274,7 +2279,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
||||||
}
|
}
|
||||||
if (ord($sText[0]) == 1) {
|
if (ord($sText[0]) == 1) {
|
||||||
if (isset($oCharacters->style->image)) {
|
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']);
|
file_put_contents($fileImage, $oCharacters->style->image['data']);
|
||||||
$oSection->addImage($fileImage, array('width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height']));
|
$oSection->addImage($fileImage, array('width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height']));
|
||||||
// print_r('>addImage<'.$fileImage.'>'.EOL);
|
// 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)
|
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)
|
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 {
|
} else {
|
||||||
$ord24 = ($or24 & 127) << 24;
|
$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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ class ODText extends AbstractReader implements ReaderInterface
|
||||||
|
|
||||||
$readerParts = array(
|
$readerParts = array(
|
||||||
'content.xml' => 'Content',
|
'content.xml' => 'Content',
|
||||||
'meta.xml' => 'Meta',
|
'meta.xml' => 'Meta',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($readerParts as $xmlFile => $partName) {
|
foreach ($readerParts as $xmlFile => $partName) {
|
||||||
|
|
@ -58,7 +58,6 @@ class ODText extends AbstractReader implements ReaderInterface
|
||||||
* @param string $partName
|
* @param string $partName
|
||||||
* @param string $docFile
|
* @param string $docFile
|
||||||
* @param string $xmlFile
|
* @param string $xmlFile
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private function readPart(PhpWord $phpWord, $relationships, $partName, $docFile, $xmlFile)
|
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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @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
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -31,7 +31,6 @@ class Content extends AbstractPart
|
||||||
* Read content.xml.
|
* Read content.xml.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function read(PhpWord $phpWord)
|
public function read(PhpWord $phpWord)
|
||||||
{
|
{
|
||||||
|
|
@ -44,16 +43,13 @@ class Content extends AbstractPart
|
||||||
foreach ($nodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
// $styleName = $xmlReader->getAttribute('text:style-name', $node);
|
// $styleName = $xmlReader->getAttribute('text:style-name', $node);
|
||||||
switch ($node->nodeName) {
|
switch ($node->nodeName) {
|
||||||
|
|
||||||
case 'text:h': // Heading
|
case 'text:h': // Heading
|
||||||
$depth = $xmlReader->getAttribute('text:outline-level', $node);
|
$depth = $xmlReader->getAttribute('text:outline-level', $node);
|
||||||
$section->addTitle($node->nodeValue, $depth);
|
$section->addTitle($node->nodeValue, $depth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'text:p': // Paragraph
|
case 'text:p': // Paragraph
|
||||||
$section->addText($node->nodeValue);
|
$section->addText($node->nodeValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'text:list': // List
|
case 'text:list': // List
|
||||||
$listItems = $xmlReader->getElements('text:list-item/text:p', $node);
|
$listItems = $xmlReader->getElements('text:list-item/text:p', $node);
|
||||||
foreach ($listItems as $listItem) {
|
foreach ($listItems as $listItem) {
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2016 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -31,7 +31,6 @@ class Meta extends AbstractPart
|
||||||
* Read meta.xml.
|
* Read meta.xml.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||||
* @return void
|
|
||||||
* @todo Process property type
|
* @todo Process property type
|
||||||
*/
|
*/
|
||||||
public function read(PhpWord $phpWord)
|
public function read(PhpWord $phpWord)
|
||||||
|
|
@ -70,9 +69,8 @@ class Meta extends AbstractPart
|
||||||
if (in_array($property, array('Category', 'Company', 'Manager'))) {
|
if (in_array($property, array('Category', 'Company', 'Manager'))) {
|
||||||
$method = "set{$property}";
|
$method = "set{$property}";
|
||||||
$docProps->$method($propertyNode->nodeValue);
|
$docProps->$method($propertyNode->nodeValue);
|
||||||
|
|
||||||
// Set other custom properties
|
|
||||||
} else {
|
} else {
|
||||||
|
// Set other custom properties
|
||||||
$docProps->setCustomProperty($property, $propertyNode->nodeValue);
|
$docProps->setCustomProperty($property, $propertyNode->nodeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue