Compare commits

..

18 Commits

Author SHA1 Message Date
troosan
2111659914 revert phpunit version 2021-02-22 08:16:46 +01:00
troosan
c28cbd7f08 Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into
develop_v1.0

# Conflicts:
#	.travis.yml
#	composer.json
2021-02-21 23:02:55 +01:00
DE TROOSTEMBERGH Antoine
087628de5f update to phpunit 7.5 2019-12-14 22:23:57 +01:00
DE TROOSTEMBERGH Antoine
6d501332f3 update 7.4 in travis build 2019-12-14 22:23:36 +01:00
DE TROOSTEMBERGH Antoine
bf52f2d058 php 7.4 not yet available 2019-12-09 22:39:01 +01:00
DE TROOSTEMBERGH Antoine
711fcdeef7 still allow php 7.4 to fail because of dompdf 2019-12-09 21:38:04 +01:00
DE TROOSTEMBERGH Antoine
590a8b7ef2 build with php nightly 2019-12-09 21:14:37 +01:00
DE TROOSTEMBERGH Antoine
9914f3d295 Merge branch 'develop' into develop_v1.0 2019-12-08 21:12:22 +01:00
troosan
847520f380 Merge branch 'master' into develop_v1.0
Conflicts:
	.travis.yml
	composer.json
2019-10-01 23:55:29 +02:00
troosan
b54f39169e
Merge pull request #1545 from troosan/stop_building_for_php5.3
Update minimum req, stop running travis builds for php 5.3, 5.4, 5.5 and 7.0
2019-01-02 14:25:06 +01:00
troosan
8d92409bfe
Merge pull request #1032 from kaystrobach/patch-1
[BUGFIX] allow to load unclean html without exception
2019-01-02 14:23:56 +01:00
troosan
06a92710f6
remove whitespaces 2019-01-02 14:06:32 +01:00
troosan
5bc9250ccc
Fix unit tests 2019-01-02 09:28:51 +01:00
troosan
2a8a32e704 add alias for 1.0-dev branch 2019-01-02 09:06:10 +01:00
troosan
2968370bd1 update dependencies to minimum php 5.6 dependencies 2018-12-31 16:18:54 +01:00
troosan
6e00210f9a stop building for 5.3, 5.4, 5.5 and 7.0 2018-12-30 15:11:01 +01:00
troosan
b54200e5d8
Merge branch 'develop' into patch-1 2018-12-03 01:07:08 +01:00
Kay Strobach
33f1619d0f [BUGFIX] allow to load unclean html without exception
fixes #754
2017-03-29 10:08:11 +02:00
563 changed files with 17249 additions and 18105 deletions

3
.gitattributes vendored
View File

@ -1,6 +1,6 @@
# build config # build config
/.scrutinizer.yml export-ignore /.scrutinizer.yml export-ignore
/.github export-ignore /.travis.yml export-ignore
/php_cs.dist export-ignore /php_cs.dist export-ignore
/phpmd.xml.dist export-ignore /phpmd.xml.dist export-ignore
/phpstan.neon export-ignore /phpstan.neon export-ignore
@ -10,6 +10,7 @@
# git files # git files
/.gitignore export-ignore /.gitignore export-ignore
/.gitattributes export-ignore /.gitattributes export-ignore
/.github export-ignore
# project directories # project directories
/build export-ignore /build export-ignore

View File

@ -9,6 +9,6 @@ labels: WontFix
Documentation is available on [Read the Docs](https://phpword.readthedocs.io/en/latest/). Documentation is available on [Read the Docs](https://phpword.readthedocs.io/en/latest/).
Sample code is in the [`/samples/` directory](https://github.com/PHPOffice/PHPWord/tree/master/samples). Sample code is in the [`/samples/` directory](https://github.com/PHPOffice/PHPWord/tree/develop/samples).
Usage questions belong on [Stack Overflow](https://stackoverflow.com/questions/tagged/phpword). Usage questions belong on [Stack Overflow](https://stackoverflow.com/questions/tagged/phpword).

View File

@ -1,8 +0,0 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: monthly
time: "11:00"
open-pull-requests-limit: 10

View File

@ -8,18 +8,16 @@ jobs:
strategy: strategy:
matrix: matrix:
php-version: php-version:
- "7.1" - '7.2'
- "7.2"
- "7.3" - "7.3"
- "7.4" - "7.4"
- "8.0" - "8.0"
- "8.1"
name: PHP ${{ matrix.php-version }} name: PHP ${{ matrix.php-version }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
@ -33,14 +31,36 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)" run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v2
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Update PHPUnit version for PHP 8
id: composer-lock
if: "startsWith(matrix.php-version, '8.')"
run: |
rm -f composer.lock
echo "::set-output name=flags::--ignore-platform-reqs"
composer remove phpunit/phpunit --dev --no-update --no-interaction
composer require phpunit/phpunit ^8.0 --dev --no-update
- name: Install dependencies - name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader run: composer update --no-progress --prefer-dist --optimize-autoloader ${{ steps.composer-lock.outputs.flags }}
- name: Update code to make PHPUnit 8 compatible
if: "startsWith(matrix.php-version, '8.')"
run: |
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function setUpBeforeClass()$/function setUpBeforeClass(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function tearDownAfterClass()$/function tearDownAfterClass(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function setUp()$/function setUp(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function tearDown()$/function tearDown(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/->assertContains(/->assertStringContainsString(/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/->assertNotContains(/->assertStringNotContainsString(/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e "s/->assertInternalType('array', /->assertIsArray(/" {} \;
sed -i "s/\$this->addWarning('The @expectedException,/\/\/\$this->addWarning('The @expectedException,/" ./vendor/phpunit/phpunit/src/Framework/TestCase.php
sed -i "s/self::createWarning('The optional \$delta/\/\/self::createWarning('The optional \$delta/" ./vendor/phpunit/phpunit/src/Framework/Assert.php
- name: Setup problem matchers for PHP - name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
@ -52,13 +72,13 @@ jobs:
uses: mheap/phpunit-matcher-action@v1 uses: mheap/phpunit-matcher-action@v1
- name: Test with PHPUnit - name: Test with PHPUnit
run: ./vendor/bin/phpunit --no-coverage run: ./vendor/bin/phpunit --teamcity --no-coverage -c ./
php-cs-fixer: php-cs-fixer:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
@ -73,7 +93,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)" run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v2
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -83,27 +103,58 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Code style with PHP-CS-Fixer - name: Code style with PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff run: ./vendor/bin/php-cs-fixer fix --format=checkstyle | cs2pr
coverage: phpcs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: 7.4 php-version: 7.4
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: pcov coverage: none
tools: cs2pr
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)" run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Code style with PHP_CodeSniffer
run: ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip --report=checkstyle | cs2pr
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: xdebug
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2

View File

@ -1,8 +1,8 @@
user=PHPOffice user=PHPOffice
project=PHPWord project=PHPWord
since-tag=0.18.1 since-tag=0.17.0
future-release=0.18.2 future-release=0.18.0
issues=false issues=false
pulls=true pulls=true

1
.gitignore vendored
View File

@ -21,4 +21,3 @@ phpword.ini
/.project /.project
/nbproject /nbproject
/.php_cs.cache /.php_cs.cache
/.phpunit.result.cache

View File

@ -1,227 +0,0 @@
<?php
$finder = PhpCsFixer\Finder::create()
->notName('pclzip.lib.php')
->notName('OLERead.php')
->in('samples')
->in('src')
->in('tests');
$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setFinder($finder)
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__))
->setRules([
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'backtick_to_shell_exec' => true,
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one']], // const are often grouped with other related const
'class_definition' => false,
'class_keyword_remove' => false, // ::class keyword gives us better support in IDE
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'combine_nested_dirname' => true,
'comment_to_phpdoc' => false, // interferes with annotations
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'constant_case' => true,
'date_time_immutable' => false, // Break our unit tests
'declare_equal_normalize' => true,
'declare_strict_types' => false, // Too early to adopt strict types
'dir_constant' => true,
'doctrine_annotation_array_assignment' => true,
'doctrine_annotation_braces' => true,
'doctrine_annotation_indentation' => true,
'doctrine_annotation_spaces' => true,
'elseif' => true,
'encoding' => true,
'ereg_to_preg' => true,
'escape_implicit_backslashes' => true,
'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
'explicit_string_variable' => false, // I feel it makes the code actually harder to read
'final_class' => false, // We need non-final classes
'final_internal_class' => true,
'final_public_method_for_abstract_class' => false, // We need non-final methods
'fopen_flag_order' => true,
'fopen_flags' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => true,
'function_declaration' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => ['annotations' => ['access', 'category', 'copyright', 'throws']],
'global_namespace_import' => true,
'header_comment' => false, // We don't use common header in all our files
'heredoc_indentation' => false, // Requires PHP >= 7.3
'heredoc_to_nowdoc' => false, // Not sure about this one
'implode_call' => true,
'include' => true,
'increment_style' => true,
'indentation_type' => true,
'is_null' => true,
'line_ending' => true,
'linebreak_after_opening_tag' => true,
'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'lowercase_cast' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'mb_str_functions' => false, // No, too dangerous to change that
'method_argument_space' => true,
'method_chaining_indentation' => true,
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => false, // Micro optimization that look messy
'native_function_casing' => true,
'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it
'native_function_type_declaration_casing' => true,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_alternative_syntax' => true,
'no_binary_string' => 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_break_comment' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'echo_tag_syntax' => ['format' => 'long'],
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => false, // Might be risky on a huge code base
'no_superfluous_phpdoc_tags' => ['allow_mixed' => 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_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_cast' => true,
'no_unset_on_property' => 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,
'non_printable_character' => true,
'normalize_index_brace' => true,
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
'not_operator_with_successor_space' => false, // idem
'nullable_type_declaration_for_default_null_value' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => false, // We prefer to keep some freedom
'ordered_imports' => true,
'ordered_interfaces' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'php_unit_dedicate_assert_internal_type' => true,
'php_unit_expectation' => true,
'php_unit_fqcn_annotation' => true,
'php_unit_internal_class' => false, // Because tests are excluded from package
'php_unit_method_casing' => true,
'php_unit_mock' => true,
'php_unit_mock_short_will_return' => true,
'php_unit_namespaced' => true,
'php_unit_no_expectation_annotation' => true,
'phpdoc_order_by_value' => ['annotations' => ['covers']],
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_size_class' => false, // That seems extra work to maintain for little benefits
'php_unit_strict' => false, // We sometime actually need assertEquals
'php_unit_test_annotation' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage
'phpdoc_add_missing_param_annotation' => false, // Don't add things that bring no value
'phpdoc_align' => false, // Waste of time
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
//'phpdoc_inline_tag' => true,
'phpdoc_line_span' => false, // Unfortunately our old comments turn even uglier with this
'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' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => false, // interferes with annotations
'phpdoc_to_param_type' => false, // Because experimental, but interesting for one shot use
'phpdoc_to_return_type' => false, // idem
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => true,
'protected_to_private' => true,
'psr_autoloading' => true,
'random_api_migration' => true,
'return_assignment' => false, // Sometimes useful for clarity or debug
'return_type_declaration' => true,
'self_accessor' => true,
'self_static_accessor' => true,
'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simple_to_complex_string_variable' => false, // Would differ from TypeScript without obvious advantages
'simplified_null_return' => false, // Even if technically correct we prefer to be explicit
'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_line_comment_style' => true,
'single_line_throw' => false, // I don't see any reason for having a special case for Exception
'single_quote' => true,
'single_trait_insert_per_statement' => true,
'space_after_semicolon' => true,
'standardize_increment' => true,
'standardize_not_equals' => true,
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
'strict_comparison' => false, // No, too dangerous to change that
'strict_param' => false, // No, too dangerous to change that
'string_line_ending' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => ['elements' => ['property', 'method']], // not const
'void_return' => true,
'whitespace_after_comma_in_array' => true,
'yoda_style' => false,
]);
return $config;

146
.php_cs.dist Normal file
View File

@ -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,
));

64
.travis.yml Normal file
View File

@ -0,0 +1,64 @@
language: php
dist: xenial
php:
- 7.1
- 7.2
- 7.3
- 7.4
- nightly
matrix:
include:
- php: 7.2
env: COVERAGE=1
- php: nightly
env: DEPENDENCIES="--ignore-platform-reqs"
exclude:
- php: 7.2
- php: nightly
allow_failures:
- php: 7.4 #needs an update on dompdf
- php: nightly
cache:
directories:
- $HOME/.composer/cache
- .php-cs.cache
env:
global:
- secure: "Sq+6bVtnPsu0mWX8DWQ+9bGAjxMcGorksUiHc4YIXEJsuDfVmVlH8tTD547IeCjDAx9MxXerZ2Z4HSjxTB70VEnJPvZMHI/EZn4Ny31YLHEthdZbV5Gd1h0TGp8VOzPKGShvGrtGBX6MvMfgpK4zuieVWbSfdKeecm8ZNLMpUd4="
before_install:
## Packages
- sudo rm -f /etc/apt/sources.list.d/mongodb.list # Makes apt crash on Precise, and we don't need MongoDB
- sudo apt-get update -qq
- sudo apt-get install -y graphviz
before_script:
## Deactivate xdebug if we don't do code coverage
- if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini || echo "xdebug not available" ; fi
## Composer
- composer self-update
- travis_wait composer install --prefer-source $(if [ -n "$DEPENDENCIES" ]; then echo $DEPENDENCIES; fi)
## PHPDocumentor
##- mkdir -p build/docs
- mkdir -p build/coverage
script:
## PHP_CodeSniffer
- 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
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ; fi
## PHPUnit
- ./vendor/bin/phpunit -c ./ $(if [ -n "$COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi)
## PHPDocumentor
##- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" ; fi
after_success:
## Coveralls
- if [ -n "$COVERAGE" ]; then travis_retry php vendor/bin/php-coveralls -v ; fi

View File

@ -2,146 +2,6 @@
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/).
## [1.0.0](https://github.com/PHPOffice/PHPWord/tree/1.0.0) (2022-11-15)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.18.3...1.0.0)
### BREAKING CHANGE
Most deprecated things were dropped. See details in
https://github.com/PHPOffice/PHPWord/commit/b9f1151bc6f90c276153c3c9dca10a5fc7f355fb.
#### Dropped classes:
- `PhpOffice\PhpWord\Template`
#### Dropped constants:
- `PhpOffice\PhpWord\Style\Font::UNDERLINE_DOTHASH`
- `PhpOffice\PhpWord\Style\Font::UNDERLINE_DOTHASHHEAVY`
- `PhpOffice\PhpWord\Style\Cell::VALIGN_TOP`
- `PhpOffice\PhpWord\Style\Cell::VALIGN_CENTER`
- `PhpOffice\PhpWord\Style\Cell::VALIGN_BOTTOM`
- `PhpOffice\PhpWord\Style\Cell::VALIGN_BOTH`
- `PhpOffice\PhpWord\Style\TOC::TABLEADER_DOT`
- `PhpOffice\PhpWord\Style\TOC::TABLEADER_UNDERSCORE`
- `PhpOffice\PhpWord\Style\TOC::TABLEADER_LINE`
- `PhpOffice\PhpWord\Style\TOC::TABLEADER_NONE`
- `PhpOffice\PhpWord\Style\Table::WIDTH_AUTO`
- `PhpOffice\PhpWord\Style\Table::WIDTH_PERCENT`
- `PhpOffice\PhpWord\Style\Table::WIDTH_TWIP`
- `PhpOffice\PhpWord\PhpWord::DEFAULT_FONT_NAME`
- `PhpOffice\PhpWord\PhpWord::DEFAULT_FONT_SIZE`
- `PhpOffice\PhpWord\PhpWord::DEFAULT_FONT_COLOR`
- `PhpOffice\PhpWord\PhpWord::DEFAULT_FONT_CONTENT_TYPE`
-
#### Dropped methods:
- `PhpOffice\PhpWord\Ekement\AbstractContainer::createTextRun()`
- `PhpOffice\PhpWord\Ekement\AbstractContainer::createFootnote()`
- `PhpOffice\PhpWord\Ekement\Footnote::getReferenceId()`
- `PhpOffice\PhpWord\Ekement\Footnote::setReferenceId()`
- `PhpOffice\PhpWord\Ekement\Image::getIsWatermark()`
- `PhpOffice\PhpWord\Ekement\Image::getIsMemImage()`
- `PhpOffice\PhpWord\Ekement\Link::getTarget()`
- `PhpOffice\PhpWord\Ekement\Link::getLinkSrc()`
- `PhpOffice\PhpWord\Ekement\Link::getLinkName()`
- `PhpOffice\PhpWord\Ekement\OLEObject::getObjectId()`
- `PhpOffice\PhpWord\Ekement\OLEObject::setObjectId()`
- `PhpOffice\PhpWord\Ekement\Section::getFootnotePropoperties()`
- `PhpOffice\PhpWord\Ekement\Section::setSettings()`
- `PhpOffice\PhpWord\Ekement\Section::getSettings()`
- `PhpOffice\PhpWord\Ekement\Section::createHeader()`
- `PhpOffice\PhpWord\Ekement\Section::createFooter()`
- `PhpOffice\PhpWord\Ekement\Section::getFooter()`
- `PhpOffice\PhpWord\Media::addSectionMediaElement()`
- `PhpOffice\PhpWord\Media::addSectionLinkElement()`
- `PhpOffice\PhpWord\Media::getSectionMediaElements()`
- `PhpOffice\PhpWord\Media::countSectionMediaElements()`
- `PhpOffice\PhpWord\Media::addHeaderMediaElement()`
- `PhpOffice\PhpWord\Media::countHeaderMediaElements()`
- `PhpOffice\PhpWord\Media::getHeaderMediaElements()`
- `PhpOffice\PhpWord\Media::addFooterMediaElement()`
- `PhpOffice\PhpWord\Media::countFooterMediaElements()`
- `PhpOffice\PhpWord\Media::getFooterMediaElements()`
- `PhpOffice\PhpWord\PhpWord::getProtection()`
- `PhpOffice\PhpWord\PhpWord::loadTemplate()`
- `PhpOffice\PhpWord\PhpWord::createSection()`
- `PhpOffice\PhpWord\PhpWord::getDocumentProperties()`
- `PhpOffice\PhpWord\PhpWord::setDocumentProperties()`
- `PhpOffice\PhpWord\Reader\AbstractReader::getReadDataOnly()`
- `PhpOffice\PhpWord\Settings::getCompatibility()`
- `PhpOffice\PhpWord\Style\AbstractStyle::setArrayStyle()`
- `PhpOffice\PhpWord\Style\Cell::getDefaultBorderColor()`
- `PhpOffice\PhpWord\Style\Font::getBold()`
- `PhpOffice\PhpWord\Style\Font::getItalic()`
- `PhpOffice\PhpWord\Style\Font::getSuperScript()`
- `PhpOffice\PhpWord\Style\Font::getSubScript()`
- `PhpOffice\PhpWord\Style\Font::getStrikethrough()`
- `PhpOffice\PhpWord\Style\Font::getParagraphStyle()`
- `PhpOffice\PhpWord\Style\Frame::getAlign()`
- `PhpOffice\PhpWord\Style\Frame::setAlign()`
- `PhpOffice\PhpWord\Style\NumberingLevel::getAlign()`
- `PhpOffice\PhpWord\Style\NumberingLevel::setAlign()`
- `PhpOffice\PhpWord\Style\Paragraph::getAlign()`
- `PhpOffice\PhpWord\Style\Paragraph::setAlign()`
- `PhpOffice\PhpWord\Style\Paragraph::getWidowControl()`
- `PhpOffice\PhpWord\Style\Paragraph::getKeepNext()`
- `PhpOffice\PhpWord\Style\Paragraph::getKeepLines()`
- `PhpOffice\PhpWord\Style\Paragraph::getPageBreakBefore()`
- `PhpOffice\PhpWord\Style\Row::getTblHeader()`
- `PhpOffice\PhpWord\Style\Row::isTblHeader()`
- `PhpOffice\PhpWord\Style\Row::getCantSplit()`
- `PhpOffice\PhpWord\Style\Row::getExactHeight()`
- `PhpOffice\PhpWord\Style\Spacing::getRule()`
- `PhpOffice\PhpWord\Style\Spacing::setRule()`
- `PhpOffice\PhpWord\Style\Table::getAlign()`
- `PhpOffice\PhpWord\Style\Table::setAlign()`
- `PhpOffice\PhpWord\Writer\AbstractWriter::getUseDiskCaching()`
- `PhpOffice\PhpWord\Writer\HTML::writeDocument()`
### Bug fixes
- Multiple PHP 8.1 fixes
- `loadConfig` returns config that was actually applied
- HTML Reader : Override inline style on HTML attribute for table
- HTML Reader : Use `border` attribute for tables
- HTML Reader : Style page-break-after in paragraph
- HTML Reader : Heading in Text Run is not allowed
-
### Miscellaneous
- Drop support for PHP 7.0 and older
## [0.18.3](https://github.com/PHPOffice/PHPWord/tree/0.18.3) (2022-02-17)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.18.2...0.18.3)
### Bug fixes
- PHP 8.1 compatibility
## [0.18.2](https://github.com/PHPOffice/PHPWord/tree/0.18.2) (2021-06-04)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.18.1...0.18.2)
### Bug fixes
- when adding image to relationship first check that the generated RID is actually unique [\#2063](https://github.com/PHPOffice/PHPWord/pull/2063) ([tpv-ebben](https://github.com/tpv-ebben))
- Update chart, don't write 'c:overlap' if grouping is 'clustered' [\#2052](https://github.com/PHPOffice/PHPWord/pull/2052) ([dfsd534](https://github.com/dfsd534))
- Update Html parser to accept line-height:normal [\#2041](https://github.com/PHPOffice/PHPWord/pull/2041) ([joelgo](https://github.com/joelgo))
- Fix image border in Word2007 Writer for LibreOffice 7 [\#2021](https://github.com/PHPOffice/PHPWord/pull/2021) ([kamilmmach](https://github.com/kamilmmach))
### Miscellaneous
- Corrected namespace for Language class in docs. [\#2087](https://github.com/PHPOffice/PHPWord/pull/2087) ([MegaChriz](https://github.com/MegaChriz))
- Added support for Garamond font [\#2078](https://github.com/PHPOffice/PHPWord/pull/2078) ([artemkolotilkin](https://github.com/artemkolotilkin))
- Add BorderStyle for Cell Style to documentation [\#2090](https://github.com/PHPOffice/PHPWord/pull/2090) ([DShkrabak](https://github.com/DShkrabak))
## [0.18.1](https://github.com/PHPOffice/PHPWord/tree/0.18.1) (2021-03-08)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.18.0...0.18.1)
### Bug fixes
- Fix BC break in #1946. This package does not replace laminas/laminas-zendframework-bridge [\#2032](https://github.com/PHPOffice/PHPWord/pull/2032) ([mussbach](https://github.com/mussbach))
## [0.18.0](https://github.com/PHPOffice/PHPWord/tree/0.18.0) (2021-02-12) ## [0.18.0](https://github.com/PHPOffice/PHPWord/tree/0.18.0) (2021-02-12)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.17.0...0.18.0) [Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.17.0...0.18.0)

View File

@ -1,16 +1,23 @@
# ![PHPWord](https://rawgit.com/PHPOffice/PHPWord/develop/docs/images/phpword.svg "PHPWord") # ![PHPWord](https://rawgit.com/PHPOffice/PHPWord/develop/docs/images/phpword.svg "PHPWord")
Master:
[![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword) [![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword)
[![CI](https://github.com/PHPOffice/PHPWord/actions/workflows/ci.yml/badge.svg)](https://github.com/PHPOffice/PHPWord/actions/workflows/ci.yml) [![Build Status](https://travis-ci.org/PHPOffice/PHPWord.svg?branch=master)](https://travis-ci.org/PHPOffice/PHPWord)
[![Code Quality](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/) [![Code Quality](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/)
[![Code Coverage](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/) [![Coverage Status](https://coveralls.io/repos/github/PHPOffice/PHPWord/badge.svg?branch=master)](https://coveralls.io/github/PHPOffice/PHPWord?branch=master)
[![Total Downloads](https://poser.pugx.org/phpoffice/phpword/downloads.png)](https://packagist.org/packages/phpoffice/phpword) [![Total Downloads](https://poser.pugx.org/phpoffice/phpword/downloads.png)](https://packagist.org/packages/phpoffice/phpword)
[![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword) [![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword)
[![Join the chat at https://gitter.im/PHPOffice/PHPWord](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/PHPOffice/PHPWord) [![Join the chat at https://gitter.im/PHPOffice/PHPWord](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/PHPOffice/PHPWord)
Develop:
[![Latest Development Version](https://img.shields.io/badge/unstable-dev--develop-orange.svg)](https://packagist.org/packages/phpoffice/phpword#dev-develop)
[![Build Status](https://travis-ci.org/PHPOffice/PHPWord.svg?branch=develop)](https://travis-ci.org/PHPOffice/PHPWord/branches)
[![Code Quality](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/?branch=develop)
[![Coverage Status](https://coveralls.io/repos/github/PHPOffice/PHPWord/badge.svg?branch=develop)](https://coveralls.io/github/PHPOffice/PHPWord?branch=develop)
PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF), HTML, and PDF. PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF), HTML, and PDF.
PHPWord is an open source project licensed under the terms of [LGPL version 3](COPYING.LESSER). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://github.com/PHPOffice/PHPWord/actions) and unit testing. You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/). PHPWord is an open source project licensed under the terms of [LGPL version 3](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/).
If you have any questions, please ask on [StackOverFlow](https://stackoverflow.com/questions/tagged/phpword) If you have any questions, please ask on [StackOverFlow](https://stackoverflow.com/questions/tagged/phpword)
@ -25,7 +32,7 @@ Read more about PHPWord:
## Features ## Features
With PHPWord, you can create OOXML, ODF, or RTF documents dynamically using your PHP scripts. Below are some of the things that you can do with PHPWord library: With PHPWord, you can create OOXML, ODF, or RTF documents dynamically using your PHP 5.3.3+ scripts. Below are some of the things that you can do with PHPWord library:
- Set document properties, e.g. title, subject, and creator. - Set document properties, e.g. title, subject, and creator.
- Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering - Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering
@ -53,7 +60,7 @@ With PHPWord, you can create OOXML, ODF, or RTF documents dynamically using your
PHPWord requires the following: PHPWord requires the following:
- PHP 7.1+ - 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)
- [Laminas Escaper component](https://docs.laminas.dev/laminas-escaper/intro/) - [Laminas Escaper component](https://docs.laminas.dev/laminas-escaper/intro/)
- [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)
@ -69,11 +76,20 @@ To [add a dependency](https://getcomposer.org/doc/04-schema.md#package-links) to
Run the following to use the latest stable version Run the following to use the latest stable version
```sh ```sh
composer require phpoffice/phpword composer require phpoffice/phpword
``` ```
or if you want the latest unreleased version or if you want the latest master version
```sh ```sh
composer require phpoffice/phpword:dev-master composer require phpoffice/phpword:dev-master
```
You can of course also manually edit your composer.json file
```json
{
"require": {
"phpoffice/phpword": "v0.16.*"
}
}
``` ```
## Getting started ## Getting started
@ -158,6 +174,6 @@ You can also read the [Developers' Documentation](http://phpword.readthedocs.org
We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute. We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute.
- Read [our contributing guide](CONTRIBUTING.md). - Read [our contributing guide](CONTRIBUTING.md).
- [Fork us](https://github.com/PHPOffice/PHPWord/fork) and [request a pull](https://github.com/PHPOffice/PHPWord/pulls) to the [master](https://github.com/PHPOffice/PHPWord/tree/master) branch. - [Fork us](https://github.com/PHPOffice/PHPWord/fork) and [request a pull](https://github.com/PHPOffice/PHPWord/pulls) to the [develop](https://github.com/PHPOffice/PHPWord/tree/develop) branch.
- Submit [bug reports or feature requests](https://github.com/PHPOffice/PHPWord/issues) to GitHub. - Submit [bug reports or feature requests](https://github.com/PHPOffice/PHPWord/issues) to GitHub.
- Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter. - Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter.

View File

@ -6,7 +6,7 @@
"docx", "OOXML", "OpenXML", "Office Open XML", "ISO IEC 29500", "WordprocessingML", "docx", "OOXML", "OpenXML", "Office Open XML", "ISO IEC 29500", "WordprocessingML",
"RTF", "Rich Text Format", "doc", "odt", "ODF", "OpenDocument", "PDF", "HTML" "RTF", "Rich Text Format", "doc", "odt", "ODF", "OpenDocument", "PDF", "HTML"
], ],
"homepage": "https://phpword.readthedocs.io/", "homepage": "http://phpoffice.github.io",
"type": "library", "type": "library",
"license": "LGPL-3.0", "license": "LGPL-3.0",
"authors": [ "authors": [
@ -43,7 +43,7 @@
], ],
"check": [ "check": [
"php-cs-fixer fix --ansi --dry-run --diff", "php-cs-fixer fix --ansi --dry-run --diff",
"phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --ignore=src/PhpWord/Shared/PCLZip --standard=PSR2 -n", "phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --ignore=src/PhpWord/Shared/PCLZip --standard=PSR2 -n",
"phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php", "phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php",
"@test-no-coverage" "@test-no-coverage"
], ],
@ -58,23 +58,21 @@
"fix": "Fixes issues found by PHP-CS" "fix": "Fixes issues found by PHP-CS"
}, },
"require": { "require": {
"php": "^7.1|^8.0", "php": "^7.1 || ^8",
"ext-dom": "*",
"ext-json": "*",
"ext-xml": "*", "ext-xml": "*",
"laminas/laminas-escaper": ">=2.6" "laminas/laminas-escaper": "^2.2"
}, },
"require-dev": { "require-dev": {
"ext-zip": "*", "ext-zip": "*",
"ext-gd": "*", "ext-gd": "*",
"ext-libxml": "*", "phpunit/phpunit": "^7.5",
"dompdf/dompdf": "^2.0", "squizlabs/php_codesniffer": "^3.5",
"mpdf/mpdf": "^8.1", "friendsofphp/php-cs-fixer": "^2.14",
"phpmd/phpmd": "^2.13", "phpmd/phpmd": "2.*",
"phpunit/phpunit": ">=7.0", "dompdf/dompdf":"0.8.* || 1.0.*",
"tecnickcom/tcpdf": "^6.5", "tecnickcom/tcpdf": "6.*",
"symfony/process": "^4.4", "mpdf/mpdf": "8.*",
"friendsofphp/php-cs-fixer": "^3.3" "php-coveralls/php-coveralls": "^2.0"
}, },
"suggest": { "suggest": {
"ext-zip": "Allows writing OOXML and ODF", "ext-zip": "Allows writing OOXML and ODF",
@ -88,9 +86,10 @@
"PhpOffice\\PhpWord\\": "src/PhpWord" "PhpOffice\\PhpWord\\": "src/PhpWord"
} }
}, },
"autoload-dev": { "extra": {
"psr-4": { "branch-alias": {
"PhpOffice\\PhpWordTests\\": "tests/PhpWordTests" "dev-develop": "0.19-dev",
"develop_v1.0": "1.0-dev"
} }
} }
} }

View File

@ -48,7 +48,7 @@ copyright = u'2014-2021, PHPWord Contributors'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.18.2' version = '0.18.0'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = version release = version

View File

@ -6,3 +6,19 @@ Frequently asked questions
How contribute to PHPWord? How contribute to PHPWord?
-------------------------- --------------------------
- Improve the documentation (`Sphinx Format <http://documentation-style-guide-sphinx.readthedocs.org/en/latest/index.html>`__) - Improve the documentation (`Sphinx Format <http://documentation-style-guide-sphinx.readthedocs.org/en/latest/index.html>`__)
Is this the same with PHPWord that I found in CodePlex?
-------------------------------------------------------
No. This one is much better with tons of new features that you cant
find in PHPWord 0.6.3. The development in CodePlex is halted and
switched to GitHub to allow more participation from the crowd. The more
the merrier, right?
Ive been running PHPWord from CodePlex flawlessly, but I cant use the latest PHPWord from GitHub. Why?
--------------------------------------------------------------------------------------------------------
PHPWord requires PHP 5.3+ since 0.8, while PHPWord 0.6.3 from CodePlex
can run with PHP 5.2. Theres a lot of new features that we can get from
PHP 5.3 and its been around since 2009! You should upgrade your PHP
version to use PHPWord 0.8+.

View File

@ -192,11 +192,11 @@ You can also specify the status of the spell and grammar checks, marking spellin
.. code-block:: php .. code-block:: php
$proofState = new \PhpOffice\PhpWord\ComplexType\ProofState(); $proofState = new ProofState();
$proofState->setGrammar(\PhpOffice\PhpWord\ComplexType\ProofState::CLEAN); $proofState->setGrammar(ProofState::CLEAN);
$proofState->setSpelling(\PhpOffice\PhpWord\ComplexType\ProofState::DIRTY); $proofState->setSpelling(ProofState::DIRTY);
$phpWord->getSettings()->setProofState($proofState); $phpWord->getSettings()->setProofState(proofState);
Track Revisions Track Revisions
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
@ -228,7 +228,7 @@ The default language of the document can be change with the following.
$phpWord->getSettings()->setThemeFontLang(new Language(Language::FR_BE)); $phpWord->getSettings()->setThemeFontLang(new Language(Language::FR_BE));
``Language`` has 3 parameters, one for Latin languages, one for East Asian languages and one for Complex (Bi-Directional) languages. ``Language`` 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\Style\Language`` class but any valid code/ID can be used. 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. In case you are generating an RTF document the language need to be set differently.

View File

@ -8,9 +8,9 @@ Requirements
Mandatory: Mandatory:
- composer - PHP 5.3.3+
- PHP 7.1+
- `XML Parser <http://www.php.net/manual/en/xml.installation.php>`__ extension - `XML Parser <http://www.php.net/manual/en/xml.installation.php>`__ extension
- `Laminas Escaper <https://docs.laminas.dev/laminas-escaper/intro/>`__ component
Optional: Optional:
@ -28,18 +28,26 @@ You just need to `add dependency <https://getcomposer.org/doc/04-schema.md#packa
Example: Example:
.. code-block:: bash .. code-block:: json
composer require phpoffice/phpword {
"require": {
"phpoffice/phpword": "v0.18.*"
}
}
If you are a developer or if you want to help us with testing then fetch the latest branch for developers. If you are a developer or if you want to help us with testing then fetch the latest branch for developers.
Notice: all contributions must be done against the developer branch. Notice: all contributions must be done against the developer branch.
Example: Example:
.. code-block:: bash .. code-block:: json
composer require phpoffice/phpword:dev-master {
"require": {
"phpoffice/phpword": "dev-develop"
}
}
Using samples Using samples
------------- -------------

View File

@ -13,10 +13,13 @@ Applications <http://en.wikipedia.org/wiki/OpenDocument>`__
Format <http://en.wikipedia.org/wiki/Rich_Text_Format>`__ (RTF). Format <http://en.wikipedia.org/wiki/Rich_Text_Format>`__ (RTF).
PHPWord is an open source project licensed under the terms of `LGPL PHPWord is an open source project licensed under the terms of `LGPL
version 3 <https://github.com/PHPOffice/PHPWord/blob/master/COPYING.LESSER>`__. version 3 <https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER>`__.
PHPWord is aimed to be a high quality software product. 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 this Developers' You can learn more about PHPWord by reading this Developers'
Documentation. Documentation and the `API
Documentation <http://phpoffice.github.io/PHPWord/docs/develop/>`__.
Features Features
-------- --------
@ -188,7 +191,7 @@ things that you can do to contribute.
guide <https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md>`__. guide <https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md>`__.
- `Fork us <https://github.com/PHPOffice/PHPWord/fork>`__ and `request - `Fork us <https://github.com/PHPOffice/PHPWord/fork>`__ and `request
a pull <https://github.com/PHPOffice/PHPWord/pulls>`__ to the a pull <https://github.com/PHPOffice/PHPWord/pulls>`__ to the
`master <https://github.com/PHPOffice/PHPWord/tree/master>`__ `develop <https://github.com/PHPOffice/PHPWord/tree/develop>`__
branch. branch.
- Submit `bug reports or feature - Submit `bug reports or feature
requests <https://github.com/PHPOffice/PHPWord/issues>`__ to GitHub. requests <https://github.com/PHPOffice/PHPWord/issues>`__ to GitHub.

View File

@ -29,7 +29,7 @@ Use ``php://output`` as the filename.
.. code-block:: php .. code-block:: php
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection(); $section = $phpWord->createSection();
$section->addText('Hello World!'); $section->addText('Hello World!');
$file = 'HelloWorld.docx'; $file = 'HelloWorld.docx';
header("Content-Description: File Transfer"); header("Content-Description: File Transfer");

View File

@ -143,7 +143,6 @@ Available Cell style options:
- ``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 *twip*. - ``border(Top|Right|Bottom|Left)Size``. Border size in *twip*.
- ``border(Top|Right|Bottom|Left)Style``. Border style. You can use constants from ``\PhpOffice\PhpWord\SimpleType\Border``
- ``gridSpan``. Number of columns spanned. - ``gridSpan``. Number of columns spanned.
- ``textDirection(btLr|tbRl)``. Direction of text. - ``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`` You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``

View File

@ -4,7 +4,7 @@ Templates processing
==================== ====================
You can create an OOXML document template with included search-patterns (macros) which can be replaced by any value you wish. Only single-line values can be replaced. You can create an OOXML document template with included search-patterns (macros) which can be replaced by any value you wish. Only single-line values can be replaced.
By default Macros are defined like this: ``${search-pattern}`` but you can define custom macros. Macros are defined like this: ``${search-pattern}``.
To load a template file, create a new instance of the TemplateProcessor. To load a template file, create a new instance of the TemplateProcessor.
.. code-block:: php .. code-block:: php
@ -35,30 +35,6 @@ You can also set multiple values by passing all of them in an array.
$templateProcessor->setValues(array('firstname' => 'John', 'lastname' => 'Doe')); $templateProcessor->setValues(array('firstname' => 'John', 'lastname' => 'Doe'));
setMacroOpeningChars
""""""""
You can define a custom opening macro. The following will set ``{#`` as the opening search pattern.
.. code-block:: php
$templateProcessor->setMacroOpeningChars('{#');
setMacroClosingChars
""""""""
You can define a custom closing macro. The following will set ``#}`` as the closing search pattern.
.. code-block:: php
$templateProcessor->setMacroClosingChars('#}');
setMacroChars
""""""""
You can define a custom opening and closing macro at the same time . The following will set the search-pattern like this: ``{#search-pattern#}`` .
.. code-block:: php
$templateProcessor->setMacroChars('{#', '#}');
setImageValue setImageValue
""""""""""""" """""""""""""
The search-pattern model for images can be like: The search-pattern model for images can be like:

View File

@ -19,9 +19,9 @@
<rule ref="rulesets/design.xml/GotoStatement" /> <rule ref="rulesets/design.xml/GotoStatement" />
<rule ref="rulesets/design.xml/DepthOfInheritance" /> <rule ref="rulesets/design.xml/DepthOfInheritance" />
<rule ref="rulesets/design.xml/CouplingBetweenObjects"> <rule ref="rulesets/design.xml/CouplingBetweenObjects">
<!-- AbstractContainer and Html need more coupling (default: 13) --> <!-- AbstractContainer needs more coupling (default: 13) -->
<properties> <properties>
<property name="maximum" value="25" /> <property name="maximum" value="20" />
</properties> </properties>
</rule> </rule>
<rule ref="rulesets/design.xml/NumberOfChildren"> <rule ref="rulesets/design.xml/NumberOfChildren">
@ -30,5 +30,6 @@
<property name="minimum" value="30" /> <property name="minimum" value="30" />
</properties> </properties>
</rule> </rule>
<!--rule ref="rulesets/unusedcode.xml" /-->
<rule ref="rulesets/controversial.xml" /> <rule ref="rulesets/controversial.xml" />
</ruleset> </ruleset>

View File

@ -1,4 +1,6 @@
<phpunit backupGlobals="false" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false" backupStaticAttributes="false"
bootstrap="./tests/bootstrap.php" bootstrap="./tests/bootstrap.php"
colors="true" colors="true"
@ -9,15 +11,20 @@
stopOnFailure="false"> stopOnFailure="false">
<testsuites> <testsuites>
<testsuite name="PhpWord Test Suite"> <testsuite name="PhpWord Test Suite">
<directory>./tests/PhpWordTests</directory> <directory>./tests/PhpWord</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter> <filter>
<whitelist> <whitelist>
<directory suffix=".php">./src</directory> <directory suffix=".php">./src</directory>
<exclude> <exclude>
<directory suffix=".php">./src/PhpWordTests/Shared/PCLZip</directory> <directory suffix=".php">./src/PhpWord/Shared/PCLZip</directory>
</exclude> </exclude>
</whitelist> </whitelist>
</filter> </filter>
<logging>
<log type="coverage-html" target="./build/coverage" />
<log type="coverage-clover" target="./build/logs/clover.xml" />
<log type="junit" target="./build/logs/logfile.xml"/>
</logging>
</phpunit> </phpunit>

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
@ -13,12 +12,12 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->getSettings()->setThemeFontLang($languageEnGb); $phpWord->getSettings()->setThemeFontLang($languageEnGb);
$fontStyleName = 'rStyle'; $fontStyleName = 'rStyle';
$phpWord->addFontStyle($fontStyleName, ['bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true]); $phpWord->addFontStyle($fontStyleName, array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
$paragraphStyleName = 'pStyle'; $paragraphStyleName = 'pStyle';
$phpWord->addParagraphStyle($paragraphStyleName, ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER, 'spaceAfter' => 100]); $phpWord->addParagraphStyle($paragraphStyleName, array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER, 'spaceAfter' => 100));
$phpWord->addTitleStyle(1, ['bold' => true], ['spaceAfter' => 240]); $phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
// New portrait section // New portrait section
$section = $phpWord->addSection(); $section = $phpWord->addSection();
@ -29,7 +28,7 @@ $section->addText('Hello World!');
// $pStyle = new Font(); // $pStyle = new Font();
// $pStyle->setLang() // $pStyle->setLang()
$section->addText('Ce texte-ci est en français.', ['lang' => \PhpOffice\PhpWord\Style\Language::FR_BE]); $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);
@ -48,33 +47,33 @@ $fontStyle['size'] = 20;
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();
$textrun->addText('I am inline styled ', $fontStyle); $textrun->addText('I am inline styled ', $fontStyle);
$textrun->addText('with '); $textrun->addText('with ');
$textrun->addText('color', ['color' => '996699']); $textrun->addText('color', array('color' => '996699'));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('bold', ['bold' => true]); $textrun->addText('bold', array('bold' => true));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('italic', ['italic' => true]); $textrun->addText('italic', array('italic' => true));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('underline', ['underline' => 'dash']); $textrun->addText('underline', array('underline' => 'dash'));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('strikethrough', ['strikethrough' => true]); $textrun->addText('strikethrough', array('strikethrough' => true));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('doubleStrikethrough', ['doubleStrikethrough' => true]); $textrun->addText('doubleStrikethrough', array('doubleStrikethrough' => true));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('superScript', ['superScript' => true]); $textrun->addText('superScript', array('superScript' => true));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('subScript', ['subScript' => true]); $textrun->addText('subScript', array('subScript' => true));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('smallCaps', ['smallCaps' => true]); $textrun->addText('smallCaps', array('smallCaps' => true));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('allCaps', ['allCaps' => true]); $textrun->addText('allCaps', array('allCaps' => true));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('fgColor', ['fgColor' => 'yellow']); $textrun->addText('fgColor', array('fgColor' => 'yellow'));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('scale', ['scale' => 200]); $textrun->addText('scale', array('scale' => 200));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('spacing', ['spacing' => 120]); $textrun->addText('spacing', array('spacing' => 120));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addText('kerning', ['kerning' => 10]); $textrun->addText('kerning', array('kerning' => 10));
$textrun->addText('. '); $textrun->addText('. ');
// Link // Link
@ -82,7 +81,7 @@ $section->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub');
$section->addTextBreak(); $section->addTextBreak();
// Image // Image
$section->addImage('resources/_earth.jpg', ['width' => 18, 'height' => 18]); $section->addImage('resources/_earth.jpg', array('width'=>18, 'height'=>18));
// Save file // Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers); echo write($phpWord, basename(__FILE__, '.php'), $writers);

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word Document // New Word Document
@ -10,20 +9,20 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
$multipleTabsStyleName = 'multipleTab'; $multipleTabsStyleName = 'multipleTab';
$phpWord->addParagraphStyle( $phpWord->addParagraphStyle(
$multipleTabsStyleName, $multipleTabsStyleName,
[ array(
'tabs' => [ 'tabs' => array(
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),
], ),
] )
); );
$rightTabStyleName = 'rightTab'; $rightTabStyleName = 'rightTab';
$phpWord->addParagraphStyle($rightTabStyleName, ['tabs' => [new \PhpOffice\PhpWord\Style\Tab('right', 9090)]]); $phpWord->addParagraphStyle($rightTabStyleName, array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('right', 9090))));
$leftTabStyleName = 'centerTab'; $leftTabStyleName = 'centerTab';
$phpWord->addParagraphStyle($leftTabStyleName, ['tabs' => [new \PhpOffice\PhpWord\Style\Tab('center', 4680)]]); $phpWord->addParagraphStyle($leftTabStyleName, array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center', 4680))));
// New portrait section // New portrait section
$section = $phpWord->addSection(); $section = $phpWord->addSection();

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\SimpleType\VerticalJc; use PhpOffice\PhpWord\SimpleType\VerticalJc;
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
@ -9,37 +8,37 @@ echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// New portrait section // New portrait section
$section = $phpWord->addSection(['borderColor' => '00FF00', 'borderSize' => 12]); $section = $phpWord->addSection(array('borderColor' => '00FF00', 'borderSize' => 12));
$section->addText('I am placed on a default section.'); $section->addText('I am placed on a default section.');
// New landscape section // New landscape section
$section = $phpWord->addSection(['orientation' => 'landscape']); $section = $phpWord->addSection(array('orientation' => 'landscape'));
$section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.'); $section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.');
$section->addPageBreak(); $section->addPageBreak();
$section->addPageBreak(); $section->addPageBreak();
// New portrait section // New portrait section
$section = $phpWord->addSection( $section = $phpWord->addSection(
['paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600] array('paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)
); );
$section->addText('This section uses other margins with folio papersize.'); $section->addText('This section uses other margins with folio papersize.');
// The text of this section is vertically centered // The text of this section is vertically centered
$section = $phpWord->addSection( $section = $phpWord->addSection(
['vAlign' => VerticalJc::CENTER] array('vAlign' => VerticalJc::CENTER)
); );
$section->addText('This section is vertically centered.'); $section->addText('This section is vertically centered.');
// New portrait section with Header & Footer // New portrait section with Header & Footer
$section = $phpWord->addSection( $section = $phpWord->addSection(
[ array(
'marginLeft' => 200, 'marginLeft' => 200,
'marginRight' => 200, 'marginRight' => 200,
'marginTop' => 200, 'marginTop' => 200,
'marginBottom' => 200, 'marginBottom' => 200,
'headerHeight' => 50, 'headerHeight' => 50,
'footerHeight' => 50, 'footerHeight' => 50,
] )
); );
$section->addText('This section and we play with header/footer height.'); $section->addText('This section and we play with header/footer height.');
$section->addHeader()->addText('Header'); $section->addHeader()->addText('Header');

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word Document // New Word Document
@ -8,16 +7,16 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Define styles // Define styles
$paragraphStyleName = 'pStyle'; $paragraphStyleName = 'pStyle';
$phpWord->addParagraphStyle($paragraphStyleName, ['spacing' => 100]); $phpWord->addParagraphStyle($paragraphStyleName, array('spacing' => 100));
$boldFontStyleName = 'BoldText'; $boldFontStyleName = 'BoldText';
$phpWord->addFontStyle($boldFontStyleName, ['bold' => true]); $phpWord->addFontStyle($boldFontStyleName, array('bold' => true));
$coloredFontStyleName = 'ColoredText'; $coloredFontStyleName = 'ColoredText';
$phpWord->addFontStyle($coloredFontStyleName, ['color' => 'FF8080', 'bgColor' => 'FFFFCC']); $phpWord->addFontStyle($coloredFontStyleName, array('color' => 'FF8080', 'bgColor' => 'FFFFCC'));
$linkFontStyleName = 'NLink'; $linkFontStyleName = 'NLink';
$phpWord->addLinkStyle($linkFontStyleName, ['color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE]); $phpWord->addLinkStyle($linkFontStyleName, array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
// New portrait section // New portrait section
$section = $phpWord->addSection(); $section = $phpWord->addSection();
@ -27,21 +26,21 @@ $textrun = $section->addTextRun($paragraphStyleName);
$textrun->addText('Each textrun can contain native text, link elements or an image.'); $textrun->addText('Each textrun can contain native text, link elements or an image.');
$textrun->addText(' No break is placed after adding an element.', $boldFontStyleName); $textrun->addText(' No break is placed after adding an element.', $boldFontStyleName);
$textrun->addText(' Both '); $textrun->addText(' Both ');
$textrun->addText('superscript', ['superScript' => true]); $textrun->addText('superscript', array('superScript' => true));
$textrun->addText(' and '); $textrun->addText(' and ');
$textrun->addText('subscript', ['subScript' => true]); $textrun->addText('subscript', array('subScript' => true));
$textrun->addText(' are also available.'); $textrun->addText(' are also available.');
$textrun->addText(' All elements are placed inside a paragraph with the optionally given paragraph style.', $coloredFontStyleName); $textrun->addText(' All elements are placed inside a paragraph with the optionally given paragraph style.', $coloredFontStyleName);
$textrun->addText(' Sample Link: '); $textrun->addText(' Sample Link: ');
$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub', $linkFontStyleName); $textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub', $linkFontStyleName);
$textrun->addText(' Sample Image: '); $textrun->addText(' Sample Image: ');
$textrun->addImage('resources/_earth.jpg', ['width' => 18, 'height' => 18]); $textrun->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18));
$textrun->addText(' Sample Object: '); $textrun->addText(' Sample Object: ');
$textrun->addObject('resources/_sheet.xls'); $textrun->addObject('resources/_sheet.xls');
$textrun->addText(' Here is some more text. '); $textrun->addText(' Here is some more text. ');
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();
$textrun->addText('This text is not visible.', ['hidden' => true]); $textrun->addText('This text is not visible.', array('hidden' => true));
// Save file // Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers); echo write($phpWord, basename(__FILE__, '.php'), $writers);

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word Document // New Word Document
@ -16,30 +15,30 @@ $section->addText("Normal paragraph. {$filler}");
// Two columns // Two columns
$section = $phpWord->addSection( $section = $phpWord->addSection(
[ array(
'colsNum' => 2, 'colsNum' => 2,
'colsSpace' => 1440, 'colsSpace' => 1440,
'breakType' => 'continuous', 'breakType' => 'continuous',
] )
); );
$section->addText("Two columns, one inch (1440 twips) spacing. {$filler}"); $section->addText("Two columns, one inch (1440 twips) spacing. {$filler}");
// Normal // Normal
$section = $phpWord->addSection(['breakType' => 'continuous']); $section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addText("Normal paragraph again. {$filler}"); $section->addText("Normal paragraph again. {$filler}");
// Three columns // Three columns
$section = $phpWord->addSection( $section = $phpWord->addSection(
[ array(
'colsNum' => 3, 'colsNum' => 3,
'colsSpace' => 720, 'colsSpace' => 720,
'breakType' => 'continuous', 'breakType' => 'continuous',
] )
); );
$section->addText("Three columns, half inch (720 twips) spacing. {$filler}"); $section->addText("Three columns, half inch (720 twips) spacing. {$filler}");
// Normal // Normal
$section = $phpWord->addSection(['breakType' => 'continuous']); $section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addText("Normal paragraph again. {$filler}"); $section->addText("Normal paragraph again. {$filler}");
// Save file // Save file

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\ComplexType\FootnoteProperties; use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
use PhpOffice\PhpWord\SimpleType\NumberFormat; use PhpOffice\PhpWord\SimpleType\NumberFormat;
@ -12,16 +11,16 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Define styles // Define styles
$paragraphStyleName = 'pStyle'; $paragraphStyleName = 'pStyle';
$phpWord->addParagraphStyle($paragraphStyleName, ['spacing' => 100]); $phpWord->addParagraphStyle($paragraphStyleName, array('spacing' => 100));
$boldFontStyleName = 'BoldText'; $boldFontStyleName = 'BoldText';
$phpWord->addFontStyle($boldFontStyleName, ['bold' => true]); $phpWord->addFontStyle($boldFontStyleName, array('bold' => true));
$coloredFontStyleName = 'ColoredText'; $coloredFontStyleName = 'ColoredText';
$phpWord->addFontStyle($coloredFontStyleName, ['color' => 'FF8080', 'bgColor' => 'FFFFCC']); $phpWord->addFontStyle($coloredFontStyleName, array('color' => 'FF8080', 'bgColor' => 'FFFFCC'));
$linkFontStyleName = 'NLink'; $linkFontStyleName = 'NLink';
$phpWord->addLinkStyle($linkFontStyleName, ['color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE]); $phpWord->addLinkStyle($linkFontStyleName, array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
// New portrait section // New portrait section
$section = $phpWord->addSection(); $section = $phpWord->addSection();
@ -39,7 +38,7 @@ $footnote->addText('But you can insert a manual text break like above, ');
$footnote->addText('links like '); $footnote->addText('links like ');
$footnote->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub', $linkFontStyleName); $footnote->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub', $linkFontStyleName);
$footnote->addText(', image like '); $footnote->addText(', image like ');
$footnote->addImage('resources/_earth.jpg', ['width' => 18, 'height' => 18]); $footnote->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18));
$footnote->addText(', or object like '); $footnote->addText(', or object like ');
$footnote->addObject('resources/_sheet.xls'); $footnote->addObject('resources/_sheet.xls');
$footnote->addText('But you can only put footnote in section, not in header or footer.'); $footnote->addText('But you can only put footnote in section, not in header or footer.');

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// Template processor instance creation // Template processor instance creation
@ -37,26 +36,26 @@ $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
$values = [ $values = array(
[ array(
'userId' => 1, 'userId' => 1,
'userFirstName' => 'James', 'userFirstName' => 'James',
'userName' => 'Taylor', 'userName' => 'Taylor',
'userPhone' => '+1 428 889 773', 'userPhone' => '+1 428 889 773',
], ),
[ array(
'userId' => 2, 'userId' => 2,
'userFirstName' => 'Robert', 'userFirstName' => 'Robert',
'userName' => 'Bell', 'userName' => 'Bell',
'userPhone' => '+1 428 889 774', 'userPhone' => '+1 428 889 774',
], ),
[ array(
'userId' => 3, 'userId' => 3,
'userFirstName' => 'Michael', 'userFirstName' => 'Michael',
'userName' => 'Ray', 'userName' => 'Ray',
'userPhone' => '+1 428 889 775', 'userPhone' => '+1 428 889 775',
], ),
]; );
$templateProcessor->cloneRowAndSetValues('userId', $values); $templateProcessor->cloneRowAndSetValues('userId', $values);
@ -81,7 +80,7 @@ $templateProcessor->cloneRowAndSetValues('userId', $values);
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(['Word2007' => 'docx'], 'results/Sample_07_TemplateCloneRow.docx'); echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_07_TemplateCloneRow.docx');
if (!CLI) { if (!CLI) {
include_once 'Sample_Footer.php'; include_once 'Sample_Footer.php';
} }

View File

@ -1,16 +1,15 @@
<?php <?php
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;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->setDefaultParagraphStyle( $phpWord->setDefaultParagraphStyle(
[ array(
'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::BOTH, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::BOTH,
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12), 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12),
'spacing' => 120, 'spacing' => 120,
] )
); );
// New section // New section
@ -20,8 +19,8 @@ $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.',
['bold' => true], array('bold' => true),
['space' => ['before' => 360, 'after' => 480]] array('space' => array('before' => 360, 'after' => 480))
); );
$section->addText( $section->addText(
@ -31,7 +30,7 @@ $section->addText(
. 'itself at the bottom of a page. Set this option to "false" if you want ' . 'itself at the bottom of a page. Set this option to "false" if you want '
. 'to disable this automatic control.', . 'to disable this automatic control.',
null, null,
['widowControl' => false, 'indentation' => ['left' => 240, 'right' => 120]] array('widowControl' => false, 'indentation' => array('left' => 240, 'right' => 120))
); );
$section->addText( $section->addText(
@ -40,7 +39,7 @@ $section->addText(
. 'breaks between paragraphs. Set this option to "true" if you do not want ' . 'breaks between paragraphs. Set this option to "true" if you do not want '
. 'your paragraph to be separated with the next paragraph.', . 'your paragraph to be separated with the next paragraph.',
null, null,
['keepNext' => true, 'indentation' => ['firstLine' => 240]] array('keepNext' => true, 'indentation' => array('firstLine' => 240))
); );
$section->addText( $section->addText(
@ -49,7 +48,7 @@ $section->addText(
. 'break within a paragraph. Set this option to "true" if you do not want ' . 'break within a paragraph. Set this option to "true" if you do not want '
. 'all lines of your paragraph to be in the same page.', . 'all lines of your paragraph to be in the same page.',
null, null,
['keepLines' => true, 'indentation' => ['left' => 240, 'hanging' => 240]] array('keepLines' => true, 'indentation' => array('left' => 240, 'hanging' => 240))
); );
$section->addText('Keep scrolling. More below.'); $section->addText('Keep scrolling. More below.');
@ -60,7 +59,7 @@ $section->addText(
. 'your paragraph into the next page. This option is most useful for ' . 'your paragraph into the next page. This option is most useful for '
. 'heading styles.', . 'heading styles.',
null, null,
['pageBreakBefore' => true] array('pageBreakBefore' => true)
); );
// Save file // Save file

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\Shared\Converter; use PhpOffice\PhpWord\Shared\Converter;
use PhpOffice\PhpWord\Style\TablePosition; use PhpOffice\PhpWord\Style\TablePosition;
@ -9,7 +8,7 @@ include_once 'Sample_Header.php';
echo date('H:i:s'), ' Create new PhpWord object', EOL; echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$header = ['size' => 16, 'bold' => true]; $header = array('size' => 16, 'bold' => true);
// 1. Basic table // 1. Basic table
@ -18,9 +17,9 @@ $cols = 5;
$section->addText('Basic table', $header); $section->addText('Basic table', $header);
$table = $section->addTable(); $table = $section->addTable();
for ($r = 1; $r <= $rows; ++$r) { for ($r = 1; $r <= $rows; $r++) {
$table->addRow(); $table->addRow();
for ($c = 1; $c <= $cols; ++$c) { for ($c = 1; $c <= $cols; $c++) {
$table->addCell(1750)->addText("Row {$r}, Cell {$c}"); $table->addCell(1750)->addText("Row {$r}, Cell {$c}");
} }
} }
@ -31,11 +30,11 @@ $section->addTextBreak(1);
$section->addText('Fancy table', $header); $section->addText('Fancy table', $header);
$fancyTableStyleName = 'Fancy Table'; $fancyTableStyleName = 'Fancy Table';
$fancyTableStyle = ['borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER, 'cellSpacing' => 50]; $fancyTableStyle = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER, 'cellSpacing' => 50);
$fancyTableFirstRowStyle = ['borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF']; $fancyTableFirstRowStyle = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
$fancyTableCellStyle = ['valign' => 'center']; $fancyTableCellStyle = array('valign' => 'center');
$fancyTableCellBtlrStyle = ['valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR]; $fancyTableCellBtlrStyle = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
$fancyTableFontStyle = ['bold' => true]; $fancyTableFontStyle = array('bold' => true);
$phpWord->addTableStyle($fancyTableStyleName, $fancyTableStyle, $fancyTableFirstRowStyle); $phpWord->addTableStyle($fancyTableStyleName, $fancyTableStyle, $fancyTableFirstRowStyle);
$table = $section->addTable($fancyTableStyleName); $table = $section->addTable($fancyTableStyleName);
$table->addRow(900); $table->addRow(900);
@ -44,7 +43,7 @@ $table->addCell(2000, $fancyTableCellStyle)->addText('Row 2', $fancyTableFontSty
$table->addCell(2000, $fancyTableCellStyle)->addText('Row 3', $fancyTableFontStyle); $table->addCell(2000, $fancyTableCellStyle)->addText('Row 3', $fancyTableFontStyle);
$table->addCell(2000, $fancyTableCellStyle)->addText('Row 4', $fancyTableFontStyle); $table->addCell(2000, $fancyTableCellStyle)->addText('Row 4', $fancyTableFontStyle);
$table->addCell(500, $fancyTableCellBtlrStyle)->addText('Row 5', $fancyTableFontStyle); $table->addCell(500, $fancyTableCellBtlrStyle)->addText('Row 5', $fancyTableFontStyle);
for ($i = 1; $i <= 8; ++$i) { for ($i = 1; $i <= 8; $i++) {
$table->addRow(); $table->addRow();
$table->addCell(2000)->addText("Cell {$i}"); $table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}"); $table->addCell(2000)->addText("Cell {$i}");
@ -66,12 +65,12 @@ for ($i = 1; $i <= 8; ++$i) {
$section->addPageBreak(); $section->addPageBreak();
$section->addText('Table with colspan and rowspan', $header); $section->addText('Table with colspan and rowspan', $header);
$fancyTableStyle = ['borderSize' => 6, 'borderColor' => '999999']; $fancyTableStyle = array('borderSize' => 6, 'borderColor' => '999999');
$cellRowSpan = ['vMerge' => 'restart', 'valign' => 'center', 'bgColor' => 'FFFF00']; $cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center', 'bgColor' => 'FFFF00');
$cellRowContinue = ['vMerge' => 'continue']; $cellRowContinue = array('vMerge' => 'continue');
$cellColSpan = ['gridSpan' => 2, 'valign' => 'center']; $cellColSpan = array('gridSpan' => 2, 'valign' => 'center');
$cellHCentered = ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER]; $cellHCentered = array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER);
$cellVCentered = ['valign' => 'center']; $cellVCentered = array('valign' => 'center');
$spanTableStyleName = 'Colspan Rowspan'; $spanTableStyleName = 'Colspan Rowspan';
$phpWord->addTableStyle($spanTableStyleName, $fancyTableStyle); $phpWord->addTableStyle($spanTableStyleName, $fancyTableStyle);
@ -112,22 +111,22 @@ $table->addCell(null, $cellRowContinue);
$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(1000, ['vMerge' => 'restart'])->addText('A'); $row->addCell(1000, array('vMerge' => 'restart'))->addText('A');
$row->addCell(1000, ['gridSpan' => 2, 'vMerge' => 'restart'])->addText('B'); $row->addCell(1000, array('gridSpan' => 2, 'vMerge' => 'restart'))->addText('B');
$row->addCell(1000)->addText('1'); $row->addCell(1000)->addText('1');
$row = $table->addRow(); $row = $table->addRow();
$row->addCell(1000, ['vMerge' => 'continue']); $row->addCell(1000, array('vMerge' => 'continue'));
$row->addCell(1000, ['vMerge' => 'continue', 'gridSpan' => 2]); $row->addCell(1000, array('vMerge' => 'continue', 'gridSpan' => 2));
$row->addCell(1000)->addText('2'); $row->addCell(1000)->addText('2');
$row = $table->addRow(); $row = $table->addRow();
$row->addCell(1000, ['vMerge' => 'continue']); $row->addCell(1000, array('vMerge' => 'continue'));
$row->addCell(1000)->addText('C'); $row->addCell(1000)->addText('C');
$row->addCell(1000)->addText('D'); $row->addCell(1000)->addText('D');
$row->addCell(1000)->addText('3'); $row->addCell(1000)->addText('3');
@ -137,10 +136,10 @@ $row->addCell(1000)->addText('3');
$section->addTextBreak(2); $section->addTextBreak(2);
$section->addText('Nested table in a centered and 50% width table.', $header); $section->addText('Nested table in a centered and 50% width table.', $header);
$table = $section->addTable(['width' => 50 * 50, 'unit' => 'pct', 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER]); $table = $section->addTable(array('width' => 50 * 50, 'unit' => 'pct', 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER));
$cell = $table->addRow()->addCell(); $cell = $table->addRow()->addCell();
$cell->addText('This cell contains nested table.'); $cell->addText('This cell contains nested table.');
$innerCell = $cell->addTable(['alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER])->addRow()->addCell(); $innerCell = $cell->addTable(array('alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER))->addRow()->addCell();
$innerCell->addText('Inside nested table'); $innerCell->addText('Inside nested table');
// 6. Table with floating position // 6. Table with floating position
@ -148,7 +147,7 @@ $innerCell->addText('Inside nested table');
$section->addTextBreak(2); $section->addTextBreak(2);
$section->addText('Table with floating positioning.', $header); $section->addText('Table with floating positioning.', $header);
$table = $section->addTable(['borderSize' => 6, 'borderColor' => '999999', 'position' => ['vertAnchor' => TablePosition::VANCHOR_TEXT, 'bottomFromText' => Converter::cmToTwip(1)]]); $table = $section->addTable(array('borderSize' => 6, 'borderColor' => '999999', 'position' => array('vertAnchor' => TablePosition::VANCHOR_TEXT, 'bottomFromText' => Converter::cmToTwip(1))));
$cell = $table->addRow()->addCell(); $cell = $table->addRow()->addCell();
$cell->addText('This is a single cell.'); $cell->addText('This is a single cell.');

View File

@ -1,14 +1,13 @@
<?php <?php
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;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$header = ['size' => 16, 'bold' => true]; $header = array('size' => 16, 'bold' => true);
//1.Use EastAisa FontStyle //1.Use EastAisa FontStyle
$section->addText('中文楷体样式测试', ['name' => '楷体', 'size' => 16, 'color' => '1B2232', 'lang' => ['latin' => 'en-US', 'eastAsia' => 'zh-CN']]); $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);

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// Read contents // Read contents

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// Read contents // Read contents

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -18,16 +17,16 @@ $cell = $table->addCell(4500);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('This is the header with '); $textrun->addText('This is the header with ');
$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub'); $textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub');
$table->addCell(4500)->addImage('resources/PhpWord.png', ['width' => 80, 'height' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END]); $table->addCell(4500)->addImage('resources/PhpWord.png', array('width' => 80, 'height' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END));
// Add header for all other pages // Add header for all other pages
$subsequent = $section->addHeader(); $subsequent = $section->addHeader();
$subsequent->addText('Subsequent pages in Section 1 will Have this!'); $subsequent->addText('Subsequent pages in Section 1 will Have this!');
$subsequent->addImage('resources/_mars.jpg', ['width' => 80, 'height' => 80]); $subsequent->addImage('resources/_mars.jpg', array('width' => 80, 'height' => 80));
// Add footer // Add footer
$footer = $section->addFooter(); $footer = $section->addFooter();
$footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', null, ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER]); $footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', null, array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
$footer->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub'); $footer->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub');
// Write some text // Write some text

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Shared\Converter; use PhpOffice\PhpWord\Shared\Converter;
@ -16,7 +15,7 @@ $section->addImage('resources/_mars.jpg');
printSeparator($section); printSeparator($section);
$section->addText('Local image with styles:'); $section->addText('Local image with styles:');
$section->addImage('resources/_earth.jpg', ['width' => 210, 'height' => 210, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER]); $section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
// Remote image // Remote image
printSeparator($section); printSeparator($section);
@ -34,21 +33,21 @@ $section->addImage($fileContent);
//Wrapping style //Wrapping style
printSeparator($section); printSeparator($section);
$text = str_repeat('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 2); $text = str_repeat('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 2);
$wrappingStyles = ['inline', 'behind', 'infront', 'square', 'tight']; $wrappingStyles = array('inline', 'behind', 'infront', 'square', 'tight');
foreach ($wrappingStyles as $wrappingStyle) { foreach ($wrappingStyles as $wrappingStyle) {
$section->addText("Wrapping style {$wrappingStyle}"); $section->addText("Wrapping style {$wrappingStyle}");
$section->addImage( $section->addImage(
'resources/_earth.jpg', 'resources/_earth.jpg',
[ array(
'positioning' => 'relative', 'positioning' => 'relative',
'marginTop' => -1, 'marginTop' => -1,
'marginLeft' => 1, 'marginLeft' => 1,
'width' => 80, 'width' => 80,
'height' => 80, 'height' => 80,
'wrappingStyle' => $wrappingStyle, 'wrappingStyle' => $wrappingStyle,
'wrapDistanceRight' => Converter::cmToPoint(1), 'wrapDistanceRight' => Converter::cmToPoint(1),
'wrapDistanceBottom' => Converter::cmToPoint(1), 'wrapDistanceBottom' => Converter::cmToPoint(1),
] )
); );
$section->addText($text); $section->addText($text);
printSeparator($section); printSeparator($section);
@ -58,16 +57,16 @@ foreach ($wrappingStyles as $wrappingStyle) {
$section->addText('Absolute positioning: see top right corner of page'); $section->addText('Absolute positioning: see top right corner of page');
$section->addImage( $section->addImage(
'resources/_mars.jpg', 'resources/_mars.jpg',
[ array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT, 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT,
'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE, 'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE,
'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE, 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE,
'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15.5), 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15.5),
'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1.55), 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1.55),
] )
); );
//Relative positioning //Relative positioning
@ -76,21 +75,21 @@ $section->addText('Relative positioning: Horizontal position center relative to
$section->addText('Vertical position top relative to line'); $section->addText('Vertical position top relative to line');
$section->addImage( $section->addImage(
'resources/_mars.jpg', 'resources/_mars.jpg',
[ array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE, 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE,
'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER, 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER,
'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_COLUMN, 'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_COLUMN,
'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP, 'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP,
'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_LINE, 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_LINE,
] )
); );
function printSeparator(Section $section): void function printSeparator(Section $section)
{ {
$section->addTextBreak(); $section->addTextBreak();
$lineStyle = ['weight' => 0.2, 'width' => 150, 'height' => 0, 'align' => 'center']; $lineStyle = array('weight' => 0.2, 'width' => 150, 'height' => 0, 'align' => 'center');
$section->addLine($lineStyle); $section->addLine($lineStyle);
$section->addTextBreak(2); $section->addTextBreak(2);
} }

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -8,24 +7,24 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Define styles // Define styles
$fontStyleName = 'myOwnStyle'; $fontStyleName = 'myOwnStyle';
$phpWord->addFontStyle($fontStyleName, ['color' => 'FF0000']); $phpWord->addFontStyle($fontStyleName, array('color' => 'FF0000'));
$paragraphStyleName = 'P-Style'; $paragraphStyleName = 'P-Style';
$phpWord->addParagraphStyle($paragraphStyleName, ['spaceAfter' => 95]); $phpWord->addParagraphStyle($paragraphStyleName, array('spaceAfter' => 95));
$multilevelNumberingStyleName = 'multilevel'; $multilevelNumberingStyleName = 'multilevel';
$phpWord->addNumberingStyle( $phpWord->addNumberingStyle(
$multilevelNumberingStyleName, $multilevelNumberingStyleName,
[ array(
'type' => 'multilevel', 'type' => 'multilevel',
'levels' => [ 'levels' => array(
['format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360], array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360),
['format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720], array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
], ),
] )
); );
$predefinedMultilevelStyle = ['listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED]; $predefinedMultilevelStyle = array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED);
// New section // New section
$section = $phpWord->addSection(); $section = $phpWord->addSection();
@ -64,32 +63,32 @@ $section->addTextBreak(2);
$section->addText('List with inline formatting.'); $section->addText('List with inline formatting.');
$listItemRun = $section->addListItemRun(); $listItemRun = $section->addListItemRun();
$listItemRun->addText('List item 1'); $listItemRun->addText('List item 1');
$listItemRun->addText(' in bold', ['bold' => true]); $listItemRun->addText(' in bold', array('bold' => true));
$listItemRun = $section->addListItemRun(1, $predefinedMultilevelStyle, $paragraphStyleName); $listItemRun = $section->addListItemRun(1, $predefinedMultilevelStyle, $paragraphStyleName);
$listItemRun->addText('List item 2'); $listItemRun->addText('List item 2');
$listItemRun->addText(' in italic', ['italic' => true]); $listItemRun->addText(' in italic', array('italic' => true));
$footnote = $listItemRun->addFootnote(); $footnote = $listItemRun->addFootnote();
$footnote->addText('this is a footnote on a list item'); $footnote->addText('this is a footnote on a list item');
$listItemRun = $section->addListItemRun(); $listItemRun = $section->addListItemRun();
$listItemRun->addText('List item 3'); $listItemRun->addText('List item 3');
$listItemRun->addText(' underlined', ['underline' => 'dash']); $listItemRun->addText(' underlined', array('underline' => 'dash'));
$section->addTextBreak(2); $section->addTextBreak(2);
// Numbered heading // Numbered heading
$headingNumberingStyleName = 'headingNumbering'; $headingNumberingStyleName = 'headingNumbering';
$phpWord->addNumberingStyle( $phpWord->addNumberingStyle(
$headingNumberingStyleName, $headingNumberingStyleName,
['type' => 'multilevel', array('type' => 'multilevel',
'levels' => [ 'levels' => array(
['pStyle' => 'Heading1', 'format' => 'decimal', 'text' => '%1'], array('pStyle' => 'Heading1', 'format' => 'decimal', 'text' => '%1'),
['pStyle' => 'Heading2', 'format' => 'decimal', 'text' => '%1.%2'], array('pStyle' => 'Heading2', 'format' => 'decimal', 'text' => '%1.%2'),
['pStyle' => 'Heading3', 'format' => 'decimal', 'text' => '%1.%2.%3'], array('pStyle' => 'Heading3', 'format' => 'decimal', 'text' => '%1.%2.%3'),
], ),
] )
); );
$phpWord->addTitleStyle(1, ['size' => 16], ['numStyle' => $headingNumberingStyleName, 'numLevel' => 0]); $phpWord->addTitleStyle(1, array('size' => 16), array('numStyle' => $headingNumberingStyleName, 'numLevel' => 0));
$phpWord->addTitleStyle(2, ['size' => 14], ['numStyle' => $headingNumberingStyleName, 'numLevel' => 1]); $phpWord->addTitleStyle(2, array('size' => 14), array('numStyle' => $headingNumberingStyleName, 'numLevel' => 1));
$phpWord->addTitleStyle(3, ['size' => 12], ['numStyle' => $headingNumberingStyleName, 'numLevel' => 2]); $phpWord->addTitleStyle(3, array('size' => 12), array('numStyle' => $headingNumberingStyleName, 'numLevel' => 2));
$section->addTitle('Heading 1', 1); $section->addTitle('Heading 1', 1);
$section->addTitle('Heading 2', 2); $section->addTitle('Heading 2', 2);

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -8,7 +7,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Define styles // Define styles
$linkFontStyleName = 'myOwnLinStyle'; $linkFontStyleName = 'myOwnLinStyle';
$phpWord->addLinkStyle($linkFontStyleName, ['bold' => true, 'color' => '808000']); $phpWord->addLinkStyle($linkFontStyleName, array('bold' => true, 'color' => '808000'));
// New section // New section
$section = $phpWord->addSection(); $section = $phpWord->addSection();
@ -17,7 +16,7 @@ $section = $phpWord->addSection();
$section->addLink( $section->addLink(
'https://github.com/PHPOffice/PHPWord', 'https://github.com/PHPOffice/PHPWord',
'PHPWord on GitHub', 'PHPWord on GitHub',
['color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE] array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)
); );
$section->addTextBreak(2); $section->addTextBreak(2);
$section->addLink('http://www.bing.com', null, $linkFontStyleName); $section->addLink('http://www.bing.com', null, $linkFontStyleName);

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -11,13 +10,13 @@ $phpWord->getSettings()->setUpdateFields(true);
$section = $phpWord->addSection(); $section = $phpWord->addSection();
// Define styles // Define styles
$fontStyle12 = ['spaceAfter' => 60, 'size' => 12]; $fontStyle12 = array('spaceAfter' => 60, 'size' => 12);
$fontStyle10 = ['size' => 10]; $fontStyle10 = array('size' => 10);
$phpWord->addTitleStyle(null, ['size' => 22, 'bold' => true]); $phpWord->addTitleStyle(null, array('size' => 22, 'bold' => true));
$phpWord->addTitleStyle(1, ['size' => 20, 'color' => '333333', 'bold' => true]); $phpWord->addTitleStyle(1, array('size' => 20, 'color' => '333333', 'bold' => true));
$phpWord->addTitleStyle(2, ['size' => 16, 'color' => '666666']); $phpWord->addTitleStyle(2, array('size' => 16, 'color' => '666666'));
$phpWord->addTitleStyle(3, ['size' => 14, 'italic' => true]); $phpWord->addTitleStyle(3, array('size' => 14, 'italic' => true));
$phpWord->addTitleStyle(4, ['size' => 12]); $phpWord->addTitleStyle(4, array('size' => 12));
// Add text elements // Add text elements
$section->addTitle('Table of contents 1', 0); $section->addTitle('Table of contents 1', 0);

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -9,7 +8,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code // Begin code
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$header = $section->addHeader(); $header = $section->addHeader();
$header->addWatermark('resources/_earth.jpg', ['marginTop' => 200, 'marginLeft' => 55]); $header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55));
$section->addText('The header reference to the current section includes a watermark image.'); $section->addText('The header reference to the current section includes a watermark image.');
// Save file // Save file

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -7,15 +6,15 @@ echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Define styles // Define styles
$fontStyle24 = ['size' => 24]; $fontStyle24 = array('size' => 24);
$paragraphStyle24 = ['spacing' => 240, 'size' => 24]; $paragraphStyle24 = array('spacing' => 240, 'size' => 24);
$fontStyleName = 'fontStyle'; $fontStyleName = 'fontStyle';
$phpWord->addFontStyle($fontStyleName, ['size' => 9]); $phpWord->addFontStyle($fontStyleName, array('size' => 9));
$paragraphStyleName = 'paragraphStyle'; $paragraphStyleName = 'paragraphStyle';
$phpWord->addParagraphStyle($paragraphStyleName, ['spacing' => 480]); $phpWord->addParagraphStyle($paragraphStyleName, array('spacing' => 480));
// New section // New section
$section = $phpWord->addSection(); $section = $phpWord->addSection();

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -11,10 +10,10 @@ $section = $phpWord->addSection();
$section->addText( $section->addText(
'This is some text highlighted using fgColor (limited to 15 colors)', 'This is some text highlighted using fgColor (limited to 15 colors)',
['fgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW] array('fgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)
); );
$section->addText('This one uses bgColor and is using hex value (0xfbbb10)', ['bgColor' => 'fbbb10']); $section->addText('This one uses bgColor and is using hex value (0xfbbb10)', array('bgColor' => 'fbbb10'));
$section->addText('Compatible with font colors', ['color' => '0000ff', 'bgColor' => 'fbbb10']); $section->addText('Compatible with font colors', array('color' => '0000ff', 'bgColor' => 'fbbb10'));
// Save file // Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers); echo write($phpWord, basename(__FILE__, '.php'), $writers);

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -16,25 +15,25 @@ $section->addText(
. 'the textbreak is still there:' . 'the textbreak is still there:'
); );
$table1 = $section->addTable(['cellMargin' => 0, 'cellMarginRight' => 0, 'cellMarginBottom' => 0, 'cellMarginLeft' => 0]); $table1 = $section->addTable(array('cellMargin' => 0, 'cellMarginRight' => 0, 'cellMarginBottom' => 0, 'cellMarginLeft' => 0));
$table1->addRow(3750); $table1->addRow(3750);
$cell1 = $table1->addCell(null, ['valign' => 'top', 'borderSize' => 30, 'borderColor' => 'ff0000']); $cell1 = $table1->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => 'ff0000'));
$cell1->addImage('./resources/_earth.jpg', ['width' => 250, 'height' => 250, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER]); $cell1->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
$section->addTextBreak(); $section->addTextBreak();
$section->addText("But if we set the rowStyle 'exactHeight' to true, the real row height is used, removing the textbreak:"); $section->addText("But if we set the rowStyle 'exactHeight' to true, the real row height is used, removing the textbreak:");
$table2 = $section->addTable( $table2 = $section->addTable(
[ array(
'cellMargin' => 0, 'cellMargin' => 0,
'cellMarginRight' => 0, 'cellMarginRight' => 0,
'cellMarginBottom' => 0, 'cellMarginBottom' => 0,
'cellMarginLeft' => 0, 'cellMarginLeft' => 0,
] )
); );
$table2->addRow(3750, ['exactHeight' => true]); $table2->addRow(3750, array('exactHeight' => true));
$cell2 = $table2->addCell(null, ['valign' => 'top', 'borderSize' => 30, 'borderColor' => '00ff00']); $cell2 = $table2->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => '00ff00'));
$cell2->addImage('./resources/_earth.jpg', ['width' => 250, 'height' => 250, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER]); $cell2->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
$section->addTextBreak(); $section->addTextBreak();
$section->addText('In this example, image is 250px height. Rows are calculated in twips, and 1px = 15twips.'); $section->addText('In this example, image is 250px height. Rows are calculated in twips, and 1px = 15twips.');

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// Template processor instance creation // Template processor instance creation
@ -15,7 +14,7 @@ $templateProcessor->deleteBlock('DELETEME');
echo date('H:i:s'), ' Saving the result document...', EOL; echo date('H:i:s'), ' Saving the result document...', EOL;
$templateProcessor->saveAs('results/Sample_23_TemplateBlock.docx'); $templateProcessor->saveAs('results/Sample_23_TemplateBlock.docx');
echo getEndingNotes(['Word2007' => 'docx'], 'Sample_23_TemplateBlock'); echo getEndingNotes(array('Word2007' => 'docx'), 'Sample_23_TemplateBlock');
if (!CLI) { if (!CLI) {
include_once 'Sample_Footer.php'; include_once 'Sample_Footer.php';
} }

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// Read contents // Read contents

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word Document // New Word Document
@ -11,13 +10,13 @@ $section = $phpWord->addSection();
// In section // In section
$textbox = $section->addTextBox( $textbox = $section->addTextBox(
[ array(
'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER,
'width' => 400, 'width' => 400,
'height' => 150, 'height' => 150,
'borderSize' => 1, 'borderSize' => 1,
'borderColor' => '#FF0000', 'borderColor' => '#FF0000',
] )
); );
$textbox->addText('Text box content in section.'); $textbox->addText('Text box content in section.');
$textbox->addText('Another line.'); $textbox->addText('Another line.');
@ -27,19 +26,19 @@ $cell->addText('Table inside textbox');
// Inside table // Inside table
$section->addTextBreak(2); $section->addTextBreak(2);
$cell = $section->addTable()->addRow()->addCell(300); $cell = $section->addTable()->addRow()->addCell(300);
$textbox = $cell->addTextBox(['borderSize' => 1, 'borderColor' => '#0000FF', 'innerMargin' => 100]); $textbox = $cell->addTextBox(array('borderSize' => 1, 'borderColor' => '#0000FF', 'innerMargin' => 100));
$textbox->addText('Textbox inside table'); $textbox->addText('Textbox inside table');
// Inside header with textrun // Inside header with textrun
$header = $section->addHeader(); $header = $section->addHeader();
$textbox = $header->addTextBox(['width' => 600, 'borderSize' => 1, 'borderColor' => '#00FF00']); $textbox = $header->addTextBox(array('width' => 600, 'borderSize' => 1, 'borderColor' => '#00FF00'));
$textrun = $textbox->addTextRun(); $textrun = $textbox->addTextRun();
$textrun->addText('TextBox in header. TextBox can contain a TextRun '); $textrun->addText('TextBox in header. TextBox can contain a TextRun ');
$textrun->addText('with bold text', ['bold' => true]); $textrun->addText('with bold text', array('bold' => true));
$textrun->addText(', '); $textrun->addText(', ');
$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub'); $textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub');
$textrun->addText(', and image '); $textrun->addText(', and image ');
$textrun->addImage('resources/_earth.jpg', ['width' => 18, 'height' => 18]); $textrun->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18));
$textrun->addText('.'); $textrun->addText('.');
// Save file // Save file

View File

@ -1,11 +1,10 @@
<?php <?php
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;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->addParagraphStyle('Heading2', ['alignment' => 'center']); $phpWord->addParagraphStyle('Heading2', array('alignment' => 'center'));
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$html = '<h1>Adding element via HTML</h1>'; $html = '<h1>Adding element via HTML</h1>';

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\TextRun;
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
@ -7,7 +6,7 @@ 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;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
PhpOffice\PhpWord\Style::addTitleStyle(1, ['size' => 14]); PhpOffice\PhpWord\Style::addTitleStyle(1, array('size' => 14));
// New section // New section
$section = $phpWord->addSection(); $section = $phpWord->addSection();
@ -16,53 +15,53 @@ $section->addTitle('This page demos fields');
// Add Field elements // Add Field elements
// See Element/Field.php for all options // See Element/Field.php for all options
$section->addText('Date field:'); $section->addText('Date field:');
$section->addField('DATE', ['dateformat' => 'dddd d MMMM yyyy H:mm:ss'], ['PreserveFormat']); $section->addField('DATE', array('dateformat' => 'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat'));
$section->addText('Style Ref field:'); $section->addText('Style Ref field:');
$section->addField('STYLEREF', ['StyleIdentifier' => 'Heading 1']); $section->addField('STYLEREF', array('StyleIdentifier' => 'Heading 1'));
$section->addText('Page field:'); $section->addText('Page field:');
$section->addField('PAGE', ['format' => 'Arabic']); $section->addField('PAGE', array('format' => 'Arabic'));
$section->addText('Number of pages field:'); $section->addText('Number of pages field:');
$section->addField('NUMPAGES', ['numformat' => '0,00', 'format' => 'Arabic'], ['PreserveFormat']); $section->addField('NUMPAGES', array('numformat' => '0,00', 'format' => 'Arabic'), array('PreserveFormat'));
$section->addTextBreak(); $section->addTextBreak();
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();
$textrun->addText('An index field is '); $textrun->addText('An index field is ');
$textrun->addField('XE', [], ['Italic'], 'My first index'); $textrun->addField('XE', array(), array('Italic'), 'My first index');
$textrun->addText('here:'); $textrun->addText('here:');
$indexEntryText = new TextRun(); $indexEntryText = new TextRun();
$indexEntryText->addText('My '); $indexEntryText->addText('My ');
$indexEntryText->addText('bold index', ['bold' => true]); $indexEntryText->addText('bold index', array('bold' => true));
$indexEntryText->addText(' entry'); $indexEntryText->addText(' entry');
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();
$textrun->addText('A complex index field is '); $textrun->addText('A complex index field is ');
$textrun->addField('XE', [], ['Bold'], $indexEntryText); $textrun->addField('XE', array(), array('Bold'), $indexEntryText);
$textrun->addText('here:'); $textrun->addText('here:');
$section->addText('The actual index:'); $section->addText('The actual index:');
$section->addField('INDEX', [], ['\\e " "'], 'right click to update the index'); $section->addField('INDEX', array(), array('\\e " "'), 'right click to update the index');
$textrun = $section->addTextRun(['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 ');
$textrun->addField('DATE', ['dateformat' => 'd-M-yyyy H:mm:ss'], ['PreserveFormat', 'LunarCalendar']); $textrun->addField('DATE', array('dateformat' => 'd-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar'));
$textrun->addText(' written in a textrun.'); $textrun->addText(' written in a textrun.');
$section->addTextBreak(); $section->addTextBreak();
$macroText = new TextRun(); $macroText = new TextRun();
$macroText->addText('Double click', ['bold' => true]); $macroText->addText('Double click', array('bold' => true));
$macroText->addText(' to '); $macroText->addText(' to ');
$macroText->addText('zoom to 100%', ['italic' => true]); $macroText->addText('zoom to 100%', array('italic' => true));
$section->addText('A macro button with styled text:'); $section->addText('A macro button with styled text:');
$section->addField('MACROBUTTON', ['macroname' => 'Zoom100'], [], $macroText); $section->addField('MACROBUTTON', array('macroname' => 'Zoom100'), array(), $macroText);
$section->addTextBreak(); $section->addTextBreak();
$section->addText('A macro button with simple text:'); $section->addText('A macro button with simple text:');
$section->addField('MACROBUTTON', ['macroname' => 'Zoom100'], [], 'double click to zoom'); $section->addField('MACROBUTTON', array('macroname' => 'Zoom100'), array(), 'double click to zoom');
// Save file // Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers); echo write($phpWord, basename(__FILE__, '.php'), $writers);

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// Read contents // Read contents

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -13,49 +12,49 @@ $section = $phpWord->addSection();
// See Element/Line.php for all options // See Element/Line.php for all options
$section->addText('Horizontal Line (Inline style):'); $section->addText('Horizontal Line (Inline style):');
$section->addLine( $section->addLine(
[ array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
'positioning' => 'absolute', 'positioning' => 'absolute',
] )
); );
$section->addText('Vertical Line (Inline style):'); $section->addText('Vertical Line (Inline style):');
$section->addLine( $section->addLine(
[ array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1),
'positioning' => 'absolute', 'positioning' => 'absolute',
] )
); );
// Two text break // Two text break
$section->addTextBreak(1); $section->addTextBreak(1);
$section->addText('Positioned Line (red):'); $section->addText('Positioned Line (red):');
$section->addLine( $section->addLine(
[ array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1),
'positioning' => 'absolute', 'positioning' => 'absolute',
'posHorizontalRel' => 'page', 'posHorizontalRel' => 'page',
'posVerticalRel' => 'page', 'posVerticalRel' => 'page',
'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(10), 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(10),
'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(8), 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(8),
'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE, 'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE,
'color' => 'red', 'color' => 'red',
] )
); );
$section->addText('Horizontal Formatted Line'); $section->addText('Horizontal Formatted Line');
$section->addLine( $section->addLine(
[ array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
'positioning' => 'absolute', 'positioning' => 'absolute',
'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK, 'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK,
'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL, 'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL,
'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT, 'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT,
'weight' => 10, 'weight' => 10,
] )
); );
// Save file // Save file

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// Read contents // Read contents

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -10,85 +9,85 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection(); $section = $phpWord->addSection();
// Define styles // Define styles
$phpWord->addTitleStyle(1, ['size' => 14, 'bold' => true]); $phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true));
// Arc // Arc
$section->addTitle('Arc', 1); $section->addTitle('Arc', 1);
$section->addShape( $section->addShape(
'arc', 'arc',
[ array(
'points' => '-90 20', 'points' => '-90 20',
'frame' => ['width' => 120, 'height' => 120], 'frame' => array('width' => 120, 'height' => 120),
'outline' => ['color' => '#333333', 'weight' => 2, 'startArrow' => 'oval', 'endArrow' => 'open'], 'outline' => array('color' => '#333333', 'weight' => 2, 'startArrow' => 'oval', 'endArrow' => 'open'),
] )
); );
// Curve // Curve
$section->addTitle('Curve', 1); $section->addTitle('Curve', 1);
$section->addShape( $section->addShape(
'curve', 'curve',
[ array(
'points' => '1,100 200,1 1,50 200,50', 'points' => '1,100 200,1 1,50 200,50',
'connector' => 'elbow', 'connector' => 'elbow',
'outline' => [ 'outline' => array(
'color' => '#66cc00', 'color' => '#66cc00',
'weight' => 2, 'weight' => 2,
'dash' => 'dash', 'dash' => 'dash',
'startArrow' => 'diamond', 'startArrow' => 'diamond',
'endArrow' => 'block', 'endArrow' => 'block',
], ),
] )
); );
// Line // Line
$section->addTitle('Line', 1); $section->addTitle('Line', 1);
$section->addShape( $section->addShape(
'line', 'line',
[ array(
'points' => '1,1 150,30', 'points' => '1,1 150,30',
'outline' => [ 'outline' => array(
'color' => '#cc00ff', 'color' => '#cc00ff',
'line' => 'thickThin', 'line' => 'thickThin',
'weight' => 3, 'weight' => 3,
'startArrow' => 'oval', 'startArrow' => 'oval',
'endArrow' => 'classic', 'endArrow' => 'classic',
], ),
] )
); );
// Polyline // Polyline
$section->addTitle('Polyline', 1); $section->addTitle('Polyline', 1);
$section->addShape( $section->addShape(
'polyline', 'polyline',
[ array(
'points' => '1,30 20,10 55,20 75,10 100,40 115,50, 120,15 200,50', 'points' => '1,30 20,10 55,20 75,10 100,40 115,50, 120,15 200,50',
'outline' => ['color' => '#cc6666', 'weight' => 2, 'startArrow' => 'none', 'endArrow' => 'classic'], 'outline' => array('color' => '#cc6666', 'weight' => 2, 'startArrow' => 'none', 'endArrow' => 'classic'),
] )
); );
// Rectangle // Rectangle
$section->addTitle('Rectangle', 1); $section->addTitle('Rectangle', 1);
$section->addShape( $section->addShape(
'rect', 'rect',
[ array(
'roundness' => 0.2, 'roundness' => 0.2,
'frame' => ['width' => 100, 'height' => 100, 'left' => 1, 'top' => 1], 'frame' => array('width' => 100, 'height' => 100, 'left' => 1, 'top' => 1),
'fill' => ['color' => '#FFCC33'], 'fill' => array('color' => '#FFCC33'),
'outline' => ['color' => '#990000', 'weight' => 1], 'outline' => array('color' => '#990000', 'weight' => 1),
'shadow' => [], 'shadow' => array(),
] )
); );
// Oval // Oval
$section->addTitle('Oval', 1); $section->addTitle('Oval', 1);
$section->addShape( $section->addShape(
'oval', 'oval',
[ array(
'frame' => ['width' => 100, 'height' => 70, 'left' => 1, 'top' => 1], 'frame' => array('width' => 100, 'height' => 70, 'left' => 1, 'top' => 1),
'fill' => ['color' => '#33CC99'], 'fill' => array('color' => '#33CC99'),
'outline' => ['color' => '#333333', 'weight' => 2], 'outline' => array('color' => '#333333', 'weight' => 2),
'extrusion' => [], 'extrusion' => array(),
] )
); );
// Save file // Save file

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
use PhpOffice\PhpWord\Shared\Converter; use PhpOffice\PhpWord\Shared\Converter;
@ -9,21 +8,21 @@ echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Define styles // Define styles
$phpWord->addTitleStyle(1, ['size' => 14, 'bold' => true], ['keepNext' => true, 'spaceBefore' => 240]); $phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240));
$phpWord->addTitleStyle(2, ['size' => 14, 'bold' => true], ['keepNext' => true, 'spaceBefore' => 240]); $phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240));
// 2D charts // 2D charts
$section = $phpWord->addSection(); $section = $phpWord->addSection();
$section->addTitle('2D charts', 1); $section->addTitle('2D charts', 1);
$section = $phpWord->addSection(['colsNum' => 2, 'breakType' => 'continuous']); $section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous'));
$chartTypes = ['pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column']; $chartTypes = array('pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column');
$twoSeries = ['bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column']; $twoSeries = array('bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column');
$threeSeries = ['bar', 'line']; $threeSeries = array('bar', 'line');
$categories = ['A', 'B', 'C', 'D', 'E']; $categories = array('A', 'B', 'C', 'D', 'E');
$series1 = [1, 3, 2, 5, 4]; $series1 = array(1, 3, 2, 5, 4);
$series2 = [3, 1, 7, 2, 6]; $series2 = array(3, 1, 7, 2, 6);
$series3 = [8, 3, 2, 5, 4]; $series3 = array(8, 3, 2, 5, 4);
$showGridLines = false; $showGridLines = false;
$showAxisLabels = false; $showAxisLabels = false;
$showLegend = true; $showLegend = true;
@ -49,20 +48,20 @@ foreach ($chartTypes as $chartType) {
} }
// 3D charts // 3D charts
$section = $phpWord->addSection(['breakType' => 'continuous']); $section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addTitle('3D charts', 1); $section->addTitle('3D charts', 1);
$section = $phpWord->addSection(['colsNum' => 2, 'breakType' => 'continuous']); $section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous'));
$chartTypes = ['pie', 'bar', 'column', 'line', 'area']; $chartTypes = array('pie', 'bar', 'column', 'line', 'area');
$multiSeries = ['bar', 'column', 'line', 'area']; $multiSeries = array('bar', 'column', 'line', 'area');
$style = [ $style = array(
'width' => Converter::cmToEmu(5), 'width' => Converter::cmToEmu(5),
'height' => Converter::cmToEmu(4), 'height' => Converter::cmToEmu(4),
'3d' => true, '3d' => true,
'showAxisLabels' => $showAxisLabels, 'showAxisLabels' => $showAxisLabels,
'showGridX' => $showGridLines, 'showGridX' => $showGridLines,
'showGridY' => $showGridLines, 'showGridY' => $showGridLines,
]; );
foreach ($chartTypes as $chartType) { foreach ($chartTypes as $chartType) {
$section->addTitle(ucfirst($chartType), 2); $section->addTitle(ucfirst($chartType), 2);
$chart = $section->addChart($chartType, $categories, $series1, $style); $chart = $section->addChart($chartType, $categories, $series1, $style);

View File

@ -1,11 +1,10 @@
<?php <?php
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;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->getSettings()->getDocumentProtection()->setEditing('forms'); $phpWord->getProtection()->setEditing('forms');
// New section // New section
$section = $phpWord->addSection(); $section = $phpWord->addSection();
@ -16,7 +15,7 @@ $textrun->addFormField('textinput')->setName('MyTextBox');
$textrun->addText(', checkbox '); $textrun->addText(', checkbox ');
$textrun->addFormField('checkbox')->setDefault(true); $textrun->addFormField('checkbox')->setDefault(true);
$textrun->addText(', or dropdown '); $textrun->addText(', or dropdown ');
$textrun->addFormField('dropdown')->setEntries(['Choice 1', 'Choice 2', 'Choice 3']); $textrun->addFormField('dropdown')->setEntries(array('Choice 1', 'Choice 2', 'Choice 3'));
$textrun->addText('. You have to set document protection to "forms" to enable dropdown.'); $textrun->addText('. You have to set document protection to "forms" to enable dropdown.');
$section->addText('They can also be added as a stand alone paragraph.'); $section->addText('They can also be added as a stand alone paragraph.');

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -11,7 +10,7 @@ $section = $phpWord->addSection();
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();
$textrun->addText('Combobox: '); $textrun->addText('Combobox: ');
$textrun->addSDT('comboBox')->setListItems(['1' => 'Choice 1', '2' => 'Choice 2']); $textrun->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();
$textrun->addText('Date: '); $textrun->addText('Date: ');
@ -25,7 +24,7 @@ $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(['1' => 'Choice 1', '2' => 'Choice 2'])->setValue('Choice 1'); $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);

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word document // New Word document
@ -12,17 +11,17 @@ $section = $phpWord->addSection();
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();
$textrun->addText('This is a Left to Right paragraph.'); $textrun->addText('This is a Left to Right paragraph.');
$textrun = $section->addTextRun(['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END]); $textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END));
$textrun->addText('سلام این یک پاراگراف راست به چپ است', ['rtl' => true]); $textrun->addText('سلام این یک پاراگراف راست به چپ است', array('rtl' => true));
$section->addText('Table visually presented as RTL'); $section->addText('Table visually presented as RTL');
$style = ['rtl' => true, 'size' => 12]; $style = array('rtl' => true, 'size' => 12);
$tableStyle = ['borderSize' => 6, 'borderColor' => '000000', 'width' => 5000, 'unit' => \PhpOffice\PhpWord\SimpleType\TblWidth::PERCENT, 'bidiVisual' => true]; $tableStyle = array('borderSize' => 6, 'borderColor' => '000000', 'width' => 5000, 'unit' => \PhpOffice\PhpWord\SimpleType\TblWidth::PERCENT, 'bidiVisual' => true);
$table = $section->addTable($tableStyle); $table = $section->addTable($tableStyle);
$cellHCentered = ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER]; $cellHCentered = array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER);
$cellHEnd = ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END]; $cellHEnd = array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END);
$cellVCentered = ['valign' => \PhpOffice\PhpWord\SimpleType\VerticalJc::CENTER]; $cellVCentered = array('valign' => \PhpOffice\PhpWord\Style\Cell::VALIGN_CENTER);
//Vidually bidirectinal table //Vidually bidirectinal table
$table->addRow(); $table->addRow();

View File

@ -1,5 +1,4 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// New Word Document // New Word Document
@ -8,7 +7,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
// A comment // A comment
$comment = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials'); $comment = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
$comment->addText('Test', ['bold' => true]); $comment->addText('Test', array('bold' => true));
$phpWord->addComment($comment); $phpWord->addComment($comment);
$section = $phpWord->addSection(); $section = $phpWord->addSection();
@ -28,9 +27,9 @@ $phpWord->addComment($commentWithStartAndEnd);
$textrunWithEnd = $section->addTextRun(); $textrunWithEnd = $section->addTextRun();
$textrunWithEnd->addText('This '); $textrunWithEnd->addText('This ');
$textToStartOn = $textrunWithEnd->addText('is', ['bold' => true]); $textToStartOn = $textrunWithEnd->addText('is', array('bold' => true));
$textToStartOn->setCommentRangeStart($commentWithStartAndEnd); $textToStartOn->setCommentRangeStart($commentWithStartAndEnd);
$textrunWithEnd->addText(' another', ['italic' => true]); $textrunWithEnd->addText(' another', array('italic' => true));
$textToEndOn = $textrunWithEnd->addText(' test'); $textToEndOn = $textrunWithEnd->addText(' test');
$textToEndOn->setCommentRangeEnd($commentWithStartAndEnd); $textToEndOn->setCommentRangeEnd($commentWithStartAndEnd);
@ -40,7 +39,7 @@ $section->addTextBreak(2);
$commentOnImage = new \PhpOffice\PhpWord\Element\Comment('Mr Smart', new \DateTime()); $commentOnImage = new \PhpOffice\PhpWord\Element\Comment('Mr Smart', new \DateTime());
$imageComment = $commentOnImage->addTextRun(); $imageComment = $commentOnImage->addTextRun();
$imageComment->addText('Hey, Mars does look '); $imageComment->addText('Hey, Mars does look ');
$imageComment->addText('red', ['color' => 'FF0000']); $imageComment->addText('red', array('color' => 'FF0000'));
$phpWord->addComment($commentOnImage); $phpWord->addComment($commentOnImage);
$image = $section->addImage('resources/_mars.jpg'); $image = $section->addImage('resources/_mars.jpg');
$image->setCommentRangeStart($commentOnImage); $image->setCommentRangeStart($commentOnImage);
@ -51,7 +50,7 @@ $section->addTextBreak(2);
$anotherText = $section->addText('another text'); $anotherText = $section->addText('another text');
$comment1 = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials'); $comment1 = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
$comment1->addText('Test', ['bold' => true]); $comment1->addText('Test', array('bold' => true));
$comment1->setStartElement($anotherText); $comment1->setStartElement($anotherText);
$comment1->setEndElement($anotherText); $comment1->setEndElement($anotherText);
$phpWord->addComment($comment1); $phpWord->addComment($comment1);

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\SimpleType\DocProtect; use PhpOffice\PhpWord\SimpleType\DocProtect;
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\Element\TrackChange; use PhpOffice\PhpWord\Element\TrackChange;
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
@ -14,7 +13,7 @@ $textRun = $section->addTextRun();
$text = $textRun->addText('Hello World! Time to '); $text = $textRun->addText('Hello World! Time to ');
$text = $textRun->addText('wake ', ['bold' => true]); $text = $textRun->addText('wake ', array('bold' => true));
$text->setChangeInfo(TrackChange::INSERTED, 'Fred', time() - 1800); $text->setChangeInfo(TrackChange::INSERTED, 'Fred', time() - 1800);
$text = $textRun->addText('up'); $text = $textRun->addText('up');

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\Element\Field; use PhpOffice\PhpWord\Element\Field;
use PhpOffice\PhpWord\Element\Table; use PhpOffice\PhpWord\Element\Table;
use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\TextRun;
@ -12,15 +11,15 @@ echo date('H:i:s'), ' Creating new TemplateProcessor instance...', EOL;
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_40_TemplateSetComplexValue.docx'); $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_40_TemplateSetComplexValue.docx');
$title = new TextRun(); $title = new TextRun();
$title->addText('This title has been set ', ['bold' => true, 'italic' => true, 'color' => 'blue']); $title->addText('This title has been set ', array('bold' => true, 'italic' => true, 'color' => 'blue'));
$title->addText('dynamically', ['bold' => true, 'italic' => true, 'color' => 'red', 'underline' => 'single']); $title->addText('dynamically', array('bold' => true, 'italic' => true, 'color' => 'red', 'underline' => 'single'));
$templateProcessor->setComplexBlock('title', $title); $templateProcessor->setComplexBlock('title', $title);
$inline = new TextRun(); $inline = new TextRun();
$inline->addText('by a red italic text', ['italic' => true, 'color' => 'red']); $inline->addText('by a red italic text', array('italic' => true, 'color' => 'red'));
$templateProcessor->setComplexValue('inline', $inline); $templateProcessor->setComplexValue('inline', $inline);
$table = new Table(['borderSize' => 12, 'borderColor' => 'green', 'width' => 6000, 'unit' => TblWidth::TWIP]); $table = new Table(array('borderSize' => 12, 'borderColor' => 'green', 'width' => 6000, 'unit' => TblWidth::TWIP));
$table->addRow(); $table->addRow();
$table->addCell(150)->addText('Cell A1'); $table->addCell(150)->addText('Cell A1');
$table->addCell(150)->addText('Cell A2'); $table->addCell(150)->addText('Cell A2');
@ -31,7 +30,7 @@ $table->addCell(150)->addText('Cell B2');
$table->addCell(150)->addText('Cell B3'); $table->addCell(150)->addText('Cell B3');
$templateProcessor->setComplexBlock('table', $table); $templateProcessor->setComplexBlock('table', $table);
$field = new Field('DATE', ['dateformat' => 'dddd d MMMM yyyy H:mm:ss'], ['PreserveFormat']); $field = new Field('DATE', array('dateformat' => 'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat'));
$templateProcessor->setComplexValue('field', $field); $templateProcessor->setComplexValue('field', $field);
// $link = new Link('https://github.com/PHPOffice/PHPWord'); // $link = new Link('https://github.com/PHPOffice/PHPWord');
@ -40,7 +39,7 @@ $templateProcessor->setComplexValue('field', $field);
echo date('H:i:s'), ' Saving the result document...', EOL; echo date('H:i:s'), ' Saving the result document...', EOL;
$templateProcessor->saveAs('results/Sample_40_TemplateSetComplexValue.docx'); $templateProcessor->saveAs('results/Sample_40_TemplateSetComplexValue.docx');
echo getEndingNotes(['Word2007' => 'docx'], 'results/Sample_40_TemplateSetComplexValue.docx'); echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_40_TemplateSetComplexValue.docx');
if (!CLI) { if (!CLI) {
include_once 'Sample_Footer.php'; include_once 'Sample_Footer.php';
} }

View File

@ -1,5 +1,4 @@
<?php <?php
use PhpOffice\PhpWord\Element\Chart; use PhpOffice\PhpWord\Element\Chart;
use PhpOffice\PhpWord\Shared\Converter; use PhpOffice\PhpWord\Shared\Converter;
@ -9,14 +8,14 @@ include_once 'Sample_Header.php';
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_41_TemplateSetChart.docx'); $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_41_TemplateSetChart.docx');
$chartTypes = ['pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column']; $chartTypes = array('pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column');
$twoSeries = ['bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column']; $twoSeries = array('bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column');
$threeSeries = ['bar', 'line']; $threeSeries = array('bar', 'line');
$categories = ['A', 'B', 'C', 'D', 'E']; $categories = array('A', 'B', 'C', 'D', 'E');
$series1 = [1, 3, 2, 5, 4]; $series1 = array(1, 3, 2, 5, 4);
$series2 = [3, 1, 7, 2, 6]; $series2 = array(3, 1, 7, 2, 6);
$series3 = [8, 3, 2, 5, 4]; $series3 = array(8, 3, 2, 5, 4);
$i = 0; $i = 0;
foreach ($chartTypes as $chartType) { foreach ($chartTypes as $chartType) {
@ -34,13 +33,13 @@ foreach ($chartTypes as $chartType) {
->setHeight(Converter::inchToEmu(3)); ->setHeight(Converter::inchToEmu(3));
$templateProcessor->setChart("chart{$i}", $chart); $templateProcessor->setChart("chart{$i}", $chart);
++$i; $i++;
} }
echo date('H:i:s'), ' Saving the result document...', EOL; echo date('H:i:s'), ' Saving the result document...', EOL;
$templateProcessor->saveAs('results/Sample_41_TemplateSetChart.docx'); $templateProcessor->saveAs('results/Sample_41_TemplateSetChart.docx');
echo getEndingNotes(['Word2007' => 'docx'], 'results/Sample_41_TemplateSetChart.docx'); echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_41_TemplateSetChart.docx');
if (!CLI) { if (!CLI) {
include_once 'Sample_Footer.php'; include_once 'Sample_Footer.php';
} }

View File

@ -19,7 +19,7 @@ if (file_exists($dompdfPath)) {
} }
// Set writers // Set writers
$writers = ['Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf']; $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf');
// Set PDF renderer // Set PDF renderer
if (null === Settings::getPdfRendererPath()) { if (null === Settings::getPdfRendererPath()) {
@ -43,7 +43,7 @@ $pageHeading = IS_INDEX ? '' : "<h1>{$pageHeading}</h1>";
// Populate samples // Populate samples
$files = ''; $files = '';
if ($handle = opendir('.')) { if ($handle = opendir('.')) {
$sampleFiles = []; $sampleFiles = array();
while (false !== ($sampleFile = readdir($handle))) { while (false !== ($sampleFile = readdir($handle))) {
$sampleFiles[] = $sampleFile; $sampleFiles[] = $sampleFile;
} }
@ -59,7 +59,7 @@ if ($handle = opendir('.')) {
} }
/** /**
* Write documents. * Write documents
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @param string $filename * @param string $filename
@ -89,11 +89,10 @@ function write($phpWord, $filename, $writers)
} }
/** /**
* Get ending notes. * Get ending notes
* *
* @param array $writers * @param array $writers
* @param mixed $filename * @param mixed $filename
*
* @return string * @return string
*/ */
function getEndingNotes($writers, $filename) function getEndingNotes($writers, $filename)
@ -115,7 +114,7 @@ function getEndingNotes($writers, $filename)
$result .= '<p>&nbsp;</p>'; $result .= '<p>&nbsp;</p>';
$result .= '<p>Results: '; $result .= '<p>Results: ';
foreach ($types as $type) { foreach ($types as $type) {
if (null !== $type) { if (!is_null($type)) {
$resultFile = 'results/' . SCRIPT_FILENAME . '.' . $type; $resultFile = 'results/' . SCRIPT_FILENAME . '.' . $type;
if (file_exists($resultFile)) { if (file_exists($resultFile)) {
$result .= "<a href='{$resultFile}' class='btn btn-primary'>{$type}</a> "; $result .= "<a href='{$resultFile}' class='btn btn-primary'>{$type}</a> ";

View File

@ -3,15 +3,15 @@ include_once 'Sample_Header.php';
use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Settings;
$requirements = [ $requirements = array(
'php' => ['PHP 7.1', version_compare(PHP_VERSION, '7.1', '>=')], 'php' => array('PHP 5.3.3', version_compare(PHP_VERSION, '5.3.3', '>=')),
'xml' => ['PHP extension XML', extension_loaded('xml')], 'xml' => array('PHP extension XML', extension_loaded('xml')),
'temp' => ['Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())], 'temp' => array('Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())),
'zip' => ['PHP extension ZipArchive (optional)', extension_loaded('zip')], 'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')),
'gd' => ['PHP extension GD (optional)', extension_loaded('gd')], 'gd' => array('PHP extension GD (optional)', extension_loaded('gd')),
'xmlw' => ['PHP extension XMLWriter (optional)', extension_loaded('xmlwriter')], 'xmlw' => array('PHP extension XMLWriter (optional)', extension_loaded('xmlwriter')),
'xsl' => ['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">
@ -28,7 +28,7 @@ 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) {
[$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>";
} }
@ -37,7 +37,7 @@ if (!CLI) {
} else { } else {
echo 'Requirement check:' . PHP_EOL; echo 'Requirement check:' . PHP_EOL;
foreach ($requirements as $key => $value) { foreach ($requirements as $key => $value) {
[$label, $result] = $value; list($label, $result) = $value;
$label = strip_tags($label); $label = strip_tags($label);
$status = $result ? '32m passed' : '31m failed'; $status = $result ? '32m passed' : '31m failed';
echo "{$label} ... \033[{$status}\033[0m" . PHP_EOL; echo "{$label} ... \033[{$status}\033[0m" . PHP_EOL;

View File

@ -11,28 +11,28 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**
* Collection abstract class. * Collection abstract class
* *
* @since 0.10.0 * @since 0.10.0
*/ */
abstract class AbstractCollection abstract class AbstractCollection
{ {
/** /**
* Items. * Items
* *
* @var \PhpOffice\PhpWord\Element\AbstractContainer[] * @var \PhpOffice\PhpWord\Element\AbstractContainer[]
*/ */
private $items = []; private $items = array();
/** /**
* Get items. * Get items
* *
* @return \PhpOffice\PhpWord\Element\AbstractContainer[] * @return \PhpOffice\PhpWord\Element\AbstractContainer[]
*/ */
@ -42,10 +42,9 @@ abstract class AbstractCollection
} }
/** /**
* Get item by index. * Get item by index
* *
* @param int $index * @param int $index
*
* @return \PhpOffice\PhpWord\Element\AbstractContainer * @return \PhpOffice\PhpWord\Element\AbstractContainer
*/ */
public function getItem($index) public function getItem($index)
@ -63,7 +62,7 @@ abstract class AbstractCollection
* @param int $index * @param int $index
* @param \PhpOffice\PhpWord\Element\AbstractContainer $item * @param \PhpOffice\PhpWord\Element\AbstractContainer $item
*/ */
public function setItem($index, $item): void public function setItem($index, $item)
{ {
if (array_key_exists($index, $this->items)) { if (array_key_exists($index, $this->items)) {
$this->items[$index] = $item; $this->items[$index] = $item;
@ -71,10 +70,9 @@ abstract class AbstractCollection
} }
/** /**
* Add new item. * Add new item
* *
* @param \PhpOffice\PhpWord\Element\AbstractContainer $item * @param \PhpOffice\PhpWord\Element\AbstractContainer $item
*
* @return int * @return int
*/ */
public function addItem($item) public function addItem($item)
@ -86,7 +84,7 @@ abstract class AbstractCollection
} }
/** /**
* Get item count. * Get item count
* *
* @return int * @return int
*/ */

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**
* Bookmarks collection. * Bookmarks collection
* *
* @since 0.12.0 * @since 0.12.0
*/ */

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**
* Charts collection. * Charts collection
* *
* @since 0.12.0 * @since 0.12.0
*/ */

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**
* Comments collection. * Comments collection
* *
* @since 0.12.0 * @since 0.12.0
*/ */

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**
* Endnotes collection. * Endnotes collection
* *
* @since 0.10.0 * @since 0.10.0
*/ */

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**
* Footnotes collection. * Footnotes collection
* *
* @since 0.10.0 * @since 0.10.0
*/ */

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**
* Titles collection. * Titles collection
* *
* @since 0.10.0 * @since 0.10.0
*/ */

View File

@ -11,17 +11,16 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\ComplexType; namespace PhpOffice\PhpWord\ComplexType;
use InvalidArgumentException;
use PhpOffice\PhpWord\SimpleType\NumberFormat; use PhpOffice\PhpWord\SimpleType\NumberFormat;
/** /**
* Footnote properties. * Footnote properties
* *
* @see http://www.datypic.com/sc/ooxml/e-w_footnotePr-1.html * @see http://www.datypic.com/sc/ooxml/e-w_footnotePr-1.html
*/ */
@ -37,35 +36,35 @@ final class FootnoteProperties
const POSITION_DOC_END = 'docEnd'; const POSITION_DOC_END = 'docEnd';
/** /**
* Footnote Positioning Location. * Footnote Positioning Location
* *
* @var string * @var string
*/ */
private $pos; private $pos;
/** /**
* Footnote Numbering Format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat. * Footnote Numbering Format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat
* *
* @var string * @var string
*/ */
private $numFmt; private $numFmt;
/** /**
* Footnote and Endnote Numbering Starting Value. * Footnote and Endnote Numbering Starting Value
* *
* @var float * @var float
*/ */
private $numStart; private $numStart;
/** /**
* Footnote and Endnote Numbering Restart Location. * Footnote and Endnote Numbering Restart Location
* *
* @var string * @var string
*/ */
private $numRestart; private $numRestart;
/** /**
* Get the Footnote Positioning Location. * Get the Footnote Positioning Location
* *
* @return string * @return string
*/ */
@ -75,32 +74,32 @@ final class FootnoteProperties
} }
/** /**
* Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd). * Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd)
* *
* @param string $pos * @param string $pos
* * @throws \InvalidArgumentException
* @return self * @return self
*/ */
public function setPos($pos) public function setPos($pos)
{ {
$position = [ $position = array(
self::POSITION_PAGE_BOTTOM, self::POSITION_PAGE_BOTTOM,
self::POSITION_BENEATH_TEXT, self::POSITION_BENEATH_TEXT,
self::POSITION_SECTION_END, self::POSITION_SECTION_END,
self::POSITION_DOC_END, self::POSITION_DOC_END,
]; );
if (in_array($pos, $position)) { if (in_array($pos, $position)) {
$this->pos = $pos; $this->pos = $pos;
} else { } else {
throw new InvalidArgumentException('Invalid value, on of ' . implode(', ', $position) . ' possible'); throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $position) . ' possible');
} }
return $this; return $this;
} }
/** /**
* Get the Footnote Numbering Format. * Get the Footnote Numbering Format
* *
* @return string * @return string
*/ */
@ -110,10 +109,9 @@ final class FootnoteProperties
} }
/** /**
* Set the Footnote Numbering Format. * Set the Footnote Numbering Format
* *
* @param string $numFmt One of NumberFormat * @param string $numFmt One of NumberFormat
*
* @return self * @return self
*/ */
public function setNumFmt($numFmt) public function setNumFmt($numFmt)
@ -125,7 +123,7 @@ final class FootnoteProperties
} }
/** /**
* Get the Footnote Numbering Format. * Get the Footnote Numbering Format
* *
* @return float * @return float
*/ */
@ -135,10 +133,9 @@ final class FootnoteProperties
} }
/** /**
* Set the Footnote Numbering Format. * Set the Footnote Numbering Format
* *
* @param float $numStart * @param float $numStart
*
* @return self * @return self
*/ */
public function setNumStart($numStart) public function setNumStart($numStart)
@ -149,7 +146,7 @@ final class FootnoteProperties
} }
/** /**
* Get the Footnote and Endnote Numbering Starting Value. * Get the Footnote and Endnote Numbering Starting Value
* *
* @return string * @return string
*/ */
@ -159,24 +156,24 @@ final class FootnoteProperties
} }
/** /**
* Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage). * Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage)
* *
* @param string $numRestart * @param string $numRestart
* * @throws \InvalidArgumentException
* @return self * @return self
*/ */
public function setNumRestart($numRestart) public function setNumRestart($numRestart)
{ {
$restartNumbers = [ $restartNumbers = array(
self::RESTART_NUMBER_CONTINUOUS, self::RESTART_NUMBER_CONTINUOUS,
self::RESTART_NUMBER_EACH_SECTION, self::RESTART_NUMBER_EACH_SECTION,
self::RESTART_NUMBER_EACH_PAGE, self::RESTART_NUMBER_EACH_PAGE,
]; );
if (in_array($numRestart, $restartNumbers)) { if (in_array($numRestart, $restartNumbers)) {
$this->numRestart = $numRestart; $this->numRestart = $numRestart;
} else { } else {
throw new InvalidArgumentException('Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible'); throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible');
} }
return $this; return $this;

View File

@ -11,50 +11,48 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\ComplexType; namespace PhpOffice\PhpWord\ComplexType;
use InvalidArgumentException;
/** /**
* Spelling and Grammatical Checking State. * Spelling and Grammatical Checking State
* *
* @see http://www.datypic.com/sc/ooxml/e-w_proofState-1.html * @see http://www.datypic.com/sc/ooxml/e-w_proofState-1.html
*/ */
final class ProofState final class ProofState
{ {
/** /**
* Check Completed. * Check Completed
*/ */
const CLEAN = 'clean'; const CLEAN = 'clean';
/** /**
* Check Not Completed. * Check Not Completed
*/ */
const DIRTY = 'dirty'; const DIRTY = 'dirty';
/** /**
* Spell Checking State. * Spell Checking State
* *
* @var string * @var string
*/ */
private $spelling; private $spelling;
/** /**
* Grammatical Checking State. * Grammatical Checking State
* *
* @var string * @var string
*/ */
private $grammar; private $grammar;
/** /**
* Set the Spell Checking State (dirty or clean). * Set the Spell Checking State (dirty or clean)
* *
* @param string $spelling * @param string $spelling
* * @throws \InvalidArgumentException
* @return self * @return self
*/ */
public function setSpelling($spelling) public function setSpelling($spelling)
@ -62,14 +60,14 @@ final class ProofState
if ($spelling == self::CLEAN || $spelling == self::DIRTY) { if ($spelling == self::CLEAN || $spelling == self::DIRTY) {
$this->spelling = $spelling; $this->spelling = $spelling;
} else { } else {
throw new InvalidArgumentException('Invalid value, dirty or clean possible'); throw new \InvalidArgumentException('Invalid value, dirty or clean possible');
} }
return $this; return $this;
} }
/** /**
* Get the Spell Checking State. * Get the Spell Checking State
* *
* @return string * @return string
*/ */
@ -79,10 +77,10 @@ final class ProofState
} }
/** /**
* Set the Grammatical Checking State (dirty or clean). * Set the Grammatical Checking State (dirty or clean)
* *
* @param string $grammar * @param string $grammar
* * @throws \InvalidArgumentException
* @return self * @return self
*/ */
public function setGrammar($grammar) public function setGrammar($grammar)
@ -90,14 +88,14 @@ final class ProofState
if ($grammar == self::CLEAN || $grammar == self::DIRTY) { if ($grammar == self::CLEAN || $grammar == self::DIRTY) {
$this->grammar = $grammar; $this->grammar = $grammar;
} else { } else {
throw new InvalidArgumentException('Invalid value, dirty or clean possible'); throw new \InvalidArgumentException('Invalid value, dirty or clean possible');
} }
return $this; return $this;
} }
/** /**
* Get the Grammatical Checking State. * Get the Grammatical Checking State
* *
* @return string * @return string
*/ */

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */

View File

@ -11,56 +11,56 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\ComplexType; namespace PhpOffice\PhpWord\ComplexType;
/** /**
* Visibility of Annotation Types. * Visibility of Annotation Types
* *
* @see http://www.datypic.com/sc/ooxml/e-w_revisionView-1.html * @see http://www.datypic.com/sc/ooxml/e-w_revisionView-1.html
*/ */
final class TrackChangesView final class TrackChangesView
{ {
/** /**
* Display Visual Indicator Of Markup Area. * Display Visual Indicator Of Markup Area
* *
* @var bool * @var bool
*/ */
private $markup; private $markup;
/** /**
* Display Comments. * Display Comments
* *
* @var bool * @var bool
*/ */
private $comments; private $comments;
/** /**
* Display Content Revisions. * Display Content Revisions
* *
* @var bool * @var bool
*/ */
private $insDel; private $insDel;
/** /**
* Display Formatting Revisions. * Display Formatting Revisions
* *
* @var bool * @var bool
*/ */
private $formatting; private $formatting;
/** /**
* Display Ink Annotations. * Display Ink Annotations
* *
* @var bool * @var bool
*/ */
private $inkAnnotations; private $inkAnnotations;
/** /**
* Get Display Visual Indicator Of Markup Area. * Get Display Visual Indicator Of Markup Area
* *
* @return bool True if markup is shown * @return bool True if markup is shown
*/ */
@ -70,18 +70,18 @@ final class TrackChangesView
} }
/** /**
* Set Display Visual Indicator Of Markup Area. * Set Display Visual Indicator Of Markup Area
* *
* @param bool $markup * @param bool $markup
* Set to true to show markup * Set to true to show markup
*/ */
public function setMarkup($markup): void public function setMarkup($markup)
{ {
$this->markup = $markup === null ? true : $markup; $this->markup = $markup === null ? true : $markup;
} }
/** /**
* Get Display Comments. * Get Display Comments
* *
* @return bool True if comments are shown * @return bool True if comments are shown
*/ */
@ -91,18 +91,18 @@ final class TrackChangesView
} }
/** /**
* Set Display Comments. * Set Display Comments
* *
* @param bool $comments * @param bool $comments
* Set to true to show comments * Set to true to show comments
*/ */
public function setComments($comments): void public function setComments($comments)
{ {
$this->comments = $comments === null ? true : $comments; $this->comments = $comments === null ? true : $comments;
} }
/** /**
* Get Display Content Revisions. * Get Display Content Revisions
* *
* @return bool True if content revisions are shown * @return bool True if content revisions are shown
*/ */
@ -112,18 +112,18 @@ final class TrackChangesView
} }
/** /**
* Set Display Content Revisions. * Set Display Content Revisions
* *
* @param bool $insDel * @param bool $insDel
* Set to true to show content revisions * Set to true to show content revisions
*/ */
public function setInsDel($insDel): void public function setInsDel($insDel)
{ {
$this->insDel = $insDel === null ? true : $insDel; $this->insDel = $insDel === null ? true : $insDel;
} }
/** /**
* Get Display Formatting Revisions. * Get Display Formatting Revisions
* *
* @return bool True if formatting revisions are shown * @return bool True if formatting revisions are shown
*/ */
@ -133,18 +133,18 @@ final class TrackChangesView
} }
/** /**
* Set Display Formatting Revisions. * Set Display Formatting Revisions
* *
* @param null|bool $formatting * @param bool|null $formatting
* Set to true to show formatting revisions * Set to true to show formatting revisions
*/ */
public function setFormatting($formatting = null): void public function setFormatting($formatting = null)
{ {
$this->formatting = $formatting === null ? true : $formatting; $this->formatting = $formatting === null ? true : $formatting;
} }
/** /**
* Get Display Ink Annotations. * Get Display Ink Annotations
* *
* @return bool True if ink annotations are shown * @return bool True if ink annotations are shown
*/ */
@ -154,12 +154,12 @@ final class TrackChangesView
} }
/** /**
* Set Display Ink Annotations. * Set Display Ink Annotations
* *
* @param bool $inkAnnotations * @param bool $inkAnnotations
* Set to true to show ink annotations * Set to true to show ink annotations
*/ */
public function setInkAnnotations($inkAnnotations): void public function setInkAnnotations($inkAnnotations)
{ {
$this->inkAnnotations = $inkAnnotations === null ? true : $inkAnnotations; $this->inkAnnotations = $inkAnnotations === null ? true : $inkAnnotations;
} }

View File

@ -11,17 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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 BadMethodCallException;
use ReflectionClass;
/** /**
* Container abstract class. * Container abstract class
* *
* @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)
@ -47,6 +44,7 @@ use ReflectionClass;
* @method Chart addChart(string $type, array $categories, array $values, array $style = null, $seriesName = null) * @method Chart addChart(string $type, array $categories, array $values, array $style = null, $seriesName = null)
* @method FormField addFormField(string $type, mixed $fStyle = null, mixed $pStyle = null) * @method FormField addFormField(string $type, mixed $fStyle = null, mixed $pStyle = null)
* @method SDT addSDT(string $type) * @method SDT addSDT(string $type)
*
* @method \PhpOffice\PhpWord\Element\OLEObject addObject(string $source, mixed $style = null) deprecated, use addOLEObject instead * @method \PhpOffice\PhpWord\Element\OLEObject addObject(string $source, mixed $style = null) deprecated, use addOLEObject instead
* *
* @since 0.10.0 * @since 0.10.0
@ -54,21 +52,21 @@ use ReflectionClass;
abstract class AbstractContainer extends AbstractElement abstract class AbstractContainer extends AbstractElement
{ {
/** /**
* Elements collection. * Elements collection
* *
* @var \PhpOffice\PhpWord\Element\AbstractElement[] * @var \PhpOffice\PhpWord\Element\AbstractElement[]
*/ */
protected $elements = []; protected $elements = array();
/** /**
* Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange. * Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange
* *
* @var string * @var string
*/ */
protected $container; protected $container;
/** /**
* Magic method to catch all 'addElement' variation. * Magic method to catch all 'addElement' variation
* *
* This removes addText, addTextRun, etc. When adding new element, we have to * This removes addText, addTextRun, etc. When adding new element, we have to
* add the model in the class docblock with `@method`. * add the model in the class docblock with `@method`.
@ -77,19 +75,18 @@ abstract class AbstractContainer extends AbstractElement
* *
* @param mixed $function * @param mixed $function
* @param mixed $args * @param mixed $args
*
* @return \PhpOffice\PhpWord\Element\AbstractElement * @return \PhpOffice\PhpWord\Element\AbstractElement
*/ */
public function __call($function, $args) public function __call($function, $args)
{ {
$elements = [ $elements = array(
'Text', 'TextRun', 'Bookmark', 'Link', 'PreserveText', 'TextBreak', 'Text', 'TextRun', 'Bookmark', 'Link', 'PreserveText', 'TextBreak',
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'OLEObject', 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'OLEObject',
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
'Line', 'Shape', 'Title', 'TOC', 'PageBreak', 'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
'Chart', 'FormField', 'SDT', 'Comment', 'Chart', 'FormField', 'SDT', 'Comment',
]; );
$functions = []; $functions = array();
foreach ($elements as $element) { foreach ($elements as $element) {
$functions['add' . strtolower($element)] = $element == 'Object' ? 'OLEObject' : $element; $functions['add' . strtolower($element)] = $element == 'Object' ? 'OLEObject' : $element;
} }
@ -102,18 +99,18 @@ 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') {
[$count, $fontStyle, $paragraphStyle] = array_pad($args, 3, null); 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);
} }
} else { } else {
// All other elements // 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([$this, 'addElement'], $args); return call_user_func_array(array($this, 'addElement'), $args);
} }
} }
@ -121,12 +118,11 @@ abstract class AbstractContainer extends AbstractElement
} }
/** /**
* Add element. * Add element
* *
* Each element has different number of parameters passed * Each element has different number of parameters passed
* *
* @param string $elementName * @param string $elementName
*
* @return \PhpOffice\PhpWord\Element\AbstractElement * @return \PhpOffice\PhpWord\Element\AbstractElement
*/ */
protected function addElement($elementName) protected function addElement($elementName)
@ -136,13 +132,13 @@ abstract class AbstractContainer extends AbstractElement
// Get arguments // Get arguments
$args = func_get_args(); $args = func_get_args();
$withoutP = in_array($this->container, ['TextRun', 'Footnote', 'Endnote', 'ListItemRun', 'Field']); $withoutP = in_array($this->container, array('TextRun', 'Footnote', 'Endnote', 'ListItemRun', 'Field'));
if ($withoutP && ($elementName == 'Text' || $elementName == 'PreserveText')) { if ($withoutP && ($elementName == 'Text' || $elementName == 'PreserveText')) {
$args[3] = null; // Remove paragraph style for texts in textrun $args[3] = null; // Remove paragraph style for texts in textrun
} }
// Create element using reflection // Create element using reflection
$reflection = new ReflectionClass($elementClass); $reflection = new \ReflectionClass($elementClass);
$elementArgs = $args; $elementArgs = $args;
array_shift($elementArgs); // Shift the $elementName off the beginning of array array_shift($elementArgs); // Shift the $elementName off the beginning of array
@ -160,7 +156,7 @@ abstract class AbstractContainer extends AbstractElement
} }
/** /**
* Get all elements. * Get all elements
* *
* @return \PhpOffice\PhpWord\Element\AbstractElement[] * @return \PhpOffice\PhpWord\Element\AbstractElement[]
*/ */
@ -170,11 +166,10 @@ abstract class AbstractContainer extends AbstractElement
} }
/** /**
* Returns the element at the requested position. * Returns the element at the requested position
* *
* @param int $index * @param int $index
* * @return \PhpOffice\PhpWord\Element\AbstractElement|null
* @return null|\PhpOffice\PhpWord\Element\AbstractElement
*/ */
public function getElement($index) public function getElement($index)
{ {
@ -186,11 +181,11 @@ abstract class AbstractContainer extends AbstractElement
} }
/** /**
* Removes the element at requested index. * Removes the element at requested index
* *
* @param int|\PhpOffice\PhpWord\Element\AbstractElement $toRemove * @param int|\PhpOffice\PhpWord\Element\AbstractElement $toRemove
*/ */
public function removeElement($toRemove): void public function removeElement($toRemove)
{ {
if (is_int($toRemove) && array_key_exists($toRemove, $this->elements)) { if (is_int($toRemove) && array_key_exists($toRemove, $this->elements)) {
unset($this->elements[$toRemove]); unset($this->elements[$toRemove]);
@ -206,7 +201,7 @@ abstract class AbstractContainer extends AbstractElement
} }
/** /**
* Count elements. * Count elements
* *
* @return int * @return int
*/ */
@ -216,58 +211,59 @@ abstract class AbstractContainer extends AbstractElement
} }
/** /**
* Check if a method is allowed for the current container. * Check if a method is allowed for the current container
* *
* @param string $method * @param string $method
* *
* @throws \BadMethodCallException
* @return bool * @return bool
*/ */
private function checkValidity($method) private function checkValidity($method)
{ {
$generalContainers = [ $generalContainers = array(
'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun', 'TrackChange', 'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun', 'TrackChange',
]; );
$validContainers = [ $validContainers = array(
'Text' => $generalContainers, 'Text' => $generalContainers,
'Bookmark' => $generalContainers, 'Bookmark' => $generalContainers,
'Link' => $generalContainers, 'Link' => $generalContainers,
'TextBreak' => $generalContainers, 'TextBreak' => $generalContainers,
'Image' => $generalContainers, 'Image' => $generalContainers,
'OLEObject' => $generalContainers, 'OLEObject' => $generalContainers,
'Field' => $generalContainers, 'Field' => $generalContainers,
'Line' => $generalContainers, 'Line' => $generalContainers,
'Shape' => $generalContainers, 'Shape' => $generalContainers,
'FormField' => $generalContainers, 'FormField' => $generalContainers,
'SDT' => $generalContainers, 'SDT' => $generalContainers,
'TrackChange' => $generalContainers, 'TrackChange' => $generalContainers,
'TextRun' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox', 'TrackChange', 'ListItemRun'], 'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox', 'TrackChange', 'ListItemRun'),
'ListItem' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox'], 'ListItem' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
'ListItemRun' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox'], 'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
'Table' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox'], 'Table' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
'CheckBox' => ['Section', 'Header', 'Footer', 'Cell', 'TextRun'], 'CheckBox' => array('Section', 'Header', 'Footer', 'Cell', 'TextRun'),
'TextBox' => ['Section', 'Header', 'Footer', 'Cell'], 'TextBox' => array('Section', 'Header', 'Footer', 'Cell'),
'Footnote' => ['Section', 'TextRun', 'Cell', 'ListItemRun'], 'Footnote' => array('Section', 'TextRun', 'Cell', 'ListItemRun'),
'Endnote' => ['Section', 'TextRun', 'Cell'], 'Endnote' => array('Section', 'TextRun', 'Cell'),
'PreserveText' => ['Section', 'Header', 'Footer', 'Cell'], 'PreserveText' => array('Section', 'Header', 'Footer', 'Cell'),
'Title' => ['Section', 'Cell'], 'Title' => array('Section', 'Cell'),
'TOC' => ['Section'], 'TOC' => array('Section'),
'PageBreak' => ['Section'], 'PageBreak' => array('Section'),
'Chart' => ['Section', 'Cell'], 'Chart' => array('Section', 'Cell'),
]; );
// Special condition, e.g. preservetext can only exists in cell when // Special condition, e.g. preservetext can only exists in cell when
// the cell is located in header or footer // the cell is located in header or footer
$validSubcontainers = [ $validSubcontainers = array(
'PreserveText' => [['Cell'], ['Header', 'Footer', 'Section']], 'PreserveText' => array(array('Cell'), array('Header', 'Footer', 'Section')),
'Footnote' => [['Cell', 'TextRun'], ['Section']], 'Footnote' => array(array('Cell', 'TextRun'), array('Section')),
'Endnote' => [['Cell', 'TextRun'], ['Section']], 'Endnote' => array(array('Cell', 'TextRun'), array('Section')),
]; );
// Check if a method is valid for current container // Check if a method is valid for current container
if (isset($validContainers[$method])) { if (isset($validContainers[$method])) {
if (!in_array($this->container, $validContainers[$method])) { if (!in_array($this->container, $validContainers[$method])) {
throw new BadMethodCallException("Cannot add {$method} in {$this->container}."); throw new \BadMethodCallException("Cannot add {$method} in {$this->container}.");
} }
} }
@ -278,11 +274,43 @@ abstract class AbstractContainer extends AbstractElement
$allowedDocParts = $rules[1]; $allowedDocParts = $rules[1];
foreach ($containers as $container) { foreach ($containers as $container) {
if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) { if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) {
throw new BadMethodCallException("Cannot add {$method} in {$this->container}."); throw new \BadMethodCallException("Cannot add {$method} in {$this->container}.");
} }
} }
} }
return true; return true;
} }
/**
* Create textrun element
*
* @deprecated 0.10.0
*
* @param mixed $paragraphStyle
*
* @return \PhpOffice\PhpWord\Element\TextRun
*
* @codeCoverageIgnore
*/
public function createTextRun($paragraphStyle = null)
{
return $this->addTextRun($paragraphStyle);
}
/**
* Create footnote element
*
* @deprecated 0.10.0
*
* @param mixed $paragraphStyle
*
* @return \PhpOffice\PhpWord\Element\Footnote
*
* @codeCoverageIgnore
*/
public function createFootnote($paragraphStyle = null)
{
return $this->addFootnote($paragraphStyle);
}
} }

View File

@ -11,40 +11,38 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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 DateTime;
use InvalidArgumentException;
use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
/** /**
* Element abstract class. * Element abstract class
* *
* @since 0.10.0 * @since 0.10.0
*/ */
abstract class AbstractElement abstract class AbstractElement
{ {
/** /**
* PhpWord object. * PhpWord object
* *
* @var \PhpOffice\PhpWord\PhpWord * @var \PhpOffice\PhpWord\PhpWord
*/ */
protected $phpWord; protected $phpWord;
/** /**
* Section Id. * Section Id
* *
* @var int * @var int
*/ */
protected $sectionId; protected $sectionId;
/** /**
* Document part type: Section|Header|Footer|Footnote|Endnote. * Document part type: Section|Header|Footer|Footnote|Endnote
* *
* Used by textrun and cell container to determine where the element is * Used by textrun and cell container to determine where the element is
* located because it will affect the availability of other element, * located because it will affect the availability of other element,
@ -55,7 +53,7 @@ abstract class AbstractElement
protected $docPart = 'Section'; protected $docPart = 'Section';
/** /**
* Document part Id. * Document part Id
* *
* For header and footer, this will be = ($sectionId - 1) * 3 + $index * For header and footer, this will be = ($sectionId - 1) * 3 + $index
* because the max number of header/footer in every page is 3, i.e. * because the max number of header/footer in every page is 3, i.e.
@ -66,28 +64,28 @@ abstract class AbstractElement
protected $docPartId = 1; protected $docPartId = 1;
/** /**
* Index of element in the elements collection (start with 1). * Index of element in the elements collection (start with 1)
* *
* @var int * @var int
*/ */
protected $elementIndex = 1; protected $elementIndex = 1;
/** /**
* Unique Id for element. * Unique Id for element
* *
* @var string * @var string
*/ */
protected $elementId; protected $elementId;
/** /**
* Relation Id. * Relation Id
* *
* @var int * @var int
*/ */
protected $relationId; protected $relationId;
/** /**
* Depth of table container nested level; Primarily used for RTF writer/reader. * Depth of table container nested level; Primarily used for RTF writer/reader
* *
* 0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc. * 0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc.
* *
@ -96,56 +94,56 @@ abstract class AbstractElement
private $nestedLevel = 0; private $nestedLevel = 0;
/** /**
* A reference to the parent. * A reference to the parent
* *
* @var null|AbstractElement * @var AbstractElement|null
*/ */
private $parent; private $parent;
/** /**
* changed element info. * changed element info
* *
* @var TrackChange * @var TrackChange
*/ */
private $trackChange; private $trackChange;
/** /**
* Parent container type. * Parent container type
* *
* @var string * @var string
*/ */
private $parentContainer; private $parentContainer;
/** /**
* Has media relation flag; true for Link, Image, and Object. * Has media relation flag; true for Link, Image, and Object
* *
* @var bool * @var bool
*/ */
protected $mediaRelation = false; protected $mediaRelation = false;
/** /**
* Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment. * 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. * The start position for the linked comment
* *
* @var Comment * @var Comment
*/ */
protected $commentRangeStart; protected $commentRangeStart;
/** /**
* The end position for the linked comment. * The end position for the linked comment
* *
* @var Comment * @var Comment
*/ */
protected $commentRangeEnd; protected $commentRangeEnd;
/** /**
* Get PhpWord. * Get PhpWord
* *
* @return \PhpOffice\PhpWord\PhpWord * @return \PhpOffice\PhpWord\PhpWord
*/ */
@ -159,13 +157,13 @@ abstract class AbstractElement
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
*/ */
public function setPhpWord(?PhpWord $phpWord = null): void public function setPhpWord(PhpWord $phpWord = null)
{ {
$this->phpWord = $phpWord; $this->phpWord = $phpWord;
} }
/** /**
* Get section number. * Get section number
* *
* @return int * @return int
*/ */
@ -180,14 +178,14 @@ abstract class AbstractElement
* @param string $docPart * @param string $docPart
* @param int $docPartId * @param int $docPartId
*/ */
public function setDocPart($docPart, $docPartId = 1): void public function setDocPart($docPart, $docPartId = 1)
{ {
$this->docPart = $docPart; $this->docPart = $docPart;
$this->docPartId = $docPartId; $this->docPartId = $docPartId;
} }
/** /**
* Get doc part. * Get doc part
* *
* @return string * @return string
*/ */
@ -197,7 +195,7 @@ abstract class AbstractElement
} }
/** /**
* Get doc part Id. * Get doc part Id
* *
* @return int * @return int
*/ */
@ -207,7 +205,7 @@ abstract class AbstractElement
} }
/** /**
* Return media element (image, object, link) container name. * Return media element (image, object, link) container name
* *
* @return string section|headerx|footerx|footnote|endnote * @return string section|headerx|footerx|footnote|endnote
*/ */
@ -222,7 +220,7 @@ abstract class AbstractElement
} }
/** /**
* Get element index. * Get element index
* *
* @return int * @return int
*/ */
@ -236,13 +234,13 @@ abstract class AbstractElement
* *
* @param int $value * @param int $value
*/ */
public function setElementIndex($value): void public function setElementIndex($value)
{ {
$this->elementIndex = $value; $this->elementIndex = $value;
} }
/** /**
* Get element unique ID. * Get element unique ID
* *
* @return string * @return string
*/ */
@ -254,13 +252,13 @@ abstract class AbstractElement
/** /**
* Set element unique ID from 6 first digit of md5. * Set element unique ID from 6 first digit of md5.
*/ */
public function setElementId(): void public function setElementId()
{ {
$this->elementId = substr(md5(mt_rand()), 0, 6); $this->elementId = substr(md5(rand()), 0, 6);
} }
/** /**
* Get relation Id. * Get relation Id
* *
* @return int * @return int
*/ */
@ -274,13 +272,13 @@ abstract class AbstractElement
* *
* @param int $value * @param int $value
*/ */
public function setRelationId($value): void public function setRelationId($value)
{ {
$this->relationId = $value; $this->relationId = $value;
} }
/** /**
* Get nested level. * Get nested level
* *
* @return int * @return int
*/ */
@ -290,7 +288,7 @@ abstract class AbstractElement
} }
/** /**
* Get comment start. * Get comment start
* *
* @return Comment * @return Comment
*/ */
@ -300,19 +298,21 @@ abstract class AbstractElement
} }
/** /**
* Set comment start. * Set comment start
*
* @param Comment $value
*/ */
public function setCommentRangeStart(Comment $value): void public function setCommentRangeStart(Comment $value)
{ {
if ($this instanceof Comment) { if ($this instanceof Comment) {
throw new InvalidArgumentException('Cannot set a Comment on a Comment'); throw new \InvalidArgumentException('Cannot set a Comment on a Comment');
} }
$this->commentRangeStart = $value; $this->commentRangeStart = $value;
$this->commentRangeStart->setStartElement($this); $this->commentRangeStart->setStartElement($this);
} }
/** /**
* Get comment end. * Get comment end
* *
* @return Comment * @return Comment
*/ */
@ -322,21 +322,23 @@ abstract class AbstractElement
} }
/** /**
* Set comment end. * Set comment end
*
* @param Comment $value
*/ */
public function setCommentRangeEnd(Comment $value): void public function setCommentRangeEnd(Comment $value)
{ {
if ($this instanceof Comment) { if ($this instanceof Comment) {
throw new InvalidArgumentException('Cannot set a Comment on a Comment'); throw new \InvalidArgumentException('Cannot set a Comment on a Comment');
} }
$this->commentRangeEnd = $value; $this->commentRangeEnd = $value;
$this->commentRangeEnd->setEndElement($this); $this->commentRangeEnd->setEndElement($this);
} }
/** /**
* Get parent element. * Get parent element
* *
* @return null|AbstractElement * @return AbstractElement|null
*/ */
public function getParent() public function getParent()
{ {
@ -344,13 +346,13 @@ abstract class AbstractElement
} }
/** /**
* 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
*/ */
public function setParentContainer(self $container): void public function setParentContainer(self $container)
{ {
$this->parentContainer = substr(get_class($container), strrpos(get_class($container), '\\') + 1); $this->parentContainer = substr(get_class($container), strrpos(get_class($container), '\\') + 1);
$this->parent = $container; $this->parent = $container;
@ -358,7 +360,7 @@ abstract class AbstractElement
// Set nested level // Set nested level
$this->nestedLevel = $container->getNestedLevel(); $this->nestedLevel = $container->getNestedLevel();
if ($this->parentContainer == 'Cell') { if ($this->parentContainer == 'Cell') {
++$this->nestedLevel; $this->nestedLevel++;
} }
// Set phpword // Set phpword
@ -374,18 +376,18 @@ abstract class AbstractElement
} }
/** /**
* Set relation Id for media elements (link, image, object; legacy of OOXML). * Set relation Id for media elements (link, image, object; legacy of OOXML)
* *
* - 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
*/ */
private function setMediaRelation(): void private function setMediaRelation()
{ {
if (!$this instanceof Link && !$this instanceof Image && !$this instanceof OLEObject) { if (!$this instanceof Link && !$this instanceof Image && !$this instanceof OLEObject) {
return; return;
} }
$elementName = substr(static::class, strrpos(static::class, '\\') + 1); $elementName = substr(get_class($this), strrpos(get_class($this), '\\') + 1);
if ($elementName == 'OLEObject') { if ($elementName == 'OLEObject') {
$elementName = 'Object'; $elementName = 'Object';
} }
@ -408,10 +410,10 @@ 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.
*/ */
private function setCollectionRelation(): void private function setCollectionRelation()
{ {
if ($this->collectionRelation === true && $this->phpWord instanceof PhpWord) { if ($this->collectionRelation === true && $this->phpWord instanceof PhpWord) {
$elementName = substr(static::class, strrpos(static::class, '\\') + 1); $elementName = substr(get_class($this), strrpos(get_class($this), '\\') + 1);
$addMethod = "add{$elementName}"; $addMethod = "add{$elementName}";
$rId = $this->phpWord->$addMethod($this); $rId = $this->phpWord->$addMethod($this);
$this->setRelationId($rId); $this->setRelationId($rId);
@ -419,7 +421,7 @@ abstract class AbstractElement
} }
/** /**
* Check if element is located in Section doc part (as opposed to Header/Footer). * Check if element is located in Section doc part (as opposed to Header/Footer)
* *
* @return bool * @return bool
*/ */
@ -429,17 +431,16 @@ abstract class AbstractElement
} }
/** /**
* Set new style value. * Set new style value
* *
* @param mixed $styleObject Style object * @param mixed $styleObject Style object
* @param mixed $styleValue Style value * @param mixed $styleValue Style value
* @param bool $returnObject Always return object * @param bool $returnObject Always return object
*
* @return mixed * @return mixed
*/ */
protected function setNewStyle($styleObject, $styleValue = null, $returnObject = false) protected function setNewStyle($styleObject, $styleValue = null, $returnObject = false)
{ {
if (null !== $styleValue && is_array($styleValue)) { if (!is_null($styleValue) && is_array($styleValue)) {
$styleObject->setStyleByArray($styleValue); $styleObject->setStyleByArray($styleValue);
$style = $styleObject; $style = $styleObject;
} else { } else {
@ -450,15 +451,17 @@ abstract class AbstractElement
} }
/** /**
* Sets the trackChange information. * Sets the trackChange information
*
* @param TrackChange $trackChange
*/ */
public function setTrackChange(TrackChange $trackChange): void public function setTrackChange(TrackChange $trackChange)
{ {
$this->trackChange = $trackChange; $this->trackChange = $trackChange;
} }
/** /**
* Gets the trackChange information. * Gets the trackChange information
* *
* @return TrackChange * @return TrackChange
*/ */
@ -468,32 +471,33 @@ abstract class AbstractElement
} }
/** /**
* Set changed. * Set changed
* *
* @param string $type INSERTED|DELETED * @param string $type INSERTED|DELETED
* @param string $author * @param string $author
* @param null|DateTime|int $date allways in UTC * @param null|int|\DateTime $date allways in UTC
*/ */
public function setChangeInfo($type, $author, $date = null): void public function setChangeInfo($type, $author, $date = null)
{ {
$this->trackChange = new TrackChange($type, $author, $date); $this->trackChange = new TrackChange($type, $author, $date);
} }
/** /**
* Set enum value. * Set enum value
* *
* @param null|string $value * @param string|null $value
* @param string[] $enum * @param string[] $enum
* @param null|string $default * @param string|null $default
* *
* @return null|string * @throws \InvalidArgumentException
* @return string|null
* *
* @todo Merge with the same method in AbstractStyle * @todo Merge with the same method in AbstractStyle
*/ */
protected function setEnumVal($value = null, $enum = [], $default = null) protected function setEnumVal($value = null, $enum = array(), $default = null)
{ {
if ($value !== null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) { if ($value !== null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
throw new InvalidArgumentException("Invalid style value: {$value}"); throw new \InvalidArgumentException("Invalid style value: {$value}");
} elseif ($value === null || trim($value) == '') { } elseif ($value === null || trim($value) == '') {
$value = $default; $value = $default;
} }

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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,26 +20,26 @@ namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Shared\Text as SharedText; use PhpOffice\PhpWord\Shared\Text as SharedText;
/** /**
* Bookmark element. * Bookmark element
*/ */
class Bookmark extends AbstractElement class Bookmark extends AbstractElement
{ {
/** /**
* Bookmark Name. * Bookmark Name
* *
* @var string * @var string
*/ */
private $name; private $name;
/** /**
* Is part of collection. * Is part of collection
* *
* @var bool * @var bool
*/ */
protected $collectionRelation = true; protected $collectionRelation = true;
/** /**
* Create a new Bookmark Element. * Create a new Bookmark Element
* *
* @param string $name * @param string $name
*/ */
@ -49,7 +49,7 @@ class Bookmark extends AbstractElement
} }
/** /**
* Get Bookmark name. * Get Bookmark name
* *
* @return string * @return string
*/ */

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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 @@ namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Cell as CellStyle;
/** /**
* Table cell element. * Table cell element
*/ */
class Cell extends AbstractContainer class Cell extends AbstractContainer
{ {
@ -30,21 +30,21 @@ class Cell extends AbstractContainer
protected $container = 'Cell'; protected $container = 'Cell';
/** /**
* Cell width. * Cell width
* *
* @var int * @var int
*/ */
private $width; private $width = null;
/** /**
* Cell style. * Cell style
* *
* @var \PhpOffice\PhpWord\Style\Cell * @var \PhpOffice\PhpWord\Style\Cell
*/ */
private $style; private $style;
/** /**
* Create new instance. * Create new instance
* *
* @param int $width * @param int $width
* @param array|\PhpOffice\PhpWord\Style\Cell $style * @param array|\PhpOffice\PhpWord\Style\Cell $style
@ -56,7 +56,7 @@ class Cell extends AbstractContainer
} }
/** /**
* Get cell style. * Get cell style
* *
* @return \PhpOffice\PhpWord\Style\Cell * @return \PhpOffice\PhpWord\Style\Cell
*/ */
@ -66,7 +66,7 @@ class Cell extends AbstractContainer
} }
/** /**
* Get cell width. * Get cell width
* *
* @return int * @return int
*/ */

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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,42 +20,42 @@ namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Chart as ChartStyle; use PhpOffice\PhpWord\Style\Chart as ChartStyle;
/** /**
* Chart element. * Chart element
* *
* @since 0.12.0 * @since 0.12.0
*/ */
class Chart extends AbstractElement class Chart extends AbstractElement
{ {
/** /**
* Is part of collection. * Is part of collection
* *
* @var bool * @var bool
*/ */
protected $collectionRelation = true; protected $collectionRelation = true;
/** /**
* Type. * Type
* *
* @var string * @var string
*/ */
private $type = 'pie'; private $type = 'pie';
/** /**
* Series. * Series
* *
* @var array * @var array
*/ */
private $series = []; private $series = array();
/** /**
* Chart style. * Chart style
* *
* @var \PhpOffice\PhpWord\Style\Chart * @var \PhpOffice\PhpWord\Style\Chart
*/ */
private $style; private $style;
/** /**
* Create new instance. * Create new instance
* *
* @param string $type * @param string $type
* @param array $categories * @param array $categories
@ -71,7 +71,7 @@ class Chart extends AbstractElement
} }
/** /**
* Get type. * Get type
* *
* @return string * @return string
*/ */
@ -85,30 +85,30 @@ class Chart extends AbstractElement
* *
* @param string $value * @param string $value
*/ */
public function setType($value): void public function setType($value)
{ {
$enum = ['pie', 'doughnut', 'line', 'bar', 'stacked_bar', 'percent_stacked_bar', 'column', 'stacked_column', 'percent_stacked_column', 'area', 'radar', 'scatter']; $enum = array('pie', 'doughnut', 'line', 'bar', 'stacked_bar', 'percent_stacked_bar', 'column', 'stacked_column', 'percent_stacked_column', 'area', 'radar', 'scatter');
$this->type = $this->setEnumVal($value, $enum, 'pie'); $this->type = $this->setEnumVal($value, $enum, 'pie');
} }
/** /**
* Add series. * Add series
* *
* @param array $categories * @param array $categories
* @param array $values * @param array $values
* @param null|mixed $name * @param null|mixed $name
*/ */
public function addSeries($categories, $values, $name = null): void public function addSeries($categories, $values, $name = null)
{ {
$this->series[] = [ $this->series[] = array(
'categories' => $categories, 'categories' => $categories,
'values' => $values, 'values' => $values,
'name' => $name, 'name' => $name,
]; );
} }
/** /**
* Get series. * Get series
* *
* @return array * @return array
*/ */
@ -118,7 +118,7 @@ class Chart extends AbstractElement
} }
/** /**
* Get chart style. * Get chart style
* *
* @return \PhpOffice\PhpWord\Style\Chart * @return \PhpOffice\PhpWord\Style\Chart
*/ */

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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,21 +20,21 @@ namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Shared\Text as SharedText; use PhpOffice\PhpWord\Shared\Text as SharedText;
/** /**
* Check box element. * Check box element
* *
* @since 0.10.0 * @since 0.10.0
*/ */
class CheckBox extends Text class CheckBox extends Text
{ {
/** /**
* Name content. * Name content
* *
* @var string * @var string
*/ */
private $name; private $name;
/** /**
* Create new instance. * Create new instance
* *
* @param string $name * @param string $name
* @param string $text * @param string $text
@ -48,10 +48,9 @@ class CheckBox extends Text
} }
/** /**
* Set name content. * Set name content
* *
* @param string $name * @param string $name
*
* @return self * @return self
*/ */
public function setName($name) public function setName($name)
@ -62,7 +61,7 @@ class CheckBox extends Text
} }
/** /**
* Get name content. * Get name content
* *
* @return string * @return string
*/ */

View File

@ -11,54 +11,51 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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 DateTime;
/** /**
* Comment element. * Comment element
*
* @see http://datypic.com/sc/ooxml/t-w_CT_Comment.html * @see http://datypic.com/sc/ooxml/t-w_CT_Comment.html
*/ */
class Comment extends TrackChange class Comment extends TrackChange
{ {
/** /**
* Initials. * Initials
* *
* @var string * @var string
*/ */
private $initials; private $initials;
/** /**
* The Element where this comment starts. * The Element where this comment starts
* *
* @var AbstractElement * @var AbstractElement
*/ */
private $startElement; private $startElement;
/** /**
* The Element where this comment ends. * The Element where this comment ends
* *
* @var AbstractElement * @var AbstractElement
*/ */
private $endElement; private $endElement;
/** /**
* Is part of collection. * Is part of collection
* *
* @var bool * @var bool
*/ */
protected $collectionRelation = true; protected $collectionRelation = true;
/** /**
* Create a new Comment Element. * Create a new Comment Element
* *
* @param string $author * @param string $author
* @param null|DateTime $date * @param null|\DateTime $date
* @param string $initials * @param string $initials
*/ */
public function __construct($author, $date = null, $initials = null) public function __construct($author, $date = null, $initials = null)
@ -68,7 +65,7 @@ class Comment extends TrackChange
} }
/** /**
* Get Initials. * Get Initials
* *
* @return string * @return string
*/ */
@ -78,11 +75,11 @@ class Comment extends TrackChange
} }
/** /**
* Sets the element where this comment starts. * Sets the element where this comment starts
* *
* @param \PhpOffice\PhpWord\Element\AbstractElement $value * @param \PhpOffice\PhpWord\Element\AbstractElement $value
*/ */
public function setStartElement(AbstractElement $value): void public function setStartElement(AbstractElement $value)
{ {
$this->startElement = $value; $this->startElement = $value;
if ($value->getCommentRangeStart() == null) { if ($value->getCommentRangeStart() == null) {
@ -91,7 +88,7 @@ class Comment extends TrackChange
} }
/** /**
* Get the element where this comment starts. * Get the element where this comment starts
* *
* @return \PhpOffice\PhpWord\Element\AbstractElement * @return \PhpOffice\PhpWord\Element\AbstractElement
*/ */
@ -101,11 +98,11 @@ class Comment extends TrackChange
} }
/** /**
* Sets the element where this comment ends. * Sets the element where this comment ends
* *
* @param \PhpOffice\PhpWord\Element\AbstractElement $value * @param \PhpOffice\PhpWord\Element\AbstractElement $value
*/ */
public function setEndElement(AbstractElement $value): void public function setEndElement(AbstractElement $value)
{ {
$this->endElement = $value; $this->endElement = $value;
if ($value->getCommentRangeEnd() == null) { if ($value->getCommentRangeEnd() == null) {
@ -114,7 +111,7 @@ class Comment extends TrackChange
} }
/** /**
* Get the element where this comment ends. * Get the element where this comment ends
* *
* @return \PhpOffice\PhpWord\Element\AbstractElement * @return \PhpOffice\PhpWord\Element\AbstractElement
*/ */

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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;
/** /**
* Endnote element. * Endnote element
* *
* @since 0.10.0 * @since 0.10.0
*/ */
@ -30,9 +30,9 @@ class Endnote extends Footnote
protected $container = 'Endnote'; protected $container = 'Endnote';
/** /**
* Create new instance. * Create new instance
* *
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $paragraphStyle * @param string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
*/ */
public function __construct($paragraphStyle = null) public function __construct($paragraphStyle = null)
{ {

View File

@ -11,17 +11,16 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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 InvalidArgumentException;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
/** /**
* Field element. * Field element
* *
* @since 0.11.0 * @since 0.11.0
* @see http://www.schemacentral.com/sc/ooxml/t-w_CT_SimpleField.html * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_SimpleField.html
@ -30,104 +29,103 @@ class Field extends AbstractElement
{ {
/** /**
* Field properties and options. Depending on type, a field can have different properties * Field properties and options. Depending on type, a field can have different properties
* and options. * and options
* *
* @var array * @var array
*/ */
protected $fieldsArray = [ protected $fieldsArray = array(
'PAGE' => [ 'PAGE' => array(
'properties' => [ 'properties' => array(
'format' => ['Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'], 'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
], ),
'options' => ['PreserveFormat'], 'options' => array('PreserveFormat'),
], ),
'NUMPAGES' => [ 'NUMPAGES' => array(
'properties' => [ 'properties' => array(
'format' => ['Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText', 'format' => array('Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText',
'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper', ], 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper', ),
'numformat' => ['0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%'], 'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%'),
], ),
'options' => ['PreserveFormat'], 'options' => array('PreserveFormat'),
], ),
'DATE' => [ 'DATE' => array(
'properties' => [ 'properties' => array(
'dateformat' => [ 'dateformat' => array(
// Generic formats /* Generic formats */
'yyyy-MM-dd', 'yyyy-MM', 'MMM-yy', 'MMM-yyyy', 'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss', 'yyyy-MM-dd', 'yyyy-MM', 'MMM-yy', 'MMM-yyyy', 'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss',
// Day-Month-Year formats /* Day-Month-Year formats */
'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-MMM-yy', 'd MMM. yy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-MMM-yy', 'd MMM. yy',
'd-M-yy', 'd-M-yy h:mm', 'd-M-yy h:mm:ss', 'd-M-yy h:mm am/pm', 'd-M-yy h:mm:ss am/pm', 'd-M-yy HH:mm', 'd-M-yy HH:mm:ss', 'd-M-yy', 'd-M-yy h:mm', 'd-M-yy h:mm:ss', 'd-M-yy h:mm am/pm', 'd-M-yy h:mm:ss am/pm', 'd-M-yy HH:mm', 'd-M-yy HH:mm:ss',
'd/M/yy', 'd/M/yy h:mm', 'd/M/yy h:mm:ss', 'd/M/yy h:mm am/pm', 'd/M/yy h:mm:ss am/pm', 'd/M/yy HH:mm', 'd/M/yy HH:mm:ss', 'd/M/yy', 'd/M/yy h:mm', 'd/M/yy h:mm:ss', 'd/M/yy h:mm am/pm', 'd/M/yy h:mm:ss am/pm', 'd/M/yy HH:mm', 'd/M/yy HH:mm:ss',
'd-M-yyyy', 'd-M-yyyy h:mm', 'd-M-yyyy h:mm:ss', 'd-M-yyyy h:mm am/pm', 'd-M-yyyy h:mm:ss am/pm', 'd-M-yyyy HH:mm', 'd-M-yyyy HH:mm:ss', 'd-M-yyyy', 'd-M-yyyy h:mm', 'd-M-yyyy h:mm:ss', 'd-M-yyyy h:mm am/pm', 'd-M-yyyy h:mm:ss am/pm', 'd-M-yyyy HH:mm', 'd-M-yyyy HH:mm:ss',
'd/M/yyyy', 'd/M/yyyy h:mm', 'd/M/yyyy h:mm:ss', 'd/M/yyyy h:mm am/pm', 'd/M/yyyy h:mm:ss am/pm', 'd/M/yyyy HH:mm', 'd/M/yyyy HH:mm:ss', 'd/M/yyyy', 'd/M/yyyy h:mm', 'd/M/yyyy h:mm:ss', 'd/M/yyyy h:mm am/pm', 'd/M/yyyy h:mm:ss am/pm', 'd/M/yyyy HH:mm', 'd/M/yyyy HH:mm:ss',
// Month-Day-Year formats /* Month-Day-Year formats */
'dddd, MMMM d yyyy', 'MMMM d yyyy', 'MMM-d-yy', 'MMM. d yy', 'dddd, MMMM d yyyy', 'MMMM d yyyy', 'MMM-d-yy', 'MMM. d yy',
'M-d-yy', 'M-d-yy h:mm', 'M-d-yy h:mm:ss', 'M-d-yy h:mm am/pm', 'M-d-yy h:mm:ss am/pm', 'M-d-yy HH:mm', 'M-d-yy HH:mm:ss', 'M-d-yy', 'M-d-yy h:mm', 'M-d-yy h:mm:ss', 'M-d-yy h:mm am/pm', 'M-d-yy h:mm:ss am/pm', 'M-d-yy HH:mm', 'M-d-yy HH:mm:ss',
'M/d/yy', 'M/d/yy h:mm', 'M/d/yy h:mm:ss', 'M/d/yy h:mm am/pm', 'M/d/yy h:mm:ss am/pm', 'M/d/yy HH:mm', 'M/d/yy HH:mm:ss', 'M/d/yy', 'M/d/yy h:mm', 'M/d/yy h:mm:ss', 'M/d/yy h:mm am/pm', 'M/d/yy h:mm:ss am/pm', 'M/d/yy HH:mm', 'M/d/yy HH:mm:ss',
'M-d-yyyy', 'M-d-yyyy h:mm', 'M-d-yyyy h:mm:ss', 'M-d-yyyy h:mm am/pm', 'M-d-yyyy h:mm:ss am/pm', 'M-d-yyyy HH:mm', 'M-d-yyyy HH:mm:ss', 'M-d-yyyy', 'M-d-yyyy h:mm', 'M-d-yyyy h:mm:ss', 'M-d-yyyy h:mm am/pm', 'M-d-yyyy h:mm:ss am/pm', 'M-d-yyyy HH:mm', 'M-d-yyyy HH:mm:ss',
'M/d/yyyy', 'M/d/yyyy h:mm', 'M/d/yyyy h:mm:ss', 'M/d/yyyy h:mm am/pm', 'M/d/yyyy h:mm:ss am/pm', 'M/d/yyyy HH:mm', 'M/d/yyyy HH:mm:ss', 'M/d/yyyy', 'M/d/yyyy h:mm', 'M/d/yyyy h:mm:ss', 'M/d/yyyy h:mm am/pm', 'M/d/yyyy h:mm:ss am/pm', 'M/d/yyyy HH:mm', 'M/d/yyyy HH:mm:ss',
], ),
], ),
'options' => ['PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat'], 'options' => array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat'),
], ),
'MACROBUTTON' => [ 'MACROBUTTON' => array(
'properties' => ['macroname' => ''], 'properties' => array('macroname' => ''),
], ),
'XE' => [ 'XE' => array(
'properties' => [], 'properties' => array(),
'options' => ['Bold', 'Italic'], 'options' => array('Bold', 'Italic'),
], ),
'INDEX' => [ 'INDEX' => array(
'properties' => [], 'properties' => array(),
'options' => ['PreserveFormat'], 'options' => array('PreserveFormat'),
], ),
'STYLEREF' => [ 'STYLEREF' => array(
'properties' => ['StyleIdentifier' => ''], 'properties' => array('StyleIdentifier' => ''),
'options' => ['PreserveFormat'], 'options' => array('PreserveFormat'),
], ),
]; );
/** /**
* Field type. * Field type
* *
* @var string * @var string
*/ */
protected $type; protected $type;
/** /**
* Field text. * Field text
* *
* @var string|TextRun * @var TextRun|string
*/ */
protected $text; protected $text;
/** /**
* Field properties. * Field properties
* *
* @var array * @var array
*/ */
protected $properties = []; protected $properties = array();
/** /**
* Field options. * Field options
* *
* @var array * @var array
*/ */
protected $options = []; protected $options = array();
/** /**
* Font style. * Font style
* *
* @var \PhpOffice\PhpWord\Style\Font|string * @var string|\PhpOffice\PhpWord\Style\Font
*/ */
protected $fontStyle; protected $fontStyle;
/** /**
* Set Font style. * Set Font style
* *
* @param array|\PhpOffice\PhpWord\Style\Font|string $style * @param string|array|\PhpOffice\PhpWord\Style\Font $style
* * @return string|\PhpOffice\PhpWord\Style\Font
* @return \PhpOffice\PhpWord\Style\Font|string
*/ */
public function setFontStyle($style = null) public function setFontStyle($style = null)
{ {
@ -146,9 +144,9 @@ class Field extends AbstractElement
} }
/** /**
* Get Font style. * Get Font style
* *
* @return \PhpOffice\PhpWord\Style\Font|string * @return string|\PhpOffice\PhpWord\Style\Font
*/ */
public function getFontStyle() public function getFontStyle()
{ {
@ -156,15 +154,15 @@ class Field extends AbstractElement
} }
/** /**
* Create a new Field Element. * Create a new Field Element
* *
* @param string $type * @param string $type
* @param array $properties * @param array $properties
* @param array $options * @param array $options
* @param null|string|TextRun $text * @param TextRun|string|null $text
* @param array|\PhpOffice\PhpWord\Style\Font|string $fontStyle * @param string|array|\PhpOffice\PhpWord\Style\Font $fontStyle
*/ */
public function __construct($type = null, $properties = [], $options = [], $text = null, $fontStyle = null) public function __construct($type = null, $properties = array(), $options = array(), $text = null, $fontStyle = null)
{ {
$this->setType($type); $this->setType($type);
$this->setProperties($properties); $this->setProperties($properties);
@ -174,10 +172,11 @@ class Field extends AbstractElement
} }
/** /**
* Set Field type. * Set Field type
* *
* @param string $type * @param string $type
* *
* @throws \InvalidArgumentException
* @return string * @return string
*/ */
public function setType($type = null) public function setType($type = null)
@ -186,7 +185,7 @@ 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 '$type'"); throw new \InvalidArgumentException("Invalid type '$type'");
} }
} }
@ -194,7 +193,7 @@ class Field extends AbstractElement
} }
/** /**
* Get Field type. * Get Field type
* *
* @return string * @return string
*/ */
@ -204,18 +203,19 @@ class Field extends AbstractElement
} }
/** /**
* Set Field properties. * Set Field properties
* *
* @param array $properties * @param array $properties
* *
* @throws \InvalidArgumentException
* @return self * @return self
*/ */
public function setProperties($properties = []) 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 '$propkey'"); throw new \InvalidArgumentException("Invalid property '$propkey'");
} }
} }
$this->properties = array_merge($this->properties, $properties); $this->properties = array_merge($this->properties, $properties);
@ -225,7 +225,7 @@ class Field extends AbstractElement
} }
/** /**
* Get Field properties. * Get Field properties
* *
* @return array * @return array
*/ */
@ -235,18 +235,19 @@ class Field extends AbstractElement
} }
/** /**
* Set Field options. * Set Field options
* *
* @param array $options * @param array $options
* *
* @throws \InvalidArgumentException
* @return self * @return self
*/ */
public function setOptions($options = []) 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])) && substr($optionkey, 0, 1) !== '\\') { if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey])) && substr($optionkey, 0, 1) !== '\\') {
throw new InvalidArgumentException("Invalid option '$optionkey', possible values are " . implode(', ', $this->fieldsArray[$this->type]['options'])); 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);
@ -256,7 +257,7 @@ class Field extends AbstractElement
} }
/** /**
* Get Field properties. * Get Field properties
* *
* @return array * @return array
*/ */
@ -266,10 +267,11 @@ class Field extends AbstractElement
} }
/** /**
* Set Field text. * Set Field text
* *
* @param string|TextRun $text * @param string|TextRun $text
* *
* @throws \InvalidArgumentException
* @return null|string|TextRun * @return null|string|TextRun
*/ */
public function setText($text = null) public function setText($text = null)
@ -278,7 +280,7 @@ class Field extends AbstractElement
if (is_string($text) || $text instanceof TextRun) { if (is_string($text) || $text instanceof TextRun) {
$this->text = $text; $this->text = $text;
} else { } else {
throw new InvalidArgumentException('Invalid text'); throw new \InvalidArgumentException('Invalid text');
} }
} }
@ -286,7 +288,7 @@ class Field extends AbstractElement
} }
/** /**
* Get Field text. * Get Field text
* *
* @return string|TextRun * @return string|TextRun
*/ */

View File

@ -11,22 +11,21 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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;
/** /**
* Footer element. * Footer element
*/ */
class Footer extends AbstractContainer class Footer extends AbstractContainer
{ {
/** /**
* Header/footer types constants. * Header/footer types constants
* *
* @var string * @var string
*
* @see http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.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
@ -39,14 +38,14 @@ class Footer extends AbstractContainer
protected $container = 'Footer'; protected $container = 'Footer';
/** /**
* Header type. * Header type
* *
* @var string * @var string
*/ */
protected $type = self::AUTO; protected $type = self::AUTO;
/** /**
* Create new instance. * Create new instance
* *
* @param int $sectionId * @param int $sectionId
* @param int $containerId * @param int $containerId
@ -66,19 +65,18 @@ class Footer extends AbstractContainer
* *
* @param string $value * @param string $value
*/ */
public function setType($value = self::AUTO): void public function setType($value = self::AUTO)
{ {
if (!in_array($value, [self::AUTO, self::FIRST, self::EVEN])) { if (!in_array($value, array(self::AUTO, self::FIRST, self::EVEN))) {
$value = self::AUTO; $value = self::AUTO;
} }
$this->type = $value; $this->type = $value;
} }
/** /**
* Get type. * Get type
* *
* @return string * @return string
*
* @since 0.10.0 * @since 0.10.0
*/ */
public function getType() public function getType()
@ -87,7 +85,7 @@ class Footer extends AbstractContainer
} }
/** /**
* Reset type to default. * Reset type to default
* *
* @return string * @return string
*/ */
@ -97,7 +95,7 @@ class Footer extends AbstractContainer
} }
/** /**
* First page only header. * First page only header
* *
* @return string * @return string
*/ */
@ -107,7 +105,7 @@ class Footer extends AbstractContainer
} }
/** /**
* Even numbered pages only. * Even numbered pages only
* *
* @return string * @return string
*/ */

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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,23 +27,23 @@ class Footnote extends AbstractContainer
protected $container = 'Footnote'; protected $container = 'Footnote';
/** /**
* Paragraph style. * Paragraph style
* *
* @var \PhpOffice\PhpWord\Style\Paragraph|string * @var string|\PhpOffice\PhpWord\Style\Paragraph
*/ */
protected $paragraphStyle; protected $paragraphStyle;
/** /**
* Is part of collection. * Is part of collection
* *
* @var bool * @var bool
*/ */
protected $collectionRelation = true; protected $collectionRelation = true;
/** /**
* Create new instance. * Create new instance
* *
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $paragraphStyle * @param string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
*/ */
public function __construct($paragraphStyle = null) public function __construct($paragraphStyle = null)
{ {
@ -52,12 +52,38 @@ class Footnote extends AbstractContainer
} }
/** /**
* Get paragraph style. * Get paragraph style
* *
* @return \PhpOffice\PhpWord\Style\Paragraph|string * @return string|\PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {
return $this->paragraphStyle; return $this->paragraphStyle;
} }
/**
* Get Footnote Reference ID
*
* @deprecated 0.10.0
* @codeCoverageIgnore
*
* @return int
*/
public function getReferenceId()
{
return $this->getRelationId();
}
/**
* Set Footnote Reference ID
*
* @deprecated 0.10.0
* @codeCoverageIgnore
*
* @param int $rId
*/
public function setReferenceId($rId)
{
$this->setRelationId($rId);
}
} }

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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;
/** /**
* Form field element. * Form field element
* *
* @since 0.12.0 * @since 0.12.0
* @see http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html * @see http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html
@ -26,46 +26,46 @@ namespace PhpOffice\PhpWord\Element;
class FormField extends Text class FormField extends Text
{ {
/** /**
* Form field type: textinput|checkbox|dropdown. * Form field type: textinput|checkbox|dropdown
* *
* @var string * @var string
*/ */
private $type = 'textinput'; private $type = 'textinput';
/** /**
* Form field name. * Form field name
* *
* @var bool|int|string * @var string|bool|int
*/ */
private $name; private $name;
/** /**
* Default value. * Default value
* *
* - TextInput: string * - TextInput: string
* - CheckBox: bool * - CheckBox: bool
* - DropDown: int Index of entries (zero based) * - DropDown: int Index of entries (zero based)
* *
* @var bool|int|string * @var string|bool|int
*/ */
private $default; private $default;
/** /**
* Value. * Value
* *
* @var bool|int|string * @var string|bool|int
*/ */
private $value; private $value;
/** /**
* Dropdown entries. * Dropdown entries
* *
* @var array * @var array
*/ */
private $entries = []; private $entries = array();
/** /**
* Create new instance. * Create new instance
* *
* @param string $type * @param string $type
* @param mixed $fontStyle * @param mixed $fontStyle
@ -78,7 +78,7 @@ class FormField extends Text
} }
/** /**
* Get type. * Get type
* *
* @return string * @return string
*/ */
@ -88,22 +88,21 @@ class FormField extends Text
} }
/** /**
* Set type. * Set type
* *
* @param string $value * @param string $value
*
* @return self * @return self
*/ */
public function setType($value) public function setType($value)
{ {
$enum = ['textinput', 'checkbox', 'dropdown']; $enum = array('textinput', 'checkbox', 'dropdown');
$this->type = $this->setEnumVal($value, $enum, $this->type); $this->type = $this->setEnumVal($value, $enum, $this->type);
return $this; return $this;
} }
/** /**
* Get name. * Get name
* *
* @return string * @return string
*/ */
@ -113,10 +112,9 @@ class FormField extends Text
} }
/** /**
* Set name. * Set name
*
* @param bool|int|string $value
* *
* @param string|bool|int $value
* @return self * @return self
*/ */
public function setName($value) public function setName($value)
@ -127,9 +125,9 @@ class FormField extends Text
} }
/** /**
* Get default. * Get default
* *
* @return bool|int|string * @return string|bool|int
*/ */
public function getDefault() public function getDefault()
{ {
@ -137,10 +135,9 @@ class FormField extends Text
} }
/** /**
* Set default. * Set default
*
* @param bool|int|string $value
* *
* @param string|bool|int $value
* @return self * @return self
*/ */
public function setDefault($value) public function setDefault($value)
@ -151,9 +148,9 @@ class FormField extends Text
} }
/** /**
* Get value. * Get value
* *
* @return bool|int|string * @return string|bool|int
*/ */
public function getValue() public function getValue()
{ {
@ -161,10 +158,9 @@ class FormField extends Text
} }
/** /**
* Set value. * Set value
*
* @param bool|int|string $value
* *
* @param string|bool|int $value
* @return self * @return self
*/ */
public function setValue($value) public function setValue($value)
@ -175,7 +171,7 @@ class FormField extends Text
} }
/** /**
* Get entries. * Get entries
* *
* @return array * @return array
*/ */
@ -185,10 +181,9 @@ class FormField extends Text
} }
/** /**
* Set entries. * Set entries
* *
* @param array $value * @param array $value
*
* @return self * @return self
*/ */
public function setEntries($value) public function setEntries($value)

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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;
/** /**
* Header element. * Header element
*/ */
class Header extends Footer class Header extends Footer
{ {
@ -28,11 +28,10 @@ class Header extends Footer
protected $container = 'Header'; protected $container = 'Header';
/** /**
* Add a Watermark Element. * Add a Watermark Element
* *
* @param string $src * @param string $src
* @param mixed $style * @param mixed $style
*
* @return Image * @return Image
*/ */
public function addWatermark($src, $style = null) public function addWatermark($src, $style = null)

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
@ -25,12 +25,12 @@ use PhpOffice\PhpWord\Shared\ZipArchive;
use PhpOffice\PhpWord\Style\Image as ImageStyle; use PhpOffice\PhpWord\Style\Image as ImageStyle;
/** /**
* Image element. * Image element
*/ */
class Image extends AbstractElement class Image extends AbstractElement
{ {
/** /**
* Image source type constants. * Image source type constants
*/ */
const SOURCE_LOCAL = 'local'; // Local images const SOURCE_LOCAL = 'local'; // Local images
const SOURCE_GD = 'gd'; // Generated using GD const SOURCE_GD = 'gd'; // Generated using GD
@ -38,103 +38,106 @@ class Image extends AbstractElement
const SOURCE_STRING = 'string'; // Image from string const SOURCE_STRING = 'string'; // Image from string
/** /**
* Image source. * Image source
* *
* @var string * @var string
*/ */
private $source; private $source;
/** /**
* Source type: local|gd|archive. * Source type: local|gd|archive
* *
* @var string * @var string
*/ */
private $sourceType; private $sourceType;
/** /**
* Image style. * Image style
* *
* @var ImageStyle * @var ImageStyle
*/ */
private $style; private $style;
/** /**
* Is watermark. * Is watermark
* *
* @var bool * @var bool
*/ */
private $watermark; private $watermark;
/** /**
* Name of image. * Name of image
* *
* @var string * @var string
*/ */
private $name; private $name;
/** /**
* Image type. * Image type
* *
* @var string * @var string
*/ */
private $imageType; private $imageType;
/** /**
* Image create function. * Image create function
* *
* @var string * @var string
*/ */
private $imageCreateFunc; private $imageCreateFunc;
/** /**
* Image function. * Image function
* *
* @var string * @var string
*/ */
private $imageFunc; private $imageFunc;
/** /**
* Image extension. * Image extension
* *
* @var string * @var string
*/ */
private $imageExtension; private $imageExtension;
/** /**
* Is memory image. * Is memory image
* *
* @var bool * @var bool
*/ */
private $memoryImage; private $memoryImage;
/** /**
* Image target file name. * Image target file name
* *
* @var string * @var string
*/ */
private $target; private $target;
/** /**
* Image media index. * Image media index
* *
* @var int * @var int
*/ */
private $mediaIndex; private $mediaIndex;
/** /**
* Has media relation flag; true for Link, Image, and Object. * Has media relation flag; true for Link, Image, and Object
* *
* @var bool * @var bool
*/ */
protected $mediaRelation = true; protected $mediaRelation = true;
/** /**
* Create new image element. * Create new image element
* *
* @param string $source * @param string $source
* @param mixed $style * @param mixed $style
* @param bool $watermark * @param bool $watermark
* @param string $name * @param string $name
*
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
*/ */
public function __construct($source, $style = null, $watermark = false, $name = null) public function __construct($source, $style = null, $watermark = false, $name = null)
{ {
@ -147,7 +150,7 @@ class Image extends AbstractElement
} }
/** /**
* Get Image style. * Get Image style
* *
* @return ImageStyle * @return ImageStyle
*/ */
@ -157,7 +160,7 @@ class Image extends AbstractElement
} }
/** /**
* Get image source. * Get image source
* *
* @return string * @return string
*/ */
@ -167,7 +170,7 @@ class Image extends AbstractElement
} }
/** /**
* Get image source type. * Get image source type
* *
* @return string * @return string
*/ */
@ -177,17 +180,17 @@ class Image extends AbstractElement
} }
/** /**
* Sets the image name. * Sets the image name
* *
* @param string $value * @param string $value
*/ */
public function setName($value): void public function setName($value)
{ {
$this->name = $value; $this->name = $value;
} }
/** /**
* Get image name. * Get image name
* *
* @return null|string * @return null|string
*/ */
@ -197,7 +200,7 @@ class Image extends AbstractElement
} }
/** /**
* Get image media ID. * Get image media ID
* *
* @return string * @return string
*/ */
@ -207,7 +210,7 @@ class Image extends AbstractElement
} }
/** /**
* Get is watermark. * Get is watermark
* *
* @return bool * @return bool
*/ */
@ -217,17 +220,17 @@ class Image extends AbstractElement
} }
/** /**
* Set is watermark. * Set is watermark
* *
* @param bool $value * @param bool $value
*/ */
public function setIsWatermark($value): void public function setIsWatermark($value)
{ {
$this->watermark = $value; $this->watermark = $value;
} }
/** /**
* Get image type. * Get image type
* *
* @return string * @return string
*/ */
@ -237,7 +240,7 @@ class Image extends AbstractElement
} }
/** /**
* Get image create function. * Get image create function
* *
* @return string * @return string
*/ */
@ -247,7 +250,7 @@ class Image extends AbstractElement
} }
/** /**
* Get image function. * Get image function
* *
* @return string * @return string
*/ */
@ -257,7 +260,7 @@ class Image extends AbstractElement
} }
/** /**
* Get image extension. * Get image extension
* *
* @return string * @return string
*/ */
@ -267,7 +270,7 @@ class Image extends AbstractElement
} }
/** /**
* Get is memory image. * Get is memory image
* *
* @return bool * @return bool
*/ */
@ -277,7 +280,7 @@ class Image extends AbstractElement
} }
/** /**
* Get target file name. * Get target file name
* *
* @return string * @return string
*/ */
@ -291,13 +294,13 @@ class Image extends AbstractElement
* *
* @param string $value * @param string $value
*/ */
public function setTarget($value): void public function setTarget($value)
{ {
$this->target = $value; $this->target = $value;
} }
/** /**
* Get media index. * Get media index
* *
* @return int * @return int
*/ */
@ -311,18 +314,16 @@ class Image extends AbstractElement
* *
* @param int $value * @param int $value
*/ */
public function setMediaIndex($value): void public function setMediaIndex($value)
{ {
$this->mediaIndex = $value; $this->mediaIndex = $value;
} }
/** /**
* Get image string data. * Get image string data
* *
* @param bool $base64 * @param bool $base64
* * @return string|null
* @return null|string
*
* @since 0.11.0 * @since 0.11.0
*/ */
public function getImageStringData($base64 = false) public function getImageStringData($base64 = false)
@ -337,7 +338,7 @@ class Image extends AbstractElement
// Return null if not found // Return null if not found
if ($this->sourceType == self::SOURCE_ARCHIVE) { if ($this->sourceType == self::SOURCE_ARCHIVE) {
$source = substr($source, 6); $source = substr($source, 6);
[$zipFilename, $imageFilename] = explode('#', $source); list($zipFilename, $imageFilename) = explode('#', $source);
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open($zipFilename) !== false) { if ($zip->open($zipFilename) !== false) {
@ -397,8 +398,11 @@ 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.
*
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
*/ */
private function checkImage(): void private function checkImage()
{ {
$this->setSourceType(); $this->setSourceType();
@ -406,19 +410,19 @@ class Image extends AbstractElement
if ($this->sourceType == self::SOURCE_ARCHIVE) { if ($this->sourceType == self::SOURCE_ARCHIVE) {
$imageData = $this->getArchiveImageSize($this->source); $imageData = $this->getArchiveImageSize($this->source);
} elseif ($this->sourceType == self::SOURCE_STRING) { } elseif ($this->sourceType == self::SOURCE_STRING) {
$imageData = @getimagesizefromstring($this->source); $imageData = $this->getStringImageSize($this->source);
} else { } else {
$imageData = @getimagesize($this->source); $imageData = @getimagesize($this->source);
} }
if (!is_array($imageData)) { if (!is_array($imageData)) {
throw new InvalidImageException(sprintf('Invalid image: %s', $this->source)); throw new InvalidImageException(sprintf('Invalid image: %s', $this->source));
} }
[$actualWidth, $actualHeight, $imageType] = $imageData; list($actualWidth, $actualHeight, $imageType) = $imageData;
// Check image type support // Check image type support
$supportedTypes = [IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG]; $supportedTypes = array(IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG);
if ($this->sourceType != self::SOURCE_GD && $this->sourceType != self::SOURCE_STRING) { if ($this->sourceType != self::SOURCE_GD && $this->sourceType != self::SOURCE_STRING) {
$supportedTypes = array_merge($supportedTypes, [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)) {
throw new UnsupportedImageTypeException(); throw new UnsupportedImageTypeException();
@ -433,7 +437,7 @@ class Image extends AbstractElement
/** /**
* Set source type. * Set source type.
*/ */
private function setSourceType(): void private function setSourceType()
{ {
if (stripos(strrev($this->source), strrev('.php')) === 0) { if (stripos(strrev($this->source), strrev('.php')) === 0) {
$this->memoryImage = true; $this->memoryImage = true;
@ -460,19 +464,21 @@ class Image extends AbstractElement
} }
/** /**
* Get image size from archive. * Get image size from archive
* *
* @since 0.12.0 Throws CreateTemporaryFileException. * @since 0.12.0 Throws CreateTemporaryFileException.
* *
* @param string $source * @param string $source
* *
* @return null|array * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
*
* @return array|null
*/ */
private function getArchiveImageSize($source) private function getArchiveImageSize($source)
{ {
$imageData = null; $imageData = null;
$source = substr($source, 6); $source = substr($source, 6);
[$zipFilename, $imageFilename] = explode('#', $source); list($zipFilename, $imageFilename) = explode('#', $source);
$tempFilename = tempnam(Settings::getTempDir(), 'PHPWordImage'); $tempFilename = tempnam(Settings::getTempDir(), 'PHPWordImage');
if (false === $tempFilename) { if (false === $tempFilename) {
@ -495,40 +501,55 @@ class Image extends AbstractElement
return $imageData; return $imageData;
} }
/**
* get image size from string
*
* @param string $source
*
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
*/
private function getStringImageSize($source)
{
$result = false;
if (!function_exists('getimagesizefromstring')) {
$uri = 'data://application/octet-stream;base64,' . base64_encode($source);
$result = @getimagesize($uri);
} else {
$result = @getimagesizefromstring($source);
}
return $result;
}
/** /**
* Set image functions and extensions. * Set image functions and extensions.
*/ */
private function setFunctions(): void private function setFunctions()
{ {
switch ($this->imageType) { switch ($this->imageType) {
case 'image/png': case 'image/png':
$this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : '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 = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : '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 = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefromjpeg'; $this->imageCreateFunc = $this->sourceType == self::SOURCE_STRING ? 'imagecreatefromstring' : 'imagecreatefromjpeg';
$this->imageFunc = 'imagejpeg'; $this->imageFunc = 'imagejpeg';
$this->imageExtension = 'jpg'; $this->imageExtension = 'jpg';
break; break;
case 'image/bmp': case 'image/bmp':
case 'image/x-ms-bmp': case 'image/x-ms-bmp':
$this->imageType = 'image/bmp'; $this->imageType = 'image/bmp';
$this->imageExtension = 'bmp'; $this->imageExtension = 'bmp';
break; break;
case 'image/tiff': case 'image/tiff':
$this->imageExtension = 'tif'; $this->imageExtension = 'tif';
break; break;
} }
} }
@ -539,7 +560,7 @@ class Image extends AbstractElement
* @param int $actualWidth * @param int $actualWidth
* @param int $actualHeight * @param int $actualHeight
*/ */
private function setProportionalSize($actualWidth, $actualHeight): void private function setProportionalSize($actualWidth, $actualHeight)
{ {
$styleWidth = $this->style->getWidth(); $styleWidth = $this->style->getWidth();
$styleHeight = $this->style->getHeight(); $styleHeight = $this->style->getHeight();
@ -554,4 +575,28 @@ class Image extends AbstractElement
} }
} }
} }
/**
* Get is watermark
*
* @deprecated 0.10.0
*
* @codeCoverageIgnore
*/
public function getIsWatermark()
{
return $this->isWatermark();
}
/**
* Get is memory image
*
* @deprecated 0.10.0
*
* @codeCoverageIgnore
*/
public function getIsMemImage()
{
return $this->isMemImage();
}
} }

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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,19 +20,19 @@ namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Line as LineStyle; use PhpOffice\PhpWord\Style\Line as LineStyle;
/** /**
* Line element. * Line element
*/ */
class Line extends AbstractElement class Line extends AbstractElement
{ {
/** /**
* Line style. * Line style
* *
* @var \PhpOffice\PhpWord\Style\Line * @var \PhpOffice\PhpWord\Style\Line
*/ */
private $style; private $style;
/** /**
* Create new line element. * Create new line element
* *
* @param mixed $style * @param mixed $style
*/ */
@ -42,7 +42,7 @@ class Line extends AbstractElement
} }
/** /**
* Get line style. * Get line style
* *
* @return \PhpOffice\PhpWord\Style\Line * @return \PhpOffice\PhpWord\Style\Line
*/ */

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
@ -22,54 +22,54 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/** /**
* Link element. * Link element
*/ */
class Link extends AbstractElement class Link extends AbstractElement
{ {
/** /**
* Link source. * Link source
* *
* @var string * @var string
*/ */
private $source; private $source;
/** /**
* Link text. * Link text
* *
* @var string * @var string
*/ */
private $text; private $text;
/** /**
* Font style. * Font style
* *
* @var \PhpOffice\PhpWord\Style\Font|string * @var string|\PhpOffice\PhpWord\Style\Font
*/ */
private $fontStyle; private $fontStyle;
/** /**
* Paragraph style. * Paragraph style
* *
* @var \PhpOffice\PhpWord\Style\Paragraph|string * @var string|\PhpOffice\PhpWord\Style\Paragraph
*/ */
private $paragraphStyle; private $paragraphStyle;
/** /**
* Has media relation flag; true for Link, Image, and Object. * Has media relation flag; true for Link, Image, and Object
* *
* @var bool * @var bool
*/ */
protected $mediaRelation = true; protected $mediaRelation = true;
/** /**
* Has internal flag - anchor to internal bookmark. * Has internal flag - anchor to internal bookmark
* *
* @var bool * @var bool
*/ */
protected $internal = false; protected $internal = false;
/** /**
* Create a new Link Element. * Create a new Link Element
* *
* @param string $source * @param string $source
* @param string $text * @param string $text
@ -80,14 +80,14 @@ class Link extends AbstractElement
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false) public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
{ {
$this->source = SharedText::toUTF8($source); $this->source = SharedText::toUTF8($source);
$this->text = null === $text ? $this->source : SharedText::toUTF8($text); $this->text = is_null($text) ? $this->source : SharedText::toUTF8($text);
$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;
} }
/** /**
* Get link source. * Get link source
* *
* @return string * @return string
*/ */
@ -97,7 +97,7 @@ class Link extends AbstractElement
} }
/** /**
* Get link text. * Get link text
* *
* @return string * @return string
*/ */
@ -107,9 +107,9 @@ class Link extends AbstractElement
} }
/** /**
* Get Text style. * Get Text style
* *
* @return \PhpOffice\PhpWord\Style\Font|string * @return string|\PhpOffice\PhpWord\Style\Font
*/ */
public function getFontStyle() public function getFontStyle()
{ {
@ -117,9 +117,9 @@ class Link extends AbstractElement
} }
/** /**
* Get Paragraph style. * Get Paragraph style
* *
* @return \PhpOffice\PhpWord\Style\Paragraph|string * @return string|\PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {
@ -127,7 +127,49 @@ class Link extends AbstractElement
} }
/** /**
* is internal. * Get link target
*
* @deprecated 0.12.0
*
* @return string
*
* @codeCoverageIgnore
*/
public function getTarget()
{
return $this->source;
}
/**
* Get Link source
*
* @deprecated 0.10.0
*
* @return string
*
* @codeCoverageIgnore
*/
public function getLinkSrc()
{
return $this->getSource();
}
/**
* Get Link name
*
* @deprecated 0.10.0
*
* @return string
*
* @codeCoverageIgnore
*/
public function getLinkName()
{
return $this->getText();
}
/**
* is internal
* *
* @return bool * @return bool
*/ */

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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,38 +21,38 @@ use PhpOffice\PhpWord\Shared\Text as SharedText;
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle; use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
/** /**
* List item element. * List item element
*/ */
class ListItem extends AbstractElement class ListItem extends AbstractElement
{ {
/** /**
* Element style. * Element style
* *
* @var \PhpOffice\PhpWord\Style\ListItem * @var \PhpOffice\PhpWord\Style\ListItem
*/ */
private $style; private $style;
/** /**
* Text object. * Text object
* *
* @var \PhpOffice\PhpWord\Element\Text * @var \PhpOffice\PhpWord\Element\Text
*/ */
private $textObject; private $textObject;
/** /**
* Depth. * Depth
* *
* @var int * @var int
*/ */
private $depth; private $depth;
/** /**
* Create a new ListItem. * Create a new ListItem
* *
* @param string $text * @param string $text
* @param int $depth * @param int $depth
* @param mixed $fontStyle * @param mixed $fontStyle
* @param null|array|string $listStyle * @param array|string|null $listStyle
* @param mixed $paragraphStyle * @param mixed $paragraphStyle
*/ */
public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
@ -61,7 +61,7 @@ class ListItem extends AbstractElement
$this->depth = $depth; $this->depth = $depth;
// Version >= 0.10.0 will pass numbering style name. Older version will use old method // Version >= 0.10.0 will pass numbering style name. Older version will use old method
if (null !== $listStyle && is_string($listStyle)) { if (!is_null($listStyle) && is_string($listStyle)) {
$this->style = new ListItemStyle($listStyle); // @codeCoverageIgnore $this->style = new ListItemStyle($listStyle); // @codeCoverageIgnore
} else { } else {
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true); $this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
@ -69,7 +69,7 @@ class ListItem extends AbstractElement
} }
/** /**
* Get style. * Get style
* *
* @return \PhpOffice\PhpWord\Style\ListItem * @return \PhpOffice\PhpWord\Style\ListItem
*/ */
@ -79,7 +79,7 @@ class ListItem extends AbstractElement
} }
/** /**
* Get Text object. * Get Text object
* *
* @return \PhpOffice\PhpWord\Element\Text * @return \PhpOffice\PhpWord\Element\Text
*/ */
@ -89,7 +89,7 @@ class ListItem extends AbstractElement
} }
/** /**
* Get depth. * Get depth
* *
* @return int * @return int
*/ */
@ -99,10 +99,9 @@ class ListItem extends AbstractElement
} }
/** /**
* Get text. * Get text
* *
* @return string * @return string
*
* @since 0.11.0 * @since 0.11.0
*/ */
public function getText() public function getText()

View File

@ -1,26 +1,26 @@
<?php <?php
/** /**
* This file is part of PHPWord - A pure PHP library for reading and writing * This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents. * word processing documents.
* *
* PHPWord is free software distributed under the terms of the GNU Lesser * PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation. * General Public License version 3 as published by the Free Software Foundation.
* *
* For the full copyright and license information, please read the LICENSE * For the full copyright and license information, please read the LICENSE
* 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.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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\Style\ListItem as ListItemStyle; use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
/** /**
* List item element. * List item element
*/ */
class ListItemRun extends TextRun class ListItemRun extends TextRun
{ {
@ -30,24 +30,24 @@ class ListItemRun extends TextRun
protected $container = 'ListItemRun'; protected $container = 'ListItemRun';
/** /**
* ListItem Style. * ListItem Style
* *
* @var \PhpOffice\PhpWord\Style\ListItem * @var \PhpOffice\PhpWord\Style\ListItem
*/ */
private $style; private $style;
/** /**
* ListItem Depth. * ListItem Depth
* *
* @var int * @var int
*/ */
private $depth; private $depth;
/** /**
* Create a new ListItem. * Create a new ListItem
* *
* @param int $depth * @param int $depth
* @param null|array|string $listStyle * @param array|string|null $listStyle
* @param mixed $paragraphStyle * @param mixed $paragraphStyle
*/ */
public function __construct($depth = 0, $listStyle = null, $paragraphStyle = null) public function __construct($depth = 0, $listStyle = null, $paragraphStyle = null)
@ -55,7 +55,7 @@ class ListItemRun extends TextRun
$this->depth = $depth; $this->depth = $depth;
// Version >= 0.10.0 will pass numbering style name. Older version will use old method // Version >= 0.10.0 will pass numbering style name. Older version will use old method
if (null !== $listStyle && is_string($listStyle)) { if (!is_null($listStyle) && is_string($listStyle)) {
$this->style = new ListItemStyle($listStyle); $this->style = new ListItemStyle($listStyle);
} else { } else {
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true); $this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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,54 +21,56 @@ use PhpOffice\PhpWord\Exception\InvalidObjectException;
use PhpOffice\PhpWord\Style\Image as ImageStyle; use PhpOffice\PhpWord\Style\Image as ImageStyle;
/** /**
* OLEObject element. * OLEObject element
*/ */
class OLEObject extends AbstractElement class OLEObject extends AbstractElement
{ {
/** /**
* Ole-Object Src. * Ole-Object Src
* *
* @var string * @var string
*/ */
private $source; private $source;
/** /**
* Image Style. * Image Style
* *
* @var \PhpOffice\PhpWord\Style\Image * @var \PhpOffice\PhpWord\Style\Image
*/ */
private $style; private $style;
/** /**
* Icon. * Icon
* *
* @var string * @var string
*/ */
private $icon; private $icon;
/** /**
* Image Relation ID. * Image Relation ID
* *
* @var int * @var int
*/ */
private $imageRelationId; private $imageRelationId;
/** /**
* Has media relation flag; true for Link, Image, and Object. * Has media relation flag; true for Link, Image, and Object
* *
* @var bool * @var bool
*/ */
protected $mediaRelation = true; protected $mediaRelation = true;
/** /**
* Create a new Ole-Object Element. * Create a new Ole-Object Element
* *
* @param string $source * @param string $source
* @param mixed $style * @param mixed $style
*
* @throws \PhpOffice\PhpWord\Exception\InvalidObjectException
*/ */
public function __construct($source, $style = null) public function __construct($source, $style = null)
{ {
$supportedTypes = ['xls', 'doc', 'ppt', 'xlsx', 'docx', 'pptx']; $supportedTypes = array('xls', 'doc', 'ppt', 'xlsx', 'docx', 'pptx');
$pathInfo = pathinfo($source); $pathInfo = pathinfo($source);
if (file_exists($source) && in_array($pathInfo['extension'], $supportedTypes)) { if (file_exists($source) && in_array($pathInfo['extension'], $supportedTypes)) {
@ -88,7 +90,7 @@ class OLEObject extends AbstractElement
} }
/** /**
* Get object source. * Get object source
* *
* @return string * @return string
*/ */
@ -98,7 +100,7 @@ class OLEObject extends AbstractElement
} }
/** /**
* Get object style. * Get object style
* *
* @return \PhpOffice\PhpWord\Style\Image * @return \PhpOffice\PhpWord\Style\Image
*/ */
@ -108,7 +110,7 @@ class OLEObject extends AbstractElement
} }
/** /**
* Get object icon. * Get object icon
* *
* @return string * @return string
*/ */
@ -118,7 +120,7 @@ class OLEObject extends AbstractElement
} }
/** /**
* Get image relation ID. * Get image relation ID
* *
* @return int * @return int
*/ */
@ -132,8 +134,36 @@ class OLEObject extends AbstractElement
* *
* @param int $rId * @param int $rId
*/ */
public function setImageRelationId($rId): void public function setImageRelationId($rId)
{ {
$this->imageRelationId = $rId; $this->imageRelationId = $rId;
} }
/**
* Get Object ID
*
* @deprecated 0.10.0
*
* @return int
*
* @codeCoverageIgnore
*/
public function getObjectId()
{
return $this->relationId + 1325353440;
}
/**
* Set Object ID
*
* @deprecated 0.10.0
*
* @param int $objId
*
* @codeCoverageIgnore
*/
public function setObjectId($objId)
{
$this->relationId = $objId;
}
} }

View File

@ -11,19 +11,19 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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;
/** /**
* Page break element. * Page break element
*/ */
class PageBreak extends AbstractElement class PageBreak extends AbstractElement
{ {
/** /**
* Create new page break. * Create new page break
*/ */
public function __construct() public function __construct()
{ {

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
@ -22,33 +22,33 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/** /**
* Preserve text/field element. * Preserve text/field element
*/ */
class PreserveText extends AbstractElement class PreserveText extends AbstractElement
{ {
/** /**
* Text content. * Text content
* *
* @var array|string * @var string|array
*/ */
private $text; private $text;
/** /**
* Text style. * Text style
* *
* @var \PhpOffice\PhpWord\Style\Font|string * @var string|\PhpOffice\PhpWord\Style\Font
*/ */
private $fontStyle; private $fontStyle;
/** /**
* Paragraph style. * Paragraph style
* *
* @var \PhpOffice\PhpWord\Style\Paragraph|string * @var string|\PhpOffice\PhpWord\Style\Paragraph
*/ */
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
@ -60,16 +60,16 @@ class PreserveText extends AbstractElement
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
$this->text = SharedText::toUTF8($text); $this->text = SharedText::toUTF8($text);
$matches = preg_split('/({.*?})/', $this->text ?? '', -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
if (isset($matches[0])) { if (isset($matches[0])) {
$this->text = $matches; $this->text = $matches;
} }
} }
/** /**
* Get Text style. * Get Text style
* *
* @return \PhpOffice\PhpWord\Style\Font|string * @return string|\PhpOffice\PhpWord\Style\Font
*/ */
public function getFontStyle() public function getFontStyle()
{ {
@ -77,9 +77,9 @@ class PreserveText extends AbstractElement
} }
/** /**
* Get Paragraph style. * Get Paragraph style
* *
* @return \PhpOffice\PhpWord\Style\Paragraph|string * @return string|\PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {
@ -87,9 +87,9 @@ class PreserveText extends AbstractElement
} }
/** /**
* Get Text content. * Get Text content
* *
* @return array|string * @return string|array
*/ */
public function getText() public function getText()
{ {

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @see https://github.com/PHPOffice/PHPWord * @see https://github.com/PHPOffice/PHPWord
* * @copyright 2010-2018 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,35 +20,35 @@ namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Row as RowStyle; use PhpOffice\PhpWord\Style\Row as RowStyle;
/** /**
* Table row element. * Table row element
* *
* @since 0.8.0 * @since 0.8.0
*/ */
class Row extends AbstractElement class Row extends AbstractElement
{ {
/** /**
* Row height. * Row height
* *
* @var int * @var int
*/ */
private $height; private $height = null;
/** /**
* Row style. * Row style
* *
* @var \PhpOffice\PhpWord\Style\Row * @var \PhpOffice\PhpWord\Style\Row
*/ */
private $style; private $style;
/** /**
* Row cells. * Row cells
* *
* @var \PhpOffice\PhpWord\Element\Cell[] * @var \PhpOffice\PhpWord\Element\Cell[]
*/ */
private $cells = []; private $cells = array();
/** /**
* Create a new table row. * Create a new table row
* *
* @param int $height * @param int $height
* @param mixed $style * @param mixed $style
@ -60,11 +60,10 @@ class Row extends AbstractElement
} }
/** /**
* Add a cell. * Add a cell
* *
* @param int $width * @param int $width
* @param mixed $style * @param mixed $style
*
* @return \PhpOffice\PhpWord\Element\Cell * @return \PhpOffice\PhpWord\Element\Cell
*/ */
public function addCell($width = null, $style = null) public function addCell($width = null, $style = null)
@ -77,7 +76,7 @@ class Row extends AbstractElement
} }
/** /**
* Get all cells. * Get all cells
* *
* @return \PhpOffice\PhpWord\Element\Cell[] * @return \PhpOffice\PhpWord\Element\Cell[]
*/ */
@ -87,7 +86,7 @@ class Row extends AbstractElement
} }
/** /**
* Get row style. * Get row style
* *
* @return \PhpOffice\PhpWord\Style\Row * @return \PhpOffice\PhpWord\Style\Row
*/ */
@ -97,7 +96,7 @@ class Row extends AbstractElement
} }
/** /**
* Get row height. * Get row height
* *
* @return int * @return int
*/ */

Some files were not shown because too many files have changed in this diff Show More