diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000000..a67fa0b144
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,12 @@
+### Description
+
+Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
+
+Fixes # (issue)
+
+### Checklist:
+
+- [ ] My CI is :green_circle:
+- [ ] I have covered by unit tests my new code (check build/coverage for coverage report)
+- [ ] I have updated the [documentation](https://github.com/PHPOffice/PHPPresentation/tree/develop/docs) to describe the changes
+- [ ] I have updated the [changelog](https://github.com/PHPOffice/PHPPresentation/blob/develop/docs/changes/1.1.0.md)
\ No newline at end of file
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index fcc83844ae..e188ab4f70 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -25,7 +25,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: '7.4'
+ php-version: '8.1'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
coverage: xdebug
- name: Create directory public/coverage
@@ -39,7 +39,7 @@ jobs:
- name: Build Coverage Report
run: XDEBUG_MODE=coverage ./vendor/bin/phpunit -c ./ --coverage-text --coverage-html ./public/coverage
- name: Build Documentation
- run: ./phpDocumentor.phar -d ./src -t ./public/docs
+ run: ./phpDocumentor.phar run -d ./src -t ./public/docs
### Deploy
- name: Deploy
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index f6211e31cd..3738b4694b 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -47,7 +47,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
+ php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
@@ -63,19 +63,19 @@ jobs:
run: ./vendor/bin/phpstan analyse -c phpstan.neon.dist
phpunit:
- name: PHPUnit
+ name: PHPUnit ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
- php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
+ php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: gd, xml, zip
- coverage: xdebug
+ coverage: ${{ (matrix.php == '7.3') && 'xdebug' || 'none' }}
- uses: actions/checkout@v2
@@ -83,6 +83,11 @@ jobs:
run: composer install --ansi --prefer-dist --no-interaction --no-progress
- name: Run phpunit
+ if: matrix.php != '7.3'
+ run: ./vendor/bin/phpunit -c phpunit.xml.dist --no-coverage
+
+ - name: Run phpunit
+ if: matrix.php == '7.3'
run: ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/clover.xml
- name: Upload coverage results to Coveralls
@@ -100,7 +105,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
+ php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
diff --git a/.gitignore b/.gitignore
index afe22ddd18..4cdc9c6013 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ Desktop.ini
### Continuous Integration
build/
phpunit.xml
+php-cs-fixer.phar
.php-cs-fixer.cache
.phpunit.result.cache
composer.phar
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 532c34a425..dd9be6be69 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -6,36 +6,215 @@
->setUsingCache(true)
->setRiskyAllowed(true)
->setRules([
- '@Symfony' => true,
+ 'align_multiline_comment' => true,
'array_indentation' => true,
- 'cast_spaces' => [
- 'space' => 'single',
- ],
+ '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,
- 'concat_space' => [
- 'spacing' => 'one',
- ],
- 'error_suppression' => [
- 'mute_deprecation_error' => false,
- 'noise_remaining_usages' => false,
- 'noise_remaining_usages_exclude' => [],
- ],
- 'function_to_constant' => false,
+ '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,
- 'no_alias_functions' => false,
- 'no_superfluous_phpdoc_tags' => false,
- 'non_printable_character' => [
- 'use_escape_sequences_in_strings' => true,
- ],
- 'phpdoc_align' => [
- 'align' => 'left',
- ],
- 'phpdoc_summary' => false,
- 'protected_to_private' => false,
- 'self_accessor' => false,
+ '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,
- 'single_line_throw' => false,
- 'no_alias_language_construct_call' => false,
])
->getFinder()
->in(__DIR__)
diff --git a/composer.json b/composer.json
index 6052836d6e..be83206bc3 100644
--- a/composer.json
+++ b/composer.json
@@ -28,7 +28,7 @@
"require-dev": {
"phpunit/phpunit": ">=7.0",
"phpmd/phpmd": "2.*",
- "phpstan/phpstan": "^0.12.88"
+ "phpstan/phpstan": "^0.12.88 || ^1.0.0"
},
"suggest": {
"ext-gd": "Required to add images"
@@ -61,7 +61,9 @@
"php samples/Sample_17_Comment.php",
"php samples/Sample_18_Animation.php",
"php samples/Sample_19_SlideMaster.php",
- "php samples/Sample_20_ExternalSlide.php"
+ "php samples/Sample_20_SlideLayout.php",
+ "php samples/Sample_21_AutoShape.php",
+ "php samples/Sample_22_ExternalSlide.php"
]
}
}
diff --git a/docs/changes/1.0.0.md b/docs/changes/1.0.0.md
index c23af1e93b..270ebbd8a6 100644
--- a/docs/changes/1.0.0.md
+++ b/docs/changes/1.0.0.md
@@ -1,9 +1,9 @@
-# 1.0.0 - WIP
+# 1.0.0
## Bugfix
-- PowerPoint2007 Writer : Text is subscripted when set superscript to false - [[@qmachard]](https://github.com/qmachard])(https://github.com/qmachard) GH-360
-- Core : Defining width & height of a shape don't return any error if width & height were equal to 0 - [[@surger]](https://github.com/surger])(https://github.com/surger) GH-555
-- ODPresentation Writer : Display axis title depending the visibility - [[@Progi1984]](https://github.com/Progi1984])(https://github.com/Progi1984) GH-410
+- PowerPoint2007 Writer : Text is subscripted when set superscript to false - [@qmachard](https://github.com/qmachard) GH-360
+- Core : Defining width & height of a shape don't return any error if width & height were equal to 0 - [@surger](https://github.com/surger) GH-555
+- ODPresentation Writer : Display axis title depending the visibility - [@Progi1984](https://github.com/Progi1984) GH-410
## Changes
- Dropped support for HHVM - [@sunspikes](https://github.com/sunspikes) GH-556
diff --git a/docs/changes/1.1.0.md b/docs/changes/1.1.0.md
new file mode 100644
index 0000000000..d9ee1da481
--- /dev/null
+++ b/docs/changes/1.1.0.md
@@ -0,0 +1,63 @@
+# 1.1.0 - WIP
+
+## Features
+
+- Support for axis options - [@mindline](https://github.com/mindline-analytics) in [#676](https://github.com/PHPOffice/PHPPresentation/pull/676)
+ - Axis intersection point (axis crossing) through `setCrossesAt`/ `getCrossesAt`
+ - Reverse axis order through `setIsReversedOrder`/ `isReversedOrder`
+ - PowerPoint2007 Writer
+- Support for Hyperlink Text Color - [@MartynasJanu](https://github.com/MartynasJanu) & [@Progi1984](https://github.com/Progi1984) in [#682](https://github.com/PHPOffice/PHPPresentation/pull/682)
+ - PowerPoint2007 Reader
+ - PowerPoint2007 Writer
+- Added support for PHP 8.2 & 8.3 - [@Progi1984](https://github.com/Progi1984) in [#769](https://github.com/PHPOffice/PHPPresentation/pull/769)
+- PowerPoint 2007 Writer : Added support to Font for Axis tick label & chinese font support - [@zhengwhizz](https://github.com/zhengwhizz) in [#774](https://github.com/PHPOffice/PHPPresentation/pull/774)
+- Support for Capitalization for Font - [@CxRxExO](https://github.com/CxRxExO) & [@Progi1984](https://github.com/Progi1984) in [#779](https://github.com/PHPOffice/PHPPresentation/pull/779)
+ - ODPresentation Reader
+ - ODPresentation Writer
+ - PowerPoint2007 Reader
+ - PowerPoint2007 Writer
+- PowerPoint2007 Writer: Enable style and position of a Placeholder - [@qmachard](https://github.com/qmachard) in [#787](https://github.com/PHPOffice/PHPPresentation/pull/787)
+- PowerPoint2007 Reader: Added support for thumbnail image - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+
+## Improvements
+- Slide : Raised max value for identifier rand call - [@Scheissy](https://github.com/Scheissy) in [#777](https://github.com/PHPOffice/PHPPresentation/pull/777)
+- Document Properties : Support for Revision & Status - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+ - PowerPoint2007 Reader
+ - PowerPoint2007 Writer
+- Presentation Properties : Added support to define content of the thumbnail - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+- Font : Support for Capitalization, Strikethrough, Pitch Family, Charset & Panose - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+ - PowerPoint2007 Reader
+ - PowerPoint2007 Writer
+- Font : Replaced Superscript/Subscript by baseline in PowerPoint2007 Writer - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+- RichText : Support for Vertical Align - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+ - PowerPoint2007 Reader
+ - PowerPoint2007 Writer
+- Shadow : Support for Type Inner & Reflection - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+ - PowerPoint2007 Reader
+ - PowerPoint2007 Writer
+- Presentation : Added ability to add a slide at any position - [@Progi1984](https://github.com/Progi1984) in [#810](https://github.com/PHPOffice/PHPPresentation/pull/810)
+
+## Bugfixes
+
+- PowerPoint2077 Writer : Fixed broken PPT Presentations due to MS Office update 2309 - [@WFarmerEthisphere](https://github.com/WFarmerEthisphere) in [#770](https://github.com/PHPOffice/PHPPresentation/pull/770)
+- PowerPoint2077 Writer : Fixed error when defining min/max bounds to 0 - [@LilyEssence](https://github.com/LilyEssence) in [#771](https://github.com/PHPOffice/PHPPresentation/pull/771)
+- PowerPoint2007 Writer : Outline : Fixed the base unit - [@Pakku](https://github.com/Pakku) in [#772](https://github.com/PHPOffice/PHPPresentation/pull/772)
+- PowerPoint2007 Writer : Fixed column indices for embedded spreadsheets - [@michael-roth](https://github.com/michael-roth) in [#773](https://github.com/PHPOffice/PHPPresentation/pull/773)
+- PowerPoint2007 Reader : Load images from file only if valid - [@aelliott1485](https://github.com/aelliott1485) in [#775](https://github.com/PHPOffice/PHPPresentation/pull/775)
+- PowerPoint2007 Writer : Fixed broken video file relationship - [@potofcoffee](https://github.com/potofcoffee) in [#776](https://github.com/PHPOffice/PHPPresentation/pull/776)
+- PowerPoint2007 Writer : Fixed issue when first element in series is null - [@ksmeeks0001](https://github.com/ksmeeks0001) in [#778](https://github.com/PHPOffice/PHPPresentation/pull/778)
+- PowerPoint2007 & ODPresentation Writer : Use of the disk caching directory for temporary files - [@nhalle](https://github.com/nhalle) in [#781](https://github.com/PHPOffice/PHPPresentation/pull/781)
+- PowerPoint2007 Reader : Fixed reading of RichText shape in Note - [@aelliott1485](https://github.com/aelliott1485) in [#782](https://github.com/PHPOffice/PHPPresentation/pull/782)
+- PowerPoint2007 Writer : Fixed broken animation for first shape - [@shannan1989](https://github.com/shannan1989) in [#783](https://github.com/PHPOffice/PHPPresentation/pull/783)
+- Samples : Allow to run without composer - [@pal-software](https://github.com/pal-software) in [#784](https://github.com/PHPOffice/PHPPresentation/pull/784)
+- PowerPoint2007 Writer: Extract relations from nested ShapeContainerInterface objects - [@DennisBirkholz](https://github.com/DennisBirkholz) in [#785](https://github.com/PHPOffice/PHPPresentation/pull/785)
+- Core : Fixed copying bug when presentation had multiple slides [@dees040](https://github.com/dees040) in [#786](https://github.com/PHPOffice/PHPPresentation/pull/786)
+- Core : DocumentLayout : Fixed error when using DocumentLayout::LAYOUT_CUSTOM by [@jiangzhangchan](https://github.com/dees040) fixing [#722](https://github.com/PHPOffice/PHPPresentation/pull/722) in [#811](https://github.com/PHPOffice/PHPPresentation/pull/811)
+
+## Miscellaneous
+
+- Fixed CI - [@Progi1984](https://github.com/Progi1984) in [#766](https://github.com/PHPOffice/PHPPresentation/pull/766)
+- CI : Removed deprecations - [@Progi1984](https://github.com/Progi1984) in [#780](https://github.com/PHPOffice/PHPPresentation/pull/780)
+
+## BC Breaks
+- `PhpOffice\PhpPresentation\Style\Outline` : the width is now based on pixels (before in points)
\ No newline at end of file
diff --git a/docs/usage/presentation.md b/docs/usage/presentation.md
index 03080aa1c2..a06e0958b2 100644
--- a/docs/usage/presentation.md
+++ b/docs/usage/presentation.md
@@ -62,6 +62,8 @@ $properties->setCreated(mktime(0, 0, 0, 3, 12, 2014));
$properties->setModified(mktime(0, 0, 0, 3, 14, 2014));
$properties->setSubject('My subject');
$properties->setKeywords('my, key, word');
+$properties->setStatus('Work in Progress');
+$properties->setRevision('Version 1.2.3');
```
### Custom Properties
@@ -203,16 +205,44 @@ echo $properties->getSlideshowType();
You can define the thumbnail of the presentation with the method `setThumbnailPath`.
+
+#### From a file
``` php
getPresentationProperties();
// Set path of the thumbnail
-$properties->setThumbnailPath(__DIR__.'\resources\phppowerpoint_logo.gif');
+$properties->setThumbnailPath(
+ __DIR__.'\resources\phppowerpoint_logo.gif',
+ PresentationProperties::THUMBNAIL_FILE
+);
// Get path of the thumbnail
echo $properties->getThumbnailPath();
+// Get content of the thumbnail
+echo $properties->getThumbnail();
+```
+
+#### From the content of the file
+``` php
+getPresentationProperties();
+// Set path of the thumbnail
+$properties->setThumbnailPath(
+ '',
+ PresentationProperties::THUMBNAIL_DATA,
+ file_get_contents(__DIR__.'\resources\phppowerpoint_logo.gif')
+);
+// Get content of the thumbnail
+echo $properties->getThumbnail();
```
### Zoom
diff --git a/docs/usage/shapes/chart.md b/docs/usage/shapes/chart.md
index 388d88309e..af5ca40244 100644
--- a/docs/usage/shapes/chart.md
+++ b/docs/usage/shapes/chart.md
@@ -95,6 +95,62 @@ $shape->getPlotArea()->getAxisX()->setMinBounds(0);
$shape->getPlotArea()->getAxisX()->setMaxBounds(200);
```
+#### Crossing
+
+!!! warning
+ Available only on the PowerPoint2007 Writer
+
+For Axis, `setCrossesAt` can be used to define where it should be crossed by the perpendicular/ horizontal axis.
+The property can be defined by one of the three given constants or as an absolute value on the target axis.
+
+``` php
+use PhpOffice\PhpPresentation\Shape\Axis;
+use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar;
+
+$bar = new Bar();
+
+$shape = $slide->createChartShape();
+$shape->getPlotArea()->setType($bar);
+
+// Usage of constant: Horizontal axis will cross the Y-Axis at `0`
+$shape->getPlotArea()->getAxisY()->setCrossesAt(Axis::CROSSES_AUTO);
+
+// Usage of individual value: Horizontal axis will cross the Y-Axis at `3`
+$shape->getPlotArea()->getAxisY()->setCrossesAt('3');
+```
+
+| Constant | Description |
+| -------------------- | ------------------------ |
+| `AXIS::CROSSES_AUTO` | Axis crosses at zero. |
+| `AXIS::CROSSES_MIN` | Axis crosses at minimum. |
+| `AXIS::CROSSES_MAX` | Axis crosses at maximum. |
+
+#### Reversed Order
+
+You can reverse the order of a categorial or value axis trought `setIsReversedOrder`.
+
+Notice: If you reverse the order of a axis, this automatically changes the position of the other axis.
+To reset this effect, the axis intersection point on the other axis must be set to `Axis::CROSSES_MAX` using `setCrossesAt`.
+
+``` php
+use PhpOffice\PhpPresentation\Shape\Axis;
+use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar;
+
+$bar = new Bar();
+
+$shape = $slide->createChartShape();
+$shape->getPlotArea()->setType($bar);
+
+// default value, will return false
+$shape->getPlotArea()->getAxisY()->isReversedOrder()
+
+// reverse order
+$shape->getPlotArea()->getAxisY()->setIsReversedOrder(true);
+
+// revert the automatic intersection switch on x axis
+$shape->getPlotArea()->getAxisX()->setCrossesAt(Axis::CROSSES_MAX);
+```
+
#### Outline
You can define outline for each axis (X & Y).
@@ -109,7 +165,8 @@ $shape->getPlotArea()->setType($line);
$shape->getPlotArea()->getAxisX()->getOutline()->setWidth(10);
$shape->getPlotArea()->getAxisX()->getOutline()->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
```
-#### Tick Label Position
+#### Tick Label
+##### Position
You can define the tick label position with the `setTickLabelPosition` method.
For resetting it, you pass `Axis::TICK_LABEL_POSITION_NEXT_TO` as parameter to this method.
@@ -131,6 +188,28 @@ $shape = $slide->createChartShape();
$shape->getPlotArea()->setType($line);
$shape->getPlotArea()->getAxisY()->setTickLabelPosition(Axis::TICK_LABEL_POSITION_LOW);
```
+
+##### Font
+
+You can define the tick label font with the `setTickLabelFont` method.
+For resetting it, you pass `null` as parameter to this method.
+
+``` php
+setColor(new Color('C00000'))
+
+$shape = $slide->createChartShape();
+$shape->getPlotArea()->setType($line);
+$shape->getPlotArea()->getAxisY()->setTickLabelFont($font);
+```
+
#### Tick Marks
For Axis Y, you can define tick mark with `setMinorTickMark` & `setMajorTickMark` methods.
diff --git a/docs/usage/shapes/richtext.md b/docs/usage/shapes/richtext.md
index e44f358e39..5ee4393a38 100644
--- a/docs/usage/shapes/richtext.md
+++ b/docs/usage/shapes/richtext.md
@@ -50,6 +50,42 @@ $richText->setColumnSpacing(200);
$columnSpacing = $richText->getColumnSpacing();
```
+## Hyperlink
+
+For a rich text, you can define the hyperlink.
+
+Example:
+
+```php
+getHyperlink()->setUrl('https://phpoffice.github.io/PHPPresentation/');
+
+```
+
+### Use of Text Color
+
+!!! warning
+ Available only on the PowerPoint2007 Reader/Writer
+
+Hyperlinks can be set to use the text color instead of the default theme color.
+
+Example:
+
+```php
+getHyperlink()->setUrl('https://phpoffice.github.io/PHPPresentation/');
+$richText->getHyperlink()->setIsTextColorUsed(true);
+
+```
+
## Paragraph
### Bullet
diff --git a/docs/usage/slides/introduction.md b/docs/usage/slides/introduction.md
index 3166122026..fcf0ee558e 100644
--- a/docs/usage/slides/introduction.md
+++ b/docs/usage/slides/introduction.md
@@ -1,8 +1,38 @@
# Introduction
-Slides are pages in a presentation. Slides are stored as a zero based array in `PHPPresentation` object. Use the method `createSlide` to create a new slide and retrieve the slide for other operation such as creating shapes for that slide.
+Slides are pages in a presentation. Slides are stored as a zero based array in `PHPPresentation` object.
-## Name
+## Create slide
+
+Use the method `createSlide` to create a new slide and retrieve the slide for other operation such as creating shapes for that slide. The slide will be added at the end of slides collection.
+
+``` php
+createSlide();
+```
+
+## Add slide to a specific position
+
+Use the method `addSlide` to add an existing slide to a specific position. Without the parameter `$position`, it will be added at the end of slides collection.
+
+``` php
+addSlide($slide, 0);
+## Add it to position 1
+$presentation->addSlide($slide, 1);
+## Add it after all slides
+$presentation->addSlide($slide);
+```
+
+## Properties
+
+### Name
By default, a slide has not a name.
You can define it with the method `setName`.
@@ -14,7 +44,7 @@ $slide = $presentation->createSlide();
$slide->setName('Title of the slide');
```
-## Visibility
+### Visibility
By default, a slide is visible.
You can define it with the method `setIsVisible`.
diff --git a/docs/usage/styles.md b/docs/usage/styles.md
index ba21479853..a21efdc8e5 100644
--- a/docs/usage/styles.md
+++ b/docs/usage/styles.md
@@ -97,11 +97,45 @@ echo $alignment->isRTL();
- `name`
- `bold`
- `italic`
-- `superScript`
-- `subScript`
+- `superScript` (deprecated)
+- `subScript` (deprecated)
- `underline`
- `strikethrough`
- `color`
+- `pitchFamily`
+- `charset`
+
+### Baseline
+
+The baseline set the position relative to the line.
+The value is a percentage.
+
+You can use some predefined values :
+
+* `Font::BASELINE_SUPERSCRIPT` (= 300000 = 300%)
+* `Font::BASELINE_SUBSCRIPT` (= -250000 = -250%)
+
+
+### Capitalization
+
+Some formats are available :
+
+* `Font::CAPITALIZATION_NONE`
+* `Font::CAPITALIZATION_ALL`
+* `Font::CAPITALIZATION_SMALL`
+
+``` php
+setCapitalization(Font::CAPITALIZATION_ALL);
+// Get capitalization of font
+echo $font->getCapitalization();
+```
### Format
@@ -123,6 +157,23 @@ $font->setFormat(Font::FORMAT_EAST_ASIAN);
// Get format of font
echo $font->getFormat();
```
+
+### Panose
+The support of Panose 1.0 is only used.
+
+``` php
+setPanose('4494D72242');
+// Get panose of font
+echo $font->getPanose();
+```
+
## Bullet
- `bulletType`
diff --git a/mkdocs.yml b/mkdocs.yml
index c60fad741d..b1888ee68d 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -67,7 +67,8 @@ nav:
- FAQ: 'faq.md'
- Credits: 'credits.md'
- Releases:
- - '1.0.0 (WIP)': 'changes/1.0.0.md'
+ - '1.1.0 (WIP)': 'changes/1.1.0.md'
+ - '1.0.0': 'changes/1.0.0.md'
- '0.9.0': 'changes/0.9.0.md'
- '0.8.0': 'changes/0.8.0.md'
- '0.7.0': 'changes/0.7.0.md'
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index 0ab30292c2..80ed4f234d 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -16,7 +16,9 @@ parameters:
- '#^Parameter \#1 \$pValue of static method PhpOffice\\Common\\Drawing\:\:pixelsToCentimeters\(\) expects int, float given\.#'
- '#^Parameter \#1 \$pValue of static method PhpOffice\\Common\\Drawing\:\:pixelsToEmu\(\) expects int, float given\.#'
## PHP 8.0 & GdImage
+ - '#^Parameter \#1 \$value of method PhpOffice\\PhpPresentation\\Shape\\Drawing\\Gd::setImageResource\(\) expects resource\|null, GdImage\ given\.#'
- '#^Parameter \#1 \$value of method PhpOffice\\PhpPresentation\\Shape\\Drawing\\Gd::setImageResource\(\) expects resource\|null, GdImage\|false given\.#'
+ - '#^Parameter \#1 \$value of method PhpOffice\\PhpPresentation\\Shape\\Drawing\\Gd::setImageResource\(\) expects resource\|null, \(GdImage\|false\) given\.#'
- '#^Parameter \#1 \$image of function imagesx expects GdImage, resource given\.#'
- '#^Parameter \#1 \$image of function imagesy expects GdImage, resource given\.#'
- '#^Parameter \#1 \$image of function imagealphablending expects GdImage, resource given\.#'
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index a9f7e2189e..4c92bf72c1 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,24 +1,33 @@
-
-
-
- ./tests/PhpPresentation
-
-
-
-
- ./src
-
-
-
-
-
-
-
+
+
+
+
+ ./src
+
+
+
+
+
+
+
+
+
+
+
+ ./tests/PhpPresentation/Tests
+
+
+
+
\ No newline at end of file
diff --git a/samples/Sample_02_Serialized.php b/samples/Sample_02_Serialized.php
index b2101c440e..26ec633f98 100644
--- a/samples/Sample_02_Serialized.php
+++ b/samples/Sample_02_Serialized.php
@@ -30,7 +30,7 @@
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
- ->setPath('./resources/phppowerpoint_logo.gif')
+ ->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
@@ -55,11 +55,11 @@
$basename = basename(__FILE__, '.php');
echo date('H:i:s') . ' Write to serialized format' . EOL;
$objWriter = IOFactory::createWriter($objPHPPresentation, 'Serialized');
-$objWriter->save('results/' . basename(__FILE__, '.php') . '.phppt');
+$objWriter->save(__DIR__ . '/results/' . basename(__FILE__, '.php') . '.phppt');
// Read from serialized file
echo date('H:i:s') . ' Read from serialized format' . EOL;
-$objPHPPresentationLoaded = IOFactory::load('results/' . basename(__FILE__, '.php') . '.phppt');
+$objPHPPresentationLoaded = IOFactory::load(__DIR__ . '/results/' . basename(__FILE__, '.php') . '.phppt');
// Save file
echo write($objPHPPresentationLoaded, basename(__FILE__, '.php'), $writers);
diff --git a/samples/Sample_03_Image.php b/samples/Sample_03_Image.php
index 8c6e0e847c..888c5ba971 100644
--- a/samples/Sample_03_Image.php
+++ b/samples/Sample_03_Image.php
@@ -17,7 +17,7 @@
// Generate an image
echo date('H:i:s') . ' Generate an image' . EOL;
-$gdImage = @imagecreatetruecolor(140, 20) or exit('Cannot Initialize new GD image stream');
+$gdImage = imagecreatetruecolor(140, 20);
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
imagestring($gdImage, 1, 5, 5, 'Created with PHPPresentation', $textColor);
diff --git a/samples/Sample_04_Table.php b/samples/Sample_04_Table.php
index 0dce634c6f..e6558d623e 100644
--- a/samples/Sample_04_Table.php
+++ b/samples/Sample_04_Table.php
@@ -85,7 +85,7 @@
$oCell->createTextRun('R2C1');
$oCell->getActiveParagraph()->getAlignment()
->setMarginLeft(30)
- ->setTextDirection(\PhpOffice\PhpPresentation\Style\Alignment::TEXT_DIRECTION_VERTICAL_270);
+ ->setTextDirection(PhpOffice\PhpPresentation\Style\Alignment::TEXT_DIRECTION_VERTICAL_270);
$oCell = $row->nextCell();
$oCell->createTextRun('R2C2');
$oCell->getActiveParagraph()->getAlignment()
diff --git a/samples/Sample_05_Chart.php b/samples/Sample_05_Chart.php
index 9169b1f43b..ad9c32f749 100644
--- a/samples/Sample_05_Chart.php
+++ b/samples/Sample_05_Chart.php
@@ -21,7 +21,7 @@
use PhpOffice\PhpPresentation\Style\Fill;
use PhpOffice\PhpPresentation\Style\Shadow;
-function fnSlide_Area(PhpPresentation $objPHPPresentation)
+function fnSlide_Area(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
@@ -71,7 +71,7 @@ function fnSlide_Area(PhpPresentation $objPHPPresentation)
$shape->getLegend()->getFont()->setItalic(true);
}
-function fnSlide_Bar(PhpPresentation $objPHPPresentation)
+function fnSlide_Bar(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
@@ -125,14 +125,14 @@ function fnSlide_Bar(PhpPresentation $objPHPPresentation)
$shape->getLegend()->getFont()->setItalic(true);
}
-function fnSlide_BarHorizontal(PhpPresentation $objPHPPresentation)
+function fnSlide_BarHorizontal(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
// Create a bar chart (that should be inserted in a shape)
echo date('H:i:s') . ' Create a horizontal bar chart (that should be inserted in a chart shape) ' . EOL;
- $barChartHorz = clone $objPHPPresentation->getSlide(1)->getShapeCollection()->offsetGet(1)->getPlotArea()->getType();
+ $barChartHorz = clone $objPHPPresentation->getSlide(1)->getShapeCollection()[1]->getPlotArea()->getType();
$barChartHorz->setBarDirection(Bar3D::DIRECTION_HORIZONTAL);
// Create templated slide
@@ -161,7 +161,7 @@ function fnSlide_BarHorizontal(PhpPresentation $objPHPPresentation)
$shape->getLegend()->getFont()->setItalic(true);
}
-function fnSlide_BarStacked(PhpPresentation $objPHPPresentation)
+function fnSlide_BarStacked(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
@@ -223,7 +223,7 @@ function fnSlide_BarStacked(PhpPresentation $objPHPPresentation)
$shape->getLegend()->getFont()->setItalic(true);
}
-function fnSlide_BarPercentStacked(PhpPresentation $objPHPPresentation)
+function fnSlide_BarPercentStacked(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
@@ -302,7 +302,7 @@ function fnSlide_BarPercentStacked(PhpPresentation $objPHPPresentation)
$shape->getLegend()->getFont()->setItalic(true);
}
-function fnSlide_Bar3D(PhpPresentation $objPHPPresentation)
+function fnSlide_Bar3D(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
@@ -356,14 +356,14 @@ function fnSlide_Bar3D(PhpPresentation $objPHPPresentation)
$shape->getLegend()->getFont()->setItalic(true);
}
-function fnSlide_Bar3DHorizontal(PhpPresentation $objPHPPresentation)
+function fnSlide_Bar3DHorizontal(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
// Create a bar chart (that should be inserted in a shape)
echo date('H:i:s') . ' Create a horizontal bar chart (that should be inserted in a chart shape) ' . EOL;
- $bar3DChartHorz = clone $objPHPPresentation->getSlide(5)->getShapeCollection()->offsetGet(1)->getPlotArea()->getType();
+ $bar3DChartHorz = clone $objPHPPresentation->getSlide(5)->getShapeCollection()[1]->getPlotArea()->getType();
$bar3DChartHorz->setBarDirection(Bar3D::DIRECTION_HORIZONTAL);
// Create templated slide
@@ -395,7 +395,7 @@ function fnSlide_Bar3DHorizontal(PhpPresentation $objPHPPresentation)
$shape->getLegend()->getFont()->setItalic(true);
}
-function fnSlide_Doughnut(PhpPresentation $objPHPPresentation)
+function fnSlide_Doughnut(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
@@ -450,7 +450,7 @@ function fnSlide_Doughnut(PhpPresentation $objPHPPresentation)
$shape->getLegend()->setPosition(Legend::POSITION_LEFT);
}
-function fnSlide_Pie3D(PhpPresentation $objPHPPresentation)
+function fnSlide_Pie3D(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
@@ -499,7 +499,7 @@ function fnSlide_Pie3D(PhpPresentation $objPHPPresentation)
$shape->getLegend()->getFont()->setItalic(true);
}
-function fnSlide_Pie(PhpPresentation $objPHPPresentation)
+function fnSlide_Pie(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
@@ -550,7 +550,7 @@ function fnSlide_Pie(PhpPresentation $objPHPPresentation)
$shape->getLegend()->getFont()->setItalic(true);
}
-function fnSlide_Radar(PhpPresentation $objPHPPresentation)
+function fnSlide_Radar(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
@@ -607,7 +607,7 @@ function fnSlide_Radar(PhpPresentation $objPHPPresentation)
->setStartColor(new Color(Color::COLOR_BLUE)); // 0000FF
}
-function fnSlide_Scatter(PhpPresentation $objPHPPresentation)
+function fnSlide_Scatter(PhpPresentation $objPHPPresentation): void
{
global $oFill;
global $oShadow;
diff --git a/samples/Sample_06_Fill.php b/samples/Sample_06_Fill.php
index e917a34f90..41bc149a61 100644
--- a/samples/Sample_06_Fill.php
+++ b/samples/Sample_06_Fill.php
@@ -46,15 +46,19 @@
switch ($inc) {
case 1:
$shape->getFill()->setFillType(Fill::FILL_NONE);
+
break;
case 2:
$shape->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR)->setRotation(90)->setStartColor(new Color('FF4672A8'))->setEndColor(new Color('FF000000'));
+
break;
case 3:
$shape->getFill()->setFillType(Fill::FILL_GRADIENT_PATH)->setRotation(90)->setStartColor(new Color('FF4672A8'))->setEndColor(new Color('FF000000'));
+
break;
case 4:
$shape->getFill()->setFillType(Fill::FILL_SOLID)->setRotation(90)->setStartColor(new Color('FF4672A8'))->setEndColor(new Color('FF4672A8'));
+
break;
}
diff --git a/samples/Sample_07_Border.php b/samples/Sample_07_Border.php
index 24816fedda..fff1aa1bb2 100644
--- a/samples/Sample_07_Border.php
+++ b/samples/Sample_07_Border.php
@@ -38,15 +38,19 @@
switch ($inc) {
case 1:
$shape->getBorder()->setColor(new Color('FF4672A8'))->setDashStyle(Border::DASH_SOLID)->setLineStyle(Border::LINE_DOUBLE);
+
break;
case 2:
$shape->getBorder()->setColor(new Color('FF4672A8'))->setDashStyle(Border::DASH_DASH)->setLineStyle(Border::LINE_SINGLE);
+
break;
case 3:
$shape->getBorder()->setColor(new Color('FF4672A8'))->setDashStyle(Border::DASH_DOT)->setLineStyle(Border::LINE_THICKTHIN);
+
break;
case 4:
$shape->getBorder()->setColor(new Color('FF4672A8'))->setDashStyle(Border::DASH_LARGEDASHDOT)->setLineStyle(Border::LINE_THINTHICK);
+
break;
}
diff --git a/samples/Sample_11_Shape.php b/samples/Sample_11_Shape.php
index 37dc5a221d..af3059f2b4 100644
--- a/samples/Sample_11_Shape.php
+++ b/samples/Sample_11_Shape.php
@@ -7,7 +7,7 @@
include_once 'Sample_Header.php';
-function fnSlideRichText(PhpPresentation $objPHPPresentation)
+function fnSlideRichText(PhpPresentation $objPHPPresentation): void
{
// Create templated slide
echo date('H:i:s') . ' Create templated slide' . EOL;
@@ -35,7 +35,7 @@ function fnSlideRichText(PhpPresentation $objPHPPresentation)
$textRun->getFont()->setColor(new Color('FF000000'));
}
-function fnSlideRichTextLineSpacing(PhpPresentation $objPHPPresentation)
+function fnSlideRichTextLineSpacing(PhpPresentation $objPHPPresentation): void
{
// Create templated slide
echo date('H:i:s') . ' Create templated slide' . EOL;
@@ -81,7 +81,7 @@ function fnSlideRichTextLineSpacing(PhpPresentation $objPHPPresentation)
$shape->createTextRun('Line Spacing 300');
}
-function fnSlideRichTextShadow(PhpPresentation $objPHPPresentation)
+function fnSlideRichTextShadow(PhpPresentation $objPHPPresentation): void
{
// Create templated slide
echo date('H:i:s') . ' Create templated slide' . EOL;
@@ -101,7 +101,7 @@ function fnSlideRichTextShadow(PhpPresentation $objPHPPresentation)
$textRun->getFont()->setColor(new Color('FF000000'));
}
-function fnSlideRichTextList(PhpPresentation $objPHPPresentation)
+function fnSlideRichTextList(PhpPresentation $objPHPPresentation): void
{
// Create templated slide
echo date('H:i:s') . ' Create templated slide' . EOL;
diff --git a/samples/Sample_15_Background.php b/samples/Sample_15_Background.php
index 74135eeceb..9e1280fd99 100644
--- a/samples/Sample_15_Background.php
+++ b/samples/Sample_15_Background.php
@@ -29,9 +29,7 @@
$oSlide2->addShape(clone $oShapeRichText);
// Slide > Background > Image
-/*
- * @link : http://publicdomainarchive.com/public-domain-images-cave-red-rocks-light-beam-cavern/
- */
+// @link : http://publicdomainarchive.com/public-domain-images-cave-red-rocks-light-beam-cavern/
$oBkgImage = new Image();
$oBkgImage->setPath(__DIR__ . '/resources/background.jpg');
$oSlide2->setBackground($oBkgImage);
diff --git a/samples/Sample_17_Comment.php b/samples/Sample_17_Comment.php
index c9fa849269..d417c4bfd1 100644
--- a/samples/Sample_17_Comment.php
+++ b/samples/Sample_17_Comment.php
@@ -14,13 +14,13 @@
$oSlide1->addShape(clone $oShapeDrawing);
$oSlide1->addShape(clone $oShapeRichText);
-$oAuthor = new \PhpOffice\PhpPresentation\Shape\Comment\Author();
+$oAuthor = new PhpOffice\PhpPresentation\Shape\Comment\Author();
$oAuthor->setName('Progi1984');
$oAuthor->setInitials('P');
// Add Comment 1
echo date('H:i:s') . ' Add Comment 1' . EOL;
-$oComment1 = new \PhpOffice\PhpPresentation\Shape\Comment();
+$oComment1 = new PhpOffice\PhpPresentation\Shape\Comment();
$oComment1->setText('Text A');
$oComment1->setOffsetX(10);
$oComment1->setOffsetY(55);
@@ -30,7 +30,7 @@
// Add Comment
echo date('H:i:s') . ' Add Comment 2' . EOL;
-$oComment2 = new \PhpOffice\PhpPresentation\Shape\Comment();
+$oComment2 = new PhpOffice\PhpPresentation\Shape\Comment();
$oComment2->setText('Text B');
$oComment2->setOffsetX(170);
$oComment2->setOffsetY(180);
diff --git a/samples/Sample_19_SlideMaster.php b/samples/Sample_19_SlideMaster.php
index d72b2488b4..9f851ac8ef 100644
--- a/samples/Sample_19_SlideMaster.php
+++ b/samples/Sample_19_SlideMaster.php
@@ -55,7 +55,7 @@
->setVertical(Alignment::VERTICAL_BASE);
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
$textRun = $shape->createTextRun('01-02-2000')->getFont()->setSize(18);
-$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_DATETIME))->getPlaceholder()->setIdx(10);
+$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_DATETIME));
// Footer placeholder
$shape = $oMasterSlide->createRichTextShape();
$shape->setWidthAndHeight(468, 38)->setOffsetX(246)->setOffsetY(680);
@@ -64,7 +64,7 @@
->setVertical(Alignment::VERTICAL_BASE);
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
$textRun = $shape->createTextRun('Placeholder for Footer')->getFont()->setSize(18);
-$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER))->getPlaceholder()->setIdx(11);
+$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER));
// Slidenumber placeholder
$shape = $oMasterSlide->createRichTextShape();
$shape->setWidthAndHeight(140, 38)->setOffsetX(770)->setOffsetY(680);
@@ -72,8 +72,8 @@
->setHorizontal(Alignment::HORIZONTAL_RIGHT)
->setVertical(Alignment::VERTICAL_BASE);
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
-$textRun = $shape->createTextRun('')->getFont()->setSize(18);
-$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM))->getPlaceholder()->setIdx(12);
+$textRun = $shape->createTextRun('')->getFont()->setSize(10);
+$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM));
// Create a shape (drawing)
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
diff --git a/samples/Sample_20_SlideLayout.php b/samples/Sample_20_SlideLayout.php
new file mode 100644
index 0000000000..1e18ac5b36
--- /dev/null
+++ b/samples/Sample_20_SlideLayout.php
@@ -0,0 +1,73 @@
+getDocumentProperties()->setCreator('PHPOffice')
+ ->setLastModifiedBy('PHPPresentation Team')
+ ->setTitle('Sample 20 SlideLayout')
+ ->setSubject('Sample 20 Subject')
+ ->setDescription('Sample 20 Description')
+ ->setKeywords('office 2007 openxml libreoffice odt php')
+ ->setCategory('Sample Category');
+
+// Create slide
+echo date('H:i:s') . ' Create slide' . EOL;
+$currentSlide = $objPHPPresentation->getActiveSlide();
+
+echo date('H:i:s') . ' Create SlideLayout' . EOL;
+$slideLayout = $objPHPPresentation->getAllMasterSlides()[0]->createSlideLayout();
+$slideLayout->setLayoutName('Sample Layout');
+
+echo date('H:i:s') . ' Create Footer' . EOL;
+$footerTextShape = $slideLayout->createRichTextShape();
+$footerTextShape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER));
+
+$footerTextShape
+ ->setOffsetX(77)
+ ->setOffsetY(677)
+ ->setWidth(448)
+ ->setHeight(23);
+
+$footerTextRun = $footerTextShape->createTextRun('Footer placeholder');
+$footerTextRun->getFont()
+ ->setName('Calibri')
+ ->setSize(9)
+ ->setColor(new Color(Color::COLOR_DARKGREEN))
+ ->setBold(true);
+
+echo date('H:i:s') . ' Create SlideNumber' . EOL;
+
+$numberTextShape = $slideLayout->createRichTextShape();
+$numberTextShape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM));
+
+$numberTextShape
+ ->setOffsetX(43)
+ ->setOffsetY(677)
+ ->setWidth(43)
+ ->setHeight(23);
+
+$numberTextRun = $numberTextShape->createTextRun('');
+$numberTextRun->getFont()
+ ->setName('Calibri')
+ ->setSize(9)
+ ->setColor(new Color(Color::COLOR_DARKGREEN))
+ ->setBold(true);
+
+echo date('H:i:s') . ' Apply Layout' . EOL;
+$currentSlide->setSlideLayout($slideLayout);
+
+// Save file
+echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
+if (!CLI) {
+ include_once 'Sample_Footer.php';
+}
diff --git a/samples/Sample_20_ExternalSlide.php b/samples/Sample_22_ExternalSlide.php
similarity index 88%
rename from samples/Sample_20_ExternalSlide.php
rename to samples/Sample_22_ExternalSlide.php
index 3e89bf3d2e..763234a6b2 100644
--- a/samples/Sample_20_ExternalSlide.php
+++ b/samples/Sample_22_ExternalSlide.php
@@ -9,7 +9,7 @@
$objPHPPresentation = new PhpPresentation();
$objPHPPresentation->removeSlideByIndex(0);
-$oReader = \PhpOffice\PhpPresentation\IOFactory::createReader('PowerPoint2007');
+$oReader = PhpOffice\PhpPresentation\IOFactory::createReader('PowerPoint2007');
$oPresentation04 = $oReader->load(__DIR__ . '/results/Sample_04_Table.pptx');
foreach ($oPresentation04->getAllSlides() as $oSlide) {
diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php
index eb16a62a3c..803480e296 100644
--- a/samples/Sample_Header.php
+++ b/samples/Sample_Header.php
@@ -1,7 +1,7 @@
$extension) {
$result .= date('H:i:s') . " Write to {$writer} format";
- if (!is_null($extension)) {
+ if (null !== $extension) {
$xmlWriter = IOFactory::createWriter($phpPresentation, $writer);
$xmlWriter->save(__DIR__ . "/{$filename}.{$extension}");
rename(__DIR__ . "/{$filename}.{$extension}", __DIR__ . "/results/{$filename}.{$extension}");
@@ -158,7 +163,7 @@ function getEndingNotes($writers)
$result .= '
';
$result .= 'Results: ';
foreach ($types as $type) {
- if (!is_null($type)) {
+ if (null !== $type) {
$resultFile = 'results/' . SCRIPT_FILENAME . '.' . $type;
if (file_exists($resultFile)) {
$result .= "{$type} ";
@@ -174,12 +179,8 @@ function getEndingNotes($writers)
/**
* Creates a templated slide.
- *
- * @param PHPPresentation $objPHPPresentation
- *
- * @return \PhpOffice\PhpPresentation\Slide
*/
-function createTemplatedSlide(PhpOffice\PhpPresentation\PhpPresentation $objPHPPresentation)
+function createTemplatedSlide(PhpPresentation $objPHPPresentation): Slide
{
// Create slide
$slide = $objPHPPresentation->createSlide();
@@ -200,9 +201,10 @@ function createTemplatedSlide(PhpOffice\PhpPresentation\PhpPresentation $objPHPP
return $slide;
}
-class PhpPptTree
+class Sample_Header
{
protected $oPhpPresentation;
+
protected $htmlOutput;
public function __construct(PhpPresentation $oPHPPpt)
@@ -230,12 +232,12 @@ public function display()
return $this->htmlOutput;
}
- protected function append($sHTML)
+ protected function append($sHTML): void
{
$this->htmlOutput .= $sHTML;
}
- protected function displayPhpPresentation(PhpPresentation $oPHPPpt)
+ protected function displayPhpPresentation(PhpPresentation $oPHPPpt): void
{
$this->append('
PhpPresentation');
$this->append('');
@@ -265,7 +267,7 @@ protected function displayPhpPresentation(PhpPresentation $oPHPPpt)
$this->append('
');
}
- protected function displayShape(AbstractShape $shape)
+ protected function displayShape(AbstractShape $shape): void
{
if ($shape instanceof Drawing\Gd) {
$this->append('Shape "Drawing\Gd"');
@@ -282,7 +284,7 @@ protected function displayShape(AbstractShape $shape)
}
}
- protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt)
+ protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt): void
{
$this->append('');
$this->append('
');
@@ -324,7 +326,7 @@ protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt)
}
}
$oNote = $oSlide->getNote();
- if ($oNote->getShapeCollection()->count() > 0) {
+ if (count($oNote->getShapeCollection()) > 0) {
$this->append('- Notes
');
foreach ($oNote->getShapeCollection() as $oShape) {
if ($oShape instanceof RichText) {
@@ -348,7 +350,7 @@ protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt)
}
}
- protected function displayShapeInfo(AbstractShape $oShape)
+ protected function displayShapeInfo(AbstractShape $oShape): void
{
$this->append('');
$this->append('
');
@@ -360,18 +362,20 @@ protected function displayShapeInfo(AbstractShape $oShape)
$this->append('- Rotation
- ' . $oShape->getRotation() . '°
');
$this->append('- Hyperlink
- ' . ucfirst(var_export($oShape->hasHyperlink(), true)) . '
');
$this->append('- Fill
');
- if (is_null($oShape->getFill())) {
+ if (null === $oShape->getFill()) {
$this->append('- None
');
} else {
switch ($oShape->getFill()->getFillType()) {
- case \PhpOffice\PhpPresentation\Style\Fill::FILL_NONE:
+ case PhpOffice\PhpPresentation\Style\Fill::FILL_NONE:
$this->append('- None
');
+
break;
- case \PhpOffice\PhpPresentation\Style\Fill::FILL_SOLID:
+ case PhpOffice\PhpPresentation\Style\Fill::FILL_SOLID:
$this->append('- Solid (');
$this->append('Color : #' . $oShape->getFill()->getStartColor()->getRGB());
$this->append(' - Alpha : ' . $oShape->getFill()->getStartColor()->getAlpha() . '%');
$this->append(')
');
+
break;
}
}
@@ -438,6 +442,7 @@ protected function displayShapeInfo(AbstractShape $oShape)
$this->append('Italic : ' . ($oRichText->getFont()->isItalic() ? 'Y' : 'N') . ' - ');
$this->append('Underline : Underline::' . $this->getConstantName('\PhpOffice\PhpPresentation\Style\Font', $oRichText->getFont()->getUnderline()) . ' - ');
$this->append('Strikethrough : ' . ($oRichText->getFont()->isStrikethrough() ? 'Y' : 'N') . ' - ');
+ $this->append('Baseline : ' . $oRichText->getFont()->getBaseline() . ' - ');
$this->append('SubScript : ' . ($oRichText->getFont()->isSubScript() ? 'Y' : 'N') . ' - ');
$this->append('SuperScript : ' . ($oRichText->getFont()->isSuperScript() ? 'Y' : 'N'));
$this->append('');
@@ -454,9 +459,9 @@ protected function displayShapeInfo(AbstractShape $oShape)
$this->append('
');
}
$this->append('');
- } else {
- // Add another shape
}
+ // Add another shape
+
$this->append('');
$this->append('
');
}
@@ -471,6 +476,7 @@ protected function getConstantName($class, $search, $startWith = '')
if (empty($startWith) || (!empty($startWith) && 0 === strpos($key, $startWith))) {
$constName = $key;
}
+
break;
}
}
diff --git a/samples/index.php b/samples/index.php
index c45af5f7f8..efda7ee8ef 100644
--- a/samples/index.php
+++ b/samples/index.php
@@ -1,7 +1,7 @@
['PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')],
+ 'php' => ['PHP 5.3.0', version_compare(PHP_VERSION, '5.3.0', '>=')],
'xml' => ['PHP extension XML', extension_loaded('xml')],
'zip' => ['PHP extension ZipArchive (optional)', extension_loaded('zip')],
'gd' => ['PHP extension GD (optional)', extension_loaded('gd')],
@@ -24,7 +24,7 @@
echo 'Requirement check:
';
echo '';
foreach ($requirements as $key => $value) {
- list($label, $result) = $value;
+ [$label, $result] = $value;
$status = $result ? 'passed' : 'failed';
echo "- {$label} ... {$status}
";
}
@@ -33,7 +33,7 @@
} else {
echo 'Requirement check:' . PHP_EOL;
foreach ($requirements as $key => $value) {
- list($label, $result) = $value;
+ [$label, $result] = $value;
$status = $result ? '32m passed' : '31m failed';
echo "{$label} ... \033[{$status}\033[0m" . PHP_EOL;
}
diff --git a/src/PhpPresentation/AbstractShape.php b/src/PhpPresentation/AbstractShape.php
index c8d3df00d8..bbe9de54d4 100644
--- a/src/PhpPresentation/AbstractShape.php
+++ b/src/PhpPresentation/AbstractShape.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,6 +20,7 @@
namespace PhpOffice\PhpPresentation;
use PhpOffice\PhpPresentation\Exception\ShapeContainerAlreadyAssignedException;
+use PhpOffice\PhpPresentation\Shape\Group;
use PhpOffice\PhpPresentation\Shape\Hyperlink;
use PhpOffice\PhpPresentation\Shape\Placeholder;
use PhpOffice\PhpPresentation\Style\Border;
@@ -35,7 +35,7 @@ abstract class AbstractShape implements ComparableInterface
/**
* Container.
*
- * @var ShapeContainerInterface|null
+ * @var null|ShapeContainerInterface
*/
protected $container;
@@ -68,7 +68,7 @@ abstract class AbstractShape implements ComparableInterface
protected $height;
/**
- * @var Fill|null
+ * @var null|Fill
*/
private $fill;
@@ -89,17 +89,17 @@ abstract class AbstractShape implements ComparableInterface
/**
* Shadow.
*
- * @var Shadow|null
+ * @var null|Shadow
*/
protected $shadow;
/**
- * @var Hyperlink|null
+ * @var null|Hyperlink
*/
protected $hyperlink;
/**
- * @var Placeholder|null
+ * @var null|Placeholder
*/
protected $placeholder;
@@ -110,6 +110,13 @@ abstract class AbstractShape implements ComparableInterface
*/
private $hashIndex;
+ /**
+ * Name.
+ *
+ * @var string
+ */
+ protected $name = '';
+
/**
* Create a new self.
*/
@@ -119,7 +126,8 @@ public function __construct()
$this->fill = new Fill();
$this->shadow = new Shadow();
$this->border = new Border();
- $this->border->setLineStyle(Style\Border::LINE_NONE);
+
+ $this->border->setLineStyle(Border::LINE_NONE);
}
/**
@@ -128,9 +136,20 @@ public function __construct()
public function __clone()
{
$this->container = null;
- $this->fill = clone $this->fill;
+ $this->name = $this->name;
$this->border = clone $this->border;
- $this->shadow = clone $this->shadow;
+ if (isset($this->fill)) {
+ $this->fill = clone $this->fill;
+ }
+ if (isset($this->shadow)) {
+ $this->shadow = clone $this->shadow;
+ }
+ if (isset($this->placeholder)) {
+ $this->placeholder = clone $this->placeholder;
+ }
+ if (isset($this->hyperlink)) {
+ $this->hyperlink = clone $this->hyperlink;
+ }
}
/**
@@ -144,33 +163,28 @@ public function getContainer(): ?ShapeContainerInterface
/**
* Set Container, Slide or Group.
*
- * @param ShapeContainerInterface $pValue
* @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide?
*
- * @throws ShapeContainerAlreadyAssignedException
- *
* @return $this
*/
- public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideOld = false)
+ public function setContainer(?ShapeContainerInterface $pValue = null, $pOverrideOld = false)
{
- if (is_null($this->container)) {
+ if (null === $this->container) {
// Add drawing to ShapeContainerInterface
$this->container = $pValue;
- if (!is_null($this->container)) {
- $this->container->getShapeCollection()->append($this);
+ if (null !== $this->container) {
+ $this->container->addShape($this);
}
} else {
if ($pOverrideOld) {
// Remove drawing from old ShapeContainerInterface
- $iterator = $this->container->getShapeCollection()->getIterator();
-
- while ($iterator->valid()) {
- if ($iterator->current()->getHashCode() == $this->getHashCode()) {
- $this->container->getShapeCollection()->offsetUnset($iterator->key());
+ foreach ($this->container->getShapeCollection() as $key => $shape) {
+ if ($shape->getHashCode() == $this->getHashCode()) {
+ $this->container->unsetShape($key);
$this->container = null;
+
break;
}
- $iterator->next();
}
// Set new \PhpOffice\PhpPresentation\Slide
@@ -183,6 +197,26 @@ public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideO
return $this;
}
+ /**
+ * Get Name.
+ */
+ public function getName(): string
+ {
+ return $this->name;
+ }
+
+ /**
+ * Set Name.
+ *
+ * @return static
+ */
+ public function setName(string $pValue = ''): self
+ {
+ $this->name = $pValue;
+
+ return $this;
+ }
+
/**
* Get OffsetX.
*/
@@ -311,7 +345,7 @@ public function getFill(): ?Fill
return $this->fill;
}
- public function setFill(Fill $pValue = null): self
+ public function setFill(?Fill $pValue = null): self
{
$this->fill = $pValue;
@@ -331,7 +365,7 @@ public function getShadow(): ?Shadow
/**
* @return $this
*/
- public function setShadow(Shadow $pValue = null)
+ public function setShadow(?Shadow $pValue = null)
{
$this->shadow = $pValue;
@@ -345,15 +379,15 @@ public function setShadow(Shadow $pValue = null)
*/
public function hasHyperlink()
{
- return !is_null($this->hyperlink);
+ return null !== $this->hyperlink;
}
/**
- * Get Hyperlink
+ * Get Hyperlink.
*/
public function getHyperlink(): Hyperlink
{
- if (is_null($this->hyperlink)) {
+ if (null === $this->hyperlink) {
$this->hyperlink = new Hyperlink();
}
@@ -361,9 +395,9 @@ public function getHyperlink(): Hyperlink
}
/**
- * Set Hyperlink
+ * Set Hyperlink.
*/
- public function setHyperlink(Hyperlink $pHyperlink = null): self
+ public function setHyperlink(?Hyperlink $pHyperlink = null): self
{
$this->hyperlink = $pHyperlink;
@@ -377,7 +411,7 @@ public function setHyperlink(Hyperlink $pHyperlink = null): self
*/
public function getHashCode(): string
{
- return md5((is_object($this->container) ? $this->container->getHashCode() : '') . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->rotation . (is_null($this->getFill()) ? '' : $this->getFill()->getHashCode()) . (is_null($this->shadow) ? '' : $this->shadow->getHashCode()) . (is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
+ return md5((is_object($this->container) ? $this->container->getHashCode() : '') . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->rotation . (null === $this->getFill() ? '' : $this->getFill()->getHashCode()) . (null === $this->shadow ? '' : $this->shadow->getHashCode()) . (null === $this->hyperlink ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
}
/**
@@ -386,7 +420,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
@@ -412,7 +446,7 @@ public function setHashIndex(int $value)
public function isPlaceholder(): bool
{
- return !is_null($this->placeholder);
+ return null !== $this->placeholder;
}
public function getPlaceholder(): ?Placeholder
diff --git a/src/PhpPresentation/Autoloader.php b/src/PhpPresentation/Autoloader.php
index 6c7211fde6..693b43aeeb 100644
--- a/src/PhpPresentation/Autoloader.php
+++ b/src/PhpPresentation/Autoloader.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/ComparableInterface.php b/src/PhpPresentation/ComparableInterface.php
index 7fefbda1c0..ed958b17ea 100644
--- a/src/PhpPresentation/ComparableInterface.php
+++ b/src/PhpPresentation/ComparableInterface.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -38,7 +37,7 @@ public function getHashCode(): string;
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int;
diff --git a/src/PhpPresentation/DocumentLayout.php b/src/PhpPresentation/DocumentLayout.php
index bf79104070..cc1deb5104 100644
--- a/src/PhpPresentation/DocumentLayout.php
+++ b/src/PhpPresentation/DocumentLayout.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -131,12 +130,17 @@ public function setDocumentLayout($pValue = self::LAYOUT_SCREEN_4X3, $isLandscap
$this->layout = $pValue;
$this->dimensionX = $this->dimension[$this->layout]['cx'];
$this->dimensionY = $this->dimension[$this->layout]['cy'];
+
break;
case self::LAYOUT_CUSTOM:
+ $this->layout = self::LAYOUT_CUSTOM;
+
+ break;
default:
$this->layout = self::LAYOUT_CUSTOM;
$this->dimensionX = $pValue['cx'];
$this->dimensionY = $pValue['cy'];
+
break;
}
@@ -196,18 +200,23 @@ protected function convertUnit(float $value, string $fromUnit, string $toUnit):
switch ($fromUnit) {
case self::UNIT_MILLIMETER:
$value *= 36000;
+
break;
case self::UNIT_CENTIMETER:
$value *= 360000;
+
break;
case self::UNIT_INCH:
$value *= 914400;
+
break;
case self::UNIT_PIXEL:
$value = Drawing::pixelsToEmu($value);
+
break;
case self::UNIT_POINT:
$value *= 12700;
+
break;
case self::UNIT_EMU:
default:
@@ -218,22 +227,27 @@ protected function convertUnit(float $value, string $fromUnit, string $toUnit):
switch ($toUnit) {
case self::UNIT_MILLIMETER:
$value /= 36000;
+
break;
case self::UNIT_CENTIMETER:
$value /= 360000;
+
break;
case self::UNIT_INCH:
$value /= 914400;
+
break;
case self::UNIT_PIXEL:
$value = Drawing::emuToPixels((int) $value);
+
break;
case self::UNIT_POINT:
$value /= 12700;
+
break;
case self::UNIT_EMU:
default:
- // no changes
+ // no changes
}
return $value;
diff --git a/src/PhpPresentation/DocumentProperties.php b/src/PhpPresentation/DocumentProperties.php
index ab45420437..bd0b4a8b6a 100644
--- a/src/PhpPresentation/DocumentProperties.php
+++ b/src/PhpPresentation/DocumentProperties.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -102,6 +101,20 @@ class DocumentProperties
*/
private $company;
+ /**
+ * Revision.
+ *
+ * @var string
+ */
+ private $revision;
+
+ /**
+ * Status.
+ *
+ * @var string
+ */
+ private $status;
+
/**
* Custom Properties.
*
@@ -110,7 +123,7 @@ class DocumentProperties
private $customProperties = [];
/**
- * Create a new \PhpOffice\PhpPresentation\DocumentProperties
+ * Create a new \PhpOffice\PhpPresentation\DocumentProperties.
*/
public function __construct()
{
@@ -125,6 +138,8 @@ public function __construct()
$this->keywords = '';
$this->category = '';
$this->company = 'Microsoft Corporation';
+ $this->revision = '';
+ $this->status = '';
}
/**
@@ -142,7 +157,7 @@ public function getCreator()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setCreator($pValue = '')
{
@@ -166,7 +181,7 @@ public function getLastModifiedBy()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setLastModifiedBy($pValue = '')
{
@@ -190,11 +205,11 @@ public function getCreated()
*
* @param int $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setCreated($pValue = null)
{
- if (is_null($pValue)) {
+ if (null === $pValue) {
$pValue = time();
}
$this->created = $pValue;
@@ -217,11 +232,11 @@ public function getModified()
*
* @param int $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setModified($pValue = null)
{
- if (is_null($pValue)) {
+ if (null === $pValue) {
$pValue = time();
}
$this->modified = $pValue;
@@ -244,7 +259,7 @@ public function getTitle()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setTitle($pValue = '')
{
@@ -268,7 +283,7 @@ public function getDescription()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setDescription($pValue = '')
{
@@ -292,7 +307,7 @@ public function getSubject()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setSubject($pValue = '')
{
@@ -316,7 +331,7 @@ public function getKeywords()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setKeywords($pValue = '')
{
@@ -340,7 +355,7 @@ public function getCategory()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setCategory($pValue = '')
{
@@ -364,7 +379,7 @@ public function getCompany()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * @return DocumentProperties
*/
public function setCompany($pValue = '')
{
@@ -385,10 +400,6 @@ public function getCustomProperties(): array
/**
* Check if a Custom Property is defined.
- *
- * @param string $propertyName
- *
- * @return bool
*/
public function isCustomPropertySet(string $propertyName): bool
{
@@ -398,9 +409,7 @@ public function isCustomPropertySet(string $propertyName): bool
/**
* Get a Custom Property Value.
*
- * @param string $propertyName
- *
- * @return mixed|null
+ * @return null|mixed
*/
public function getCustomPropertyValue(string $propertyName)
{
@@ -413,10 +422,6 @@ public function getCustomPropertyValue(string $propertyName)
/**
* Get a Custom Property Type.
- *
- * @param string $propertyName
- *
- * @return string|null
*/
public function getCustomPropertyType(string $propertyName): ?string
{
@@ -430,16 +435,13 @@ public function getCustomPropertyType(string $propertyName): ?string
/**
* Set a Custom Property.
*
- * @param string $propertyName
* @param mixed $propertyValue
- * @param string|null $propertyType
+ * @param null|string $propertyType
* 'i' : Integer
* 'f' : Floating Point
* 's' : String
* 'd' : Date/Time
* 'b' : Boolean
- *
- * @return self
*/
public function setCustomProperty(string $propertyName, $propertyValue = '', ?string $propertyType = null): self
{
@@ -467,4 +469,40 @@ public function setCustomProperty(string $propertyName, $propertyValue = '', ?st
return $this;
}
+
+ /**
+ * Get Revision.
+ */
+ public function getRevision(): string
+ {
+ return $this->revision;
+ }
+
+ /**
+ * Set Revision.
+ */
+ public function setRevision(string $pValue = ''): self
+ {
+ $this->revision = $pValue;
+
+ return $this;
+ }
+
+ /**
+ * Get Status.
+ */
+ public function getStatus(): string
+ {
+ return $this->status;
+ }
+
+ /**
+ * Set Status.
+ */
+ public function setStatus(string $pValue = ''): self
+ {
+ $this->status = $pValue;
+
+ return $this;
+ }
}
diff --git a/src/PhpPresentation/Exception/DirectoryNotFoundException.php b/src/PhpPresentation/Exception/DirectoryNotFoundException.php
index bfd444c440..e1c64e38be 100644
--- a/src/PhpPresentation/Exception/DirectoryNotFoundException.php
+++ b/src/PhpPresentation/Exception/DirectoryNotFoundException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/FeatureNotImplementedException.php b/src/PhpPresentation/Exception/FeatureNotImplementedException.php
index 56160e6bbe..2ba4a04ed3 100644
--- a/src/PhpPresentation/Exception/FeatureNotImplementedException.php
+++ b/src/PhpPresentation/Exception/FeatureNotImplementedException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/FileCopyException.php b/src/PhpPresentation/Exception/FileCopyException.php
index a6574bce5d..84dd930881 100644
--- a/src/PhpPresentation/Exception/FileCopyException.php
+++ b/src/PhpPresentation/Exception/FileCopyException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/FileNotFoundException.php b/src/PhpPresentation/Exception/FileNotFoundException.php
index 368a32b97f..bf825a4461 100644
--- a/src/PhpPresentation/Exception/FileNotFoundException.php
+++ b/src/PhpPresentation/Exception/FileNotFoundException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/FileRemoveException.php b/src/PhpPresentation/Exception/FileRemoveException.php
index e9b4e306af..04bd141ac1 100644
--- a/src/PhpPresentation/Exception/FileRemoveException.php
+++ b/src/PhpPresentation/Exception/FileRemoveException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/InvalidClassException.php b/src/PhpPresentation/Exception/InvalidClassException.php
index 06642d5ff3..e8813fbb49 100644
--- a/src/PhpPresentation/Exception/InvalidClassException.php
+++ b/src/PhpPresentation/Exception/InvalidClassException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/InvalidFileFormatException.php b/src/PhpPresentation/Exception/InvalidFileFormatException.php
index 4dcbff7b82..1894d4e1e1 100644
--- a/src/PhpPresentation/Exception/InvalidFileFormatException.php
+++ b/src/PhpPresentation/Exception/InvalidFileFormatException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/InvalidParameterException.php b/src/PhpPresentation/Exception/InvalidParameterException.php
index a6a97cf97a..5a426ea610 100644
--- a/src/PhpPresentation/Exception/InvalidParameterException.php
+++ b/src/PhpPresentation/Exception/InvalidParameterException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,12 +21,17 @@
class InvalidParameterException extends PhpPresentationException
{
- public function __construct(string $parameter, string $value)
+ public function __construct(string $parameter, string $value, ?string $error = null)
{
- parent::__construct(sprintf(
+ $message = sprintf(
'The parameter %s can\'t have the value "%s"',
$parameter,
$value
- ));
+ );
+ if ($error) {
+ $message = sprintf('%s (Validation: %s)', $message, $error);
+ }
+
+ parent::__construct($message);
}
}
diff --git a/src/PhpPresentation/Exception/NotAllowedValueException.php b/src/PhpPresentation/Exception/NotAllowedValueException.php
new file mode 100644
index 0000000000..9c0da31cf9
--- /dev/null
+++ b/src/PhpPresentation/Exception/NotAllowedValueException.php
@@ -0,0 +1,35 @@
+ $value
+ */
+ public function __construct(string $parameter, array $value)
+ {
+ parent::__construct(sprintf(
+ 'The value "%s" is not in allowed values ("%s")',
+ $parameter,
+ implode('", "', $value)
+ ));
+ }
+}
diff --git a/src/PhpPresentation/Exception/OutOfBoundsException.php b/src/PhpPresentation/Exception/OutOfBoundsException.php
index 7946c60752..38789d720e 100644
--- a/src/PhpPresentation/Exception/OutOfBoundsException.php
+++ b/src/PhpPresentation/Exception/OutOfBoundsException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/PhpPresentationException.php b/src/PhpPresentation/Exception/PhpPresentationException.php
index 52392894a1..629b70a0aa 100644
--- a/src/PhpPresentation/Exception/PhpPresentationException.php
+++ b/src/PhpPresentation/Exception/PhpPresentationException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/ShapeContainerAlreadyAssignedException.php b/src/PhpPresentation/Exception/ShapeContainerAlreadyAssignedException.php
index cd39cb0477..c210830110 100644
--- a/src/PhpPresentation/Exception/ShapeContainerAlreadyAssignedException.php
+++ b/src/PhpPresentation/Exception/ShapeContainerAlreadyAssignedException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Exception/UnauthorizedMimetypeException.php b/src/PhpPresentation/Exception/UnauthorizedMimetypeException.php
index 01a8b5b66d..67f03fc190 100644
--- a/src/PhpPresentation/Exception/UnauthorizedMimetypeException.php
+++ b/src/PhpPresentation/Exception/UnauthorizedMimetypeException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,7 +22,6 @@
class UnauthorizedMimetypeException extends PhpPresentationException
{
/**
- * @param string $expectedMimetype
* @param array $authorizedMimetypes
*/
public function __construct(string $expectedMimetype, array $authorizedMimetypes)
diff --git a/src/PhpPresentation/Exception/UndefinedChartTypeException.php b/src/PhpPresentation/Exception/UndefinedChartTypeException.php
index 5e77181a0c..6b53f26f78 100644
--- a/src/PhpPresentation/Exception/UndefinedChartTypeException.php
+++ b/src/PhpPresentation/Exception/UndefinedChartTypeException.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/GeometryCalculator.php b/src/PhpPresentation/GeometryCalculator.php
index 7eccbf8959..2c050929ed 100644
--- a/src/PhpPresentation/GeometryCalculator.php
+++ b/src/PhpPresentation/GeometryCalculator.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/HashTable.php b/src/PhpPresentation/HashTable.php
index df5e5a29a8..6a72f5c30f 100644
--- a/src/PhpPresentation/HashTable.php
+++ b/src/PhpPresentation/HashTable.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/IOFactory.php b/src/PhpPresentation/IOFactory.php
index 0d7f90b291..88f7d4bc14 100644
--- a/src/PhpPresentation/IOFactory.php
+++ b/src/PhpPresentation/IOFactory.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -40,9 +39,6 @@ class IOFactory
/**
* Create writer.
- *
- * @param PhpPresentation $phpPresentation
- * @param string $name
*/
public static function createWriter(PhpPresentation $phpPresentation, string $name = 'PowerPoint2007'): WriterInterface
{
@@ -51,8 +47,6 @@ public static function createWriter(PhpPresentation $phpPresentation, string $na
/**
* Create reader.
- *
- * @param string $name
*/
public static function createReader(string $name): ReaderInterface
{
@@ -61,8 +55,6 @@ public static function createReader(string $name): ReaderInterface
/**
* Loads PhpPresentation from file using automatic ReaderInterface resolution.
- *
- * @throws InvalidFileFormatException
*/
public static function load(string $pFilename): PhpPresentation
{
@@ -76,23 +68,17 @@ public static function load(string $pFilename): PhpPresentation
throw new InvalidFileFormatException(
$pFilename,
- IOFactory::class,
+ self::class,
'Could not automatically determine the good ' . ReaderInterface::class
);
}
/**
- * Load class
- *
- * @param string $class
- * @param string $type
- * @param PhpPresentation|null $phpPresentation
+ * Load class.
*
* @return object
- *
- * @throws InvalidClassException
*/
- private static function loadClass(string $class, string $type, PhpPresentation $phpPresentation = null)
+ private static function loadClass(string $class, string $type, ?PhpPresentation $phpPresentation = null)
{
if (!class_exists($class)) {
throw new InvalidClassException($class, $type . ': The class doesn\'t exist');
@@ -100,7 +86,7 @@ private static function loadClass(string $class, string $type, PhpPresentation $
if (!self::isConcreteClass($class)) {
throw new InvalidClassException($class, $type . ': The class is an abstract class or an interface');
}
- if (is_null($phpPresentation)) {
+ if (null === $phpPresentation) {
return new $class();
}
diff --git a/src/PhpPresentation/PhpPresentation.php b/src/PhpPresentation/PhpPresentation.php
index e2db811f5a..5f9df71912 100644
--- a/src/PhpPresentation/PhpPresentation.php
+++ b/src/PhpPresentation/PhpPresentation.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -118,8 +117,6 @@ public function getPresentationProperties(): PresentationProperties
/**
* Set presentation properties.
- *
- * @return PhpPresentation
*/
public function setPresentationProperties(PresentationProperties $value): self
{
@@ -168,9 +165,13 @@ public function createSlide(): Slide
/**
* Add slide.
*/
- public function addSlide(Slide $slide): Slide
+ public function addSlide(Slide $slide, int $index = -1): Slide
{
- $this->slideCollection[] = $slide;
+ if ($index > -1) {
+ array_splice($this->slideCollection, $index, 0, [$slide]);
+ } else {
+ $this->slideCollection[] = $slide;
+ }
return $slide;
}
@@ -179,8 +180,6 @@ public function addSlide(Slide $slide): Slide
* Remove slide by index.
*
* @param int $index Slide index
- *
- * @throws OutOfBoundsException
*/
public function removeSlideByIndex(int $index = 0): self
{
@@ -196,8 +195,6 @@ public function removeSlideByIndex(int $index = 0): self
* Get slide by index.
*
* @param int $index Slide index
- *
- * @throws OutOfBoundsException
*/
public function getSlide(int $index = 0): Slide
{
@@ -257,8 +254,6 @@ public function getActiveSlideIndex(): int
* Set active slide index.
*
* @param int $index Active slide index
- *
- * @throws OutOfBoundsException
*/
public function setActiveSlideIndex(int $index = 0): Slide
{
@@ -316,16 +311,31 @@ public function addMasterSlide(SlideMaster $slide): SlideMaster
/**
* Copy presentation (!= clone!).
*/
- public function copy(): PhpPresentation
+ public function copy(): self
{
$copied = clone $this;
$slideCount = count($this->slideCollection);
+
+ // Because the rebindParent() method on AbstractSlide removes the slide
+ // from the parent (current $this which we're cloning) presentation, we
+ // save the collection. This way, after the copying has finished, we can
+ // return the slides to the original presentation.
+ $oldSlideCollection = $this->slideCollection;
+ $newSlideCollection = [];
+
for ($i = 0; $i < $slideCount; ++$i) {
- $this->slideCollection[$i] = $this->slideCollection[$i]->copy();
- $this->slideCollection[$i]->rebindParent($this);
+ $newSlideCollection[$i] = $oldSlideCollection[$i]->copy();
+ $newSlideCollection[$i]->rebindParent($copied);
}
+ // Give the copied presentation a copied slide collection which the
+ // copied slides have been rebind to the copied presentation.
+ $copied->slideCollection = $newSlideCollection;
+
+ // Return the original slides to the original presentation.
+ $this->slideCollection = $oldSlideCollection;
+
return $copied;
}
diff --git a/src/PhpPresentation/PresentationProperties.php b/src/PhpPresentation/PresentationProperties.php
index a8ee8eff3f..dce8f439db 100644
--- a/src/PhpPresentation/PresentationProperties.php
+++ b/src/PhpPresentation/PresentationProperties.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -31,6 +30,9 @@ class PresentationProperties
public const VIEW_SLIDE_SORTER = 'sldSorterView';
public const VIEW_SLIDE_THUMBNAIL = 'sldThumbnailView';
+ public const THUMBNAIL_FILE = 'file';
+ public const THUMBNAIL_DATA = 'data';
+
/**
* @var array
*/
@@ -71,10 +73,20 @@ class PresentationProperties
protected $markAsFinal = false;
/**
- * @var string|null
+ * @var null|string Define the thumbnail content (if content into zip file)
*/
protected $thumbnail;
+ /**
+ * @var null|string Define the thumbnail place
+ */
+ protected $thumbnailPath;
+
+ /**
+ * @var string Define if thumbnail is out of PPT or previouly store into PPT
+ */
+ protected $thumbnailType = self::THUMBNAIL_FILE;
+
/**
* Zoom.
*
@@ -111,30 +123,60 @@ public function setLoopContinuouslyUntilEsc(bool $value = false): self
/**
* Return the thumbnail file path.
- *
- * @return string|null
*/
public function getThumbnailPath(): ?string
{
- return $this->thumbnail;
+ return $this->thumbnailPath;
+ }
+
+ /**
+ * Return the content of thumbnail.
+ */
+ public function getThumbnail(): ?string
+ {
+ // Return content of local file
+ if ($this->getThumbnailType() == self::THUMBNAIL_FILE) {
+ if ($this->getThumbnailPath()) {
+ return file_get_contents($this->getThumbnailPath());
+ }
+
+ return null;
+ }
+
+ // Return content of image stored into zip file
+ if ($this->getThumbnailType() == self::THUMBNAIL_DATA) {
+ return $this->thumbnail;
+ }
+
+ return null;
}
/**
* Define the path for the thumbnail file / preview picture.
- *
- * @param string $path
- *
- * @return self
*/
- public function setThumbnailPath(string $path = ''): self
+ public function setThumbnailPath(string $path = '', string $type = self::THUMBNAIL_FILE, ?string $content = null): self
{
- if (file_exists($path)) {
- $this->thumbnail = $path;
+ if (file_exists($path) && $type == self::THUMBNAIL_FILE) {
+ $this->thumbnailPath = $path;
+ $this->thumbnailType = $type;
+ }
+ if ($content != '' && $type == self::THUMBNAIL_DATA) {
+ $this->thumbnailPath = '';
+ $this->thumbnailType = $type;
+ $this->thumbnail = $content;
}
return $this;
}
+ /**
+ * Return the thumbnail type.
+ */
+ public function getThumbnailType(): string
+ {
+ return $this->thumbnailType;
+ }
+
/**
* Mark a document as final.
*/
@@ -147,8 +189,6 @@ public function markAsFinal(bool $state = true): self
/**
* Return if this document is marked as final.
- *
- * @return bool
*/
public function isMarkedAsFinal(): bool
{
@@ -173,11 +213,6 @@ public function getZoom(): float
return $this->zoom;
}
- /**
- * @param string $value
- *
- * @return self
- */
public function setLastView(string $value = self::VIEW_SLIDE): self
{
if (in_array($value, $this->arrayView)) {
@@ -187,9 +222,6 @@ public function setLastView(string $value = self::VIEW_SLIDE): self
return $this;
}
- /**
- * @return string
- */
public function getLastView(): string
{
return $this->lastView;
@@ -207,19 +239,11 @@ public function isCommentVisible(): bool
return $this->isCommentVisible;
}
- /**
- * @return string
- */
public function getSlideshowType(): string
{
return $this->slideshowType;
}
- /**
- * @param string $value
- *
- * @return self
- */
public function setSlideshowType(string $value = self::SLIDESHOW_TYPE_PRESENT): self
{
if (in_array($value, $this->arraySlideshowTypes)) {
diff --git a/src/PhpPresentation/Reader/ODPresentation.php b/src/PhpPresentation/Reader/ODPresentation.php
index 25a6d1cbb3..579fab676b 100644
--- a/src/PhpPresentation/Reader/ODPresentation.php
+++ b/src/PhpPresentation/Reader/ODPresentation.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,6 +32,7 @@
use PhpOffice\PhpPresentation\Shape\Drawing\Gd;
use PhpOffice\PhpPresentation\Shape\RichText;
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
+use PhpOffice\PhpPresentation\Slide\Background\Color as BackgroundColor;
use PhpOffice\PhpPresentation\Slide\Background\Image;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Bullet;
@@ -53,24 +53,29 @@ class ODPresentation implements ReaderInterface
* @var PhpPresentation
*/
protected $oPhpPresentation;
+
/**
* Output Object.
*
- * @var \ZipArchive
+ * @var ZipArchive
*/
protected $oZip;
+
/**
- * @var array[]
+ * @var array
*/
protected $arrayStyles = [];
+
/**
- * @var array[]
+ * @var array>
*/
protected $arrayCommonStyles = [];
+
/**
- * @var \PhpOffice\Common\XMLReader
+ * @var XMLReader
*/
protected $oXMLReader;
+
/**
* @var int
*/
@@ -86,8 +91,6 @@ public function canRead(string $pFilename): bool
/**
* Does a file support UnserializePhpPresentation ?
- *
- * @throws FileNotFoundException
*/
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
{
@@ -111,14 +114,12 @@ public function fileSupportsUnserializePhpPresentation(string $pFilename = ''):
/**
* Loads PhpPresentation Serialized file.
- *
- * @throws InvalidFileFormatException
*/
public function load(string $pFilename): PhpPresentation
{
// Unserialize... First make sure the file supports it!
if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
- throw new InvalidFileFormatException($pFilename, ODPresentation::class);
+ throw new InvalidFileFormatException($pFilename, self::class);
}
return $this->loadFile($pFilename);
@@ -157,7 +158,7 @@ protected function loadFile($pFilename)
}
/**
- * Read Document Properties
+ * Read Document Properties.
*/
protected function loadDocumentProperties(): void
{
@@ -198,18 +199,22 @@ protected function loadDocumentProperties(): void
switch ($propertyType) {
case 'boolean':
$propertyType = DocumentProperties::PROPERTY_TYPE_BOOLEAN;
+
break;
case 'float':
$propertyType = filter_var($propertyValue, FILTER_VALIDATE_INT) === false
? DocumentProperties::PROPERTY_TYPE_FLOAT
: DocumentProperties::PROPERTY_TYPE_INTEGER;
+
break;
case 'date':
$propertyType = DocumentProperties::PROPERTY_TYPE_DATE;
+
break;
case 'string':
default:
$propertyType = DocumentProperties::PROPERTY_TYPE_STRING;
+
break;
}
$properties->setCustomProperty($propertyName, $propertyValue, $propertyType);
@@ -217,7 +222,7 @@ protected function loadDocumentProperties(): void
}
/**
- * Extract all slides
+ * Extract all slides.
*/
protected function loadSlides(): void
{
@@ -244,7 +249,7 @@ protected function loadPresentationProperties(): void
}
/**
- * Extract style
+ * Extract style.
*/
protected function loadStyle(DOMElement $nodeStyle): bool
{
@@ -254,7 +259,7 @@ protected function loadStyle(DOMElement $nodeStyle): bool
if ($nodeDrawingPageProps instanceof DOMElement) {
// Read Background Color
if ($nodeDrawingPageProps->hasAttribute('draw:fill-color') && 'solid' == $nodeDrawingPageProps->getAttribute('draw:fill')) {
- $oBackground = new \PhpOffice\PhpPresentation\Slide\Background\Color();
+ $oBackground = new BackgroundColor();
$oColor = new Color();
$oColor->setRGB(substr($nodeDrawingPageProps->getAttribute('draw:fill-color'), -6));
$oBackground->setColor($oColor);
@@ -306,6 +311,7 @@ protected function loadStyle(DOMElement $nodeStyle): bool
case 'none':
$oFill = new Fill();
$oFill->setFillType(Fill::FILL_NONE);
+
break;
case 'solid':
$oFill = new Fill();
@@ -315,6 +321,7 @@ protected function loadStyle(DOMElement $nodeStyle): bool
$oColor->setRGB(substr($nodeGraphicProps->getAttribute('draw:fill-color'), 1));
$oFill->setStartColor($oColor);
}
+
break;
}
}
@@ -326,6 +333,22 @@ protected function loadStyle(DOMElement $nodeStyle): bool
if ($nodeTextProperties->hasAttribute('fo:color')) {
$oFont->getColor()->setRGB(substr($nodeTextProperties->getAttribute('fo:color'), -6));
}
+ if ($nodeTextProperties->hasAttribute('fo:text-transform')) {
+ switch ($nodeTextProperties->getAttribute('fo:text-transform')) {
+ case 'none':
+ $oFont->setCapitalization(Font::CAPITALIZATION_NONE);
+
+ break;
+ case 'lowercase':
+ $oFont->setCapitalization(Font::CAPITALIZATION_SMALL);
+
+ break;
+ case 'uppercase':
+ $oFont->setCapitalization(Font::CAPITALIZATION_ALL);
+
+ break;
+ }
+ }
// Font Latin
if ($nodeTextProperties->hasAttribute('fo:font-family')) {
$oFont
@@ -378,12 +401,15 @@ protected function loadStyle(DOMElement $nodeStyle): bool
switch ($nodeTextProperties->getAttribute('style:script-type')) {
case 'latin':
$oFont->setFormat(Font::FORMAT_LATIN);
+
break;
case 'asian':
$oFont->setFormat(Font::FORMAT_EAST_ASIAN);
+
break;
case 'complex':
$oFont->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
+
break;
}
}
@@ -414,11 +440,13 @@ protected function loadStyle(DOMElement $nodeStyle): bool
case 'tb-lr':
case 'lr':
$oAlignment->setIsRTL(false);
+
break;
case 'rl-tb':
case 'tb-rl':
case 'rl':
$oAlignment->setIsRTL(false);
+
break;
case 'tb':
case 'page':
@@ -487,7 +515,7 @@ protected function loadStyle(DOMElement $nodeStyle): bool
}
/**
- * Read Slide
+ * Read Slide.
*/
protected function loadSlide(DOMElement $nodeSlide): bool
{
@@ -507,10 +535,12 @@ protected function loadSlide(DOMElement $nodeSlide): bool
if ($oNodeFrame instanceof DOMElement) {
if ($this->oXMLReader->getElement('draw:image', $oNodeFrame)) {
$this->loadShapeDrawing($oNodeFrame);
+
continue;
}
if ($this->oXMLReader->getElement('draw:text-box', $oNodeFrame)) {
$this->loadShapeRichText($oNodeFrame);
+
continue;
}
}
@@ -520,7 +550,7 @@ protected function loadSlide(DOMElement $nodeSlide): bool
}
/**
- * Read Shape Drawing
+ * Read Shape Drawing.
*/
protected function loadShapeDrawing(DOMElement $oNodeFrame): void
{
@@ -577,7 +607,7 @@ protected function loadShapeDrawing(DOMElement $oNodeFrame): void
}
/**
- * Read Shape RichText
+ * Read Shape RichText.
*/
protected function loadShapeRichText(DOMElement $oNodeFrame): void
{
@@ -608,7 +638,7 @@ protected function loadShapeRichText(DOMElement $oNodeFrame): void
}
/**
- * Read Paragraph
+ * Read Paragraph.
*/
protected function readParagraph(RichText $oShape, DOMElement $oNodeParent): void
{
@@ -646,7 +676,7 @@ protected function readParagraph(RichText $oShape, DOMElement $oNodeParent): voi
}
/**
- * Read Paragraph Item
+ * Read Paragraph Item.
*/
protected function readParagraphItem(Paragraph $oParagraph, DOMElement $oNodeParent): void
{
@@ -673,7 +703,7 @@ protected function readParagraphItem(Paragraph $oParagraph, DOMElement $oNodePar
}
/**
- * Read List
+ * Read List.
*/
protected function readList(RichText $oShape, DOMElement $oNodeParent): void
{
@@ -692,7 +722,7 @@ protected function readList(RichText $oShape, DOMElement $oNodeParent): void
}
/**
- * Read List Item
+ * Read List Item.
*/
protected function readListItem(RichText $oShape, DOMElement $oNodeParent, DOMElement $oNodeParagraph): void
{
@@ -726,11 +756,6 @@ protected function loadStylesFile(): void
}
}
- /**
- * @param string $expr
- *
- * @return string
- */
private function getExpressionUnit(string $expr): string
{
if (substr($expr, -1) == '%') {
@@ -740,11 +765,6 @@ private function getExpressionUnit(string $expr): string
return substr($expr, -2);
}
- /**
- * @param string $expr
- *
- * @return string
- */
private function getExpressionValue(string $expr): string
{
if (substr($expr, -1) == '%') {
diff --git a/src/PhpPresentation/Reader/PowerPoint2007.php b/src/PhpPresentation/Reader/PowerPoint2007.php
index ad0deb9767..140c2f4a5d 100644
--- a/src/PhpPresentation/Reader/PowerPoint2007.php
+++ b/src/PhpPresentation/Reader/PowerPoint2007.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,6 +34,7 @@
use PhpOffice\PhpPresentation\PresentationProperties;
use PhpOffice\PhpPresentation\Shape\Drawing\Base64;
use PhpOffice\PhpPresentation\Shape\Drawing\Gd;
+use PhpOffice\PhpPresentation\Shape\Hyperlink;
use PhpOffice\PhpPresentation\Shape\Placeholder;
use PhpOffice\PhpPresentation\Shape\RichText;
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
@@ -51,6 +51,7 @@
use PhpOffice\PhpPresentation\Style\Fill;
use PhpOffice\PhpPresentation\Style\Font;
use PhpOffice\PhpPresentation\Style\SchemeColor;
+use PhpOffice\PhpPresentation\Style\Shadow;
use PhpOffice\PhpPresentation\Style\TextStyle;
use ZipArchive;
@@ -65,24 +66,29 @@ class PowerPoint2007 implements ReaderInterface
* @var PhpPresentation
*/
protected $oPhpPresentation;
+
/**
* Output Object.
*
- * @var \ZipArchive
+ * @var ZipArchive
*/
protected $oZip;
+
/**
- * @var array[]
+ * @var array>>
*/
protected $arrayRels = [];
+
/**
* @var SlideLayout[]
*/
protected $arraySlideLayouts = [];
+
/**
* @var string
*/
protected $filename;
+
/**
* @var string
*/
@@ -98,8 +104,6 @@ public function canRead(string $pFilename): bool
/**
* Does a file support UnserializePhpPresentation ?
- *
- * @throws FileNotFoundException
*/
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
{
@@ -123,14 +127,12 @@ public function fileSupportsUnserializePhpPresentation(string $pFilename = ''):
/**
* Loads PhpPresentation Serialized file.
- *
- * @throws InvalidFileFormatException
*/
public function load(string $pFilename): PhpPresentation
{
// Unserialize... First make sure the file supports it!
if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
- throw new InvalidFileFormatException($pFilename, PowerPoint2007::class);
+ throw new InvalidFileFormatException($pFilename, self::class);
}
return $this->loadFile($pFilename);
@@ -153,6 +155,11 @@ protected function loadFile(string $pFilename): PhpPresentation
$this->loadDocumentProperties($docPropsCore);
}
+ $docThumbnail = $this->oZip->getFromName('_rels/.rels');
+ if ($docThumbnail !== false) {
+ $this->loadThumbnailProperties($docThumbnail);
+ }
+
$docPropsCustom = $this->oZip->getFromName('docProps/custom.xml');
if (false !== $docPropsCustom) {
$this->loadCustomProperties($docPropsCustom);
@@ -183,7 +190,7 @@ protected function loadFile(string $pFilename): PhpPresentation
protected function loadDocumentLayout(string $sPart): void
{
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
foreach ($xmlReader->getElements('/p:presentation/p:sldSz') as $oElement) {
if (!($oElement instanceof DOMElement)) {
@@ -210,7 +217,7 @@ protected function loadDocumentLayout(string $sPart): void
protected function loadDocumentProperties(string $sPart): void
{
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
$arrayProperties = [
'/cp:coreProperties/dc:creator' => 'setCreator',
@@ -222,6 +229,8 @@ protected function loadDocumentProperties(string $sPart): void
'/cp:coreProperties/cp:category' => 'setCategory',
'/cp:coreProperties/dcterms:created' => 'setCreated',
'/cp:coreProperties/dcterms:modified' => 'setModified',
+ '/cp:coreProperties/cp:revision' => 'setRevision',
+ '/cp:coreProperties/cp:contentStatus' => 'setStatus',
];
$oProperties = $this->oPhpPresentation->getDocumentProperties();
foreach ($arrayProperties as $path => $property) {
@@ -238,6 +247,23 @@ protected function loadDocumentProperties(string $sPart): void
}
}
+ /**
+ * Read information of the document thumbnail.
+ */
+ protected function loadThumbnailProperties(string $sPart): void
+ {
+ $xmlReader = new XMLReader();
+ $xmlReader->getDomFromString($sPart);
+
+ $oElement = $xmlReader->getElement('*[@Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"]');
+ if ($oElement instanceof DOMElement) {
+ $path = $oElement->getAttribute('Target');
+ $this->oPhpPresentation
+ ->getPresentationProperties()
+ ->setThumbnailPath('', PresentationProperties::THUMBNAIL_DATA, $this->oZip->getFromName($path));
+ }
+ }
+
/**
* Read Custom Properties.
*/
@@ -245,7 +271,7 @@ protected function loadCustomProperties(string $sPart): void
{
$xmlReader = new XMLReader();
$sPart = str_replace(' xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"', '', $sPart);
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
foreach ($xmlReader->getElements('/Properties/property[@fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"]') as $element) {
if (!$element->hasAttribute('name')) {
@@ -288,12 +314,12 @@ protected function loadCustomProperties(string $sPart): void
}
/**
- * Read Presentation Properties
+ * Read Presentation Properties.
*/
protected function loadPresentationProperties(string $sPart): void
{
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
$element = $xmlReader->getElement('/p:presentationPr/p:showPr');
if ($element instanceof DOMElement) {
@@ -327,25 +353,25 @@ protected function loadPresentationProperties(string $sPart): void
protected function loadViewProperties(string $sPart): void
{
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
$pathZoom = '/p:viewPr/p:slideViewPr/p:cSldViewPr/p:cViewPr/p:scale/a:sx';
$oElement = $xmlReader->getElement($pathZoom);
if ($oElement instanceof DOMElement) {
if ($oElement->hasAttribute('d') && $oElement->hasAttribute('n')) {
- $this->oPhpPresentation->getPresentationProperties()->setZoom($oElement->getAttribute('n') / $oElement->getAttribute('d'));
+ $this->oPhpPresentation->getPresentationProperties()->setZoom((int) $oElement->getAttribute('n') / (int) $oElement->getAttribute('d'));
}
}
}
}
/**
- * Extract all slides
+ * Extract all slides.
*/
protected function loadSlides(string $sPart): void
{
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
$fileRels = 'ppt/_rels/presentation.xml.rels';
$this->loadRels($fileRels);
@@ -376,7 +402,7 @@ protected function loadSlides(string $sPart): void
}
/**
- * Extract all MasterSlides
+ * Extract all MasterSlides.
*/
protected function loadMasterSlides(XMLReader $xmlReader, string $fileRels): void
{
@@ -400,12 +426,12 @@ protected function loadMasterSlides(XMLReader $xmlReader, string $fileRels): voi
}
/**
- * Extract data from slide
+ * Extract data from slide.
*/
protected function loadSlide(string $sPart, string $baseFile): void
{
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
// Core
$oSlide = $this->oPhpPresentation->createSlide();
@@ -448,8 +474,7 @@ protected function loadSlide(string $sPart, string $baseFile): void
$pathImage = explode('/', $pathImage);
foreach ($pathImage as $key => $partPath) {
if ('..' == $partPath) {
- unset($pathImage[$key - 1]);
- unset($pathImage[$key]);
+ unset($pathImage[$key - 1], $pathImage[$key]);
}
}
$pathImage = implode('/', $pathImage);
@@ -479,6 +504,7 @@ protected function loadSlide(string $sPart, string $baseFile): void
if (array_key_exists($layoutBasename, $this->arraySlideLayouts)) {
$oSlide->setSlideLayout($this->arraySlideLayouts[$layoutBasename]);
}
+
break;
}
}
@@ -488,7 +514,7 @@ protected function loadSlide(string $sPart, string $baseFile): void
protected function loadMasterSlide(string $sPart, string $baseFile): void
{
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
// Core
$oSlideMaster = $this->oPhpPresentation->createMasterSlide();
@@ -532,7 +558,7 @@ protected function loadMasterSlide(string $sPart, string $baseFile): void
} else {
$level = str_replace('a:lvl', '', $oElementLvl->nodeName);
$level = str_replace('pPr', '', $level);
- $level = intval($level);
+ $level = (int) $level;
}
if ($oElementLvl->hasAttribute('algn')) {
@@ -556,7 +582,7 @@ protected function loadMasterSlide(string $sPart, string $baseFile): void
$oElementLvlDefRPR = $xmlReader->getElement('a:defRPr', $oElementLvl);
if ($oElementLvlDefRPR instanceof DOMElement) {
if ($oElementLvlDefRPR->hasAttribute('sz')) {
- $oRTParagraph->getFont()->setSize($oElementLvlDefRPR->getAttribute('sz') / 100);
+ $oRTParagraph->getFont()->setSize((int) ((int) $oElementLvlDefRPR->getAttribute('sz') / 100));
}
if ($oElementLvlDefRPR->hasAttribute('b') && 1 == $oElementLvlDefRPR->getAttribute('b')) {
$oRTParagraph->getFont()->setBold(true);
@@ -577,12 +603,15 @@ protected function loadMasterSlide(string $sPart, string $baseFile): void
switch ($oElementTxStyle->nodeName) {
case 'p:bodyStyle':
$oSlideMaster->getTextStyles()->setBodyStyleAtLvl($oRTParagraph, $level);
+
break;
case 'p:otherStyle':
$oSlideMaster->getTextStyles()->setOtherStyleAtLvl($oRTParagraph, $level);
+
break;
case 'p:titleStyle':
$oSlideMaster->getTextStyles()->setTitleStyleAtLvl($oRTParagraph, $level);
+
break;
}
}
@@ -595,6 +624,7 @@ protected function loadMasterSlide(string $sPart, string $baseFile): void
if (false !== $pptTheme) {
$this->loadTheme($pptTheme, $oSlideMaster);
}
+
break;
}
}
@@ -624,7 +654,7 @@ protected function loadMasterSlide(string $sPart, string $baseFile): void
protected function loadLayoutSlide(string $sPart, string $baseFile, SlideMaster $oSlideMaster): ?SlideLayout
{
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
// Core
$oSlideLayout = new SlideLayout($oSlideMaster);
@@ -659,14 +689,15 @@ protected function loadLayoutSlide(string $sPart, string $baseFile, SlideMaster
return $oSlideLayout;
}
- /* @phpstan-ignore-next-line */
+
+ // @phpstan-ignore-next-line
return null;
}
protected function loadTheme(string $sPart, SlideMaster $oSlideMaster): void
{
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
$oElements = $xmlReader->getElements('/a:theme/a:themeElements/a:clrScheme/*');
foreach ($oElements as $oElement) {
@@ -725,8 +756,7 @@ protected function loadSlideBackground(XMLReader $xmlReader, DOMElement $oElemen
$pathImage = explode('/', $pathImage);
foreach ($pathImage as $key => $partPath) {
if ('..' == $partPath) {
- unset($pathImage[$key - 1]);
- unset($pathImage[$key]);
+ unset($pathImage[$key - 1], $pathImage[$key]);
}
}
$pathImage = implode('/', $pathImage);
@@ -747,7 +777,7 @@ protected function loadSlideNote(string $baseFile, Slide $oSlide): void
{
$sPart = $this->oZip->getFromName('ppt/notesSlides/' . $baseFile);
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
$oNote = $oSlide->getNote();
@@ -777,12 +807,9 @@ protected function loadShapeDrawing(XMLReader $document, DOMElement $node, Abstr
// Hyperlink
$oElementHlinkClick = $document->getElement('a:hlinkClick', $oElement);
if (is_object($oElementHlinkClick)) {
- if ($oElementHlinkClick->hasAttribute('tooltip')) {
- $oShape->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip'));
- }
- if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target'])) {
- $oShape->getHyperlink()->setUrl($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target']);
- }
+ $oShape->setHyperlink(
+ $this->loadHyperlink($document, $oElementHlinkClick, $oShape->getHyperlink())
+ );
}
}
@@ -793,8 +820,7 @@ protected function loadShapeDrawing(XMLReader $document, DOMElement $node, Abstr
$pathImage = explode('/', $pathImage);
foreach ($pathImage as $key => $partPath) {
if ('..' == $partPath) {
- unset($pathImage[$key - 1]);
- unset($pathImage[$key]);
+ unset($pathImage[$key - 1], $pathImage[$key]);
}
}
$pathImage = implode('/', $pathImage);
@@ -804,7 +830,11 @@ protected function loadShapeDrawing(XMLReader $document, DOMElement $node, Abstr
$info = getimagesizefromstring($imageFile);
$oShape->setMimeType($info['mime']);
$oShape->setRenderingFunction(str_replace('/', '', $info['mime']));
- $oShape->setImageResource(imagecreatefromstring($imageFile));
+ $image = @imagecreatefromstring($imageFile);
+ if (!$image) {
+ return;
+ }
+ $oShape->setImageResource($image);
} elseif ($oShape instanceof Base64) {
$oShape->setData('data:image/svg+xml;base64,' . base64_encode($imageFile));
}
@@ -844,52 +874,70 @@ protected function loadShapeDrawing(XMLReader $document, DOMElement $node, Abstr
$oShape->setHeight(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cy')));
}
}
-
+ // Load shape effects
$oElement = $document->getElement('p:spPr/a:effectLst', $node);
if ($oElement instanceof DOMElement) {
- $oShape->getShadow()->setVisible(true);
+ $oShape->setShadow(
+ $this->loadShadow($document, $oElement)
+ );
+ }
+ $oSlide->addShape($oShape);
+ }
- $oSubElement = $document->getElement('a:outerShdw', $oElement);
- if ($oSubElement instanceof DOMElement) {
- if ($oSubElement->hasAttribute('blurRad')) {
- $oShape->getShadow()->setBlurRadius(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('blurRad')));
- }
- if ($oSubElement->hasAttribute('dist')) {
- $oShape->getShadow()->setDistance(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('dist')));
- }
- if ($oSubElement->hasAttribute('dir')) {
- $oShape->getShadow()->setDirection((int) CommonDrawing::angleToDegrees((int) $oSubElement->getAttribute('dir')));
- }
- if ($oSubElement->hasAttribute('algn')) {
- $oShape->getShadow()->setAlignment($oSubElement->getAttribute('algn'));
- }
- }
+ /**
+ * Load Shadow for shape or paragraph.
+ */
+ protected function loadShadow(XMLReader $document, DOMElement $node): ?Shadow
+ {
+ if ($node instanceof DOMElement) {
+ $aNodes = $document->getElements('*', $node);
+ foreach ($aNodes as $nodeShadow) {
+ $type = explode(':', $nodeShadow->tagName);
+ $type = array_pop($type);
+ if ($type == Shadow::TYPE_SHADOW_INNER || $type == Shadow::TYPE_SHADOW_OUTER || $type == Shadow::TYPE_REFLECTION) {
+ $oShadow = new Shadow();
+ $oShadow->setVisible(true);
+ $oShadow->setType($type);
+ if ($nodeShadow->hasAttribute('blurRad')) {
+ $oShadow->setBlurRadius(CommonDrawing::emuToPixels((int) $nodeShadow->getAttribute('blurRad')));
+ }
+ if ($nodeShadow->hasAttribute('dist')) {
+ $oShadow->setDistance(CommonDrawing::emuToPixels((int) $nodeShadow->getAttribute('dist')));
+ }
+ if ($nodeShadow->hasAttribute('dir')) {
+ $oShadow->setDirection((int) CommonDrawing::angleToDegrees((int) $nodeShadow->getAttribute('dir')));
+ }
+ if ($nodeShadow->hasAttribute('algn')) {
+ $oShadow->setAlignment($node->getAttribute('algn'));
+ }
- $oSubElement = $document->getElement('a:outerShdw/a:srgbClr', $oElement);
- if ($oSubElement instanceof DOMElement) {
- if ($oSubElement->hasAttribute('val')) {
- $oColor = new Color();
- $oColor->setRGB($oSubElement->getAttribute('val'));
- $oShape->getShadow()->setColor($oColor);
- }
- }
+ // Get color define by prstClr
+ $oSubElement = $document->getElement('a:prstClr', $nodeShadow);
+ if ($oSubElement instanceof DOMElement && $oSubElement->hasAttribute('val')) {
+ $oColor = new Color();
+ $oColor->setRGB($oSubElement->getAttribute('val'));
+
+ $oSubElt = $document->getElement('a:alpha', $oSubElement);
+ if ($oSubElt instanceof DOMElement && $oSubElt->hasAttribute('val')) {
+ $oColor->setAlpha((int) $oSubElt->getAttribute('val') / 1000);
+ }
+
+ $oShadow->setColor($oColor);
+ }
- $oSubElement = $document->getElement('a:outerShdw/a:srgbClr/a:alpha', $oElement);
- if ($oSubElement instanceof DOMElement) {
- if ($oSubElement->hasAttribute('val')) {
- $oShape->getShadow()->setAlpha((int) $oSubElement->getAttribute('val') / 1000);
+ return $oShadow;
}
}
}
- $oSlide->addShape($oShape);
+ return null;
}
- protected function loadShapeRichText(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void
+ /**
+ * @param AbstractSlide|Note $oSlide
+ */
+ protected function loadShapeRichText(XMLReader $document, DOMElement $node, $oSlide): void
{
- if (!$document->elementExists('p:txBody/a:p/a:r', $node)) {
- return;
- }
// Core
$oShape = $oSlide->createRichTextShape();
$oShape->setParagraphs([]);
@@ -898,6 +946,11 @@ protected function loadShapeRichText(XMLReader $document, DOMElement $node, Abst
$this->fileRels = $oSlide->getRelsIndex();
}
+ $oElement = $document->getElement('p:nvSpPr/p:cNvPr', $node);
+ if ($oElement instanceof DOMElement) {
+ $oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : '');
+ }
+
$oElement = $document->getElement('p:spPr/a:xfrm', $node);
if ($oElement instanceof DOMElement && $oElement->hasAttribute('rot')) {
$oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot')));
@@ -931,6 +984,34 @@ protected function loadShapeRichText(XMLReader $document, DOMElement $node, Abst
}
}
+ // Load shape effects
+ $oElement = $document->getElement('p:spPr/a:effectLst', $node);
+ if ($oElement instanceof DOMElement) {
+ $oShape->setShadow(
+ $this->loadShadow($document, $oElement)
+ );
+ }
+
+ // FBU-20210202+ Read body definitions
+ $bodyPr = $document->getElement('p:txBody/a:bodyPr', $node);
+ if ($bodyPr instanceof DOMElement) {
+ if ($bodyPr->hasAttribute('lIns')) {
+ $oShape->setInsetLeft((int) $bodyPr->getAttribute('lIns'));
+ }
+ if ($bodyPr->hasAttribute('tIns')) {
+ $oShape->setInsetTop((int) $bodyPr->getAttribute('tIns'));
+ }
+ if ($bodyPr->hasAttribute('rIns')) {
+ $oShape->setInsetRight((int) $bodyPr->getAttribute('rIns'));
+ }
+ if ($bodyPr->hasAttribute('bIns')) {
+ $oShape->setInsetBottom((int) $bodyPr->getAttribute('bIns'));
+ }
+ if ($bodyPr->hasAttribute('anchorCtr')) {
+ $oShape->setVerticalAlignCenter((int) $bodyPr->getAttribute('anchorCtr'));
+ }
+ }
+
$arrayElements = $document->getElements('p:txBody/a:p', $node);
foreach ($arrayElements as $oElement) {
if ($oElement instanceof DOMElement) {
@@ -938,6 +1019,13 @@ protected function loadShapeRichText(XMLReader $document, DOMElement $node, Abst
}
}
+ $oElement = $document->getElement('p:spPr', $node);
+ if ($oElement instanceof DOMElement) {
+ $oShape->setFill(
+ $this->loadStyleFill($document, $oElement)
+ );
+ }
+
if (count($oShape->getParagraphs()) > 0) {
$oShape->setActiveParagraph(0);
}
@@ -1117,20 +1205,20 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
$oElementLineSpacingPoints = $document->getElement('a:lnSpc/a:spcPts', $oSubElement);
if ($oElementLineSpacingPoints instanceof DOMElement) {
$oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT);
- $oParagraph->setLineSpacing($oElementLineSpacingPoints->getAttribute('val') / 100);
+ $oParagraph->setLineSpacing((int) $oElementLineSpacingPoints->getAttribute('val') / 100);
}
$oElementLineSpacingPercent = $document->getElement('a:lnSpc/a:spcPct', $oSubElement);
if ($oElementLineSpacingPercent instanceof DOMElement) {
$oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_PERCENT);
- $oParagraph->setLineSpacing($oElementLineSpacingPercent->getAttribute('val') / 1000);
+ $oParagraph->setLineSpacing((int) $oElementLineSpacingPercent->getAttribute('val') / 1000);
}
$oElementSpacingBefore = $document->getElement('a:spcBef/a:spcPts', $oSubElement);
if ($oElementSpacingBefore instanceof DOMElement) {
- $oParagraph->setSpacingBefore($oElementSpacingBefore->getAttribute('val') / 100);
+ $oParagraph->setSpacingBefore((int) $oElementSpacingBefore->getAttribute('val') / 100);
}
$oElementSpacingAfter = $document->getElement('a:spcAft/a:spcPts', $oSubElement);
if ($oElementSpacingAfter instanceof DOMElement) {
- $oParagraph->setSpacingAfter($oElementSpacingAfter->getAttribute('val') / 100);
+ $oParagraph->setSpacingAfter((int) $oElementSpacingAfter->getAttribute('val') / 100);
}
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE);
@@ -1193,14 +1281,23 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
$oText->getFont()->setItalic('true' == $att || '1' == $att ? true : false);
}
if ($oElementrPr->hasAttribute('strike')) {
- $oText->getFont()->setStrikethrough('noStrike' == $oElementrPr->getAttribute('strike') ? false : true);
+ $oText->getFont()->setStrikethrough($oElementrPr->getAttribute('strike'));
}
if ($oElementrPr->hasAttribute('sz')) {
- $oText->getFont()->setSize((int) ($oElementrPr->getAttribute('sz') / 100));
+ $oText->getFont()->setSize((int) ((int) $oElementrPr->getAttribute('sz') / 100));
}
if ($oElementrPr->hasAttribute('u')) {
$oText->getFont()->setUnderline($oElementrPr->getAttribute('u'));
}
+ if ($oElementrPr->hasAttribute('cap')) {
+ $oText->getFont()->setCapitalization($oElementrPr->getAttribute('cap'));
+ }
+ if ($oElementrPr->hasAttribute('lang')) {
+ $oText->setLanguage($oElementrPr->getAttribute('lang'));
+ }
+ if ($oElementrPr->hasAttribute('baseline')) {
+ $oText->getFont()->setBaseline((int) $oElementrPr->getAttribute('baseline'));
+ }
// Color
$oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr);
if (is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) {
@@ -1211,12 +1308,9 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
// Hyperlink
$oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr);
if (is_object($oElementHlinkClick)) {
- if ($oElementHlinkClick->hasAttribute('tooltip')) {
- $oText->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip'));
- }
- if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$this->fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target'])) {
- $oText->getHyperlink()->setUrl($this->arrayRels[$this->fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target']);
- }
+ $oText->setHyperlink(
+ $this->loadHyperlink($document, $oElementHlinkClick, $oText->getHyperlink())
+ );
}
// Font
$oElementFontFormat = null;
@@ -1238,9 +1332,22 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
if (is_object($oElementFontFormat) && $oElementFontFormat->hasAttribute('typeface')) {
$oText->getFont()->setName($oElementFontFormat->getAttribute('typeface'));
}
-
- //} else {
- // $oText = $oParagraph->createText();
+ // Font definition
+ $oElementFont = $document->getElement('a:latin', $oElementrPr);
+ if ($oElementFont instanceof DOMElement) {
+ if ($oElementFont->hasAttribute('typeface')) {
+ $oText->getFont()->setName($oElementFont->getAttribute('typeface'));
+ }
+ if ($oElementFont->hasAttribute('panose')) {
+ $oText->getFont()->setPanose($oElementFont->getAttribute('panose'));
+ }
+ if ($oElementFont->hasAttribute('pitchFamily')) {
+ $oText->getFont()->setPitchFamily((int) $oElementFont->getAttribute('pitchFamily'));
+ }
+ if ($oElementFont->hasAttribute('charset')) {
+ $oText->getFont()->setCharset((int) $oElementFont->getAttribute('charset'));
+ }
+ }
$oSubSubElement = $document->getElement('a:t', $oSubElement);
$oText->setText($oSubSubElement->nodeValue);
@@ -1249,10 +1356,27 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
}
}
+ protected function loadHyperlink(XMLReader $xmlReader, DOMElement $element, Hyperlink $hyperlink): Hyperlink
+ {
+ if ($element->hasAttribute('tooltip')) {
+ $hyperlink->setTooltip($element->getAttribute('tooltip'));
+ }
+ if ($element->hasAttribute('r:id') && isset($this->arrayRels[$this->fileRels][$element->getAttribute('r:id')]['Target'])) {
+ $hyperlink->setUrl($this->arrayRels[$this->fileRels][$element->getAttribute('r:id')]['Target']);
+ }
+ if ($subElementExt = $xmlReader->getElement('a:extLst/a:ext', $element)) {
+ if ($subElementExt->hasAttribute('uri') && $subElementExt->getAttribute('uri') == '{A12FA001-AC4F-418D-AE19-62706E023703}') {
+ $hyperlink->setIsTextColorUsed(true);
+ }
+ }
+
+ return $hyperlink;
+ }
+
protected function loadStyleBorder(XMLReader $xmlReader, DOMElement $oElement, Border $oBorder): void
{
if ($oElement->hasAttribute('w')) {
- $oBorder->setLineWidth($oElement->getAttribute('w') / 12700);
+ $oBorder->setLineWidth((int) ((int) $oElement->getAttribute('w') / 12700));
}
if ($oElement->hasAttribute('cmpd')) {
$oBorder->setLineStyle($oElement->getAttribute('cmpd'));
@@ -1280,7 +1404,7 @@ protected function loadStyleColor(XMLReader $xmlReader, DOMElement $oElement): C
$oColor->setRGB($oElement->getAttribute('val'));
$oElementAlpha = $xmlReader->getElement('a:alpha', $oElement);
if ($oElementAlpha instanceof DOMElement && $oElementAlpha->hasAttribute('val')) {
- $alpha = strtoupper(dechex((($oElementAlpha->getAttribute('val') / 1000) / 100) * 255));
+ $alpha = strtoupper(dechex((((int) $oElementAlpha->getAttribute('val') / 1000) / 100) * 255));
$oColor->setRGB($oElement->getAttribute('val'), $alpha);
}
@@ -1335,7 +1459,7 @@ protected function loadRels(string $fileRels): void
$sPart = $this->oZip->getFromName($fileRels);
if (false !== $sPart) {
$xmlReader = new XMLReader();
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
foreach ($xmlReader->getElements('*') as $oNode) {
if (!($oNode instanceof DOMElement)) {
@@ -1354,8 +1478,6 @@ protected function loadRels(string $fileRels): void
* @param AbstractSlide|Note $oSlide
* @param DOMNodeList $oElements
*
- * @throws FeatureNotImplementedException
- *
* @internal param $baseFile
*/
protected function loadSlideShapes($oSlide, DOMNodeList $oElements, XMLReader $xmlReader): void
@@ -1366,13 +1488,20 @@ protected function loadSlideShapes($oSlide, DOMNodeList $oElements, XMLReader $x
}
switch ($oNode->tagName) {
case 'p:graphicFrame':
- $this->loadShapeTable($xmlReader, $oNode, $oSlide);
+ if ($oSlide instanceof AbstractSlide) {
+ $this->loadShapeTable($xmlReader, $oNode, $oSlide);
+ }
+
break;
case 'p:pic':
- $this->loadShapeDrawing($xmlReader, $oNode, $oSlide);
+ if ($oSlide instanceof AbstractSlide) {
+ $this->loadShapeDrawing($xmlReader, $oNode, $oSlide);
+ }
+
break;
case 'p:sp':
$this->loadShapeRichText($xmlReader, $oNode, $oSlide);
+
break;
default:
//throw new FeatureNotImplementedException();
diff --git a/src/PhpPresentation/Reader/PowerPoint97.php b/src/PhpPresentation/Reader/PowerPoint97.php
index acd074ca26..4ef8fc91c2 100644
--- a/src/PhpPresentation/Reader/PowerPoint97.php
+++ b/src/PhpPresentation/Reader/PowerPoint97.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -299,97 +298,99 @@ class PowerPoint97 implements ReaderInterface
* @var array
*/
private $arrayFonts = [];
+
/**
* Array with Hyperlinks.
*
* @var array>
*/
private $arrayHyperlinks = [];
+
/**
* Array with Notes.
*
* @var array
*/
private $arrayNotes = [];
+
/**
* Array with Pictures.
*
* @var array
*/
private $arrayPictures = [];
+
/**
* Offset (in bytes) from the beginning of the PowerPoint Document Stream to the UserEditAtom record for the most recent user edit.
*
* @var int
*/
private $offsetToCurrentEdit;
+
/**
* A structure that specifies a compressed table of sequential persist object identifiers and stream offsets to associated persist objects.
*
* @var array
*/
private $rgPersistDirEntry;
+
/**
* Offset (in bytes) from the beginning of the PowerPoint Document Stream to the PersistDirectoryAtom record for this user edit.
*
* @var int
*/
private $offsetPersistDirectory;
+
/**
* Output Object.
*
* @var PhpPresentation
*/
private $oPhpPresentation;
+
/**
- * @var Group|null
+ * @var null|Group
*/
private $oCurrentGroup;
+
/**
* @var bool
*/
private $bFirstShapeGroup = false;
+
/**
* Stream "Powerpoint Document".
*
* @var string
*/
private $streamPowerpointDocument;
+
/**
* Stream "Current User".
*
* @var string
*/
private $streamCurrentUser;
- /**
- * Stream "Summary Information".
- *
- * @var string
- */
- private $streamSummaryInformation;
- /**
- * Stream "Document Summary Information".
- *
- * @var string
- */
- private $streamDocumentSummaryInformation;
+
/**
* Stream "Pictures".
*
* @var string
*/
private $streamPictures;
+
/**
* @var int
*/
private $inMainType;
+
/**
- * @var int|null
+ * @var null|int
*/
private $currentNote;
/**
- * @var string|null
+ * @var null|string
*/
private $filename;
@@ -403,8 +404,6 @@ public function canRead(string $pFilename): bool
/**
* Does a file support UnserializePhpPresentation ?
- *
- * @throws FileNotFoundException
*/
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
{
@@ -427,14 +426,12 @@ public function fileSupportsUnserializePhpPresentation(string $pFilename = ''):
/**
* Loads PhpPresentation Serialized file.
- *
- * @throws InvalidFileFormatException
*/
public function load(string $pFilename): PhpPresentation
{
// Unserialize... First make sure the file supports it!
if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
- throw new InvalidFileFormatException($pFilename, PowerPoint97::class);
+ throw new InvalidFileFormatException($pFilename, self::class);
}
$this->filename = $pFilename;
@@ -443,7 +440,7 @@ public function load(string $pFilename): PhpPresentation
}
/**
- * Load PhpPresentation Serialized file
+ * Load PhpPresentation Serialized file.
*/
private function loadFile(): PhpPresentation
{
@@ -463,7 +460,7 @@ private function loadFile(): PhpPresentation
}
/**
- * Read OLE Part
+ * Read OLE Part.
*/
private function loadOLE(): void
{
@@ -477,12 +474,6 @@ private function loadOLE(): void
// Current User Stream
$this->streamCurrentUser = $oOLE->getStream($oOLE->currentUser);
- // Get summary information data
- $this->streamSummaryInformation = $oOLE->getStream($oOLE->summaryInformation);
-
- // Get additional document summary information data
- $this->streamDocumentSummaryInformation = $oOLE->getStream($oOLE->docSummaryInfos);
-
// Get pictures data
$this->streamPictures = $oOLE->getStream($oOLE->pictures);
}
@@ -490,8 +481,6 @@ private function loadOLE(): void
/**
* Stream Pictures.
*
- * @throws FeatureNotImplementedException
- *
* @see http://msdn.microsoft.com/en-us/library/dd920746(v=office.12).aspx
*/
private function loadPicturesStream(): void
@@ -509,12 +498,11 @@ private function loadPicturesStream(): void
// OfficeArtFBSE
throw new FeatureNotImplementedException();
}
- if ($arrayRH['recType'] >= 0xF018 && $arrayRH['recType'] <= 0xF117) {
- $arrayRecord = $this->readRecordOfficeArtBlip($stream, $pos - 8);
- if ($arrayRecord['length'] > 0) {
- $pos += $arrayRecord['length'];
- $this->arrayPictures[] = $arrayRecord['picture'];
- }
+ // $arrayRH['recType'] >= 0xF018 && $arrayRH['recType'] <= 0xF117
+ $arrayRecord = $this->readRecordOfficeArtBlip($stream, $pos - 8);
+ if ($arrayRecord['length'] > 0) {
+ $pos += $arrayRecord['length'];
+ $this->arrayPictures[] = $arrayRecord['picture'];
}
$readSuccess = true;
}
@@ -524,9 +512,6 @@ private function loadPicturesStream(): void
/**
* Stream Current User.
*
- * @throws FeatureNotImplementedException
- * @throws InvalidFileFormatException
- *
* @see http://msdn.microsoft.com/en-us/library/dd908567(v=office.12).aspx
*/
private function loadCurrentUserStream(): void
@@ -540,20 +525,20 @@ private function loadCurrentUserStream(): void
$rHeader = $this->loadRecordHeader($this->streamCurrentUser, $pos);
$pos += 8;
if (0x0 != $rHeader['recVer'] || 0x000 != $rHeader['recInstance'] || self::RT_CURRENTUSERATOM != $rHeader['recType']) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : CurrentUserAtom > RecordHeader');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : CurrentUserAtom > RecordHeader');
}
// Size
$size = self::getInt4d($this->streamCurrentUser, $pos);
$pos += 4;
if (0x00000014 != $size) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : CurrentUserAtom > Size');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : CurrentUserAtom > Size');
}
// headerToken
$headerToken = self::getInt4d($this->streamCurrentUser, $pos);
$pos += 4;
- if (0xF3D1C4DF == $headerToken && 0xE391C05F != $headerToken) {
+ if (0xF3D1C4DF == $headerToken) {
// Encrypted file
throw new FeatureNotImplementedException();
}
@@ -566,28 +551,28 @@ private function loadCurrentUserStream(): void
$lenUserName = self::getInt2d($this->streamCurrentUser, $pos);
$pos += 2;
if ($lenUserName > 255) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : CurrentUserAtom > lenUserName');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : CurrentUserAtom > lenUserName');
}
// docFileVersion
$docFileVersion = self::getInt2d($this->streamCurrentUser, $pos);
$pos += 2;
if (0x03F4 != $docFileVersion) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : CurrentUserAtom > docFileVersion');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : CurrentUserAtom > docFileVersion');
}
// majorVersion
$majorVersion = self::getInt1d($this->streamCurrentUser, $pos);
++$pos;
if (0x03 != $majorVersion) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : CurrentUserAtom > majorVersion');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : CurrentUserAtom > majorVersion');
}
// minorVersion
$minorVersion = self::getInt1d($this->streamCurrentUser, $pos);
++$pos;
if (0x00 != $minorVersion) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : CurrentUserAtom > minorVersion');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : CurrentUserAtom > minorVersion');
}
// unused
@@ -609,7 +594,7 @@ private function loadCurrentUserStream(): void
$relVersion = self::getInt4d($this->streamCurrentUser, $pos);
$pos += 4;
if (0x00000008 != $relVersion && 0x00000009 != $relVersion) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : CurrentUserAtom > relVersion');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : CurrentUserAtom > relVersion');
}
// unicodeUserName
@@ -645,12 +630,15 @@ private function loadPowerpointDocumentStream(): void
switch ($rHeader['recType']) {
case self::RT_DOCUMENT:
$this->readRecordDocumentContainer($this->streamPowerpointDocument, $pos);
+
break;
case self::RT_NOTES:
$this->readRecordNotesContainer($this->streamPowerpointDocument, $pos);
+
break;
case self::RT_SLIDE:
$this->readRecordSlideContainer($this->streamPowerpointDocument, $pos);
+
break;
default:
break;
@@ -717,8 +705,6 @@ public static function getInt4d(string $data, int $pos): int
*
* @return array
*
- * @throws FeatureNotImplementedException
- *
* @see https://msdn.microsoft.com/en-us/library/dd772900(v=office.12).aspx
*/
private function readRecordAnimationInfoContainer(string $stream, int $pos): array
@@ -731,6 +717,7 @@ private function readRecordAnimationInfoContainer(string $stream, int $pos): arr
if (0xF == $data['recVer'] && 0x000 == $data['recInstance'] && self::RT_ANIMATIONINFO == $data['recType']) {
// Record Header
$arrayReturn['length'] += 8;
+
// animationAtom
// animationSound
throw new FeatureNotImplementedException();
@@ -742,9 +729,6 @@ private function readRecordAnimationInfoContainer(string $stream, int $pos): arr
/**
* A container record that specifies information about the document.
*
- * @throws FeatureNotImplementedException
- * @throws InvalidFileFormatException
- *
* @see http://msdn.microsoft.com/en-us/library/dd947357(v=office.12).aspx
*/
private function readRecordDocumentContainer(string $stream, int $pos): void
@@ -752,7 +736,7 @@ private function readRecordDocumentContainer(string $stream, int $pos): void
$documentAtom = $this->loadRecordHeader($stream, $pos);
$pos += 8;
if (0x1 != $documentAtom['recVer'] || 0x000 != $documentAtom['recInstance'] || self::RT_DOCUMENTATOM != $documentAtom['recType']) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : RTDocument > DocumentAtom');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : RTDocument > DocumentAtom');
}
$pos += $documentAtom['recLen'];
@@ -762,7 +746,7 @@ private function readRecordDocumentContainer(string $stream, int $pos): void
// exObjListAtom > rh
$exObjListAtom = $this->loadRecordHeader($stream, $pos);
if (0x0 != $exObjListAtom['recVer'] || 0x000 != $exObjListAtom['recInstance'] || self::RT_EXTERNALOBJECTLISTATOM != $exObjListAtom['recType'] || 0x00000004 != $exObjListAtom['recLen']) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : RTDocument > DocumentAtom > exObjList > exObjListAtom');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : RTDocument > DocumentAtom > exObjList > exObjListAtom');
}
$pos += 8;
// exObjListAtom > exObjIdSeed
@@ -778,8 +762,8 @@ private function readRecordDocumentContainer(string $stream, int $pos): void
//@link : http://msdn.microsoft.com/en-us/library/dd944995(v=office.12).aspx
// exHyperlinkAtom > rh
$exHyperlinkAtom = $this->loadRecordHeader($stream, $pos);
- if (0x0 != $exHyperlinkAtom['recVer'] || 0x000 != $exHyperlinkAtom['recInstance'] || self::RT_EXTERNALHYPERLINKATOM != $exHyperlinkAtom['recType'] || 0x00000004 != $exObjListAtom['recLen']) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : RTDocument > DocumentAtom > exObjList > rgChildRec > RT_ExternalHyperlink');
+ if (0x0 != $exHyperlinkAtom['recVer'] || 0x000 != $exHyperlinkAtom['recInstance'] || self::RT_EXTERNALHYPERLINKATOM != $exHyperlinkAtom['recType'] || 0x00000004 != $exHyperlinkAtom['recLen']) {
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : RTDocument > DocumentAtom > exObjList > rgChildRec > RT_ExternalHyperlink');
}
$pos += 8;
$exObjList['recLen'] -= 8;
@@ -828,6 +812,7 @@ private function readRecordDocumentContainer(string $stream, int $pos): void
$string .= chr($char);
}
}
+
break;
default:
// var_dump(dechex((int) $childRec['recType']));
@@ -856,7 +841,7 @@ private function readRecordDocumentContainer(string $stream, int $pos): void
$pos += 8;
$fontCollection['recLen'] -= 8;
if (0x0 != $fontEntityAtom['recVer'] || $fontEntityAtom['recInstance'] > 128 || self::RT_FONTENTITYATOM != $fontEntityAtom['recType']) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : RTDocument > RT_Environment > RT_FontCollection > RT_FontEntityAtom');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : RTDocument > RT_Environment > RT_FontCollection > RT_FontEntityAtom');
}
$string = '';
for ($inc = 0; $inc < 32; ++$inc) {
@@ -1198,8 +1183,6 @@ private function readRecordMouseClickInteractiveInfoContainer(string $stream, in
*
* @return array
*
- * @throws FeatureNotImplementedException
- *
* @see https://msdn.microsoft.com/en-us/library/dd925811(v=office.12).aspx
*/
private function readRecordMouseOverInteractiveInfoContainer(string $stream, int $pos): array
@@ -1212,6 +1195,7 @@ private function readRecordMouseOverInteractiveInfoContainer(string $stream, int
if (0xF == $data['recVer'] && 0x001 == $data['recInstance'] && self::RT_INTERACTIVEINFO == $data['recType']) {
// Record Header
$arrayReturn['length'] += 8;
+
// interactiveInfoAtom
// macroNameAtom
throw new FeatureNotImplementedException();
@@ -1225,8 +1209,6 @@ private function readRecordMouseOverInteractiveInfoContainer(string $stream, int
*
* @return array{'length': int, 'picture': null|string}
*
- * @throws FeatureNotImplementedException
- *
* @see https://msdn.microsoft.com/en-us/library/dd910081(v=office.12).aspx
*/
private function readRecordOfficeArtBlip(string $stream, int $pos): array
@@ -1258,6 +1240,7 @@ private function readRecordOfficeArtBlip(string $stream, int $pos): array
// BLIPFileData
$arrayReturn['picture'] = substr($this->streamPictures, $pos + $arrayReturn['length'], $data['recLen']);
$arrayReturn['length'] += $data['recLen'];
+
break;
default:
// var_dump(dechex((int) $data['recType']))
@@ -1304,8 +1287,6 @@ private function readRecordOfficeArtChildAnchor(string $stream, int $pos)
*
* @return array
*
- * @throws FeatureNotImplementedException
- *
* @see https://msdn.microsoft.com/en-us/library/dd922797(v=office.12).aspx
*/
private function readRecordOfficeArtClientAnchor(string $stream, int $pos)
@@ -1330,6 +1311,7 @@ private function readRecordOfficeArtClientAnchor(string $stream, int $pos)
$arrayReturn['height'] = (int) (self::getInt2d($stream, $pos + $arrayReturn['length']) / 6) - $arrayReturn['left'];
$arrayReturn['length'] += 2;
$pos += 8;
+
break;
case 0x00000010:
// record OfficeArtClientAnchor (0x00000010)
@@ -1343,9 +1325,7 @@ private function readRecordOfficeArtClientAnchor(string $stream, int $pos)
/**
* A container record that specifies text related data for a shape.
*
- * @return array{'length': int, 'text': string, 'numParts': int, 'numTexts': int, 'hyperlink': array>, 'part': array}
- *
- * @throws FeatureNotImplementedException
+ * @return array{'length': int, 'alignH': null|string, 'text': string, 'numParts': int, 'numTexts': int, 'hyperlink': array>, 'part': array{'length': int, 'strLenRT': int, 'partLength': float|int, 'bold': bool, 'italic': bool, 'underline': bool, 'fontName': string, 'fontSize': int, 'color': Color}}
*
* @see https://msdn.microsoft.com/en-us/library/dd910958(v=office.12).aspx
*/
@@ -1370,9 +1350,7 @@ private function readRecordOfficeArtClientTextbox(string $stream, int $pos)
$strLen = 0;
do {
$rhChild = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']);
- /*
- * @link : https://msdn.microsoft.com/en-us/library/dd947039(v=office.12).aspx
- */
+ // @link : https://msdn.microsoft.com/en-us/library/dd947039(v=office.12).aspx
// echo dechex($rhChild['recType']).'-'.$rhChild['recType'].EOL;
switch ($rhChild['recType']) {
case self::RT_INTERACTIVEINFO:
@@ -1386,6 +1364,7 @@ private function readRecordOfficeArtClientTextbox(string $stream, int $pos)
$mouseOverInfo = $this->readRecordMouseOverInteractiveInfoContainer($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += $mouseOverInfo['length'];
}
+
break;
case self::RT_STYLETEXTPROPATOM:
$arrayReturn['length'] += 8;
@@ -1411,6 +1390,7 @@ private function readRecordOfficeArtClientTextbox(string $stream, int $pos)
$strLenRT = $strucTextCFRun['strLenRT'];
$arrayReturn['length'] += $strucTextCFRun['length'];
} while ($strLenRT > 0);
+
break;
case self::RT_TEXTBYTESATOM:
$arrayReturn['length'] += 8;
@@ -1424,6 +1404,7 @@ private function readRecordOfficeArtClientTextbox(string $stream, int $pos)
$arrayReturn['text'] .= Text::chr($char);
++$arrayReturn['length'];
}
+
break;
case self::RT_TEXTCHARSATOM:
$arrayReturn['length'] += 8;
@@ -1437,12 +1418,14 @@ private function readRecordOfficeArtClientTextbox(string $stream, int $pos)
$arrayReturn['text'] .= Text::chr($char);
$arrayReturn['length'] += 2;
}
+
break;
case self::RT_TEXTHEADERATOM:
$arrayReturn['length'] += 8;
// @link : http://msdn.microsoft.com/en-us/library/dd905272(v=office.12).aspx
// textType
$arrayReturn['length'] += 4;
+
break;
case self::RT_TEXTINTERACTIVEINFOATOM:
$arrayReturn['length'] += 8;
@@ -1458,6 +1441,7 @@ private function readRecordOfficeArtClientTextbox(string $stream, int $pos)
if (0x0001 == $rhChild['recInstance']) {
throw new FeatureNotImplementedException();
}
+
break;
case self::RT_TEXTSPECIALINFOATOM:
$arrayReturn['length'] += 8;
@@ -1468,16 +1452,19 @@ private function readRecordOfficeArtClientTextbox(string $stream, int $pos)
$strLenRT = $structTextSIRun['strLenRT'];
$arrayReturn['length'] += $structTextSIRun['length'];
} while ($strLenRT > 0);
+
break;
case self::RT_TEXTRULERATOM:
$arrayReturn['length'] += 8;
// @link : http://msdn.microsoft.com/en-us/library/dd953212(v=office.12).aspx
$structRuler = $this->readStructureTextRuler($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += $structRuler['length'];
+
break;
case self::RT_SLIDENUMBERMETACHARATOM:
$datasRecord = $this->readRecordSlideNumberMCAtom($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += $datasRecord['length'];
+
break;
default:
$arrayReturn['length'] += 8;
@@ -1494,8 +1481,6 @@ private function readRecordOfficeArtClientTextbox(string $stream, int $pos)
*
* @return array{'length': int, 'shape': null|AbstractShape}
*
- * @throws InvalidFileFormatException
- *
* @see https://msdn.microsoft.com/en-us/library/dd943794(v=office.12).aspx
*/
private function readRecordOfficeArtSpContainer(string $stream, int $pos)
@@ -1516,7 +1501,7 @@ private function readRecordOfficeArtSpContainer(string $stream, int $pos)
// shapeProp
$shapeProp = $this->readRecordOfficeArtFSP($stream, $pos + $arrayReturn['length']);
if (0 == $shapeProp['length']) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class);
+ throw new InvalidFileFormatException($this->filename, self::class);
}
$arrayReturn['length'] += $shapeProp['length'];
@@ -1612,7 +1597,7 @@ private function readRecordOfficeArtSpContainer(string $stream, int $pos)
$start = 0;
$lastLevel = -1;
$lastMarginLeft = 0;
- /* @phpstan-ignore-next-line */
+ // @phpstan-ignore-next-line
for ($inc = 1; $inc <= $clientTextbox['numParts']; ++$inc) {
if ($clientTextbox['numParts'] == $clientTextbox['numTexts'] && isset($clientTextbox['text' . $inc])) {
if (isset($clientTextbox['text' . $inc]['bulletChar'])) {
@@ -1639,15 +1624,16 @@ private function readRecordOfficeArtSpContainer(string $stream, int $pos)
}
}
// Texte
- $sText = substr(isset($clientTextbox['text']) ? $clientTextbox['text'] : '', $start, $clientTextbox['part' . $inc]['partLength']);
+ $sText = substr($clientTextbox['text'] ?? '', $start, $clientTextbox['part' . $inc]['partLength']);
$sHyperlinkURL = '';
if (empty($sText)) {
// Is there a hyperlink ?
if (!empty($clientTextbox['hyperlink'])) {
foreach ($clientTextbox['hyperlink'] as $itmHyperlink) {
- if ($itmHyperlink['start'] == $start && ($itmHyperlink['end'] - $itmHyperlink['start']) == $clientTextbox['part' . $inc]['partLength']) {
+ if ($itmHyperlink['start'] == $start && ($itmHyperlink['end'] - $itmHyperlink['start']) == (float) $clientTextbox['part' . $inc]['partLength']) {
$sText = $this->arrayHyperlinks[$itmHyperlink['id']]['text'];
$sHyperlinkURL = $this->arrayHyperlinks[$itmHyperlink['id']]['url'];
+
break;
}
}
@@ -1764,8 +1750,6 @@ private function readRecordOfficeArtSpContainer(string $stream, int $pos)
*
* @return array
*
- * @throws InvalidFileFormatException
- *
* @see : https://msdn.microsoft.com/en-us/library/dd910416(v=office.12).aspx
*/
private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = false)
@@ -1781,7 +1765,7 @@ private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = fal
do {
$rhFileBlock = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']);
if (!(0xF == $rhFileBlock['recVer'] && 0x0000 == $rhFileBlock['recInstance'] && (0xF003 == $rhFileBlock['recType'] || 0xF004 == $rhFileBlock['recType']))) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class);
+ throw new InvalidFileFormatException($this->filename, self::class);
}
switch ($rhFileBlock['recType']) {
@@ -1793,6 +1777,7 @@ private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = fal
$fileBlock = $this->readRecordOfficeArtSpgrContainer($stream, $pos + $arrayReturn['length'], true);
$arrayReturn['length'] += $fileBlock['length'];
$data['recLen'] -= $fileBlock['length'];
+
break;
case 0xF004:
// Core
@@ -1805,16 +1790,17 @@ private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = fal
$data['recLen'] -= $fileBlock['length'];
// Core
//@todo
- if (!is_null($fileBlock['shape'])) {
+ if (null !== $fileBlock['shape']) {
switch ($this->inMainType) {
case self::RT_NOTES:
$arrayIdxSlide = array_flip($this->arrayNotes);
if ($this->currentNote > 0 && isset($arrayIdxSlide[$this->currentNote])) {
$oSlide = $this->oPhpPresentation->getSlide($arrayIdxSlide[$this->currentNote]);
- if (0 == $oSlide->getNote()->getShapeCollection()->count()) {
+ if (0 == count($oSlide->getNote()->getShapeCollection())) {
$oSlide->getNote()->addShape($fileBlock['shape']);
}
}
+
break;
case self::RT_SLIDE:
if ($bInGroup) {
@@ -1822,6 +1808,7 @@ private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = fal
} else {
$this->oPhpPresentation->getActiveSlide()->addShape($fileBlock['shape']);
}
+
break;
}
}
@@ -1839,8 +1826,6 @@ private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = fal
*
* @return array
*
- * @throws FeatureNotImplementedException
- *
* @see https://msdn.microsoft.com/en-us/library/dd950206(v=office.12).aspx
*/
private function readRecordOfficeArtTertiaryFOPT(string $stream, int $pos)
@@ -1880,6 +1865,7 @@ private function readRecordOfficeArtTertiaryFOPT(string $stream, int $pos)
if (0x1 == $opt['fComplex']) {
$arrayReturn['length'] += $opt['op'];
}
+
break;
case 0x03A9:
// GroupShape : metroBlob
@@ -1887,6 +1873,7 @@ private function readRecordOfficeArtTertiaryFOPT(string $stream, int $pos)
if (0x1 == $opt['fComplex']) {
$arrayReturn['length'] += $opt['op'];
}
+
break;
case 0x01FF:
// Line Style Boolean
@@ -1968,7 +1955,7 @@ private function readRecordOfficeArtFDG(string $stream, int $pos): array
/**
* The OfficeArtFOPT record specifies a table of OfficeArtRGFOPTE records.
*
- * @return array
+ * @return array
*
* @see https://msdn.microsoft.com/en-us/library/dd943404(v=office.12).aspx
*/
@@ -2007,6 +1994,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
// Transform : rotation
//@link : https://msdn.microsoft.com/en-us/library/dd949750(v=office.12).aspx
$arrayReturn['rotation'] = $opt['op'];
+
break;
case 0x007F:
// Transform : Protection Boolean Properties
@@ -2020,21 +2008,25 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
// Text : dxTextLeft
//@link : http://msdn.microsoft.com/en-us/library/dd953234(v=office.12).aspx
$arrayReturn['insetLeft'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']);
+
break;
case 0x0082:
// Text : dyTextTop
//@link : http://msdn.microsoft.com/en-us/library/dd925068(v=office.12).aspx
$arrayReturn['insetTop'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']);
+
break;
case 0x0083:
// Text : dxTextRight
//@link : http://msdn.microsoft.com/en-us/library/dd906782(v=office.12).aspx
$arrayReturn['insetRight'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']);
+
break;
case 0x0084:
// Text : dyTextBottom
//@link : http://msdn.microsoft.com/en-us/library/dd772858(v=office.12).aspx
$arrayReturn['insetBottom'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']);
+
break;
case 0x0085:
// Text : WrapText
@@ -2054,9 +2046,9 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
if (0 == $opt['fComplex']) {
$arrayReturn['pib'] = $opt['op'];
$data['recLen'] -= $opt['op'];
- } else {
- // pib Complex
}
+ // pib Complex
+
break;
case 0x13F:
// Blip Boolean Properties
@@ -2086,6 +2078,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
// Geometry : shapePath
//@link : http://msdn.microsoft.com/en-us/library/dd945249(v=office.12).aspx
$arrayReturn['line'] = true;
+
break;
case 0x145:
// Geometry : pVertices
@@ -2094,6 +2087,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
$arrayReturn['length'] += $opt['op'];
$data['recLen'] -= $opt['op'];
}
+
break;
case 0x146:
// Geometry : pSegmentInfo
@@ -2102,6 +2096,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
$arrayReturn['length'] += $opt['op'];
$data['recLen'] -= $opt['op'];
}
+
break;
case 0x155:
// Geometry : pAdjustHandles
@@ -2110,6 +2105,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
$arrayReturn['length'] += $opt['op'];
$data['recLen'] -= $opt['op'];
}
+
break;
case 0x156:
// Geometry : pGuides
@@ -2118,6 +2114,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
$arrayReturn['length'] += $opt['op'];
$data['recLen'] -= $opt['op'];
}
+
break;
case 0x157:
// Geometry : pInscribe
@@ -2126,6 +2123,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
$arrayReturn['length'] += $opt['op'];
$data['recLen'] -= $opt['op'];
}
+
break;
case 0x17F:
// Geometry Boolean Properties
@@ -2141,6 +2139,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
$strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
+
// echo 'fillColor : '.$strColor.EOL;
break;
case 0x0183:
@@ -2149,6 +2148,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
$strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
+
// echo 'fillBackColor : '.$strColor.EOL;
break;
case 0x0193:
@@ -2172,6 +2172,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
$strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
$arrayReturn['lineColor'] = $strColor;
+
break;
case 0x01C1:
// Line Style : lineOpacity
@@ -2186,6 +2187,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
// Line Style : lineWidth
//@link : http://msdn.microsoft.com/en-us/library/dd926964(v=office.12).aspx
$arrayReturn['lineWidth'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']);
+
break;
case 0x01D6:
// Line Style : lineJoinStyle
@@ -2211,11 +2213,13 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
// Shadow Style : shadowOffsetX
//@link : http://msdn.microsoft.com/en-us/library/dd945280(v=office.12).aspx
$arrayReturn['shadowOffsetX'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']);
+
break;
case 0x0206:
// Shadow Style : shadowOffsetY
//@link : http://msdn.microsoft.com/en-us/library/dd907855(v=office.12).aspx
$arrayReturn['shadowOffsetY'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']);
+
break;
case 0x023F:
// Shadow Style : Shadow Style Boolean Properties
@@ -2236,6 +2240,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array
$arrayReturn['length'] += $opt['op'];
$data['recLen'] -= $opt['op'];
}
+
break;
case 0x03BF:
// Group Shape Property Set : Group Shape Boolean Properties
@@ -2362,8 +2367,6 @@ private function readRecordOfficeArtSecondaryFOPT(string $stream, int $pos): arr
*
* @return array
*
- * @throws FeatureNotImplementedException
- *
* @see : https://msdn.microsoft.com/en-us/library/dd950927(v=office.12).aspx
*/
private function readRecordOfficeArtClientData(string $stream, int $pos): array
@@ -2422,14 +2425,17 @@ private function readRecordOfficeArtClientData(string $stream, int $pos): array
case self::RT_PROGTAGS:
$dataRG = $this->readRecordShapeProgTagsContainer($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += $dataRG['length'];
+
break;
case self::RT_ROUNDTRIPHFPLACEHOLDER12ATOM:
$dataRG = $this->readRecordRoundTripHFPlaceholder12Atom($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += $dataRG['length'];
+
break;
case self::RT_ROUNDTRIPSHAPEID12ATOM:
$dataRG = $this->readRecordRoundTripShapeId12Atom($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += $dataRG['length'];
+
break;
default:
// var_dump('0x' . dechex($dataHeaderRG['recType']));
@@ -2446,15 +2452,13 @@ private function readRecordOfficeArtClientData(string $stream, int $pos): array
* An atom record that specifies a persist object directory. Each persist object identifier specified MUST be unique in that persist object directory.
*
* @see http://msdn.microsoft.com/en-us/library/dd952680(v=office.12).aspx
- *
- * @throws InvalidFileFormatException
*/
private function readRecordPersistDirectoryAtom(string $stream, int $pos): void
{
$rHeader = $this->loadRecordHeader($stream, $pos);
$pos += 8;
if (0x0 != $rHeader['recVer'] || 0x000 != $rHeader['recInstance'] || self::RT_PERSISTDIRECTORYATOM != $rHeader['recType']) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : PersistDirectoryAtom > RecordHeader');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : PersistDirectoryAtom > RecordHeader');
}
// rgPersistDirEntry
// @link : http://msdn.microsoft.com/en-us/library/dd947347(v=office.12).aspx
@@ -2696,8 +2700,6 @@ private function readRecordShapeProgBinaryTagContainer(string $stream, int $pos)
*
* @return array
*
- * @throws FeatureNotImplementedException
- *
* @see https://msdn.microsoft.com/en-us/library/dd911266(v=office.12).aspx
*/
private function readRecordShapeProgTagsContainer(string $stream, int $pos): array
@@ -2718,8 +2720,9 @@ private function readRecordShapeProgTagsContainer(string $stream, int $pos): arr
case self::RT_PROGBINARYTAG:
$dataRG = $this->readRecordShapeProgBinaryTagContainer($stream, $pos + $arrayReturn['length'] + $length);
$length += $dataRG['length'];
+
break;
- //case self::RT_PROGSTRINGTAG:
+ //case self::RT_PROGSTRINGTAG:
default:
// var_dump('0x' . dechex($dataHeaderRG['recType']));
throw new FeatureNotImplementedException();
@@ -2774,8 +2777,6 @@ private function readRecordSlideAtom(string $stream, int $pos): array
/**
* A container record that specifies a presentation slide or title master slide.
*
- * @throws InvalidFileFormatException
- *
* @see http://msdn.microsoft.com/en-us/library/dd946323(v=office.12).aspx
*/
private function readRecordSlideContainer(string $stream, int $pos): void
@@ -2787,7 +2788,7 @@ private function readRecordSlideContainer(string $stream, int $pos): void
// *** slideAtom (32 bytes)
$slideAtom = $this->readRecordSlideAtom($stream, $pos);
if (0 == $slideAtom['length']) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class);
+ throw new InvalidFileFormatException($this->filename, self::class);
}
$pos += $slideAtom['length'];
@@ -2811,7 +2812,7 @@ private function readRecordSlideContainer(string $stream, int $pos): void
$slideSchemeColorAtom = $this->readRecordSlideSchemeColorSchemeAtom($stream, $pos);
if (0 == $slideSchemeColorAtom['length']) {
// Record SlideSchemeColorSchemeAtom
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class);
+ throw new InvalidFileFormatException($this->filename, self::class);
}
$pos += $slideSchemeColorAtom['length'];
@@ -2964,15 +2965,13 @@ private function readRecordSlideShowSlideInfoAtom(string $stream, int $pos): arr
* UserEditAtom.
*
* @see http://msdn.microsoft.com/en-us/library/dd945746(v=office.12).aspx
- *
- * @throws InvalidFileFormatException
*/
private function readRecordUserEditAtom(string $stream, int $pos): void
{
$rHeader = $this->loadRecordHeader($stream, $pos);
$pos += 8;
if (0x0 != $rHeader['recVer'] || 0x000 != $rHeader['recInstance'] || self::RT_USEREDITATOM != $rHeader['recType'] || (0x0000001C != $rHeader['recLen'] && 0x00000020 != $rHeader['recLen'])) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : UserEditAtom > RecordHeader');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : UserEditAtom > RecordHeader');
}
// lastSlideIdRef
@@ -2984,14 +2983,14 @@ private function readRecordUserEditAtom(string $stream, int $pos): void
$minorVersion = self::getInt1d($stream, $pos);
++$pos;
if (0x00 != $minorVersion) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : UserEditAtom > minorVersion');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : UserEditAtom > minorVersion');
}
// majorVersion
$majorVersion = self::getInt1d($stream, $pos);
++$pos;
if (0x03 != $majorVersion) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : UserEditAtom > majorVersion');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : UserEditAtom > majorVersion');
}
// offsetLastEdit
@@ -3004,7 +3003,7 @@ private function readRecordUserEditAtom(string $stream, int $pos): void
$docPersistIdRef = self::getInt4d($stream, $pos);
$pos += 4;
if (0x00000001 != $docPersistIdRef) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : UserEditAtom > docPersistIdRef');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : UserEditAtom > docPersistIdRef');
}
// persistIdSeed
@@ -3020,8 +3019,6 @@ private function readRecordUserEditAtom(string $stream, int $pos): void
*
* @return array{'length': int, 'strLenRT': int, 'partLength': int, 'bold': bool, 'italic': bool, 'underline': bool, 'fontName': string, 'fontSize': int, 'color': Color}
*
- * @throws FeatureNotImplementedException
- *
* @see https://msdn.microsoft.com/en-us/library/dd945870(v=office.12).aspx
*/
private function readStructureTextCFRun(string $stream, int $pos, int $strLenRT): array
@@ -3089,7 +3086,7 @@ private function readStructureTextCFRun(string $stream, int $pos, int $strLenRT)
if (1 == $masksData['typeface']) {
$data = self::getInt2d($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 2;
- $arrayReturn['fontName'] = isset($this->arrayFonts[$data]) ? $this->arrayFonts[$data] : '';
+ $arrayReturn['fontName'] = $this->arrayFonts[$data] ?? '';
}
if (1 == $masksData['oldEATypeface']) {
// $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
@@ -3135,9 +3132,7 @@ private function readStructureTextCFRun(string $stream, int $pos, int $strLenRT)
/**
* A structure that specifies the paragraph-level formatting of a run of text.
*
- * @return array{'length': int, 'strLenRT': int, 'alignH': string, 'bulletChar': string, 'leftMargin': int, 'indent': int}
- *
- * @throws FeatureNotImplementedException
+ * @return array{'length': int, 'strLenRT': int, 'alignH': null|string, 'bulletChar': string, 'leftMargin': int, 'indent': int}
*
* @see https://msdn.microsoft.com/en-us/library/dd923535(v=office.12).aspx
*/
@@ -3232,24 +3227,31 @@ private function readStructureTextPFRun(string $stream, int $pos, int $strLenRT)
switch ($data) {
case 0x0000:
$arrayReturn['alignH'] = Alignment::HORIZONTAL_LEFT;
+
break;
case 0x0001:
$arrayReturn['alignH'] = Alignment::HORIZONTAL_CENTER;
+
break;
case 0x0002:
$arrayReturn['alignH'] = Alignment::HORIZONTAL_RIGHT;
+
break;
case 0x0003:
$arrayReturn['alignH'] = Alignment::HORIZONTAL_JUSTIFY;
+
break;
case 0x0004:
$arrayReturn['alignH'] = Alignment::HORIZONTAL_DISTRIBUTED;
+
break;
case 0x0005:
$arrayReturn['alignH'] = Alignment::HORIZONTAL_DISTRIBUTED;
+
break;
case 0x0006:
$arrayReturn['alignH'] = Alignment::HORIZONTAL_JUSTIFY;
+
break;
default:
break;
@@ -3304,8 +3306,6 @@ private function readStructureTextPFRun(string $stream, int $pos, int $strLenRT)
*
* @return array
*
- * @throws FeatureNotImplementedException
- *
* @see https://msdn.microsoft.com/en-us/library/dd909603(v=office.12).aspx
*/
private function readStructureTextSIRun(string $stream, int $pos, int $strLenRT): array
@@ -3366,8 +3366,6 @@ private function readStructureTextSIRun(string $stream, int $pos, int $strLenRT)
*
* @return array
*
- * @throws FeatureNotImplementedException
- *
* @see https://msdn.microsoft.com/en-us/library/dd922749(v=office.12).aspx
*/
private function readStructureTextRuler(string $stream, int $pos): array
@@ -3477,8 +3475,6 @@ private function readRecordNotesContainer(string $stream, int $pos): void
/**
* @return array
- *
- * @throws InvalidFileFormatException
*/
private function readRecordNotesAtom(string $stream, int $pos): array
{
@@ -3488,7 +3484,7 @@ private function readRecordNotesAtom(string $stream, int $pos): array
$data = $this->loadRecordHeader($stream, $pos);
if (0x1 != $data['recVer'] || 0x000 != $data['recInstance'] || self::RT_NOTESATOM != $data['recType'] || 0x00000008 != $data['recLen']) {
- throw new InvalidFileFormatException($this->filename, PowerPoint97::class, 'Location : NotesAtom > RecordHeader)');
+ throw new InvalidFileFormatException($this->filename, self::class, 'Location : NotesAtom > RecordHeader)');
}
// Record Header
$arrayReturn['length'] += 8;
diff --git a/src/PhpPresentation/Reader/ReaderInterface.php b/src/PhpPresentation/Reader/ReaderInterface.php
index d3e06d393c..e6a4c3ad5e 100644
--- a/src/PhpPresentation/Reader/ReaderInterface.php
+++ b/src/PhpPresentation/Reader/ReaderInterface.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Reader/Serialized.php b/src/PhpPresentation/Reader/Serialized.php
index 33de31b412..df58d95511 100644
--- a/src/PhpPresentation/Reader/Serialized.php
+++ b/src/PhpPresentation/Reader/Serialized.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -43,8 +42,6 @@ public function canRead(string $pFilename): bool
/**
* Does a file support UnserializePhpPresentation ?
- *
- * @throws FileNotFoundException
*/
public function fileSupportsUnserializePhpPresentation(string $pFilename): bool
{
@@ -59,9 +56,6 @@ public function fileSupportsUnserializePhpPresentation(string $pFilename): bool
/**
* Loads PhpPresentation Serialized file.
- *
- * @throws FileNotFoundException
- * @throws InvalidFileFormatException
*/
public function load(string $pFilename): PhpPresentation
{
@@ -72,7 +66,7 @@ public function load(string $pFilename): PhpPresentation
// Unserialize... First make sure the file supports it!
if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
- throw new InvalidFileFormatException($pFilename, Serialized::class);
+ throw new InvalidFileFormatException($pFilename, self::class);
}
return $this->loadSerialized($pFilename);
@@ -80,19 +74,17 @@ public function load(string $pFilename): PhpPresentation
/**
* Load PhpPresentation Serialized file.
- *
- * @throws InvalidFileFormatException
*/
private function loadSerialized(string $pFilename): PhpPresentation
{
$oArchive = new ZipArchive();
if (true !== $oArchive->open($pFilename)) {
- throw new InvalidFileFormatException($pFilename, Serialized::class);
+ throw new InvalidFileFormatException($pFilename, self::class);
}
$xmlContent = $oArchive->getFromName('PhpPresentation.xml');
if (empty($xmlContent)) {
- throw new InvalidFileFormatException($pFilename, Serialized::class, 'The file PhpPresentation.xml is malformed');
+ throw new InvalidFileFormatException($pFilename, self::class, 'The file PhpPresentation.xml is malformed');
}
$xmlData = simplexml_load_string($xmlContent);
@@ -100,14 +92,13 @@ private function loadSerialized(string $pFilename): PhpPresentation
// Update media links
for ($i = 0; $i < $file->getSlideCount(); ++$i) {
- for ($j = 0; $j < $file->getSlide($i)->getShapeCollection()->count(); ++$j) {
- if ($file->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawingAdapter) {
- $imgTemp = $file->getSlide($i)->getShapeCollection()->offsetGet($j);
- $imgPath = 'zip://' . $pFilename . '#media/' . $imgTemp->getImageIndex() . '/' . pathinfo($imgTemp->getPath(), PATHINFO_BASENAME);
- if ($imgTemp instanceof DrawingFile) {
- $imgTemp->setPath($imgPath, false);
+ foreach ($file->getSlide($i)->getShapeCollection() as $shape) {
+ if ($shape instanceof AbstractDrawingAdapter) {
+ $imgPath = 'zip://' . $pFilename . '#media/' . $shape->getImageIndex() . '/' . pathinfo($shape->getPath(), PATHINFO_BASENAME);
+ if ($shape instanceof DrawingFile) {
+ $shape->setPath($imgPath, false);
} else {
- $imgTemp->setPath($imgPath);
+ $shape->setPath($imgPath);
}
}
}
diff --git a/src/PhpPresentation/Shape/AbstractGraphic.php b/src/PhpPresentation/Shape/AbstractGraphic.php
index e7a4e731d7..064e32a9eb 100644
--- a/src/PhpPresentation/Shape/AbstractGraphic.php
+++ b/src/PhpPresentation/Shape/AbstractGraphic.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -42,13 +41,6 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
*/
private $imageIndex = 0;
- /**
- * Name.
- *
- * @var string
- */
- protected $name;
-
/**
* Description.
*
@@ -68,7 +60,7 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
*
* @var string
*/
- public $relationId = null;
+ public $relationId;
/**
* Create a new \PhpOffice\PhpPresentation\Slide\AbstractDrawing.
@@ -106,30 +98,6 @@ public function getImageIndex()
return $this->imageIndex;
}
- /**
- * Get Name.
- *
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Set Name.
- *
- * @param string $pValue
- *
- * @return $this
- */
- public function setName($pValue = '')
- {
- $this->name = $pValue;
-
- return $this;
- }
-
/**
* Get Description.
*
diff --git a/src/PhpPresentation/Shape/AutoShape.php b/src/PhpPresentation/Shape/AutoShape.php
index 3d2c21ca59..fc52bad918 100644
--- a/src/PhpPresentation/Shape/AutoShape.php
+++ b/src/PhpPresentation/Shape/AutoShape.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,7 +24,7 @@
use PhpOffice\PhpPresentation\Style\Outline;
/**
- * AutoShape shape
+ * AutoShape shape.
*
* @see : https://github.com/scanny/python-pptx/blob/eaa1e0fd3db28b03a353e116a5c7d2084dd87c26/pptx/enum/shapes.py
*/
@@ -238,19 +237,11 @@ public function __construct()
$this->outline = new Outline();
}
- /**
- * @return string
- */
public function getText(): string
{
return $this->text;
}
- /**
- * @param string $text
- *
- * @return self
- */
public function setText(string $text): self
{
$this->text = $text;
@@ -258,19 +249,11 @@ public function setText(string $text): self
return $this;
}
- /**
- * @return string
- */
public function getType(): string
{
return $this->type;
}
- /**
- * @param string $type
- *
- * @return self
- */
public function setType(string $type): self
{
$this->type = $type;
@@ -278,19 +261,11 @@ public function setType(string $type): self
return $this;
}
- /**
- * @return Outline
- */
public function getOutline(): Outline
{
return $this->outline;
}
- /**
- * @param Outline $outline
- *
- * @return self
- */
public function setOutline(Outline $outline): self
{
$this->outline = $outline;
diff --git a/src/PhpPresentation/Shape/Chart.php b/src/PhpPresentation/Shape/Chart.php
index 3d56b7378e..35aa3d17ad 100644
--- a/src/PhpPresentation/Shape/Chart.php
+++ b/src/PhpPresentation/Shape/Chart.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -103,9 +102,7 @@ public function __clone()
}
/**
- * How missing/blank values are displayed on chart (dispBlanksAs property)
- *
- * @return string
+ * How missing/blank values are displayed on chart (dispBlanksAs property).
*/
public function getDisplayBlankAs(): string
{
@@ -114,8 +111,6 @@ public function getDisplayBlankAs(): string
/**
* Get Title.
- *
- * @return Title
*/
public function getTitle(): Title
{
@@ -124,8 +119,6 @@ public function getTitle(): Title
/**
* Get Legend.
- *
- * @return Legend
*/
public function getLegend(): Legend
{
@@ -134,8 +127,6 @@ public function getLegend(): Legend
/**
* Get PlotArea.
- *
- * @return PlotArea
*/
public function getPlotArea(): PlotArea
{
@@ -144,8 +135,6 @@ public function getPlotArea(): PlotArea
/**
* Get View3D.
- *
- * @return View3D
*/
public function getView3D(): View3D
{
@@ -154,8 +143,6 @@ public function getView3D(): View3D
/**
* Is the spreadsheet included for editing data ?
- *
- * @return bool
*/
public function hasIncludedSpreadsheet(): bool
{
@@ -163,11 +150,7 @@ public function hasIncludedSpreadsheet(): bool
}
/**
- * Define a way to display missing/blank values (dispBlanksAs property)
- *
- * @param string $value
- *
- * @return self
+ * Define a way to display missing/blank values (dispBlanksAs property).
*/
public function setDisplayBlankAs(string $value): self
{
@@ -180,10 +163,6 @@ public function setDisplayBlankAs(string $value): self
/**
* Is the spreadsheet included for editing data ?
- *
- * @param bool $value
- *
- * @return self
*/
public function setIncludeSpreadsheet(bool $value = false): self
{
@@ -194,8 +173,6 @@ public function setIncludeSpreadsheet(bool $value = false): self
/**
* Get indexed filename (using image index).
- *
- * @return string
*/
public function getIndexedFilename(): string
{
diff --git a/src/PhpPresentation/Shape/Chart/Axis.php b/src/PhpPresentation/Shape/Chart/Axis.php
index e82a85eb09..8576a0cffd 100644
--- a/src/PhpPresentation/Shape/Chart/Axis.php
+++ b/src/PhpPresentation/Shape/Chart/Axis.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -38,6 +37,12 @@ class Axis implements ComparableInterface
public const TICK_LABEL_POSITION_HIGH = 'high';
public const TICK_LABEL_POSITION_LOW = 'low';
+ public const CROSSES_AUTO = 'autoZero';
+ public const CROSSES_MIN = 'min';
+ public const CROSSES_MAX = 'max';
+
+ public const DEFAULT_FORMAT_CODE = 'general';
+
/**
* Title.
*
@@ -51,11 +56,11 @@ class Axis implements ComparableInterface
private $titleRotation = 0;
/**
- * Format code
+ * Format code.
*
* @var string
*/
- private $formatCode = '';
+ private $formatCode = self::DEFAULT_FORMAT_CODE;
/**
* Font.
@@ -65,12 +70,19 @@ class Axis implements ComparableInterface
private $font;
/**
- * @var Gridlines|null
+ * Tick lable font.
+ *
+ * @var Font
+ */
+ protected $tickLabelFont;
+
+ /**
+ * @var null|Gridlines
*/
protected $majorGridlines;
/**
- * @var Gridlines|null
+ * @var null|Gridlines
*/
protected $minorGridlines;
@@ -84,6 +96,16 @@ class Axis implements ComparableInterface
*/
protected $maxBounds;
+ /**
+ * @var string
+ */
+ protected $crossesAt = self::CROSSES_AUTO;
+
+ /**
+ * @var bool
+ */
+ protected $isReversedOrder = false;
+
/**
* @var string
*/
@@ -129,12 +151,11 @@ public function __construct(string $title = 'Axis Title')
$this->title = $title;
$this->outline = new Outline();
$this->font = new Font();
+ $this->tickLabelFont = new Font();
}
/**
* Get Title.
- *
- * @return string
*/
public function getTitle(): string
{
@@ -143,10 +164,6 @@ public function getTitle(): string
/**
* Set Title.
- *
- * @param string $value
- *
- * @return self
*/
public function setTitle(string $value = 'Axis Title'): self
{
@@ -157,22 +174,34 @@ public function setTitle(string $value = 'Axis Title'): self
/**
* Get font.
- *
- * @return Font|null
*/
public function getFont(): ?Font
{
return $this->font;
}
+ /**
+ * Set tick label font.
+ */
+ public function setTickLabelFont(?Font $font = null): self
+ {
+ $this->tickLabelFont = $font;
+
+ return $this;
+ }
+
+ /**
+ * Get tick label font.
+ */
+ public function getTickLabelFont(): ?Font
+ {
+ return $this->tickLabelFont;
+ }
+
/**
* Set font.
- *
- * @param Font|null $font
- *
- * @return self
*/
- public function setFont(Font $font = null): self
+ public function setFont(?Font $font = null): self
{
$this->font = $font;
@@ -181,8 +210,6 @@ public function setFont(Font $font = null): self
/**
* Get Format Code.
- *
- * @return string
*/
public function getFormatCode(): string
{
@@ -191,54 +218,58 @@ public function getFormatCode(): string
/**
* Set Format Code.
- *
- * @param string $value
- *
- * @return self
*/
- public function setFormatCode(string $value = ''): self
+ public function setFormatCode(string $value = self::DEFAULT_FORMAT_CODE): self
{
$this->formatCode = $value;
return $this;
}
- /**
- * @return int|null
- */
public function getMinBounds(): ?int
{
return $this->minBounds;
}
- /**
- * @param int|null $minBounds
- *
- * @return self
- */
- public function setMinBounds(int $minBounds = null): self
+ public function setMinBounds(?int $minBounds = null): self
{
- $this->minBounds = is_null($minBounds) ? null : $minBounds;
+ $this->minBounds = null === $minBounds ? null : $minBounds;
return $this;
}
- /**
- * @return int|null
- */
public function getMaxBounds(): ?int
{
return $this->maxBounds;
}
- /**
- * @param int|null $maxBounds
- *
- * @return self
- */
- public function setMaxBounds(int $maxBounds = null): self
+ public function setMaxBounds(?int $maxBounds = null): self
+ {
+ $this->maxBounds = null === $maxBounds ? null : $maxBounds;
+
+ return $this;
+ }
+
+ public function getCrossesAt(): string
+ {
+ return $this->crossesAt;
+ }
+
+ public function setCrossesAt(string $value = self::CROSSES_AUTO): self
+ {
+ $this->crossesAt = $value;
+
+ return $this;
+ }
+
+ public function isReversedOrder(): bool
{
- $this->maxBounds = is_null($maxBounds) ? null : $maxBounds;
+ return $this->isReversedOrder;
+ }
+
+ public function setIsReversedOrder(bool $value = false): self
+ {
+ $this->isReversedOrder = $value;
return $this;
}
@@ -267,19 +298,11 @@ public function setMinorGridlines(Gridlines $minorGridlines): self
return $this;
}
- /**
- * @return string
- */
public function getMinorTickMark(): string
{
return $this->minorTickMark;
}
- /**
- * @param string $tickMark
- *
- * @return self
- */
public function setMinorTickMark(string $tickMark = self::TICK_MARK_NONE): self
{
$this->minorTickMark = $tickMark;
@@ -287,19 +310,11 @@ public function setMinorTickMark(string $tickMark = self::TICK_MARK_NONE): self
return $this;
}
- /**
- * @return string
- */
public function getMajorTickMark(): string
{
return $this->majorTickMark;
}
- /**
- * @param string $tickMark
- *
- * @return self
- */
public function setMajorTickMark(string $tickMark = self::TICK_MARK_NONE): self
{
$this->majorTickMark = $tickMark;
@@ -307,18 +322,13 @@ public function setMajorTickMark(string $tickMark = self::TICK_MARK_NONE): self
return $this;
}
- /**
- * @return float|null
- */
public function getMinorUnit(): ?float
{
return $this->minorUnit;
}
/**
- * @param float|null $unit
- *
- * @return self
+ * @param null|float $unit
*/
public function setMinorUnit($unit = null): self
{
@@ -327,39 +337,23 @@ public function setMinorUnit($unit = null): self
return $this;
}
- /**
- * @return float|null
- */
public function getMajorUnit(): ?float
{
return $this->majorUnit;
}
- /**
- * @param float|null $unit
- *
- * @return self
- */
- public function setMajorUnit(float $unit = null): self
+ public function setMajorUnit(?float $unit = null): self
{
$this->majorUnit = $unit;
return $this;
}
- /**
- * @return Outline
- */
public function getOutline(): Outline
{
return $this->outline;
}
- /**
- * @param Outline $outline
- *
- * @return self
- */
public function setOutline(Outline $outline): self
{
$this->outline = $outline;
@@ -367,19 +361,11 @@ public function setOutline(Outline $outline): self
return $this;
}
- /**
- * @return int
- */
public function getTitleRotation(): int
{
return $this->titleRotation;
}
- /**
- * @param int $titleRotation
- *
- * @return self
- */
public function setTitleRotation(int $titleRotation): self
{
if ($titleRotation < 0) {
@@ -394,7 +380,7 @@ public function setTitleRotation(int $titleRotation): self
}
/**
- * Get hash code
+ * Get hash code.
*
* @return string Hash code
*/
@@ -416,7 +402,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
@@ -442,8 +428,6 @@ public function setHashIndex(int $value)
/**
* Axis is hidden ?
- *
- * @return bool
*/
public function isVisible(): bool
{
@@ -454,8 +438,6 @@ public function isVisible(): bool
* Hide an axis.
*
* @param bool $value delete
- *
- * @return self
*/
public function setIsVisible(bool $value): self
{
@@ -464,19 +446,11 @@ public function setIsVisible(bool $value): self
return $this;
}
- /**
- * @return string
- */
public function getTickLabelPosition(): string
{
return $this->tickLabelPosition;
}
- /**
- * @param string $value
- *
- * @return self
- */
public function setTickLabelPosition(string $value = self::TICK_LABEL_POSITION_NEXT_TO): self
{
if (in_array($value, [
diff --git a/src/PhpPresentation/Shape/Chart/Gridlines.php b/src/PhpPresentation/Shape/Chart/Gridlines.php
index 83f1248865..e1b78e6922 100644
--- a/src/PhpPresentation/Shape/Chart/Gridlines.php
+++ b/src/PhpPresentation/Shape/Chart/Gridlines.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Chart/Legend.php b/src/PhpPresentation/Shape/Chart/Legend.php
index 6878f62a8f..2d31708fc0 100644
--- a/src/PhpPresentation/Shape/Chart/Legend.php
+++ b/src/PhpPresentation/Shape/Chart/Legend.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -83,28 +82,28 @@ class Legend implements ComparableInterface
/**
* Font.
*
- * @var Font|null
+ * @var null|Font
*/
private $font;
/**
* Border.
*
- * @var \PhpOffice\PhpPresentation\Style\Border
+ * @var Border
*/
private $border;
/**
* Fill.
*
- * @var \PhpOffice\PhpPresentation\Style\Fill
+ * @var Fill
*/
private $fill;
/**
* Alignment.
*
- * @var \PhpOffice\PhpPresentation\Style\Alignment
+ * @var Alignment
*/
private $alignment;
@@ -134,7 +133,7 @@ public function isVisible()
*
* @param bool $value
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
+ * @return Legend
*/
public function setVisible($value = true)
{
@@ -158,7 +157,7 @@ public function getPosition()
*
* @param string $value
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
+ * @return Legend
*/
public function setPosition($value = self::POSITION_RIGHT)
{
@@ -250,9 +249,9 @@ public function getFont(): ?Font
/**
* Set font.
*
- * @param Font|null $pFont Font
+ * @param null|Font $pFont Font
*/
- public function setFont(Font $pFont = null): self
+ public function setFont(?Font $pFont = null): self
{
$this->font = $pFont;
@@ -262,7 +261,7 @@ public function setFont(Font $pFont = null): self
/**
* Get Border.
*
- * @return \PhpOffice\PhpPresentation\Style\Border
+ * @return Border
*/
public function getBorder()
{
@@ -272,7 +271,7 @@ public function getBorder()
/**
* Set Border.
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
+ * @return Legend
*/
public function setBorder(Border $border)
{
@@ -284,7 +283,7 @@ public function setBorder(Border $border)
/**
* Get Fill.
*
- * @return \PhpOffice\PhpPresentation\Style\Fill
+ * @return Fill
*/
public function getFill()
{
@@ -294,7 +293,7 @@ public function getFill()
/**
* Set Fill.
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
+ * @return Legend
*/
public function setFill(Fill $fill)
{
@@ -306,7 +305,7 @@ public function setFill(Fill $fill)
/**
* Get alignment.
*
- * @return \PhpOffice\PhpPresentation\Style\Alignment
+ * @return Alignment
*/
public function getAlignment()
{
@@ -316,7 +315,7 @@ public function getAlignment()
/**
* Set alignment.
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Legend
+ * @return Legend
*/
public function setAlignment(Alignment $alignment)
{
@@ -348,7 +347,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Shape/Chart/Marker.php b/src/PhpPresentation/Shape/Chart/Marker.php
index 008f787b3b..74d41d6550 100644
--- a/src/PhpPresentation/Shape/Chart/Marker.php
+++ b/src/PhpPresentation/Shape/Chart/Marker.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -102,19 +101,11 @@ public function setSize(int $size = 5): self
return $this;
}
- /**
- * @return Fill
- */
public function getFill(): Fill
{
return $this->fill;
}
- /**
- * @param Fill $fill
- *
- * @return self
- */
public function setFill(Fill $fill): self
{
$this->fill = $fill;
@@ -122,19 +113,11 @@ public function setFill(Fill $fill): self
return $this;
}
- /**
- * @return Border
- */
public function getBorder(): Border
{
return $this->border;
}
- /**
- * @param Border $border
- *
- * @return self
- */
public function setBorder(Border $border): self
{
$this->border = $border;
diff --git a/src/PhpPresentation/Shape/Chart/PlotArea.php b/src/PhpPresentation/Shape/Chart/PlotArea.php
index 2eb97174f8..9f1eaa635e 100644
--- a/src/PhpPresentation/Shape/Chart/PlotArea.php
+++ b/src/PhpPresentation/Shape/Chart/PlotArea.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -32,7 +31,7 @@ class PlotArea implements ComparableInterface
/**
* Type.
*
- * @var AbstractType|null
+ * @var null|AbstractType
*/
private $type;
@@ -90,12 +89,9 @@ public function __clone()
$this->axisY = clone $this->axisY;
}
- /**
- * @throws UndefinedChartTypeException
- */
public function getType(): AbstractType
{
- if (is_null($this->type)) {
+ if (null === $this->type) {
throw new UndefinedChartTypeException();
}
@@ -153,8 +149,6 @@ public function getOffsetY(): float
/**
* Set OffsetY (as a fraction of the chart).
- *
- * @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
*/
public function setOffsetY(float $pValue = 0): self
{
@@ -191,8 +185,6 @@ public function getHeight(): float
/**
* Set Height (as a fraction of the chart).
- *
- * @return \PhpOffice\PhpPresentation\Shape\Chart\PlotArea
*/
public function setHeight(float $value = 0): self
{
@@ -208,7 +200,7 @@ public function setHeight(float $value = 0): self
*/
public function getHashCode(): string
{
- return md5((is_null($this->type) ? 'null' : $this->type->getHashCode()) . $this->axisX->getHashCode() . $this->axisY->getHashCode() . $this->offsetX . $this->offsetY . $this->width . $this->height . __CLASS__);
+ return md5((null === $this->type ? 'null' : $this->type->getHashCode()) . $this->axisX->getHashCode() . $this->axisY->getHashCode() . $this->offsetX . $this->offsetY . $this->width . $this->height . __CLASS__);
}
/**
@@ -224,7 +216,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Shape/Chart/Series.php b/src/PhpPresentation/Shape/Chart/Series.php
index ea1bf49965..104a7ef39f 100644
--- a/src/PhpPresentation/Shape/Chart/Series.php
+++ b/src/PhpPresentation/Shape/Chart/Series.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -27,7 +26,7 @@
class Series implements ComparableInterface
{
- /* Label positions */
+ // Label positions
public const LABEL_BESTFIT = 'bestFit';
public const LABEL_BOTTOM = 'b';
public const LABEL_CENTER = 'ctr';
@@ -50,20 +49,20 @@ class Series implements ComparableInterface
*
* @var string
*/
- protected $DlblNumFormat = '';
+ protected $dlblNumFormat = '';
/**
- * @var string|null
+ * @var null|string
*/
protected $separator;
/**
- * @var Fill|null
+ * @var null|Fill
*/
protected $fill;
/**
- * @var Font|null
+ * @var null|Font
*/
protected $font;
@@ -78,7 +77,7 @@ class Series implements ComparableInterface
protected $marker;
/**
- * @var Outline|null
+ * @var null|Outline
*/
protected $outline;
@@ -134,7 +133,7 @@ class Series implements ComparableInterface
/**
* Values (key/value).
*
- * @var array
+ * @var array
*/
private $values = [];
@@ -146,8 +145,7 @@ class Series implements ComparableInterface
private $hashIndex;
/**
- * @param string $title
- * @param array $values
+ * @param array $values
*/
public function __construct(string $title = 'Series Title', array $values = [])
{
@@ -184,7 +182,7 @@ public function setTitle(string $value = 'Series Title'): self
*/
public function getDlblNumFormat(): string
{
- return $this->DlblNumFormat;
+ return $this->dlblNumFormat;
}
/**
@@ -192,7 +190,7 @@ public function getDlblNumFormat(): string
*/
public function hasDlblNumFormat(): bool
{
- return !empty($this->DlblNumFormat);
+ return !empty($this->dlblNumFormat);
}
/**
@@ -200,20 +198,17 @@ public function hasDlblNumFormat(): bool
*/
public function setDlblNumFormat(string $value = ''): self
{
- $this->DlblNumFormat = $value;
+ $this->dlblNumFormat = $value;
return $this;
}
- /**
- * @return Fill
- */
public function getFill(): ?Fill
{
return $this->fill;
}
- public function setFill(Fill $fill = null): self
+ public function setFill(?Fill $fill = null): self
{
$this->fill = $fill;
@@ -243,7 +238,7 @@ public function getDataPointFills(): array
/**
* Get Values.
*
- * @return array
+ * @return array
*/
public function getValues(): array
{
@@ -253,7 +248,7 @@ public function getValues(): array
/**
* Set Values.
*
- * @param array $values
+ * @param array $values
*/
public function setValues(array $values = []): self
{
@@ -264,11 +259,6 @@ public function setValues(array $values = []): self
/**
* Add Value.
- *
- * @param string $key
- * @param string|null $value
- *
- * @return self
*/
public function addValue(string $key, ?string $value): self
{
@@ -369,7 +359,7 @@ public function setShowPercentage(bool $value): self
public function hasShowSeparator(): bool
{
- return !is_null($this->separator);
+ return null !== $this->separator;
}
public function setSeparator(?string $pValue): self
@@ -408,8 +398,6 @@ public function setShowLeaderLines($value)
/**
* Get font.
- *
- * @return Font
*/
public function getFont(): ?Font
{
@@ -419,9 +407,9 @@ public function getFont(): ?Font
/**
* Set font.
*
- * @param Font|null $pFont Font
+ * @param null|Font $pFont Font
*/
- public function setFont(Font $pFont = null): self
+ public function setFont(?Font $pFont = null): self
{
$this->font = $pFont;
@@ -477,7 +465,7 @@ public function setOutline(?Outline $outline): self
*/
public function getHashCode(): string
{
- return md5((is_null($this->fill) ? 'null' : $this->fill->getHashCode()) . (is_null($this->font) ? 'null' : $this->font->getHashCode()) . var_export($this->values, true) . var_export($this, true) . __CLASS__);
+ return md5((null === $this->fill ? 'null' : $this->fill->getHashCode()) . (null === $this->font ? 'null' : $this->font->getHashCode()) . var_export($this->values, true) . var_export($this, true) . __CLASS__);
}
/**
@@ -486,7 +474,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Shape/Chart/Title.php b/src/PhpPresentation/Shape/Chart/Title.php
index a03165724b..a06c744689 100644
--- a/src/PhpPresentation/Shape/Chart/Title.php
+++ b/src/PhpPresentation/Shape/Chart/Title.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -74,14 +73,14 @@ class Title implements ComparableInterface
/**
* Alignment.
*
- * @var \PhpOffice\PhpPresentation\Style\Alignment
+ * @var Alignment
*/
private $alignment;
/**
* Font.
*
- * @var \PhpOffice\PhpPresentation\Style\Font
+ * @var Font
*/
private $font;
@@ -118,7 +117,7 @@ public function isVisible()
*
* @param bool $value
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Title
+ * @return Title
*/
public function setVisible($value = true)
{
@@ -142,7 +141,7 @@ public function getText()
*
* @param string $value
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Title
+ * @return Title
*/
public function setText($value = null)
{
@@ -234,9 +233,9 @@ public function getFont(): ?Font
/**
* Set font.
*
- * @param Font|null $pFont Font
+ * @param null|Font $pFont Font
*/
- public function setFont(Font $pFont = null): self
+ public function setFont(?Font $pFont = null): self
{
$this->font = $pFont;
@@ -246,7 +245,7 @@ public function setFont(Font $pFont = null): self
/**
* Get alignment.
*
- * @return \PhpOffice\PhpPresentation\Style\Alignment
+ * @return Alignment
*/
public function getAlignment()
{
@@ -256,7 +255,7 @@ public function getAlignment()
/**
* Set alignment.
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Title
+ * @return Title
*/
public function setAlignment(Alignment $alignment)
{
@@ -281,7 +280,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Shape/Chart/Type/AbstractType.php b/src/PhpPresentation/Shape/Chart/Type/AbstractType.php
index 1121231157..b9bb21281c 100644
--- a/src/PhpPresentation/Shape/Chart/Type/AbstractType.php
+++ b/src/PhpPresentation/Shape/Chart/Type/AbstractType.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -76,7 +75,7 @@ public function hasAxisY(): bool
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php b/src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php
index 234717698d..8b671c74e8 100644
--- a/src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php
+++ b/src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,7 +22,7 @@
/**
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar.
*/
-class AbstractTypeBar extends AbstractType
+abstract class AbstractTypeBar extends AbstractType
{
/** Orientation of bars */
public const DIRECTION_VERTICAL = 'col';
@@ -68,7 +67,7 @@ class AbstractTypeBar extends AbstractType
*
* @param string $value
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypeBar
+ * @return AbstractTypeBar
*/
public function setBarDirection($value = self::DIRECTION_VERTICAL)
{
@@ -92,7 +91,7 @@ public function getBarDirection()
*
* @param string $value
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypeBar
+ * @return AbstractTypeBar
*/
public function setBarGrouping($value = self::GROUPING_CLUSTERED)
{
@@ -142,9 +141,6 @@ public function setGapWidthPercent($gapWidthPercent)
return $this;
}
- /**
- * @return int
- */
public function getOverlapWidthPercent(): int
{
return $this->overlapWidthPercent;
@@ -152,8 +148,6 @@ public function getOverlapWidthPercent(): int
/**
* @param int $value overlap width percentage
- *
- * @return self
*/
public function setOverlapWidthPercent(int $value): self
{
diff --git a/src/PhpPresentation/Shape/Chart/Type/AbstractTypeLine.php b/src/PhpPresentation/Shape/Chart/Type/AbstractTypeLine.php
index 3040f0bc3e..159ca586a9 100644
--- a/src/PhpPresentation/Shape/Chart/Type/AbstractTypeLine.php
+++ b/src/PhpPresentation/Shape/Chart/Type/AbstractTypeLine.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +19,7 @@
namespace PhpOffice\PhpPresentation\Shape\Chart\Type;
-class AbstractTypeLine extends AbstractType
+abstract class AbstractTypeLine extends AbstractType
{
/**
* Is Line Smooth?
@@ -31,8 +30,6 @@ class AbstractTypeLine extends AbstractType
/**
* Is Line Smooth?
- *
- * @return bool
*/
public function isSmooth(): bool
{
@@ -40,13 +37,9 @@ public function isSmooth(): bool
}
/**
- * Set Line Smoothness
- *
- * @param bool $value
- *
- * @return AbstractTypeLine
+ * Set Line Smoothness.
*/
- public function setIsSmooth(bool $value = true): AbstractTypeLine
+ public function setIsSmooth(bool $value = true): self
{
$this->isSmooth = $value;
diff --git a/src/PhpPresentation/Shape/Chart/Type/AbstractTypePie.php b/src/PhpPresentation/Shape/Chart/Type/AbstractTypePie.php
index b538d9a16b..0583067bd5 100644
--- a/src/PhpPresentation/Shape/Chart/Type/AbstractTypePie.php
+++ b/src/PhpPresentation/Shape/Chart/Type/AbstractTypePie.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,7 +22,7 @@
/**
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar.
*/
-class AbstractTypePie extends AbstractType
+abstract class AbstractTypePie extends AbstractType
{
/**
* Create a new self instance.
diff --git a/src/PhpPresentation/Shape/Chart/Type/Area.php b/src/PhpPresentation/Shape/Chart/Type/Area.php
index 49fc9bd6b2..bcdab02028 100644
--- a/src/PhpPresentation/Shape/Chart/Type/Area.php
+++ b/src/PhpPresentation/Shape/Chart/Type/Area.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Chart/Type/Bar.php b/src/PhpPresentation/Shape/Chart/Type/Bar.php
index 9ea5b3dc7e..e16787d902 100644
--- a/src/PhpPresentation/Shape/Chart/Type/Bar.php
+++ b/src/PhpPresentation/Shape/Chart/Type/Bar.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Chart/Type/Bar3D.php b/src/PhpPresentation/Shape/Chart/Type/Bar3D.php
index 1011ad071b..1e4fa0b865 100644
--- a/src/PhpPresentation/Shape/Chart/Type/Bar3D.php
+++ b/src/PhpPresentation/Shape/Chart/Type/Bar3D.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php
index 292c823262..11cf586530 100644
--- a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php
+++ b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Chart/Type/Line.php b/src/PhpPresentation/Shape/Chart/Type/Line.php
index cefca9dddc..b8d635e366 100644
--- a/src/PhpPresentation/Shape/Chart/Type/Line.php
+++ b/src/PhpPresentation/Shape/Chart/Type/Line.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Chart/Type/Pie.php b/src/PhpPresentation/Shape/Chart/Type/Pie.php
index 53cb6b1fe2..3cf6959c1b 100644
--- a/src/PhpPresentation/Shape/Chart/Type/Pie.php
+++ b/src/PhpPresentation/Shape/Chart/Type/Pie.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Chart/Type/Pie3D.php b/src/PhpPresentation/Shape/Chart/Type/Pie3D.php
index 05689c61ac..b8c63bec11 100644
--- a/src/PhpPresentation/Shape/Chart/Type/Pie3D.php
+++ b/src/PhpPresentation/Shape/Chart/Type/Pie3D.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Chart/Type/Radar.php b/src/PhpPresentation/Shape/Chart/Type/Radar.php
index 9f45b5d5ef..322d30b4d0 100644
--- a/src/PhpPresentation/Shape/Chart/Type/Radar.php
+++ b/src/PhpPresentation/Shape/Chart/Type/Radar.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,7 +24,7 @@
class Radar extends AbstractType implements ComparableInterface
{
/**
- * Get hash code
+ * Get hash code.
*
* @return string Hash code
*/
diff --git a/src/PhpPresentation/Shape/Chart/Type/Scatter.php b/src/PhpPresentation/Shape/Chart/Type/Scatter.php
index 58f2576e7c..16668b34a7 100644
--- a/src/PhpPresentation/Shape/Chart/Type/Scatter.php
+++ b/src/PhpPresentation/Shape/Chart/Type/Scatter.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Chart/View3D.php b/src/PhpPresentation/Shape/Chart/View3D.php
index 21bbaeefe6..64111db63f 100644
--- a/src/PhpPresentation/Shape/Chart/View3D.php
+++ b/src/PhpPresentation/Shape/Chart/View3D.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -58,7 +57,7 @@ class View3D implements ComparableInterface
/**
* Height Percent.
*
- * @var int|null
+ * @var null|int
*/
private $heightPercent = 100;
@@ -98,7 +97,7 @@ public function getRotationX()
*
* @param int $pValue
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
+ * @return View3D
*/
public function setRotationX($pValue = 0)
{
@@ -122,7 +121,7 @@ public function getRotationY()
*
* @param int $pValue
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
+ * @return View3D
*/
public function setRotationY($pValue = 0)
{
@@ -146,7 +145,7 @@ public function hasRightAngleAxes()
*
* @param bool $value
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
+ * @return View3D
*/
public function setRightAngleAxes($value = true)
{
@@ -170,7 +169,7 @@ public function getPerspective()
*
* @param int $value
*
- * @return \PhpOffice\PhpPresentation\Shape\Chart\View3D
+ * @return View3D
*/
public function setPerspective($value = 30)
{
@@ -237,7 +236,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Shape/Comment.php b/src/PhpPresentation/Shape/Comment.php
index d909e05483..945faa879f 100644
--- a/src/PhpPresentation/Shape/Comment.php
+++ b/src/PhpPresentation/Shape/Comment.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,7 +29,7 @@
class Comment extends AbstractShape implements ComparableInterface
{
/**
- * @var Author|null
+ * @var null|Author
*/
protected $author;
@@ -105,7 +104,7 @@ public function setText($text = '')
/**
* Comment has not height.
*
- * @return int|null
+ * @return null|int
*/
public function getHeight()
{
@@ -125,7 +124,7 @@ public function setHeight(int $pValue = 0)
/**
* Comment has not width.
*
- * @return int|null
+ * @return null|int
*/
public function getWidth()
{
diff --git a/src/PhpPresentation/Shape/Comment/Author.php b/src/PhpPresentation/Shape/Comment/Author.php
index 59784f3e94..be9e3a896c 100644
--- a/src/PhpPresentation/Shape/Comment/Author.php
+++ b/src/PhpPresentation/Shape/Comment/Author.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Drawing/AbstractDrawingAdapter.php b/src/PhpPresentation/Shape/Drawing/AbstractDrawingAdapter.php
index f361ba7d49..f06988cfe7 100644
--- a/src/PhpPresentation/Shape/Drawing/AbstractDrawingAdapter.php
+++ b/src/PhpPresentation/Shape/Drawing/AbstractDrawingAdapter.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Drawing/Base64.php b/src/PhpPresentation/Shape/Drawing/Base64.php
index 9d4dfbc905..5574c78e05 100644
--- a/src/PhpPresentation/Shape/Drawing/Base64.php
+++ b/src/PhpPresentation/Shape/Drawing/Base64.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -57,7 +56,7 @@ class Base64 extends AbstractDrawingAdapter
public function __construct()
{
parent::__construct();
- $this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999));
+ $this->uniqueName = md5(mt_rand(0, 9999) . time() . mt_rand(0, 9999));
$this->data = '';
}
@@ -75,19 +74,16 @@ public function setData(string $data): self
public function getContents(): string
{
- list(, $imageContents) = explode(';', $this->getData());
- list(, $imageContents) = explode(',', $imageContents);
+ [, $imageContents] = explode(';', $this->getData());
+ [, $imageContents] = explode(',', $imageContents);
return base64_decode($imageContents);
}
- /**
- * @throws UnauthorizedMimetypeException
- */
public function getExtension(): string
{
- list($data) = explode(';', $this->getData());
- list(, $mime) = explode(':', $data);
+ [$data] = explode(';', $this->getData());
+ [, $mime] = explode(':', $data);
if (!array_key_exists($mime, $this->arrayMimeExtension)) {
throw new UnauthorizedMimetypeException($mime, $this->arrayMimeExtension);
@@ -103,8 +99,8 @@ public function getIndexedFilename(): string
public function getMimeType(): string
{
- list($data) = explode(';', $this->getData());
- list(, $mime) = explode(':', $data);
+ [$data] = explode(';', $this->getData());
+ [, $mime] = explode(':', $data);
if (!empty($mime)) {
return $mime;
diff --git a/src/PhpPresentation/Shape/Drawing/File.php b/src/PhpPresentation/Shape/Drawing/File.php
index 754985a44c..9078c98a09 100644
--- a/src/PhpPresentation/Shape/Drawing/File.php
+++ b/src/PhpPresentation/Shape/Drawing/File.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -43,10 +42,6 @@ public function getPath(): string
*
* @param string $pValue File path
* @param bool $pVerifyFile Verify file
- *
- * @throws FileNotFoundException
- *
- * @return self
*/
public function setPath(string $pValue = '', bool $pVerifyFile = true): self
{
@@ -59,7 +54,7 @@ public function setPath(string $pValue = '', bool $pVerifyFile = true): self
if ($pVerifyFile) {
if (0 == $this->width && 0 == $this->height) {
- list($this->width, $this->height) = getimagesize($this->getPath());
+ [$this->width, $this->height] = getimagesize($this->getPath());
}
}
@@ -76,9 +71,6 @@ public function getExtension(): string
return pathinfo($this->getPath(), PATHINFO_EXTENSION);
}
- /**
- * @throws FileNotFoundException
- */
public function getMimeType(): string
{
if (!CommonFile::fileExists($this->getPath())) {
diff --git a/src/PhpPresentation/Shape/Drawing/Gd.php b/src/PhpPresentation/Shape/Drawing/Gd.php
index 59bcf8d3dd..16fa6fe165 100644
--- a/src/PhpPresentation/Shape/Drawing/Gd.php
+++ b/src/PhpPresentation/Shape/Drawing/Gd.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,13 +21,13 @@
class Gd extends AbstractDrawingAdapter
{
- /* Rendering functions */
+ // Rendering functions
public const RENDERING_DEFAULT = 'imagepng';
public const RENDERING_PNG = 'imagepng';
public const RENDERING_GIF = 'imagegif';
public const RENDERING_JPEG = 'imagejpeg';
- /* MIME types */
+ // MIME types
public const MIMETYPE_DEFAULT = 'image/png';
public const MIMETYPE_PNG = 'image/png';
public const MIMETYPE_GIF = 'image/gif';
@@ -68,7 +67,7 @@ class Gd extends AbstractDrawingAdapter
public function __construct()
{
parent::__construct();
- $this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999));
+ $this->uniqueName = md5(mt_rand(0, 9999) . time() . mt_rand(0, 9999));
}
/**
@@ -92,7 +91,7 @@ public function setImageResource($value = null)
{
$this->imageResource = $value;
- if (!is_null($this->imageResource)) {
+ if (null !== $this->imageResource) {
// Get width/height
$this->width = imagesx($this->imageResource);
$this->height = imagesy($this->imageResource);
diff --git a/src/PhpPresentation/Shape/Drawing/ZipFile.php b/src/PhpPresentation/Shape/Drawing/ZipFile.php
index 2a921e9d25..481cfe70b4 100644
--- a/src/PhpPresentation/Shape/Drawing/ZipFile.php
+++ b/src/PhpPresentation/Shape/Drawing/ZipFile.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,6 +21,7 @@
use PhpOffice\Common\File as CommonFile;
use PhpOffice\PhpPresentation\Exception\FileNotFoundException;
+use ZipArchive;
class ZipFile extends AbstractDrawingAdapter
{
@@ -42,8 +42,6 @@ public function getPath(): string
* Set Path.
*
* @param string $pValue File path
- *
- * @return \PhpOffice\PhpPresentation\Shape\Drawing\ZipFile
*/
public function setPath(string $pValue = ''): self
{
@@ -52,16 +50,13 @@ public function setPath(string $pValue = ''): self
return $this;
}
- /**
- * @throws FileNotFoundException
- */
public function getContents(): string
{
if (!CommonFile::fileExists($this->getZipFileOut())) {
throw new FileNotFoundException($this->getZipFileOut());
}
- $imageZip = new \ZipArchive();
+ $imageZip = new ZipArchive();
$imageZip->open($this->getZipFileOut());
$imageContents = $imageZip->getFromName($this->getZipFileIn());
$imageZip->close();
@@ -75,15 +70,12 @@ public function getExtension(): string
return pathinfo($this->getZipFileIn(), PATHINFO_EXTENSION);
}
- /**
- * @throws FileNotFoundException
- */
public function getMimeType(): string
{
if (!CommonFile::fileExists($this->getZipFileOut())) {
throw new FileNotFoundException($this->getZipFileOut());
}
- $oArchive = new \ZipArchive();
+ $oArchive = new ZipArchive();
$oArchive->open($this->getZipFileOut());
if (!function_exists('getimagesizefromstring')) {
$uri = 'data://application/octet-stream;base64,' . base64_encode($oArchive->getFromName($this->getZipFileIn()));
diff --git a/src/PhpPresentation/Shape/Group.php b/src/PhpPresentation/Shape/Group.php
index dcb29ac4e9..1ceaf55e52 100644
--- a/src/PhpPresentation/Shape/Group.php
+++ b/src/PhpPresentation/Shape/Group.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,19 +19,14 @@
namespace PhpOffice\PhpPresentation\Shape;
-use ArrayObject;
use PhpOffice\PhpPresentation\AbstractShape;
use PhpOffice\PhpPresentation\GeometryCalculator;
use PhpOffice\PhpPresentation\ShapeContainerInterface;
+use PhpOffice\PhpPresentation\Traits\ShapeCollection;
class Group extends AbstractShape implements ShapeContainerInterface
{
- /**
- * Collection of shapes.
- *
- * @var array|ArrayObject
- */
- private $shapeCollection;
+ use ShapeCollection;
/**
* Extent X.
@@ -51,31 +45,6 @@ class Group extends AbstractShape implements ShapeContainerInterface
public function __construct()
{
parent::__construct();
-
- // Shape collection
- $this->shapeCollection = new ArrayObject();
- }
-
- /**
- * Get collection of shapes.
- *
- * @return array|ArrayObject
- */
- public function getShapeCollection()
- {
- return $this->shapeCollection;
- }
-
- /**
- * Add shape to slide.
- *
- * @return AbstractShape
- */
- public function addShape(AbstractShape $shape): AbstractShape
- {
- $shape->setContainer($this);
-
- return $shape;
}
/**
@@ -176,8 +145,6 @@ public function setHeight(int $pValue = 0)
/**
* Create rich text shape.
- *
- * @return RichText
*/
public function createRichTextShape(): RichText
{
@@ -194,8 +161,6 @@ public function createRichTextShape(): RichText
* @param int $fromY Starting point y offset
* @param int $toX Ending point x offset
* @param int $toY Ending point y offset
- *
- * @return Line
*/
public function createLineShape(int $fromX, int $fromY, int $toX, int $toY): Line
{
@@ -207,8 +172,6 @@ public function createLineShape(int $fromX, int $fromY, int $toX, int $toY): Lin
/**
* Create chart shape.
- *
- * @return Chart
*/
public function createChartShape(): Chart
{
@@ -220,8 +183,6 @@ public function createChartShape(): Chart
/**
* Create drawing shape.
- *
- * @return Drawing\File
*/
public function createDrawingShape(): Drawing\File
{
@@ -235,8 +196,6 @@ public function createDrawingShape(): Drawing\File
* Create table shape.
*
* @param int $columns Number of columns
- *
- * @return Table
*/
public function createTableShape(int $columns = 1): Table
{
diff --git a/src/PhpPresentation/Shape/Hyperlink.php b/src/PhpPresentation/Shape/Hyperlink.php
index 694fe2acf2..97c0d2aec1 100644
--- a/src/PhpPresentation/Shape/Hyperlink.php
+++ b/src/PhpPresentation/Shape/Hyperlink.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -44,14 +43,14 @@ class Hyperlink
*
* @var int
*/
- private $slideNumber = null;
+ private $slideNumber;
/**
* Slide relation ID (should not be used by user code!).
*
* @var string
*/
- public $relationId = null;
+ public $relationId;
/**
* Hash index.
@@ -60,6 +59,13 @@ class Hyperlink
*/
private $hashIndex;
+ /**
+ * If true, uses the text color, instead of theme color.
+ *
+ * @var bool
+ */
+ private $isTextColorUsed = false;
+
/**
* Create a new \PhpOffice\PhpPresentation\Shape\Hyperlink.
*
@@ -68,15 +74,12 @@ class Hyperlink
*/
public function __construct(string $pUrl = '', string $pTooltip = '')
{
- // Initialise member variables
$this->setUrl($pUrl);
$this->setTooltip($pTooltip);
}
/**
* Get URL.
- *
- * @return string
*/
public function getUrl(): string
{
@@ -85,10 +88,6 @@ public function getUrl(): string
/**
* Set URL.
- *
- * @param string $value
- *
- * @return self
*/
public function setUrl(string $value = ''): self
{
@@ -99,8 +98,6 @@ public function setUrl(string $value = ''): self
/**
* Get tooltip.
- *
- * @return string
*/
public function getTooltip(): string
{
@@ -109,10 +106,6 @@ public function getTooltip(): string
/**
* Set tooltip.
- *
- * @param string $value
- *
- * @return self
*/
public function setTooltip(string $value = ''): self
{
@@ -123,8 +116,6 @@ public function setTooltip(string $value = ''): self
/**
* Get slide number.
- *
- * @return int
*/
public function getSlideNumber(): int
{
@@ -133,10 +124,6 @@ public function getSlideNumber(): int
/**
* Set slide number.
- *
- * @param int $value
- *
- * @return self
*/
public function setSlideNumber(int $value = 1): self
{
@@ -148,8 +135,6 @@ public function setSlideNumber(int $value = 1): self
/**
* Is this hyperlink internal? (to another slide).
- *
- * @return bool
*/
public function isInternal(): bool
{
@@ -172,7 +157,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
@@ -195,4 +180,28 @@ public function setHashIndex(int $value)
return $this;
}
+
+ /**
+ * Get whether or not to use text color for a hyperlink, instead of theme color.
+ *
+ * @see https://docs.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/014fbc20-3705-4812-b8cd-93f5af05b504
+ *
+ * @return bool whether or not to use text color for a hyperlink, instead of theme color
+ */
+ public function isTextColorUsed(): bool
+ {
+ return $this->isTextColorUsed;
+ }
+
+ /**
+ * Set whether or not to use text color for a hyperlink, instead of theme color.
+ *
+ * @see https://docs.microsoft.com/en-us/openspecs/office_standards/ms-odrawxml/014fbc20-3705-4812-b8cd-93f5af05b504
+ */
+ public function setIsTextColorUsed(bool $isTextColorUsed): self
+ {
+ $this->isTextColorUsed = $isTextColorUsed;
+
+ return $this;
+ }
}
diff --git a/src/PhpPresentation/Shape/Line.php b/src/PhpPresentation/Shape/Line.php
index be7574d557..5e1c85aa57 100644
--- a/src/PhpPresentation/Shape/Line.php
+++ b/src/PhpPresentation/Shape/Line.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/Media.php b/src/PhpPresentation/Shape/Media.php
index 1207195d57..b53cb86be4 100644
--- a/src/PhpPresentation/Shape/Media.php
+++ b/src/PhpPresentation/Shape/Media.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,12 +32,15 @@ public function getMimeType(): string
switch (strtolower($this->getExtension())) {
case 'mp4':
$mimetype = 'video/mp4';
+
break;
case 'ogv':
$mimetype = 'video/ogg';
+
break;
case 'wmv':
$mimetype = 'video/x-ms-wmv';
+
break;
default:
$mimetype = 'application/octet-stream';
diff --git a/src/PhpPresentation/Shape/Placeholder.php b/src/PhpPresentation/Shape/Placeholder.php
index 45f6ac8202..1117736dcd 100644
--- a/src/PhpPresentation/Shape/Placeholder.php
+++ b/src/PhpPresentation/Shape/Placeholder.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -42,7 +41,7 @@ class Placeholder
* Specifies the index of the placeholder. This is used when applying templates or changing layouts to
* match a placeholder on one template or master to another.
*
- * @var int|null
+ * @var null|int
*/
protected $idx;
diff --git a/src/PhpPresentation/Shape/RichText.php b/src/PhpPresentation/Shape/RichText.php
index b9082773ad..7aafe3c10e 100644
--- a/src/PhpPresentation/Shape/RichText.php
+++ b/src/PhpPresentation/Shape/RichText.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,6 +21,7 @@
use PhpOffice\PhpPresentation\AbstractShape;
use PhpOffice\PhpPresentation\ComparableInterface;
+use PhpOffice\PhpPresentation\Exception\NotAllowedValueException;
use PhpOffice\PhpPresentation\Exception\OutOfBoundsException;
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
use PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface;
@@ -45,12 +45,16 @@ class RichText extends AbstractShape implements ComparableInterface
public const OVERFLOW_CLIP = 'clip';
public const OVERFLOW_OVERFLOW = 'overflow';
+ /** Vertical alignment center */
+ public const VALIGN_CENTER = 1;
+ public const VALIGN_NOTCENTER = 0;
+
/**
* Rich text paragraphs.
*
* @var array
*/
- private $richTextParagraphs;
+ private $richTextParagraphs = [];
/**
* Active paragraph.
@@ -109,7 +113,7 @@ class RichText extends AbstractShape implements ComparableInterface
private $columns = 1;
/**
- * The spacing between columns
+ * The spacing between columns.
*
* @var int
*/
@@ -146,31 +150,38 @@ class RichText extends AbstractShape implements ComparableInterface
/**
* Horizontal Auto Shrink.
*
- * @var bool|null
+ * @var null|bool
*/
private $autoShrinkHorizontal;
/**
* Vertical Auto Shrink.
*
- * @var bool|null
+ * @var null|bool
*/
private $autoShrinkVertical;
/**
* The percentage of the original font size to which the text is scaled.
*
- * @var float|null
+ * @var null|float
*/
private $fontScale;
/**
* The percentage of the reduction of the line spacing.
*
- * @var float|null
+ * @var null|float
*/
private $lnSpcReduction;
+ /**
+ * Define vertical text center position into shape (center,not center).
+ *
+ * @var int
+ */
+ private $verticalAlignCenter = self::VALIGN_NOTCENTER;
+
/**
* Create a new \PhpOffice\PhpPresentation\Shape\RichText instance.
*/
@@ -185,10 +196,21 @@ public function __construct()
parent::__construct();
}
+ /**
+ * Magic Method : clone.
+ */
+ public function __clone()
+ {
+ // Call perent clonage for heritage
+ parent::__clone();
+ // Clone each paragraph
+ foreach ($this->richTextParagraphs as &$paragraph) {
+ $paragraph = clone $paragraph;
+ }
+ }
+
/**
* Get active paragraph index.
- *
- * @return int
*/
public function getActiveParagraphIndex(): int
{
@@ -202,8 +224,6 @@ public function getActiveParagraph(): Paragraph
/**
* Set active paragraph.
- *
- * @throws OutOfBoundsException
*/
public function setActiveParagraph(int $index = 0): Paragraph
{
@@ -218,8 +238,6 @@ public function setActiveParagraph(int $index = 0): Paragraph
/**
* Get paragraph.
- *
- * @throws OutOfBoundsException
*/
public function getParagraph(int $index = 0): Paragraph
{
@@ -261,11 +279,9 @@ public function createParagraph(): Paragraph
/**
* Add text.
*
- * @param TextElementInterface|null $pText Rich text element
- *
- * @return self
+ * @param null|TextElementInterface $pText Rich text element
*/
- public function addText(TextElementInterface $pText = null): self
+ public function addText(?TextElementInterface $pText = null): self
{
$this->richTextParagraphs[$this->activeParagraph]->addText($pText);
@@ -276,8 +292,6 @@ public function addText(TextElementInterface $pText = null): self
* Create text (can not be formatted !).
*
* @param string $pText Text
- *
- * @return RichText\TextElement
*/
public function createText(string $pText = ''): RichText\TextElement
{
@@ -286,8 +300,6 @@ public function createText(string $pText = ''): RichText\TextElement
/**
* Create break.
- *
- * @return RichText\BreakElement
*/
public function createBreak(): RichText\BreakElement
{
@@ -298,8 +310,6 @@ public function createBreak(): RichText\BreakElement
* Create text run (can be formatted).
*
* @param string $pText Text
- *
- * @return RichText\Run
*/
public function createTextRun(string $pText = ''): RichText\Run
{
@@ -308,8 +318,6 @@ public function createTextRun(string $pText = ''): RichText\Run
/**
* Get plain text.
- *
- * @return string
*/
public function getPlainText(): string
{
@@ -358,8 +366,6 @@ public function setParagraphs(array $paragraphs = []): self
/**
* Get text wrapping.
- *
- * @return string
*/
public function getWrap(): string
{
@@ -368,10 +374,6 @@ public function getWrap(): string
/**
* Set text wrapping.
- *
- * @param string $value
- *
- * @return self
*/
public function setWrap(string $value = self::WRAP_SQUARE): self
{
@@ -382,8 +384,6 @@ public function setWrap(string $value = self::WRAP_SQUARE): self
/**
* Get autofit.
- *
- * @return string
*/
public function getAutoFit(): string
{
@@ -408,22 +408,16 @@ public function getLineSpaceReduction(): ?float
/**
* Set autofit.
- *
- * @param string $value
- * @param float|null $fontScale
- * @param float|null $lnSpcReduction
- *
- * @return self
*/
- public function setAutoFit(string $value = self::AUTOFIT_DEFAULT, float $fontScale = null, float $lnSpcReduction = null): self
+ public function setAutoFit(string $value = self::AUTOFIT_DEFAULT, ?float $fontScale = null, ?float $lnSpcReduction = null): self
{
$this->autoFit = $value;
- if (!is_null($fontScale)) {
+ if (null !== $fontScale) {
$this->fontScale = $fontScale;
}
- if (!is_null($lnSpcReduction)) {
+ if (null !== $lnSpcReduction) {
$this->lnSpcReduction = $lnSpcReduction;
}
@@ -432,8 +426,6 @@ public function setAutoFit(string $value = self::AUTOFIT_DEFAULT, float $fontSca
/**
* Get horizontal overflow.
- *
- * @return string
*/
public function getHorizontalOverflow(): string
{
@@ -442,10 +434,6 @@ public function getHorizontalOverflow(): string
/**
* Set horizontal overflow.
- *
- * @param string $value
- *
- * @return self
*/
public function setHorizontalOverflow(string $value = self::OVERFLOW_OVERFLOW): self
{
@@ -456,8 +444,6 @@ public function setHorizontalOverflow(string $value = self::OVERFLOW_OVERFLOW):
/**
* Get vertical overflow.
- *
- * @return string
*/
public function getVerticalOverflow(): string
{
@@ -466,10 +452,6 @@ public function getVerticalOverflow(): string
/**
* Set vertical overflow.
- *
- * @param string $value
- *
- * @return self
*/
public function setVerticalOverflow(string $value = self::OVERFLOW_OVERFLOW): self
{
@@ -480,8 +462,6 @@ public function setVerticalOverflow(string $value = self::OVERFLOW_OVERFLOW): se
/**
* Get upright.
- *
- * @return bool
*/
public function isUpright(): bool
{
@@ -490,10 +470,6 @@ public function isUpright(): bool
/**
* Set vertical.
- *
- * @param bool $value
- *
- * @return self
*/
public function setUpright(bool $value = false): self
{
@@ -504,8 +480,6 @@ public function setUpright(bool $value = false): self
/**
* Get vertical.
- *
- * @return bool
*/
public function isVertical(): bool
{
@@ -514,10 +488,6 @@ public function isVertical(): bool
/**
* Set vertical.
- *
- * @param bool $value
- *
- * @return self
*/
public function setVertical(bool $value = false): self
{
@@ -527,9 +497,36 @@ public function setVertical(bool $value = false): self
}
/**
- * Get columns.
+ * Define the vertical alignment if centered or not.
+ *
+ * @param int $value 1=center 0=not
*
- * @return int
+ * @see self::VALIGN_CENTER, self::VALIGN_NOTCENTER
+ */
+ public function setVerticalAlignCenter(int $value): self
+ {
+ if (!in_array(
+ $value,
+ [self::VALIGN_CENTER, self::VALIGN_NOTCENTER]
+ )) {
+ throw new NotAllowedValueException((string) $value, [(string) self::VALIGN_CENTER, (string) self::VALIGN_NOTCENTER]);
+ }
+
+ $this->verticalAlignCenter = $value;
+
+ return $this;
+ }
+
+ /**
+ * Get the vertical alignment center.
+ */
+ public function getVerticalAlignCenter(): int
+ {
+ return $this->verticalAlignCenter;
+ }
+
+ /**
+ * Get columns.
*/
public function getColumns(): int
{
@@ -538,12 +535,6 @@ public function getColumns(): int
/**
* Set columns.
- *
- * @param int $value
- *
- * @return self
- *
- * @throws OutOfBoundsException
*/
public function setColumns(int $value = 1): self
{
@@ -558,8 +549,6 @@ public function setColumns(int $value = 1): self
/**
* Get bottom inset.
- *
- * @return float
*/
public function getInsetBottom(): float
{
@@ -568,10 +557,6 @@ public function getInsetBottom(): float
/**
* Set bottom inset.
- *
- * @param float $value
- *
- * @return self
*/
public function setInsetBottom(float $value = 4.8): self
{
@@ -582,8 +567,6 @@ public function setInsetBottom(float $value = 4.8): self
/**
* Get left inset.
- *
- * @return float
*/
public function getInsetLeft(): float
{
@@ -592,10 +575,6 @@ public function getInsetLeft(): float
/**
* Set left inset.
- *
- * @param float $value
- *
- * @return self
*/
public function setInsetLeft(float $value = 9.6): self
{
@@ -606,8 +585,6 @@ public function setInsetLeft(float $value = 9.6): self
/**
* Get right inset.
- *
- * @return float
*/
public function getInsetRight(): float
{
@@ -616,10 +593,6 @@ public function getInsetRight(): float
/**
* Set left inset.
- *
- * @param float $value
- *
- * @return self
*/
public function setInsetRight(float $value = 9.6): self
{
@@ -630,8 +603,6 @@ public function setInsetRight(float $value = 9.6): self
/**
* Get top inset.
- *
- * @return float
*/
public function getInsetTop(): float
{
@@ -640,10 +611,6 @@ public function getInsetTop(): float
/**
* Set top inset.
- *
- * @param float $value
- *
- * @return self
*/
public function setInsetTop(float $value = 4.8): self
{
@@ -652,7 +619,7 @@ public function setInsetTop(float $value = 4.8): self
return $this;
}
- public function setAutoShrinkHorizontal(bool $value = null): self
+ public function setAutoShrinkHorizontal(?bool $value = null): self
{
$this->autoShrinkHorizontal = $value;
@@ -666,10 +633,8 @@ public function hasAutoShrinkHorizontal(): ?bool
/**
* Set vertical auto shrink.
- *
- * @return RichText
*/
- public function setAutoShrinkVertical(bool $value = null): self
+ public function setAutoShrinkVertical(?bool $value = null): self
{
$this->autoShrinkVertical = $value;
@@ -685,9 +650,7 @@ public function hasAutoShrinkVertical(): ?bool
}
/**
- * Get spacing between columns
- *
- * @return int
+ * Get spacing between columns.
*/
public function getColumnSpacing(): int
{
@@ -695,11 +658,7 @@ public function getColumnSpacing(): int
}
/**
- * Set spacing between columns
- *
- * @param int $value
- *
- * @return self
+ * Set spacing between columns.
*/
public function setColumnSpacing(int $value = 0): self
{
@@ -736,6 +695,7 @@ public function getHashCode(): string
. $this->leftInset
. $this->rightInset
. $this->topInset
+ . $this->verticalAlignCenter
. parent::getHashCode()
. __CLASS__
);
diff --git a/src/PhpPresentation/Shape/RichText/BreakElement.php b/src/PhpPresentation/Shape/RichText/BreakElement.php
index 5df5f06486..093d4bb6de 100644
--- a/src/PhpPresentation/Shape/RichText/BreakElement.php
+++ b/src/PhpPresentation/Shape/RichText/BreakElement.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Shape/RichText/Paragraph.php b/src/PhpPresentation/Shape/RichText/Paragraph.php
index 5fa26925cc..2eb173a620 100644
--- a/src/PhpPresentation/Shape/RichText/Paragraph.php
+++ b/src/PhpPresentation/Shape/RichText/Paragraph.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -50,7 +49,7 @@ class Paragraph implements ComparableInterface
/**
* Font.
*
- * @var Font|null
+ * @var null|Font
*/
private $font;
@@ -98,6 +97,17 @@ public function __construct()
$this->bulletStyle = new Bullet();
}
+ /**
+ * Magic Method : clone.
+ */
+ public function __clone()
+ {
+ // Clone each text
+ foreach ($this->richTextElements as &$rtElement) {
+ $rtElement = clone $rtElement;
+ }
+ }
+
/**
* Get alignment.
*/
@@ -127,9 +137,9 @@ public function getFont(): ?Font
/**
* Set font.
*
- * @param Font|null $pFont Font
+ * @param null|Font $pFont Font
*/
- public function setFont(Font $pFont = null): self
+ public function setFont(?Font $pFont = null): self
{
$this->font = $pFont;
@@ -145,9 +155,9 @@ public function getBulletStyle(): ?Bullet
}
/**
- * Set bullet style
+ * Set bullet style.
*/
- public function setBulletStyle(Bullet $style = null): self
+ public function setBulletStyle(?Bullet $style = null): self
{
$this->bulletStyle = $style;
@@ -170,9 +180,9 @@ public function createText(string $pText = ''): TextElement
/**
* Add text.
*
- * @param TextElementInterface|null $pText Rich text element
+ * @param null|TextElementInterface $pText Rich text element
*/
- public function addText(TextElementInterface $pText = null): self
+ public function addText(?TextElementInterface $pText = null): self
{
$this->richTextElements[] = $pText;
@@ -276,7 +286,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
@@ -300,20 +310,15 @@ public function setHashIndex(int $value)
return $this;
}
- /**
- * @return int
- */
public function getLineSpacing(): int
{
return $this->lineSpacing;
}
/**
- * Value in points
+ * Value in points.
*
* @param int $lineSpacing
- *
- * @return self
*/
public function setLineSpacing($lineSpacing): self
{
@@ -322,19 +327,11 @@ public function setLineSpacing($lineSpacing): self
return $this;
}
- /**
- * @return string
- */
public function getLineSpacingMode(): string
{
return $this->lineSpacingMode;
}
- /**
- * @param string $lineSpacingMode
- *
- * @return self
- */
public function setLineSpacingMode(string $lineSpacingMode): self
{
if (in_array($lineSpacingMode, [
@@ -348,9 +345,7 @@ public function setLineSpacingMode(string $lineSpacingMode): self
}
/**
- * Value in points
- *
- * @return int
+ * Value in points.
*/
public function getSpacingBefore(): int
{
@@ -358,11 +353,7 @@ public function getSpacingBefore(): int
}
/**
- * Value in points
- *
- * @param int $spacingBefore
- *
- * @return self
+ * Value in points.
*/
public function setSpacingBefore(int $spacingBefore): self
{
@@ -372,9 +363,7 @@ public function setSpacingBefore(int $spacingBefore): self
}
/**
- * Value in points
- *
- * @return int
+ * Value in points.
*/
public function getSpacingAfter(): int
{
@@ -382,11 +371,7 @@ public function getSpacingAfter(): int
}
/**
- * Value in points
- *
- * @param int $spacingAfter
- *
- * @return self
+ * Value in points.
*/
public function setSpacingAfter(int $spacingAfter): self
{
diff --git a/src/PhpPresentation/Shape/RichText/Run.php b/src/PhpPresentation/Shape/RichText/Run.php
index ba4f53250e..a9f99fe3e7 100644
--- a/src/PhpPresentation/Shape/RichText/Run.php
+++ b/src/PhpPresentation/Shape/RichText/Run.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,18 +29,16 @@ class Run extends TextElement implements TextElementInterface
/**
* Font.
*
- * @var \PhpOffice\PhpPresentation\Style\Font
+ * @var Font
*/
private $font;
/**
- * Create a new \PhpOffice\PhpPresentation\Shape\RichText\Run instance.
- *
* @param string $pText Text
*/
public function __construct($pText = '')
{
- // Initialise variables
+ // Initialize variables
$this->setText($pText);
$this->font = new Font();
}
@@ -57,11 +54,9 @@ public function getFont(): Font
/**
* Set font.
*
- * @param Font|null $pFont Font
- *
- * @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
+ * @return self
*/
- public function setFont(Font $pFont = null)
+ public function setFont(?Font $pFont = null)
{
$this->font = $pFont;
@@ -70,8 +65,6 @@ public function setFont(Font $pFont = null)
/**
* Get hash code.
- *
- * @return string Hash code
*/
public function getHashCode(): string
{
diff --git a/src/PhpPresentation/Shape/RichText/TextElement.php b/src/PhpPresentation/Shape/RichText/TextElement.php
index 3c74d02fd6..e240a01e21 100644
--- a/src/PhpPresentation/Shape/RichText/TextElement.php
+++ b/src/PhpPresentation/Shape/RichText/TextElement.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -43,7 +42,7 @@ class TextElement implements TextElementInterface
/**
* Hyperlink.
*
- * @var Hyperlink|null
+ * @var null|Hyperlink
*/
protected $hyperlink;
@@ -73,7 +72,7 @@ public function getText()
*
* @param string $pText Text value
*
- * @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
+ * @return TextElementInterface
*/
public function setText($pText = '')
{
@@ -92,12 +91,12 @@ public function getFont(): ?Font
public function hasHyperlink(): bool
{
- return !is_null($this->hyperlink);
+ return null !== $this->hyperlink;
}
public function getHyperlink(): Hyperlink
{
- if (is_null($this->hyperlink)) {
+ if (null === $this->hyperlink) {
$this->hyperlink = new Hyperlink();
}
@@ -107,9 +106,9 @@ public function getHyperlink(): Hyperlink
/**
* Set Hyperlink.
*
- * @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement
+ * @return TextElement
*/
- public function setHyperlink(Hyperlink $pHyperlink = null)
+ public function setHyperlink(?Hyperlink $pHyperlink = null)
{
$this->hyperlink = $pHyperlink;
@@ -147,6 +146,6 @@ public function setLanguage($language)
*/
public function getHashCode(): string
{
- return md5($this->text . (is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
+ return md5($this->text . (null === $this->hyperlink ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
}
}
diff --git a/src/PhpPresentation/Shape/RichText/TextElementInterface.php b/src/PhpPresentation/Shape/RichText/TextElementInterface.php
index 4c704436cd..21db945863 100644
--- a/src/PhpPresentation/Shape/RichText/TextElementInterface.php
+++ b/src/PhpPresentation/Shape/RichText/TextElementInterface.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,6 +19,8 @@
namespace PhpOffice\PhpPresentation\Shape\RichText;
+use PhpOffice\PhpPresentation\Style\Font;
+
/**
* Rich text element interface.
*/
@@ -37,14 +38,14 @@ public function getText();
*
* @param string $pText Text value
*
- * @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
+ * @return TextElementInterface
*/
public function setText($pText = '');
/**
* Get font.
*
- * @return \PhpOffice\PhpPresentation\Style\Font
+ * @return Font
*/
public function getFont();
@@ -56,7 +57,7 @@ public function getLanguage();
/**
* @param string $lang
*
- * @return \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface
+ * @return TextElementInterface
*/
public function setLanguage($lang);
diff --git a/src/PhpPresentation/Shape/Table.php b/src/PhpPresentation/Shape/Table.php
index d6313be119..496077877a 100644
--- a/src/PhpPresentation/Shape/Table.php
+++ b/src/PhpPresentation/Shape/Table.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -63,8 +62,6 @@ public function __construct($columns = 1)
* Get row.
*
* @param int $row Row number
- *
- * @throws OutOfBoundsException
*/
public function getRow(int $row = 0): Row
{
@@ -79,11 +76,6 @@ public function getRow(int $row = 0): Row
return $this->rows[$row];
}
- /**
- * @param int $row
- *
- * @return bool
- */
public function hasRow(int $row): bool
{
return isset($this->rows[$row]);
@@ -101,8 +93,6 @@ public function getRows(): array
/**
* Create row.
- *
- * @return Row
*/
public function createRow(): Row
{
@@ -112,19 +102,11 @@ public function createRow(): Row
return $row;
}
- /**
- * @return int
- */
public function getNumColumns(): int
{
return $this->columnCount;
}
- /**
- * @param int $numColumn
- *
- * @return self
- */
public function setNumColumns(int $numColumn): self
{
$this->columnCount = $numColumn;
diff --git a/src/PhpPresentation/Shape/Table/Cell.php b/src/PhpPresentation/Shape/Table/Cell.php
index c8e8a942c5..d5e5251c8a 100644
--- a/src/PhpPresentation/Shape/Table/Cell.php
+++ b/src/PhpPresentation/Shape/Table/Cell.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -49,14 +48,14 @@ class Cell implements ComparableInterface
/**
* Fill.
*
- * @var \PhpOffice\PhpPresentation\Style\Fill
+ * @var Fill
*/
private $fill;
/**
* Borders.
*
- * @var \PhpOffice\PhpPresentation\Style\Borders
+ * @var Borders
*/
private $borders;
@@ -128,8 +127,6 @@ public function getActiveParagraph(): Paragraph
* Set active paragraph.
*
* @param int $index
- *
- * @throws OutOfBoundsException
*/
public function setActiveParagraph($index = 0): Paragraph
{
@@ -144,10 +141,6 @@ public function setActiveParagraph($index = 0): Paragraph
/**
* Get paragraph.
- *
- * @param int $index
- *
- * @throws OutOfBoundsException
*/
public function getParagraph(int $index = 0): Paragraph
{
@@ -185,9 +178,9 @@ public function createParagraph(): Paragraph
*
* @param TextElementInterface $pText Rich text element
*
- * @return \PhpOffice\PhpPresentation\Shape\Table\Cell
+ * @return Cell
*/
- public function addText(TextElementInterface $pText = null)
+ public function addText(?TextElementInterface $pText = null)
{
$this->richTextParagraphs[$this->activeParagraph]->addText($pText);
@@ -271,8 +264,6 @@ public function getParagraphs()
* Set paragraphs.
*
* @param array $paragraphs Array of paragraphs
- *
- * @return \PhpOffice\PhpPresentation\Shape\Table\Cell
*/
public function setParagraphs(array $paragraphs = []): self
{
@@ -285,7 +276,7 @@ public function setParagraphs(array $paragraphs = []): self
/**
* Get fill.
*
- * @return \PhpOffice\PhpPresentation\Style\Fill
+ * @return Fill
*/
public function getFill()
{
@@ -295,7 +286,7 @@ public function getFill()
/**
* Set fill.
*
- * @return \PhpOffice\PhpPresentation\Shape\Table\Cell
+ * @return Cell
*/
public function setFill(Fill $fill)
{
@@ -307,7 +298,7 @@ public function setFill(Fill $fill)
/**
* Get borders.
*
- * @return \PhpOffice\PhpPresentation\Style\Borders
+ * @return Borders
*/
public function getBorders()
{
@@ -317,7 +308,7 @@ public function getBorders()
/**
* Set borders.
*
- * @return \PhpOffice\PhpPresentation\Shape\Table\Cell
+ * @return Cell
*/
public function setBorders(Borders $borders)
{
@@ -393,7 +384,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Shape/Table/Row.php b/src/PhpPresentation/Shape/Table/Row.php
index 039bbf16d0..59e9207e2e 100644
--- a/src/PhpPresentation/Shape/Table/Row.php
+++ b/src/PhpPresentation/Shape/Table/Row.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -81,8 +80,6 @@ public function __construct(int $columns = 1)
* Get cell.
*
* @param int $cell Cell number
- *
- * @throws OutOfBoundsException
*/
public function getCell(int $cell = 0): Cell
{
@@ -101,8 +98,6 @@ public function getCell(int $cell = 0): Cell
* Get cell.
*
* @param int $cell Cell number
- *
- * @return bool
*/
public function hasCell(int $cell): bool
{
@@ -121,10 +116,6 @@ public function getCells(): array
/**
* Next cell (moves one cell to the right).
- *
- * @return Cell
- *
- * @throws OutOfBoundsException
*/
public function nextCell(): Cell
{
@@ -144,8 +135,6 @@ public function nextCell(): Cell
/**
* Get fill.
- *
- * @return Fill
*/
public function getFill(): Fill
{
@@ -154,8 +143,6 @@ public function getFill(): Fill
/**
* Set fill.
- *
- * @return self
*/
public function setFill(Fill $fill): self
{
@@ -166,8 +153,6 @@ public function setFill(Fill $fill): self
/**
* Get height.
- *
- * @return int
*/
public function getHeight(): int
{
@@ -176,10 +161,6 @@ public function getHeight(): int
/**
* Set height.
- *
- * @param int $value
- *
- * @return self
*/
public function setHeight(int $value = 0): self
{
@@ -209,7 +190,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/ShapeContainerInterface.php b/src/PhpPresentation/ShapeContainerInterface.php
index 48e24f1674..5fde0573d0 100644
--- a/src/PhpPresentation/ShapeContainerInterface.php
+++ b/src/PhpPresentation/ShapeContainerInterface.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,10 +36,17 @@ public function getShapeCollection();
/**
* Add shape to slide.
*
- * @return AbstractShape
+ * @return static
*/
public function addShape(AbstractShape $shape);
+ /**
+ * Unset shape from the collection.
+ *
+ * @return static
+ */
+ public function unsetShape(int $key);
+
/**
* Get X Offset.
*/
diff --git a/src/PhpPresentation/Slide.php b/src/PhpPresentation/Slide.php
index 61c0d57757..3b0a9218f0 100644
--- a/src/PhpPresentation/Slide.php
+++ b/src/PhpPresentation/Slide.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -39,7 +38,7 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
/**
* Slide layout.
*
- * @var SlideLayout|null
+ * @var null|SlideLayout
*/
private $slideLayout;
@@ -63,23 +62,19 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
/**
* Name of the title.
*
- * @var string|null
+ * @var null|string
*/
protected $name;
/**
* Create a new slide.
- *
- * @param PhpPresentation $pParent
*/
- public function __construct(PhpPresentation $pParent = null)
+ public function __construct(?PhpPresentation $pParent = null)
{
// Set parent
$this->parent = $pParent;
- // Shape collection
- $this->shapeCollection = new \ArrayObject();
// Set identifier
- $this->identifier = md5(rand(0, 9999) . time());
+ $this->identifier = md5(mt_rand(0, mt_getrandmax()) . time());
// Set Slide Layout
if ($this->parent instanceof PhpPresentation) {
$arrayMasterSlides = $this->parent->getAllMasterSlides();
@@ -125,7 +120,7 @@ public function getSlideMasterId()
*
* @param int $masterId
*
- * @return \PhpOffice\PhpPresentation\Slide
+ * @return Slide
*/
public function setSlideMasterId($masterId = 1)
{
@@ -134,10 +129,26 @@ public function setSlideMasterId($masterId = 1)
return $this;
}
+ public function __clone()
+ {
+ // Set parent
+ $this->parent = clone $this->parent;
+ // Shape collection
+ foreach ($this->shapeCollection as &$shape) {
+ $shape = clone $shape;
+ }
+ // Transition
+ if (isset($this->slideTransition)) {
+ $this->slideTransition = clone $this->slideTransition;
+ }
+ // Note
+ $this->slideNote = clone $this->slideNote;
+ }
+
/**
* Copy slide (!= clone!).
*
- * @return \PhpOffice\PhpPresentation\Slide
+ * @return Slide
*/
public function copy()
{
@@ -151,9 +162,9 @@ public function getNote(): Note
return $this->slideNote;
}
- public function setNote(Note $note = null): self
+ public function setNote(?Note $note = null): self
{
- $this->slideNote = (is_null($note) ? new Note() : $note);
+ $this->slideNote = (null === $note ? new Note() : $note);
$this->slideNote->setParent($this);
return $this;
@@ -161,8 +172,6 @@ public function setNote(Note $note = null): self
/**
* Get the name of the slide.
- *
- * @return string
*/
public function getName(): ?string
{
@@ -202,7 +211,7 @@ public function setIsVisible($value = true)
/**
* Add an animation to the slide.
*
- * @param \PhpOffice\PhpPresentation\Slide\Animation $animation
+ * @param Slide\Animation $animation
*
* @return Slide
*/
diff --git a/src/PhpPresentation/Slide/AbstractBackground.php b/src/PhpPresentation/Slide/AbstractBackground.php
index 42aa4d5856..94b9063b0a 100644
--- a/src/PhpPresentation/Slide/AbstractBackground.php
+++ b/src/PhpPresentation/Slide/AbstractBackground.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Slide/AbstractSlide.php b/src/PhpPresentation/Slide/AbstractSlide.php
index ad5acd19c4..9c93c32834 100644
--- a/src/PhpPresentation/Slide/AbstractSlide.php
+++ b/src/PhpPresentation/Slide/AbstractSlide.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,8 +19,6 @@
namespace PhpOffice\PhpPresentation\Slide;
-use ArrayObject;
-use PhpOffice\PhpPresentation\AbstractShape;
use PhpOffice\PhpPresentation\ComparableInterface;
use PhpOffice\PhpPresentation\GeometryCalculator;
use PhpOffice\PhpPresentation\PhpPresentation;
@@ -32,66 +29,71 @@
use PhpOffice\PhpPresentation\Shape\RichText;
use PhpOffice\PhpPresentation\Shape\Table;
use PhpOffice\PhpPresentation\ShapeContainerInterface;
+use PhpOffice\PhpPresentation\Traits\ShapeCollection;
abstract class AbstractSlide implements ComparableInterface, ShapeContainerInterface
{
+ use ShapeCollection;
+
/**
* @var string
*/
protected $relsIndex;
+
/**
- * @var Transition|null
+ * @var null|Transition
*/
protected $slideTransition;
- /**
- * Collection of shapes.
- *
- * @var array|ArrayObject
- */
- protected $shapeCollection = [];
/**
* Extent Y.
*
* @var int
*/
protected $extentY;
+
/**
* Extent X.
*
* @var int
*/
protected $extentX;
+
/**
* Offset X.
*
* @var int
*/
protected $offsetX;
+
/**
* Offset Y.
*
* @var int
*/
protected $offsetY;
+
/**
* Slide identifier.
*
* @var string
*/
protected $identifier;
+
/**
* Hash index.
*
* @var int
*/
protected $hashIndex;
+
/**
* Parent presentation.
*
- * @var PhpPresentation|null
+ * @var null|PhpPresentation
*/
protected $parent;
+
/**
* Background of the slide.
*
@@ -99,42 +101,6 @@ abstract class AbstractSlide implements ComparableInterface, ShapeContainerInter
*/
protected $background;
- /**
- * Get collection of shapes.
- *
- * @return array|ArrayObject
- */
- public function getShapeCollection()
- {
- return $this->shapeCollection;
- }
-
- /**
- * Get collection of shapes.
- *
- * @param array|ArrayObject $shapeCollection
- *
- * @return AbstractSlide
- */
- public function setShapeCollection($shapeCollection = [])
- {
- $this->shapeCollection = $shapeCollection;
-
- return $this;
- }
-
- /**
- * Add shape to slide.
- *
- * @return AbstractShape
- */
- public function addShape(AbstractShape $shape): AbstractShape
- {
- $shape->setContainer($this);
-
- return $shape;
- }
-
/**
* Get X Offset.
*/
@@ -207,7 +173,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
@@ -315,7 +281,7 @@ public function getParent(): ?PhpPresentation
/**
* Re-bind parent.
*/
- public function rebindParent(PhpPresentation $parent): AbstractSlide
+ public function rebindParent(PhpPresentation $parent): self
{
$this->parent->removeSlideByIndex($this->parent->getIndex($this));
$this->parent = $parent;
@@ -328,7 +294,7 @@ public function getBackground(): ?AbstractBackground
return $this->background;
}
- public function setBackground(AbstractBackground $background = null): AbstractSlide
+ public function setBackground(?AbstractBackground $background = null): self
{
$this->background = $background;
@@ -340,7 +306,7 @@ public function getTransition(): ?Transition
return $this->slideTransition;
}
- public function setTransition(Transition $transition = null): self
+ public function setTransition(?Transition $transition = null): self
{
$this->slideTransition = $transition;
diff --git a/src/PhpPresentation/Slide/Animation.php b/src/PhpPresentation/Slide/Animation.php
index 2e6d1dc48a..e32a4c71b2 100644
--- a/src/PhpPresentation/Slide/Animation.php
+++ b/src/PhpPresentation/Slide/Animation.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,42 +19,9 @@
namespace PhpOffice\PhpPresentation\Slide;
-use PhpOffice\PhpPresentation\AbstractShape;
+use PhpOffice\PhpPresentation\Traits\ShapeCollection;
class Animation
{
- /**
- * @var array
- */
- protected $shapeCollection = [];
-
- /**
- * @return Animation
- */
- public function addShape(AbstractShape $shape)
- {
- $this->shapeCollection[] = $shape;
-
- return $this;
- }
-
- /**
- * @return array
- */
- public function getShapeCollection(): array
- {
- return $this->shapeCollection;
- }
-
- /**
- * @param array $array
- *
- * @return Animation
- */
- public function setShapeCollection(array $array = [])
- {
- $this->shapeCollection = $array;
-
- return $this;
- }
+ use ShapeCollection;
}
diff --git a/src/PhpPresentation/Slide/Background/Color.php b/src/PhpPresentation/Slide/Background/Color.php
index 24507d8dc4..22ed3e0632 100644
--- a/src/PhpPresentation/Slide/Background/Color.php
+++ b/src/PhpPresentation/Slide/Background/Color.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,11 +25,11 @@
class Color extends AbstractBackground
{
/**
- * @var StyleColor|null
+ * @var null|StyleColor
*/
protected $color;
- public function setColor(StyleColor $color = null): self
+ public function setColor(?StyleColor $color = null): self
{
$this->color = $color;
diff --git a/src/PhpPresentation/Slide/Background/Image.php b/src/PhpPresentation/Slide/Background/Image.php
index 39c998e2ba..d39d009011 100644
--- a/src/PhpPresentation/Slide/Background/Image.php
+++ b/src/PhpPresentation/Slide/Background/Image.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -49,8 +48,6 @@ class Image extends AbstractBackground
/**
* Get Path.
- *
- * @return string
*/
public function getPath(): ?string
{
@@ -63,8 +60,6 @@ public function getPath(): ?string
* @param string $pValue File path
* @param bool $pVerifyFile Verify file
*
- * @throws FileNotFoundException
- *
* @return self
*/
public function setPath(string $pValue = '', bool $pVerifyFile = true)
@@ -76,7 +71,7 @@ public function setPath(string $pValue = '', bool $pVerifyFile = true)
if (0 == $this->width && 0 == $this->height) {
// Get width/height
- list($this->width, $this->height) = getimagesize($pValue);
+ [$this->width, $this->height] = getimagesize($pValue);
}
}
$this->path = $pValue;
@@ -86,8 +81,6 @@ public function setPath(string $pValue = '', bool $pVerifyFile = true)
/**
* Get Filename.
- *
- * @return string
*/
public function getFilename(): string
{
@@ -96,8 +89,6 @@ public function getFilename(): string
/**
* Get Extension.
- *
- * @return string
*/
public function getExtension(): string
{
diff --git a/src/PhpPresentation/Slide/Background/SchemeColor.php b/src/PhpPresentation/Slide/Background/SchemeColor.php
index 3cb785df53..380502e899 100644
--- a/src/PhpPresentation/Slide/Background/SchemeColor.php
+++ b/src/PhpPresentation/Slide/Background/SchemeColor.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,14 +25,14 @@
class SchemeColor extends AbstractBackground
{
/**
- * @var StyleSchemeColor|null
+ * @var null|StyleSchemeColor
*/
protected $schemeColor;
/**
* @return $this
*/
- public function setSchemeColor(StyleSchemeColor $color = null): self
+ public function setSchemeColor(?StyleSchemeColor $color = null): self
{
$this->schemeColor = $color;
diff --git a/src/PhpPresentation/Slide/Iterator.php b/src/PhpPresentation/Slide/Iterator.php
index 787d06153f..f718728ecc 100644
--- a/src/PhpPresentation/Slide/Iterator.php
+++ b/src/PhpPresentation/Slide/Iterator.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,6 +21,7 @@
use IteratorIterator;
use PhpOffice\PhpPresentation\PhpPresentation;
+use ReturnTypeWillChange;
// @phpstan-ignore-next-line
class Iterator extends IteratorIterator
@@ -48,18 +48,11 @@ public function __construct(PhpPresentation $subject)
$this->subject = $subject;
}
- /**
- * Destructor.
- */
- public function __destruct()
- {
- unset($this->subject);
- }
-
/**
* Rewind iterator.
*/
- public function rewind()
+ #[ReturnTypeWillChange]
+ public function rewind(): void
{
$this->position = 0;
}
@@ -69,6 +62,7 @@ public function rewind()
*
* @return \PhpOffice\PhpPresentation\Slide
*/
+ #[ReturnTypeWillChange]
public function current()
{
return $this->subject->getSlide($this->position);
@@ -79,6 +73,7 @@ public function current()
*
* @return int
*/
+ #[ReturnTypeWillChange]
public function key()
{
return $this->position;
@@ -87,7 +82,8 @@ public function key()
/**
* Next value.
*/
- public function next()
+ #[ReturnTypeWillChange]
+ public function next(): void
{
++$this->position;
}
@@ -97,6 +93,7 @@ public function next()
*
* @return bool
*/
+ #[ReturnTypeWillChange]
public function valid()
{
return $this->position < $this->subject->getSlideCount();
diff --git a/src/PhpPresentation/Slide/Layout.php b/src/PhpPresentation/Slide/Layout.php
index 1c1ec93cb6..e4c6726eec 100644
--- a/src/PhpPresentation/Slide/Layout.php
+++ b/src/PhpPresentation/Slide/Layout.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Slide/Note.php b/src/PhpPresentation/Slide/Note.php
index d1423a0262..b7a323c672 100644
--- a/src/PhpPresentation/Slide/Note.php
+++ b/src/PhpPresentation/Slide/Note.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,16 +19,17 @@
namespace PhpOffice\PhpPresentation\Slide;
-use ArrayObject;
-use PhpOffice\PhpPresentation\AbstractShape;
use PhpOffice\PhpPresentation\ComparableInterface;
use PhpOffice\PhpPresentation\GeometryCalculator;
use PhpOffice\PhpPresentation\Shape\RichText;
use PhpOffice\PhpPresentation\ShapeContainerInterface;
use PhpOffice\PhpPresentation\Slide;
+use PhpOffice\PhpPresentation\Traits\ShapeCollection;
class Note implements ComparableInterface, ShapeContainerInterface
{
+ use ShapeCollection;
+
/**
* Parent slide.
*
@@ -37,13 +37,6 @@ class Note implements ComparableInterface, ShapeContainerInterface
*/
private $parent;
- /**
- * Collection of shapes.
- *
- * @var array|ArrayObject
- */
- private $shapeCollection;
-
/**
* Note identifier.
*
@@ -88,41 +81,14 @@ class Note implements ComparableInterface, ShapeContainerInterface
/**
* Create a new note.
- *
- * @param Slide $pParent
*/
- public function __construct(Slide $pParent = null)
+ public function __construct(?Slide $pParent = null)
{
// Set parent
$this->parent = $pParent;
- // Shape collection
- $this->shapeCollection = new ArrayObject();
-
// Set identifier
- $this->identifier = md5(rand(0, 9999) . time());
- }
-
- /**
- * Get collection of shapes.
- *
- * @return array|ArrayObject
- */
- public function getShapeCollection()
- {
- return $this->shapeCollection;
- }
-
- /**
- * Add shape to slide.
- *
- * @return AbstractShape
- */
- public function addShape(AbstractShape $shape): AbstractShape
- {
- $shape->setContainer($this);
-
- return $shape;
+ $this->identifier = md5(mt_rand(0, 9999) . time());
}
/**
@@ -230,7 +196,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Slide/SlideLayout.php b/src/PhpPresentation/Slide/SlideLayout.php
index 9c30db23ba..24c34544b2 100644
--- a/src/PhpPresentation/Slide/SlideLayout.php
+++ b/src/PhpPresentation/Slide/SlideLayout.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,34 +29,39 @@ class SlideLayout extends AbstractSlide implements ComparableInterface, ShapeCon
* @var SlideMaster
*/
protected $slideMaster;
+
/**
* Slide relation ID (should not be used by user code!).
*
* @var string
*/
public $relationId;
+
/**
* Slide layout NR (should not be used by user code!).
*
* @var int
*/
public $layoutNr;
+
/**
* Slide layout ID (should not be used by user code!).
*
* @var int
*/
public $layoutId;
+
/**
* Slide layout ID (should not be used by user code!).
*
- * @var string|null
+ * @var null|string
*/
protected $layoutName;
+
/**
* Mapping of colors to the theme.
*
- * @var \PhpOffice\PhpPresentation\Style\ColorMap
+ * @var ColorMap
*/
public $colorMap;
@@ -68,10 +72,8 @@ public function __construct(SlideMaster $pSlideMaster)
{
// Set parent
$this->slideMaster = $pSlideMaster;
- // Shape collection
- $this->shapeCollection = new \ArrayObject();
// Set identifier
- $this->identifier = md5(rand(0, 9999) . time());
+ $this->identifier = md5(mt_rand(0, 9999) . time());
// Set a basic colorMap
$this->colorMap = new ColorMap();
}
diff --git a/src/PhpPresentation/Slide/SlideMaster.php b/src/PhpPresentation/Slide/SlideMaster.php
index 3966f008cf..1d30e539a7 100644
--- a/src/PhpPresentation/Slide/SlideMaster.php
+++ b/src/PhpPresentation/Slide/SlideMaster.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,20 +36,24 @@ class SlideMaster extends AbstractSlide implements ComparableInterface, ShapeCon
* @var array
*/
protected $slideLayouts = [];
+
/**
* Mapping of colors to the theme.
*
* @var ColorMap
*/
public $colorMap;
+
/**
* @var TextStyle
*/
protected $textStyles;
+
/**
* @var array
*/
protected $arraySchemeColor = [];
+
/**
* @var array
*/
@@ -72,14 +75,12 @@ class SlideMaster extends AbstractSlide implements ComparableInterface, ShapeCon
/**
* Create a new slideMaster.
*/
- public function __construct(PhpPresentation $pParent = null)
+ public function __construct(?PhpPresentation $pParent = null)
{
// Set parent
$this->parent = $pParent;
- // Shape collection
- $this->shapeCollection = new \ArrayObject();
// Set identifier
- $this->identifier = md5(rand(0, 9999) . time());
+ $this->identifier = md5(mt_rand(0, 9999) . time());
// Set a basic colorMap
$this->colorMap = new ColorMap();
// Set a white background
@@ -98,8 +99,6 @@ public function __construct(PhpPresentation $pParent = null)
/**
* Create a slideLayout and add it to this presentation.
- *
- * @return SlideLayout
*/
public function createSlideLayout(): SlideLayout
{
@@ -111,12 +110,8 @@ public function createSlideLayout(): SlideLayout
/**
* Add slideLayout.
- *
- * @param SlideLayout|null $slideLayout
- *
- * @return SlideLayout
*/
- public function addSlideLayout(SlideLayout $slideLayout = null): SlideLayout
+ public function addSlideLayout(?SlideLayout $slideLayout = null): SlideLayout
{
$this->slideLayouts[] = $slideLayout;
@@ -131,17 +126,11 @@ public function getAllSlideLayouts(): array
return $this->slideLayouts;
}
- /**
- * @return TextStyle
- */
public function getTextStyles(): TextStyle
{
return $this->textStyles;
}
- /**
- * @return self
- */
public function setTextStyles(TextStyle $textStyle): self
{
$this->textStyles = $textStyle;
@@ -149,9 +138,6 @@ public function setTextStyles(TextStyle $textStyle): self
return $this;
}
- /**
- * @return self
- */
public function addSchemeColor(SchemeColor $schemeColor): self
{
$this->arraySchemeColor[$schemeColor->getValue()] = $schemeColor;
diff --git a/src/PhpPresentation/Slide/Transition.php b/src/PhpPresentation/Slide/Transition.php
index 9836f7c62e..b4589ba97e 100644
--- a/src/PhpPresentation/Slide/Transition.php
+++ b/src/PhpPresentation/Slide/Transition.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -81,22 +80,26 @@ class Transition
* @var bool
*/
protected $hasManualTrigger = false;
+
/**
* @var bool
*/
protected $hasTimeTrigger = false;
+
/**
- * @var int|null
+ * @var null|int
*/
- protected $advanceTimeTrigger = null;
+ protected $advanceTimeTrigger;
+
/**
- * @var string|null
+ * @var null|string
*/
- protected $speed = null;
+ protected $speed;
+
/**
- * @var string|null
+ * @var null|string
*/
- protected $transitionType = null;
+ protected $transitionType;
public function setSpeed(?string $speed = self::SPEED_MEDIUM): self
{
@@ -144,7 +147,7 @@ public function getAdvanceTimeTrigger(): ?int
return $this->advanceTimeTrigger;
}
- public function setTransitionType(string $type = null): self
+ public function setTransitionType(?string $type = null): self
{
$this->transitionType = $type;
diff --git a/src/PhpPresentation/Style/Alignment.php b/src/PhpPresentation/Style/Alignment.php
index fae963ebe7..9e17e7dcdf 100644
--- a/src/PhpPresentation/Style/Alignment.php
+++ b/src/PhpPresentation/Style/Alignment.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,7 +24,7 @@
class Alignment implements ComparableInterface
{
- /* Horizontal alignment */
+ // Horizontal alignment
public const HORIZONTAL_GENERAL = 'l';
public const HORIZONTAL_LEFT = 'l';
public const HORIZONTAL_RIGHT = 'r';
@@ -33,14 +32,14 @@ class Alignment implements ComparableInterface
public const HORIZONTAL_JUSTIFY = 'just';
public const HORIZONTAL_DISTRIBUTED = 'dist';
- /* Vertical alignment */
+ // Vertical alignment
public const VERTICAL_BASE = 'base';
public const VERTICAL_AUTO = 'auto';
public const VERTICAL_BOTTOM = 'b';
public const VERTICAL_TOP = 't';
public const VERTICAL_CENTER = 'ctr';
- /* Text direction */
+ // Text direction
public const TEXT_DIRECTION_HORIZONTAL = 'horz';
public const TEXT_DIRECTION_VERTICAL_90 = 'vert';
public const TEXT_DIRECTION_VERTICAL_270 = 'vert270';
@@ -119,7 +118,7 @@ class Alignment implements ComparableInterface
private $marginBottom = 0;
/**
- * RTL Direction Support
+ * RTL Direction Support.
*
* @var bool
*/
@@ -186,8 +185,6 @@ public function getLevel(): int
* Set Level.
*
* @param int $pValue Ranging 0 - 8
- *
- * @throws OutOfBoundsException
*/
public function setLevel(int $pValue = 0): self
{
@@ -316,19 +313,11 @@ public function setTextDirection(string $pValue = self::TEXT_DIRECTION_HORIZONTA
return $this;
}
- /**
- * @return bool
- */
public function isRTL(): bool
{
return $this->isRTL;
}
- /**
- * @param bool $value
- *
- * @return self
- */
public function setIsRTL(bool $value = false): self
{
$this->isRTL = $value;
@@ -361,7 +350,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Style/Border.php b/src/PhpPresentation/Style/Border.php
index 59b55ba3ad..287549ebfa 100644
--- a/src/PhpPresentation/Style/Border.php
+++ b/src/PhpPresentation/Style/Border.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,7 +23,7 @@
class Border implements ComparableInterface
{
- /* Line style */
+ // Line style
public const LINE_NONE = 'none';
public const LINE_SINGLE = 'sng';
public const LINE_DOUBLE = 'dbl';
@@ -32,7 +31,7 @@ class Border implements ComparableInterface
public const LINE_THINTHICK = 'thinThick';
public const LINE_TRI = 'tri';
- /* Dash style */
+ // Dash style
public const DASH_DASH = 'dash';
public const DASH_DASHDOT = 'dashDot';
public const DASH_DOT = 'dot';
@@ -87,8 +86,6 @@ public function __construct()
/**
* Get line width (in points).
- *
- * @return int
*/
public function getLineWidth(): int
{
@@ -97,10 +94,6 @@ public function getLineWidth(): int
/**
* Set line width (in points).
- *
- * @param int $pValue
- *
- * @return self
*/
public function setLineWidth(int $pValue = 1): self
{
@@ -111,8 +104,6 @@ public function setLineWidth(int $pValue = 1): self
/**
* Get line style.
- *
- * @return string
*/
public function getLineStyle(): string
{
@@ -121,10 +112,6 @@ public function getLineStyle(): string
/**
* Set line style.
- *
- * @param string $pValue
- *
- * @return self
*/
public function setLineStyle(string $pValue = self::LINE_SINGLE): self
{
@@ -138,8 +125,6 @@ public function setLineStyle(string $pValue = self::LINE_SINGLE): self
/**
* Get dash style.
- *
- * @return string
*/
public function getDashStyle(): string
{
@@ -148,10 +133,6 @@ public function getDashStyle(): string
/**
* Set dash style.
- *
- * @param string $pValue
- *
- * @return self
*/
public function setDashStyle(string $pValue = self::DASH_SOLID): self
{
@@ -165,8 +146,6 @@ public function setDashStyle(string $pValue = self::DASH_SOLID): self
/**
* Get Border Color.
- *
- * @return Color
*/
public function getColor(): ?Color
{
@@ -175,12 +154,8 @@ public function getColor(): ?Color
/**
* Set Border Color.
- *
- * @param Color|null $color
- *
- * @return self
*/
- public function setColor(Color $color = null): self
+ public function setColor(?Color $color = null): self
{
$this->color = $color;
@@ -209,7 +184,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Style/Borders.php b/src/PhpPresentation/Style/Borders.php
index 01fa0112ac..f2aefa5b8a 100644
--- a/src/PhpPresentation/Style/Borders.php
+++ b/src/PhpPresentation/Style/Borders.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,42 +29,42 @@ class Borders implements ComparableInterface
/**
* Left.
*
- * @var \PhpOffice\PhpPresentation\Style\Border
+ * @var Border
*/
private $left;
/**
* Right.
*
- * @var \PhpOffice\PhpPresentation\Style\Border
+ * @var Border
*/
private $right;
/**
* Top.
*
- * @var \PhpOffice\PhpPresentation\Style\Border
+ * @var Border
*/
private $top;
/**
* Bottom.
*
- * @var \PhpOffice\PhpPresentation\Style\Border
+ * @var Border
*/
private $bottom;
/**
* Diagonal up.
*
- * @var \PhpOffice\PhpPresentation\Style\Border
+ * @var Border
*/
private $diagonalUp;
/**
* Diagonal down.
*
- * @var \PhpOffice\PhpPresentation\Style\Border
+ * @var Border
*/
private $diagonalDown;
@@ -95,7 +94,7 @@ public function __construct()
/**
* Get Left.
*
- * @return \PhpOffice\PhpPresentation\Style\Border
+ * @return Border
*/
public function getLeft()
{
@@ -105,7 +104,7 @@ public function getLeft()
/**
* Get Right.
*
- * @return \PhpOffice\PhpPresentation\Style\Border
+ * @return Border
*/
public function getRight()
{
@@ -115,7 +114,7 @@ public function getRight()
/**
* Get Top.
*
- * @return \PhpOffice\PhpPresentation\Style\Border
+ * @return Border
*/
public function getTop()
{
@@ -125,7 +124,7 @@ public function getTop()
/**
* Get Bottom.
*
- * @return \PhpOffice\PhpPresentation\Style\Border
+ * @return Border
*/
public function getBottom()
{
@@ -135,7 +134,7 @@ public function getBottom()
/**
* Get Diagonal Up.
*
- * @return \PhpOffice\PhpPresentation\Style\Border
+ * @return Border
*/
public function getDiagonalUp()
{
@@ -145,7 +144,7 @@ public function getDiagonalUp()
/**
* Get Diagonal Down.
*
- * @return \PhpOffice\PhpPresentation\Style\Border
+ * @return Border
*/
public function getDiagonalDown()
{
@@ -176,7 +175,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Style/Bullet.php b/src/PhpPresentation/Style/Bullet.php
index dd3729d5d7..1222cc1f43 100644
--- a/src/PhpPresentation/Style/Bullet.php
+++ b/src/PhpPresentation/Style/Bullet.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -27,12 +26,12 @@
*/
class Bullet implements ComparableInterface
{
- /* Bullet types */
+ // Bullet types
public const TYPE_NONE = 'none';
public const TYPE_BULLET = 'bullet';
public const TYPE_NUMERIC = 'numeric';
- /* Numeric bullet styles */
+ // Numeric bullet styles
public const NUMERIC_DEFAULT = 'arabicPeriod';
public const NUMERIC_ALPHALCPARENBOTH = 'alphaLcParenBoth';
public const NUMERIC_ALPHAUCPARENBOTH = 'alphaUcParenBoth';
@@ -150,7 +149,7 @@ public function getBulletType()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\Style\Bullet
+ * @return Bullet
*/
public function setBulletType($pValue = self::TYPE_NONE)
{
@@ -174,7 +173,7 @@ public function getBulletFont()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\Style\Bullet
+ * @return Bullet
*/
public function setBulletFont($pValue = 'Calibri')
{
@@ -201,7 +200,7 @@ public function getBulletChar()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\Style\Bullet
+ * @return Bullet
*/
public function setBulletChar($pValue = '-')
{
@@ -225,7 +224,7 @@ public function getBulletNumericStyle()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\Style\Bullet
+ * @return Bullet
*/
public function setBulletNumericStyle($pValue = self::NUMERIC_DEFAULT)
{
@@ -249,7 +248,7 @@ public function getBulletNumericStartAt()
*
* @param int|string $pValue
*
- * @return \PhpOffice\PhpPresentation\Style\Bullet
+ * @return Bullet
*/
public function setBulletNumericStartAt($pValue = 1)
{
@@ -281,7 +280,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Style/Color.php b/src/PhpPresentation/Style/Color.php
index 56e51029f8..6e1f54da6d 100644
--- a/src/PhpPresentation/Style/Color.php
+++ b/src/PhpPresentation/Style/Color.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -27,7 +26,7 @@
*/
class Color implements ComparableInterface
{
- /* Colors */
+ // Colors
public const COLOR_BLACK = 'FF000000';
public const COLOR_WHITE = 'FFFFFFFF';
public const COLOR_RED = 'FFFF0000';
@@ -79,7 +78,7 @@ public function getARGB()
*
* @param string $pValue
*
- * @return \PhpOffice\PhpPresentation\Style\Color
+ * @return Color
*/
public function setARGB($pValue = self::COLOR_BLACK)
{
@@ -94,8 +93,6 @@ public function setARGB($pValue = self::COLOR_BLACK)
/**
* Get the alpha % of the ARGB
* Will return 100 if no ARGB.
- *
- * @return int
*/
public function getAlpha(): int
{
@@ -111,8 +108,6 @@ public function getAlpha(): int
/**
* Set the alpha % of the ARGB.
*
- * @param int $alpha
- *
* @return $this
*/
public function setAlpha(int $alpha = 100): self
@@ -140,9 +135,9 @@ public function getRGB()
{
if (6 == strlen($this->argb)) {
return $this->argb;
- } else {
- return substr($this->argb, 2);
}
+
+ return substr($this->argb, 2);
}
/**
@@ -151,7 +146,7 @@ public function getRGB()
* @param string $pValue
* @param string $pAlpha
*
- * @return \PhpOffice\PhpPresentation\Style\Color
+ * @return Color
*/
public function setRGB($pValue = '000000', $pAlpha = 'FF')
{
@@ -185,7 +180,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Style/ColorMap.php b/src/PhpPresentation/Style/ColorMap.php
index f95a3bc55b..5d67c4896a 100644
--- a/src/PhpPresentation/Style/ColorMap.php
+++ b/src/PhpPresentation/Style/ColorMap.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Style/Fill.php b/src/PhpPresentation/Style/Fill.php
index 19b92dbc2e..337ea3cb6b 100644
--- a/src/PhpPresentation/Style/Fill.php
+++ b/src/PhpPresentation/Style/Fill.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,7 +23,7 @@
class Fill implements ComparableInterface
{
- /* Fill types */
+ // Fill types
public const FILL_NONE = 'none';
public const FILL_SOLID = 'solid';
public const FILL_GRADIENT_LINEAR = 'linear';
@@ -93,8 +92,6 @@ public function __construct()
/**
* Get Fill Type.
- *
- * @return string
*/
public function getFillType(): string
{
@@ -105,8 +102,6 @@ public function getFillType(): string
* Set Fill Type.
*
* @param string $pValue Fill type
- *
- * @return self
*/
public function setFillType(string $pValue = self::FILL_NONE): self
{
@@ -117,8 +112,6 @@ public function setFillType(string $pValue = self::FILL_NONE): self
/**
* Get Rotation.
- *
- * @return float
*/
public function getRotation(): float
{
@@ -127,10 +120,6 @@ public function getRotation(): float
/**
* Set Rotation.
- *
- * @param float $pValue
- *
- * @return self
*/
public function setRotation(float $pValue = 0): self
{
@@ -141,8 +130,6 @@ public function setRotation(float $pValue = 0): self
/**
* Get Start Color.
- *
- * @return Color
*/
public function getStartColor(): Color
{
@@ -153,10 +140,6 @@ public function getStartColor(): Color
/**
* Set Start Color.
- *
- * @param Color $pValue
- *
- * @return self
*/
public function setStartColor(Color $pValue): self
{
@@ -167,8 +150,6 @@ public function setStartColor(Color $pValue): self
/**
* Get End Color.
- *
- * @return Color
*/
public function getEndColor(): Color
{
@@ -179,10 +160,6 @@ public function getEndColor(): Color
/**
* Set End Color.
- *
- * @param Color $pValue
- *
- * @return self
*/
public function setEndColor(Color $pValue): self
{
@@ -213,7 +190,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Style/Font.php b/src/PhpPresentation/Style/Font.php
index 2e25b257a4..2975df4ef1 100644
--- a/src/PhpPresentation/Style/Font.php
+++ b/src/PhpPresentation/Style/Font.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,13 +20,33 @@
namespace PhpOffice\PhpPresentation\Style;
use PhpOffice\PhpPresentation\ComparableInterface;
+use PhpOffice\PhpPresentation\Exception\InvalidParameterException;
+use PhpOffice\PhpPresentation\Exception\NotAllowedValueException;
/**
* \PhpOffice\PhpPresentation\Style\Font.
*/
class Font implements ComparableInterface
{
- /* Underline types */
+ // Capitalization type
+ public const CAPITALIZATION_NONE = 'none';
+ public const CAPITALIZATION_SMALL = 'small';
+ public const CAPITALIZATION_ALL = 'all';
+
+ // Charset type
+ public const CHARSET_DEFAULT = 0x01;
+
+ // Format type
+ public const FORMAT_LATIN = 'latin';
+ public const FORMAT_EAST_ASIAN = 'ea';
+ public const FORMAT_COMPLEX_SCRIPT = 'cs';
+
+ // Strike type
+ public const STRIKE_NONE = 'noStrike';
+ public const STRIKE_SINGLE = 'sngStrike';
+ public const STRIKE_DOUBLE = 'dblStrike';
+
+ // Underline types
public const UNDERLINE_NONE = 'none';
public const UNDERLINE_DASH = 'dash';
public const UNDERLINE_DASHHEAVY = 'dashHeavy';
@@ -47,9 +66,9 @@ class Font implements ComparableInterface
public const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
public const UNDERLINE_WORDS = 'words';
- public const FORMAT_LATIN = 'latin';
- public const FORMAT_EAST_ASIAN = 'ea';
- public const FORMAT_COMPLEX_SCRIPT = 'cs';
+ // Script sub and super values
+ public const BASELINE_SUPERSCRIPT = 300000;
+ public const BASELINE_SUBSCRIPT = -250000;
/**
* Name.
@@ -58,6 +77,27 @@ class Font implements ComparableInterface
*/
private $name = 'Calibri';
+ /**
+ * Panose.
+ *
+ * @var string
+ */
+ private $panose = '';
+
+ /**
+ * Pitch Family.
+ *
+ * @var int
+ */
+ private $pitchFamily = 0;
+
+ /**
+ * Charset.
+ *
+ * @var int
+ */
+ private $charset = self::CHARSET_DEFAULT;
+
/**
* Font Size.
*
@@ -80,18 +120,18 @@ class Font implements ComparableInterface
private $italic = false;
/**
- * Superscript.
+ * Baseline.
*
- * @var bool
+ * @var int
*/
- private $superScript = false;
+ private $baseline = 0;
/**
- * Subscript.
+ * Capitalization.
*
- * @var bool
+ * @var string
*/
- private $subScript = false;
+ private $capitalization = self::CAPITALIZATION_NONE;
/**
* Underline.
@@ -103,9 +143,9 @@ class Font implements ComparableInterface
/**
* Strikethrough.
*
- * @var bool
+ * @var string
*/
- private $strikethrough = false;
+ private $strikethrough = self::STRIKE_NONE;
/**
* Foreground color.
@@ -122,7 +162,7 @@ class Font implements ComparableInterface
private $characterSpacing = 0;
/**
- * Format
+ * Format.
*
* @var string
*/
@@ -141,9 +181,7 @@ public function __construct()
}
/**
- * Get Name
- *
- * @return string
+ * Get Name.
*/
public function getName(): string
{
@@ -151,11 +189,7 @@ public function getName(): string
}
/**
- * Set Name
- *
- * @param string $pValue
- *
- * @return self
+ * Set Name.
*/
public function setName(string $pValue = 'Calibri'): self
{
@@ -167,10 +201,77 @@ public function setName(string $pValue = 'Calibri'): self
return $this;
}
+ /**
+ * Get panose.
+ */
+ public function getPanose(): string
+ {
+ return $this->panose;
+ }
+
+ /**
+ * Set panose.
+ */
+ public function setPanose(string $pValue): self
+ {
+ if (mb_strlen($pValue) !== 10) {
+ throw new InvalidParameterException('pValue', $pValue, 'The length is not equals to 10');
+ }
+
+ $allowedChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
+ foreach (mb_str_split($pValue) as $char) {
+ if (!in_array($char, $allowedChars)) {
+ throw new InvalidParameterException(
+ 'pValue',
+ $pValue,
+ sprintf('The character "%s" is not allowed', $char)
+ );
+ }
+ }
+
+ $this->panose = $pValue;
+
+ return $this;
+ }
+
+ /**
+ * Get pitchFamily.
+ */
+ public function getPitchFamily(): int
+ {
+ return $this->pitchFamily;
+ }
+
+ /**
+ * Set pitchFamily.
+ */
+ public function setPitchFamily(int $pValue): self
+ {
+ $this->pitchFamily = $pValue;
+
+ return $this;
+ }
+
+ /**
+ * Get charset.
+ */
+ public function getCharset(): int
+ {
+ return $this->charset;
+ }
+
+ /**
+ * Set charset.
+ */
+ public function setCharset(int $pValue): self
+ {
+ $this->charset = $pValue;
+
+ return $this;
+ }
+
/**
* Get Character Spacing.
- *
- * @return float
*/
public function getCharacterSpacing(): float
{
@@ -180,10 +281,6 @@ public function getCharacterSpacing(): float
/**
* Set Character Spacing
* Value in pt.
- *
- * @param float $pValue
- *
- * @return self
*/
public function setCharacterSpacing(float $pValue = 0): self
{
@@ -212,8 +309,6 @@ public function setSize(int $pValue = 10): self
/**
* Get Bold.
- *
- * @return bool
*/
public function isBold(): bool
{
@@ -232,8 +327,6 @@ public function setBold(bool $pValue = false): self
/**
* Get Italic.
- *
- * @return bool
*/
public function isItalic(): bool
{
@@ -250,52 +343,91 @@ public function setItalic(bool $pValue = false): self
return $this;
}
+ /**
+ * Set Baseline.
+ */
+ public function setBaseline(int $pValue): self
+ {
+ $this->baseline = $pValue;
+
+ return $this;
+ }
+
+ /**
+ * Get Baseline.
+ */
+ public function getBaseline(): int
+ {
+ return $this->baseline;
+ }
+
/**
* Get SuperScript.
*
- * @return bool
+ * @deprecated getBaseline() === self::BASELINE_SUPERSCRIPT
*/
public function isSuperScript(): bool
{
- return $this->superScript;
+ return $this->getBaseline() === self::BASELINE_SUPERSCRIPT;
}
/**
* Set SuperScript.
+ *
+ * @deprecated setBaseline(self::BASELINE_SUPERSCRIPT)
*/
public function setSuperScript(bool $pValue = false): self
{
- $this->superScript = $pValue;
-
- // Set SubScript at false only if SuperScript is true
- if (true === $pValue) {
- $this->subScript = false;
- }
-
- return $this;
+ return $this->setBaseline($pValue ? self::BASELINE_SUPERSCRIPT : ($this->getBaseline() == self::BASELINE_SUBSCRIPT ? $this->getBaseline() : 0));
}
+ /**
+ * Get SubScript.
+ *
+ * @deprecated getBaseline() === self::BASELINE_SUBSCRIPT
+ */
public function isSubScript(): bool
{
- return $this->subScript;
+ return $this->getBaseline() === self::BASELINE_SUBSCRIPT;
}
+ /**
+ * Set SubScript.
+ *
+ * @deprecated setBaseline(self::BASELINE_SUBSCRIPT)
+ */
public function setSubScript(bool $pValue = false): self
{
- $this->subScript = $pValue;
+ return $this->setBaseline($pValue ? self::BASELINE_SUBSCRIPT : ($this->getBaseline() == self::BASELINE_SUPERSCRIPT ? $this->getBaseline() : 0));
+ }
+
+ /**
+ * Get Capitalization.
+ */
+ public function getCapitalization(): string
+ {
+ return $this->capitalization;
+ }
- // Set SuperScript at false only if SubScript is true
- if (true === $pValue) {
- $this->superScript = false;
+ /**
+ * Set Capitalization.
+ */
+ public function setCapitalization(string $pValue = self::CAPITALIZATION_NONE): self
+ {
+ if (!in_array(
+ $pValue,
+ [self::CAPITALIZATION_NONE, self::CAPITALIZATION_ALL, self::CAPITALIZATION_SMALL]
+ )) {
+ throw new NotAllowedValueException($pValue, [self::CAPITALIZATION_NONE, self::CAPITALIZATION_ALL, self::CAPITALIZATION_SMALL]);
}
+ $this->capitalization = $pValue;
+
return $this;
}
/**
* Get Underline.
- *
- * @return string
*/
public function getUnderline(): string
{
@@ -306,8 +438,6 @@ public function getUnderline(): string
* Set Underline.
*
* @param string $pValue Underline type
- *
- * @return self
*/
public function setUnderline(string $pValue = self::UNDERLINE_NONE): self
{
@@ -322,19 +452,42 @@ public function setUnderline(string $pValue = self::UNDERLINE_NONE): self
/**
* Get Strikethrough.
*
- * @return bool
+ * @deprecated Use `getStrikethrough`
*/
public function isStrikethrough(): bool
+ {
+ return $this->strikethrough !== self::STRIKE_NONE;
+ }
+
+ /**
+ * Get Strikethrough.
+ */
+ public function getStrikethrough(): string
{
return $this->strikethrough;
}
/**
* Set Strikethrough.
+ *
+ * @deprecated $pValue as boolean
+ *
+ * @param bool|string $pValue
+ *
+ * @return self
*/
- public function setStrikethrough(bool $pValue = false): self
+ public function setStrikethrough($pValue = false)
{
- $this->strikethrough = $pValue;
+ if (is_bool($pValue)) {
+ $pValue = $pValue ? self::STRIKE_SINGLE : self::STRIKE_NONE;
+ }
+ if (in_array($pValue, [
+ self::STRIKE_NONE,
+ self::STRIKE_SINGLE,
+ self::STRIKE_DOUBLE,
+ ])) {
+ $this->strikethrough = $pValue;
+ }
return $this;
}
@@ -358,9 +511,7 @@ public function setColor(Color $pValue): self
}
/**
- * Get format
- *
- * @return string
+ * Get format.
*/
public function getFormat(): string
{
@@ -368,11 +519,7 @@ public function getFormat(): string
}
/**
- * Set format
- *
- * @param string $value
- *
- * @return self
+ * Set format.
*/
public function setFormat(string $value = self::FORMAT_LATIN): self
{
@@ -399,8 +546,7 @@ public function getHashCode(): string
. $this->size
. ($this->bold ? 't' : 'f')
. ($this->italic ? 't' : 'f')
- . ($this->superScript ? 't' : 'f')
- . ($this->subScript ? 't' : 'f')
+ . $this->baseline
. $this->underline
. ($this->strikethrough ? 't' : 'f')
. $this->format
@@ -415,7 +561,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Style/Outline.php b/src/PhpPresentation/Style/Outline.php
index 99714e27d6..ab1cc9d698 100644
--- a/src/PhpPresentation/Style/Outline.php
+++ b/src/PhpPresentation/Style/Outline.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -31,7 +30,7 @@ class Outline
protected $fill;
/**
- * @var float
+ * @var int
*/
protected $width = 1;
@@ -52,15 +51,18 @@ public function setFill(Fill $fill): self
return $this;
}
- public function getWidth(): float
+ /**
+ * Value in pixels.
+ */
+ public function getWidth(): int
{
return $this->width;
}
/**
- * Value in points.
+ * Value in pixels.
*/
- public function setWidth(float $pValue = 1): self
+ public function setWidth(int $pValue = 1): self
{
$this->width = $pValue;
diff --git a/src/PhpPresentation/Style/SchemeColor.php b/src/PhpPresentation/Style/SchemeColor.php
index 040e103b13..04e7244256 100644
--- a/src/PhpPresentation/Style/SchemeColor.php
+++ b/src/PhpPresentation/Style/SchemeColor.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Style/Shadow.php b/src/PhpPresentation/Style/Shadow.php
index 826dd47d95..af3b3e1c38 100644
--- a/src/PhpPresentation/Style/Shadow.php
+++ b/src/PhpPresentation/Style/Shadow.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,13 +20,18 @@
namespace PhpOffice\PhpPresentation\Style;
use PhpOffice\PhpPresentation\ComparableInterface;
+use PhpOffice\PhpPresentation\Exception\NotAllowedValueException;
/**
* \PhpOffice\PhpPresentation\Style\Shadow.
*/
class Shadow implements ComparableInterface
{
- /* Shadow alignment */
+ public const TYPE_SHADOW_INNER = 'innerShdw';
+ public const TYPE_SHADOW_OUTER = 'outerShdw';
+ public const TYPE_REFLECTION = 'reflection';
+
+ // Shadow alignment
public const SHADOW_BOTTOM = 'b';
public const SHADOW_BOTTOM_LEFT = 'bl';
public const SHADOW_BOTTOM_RIGHT = 'br';
@@ -73,7 +77,7 @@ class Shadow implements ComparableInterface
private $alignment = self::SHADOW_BOTTOM_RIGHT;
/**
- * @var Color|null
+ * @var null|Color
*/
private $color;
@@ -82,6 +86,11 @@ class Shadow implements ComparableInterface
*/
private $alpha = 50;
+ /**
+ * @var string
+ */
+ private $type = self::TYPE_SHADOW_OUTER;
+
/**
* Hash index.
*
@@ -200,7 +209,7 @@ public function getColor(): ?Color
/**
* Set Color.
*/
- public function setColor(Color $pValue = null): self
+ public function setColor(?Color $pValue = null): self
{
$this->color = $pValue;
@@ -225,6 +234,31 @@ public function setAlpha(int $pValue = 0): self
return $this;
}
+ /**
+ * Get Type.
+ */
+ public function getType(): string
+ {
+ return $this->type;
+ }
+
+ /**
+ * Set Type.
+ */
+ public function setType(string $pValue = self::TYPE_SHADOW_OUTER): self
+ {
+ if (!in_array(
+ $pValue,
+ [self::TYPE_REFLECTION, self::TYPE_SHADOW_INNER, self::TYPE_SHADOW_OUTER]
+ )) {
+ throw new NotAllowedValueException($pValue, [self::TYPE_REFLECTION, self::TYPE_SHADOW_INNER, self::TYPE_SHADOW_OUTER]);
+ }
+
+ $this->type = $pValue;
+
+ return $this;
+ }
+
/**
* Get hash code.
*
@@ -232,7 +266,7 @@ public function setAlpha(int $pValue = 0): self
*/
public function getHashCode(): string
{
- return md5(($this->visible ? 't' : 'f') . $this->blurRadius . $this->distance . $this->direction . $this->alignment . $this->color->getHashCode() . $this->alpha . __CLASS__);
+ return md5(($this->visible ? 't' : 'f') . $this->blurRadius . $this->distance . $this->direction . $this->alignment . $this->type . $this->color->getHashCode() . $this->alpha . __CLASS__);
}
/**
@@ -241,7 +275,7 @@ public function getHashCode(): string
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
*
- * @return int|null Hash index
+ * @return null|int Hash index
*/
public function getHashIndex(): ?int
{
diff --git a/src/PhpPresentation/Style/TextStyle.php b/src/PhpPresentation/Style/TextStyle.php
index 64d7c5abf2..2ce0555acb 100644
--- a/src/PhpPresentation/Style/TextStyle.php
+++ b/src/PhpPresentation/Style/TextStyle.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,10 +27,12 @@ class TextStyle
* @var array
*/
protected $bodyStyle = [];
+
/**
* @var array
*/
protected $titleStyle = [];
+
/**
* @var array
*/
@@ -39,8 +40,6 @@ class TextStyle
/**
* TextStyle constructor.
- *
- * @param bool $default
*/
public function __construct(bool $default = true)
{
@@ -72,7 +71,7 @@ public function __construct(bool $default = true)
private function checkLvl(?int $lvl): bool
{
- if (is_null($lvl) || $lvl > 9) {
+ if (null === $lvl || $lvl > 9) {
return false;
}
@@ -97,9 +96,6 @@ public function setTitleStyleAtLvl(RichTextParagraph $style, ?int $lvl): self
return $this;
}
- /**
- * @return TextStyle
- */
public function setOtherStyleAtLvl(RichTextParagraph $style, ?int $lvl): self
{
if ($this->checkLvl($lvl)) {
diff --git a/src/PhpPresentation/Traits/ShapeCollection.php b/src/PhpPresentation/Traits/ShapeCollection.php
new file mode 100644
index 0000000000..6c7582cb1c
--- /dev/null
+++ b/src/PhpPresentation/Traits/ShapeCollection.php
@@ -0,0 +1,96 @@
+
+ */
+ protected $shapeCollection = [];
+
+ /**
+ * Get collection of shapes.
+ *
+ * @return array
+ */
+ public function getShapeCollection(): array
+ {
+ return $this->shapeCollection;
+ }
+
+ /**
+ * Search into collection of shapes for a name or/and a type.
+ *
+ * @return array
+ */
+ public function searchShapes(?string $name = null, ?string $type = null): array
+ {
+ $found = [];
+ foreach ($this->getShapeCollection() as $shape) {
+ if ($name && $shape->getName() !== $name) {
+ continue;
+ }
+ if ($type && get_class($shape) !== $type) {
+ continue;
+ }
+
+ $found[] = $shape;
+ }
+
+ return $found;
+ }
+
+ /**
+ * Get collection of shapes.
+ *
+ * @param array $shapeCollection
+ */
+ public function setShapeCollection(array $shapeCollection = []): self
+ {
+ $this->shapeCollection = $shapeCollection;
+
+ return $this;
+ }
+
+ /**
+ * @return static
+ */
+ public function addShape(AbstractShape $shape)
+ {
+ $this->shapeCollection[] = $shape;
+
+ return $this;
+ }
+
+ /**
+ * @return static
+ */
+ public function unsetShape(int $key)
+ {
+ unset($this->shapeCollection[$key]);
+
+ return $this;
+ }
+}
diff --git a/src/PhpPresentation/Writer/AbstractDecoratorWriter.php b/src/PhpPresentation/Writer/AbstractDecoratorWriter.php
index 9b12bf9364..ddcce2a313 100644
--- a/src/PhpPresentation/Writer/AbstractDecoratorWriter.php
+++ b/src/PhpPresentation/Writer/AbstractDecoratorWriter.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,13 +25,10 @@
abstract class AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
abstract public function render(): ZipInterface;
/**
- * @var \PhpOffice\PhpPresentation\HashTable
+ * @var HashTable
*/
protected $oHashTable;
diff --git a/src/PhpPresentation/Writer/AbstractWriter.php b/src/PhpPresentation/Writer/AbstractWriter.php
index 14179efc39..edbfb89c83 100644
--- a/src/PhpPresentation/Writer/AbstractWriter.php
+++ b/src/PhpPresentation/Writer/AbstractWriter.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +19,6 @@
namespace PhpOffice\PhpPresentation\Writer;
-use ArrayIterator;
use PhpOffice\Common\Adapter\Zip\ZipInterface;
use PhpOffice\PhpPresentation\AbstractShape;
use PhpOffice\PhpPresentation\HashTable;
@@ -41,12 +39,12 @@ abstract class AbstractWriter
/**
* Private PhpPresentation.
*
- * @var PhpPresentation|null
+ * @var null|PhpPresentation
*/
protected $oPresentation;
/**
- * @var ZipInterface|null
+ * @var null|ZipInterface
*/
protected $oZipAdapter;
@@ -69,11 +67,11 @@ public function getPhpPresentation(): ?PhpPresentation
/**
* Get PhpPresentation object.
*
- * @param PhpPresentation|null $pPhpPresentation PhpPresentation object
+ * @param null|PhpPresentation $pPhpPresentation PhpPresentation object
*
* @return self
*/
- public function setPhpPresentation(PhpPresentation $pPhpPresentation = null)
+ public function setPhpPresentation(?PhpPresentation $pPhpPresentation = null)
{
$this->oPresentation = $pPhpPresentation;
@@ -111,13 +109,13 @@ protected function allDrawings(): array
// Get an array of all slide layouts
$aSlideLayouts = [];
- array_walk_recursive($aSlideMasterLayouts, function ($oSlideLayout) use (&$aSlideLayouts) {
+ array_walk_recursive($aSlideMasterLayouts, function ($oSlideLayout) use (&$aSlideLayouts): void {
$aSlideLayouts[] = $oSlideLayout;
});
// Loop through PhpPresentation
foreach (array_merge($this->getPhpPresentation()->getAllSlides(), $aSlideMasters, $aSlideLayouts) as $oSlide) {
- $arrayReturn = $this->iterateCollection($oSlide->getShapeCollection()->getIterator());
+ $arrayReturn = $this->iterateCollection($oSlide->getShapeCollection());
$aDrawings = array_merge($aDrawings, $arrayReturn);
}
@@ -125,28 +123,23 @@ protected function allDrawings(): array
}
/**
- * @param ArrayIterator $oIterator
+ * @param array $collection
*
* @return array
*/
- private function iterateCollection(ArrayIterator $oIterator): array
+ private function iterateCollection(array $collection): array
{
$arrayReturn = [];
- if ($oIterator->count() <= 0) {
- return $arrayReturn;
- }
- while ($oIterator->valid()) {
- $oShape = $oIterator->current();
+ foreach ($collection as $oShape) {
if ($oShape instanceof AbstractDrawingAdapter) {
$arrayReturn[] = $oShape;
} elseif ($oShape instanceof Chart) {
$arrayReturn[] = $oShape;
} elseif ($oShape instanceof Group) {
- $arrayGroup = $this->iterateCollection($oShape->getShapeCollection()->getIterator());
+ $arrayGroup = $this->iterateCollection($oShape->getShapeCollection());
$arrayReturn = array_merge($arrayReturn, $arrayGroup);
}
- $oIterator->next();
}
return $arrayReturn;
diff --git a/src/PhpPresentation/Writer/ODPresentation.php b/src/PhpPresentation/Writer/ODPresentation.php
index a963259dbe..f142fe06ce 100644
--- a/src/PhpPresentation/Writer/ODPresentation.php
+++ b/src/PhpPresentation/Writer/ODPresentation.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,6 +27,7 @@
use PhpOffice\PhpPresentation\Exception\InvalidParameterException;
use PhpOffice\PhpPresentation\HashTable;
use PhpOffice\PhpPresentation\PhpPresentation;
+use ReflectionClass;
/**
* ODPresentation writer.
@@ -55,10 +55,8 @@ class ODPresentation extends AbstractWriter implements WriterInterface
/**
* Create a new \PhpOffice\PhpPresentation\Writer\ODPresentation.
- *
- * @param PhpPresentation $pPhpPresentation
*/
- public function __construct(PhpPresentation $pPhpPresentation = null)
+ public function __construct(?PhpPresentation $pPhpPresentation = null)
{
// Assign PhpPresentation
$this->setPhpPresentation($pPhpPresentation ?? new PhpPresentation());
@@ -74,10 +72,6 @@ public function __construct(PhpPresentation $pPhpPresentation = null)
/**
* Save PhpPresentation to file.
- *
- * @throws FileCopyException
- * @throws FileRemoveException
- * @throws InvalidParameterException
*/
public function save(string $pFilename): void
{
@@ -87,7 +81,7 @@ public function save(string $pFilename): void
// If $pFilename is php://output or php://stdout, make it a temporary file...
$originalFilename = $pFilename;
if ('php://output' == strtolower($pFilename) || 'php://stdout' == strtolower($pFilename)) {
- $pFilename = @tempnam('./', 'phppttmp');
+ $pFilename = @tempnam($this->diskCachingDirectory, 'phppttmp');
if ('' == $pFilename) {
$pFilename = $originalFilename;
}
@@ -105,14 +99,14 @@ public function save(string $pFilename): void
$arrayChart = [];
$arrayFiles = [];
- $oDir = new DirectoryIterator(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ODPresentation');
+ $oDir = new DirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . 'ODPresentation');
foreach ($oDir as $oFile) {
if (!$oFile->isFile()) {
continue;
}
$class = __NAMESPACE__ . '\\ODPresentation\\' . $oFile->getBasename('.php');
- $class = new \ReflectionClass($class);
+ $class = new ReflectionClass($class);
if ($class->isAbstract() || !$class->isSubclassOf('PhpOffice\PhpPresentation\Writer\ODPresentation\AbstractDecoratorWriter')) {
continue;
@@ -160,18 +154,15 @@ public function hasDiskCaching()
/**
* Set use disk caching where possible?
*
- * @param bool $pValue
* @param string $directory Disk caching directory
*
- * @throws DirectoryNotFoundException
- *
- * @return \PhpOffice\PhpPresentation\Writer\ODPresentation
+ * @return ODPresentation
*/
- public function setUseDiskCaching(bool $pValue = false, string $directory = null)
+ public function setUseDiskCaching(bool $pValue = false, ?string $directory = null)
{
$this->useDiskCaching = $pValue;
- if (!is_null($directory)) {
+ if (null !== $directory) {
if (!is_dir($directory)) {
throw new DirectoryNotFoundException($directory);
}
diff --git a/src/PhpPresentation/Writer/ODPresentation/AbstractDecoratorWriter.php b/src/PhpPresentation/Writer/ODPresentation/AbstractDecoratorWriter.php
index 7683106b67..98c6064ea9 100644
--- a/src/PhpPresentation/Writer/ODPresentation/AbstractDecoratorWriter.php
+++ b/src/PhpPresentation/Writer/ODPresentation/AbstractDecoratorWriter.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Writer/ODPresentation/Content.php b/src/PhpPresentation/Writer/ODPresentation/Content.php
index bf9fc5b655..33de96a407 100644
--- a/src/PhpPresentation/Writer/ODPresentation/Content.php
+++ b/src/PhpPresentation/Writer/ODPresentation/Content.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,7 +27,6 @@
use PhpOffice\PhpPresentation\Shape\Chart;
use PhpOffice\PhpPresentation\Shape\Comment;
use PhpOffice\PhpPresentation\Shape\Drawing\AbstractDrawingAdapter;
-use PhpOffice\PhpPresentation\Shape\Drawing as ShapeDrawing;
use PhpOffice\PhpPresentation\Shape\Group;
use PhpOffice\PhpPresentation\Shape\Line;
use PhpOffice\PhpPresentation\Shape\Media;
@@ -179,7 +177,7 @@ protected function writeContent(): string
$oAlign = $item['oAlign_' . $level];
// text:list-level-style-bullet
$objWriter->startElement('text:list-level-style-bullet');
- $objWriter->writeAttribute('text:level', intval($level) + 1);
+ $objWriter->writeAttribute('text:level', (int) $level + 1);
$objWriter->writeAttribute('text:bullet-char', $oStyle->getBulletChar());
// style:list-level-properties
$objWriter->startElement('style:list-level-properties');
@@ -235,21 +233,27 @@ protected function writeContent(): string
switch ($item->getAlignment()->getHorizontal()) {
case Alignment::HORIZONTAL_LEFT:
$objWriter->writeAttribute('fo:text-align', 'left');
+
break;
case Alignment::HORIZONTAL_RIGHT:
$objWriter->writeAttribute('fo:text-align', 'right');
+
break;
case Alignment::HORIZONTAL_CENTER:
$objWriter->writeAttribute('fo:text-align', 'center');
+
break;
case Alignment::HORIZONTAL_JUSTIFY:
$objWriter->writeAttribute('fo:text-align', 'justify');
+
break;
case Alignment::HORIZONTAL_DISTRIBUTED:
$objWriter->writeAttribute('fo:text-align', 'justify');
+
break;
default:
$objWriter->writeAttribute('fo:text-align', 'left');
+
break;
}
$objWriter->writeAttribute(
@@ -271,6 +275,20 @@ protected function writeContent(): string
// style:style > style:text-properties
$objWriter->startElement('style:text-properties');
$objWriter->writeAttribute('fo:color', '#' . $item->getFont()->getColor()->getRGB());
+ switch ($item->getFont()->getCapitalization()) {
+ case Font::CAPITALIZATION_NONE:
+ $objWriter->writeAttribute('fo:text-transform', 'none');
+
+ break;
+ case Font::CAPITALIZATION_ALL:
+ $objWriter->writeAttribute('fo:text-transform', 'uppercase');
+
+ break;
+ case Font::CAPITALIZATION_SMALL:
+ $objWriter->writeAttribute('fo:text-transform', 'lowercase');
+
+ break;
+ }
switch ($item->getFont()->getFormat()) {
case Font::FORMAT_LATIN:
$objWriter->writeAttribute('fo:font-family', $item->getFont()->getName());
@@ -278,6 +296,7 @@ protected function writeContent(): string
$objWriter->writeAttributeIf($item->getFont()->isBold(), 'fo:font-weight', 'bold');
$objWriter->writeAttribute('fo:language', ($item->getLanguage() ? $item->getLanguage() : 'en'));
$objWriter->writeAttribute('style:script-type', 'latin');
+
break;
case Font::FORMAT_EAST_ASIAN:
$objWriter->writeAttribute('style:font-family-asian', $item->getFont()->getName());
@@ -285,6 +304,7 @@ protected function writeContent(): string
$objWriter->writeAttributeIf($item->getFont()->isBold(), 'style:font-weight-asian', 'bold');
$objWriter->writeAttribute('style:language-asian', ($item->getLanguage() ? $item->getLanguage() : 'en'));
$objWriter->writeAttribute('style:script-type', 'asian');
+
break;
case Font::FORMAT_COMPLEX_SCRIPT:
$objWriter->writeAttribute('style:font-family-complex', $item->getFont()->getName());
@@ -292,6 +312,7 @@ protected function writeContent(): string
$objWriter->writeAttributeIf($item->getFont()->isBold(), 'style:font-weight-complex', 'bold');
$objWriter->writeAttribute('style:language-complex', ($item->getLanguage() ? $item->getLanguage() : 'en'));
$objWriter->writeAttribute('style:script-type', 'complex');
+
break;
}
@@ -318,7 +339,7 @@ protected function writeContent(): string
$pSlide = $this->getPresentation()->getSlide($i);
$objWriter->startElement('draw:page');
$name = $pSlide->getName();
- if (!is_null($name)) {
+ if (null !== $name) {
$objWriter->writeAttribute('draw:name', $name);
}
$objWriter->writeAttribute('draw:master-page-name', 'Standard');
@@ -426,10 +447,8 @@ protected function writeShapeMedia(XMLWriter $objWriter, Media $shape): void
/**
* Write picture.
- *
- * @param AbstractDrawingAdapter $shape
*/
- protected function writeShapeDrawing(XMLWriter $objWriter, ShapeDrawing\AbstractDrawingAdapter $shape): void
+ protected function writeShapeDrawing(XMLWriter $objWriter, AbstractDrawingAdapter $shape): void
{
// draw:frame
$objWriter->startElement('draw:frame');
@@ -543,13 +562,13 @@ protected function writeShapeTxt(XMLWriter $objWriter, RichText $shape): void
}
}
$objWriter->endElement();
- //===============================================
- // Bullet list
- //===============================================
+ //===============================================
+ // Bullet list
+ //===============================================
} elseif ('bullet' == $paragraph->getBulletStyle()->getBulletType()) {
$bCstShpHasBullet = true;
// Open the bullet list
- if ('bullet' != $sCstShpLastBullet || ($sCstShpLastBullet == $paragraph->getBulletStyle()->getBulletType() && $iCstShpLastBulletLvl < $paragraph->getAlignment()->getLevel())) {
+ if ('bullet' != $sCstShpLastBullet || $iCstShpLastBulletLvl < $paragraph->getAlignment()->getLevel()) {
// text:list
$objWriter->startElement('text:list');
$objWriter->writeAttribute('text:style-name', 'L_' . $paragraph->getBulletStyle()->getHashCode());
@@ -633,9 +652,7 @@ protected function writeShapeTxt(XMLWriter $objWriter, RichText $shape): void
*/
protected function writeShapeComment(XMLWriter $objWriter, Comment $oShape): void
{
- /*
- * Note : This element is not valid in the Schema 1.2
- */
+ // Note : This element is not valid in the Schema 1.2
// officeooo:annotation
$objWriter->startElement('officeooo:annotation');
$objWriter->writeAttribute('svg:x', number_format(CommonDrawing::pixelsToCentimeters((int) $oShape->getOffsetX()), 2, '.', '') . 'cm');
@@ -874,15 +891,18 @@ protected function writeTxtStyle(XMLWriter $objWriter, RichText $shape): void
case Fill::FILL_GRADIENT_PATH:
$objWriter->writeAttribute('draw:fill', 'gradient');
$objWriter->writeAttribute('draw:fill-gradient-name', 'gradient_' . $shape->getFill()->getHashCode());
+
break;
case Fill::FILL_SOLID:
$objWriter->writeAttribute('draw:fill', 'solid');
$objWriter->writeAttribute('draw:fill-color', '#' . $shape->getFill()->getStartColor()->getRGB());
+
break;
case Fill::FILL_NONE:
default:
$objWriter->writeAttribute('draw:fill', 'none');
$objWriter->writeAttribute('draw:fill-color', '#' . $shape->getFill()->getStartColor()->getRGB());
+
break;
}
// Border
@@ -894,6 +914,7 @@ protected function writeTxtStyle(XMLWriter $objWriter, RichText $shape): void
switch ($shape->getBorder()->getDashStyle()) {
case Border::DASH_SOLID:
$objWriter->writeAttribute('draw:stroke', 'solid');
+
break;
case Border::DASH_DASH:
case Border::DASH_DASHDOT:
@@ -907,9 +928,11 @@ protected function writeTxtStyle(XMLWriter $objWriter, RichText $shape): void
case Border::DASH_SYSDOT:
$objWriter->writeAttribute('draw:stroke', 'dash');
$objWriter->writeAttribute('draw:stroke-dash', 'strokeDash_' . $shape->getBorder()->getDashStyle());
+
break;
default:
$objWriter->writeAttribute('draw:stroke', 'none');
+
break;
}
}
@@ -995,12 +1018,15 @@ protected function writeLineStyle(XMLWriter $objWriter, Line $shape): void
switch ($shape->getBorder()->getLineStyle()) {
case Border::LINE_NONE:
$objWriter->writeAttribute('draw:stroke', 'none');
+
break;
case Border::LINE_SINGLE:
$objWriter->writeAttribute('draw:stroke', 'solid');
+
break;
default:
$objWriter->writeAttribute('draw:stroke', 'none');
+
break;
}
$objWriter->writeAttribute('svg:stroke-color', '#' . $shape->getBorder()->getColor()->getRGB());
@@ -1034,9 +1060,7 @@ protected function writeTableStyle(XMLWriter $objWriter, Table $shape): void
$objWriter->writeAttribute('style:name', 'gr' . $this->shapeId . 'r' . $keyRow . 'c' . $keyCell);
$objWriter->writeAttribute('style:family', 'table-cell');
- /*
- * Note : This element is not valid in the Schema 1.2
- */
+ // Note : This element is not valid in the Schema 1.2
// style:graphic-properties
if (Fill::FILL_NONE != $shapeCell->getFill()->getFillType()) {
$objWriter->startElement('style:graphic-properties');
@@ -1157,166 +1181,214 @@ protected function writeStyleSlide(XMLWriter $objWriter, Slide $slide, int $incP
// style:style/style:drawing-page-properties
$objWriter->startElement('style:drawing-page-properties');
$objWriter->writeAttributeIf(!$slide->isVisible(), 'presentation:visibility', 'hidden');
- if (!is_null($oTransition = $slide->getTransition())) {
+ if (null !== ($oTransition = $slide->getTransition())) {
$objWriter->writeAttribute('presentation:duration', 'PT' . number_format($oTransition->getAdvanceTimeTrigger() / 1000, 6, '.', '') . 'S');
$objWriter->writeAttributeIf($oTransition->hasManualTrigger(), 'presentation:transition-type', 'manual');
$objWriter->writeAttributeIf($oTransition->hasTimeTrigger(), 'presentation:transition-type', 'automatic');
switch ($oTransition->getSpeed()) {
case Transition::SPEED_FAST:
$objWriter->writeAttribute('presentation:transition-speed', 'fast');
+
break;
case Transition::SPEED_MEDIUM:
$objWriter->writeAttribute('presentation:transition-speed', 'medium');
+
break;
case Transition::SPEED_SLOW:
$objWriter->writeAttribute('presentation:transition-speed', 'slow');
+
break;
}
- /*
- * http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#property-presentation_transition-style
- */
+ // http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#property-presentation_transition-style
switch ($oTransition->getTransitionType()) {
case Transition::TRANSITION_BLINDS_HORIZONTAL:
$objWriter->writeAttribute('presentation:transition-style', 'horizontal-stripes');
+
break;
case Transition::TRANSITION_BLINDS_VERTICAL:
$objWriter->writeAttribute('presentation:transition-style', 'vertical-stripes');
+
break;
case Transition::TRANSITION_CHECKER_HORIZONTAL:
$objWriter->writeAttribute('presentation:transition-style', 'horizontal-checkerboard');
+
break;
case Transition::TRANSITION_CHECKER_VERTICAL:
$objWriter->writeAttribute('presentation:transition-style', 'vertical-checkerboard');
+
break;
case Transition::TRANSITION_CIRCLE:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_COMB_HORIZONTAL:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_COMB_VERTICAL:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_COVER_DOWN:
$objWriter->writeAttribute('presentation:transition-style', 'uncover-to-bottom');
+
break;
case Transition::TRANSITION_COVER_LEFT:
$objWriter->writeAttribute('presentation:transition-style', 'uncover-to-left');
+
break;
case Transition::TRANSITION_COVER_LEFT_DOWN:
$objWriter->writeAttribute('presentation:transition-style', 'uncover-to-lowerleft');
+
break;
case Transition::TRANSITION_COVER_LEFT_UP:
$objWriter->writeAttribute('presentation:transition-style', 'uncover-to-upperleft');
+
break;
case Transition::TRANSITION_COVER_RIGHT:
$objWriter->writeAttribute('presentation:transition-style', 'uncover-to-right');
+
break;
case Transition::TRANSITION_COVER_RIGHT_DOWN:
$objWriter->writeAttribute('presentation:transition-style', 'uncover-to-lowerright');
+
break;
case Transition::TRANSITION_COVER_RIGHT_UP:
$objWriter->writeAttribute('presentation:transition-style', 'uncover-to-upperright');
+
break;
case Transition::TRANSITION_COVER_UP:
$objWriter->writeAttribute('presentation:transition-style', 'uncover-to-top');
+
break;
case Transition::TRANSITION_CUT:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_DIAMOND:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_DISSOLVE:
$objWriter->writeAttribute('presentation:transition-style', 'dissolve');
+
break;
case Transition::TRANSITION_FADE:
$objWriter->writeAttribute('presentation:transition-style', 'fade-from-center');
+
break;
case Transition::TRANSITION_NEWSFLASH:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_PLUS:
$objWriter->writeAttribute('presentation:transition-style', 'close');
+
break;
case Transition::TRANSITION_PULL_DOWN:
$objWriter->writeAttribute('presentation:transition-style', 'stretch-from-bottom');
+
break;
case Transition::TRANSITION_PULL_LEFT:
$objWriter->writeAttribute('presentation:transition-style', 'stretch-from-left');
+
break;
case Transition::TRANSITION_PULL_RIGHT:
$objWriter->writeAttribute('presentation:transition-style', 'stretch-from-right');
+
break;
case Transition::TRANSITION_PULL_UP:
$objWriter->writeAttribute('presentation:transition-style', 'stretch-from-top');
+
break;
case Transition::TRANSITION_PUSH_DOWN:
$objWriter->writeAttribute('presentation:transition-style', 'roll-from-bottom');
+
break;
case Transition::TRANSITION_PUSH_LEFT:
$objWriter->writeAttribute('presentation:transition-style', 'roll-from-left');
+
break;
case Transition::TRANSITION_PUSH_RIGHT:
$objWriter->writeAttribute('presentation:transition-style', 'roll-from-right');
+
break;
case Transition::TRANSITION_PUSH_UP:
$objWriter->writeAttribute('presentation:transition-style', 'roll-from-top');
+
break;
case Transition::TRANSITION_RANDOM:
$objWriter->writeAttribute('presentation:transition-style', 'random');
+
break;
case Transition::TRANSITION_RANDOMBAR_HORIZONTAL:
$objWriter->writeAttribute('presentation:transition-style', 'horizontal-lines');
+
break;
case Transition::TRANSITION_RANDOMBAR_VERTICAL:
$objWriter->writeAttribute('presentation:transition-style', 'vertical-lines');
+
break;
case Transition::TRANSITION_SPLIT_IN_HORIZONTAL:
$objWriter->writeAttribute('presentation:transition-style', 'close-horizontal');
+
break;
case Transition::TRANSITION_SPLIT_OUT_HORIZONTAL:
$objWriter->writeAttribute('presentation:transition-style', 'open-horizontal');
+
break;
case Transition::TRANSITION_SPLIT_IN_VERTICAL:
$objWriter->writeAttribute('presentation:transition-style', 'close-vertical');
+
break;
case Transition::TRANSITION_SPLIT_OUT_VERTICAL:
$objWriter->writeAttribute('presentation:transition-style', 'open-vertical');
+
break;
case Transition::TRANSITION_STRIPS_LEFT_DOWN:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_STRIPS_LEFT_UP:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_STRIPS_RIGHT_DOWN:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_STRIPS_RIGHT_UP:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_WEDGE:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_WIPE_DOWN:
$objWriter->writeAttribute('presentation:transition-style', 'fade-from-bottom');
+
break;
case Transition::TRANSITION_WIPE_LEFT:
$objWriter->writeAttribute('presentation:transition-style', 'fade-from-left');
+
break;
case Transition::TRANSITION_WIPE_RIGHT:
$objWriter->writeAttribute('presentation:transition-style', 'fade-from-right');
+
break;
case Transition::TRANSITION_WIPE_UP:
$objWriter->writeAttribute('presentation:transition-style', 'fade-from-top');
+
break;
case Transition::TRANSITION_ZOOM_IN:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
case Transition::TRANSITION_ZOOM_OUT:
$objWriter->writeAttribute('presentation:transition-style', 'none');
+
break;
}
}
@@ -1347,10 +1419,12 @@ protected function writeStylePartFill(XMLWriter $objWriter, ?Fill $oFill): void
case Fill::FILL_SOLID:
$objWriter->writeAttribute('draw:fill', 'solid');
$objWriter->writeAttribute('draw:fill-color', '#' . $oFill->getStartColor()->getRGB());
+
break;
case Fill::FILL_NONE:
default:
$objWriter->writeAttribute('draw:fill', 'none');
+
break;
}
}
diff --git a/src/PhpPresentation/Writer/ODPresentation/Meta.php b/src/PhpPresentation/Writer/ODPresentation/Meta.php
index d976503e8b..cc1ca03ab4 100644
--- a/src/PhpPresentation/Writer/ODPresentation/Meta.php
+++ b/src/PhpPresentation/Writer/ODPresentation/Meta.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,9 +25,6 @@
class Meta extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
// Create XML writer
@@ -83,20 +79,24 @@ public function render(): ZipInterface
case DocumentProperties::PROPERTY_TYPE_FLOAT:
$objWriter->writeAttribute('meta:value-type', 'float');
$objWriter->writeRaw((string) $propertyValue);
+
break;
case DocumentProperties::PROPERTY_TYPE_BOOLEAN:
$objWriter->writeAttribute('meta:value-type', 'boolean');
$objWriter->writeRaw($propertyValue ? 'true' : 'false');
+
break;
case DocumentProperties::PROPERTY_TYPE_DATE:
$objWriter->writeAttribute('meta:value-type', 'date');
$objWriter->writeRaw(date(DATE_W3C, (int) $propertyValue));
+
break;
case DocumentProperties::PROPERTY_TYPE_STRING:
case DocumentProperties::PROPERTY_TYPE_UNKNOWN:
default:
$objWriter->writeAttribute('meta:value-type', 'string');
$objWriter->writeRaw((string) $propertyValue);
+
break;
}
$objWriter->endElement();
diff --git a/src/PhpPresentation/Writer/ODPresentation/MetaInfManifest.php b/src/PhpPresentation/Writer/ODPresentation/MetaInfManifest.php
index 49f023e763..b97f3d6f44 100644
--- a/src/PhpPresentation/Writer/ODPresentation/MetaInfManifest.php
+++ b/src/PhpPresentation/Writer/ODPresentation/MetaInfManifest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -27,9 +26,6 @@
class MetaInfManifest extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
// Create XML writer
diff --git a/src/PhpPresentation/Writer/ODPresentation/Mimetype.php b/src/PhpPresentation/Writer/ODPresentation/Mimetype.php
index 80101241df..5a70604170 100644
--- a/src/PhpPresentation/Writer/ODPresentation/Mimetype.php
+++ b/src/PhpPresentation/Writer/ODPresentation/Mimetype.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,9 +23,6 @@
class Mimetype extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
$this->getZip()->addFromString('mimetype', 'application/vnd.oasis.opendocument.presentation');
diff --git a/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php b/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php
index 12ded07239..e2f896c2af 100644
--- a/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php
+++ b/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -48,22 +47,27 @@ class ObjectsChart extends AbstractDecoratorWriter
* @var XMLWriter
*/
protected $xmlContent;
+
/**
* @var mixed
*/
protected $arrayData;
+
/**
* @var mixed
*/
protected $arrayTitle;
+
/**
* @var int
*/
protected $numData;
+
/**
* @var int
*/
protected $numSeries;
+
/**
* @var string
*/
@@ -307,7 +311,7 @@ protected function writeAxisStyle(Chart $chart): void
$this->writeGridlineStyle($chart->getPlotArea()->getAxisY()->getMinorGridlines(), 'styleAxisYGridlinesMinor');
}
- protected function writeAxisMainStyle(Chart\Axis $axis, string $styleName, AbstractType $chartType): void
+ protected function writeAxisMainStyle(Axis $axis, string $styleName, AbstractType $chartType): void
{
// style:style
$this->xmlContent->startElement('style:style');
@@ -326,15 +330,18 @@ protected function writeAxisMainStyle(Chart\Axis $axis, string $styleName, Abstr
switch ($axis->getTickLabelPosition()) {
case Axis::TICK_LABEL_POSITION_NEXT_TO:
$this->xmlContent->writeAttribute('chart:axis-label-position', 'near-axis');
+
break;
case Axis::TICK_LABEL_POSITION_HIGH:
$this->xmlContent->writeAttribute('chart:axis-position', '0');
$this->xmlContent->writeAttribute('chart:axis-label-position', 'outside-end');
+
break;
case Axis::TICK_LABEL_POSITION_LOW:
$this->xmlContent->writeAttribute('chart:axis-position', '0');
$this->xmlContent->writeAttribute('chart:axis-label-position', 'outside-start');
$this->xmlContent->writeAttribute('chart:tick-mark-position', 'at-axis');
+
break;
}
$this->xmlContent->writeAttributeIf($chartType instanceof Radar && $styleName == 'styleAxisX', 'chart:reverse-direction', 'true');
@@ -356,7 +363,7 @@ protected function writeAxisMainStyle(Chart\Axis $axis, string $styleName, Abstr
$this->xmlContent->endElement();
}
- protected function writeAxisTitleStyle(Chart\Axis $axis, string $styleName): void
+ protected function writeAxisTitleStyle(Axis $axis, string $styleName): void
{
// style:style
$this->xmlContent->startElement('style:style');
@@ -449,19 +456,24 @@ protected function writeLegend(Chart $chart): void
switch ($chart->getLegend()->getPosition()) {
case Chart\Legend::POSITION_BOTTOM:
$position = 'bottom';
+
break;
case Chart\Legend::POSITION_LEFT:
$position = 'start';
+
break;
case Chart\Legend::POSITION_TOP:
$position = 'top';
+
break;
case Chart\Legend::POSITION_TOPRIGHT:
$position = 'top-end';
+
break;
case Chart\Legend::POSITION_RIGHT:
default:
$position = 'end';
+
break;
}
$this->xmlContent->writeAttribute('chart:legend-position', $position);
@@ -573,12 +585,15 @@ protected function writePlotAreaStyle(Chart $chart): void
switch ($chart->getDisplayBlankAs()) {
case Chart::BLANKAS_ZERO:
$this->xmlContent->writeAttribute('chart:treat-empty-cells', 'use-zero');
+
break;
case Chart::BLANKAS_GAP:
$this->xmlContent->writeAttribute('chart:treat-empty-cells', 'leave-gap');
+
break;
case Chart::BLANKAS_SPAN:
$this->xmlContent->writeAttribute('chart:treat-empty-cells', 'ignore');
+
break;
}
if ($chartType instanceof AbstractTypeBar) {
@@ -706,27 +721,27 @@ protected function writeSeriesStyle(Chart $chart, Chart\Series $series): void
}
if ($chartType instanceof Line || $chartType instanceof Scatter) {
$oMarker = $series->getMarker();
- /*
- * @link : http://www.datypic.com/sc/odf/a-chart_symbol-type.html
- */
+ // @link : http://www.datypic.com/sc/odf/a-chart_symbol-type.html
$this->xmlContent->writeAttributeIf(Chart\Marker::SYMBOL_NONE == $oMarker->getSymbol(), 'chart:symbol-type', 'none');
- /*
- * @link : http://www.datypic.com/sc/odf/a-chart_symbol-name.html
- */
+ // @link : http://www.datypic.com/sc/odf/a-chart_symbol-name.html
$this->xmlContent->writeAttributeIf(Chart\Marker::SYMBOL_NONE != $oMarker->getSymbol(), 'chart:symbol-type', 'named-symbol');
if (Chart\Marker::SYMBOL_NONE != $oMarker->getSymbol()) {
switch ($oMarker->getSymbol()) {
case Chart\Marker::SYMBOL_DASH:
$symbolName = 'horizontal-bar';
+
break;
case Chart\Marker::SYMBOL_DOT:
$symbolName = 'circle';
+
break;
case Chart\Marker::SYMBOL_TRIANGLE:
$symbolName = 'arrow-up';
+
break;
default:
$symbolName = $oMarker->getSymbol();
+
break;
}
$this->xmlContent->writeAttribute('chart:symbol-name', $symbolName);
@@ -760,7 +775,7 @@ protected function writeSeriesStyle(Chart $chart, Chart\Series $series): void
if ($oOutline instanceof Outline) {
$outlineWidth = $oOutline->getWidth();
if (!empty($outlineWidth)) {
- $outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', '');
+ $outlineWidth = number_format(CommonDrawing::pixelsToCentimeters($outlineWidth), 3, '.', '');
}
$outlineColor = $oOutline->getFill()->getStartColor()->getRGB();
}
@@ -880,13 +895,13 @@ protected function writeTable(): void
// table:table-cell
$this->xmlContent->startElement('table:table-cell');
- $cellValueTypeFloat = is_null($cell) ? true : is_numeric($cell);
+ $cellValueTypeFloat = null === $cell ? true : is_numeric($cell);
$this->xmlContent->writeAttributeIf(!$cellValueTypeFloat, 'office:value-type', 'string');
$this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value-type', 'float');
- $this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value', is_null($cell) ? 'NaN' : $cell);
+ $this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value', null === $cell ? 'NaN' : $cell);
// text:p
$this->xmlContent->startElement('text:p');
- $this->xmlContent->text(is_null($cell) ? 'NaN' : (string) $cell);
+ $this->xmlContent->text(null === $cell ? 'NaN' : (string) $cell);
$this->xmlContent->endElement();
// > table:table-cell
$this->xmlContent->endElement();
diff --git a/src/PhpPresentation/Writer/ODPresentation/Pictures.php b/src/PhpPresentation/Writer/ODPresentation/Pictures.php
index ac8cfa9335..ba83e8306e 100644
--- a/src/PhpPresentation/Writer/ODPresentation/Pictures.php
+++ b/src/PhpPresentation/Writer/ODPresentation/Pictures.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,9 +25,6 @@
class Pictures extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
$arrMedia = [];
diff --git a/src/PhpPresentation/Writer/ODPresentation/Styles.php b/src/PhpPresentation/Writer/ODPresentation/Styles.php
index 6bc8cbfb2a..a36a067cf9 100644
--- a/src/PhpPresentation/Writer/ODPresentation/Styles.php
+++ b/src/PhpPresentation/Writer/ODPresentation/Styles.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -39,6 +38,7 @@ class Styles extends AbstractDecoratorWriter
* @var array
*/
protected $arrayGradient = [];
+
/**
* Stores font styles draw:stroke-dash nodes.
*
@@ -199,6 +199,7 @@ protected function writeRichTextStyle(XMLWriter $objWriter, RichText $shape): vo
$objWriter->writeAttribute('draw:distance', '0.105cm');
$objWriter->writeAttribute('draw:dots2', '1');
$objWriter->writeAttribute('draw:dots2-length', '0.14cm');
+
break;
case Border::DASH_DASHDOT:
$objWriter->writeAttribute('draw:distance', '0.105cm');
@@ -206,16 +207,19 @@ protected function writeRichTextStyle(XMLWriter $objWriter, RichText $shape): vo
$objWriter->writeAttribute('draw:dots1-length', '0.035cm');
$objWriter->writeAttribute('draw:dots2', '1');
$objWriter->writeAttribute('draw:dots2-length', '0.14cm');
+
break;
case Border::DASH_DOT:
$objWriter->writeAttribute('draw:distance', '0.105cm');
$objWriter->writeAttribute('draw:dots1', '1');
$objWriter->writeAttribute('draw:dots1-length', '0.035cm');
+
break;
case Border::DASH_LARGEDASH:
$objWriter->writeAttribute('draw:distance', '0.105cm');
$objWriter->writeAttribute('draw:dots2', '1');
$objWriter->writeAttribute('draw:dots2-length', '0.28cm');
+
break;
case Border::DASH_LARGEDASHDOT:
$objWriter->writeAttribute('draw:distance', '0.105cm');
@@ -223,6 +227,7 @@ protected function writeRichTextStyle(XMLWriter $objWriter, RichText $shape): vo
$objWriter->writeAttribute('draw:dots1-length', '0.035cm');
$objWriter->writeAttribute('draw:dots2', '1');
$objWriter->writeAttribute('draw:dots2-length', '0.28cm');
+
break;
case Border::DASH_LARGEDASHDOTDOT:
$objWriter->writeAttribute('draw:distance', '0.105cm');
@@ -230,11 +235,13 @@ protected function writeRichTextStyle(XMLWriter $objWriter, RichText $shape): vo
$objWriter->writeAttribute('draw:dots1-length', '0.035cm');
$objWriter->writeAttribute('draw:dots2', '1');
$objWriter->writeAttribute('draw:dots2-length', '0.28cm');
+
break;
case Border::DASH_SYSDASH:
$objWriter->writeAttribute('draw:distance', '0.035cm');
$objWriter->writeAttribute('draw:dots2', '1');
$objWriter->writeAttribute('draw:dots2-length', '0.105cm');
+
break;
case Border::DASH_SYSDASHDOT:
$objWriter->writeAttribute('draw:distance', '0.035cm');
@@ -242,6 +249,7 @@ protected function writeRichTextStyle(XMLWriter $objWriter, RichText $shape): vo
$objWriter->writeAttribute('draw:dots1-length', '0.035cm');
$objWriter->writeAttribute('draw:dots2', '1');
$objWriter->writeAttribute('draw:dots2-length', '0.105cm');
+
break;
case Border::DASH_SYSDASHDOTDOT:
$objWriter->writeAttribute('draw:distance', '0.035cm');
@@ -249,11 +257,13 @@ protected function writeRichTextStyle(XMLWriter $objWriter, RichText $shape): vo
$objWriter->writeAttribute('draw:dots1-length', '0.035cm');
$objWriter->writeAttribute('draw:dots2', '1');
$objWriter->writeAttribute('draw:dots2-length', '0.105cm');
+
break;
case Border::DASH_SYSDOT:
$objWriter->writeAttribute('draw:distance', '0.035cm');
$objWriter->writeAttribute('draw:dots1', '1');
$objWriter->writeAttribute('draw:dots1-length', '0.035cm');
+
break;
}
$objWriter->endElement();
diff --git a/src/PhpPresentation/Writer/ODPresentation/ThumbnailsThumbnail.php b/src/PhpPresentation/Writer/ODPresentation/ThumbnailsThumbnail.php
index 1d754335f8..7d05129b66 100644
--- a/src/PhpPresentation/Writer/ODPresentation/ThumbnailsThumbnail.php
+++ b/src/PhpPresentation/Writer/ODPresentation/ThumbnailsThumbnail.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -32,7 +31,7 @@ public function render(): ZipInterface
// PNG : 8bit, non-interlaced with full alpha transparency
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail));
if ($gdImage) {
- list($width, $height) = getimagesize($pathThumbnail);
+ [$width, $height] = getimagesize($pathThumbnail);
$gdRender = imagecreatetruecolor(128, 128);
$colorBgAlpha = imagecolorallocatealpha($gdRender, 0, 0, 0, 127);
diff --git a/src/PhpPresentation/Writer/PowerPoint2007.php b/src/PhpPresentation/Writer/PowerPoint2007.php
index e98a61837b..dd46c37ee4 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -52,10 +51,8 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
/**
* Create a new PowerPoint2007 file.
- *
- * @param PhpPresentation $pPhpPresentation
*/
- public function __construct(PhpPresentation $pPhpPresentation = null)
+ public function __construct(?PhpPresentation $pPhpPresentation = null)
{
// Assign PhpPresentation
$this->setPhpPresentation($pPhpPresentation ?? new PhpPresentation());
@@ -71,10 +68,6 @@ public function __construct(PhpPresentation $pPhpPresentation = null)
/**
* Save PhpPresentation to file.
- *
- * @throws FileCopyException
- * @throws FileRemoveException
- * @throws InvalidParameterException
*/
public function save(string $pFilename): void
{
@@ -86,7 +79,7 @@ public function save(string $pFilename): void
// If $pFilename is php://output or php://stdout, make it a temporary file...
$originalFilename = $pFilename;
if ('php://output' == strtolower($pFilename) || 'php://stdout' == strtolower($pFilename)) {
- $pFilename = @tempnam('./', 'phppttmp');
+ $pFilename = @tempnam($this->diskCachingDir, 'phppttmp');
if ('' == $pFilename) {
$pFilename = $originalFilename;
}
@@ -98,7 +91,7 @@ public function save(string $pFilename): void
$oZip = $this->getZipAdapter();
$oZip->open($pFilename);
- $oDir = new DirectoryIterator(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'PowerPoint2007');
+ $oDir = new DirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . 'PowerPoint2007');
$arrayFiles = [];
foreach ($oDir as $oFile) {
if (!$oFile->isFile()) {
@@ -152,18 +145,15 @@ public function hasDiskCaching()
/**
* Set use disk caching where possible?
*
- * @param bool $useDiskCaching
* @param string $directory Disk caching directory
*
- * @throws DirectoryNotFoundException
- *
- * @return \PhpOffice\PhpPresentation\Writer\PowerPoint2007
+ * @return PowerPoint2007
*/
- public function setUseDiskCaching(bool $useDiskCaching = false, string $directory = null)
+ public function setUseDiskCaching(bool $useDiskCaching = false, ?string $directory = null)
{
$this->useDiskCaching = $useDiskCaching;
- if (!is_null($directory)) {
+ if (null !== $directory) {
if (!is_dir($directory)) {
throw new DirectoryNotFoundException($directory);
}
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php
index 672d828a2b..a96413c2d5 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -59,7 +58,6 @@ protected function writeRelationship(XMLWriter $objWriter, int $pId, string $pTy
* @param XMLWriter $objWriter XML Writer
* @param Border $pBorder Border
* @param string $pElementName Element name
- * @param bool $isMarker
*/
protected function writeBorder(XMLWriter $objWriter, Border $pBorder, string $pElementName = 'L', bool $isMarker = false): void
{
@@ -125,7 +123,7 @@ protected function writeBorder(XMLWriter $objWriter, Border $pBorder, string $pE
protected function writeColor(XMLWriter $objWriter, Color $color, ?int $alpha = null): void
{
- if (is_null($alpha)) {
+ if (null === $alpha) {
$alpha = $color->getAlpha();
}
@@ -145,7 +143,7 @@ protected function writeColor(XMLWriter $objWriter, Color $color, ?int $alpha =
* Write Fill.
*
* @param XMLWriter $objWriter XML Writer
- * @param Fill|null $pFill Fill style
+ * @param null|Fill $pFill Fill style
*/
protected function writeFill(XMLWriter $objWriter, ?Fill $pFill): void
{
@@ -257,7 +255,7 @@ protected function writePatternFill(XMLWriter $objWriter, Fill $pFill): void
}
/**
- * Write Outline
+ * Write Outline.
*/
protected function writeOutline(XMLWriter $objWriter, ?Outline $oOutline): void
{
@@ -265,8 +263,7 @@ protected function writeOutline(XMLWriter $objWriter, ?Outline $oOutline): void
return;
}
// Width : pts
- $width = $oOutline->getWidth() ?? 0;
- $width = CommonDrawing::pointsToEmu($width);
+ $width = CommonDrawing::pixelsToEmu($oOutline->getWidth());
// a:ln
$objWriter->startElement('a:ln');
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php
index d7f533108f..58ef3b2443 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -50,6 +49,7 @@
use PhpOffice\PhpPresentation\Style\Border;
use PhpOffice\PhpPresentation\Style\Bullet;
use PhpOffice\PhpPresentation\Style\Color;
+use PhpOffice\PhpPresentation\Style\Font;
use PhpOffice\PhpPresentation\Style\Shadow;
abstract class AbstractSlide extends AbstractDecoratorWriter
@@ -59,60 +59,56 @@ abstract class AbstractSlide extends AbstractDecoratorWriter
*/
protected function writeDrawingRelations(AbstractSlideAlias $pSlideMaster, XMLWriter $objWriter, int $relId)
{
- if ($pSlideMaster->getShapeCollection()->count() > 0) {
+ if (count($pSlideMaster->getShapeCollection()) > 0) {
// Loop trough images and write relationships
- $iterator = $pSlideMaster->getShapeCollection()->getIterator();
- while ($iterator->valid()) {
- if ($iterator->current() instanceof ShapeDrawingFile || $iterator->current() instanceof ShapeDrawingGd) {
+ foreach ($pSlideMaster->getShapeCollection() as $shape) {
+ if ($shape instanceof ShapeDrawingFile || $shape instanceof ShapeDrawingGd) {
// Write relationship for image drawing
$this->writeRelationship(
$objWriter,
$relId,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
- '../media/' . str_replace(' ', '_', $iterator->current()->getIndexedFilename())
+ '../media/' . str_replace(' ', '_', $shape->getIndexedFilename())
);
- $iterator->current()->relationId = 'rId' . $relId;
+ $shape->relationId = 'rId' . $relId;
++$relId;
- } elseif ($iterator->current() instanceof ShapeChart) {
+ } elseif ($shape instanceof ShapeChart) {
// Write relationship for chart drawing
$this->writeRelationship(
$objWriter,
$relId,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
- '../charts/' . $iterator->current()->getIndexedFilename()
+ '../charts/' . $shape->getIndexedFilename()
);
- $iterator->current()->relationId = 'rId' . $relId;
+ $shape->relationId = 'rId' . $relId;
++$relId;
- } elseif ($iterator->current() instanceof Group) {
- $iterator2 = $iterator->current()->getShapeCollection()->getIterator();
- while ($iterator2->valid()) {
- if ($iterator2->current() instanceof ShapeDrawingFile ||
- $iterator2->current() instanceof ShapeDrawingGd
+ } elseif ($shape instanceof Group) {
+ foreach ($shape->getShapeCollection() as $subShape) {
+ if ($subShape instanceof ShapeDrawingFile ||
+ $subShape instanceof ShapeDrawingGd
) {
// Write relationship for image drawing
$this->writeRelationship(
$objWriter,
$relId,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
- '../media/' . str_replace(' ', '_', $iterator2->current()->getIndexedFilename())
+ '../media/' . str_replace(' ', '_', $subShape->getIndexedFilename())
);
- $iterator2->current()->relationId = 'rId' . $relId;
+ $subShape->relationId = 'rId' . $relId;
++$relId;
- } elseif ($iterator2->current() instanceof ShapeChart) {
+ } elseif ($subShape instanceof ShapeChart) {
// Write relationship for chart drawing
$this->writeRelationship(
$objWriter,
$relId,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
- '../charts/' . $iterator2->current()->getIndexedFilename()
+ '../charts/' . $subShape->getIndexedFilename()
);
- $iterator2->current()->relationId = 'rId' . $relId;
+ $subShape->relationId = 'rId' . $relId;
++$relId;
}
- $iterator2->next();
}
}
- $iterator->next();
}
}
@@ -120,12 +116,13 @@ protected function writeDrawingRelations(AbstractSlideAlias $pSlideMaster, XMLWr
}
/**
+ * Note : $shapeId needs to start to 1
+ * The animation is applied to the shape which is next to the target shape.
+ *
* @param array|ArrayObject $shapes
* @param int $shapeId
- *
- * @throws UndefinedChartTypeException
*/
- protected function writeShapeCollection(XMLWriter $objWriter, $shapes = [], &$shapeId = 0): void
+ protected function writeShapeCollection(XMLWriter $objWriter, $shapes = [], &$shapeId = 1): void
{
if (0 == count($shapes)) {
return;
@@ -159,8 +156,6 @@ protected function writeShapeCollection(XMLWriter $objWriter, $shapes = [], &$sh
* Write txt.
*
* @param XMLWriter $objWriter XML Writer
- * @param RichText $shape
- * @param int $shapeId
*/
protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $shapeId): void
{
@@ -174,7 +169,7 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh
if ($shape->isPlaceholder()) {
$objWriter->writeAttribute('name', 'Placeholder for ' . $shape->getPlaceholder()->getType());
} else {
- $objWriter->writeAttribute('name', '');
+ $objWriter->writeAttribute('name', $shape->getName());
}
// Hyperlink
if ($shape->hasHyperlink()) {
@@ -182,16 +177,16 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh
}
// > p:sp\p:nvSpPr
$objWriter->endElement();
- // p:sp\p:cNvSpPr
+ // p:sp\p:nvSpPr\p:cNvSpPr
$objWriter->startElement('p:cNvSpPr');
$objWriter->writeAttribute('txBox', '1');
$objWriter->endElement();
- // p:sp\p:cNvSpPr\p:nvPr
+ // p:sp\p:nvSpPr\p:nvPr
if ($shape->isPlaceholder()) {
$objWriter->startElement('p:nvPr');
$objWriter->startElement('p:ph');
$objWriter->writeAttribute('type', $shape->getPlaceholder()->getType());
- if (!is_null($shape->getPlaceholder()->getIdx())) {
+ if (null !== $shape->getPlaceholder()->getIdx()) {
$objWriter->writeAttribute('idx', $shape->getPlaceholder()->getIdx());
}
$objWriter->endElement();
@@ -199,36 +194,35 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh
} else {
$objWriter->writeElement('p:nvPr', null);
}
- // > p:sp\p:cNvSpPr
+ // > p:sp\p:nvSpPr
$objWriter->endElement();
// p:sp\p:spPr
$objWriter->startElement('p:spPr');
- if (!$shape->isPlaceholder()) {
- // p:sp\p:spPr\a:xfrm
- $objWriter->startElement('a:xfrm');
- $objWriter->writeAttributeIf(0 != $shape->getRotation(), 'rot', CommonDrawing::degreesToAngle((int) $shape->getRotation()));
- // p:sp\p:spPr\a:xfrm\a:off
- $objWriter->startElement('a:off');
- $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX()));
- $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY()));
- $objWriter->endElement();
- // p:sp\p:spPr\a:xfrm\a:ext
- $objWriter->startElement('a:ext');
- $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($shape->getWidth()));
- $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($shape->getHeight()));
- $objWriter->endElement();
- // > p:sp\p:spPr\a:xfrm
- $objWriter->endElement();
- // p:sp\p:spPr\a:prstGeom
- $objWriter->startElement('a:prstGeom');
- $objWriter->writeAttribute('prst', 'rect');
+ // p:sp\p:spPr\a:xfrm
+ $objWriter->startElement('a:xfrm');
+ $objWriter->writeAttributeIf($shape->getRotation() != 0, 'rot', CommonDrawing::degreesToAngle($shape->getRotation()));
+ // p:sp\p:spPr\a:xfrm\a:off
+ $objWriter->startElement('a:off');
+ $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX()));
+ $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY()));
+ $objWriter->endElement();
+ // p:sp\p:spPr\a:xfrm\a:ext
+ $objWriter->startElement('a:ext');
+ $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($shape->getWidth()));
+ $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($shape->getHeight()));
+ $objWriter->endElement();
+ // > p:sp\p:spPr\a:xfrm
+ $objWriter->endElement();
+ // p:sp\p:spPr\a:prstGeom
+ $objWriter->startElement('a:prstGeom');
+ $objWriter->writeAttribute('prst', 'rect');
- // p:sp\p:spPr\a:prstGeom\a:avLst
- $objWriter->writeElement('a:avLst');
+ // p:sp\p:spPr\a:prstGeom\a:avLst
+ $objWriter->writeElement('a:avLst');
+
+ $objWriter->endElement();
- $objWriter->endElement();
- }
$this->writeFill($objWriter, $shape->getFill());
$this->writeBorder($objWriter, $shape->getBorder(), '');
$this->writeShadow($objWriter, $shape->getShadow());
@@ -241,10 +235,12 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh
//@link :http://msdn.microsoft.com/en-us/library/documentformat.openxml.drawing.bodyproperties%28v=office.14%29.aspx
$objWriter->startElement('a:bodyPr');
if (!$shape->isPlaceholder()) {
+ // Vertical alignment
$verticalAlign = $shape->getActiveParagraph()->getAlignment()->getVertical();
if (Alignment::VERTICAL_BASE != $verticalAlign && Alignment::VERTICAL_AUTO != $verticalAlign) {
$objWriter->writeAttribute('anchor', $verticalAlign);
}
+ $objWriter->writeAttribute('anchorCtr', $shape->getVerticalAlignCenter());
if (RichText::WRAP_SQUARE != $shape->getWrap()) {
$objWriter->writeAttribute('wrap', $shape->getWrap());
}
@@ -258,24 +254,22 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh
if ($shape->isUpright()) {
$objWriter->writeAttribute('upright', '1');
}
- if ($shape->isVertical()) {
- $objWriter->writeAttribute('vert', 'vert');
- }
+ $objWriter->writeAttribute('vert', $shape->isVertical() ? 'vert' : 'horz');
$objWriter->writeAttribute('bIns', CommonDrawing::pixelsToEmu($shape->getInsetBottom()));
$objWriter->writeAttribute('lIns', CommonDrawing::pixelsToEmu($shape->getInsetLeft()));
$objWriter->writeAttribute('rIns', CommonDrawing::pixelsToEmu($shape->getInsetRight()));
$objWriter->writeAttribute('tIns', CommonDrawing::pixelsToEmu($shape->getInsetTop()));
- if (1 != $shape->getColumns()) {
+ if ($shape->getColumns() != 1) {
$objWriter->writeAttribute('numCol', $shape->getColumns());
$objWriter->writeAttribute('spcCol', CommonDrawing::pixelsToEmu($shape->getColumnSpacing()));
}
// a:spAutoFit
$objWriter->startElement('a:' . $shape->getAutoFit());
if (RichText::AUTOFIT_NORMAL == $shape->getAutoFit()) {
- if (!is_null($shape->getFontScale())) {
+ if (null !== $shape->getFontScale()) {
$objWriter->writeAttribute('fontScale', $shape->getFontScale() * 1000);
}
- if (!is_null($shape->getLineSpaceReduction())) {
+ if (null !== $shape->getLineSpaceReduction()) {
$objWriter->writeAttribute('lnSpcReduction', $shape->getLineSpaceReduction() * 1000);
}
}
@@ -289,11 +283,30 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh
Placeholder::PH_TYPE_DATETIME == $shape->getPlaceholder()->getType())
) {
$objWriter->startElement('a:p');
+
+ // Paragraph Style
+ $paragraphs = $shape->getParagraphs();
+ if (!empty($paragraphs)) {
+ $paragraph = &$paragraphs[0];
+ $this->writeParagraphStyles($objWriter, $paragraph, true);
+ }
+
$objWriter->startElement('a:fld');
$objWriter->writeAttribute('id', $this->getGUID());
$objWriter->writeAttribute('type', (
Placeholder::PH_TYPE_SLIDENUM == $shape->getPlaceholder()->getType() ? 'slidenum' : 'datetime'
));
+
+ if (isset($paragraph)) {
+ $elements = $paragraph->getRichTextElements();
+ if (!empty($elements)) {
+ $element = &$elements[0];
+ if ($element instanceof Run) {
+ $this->writeRunStyles($objWriter, $element);
+ }
+ }
+ }
+
$objWriter->writeElement('a:t', (
Placeholder::PH_TYPE_SLIDENUM == $shape->getPlaceholder()->getType() ? '' : '03-04-05'
));
@@ -311,8 +324,6 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh
* Write table.
*
* @param XMLWriter $objWriter XML Writer
- * @param ShapeTable $shape
- * @param int $shapeId
*/
protected function writeShapeTable(XMLWriter $objWriter, ShapeTable $shape, int $shapeId): void
{
@@ -510,7 +521,7 @@ protected function writeShapeTable(XMLWriter $objWriter, ShapeTable $shape, int
* @param XMLWriter $objWriter XML Writer
* @param array $paragraphs
*/
- protected function writeParagraphs(XMLWriter $objWriter, array $paragraphs, bool $bIsPlaceholder = false): void
+ protected function writeParagraphs(XMLWriter $objWriter, array $paragraphs): void
{
// Loop trough paragraphs
foreach ($paragraphs as $paragraph) {
@@ -518,76 +529,7 @@ protected function writeParagraphs(XMLWriter $objWriter, array $paragraphs, bool
$objWriter->startElement('a:p');
// a:pPr
- if (!$bIsPlaceholder) {
- // a:pPr
- $objWriter->startElement('a:pPr');
- $objWriter->writeAttribute('algn', $paragraph->getAlignment()->getHorizontal());
- $objWriter->writeAttribute('rtl', $paragraph->getAlignment()->isRTL() ? '1' : '0');
- $objWriter->writeAttribute('fontAlgn', $paragraph->getAlignment()->getVertical());
- $objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginLeft()));
- $objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginRight()));
- $objWriter->writeAttribute('indent', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getIndent()));
- $objWriter->writeAttribute('lvl', $paragraph->getAlignment()->getLevel());
-
- // a:pPr:a:lnSpc
- $objWriter->startElement('a:lnSpc');
- if ($paragraph->getLineSpacingMode() == Paragraph::LINE_SPACING_MODE_POINT) {
- $objWriter->startElement('a:spcPts');
- $objWriter->writeAttribute('val', $paragraph->getLineSpacing() * 100);
- $objWriter->endElement();
- } else {
- $objWriter->startElement('a:spcPct');
- $objWriter->writeAttribute('val', $paragraph->getLineSpacing() * 1000);
- $objWriter->endElement();
- }
- // >a:pPr:a:lnSpc
- $objWriter->endElement();
-
- $objWriter->startElement('a:spcBef');
- $objWriter->startElement('a:spcPts');
- $objWriter->writeAttribute('val', $paragraph->getSpacingBefore() * 100);
- $objWriter->endElement();
- $objWriter->endElement();
-
- $objWriter->startElement('a:spcAft');
- $objWriter->startElement('a:spcPts');
- $objWriter->writeAttribute('val', $paragraph->getSpacingAfter() * 100);
- $objWriter->endElement();
- $objWriter->endElement();
-
- // Bullet type specified?
- if (Bullet::TYPE_NONE != $paragraph->getBulletStyle()->getBulletType()) {
- // Color
- // a:buClr must be before a:buFont (else PowerPoint crashes at launch)
- if ($paragraph->getBulletStyle()->getBulletColor() instanceof Color) {
- $objWriter->startElement('a:buClr');
- $this->writeColor($objWriter, $paragraph->getBulletStyle()->getBulletColor());
- $objWriter->endElement();
- }
-
- // a:buFont
- $objWriter->startElement('a:buFont');
- $objWriter->writeAttribute('typeface', $paragraph->getBulletStyle()->getBulletFont());
- $objWriter->endElement();
-
- if (Bullet::TYPE_BULLET == $paragraph->getBulletStyle()->getBulletType()) {
- // a:buChar
- $objWriter->startElement('a:buChar');
- $objWriter->writeAttribute('char', $paragraph->getBulletStyle()->getBulletChar());
- $objWriter->endElement();
- } elseif (Bullet::TYPE_NUMERIC == $paragraph->getBulletStyle()->getBulletType()) {
- // a:buAutoNum
- $objWriter->startElement('a:buAutoNum');
- $objWriter->writeAttribute('type', $paragraph->getBulletStyle()->getBulletNumericStyle());
- if (1 != $paragraph->getBulletStyle()->getBulletNumericStartAt()) {
- $objWriter->writeAttribute('startAt', $paragraph->getBulletStyle()->getBulletNumericStartAt());
- }
- $objWriter->endElement();
- }
- }
-
- $objWriter->endElement();
- }
+ $this->writeParagraphStyles($objWriter, $paragraph, false);
// Loop trough rich text elements
$elements = $paragraph->getRichTextElements();
@@ -600,38 +542,8 @@ protected function writeParagraphs(XMLWriter $objWriter, array $paragraphs, bool
$objWriter->startElement('a:r');
// a:rPr
- if ($element instanceof Run && !$bIsPlaceholder) {
- // a:rPr
- $objWriter->startElement('a:rPr');
-
- // Lang
- $objWriter->writeAttribute('lang', ($element->getLanguage() ? $element->getLanguage() : 'en-US'));
- $objWriter->writeAttributeIf($element->getFont()->isBold(), 'b', '1');
- $objWriter->writeAttributeIf($element->getFont()->isItalic(), 'i', '1');
- $objWriter->writeAttributeIf($element->getFont()->isStrikethrough(), 'strike', 'sngStrike');
- $objWriter->writeAttribute('sz', ($element->getFont()->getSize() * 100));
- $objWriter->writeAttribute('spc', $element->getFont()->getCharacterSpacing());
- $objWriter->writeAttribute('u', $element->getFont()->getUnderline());
- $objWriter->writeAttributeIf($element->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($element->getFont()->isSubScript(), 'baseline', '-250000');
-
- // Color - a:solidFill
- $objWriter->startElement('a:solidFill');
- $this->writeColor($objWriter, $element->getFont()->getColor());
- $objWriter->endElement();
-
- // Font
- // - a:latin
- // - a:ea
- // - a:cs
- $objWriter->startElement('a:' . $element->getFont()->getFormat());
- $objWriter->writeAttribute('typeface', $element->getFont()->getName());
- $objWriter->endElement();
-
- // a:hlinkClick
- $this->writeHyperlink($objWriter, $element);
-
- $objWriter->endElement();
+ if ($element instanceof Run) {
+ $this->writeRunStyles($objWriter, $element);
}
// t
@@ -647,6 +559,148 @@ protected function writeParagraphs(XMLWriter $objWriter, array $paragraphs, bool
}
}
+ /**
+ * Write Paragraph Styles (a:pPr).
+ */
+ protected function writeParagraphStyles(XMLWriter $objWriter, Paragraph $paragraph, bool $isPlaceholder = false): void
+ {
+ $objWriter->startElement('a:pPr');
+ $objWriter->writeAttribute('algn', $paragraph->getAlignment()->getHorizontal());
+ $objWriter->writeAttribute('rtl', $paragraph->getAlignment()->isRTL() ? '1' : '0');
+ $objWriter->writeAttribute('fontAlgn', $paragraph->getAlignment()->getVertical());
+ $objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginLeft()));
+ $objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginRight()));
+ $objWriter->writeAttribute('indent', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getIndent()));
+ $objWriter->writeAttribute('lvl', $paragraph->getAlignment()->getLevel());
+
+ $objWriter->startElement('a:lnSpc');
+ if ($paragraph->getLineSpacingMode() == Paragraph::LINE_SPACING_MODE_POINT) {
+ $objWriter->startElement('a:spcPts');
+ $objWriter->writeAttribute('val', $paragraph->getLineSpacing() * 100);
+ $objWriter->endElement();
+ } else {
+ $objWriter->startElement('a:spcPct');
+ $objWriter->writeAttribute('val', $paragraph->getLineSpacing() * 1000);
+ $objWriter->endElement();
+ }
+ $objWriter->endElement();
+
+ $objWriter->startElement('a:spcBef');
+ $objWriter->startElement('a:spcPts');
+ $objWriter->writeAttribute('val', $paragraph->getSpacingBefore() * 100);
+ $objWriter->endElement();
+ $objWriter->endElement();
+
+ $objWriter->startElement('a:spcAft');
+ $objWriter->startElement('a:spcPts');
+ $objWriter->writeAttribute('val', $paragraph->getSpacingAfter() * 100);
+ $objWriter->endElement();
+ $objWriter->endElement();
+
+ if (!$isPlaceholder) {
+ // Bullet type specified?
+ if ($paragraph->getBulletStyle()->getBulletType() != Bullet::TYPE_NONE) {
+ // Color
+ // a:buClr must be before a:buFont (else PowerPoint crashes at launch)
+ if ($paragraph->getBulletStyle()->getBulletColor() instanceof Color) {
+ $objWriter->startElement('a:buClr');
+ $this->writeColor($objWriter, $paragraph->getBulletStyle()->getBulletColor());
+ $objWriter->endElement();
+ }
+
+ // a:buFont
+ $objWriter->startElement('a:buFont');
+ $objWriter->writeAttribute('typeface', $paragraph->getBulletStyle()->getBulletFont());
+ $objWriter->endElement();
+
+ if ($paragraph->getBulletStyle()->getBulletType() == Bullet::TYPE_BULLET) {
+ // a:buChar
+ $objWriter->startElement('a:buChar');
+ $objWriter->writeAttribute('char', $paragraph->getBulletStyle()->getBulletChar());
+ $objWriter->endElement();
+ } elseif ($paragraph->getBulletStyle()->getBulletType() == Bullet::TYPE_NUMERIC) {
+ // a:buAutoNum
+ $objWriter->startElement('a:buAutoNum');
+ $objWriter->writeAttribute('type', $paragraph->getBulletStyle()->getBulletNumericStyle());
+ if ($paragraph->getBulletStyle()->getBulletNumericStartAt() != 1) {
+ $objWriter->writeAttribute('startAt', $paragraph->getBulletStyle()->getBulletNumericStartAt());
+ }
+ $objWriter->endElement();
+ }
+ }
+ }
+
+ $objWriter->endElement();
+ }
+
+ /**
+ * Write RichTextElement Styles (a:pPr).
+ */
+ protected function writeRunStyles(XMLWriter $objWriter, Run $element): void
+ {
+ // a:rPr
+ $objWriter->startElement('a:rPr');
+
+ // Lang
+ $objWriter->writeAttribute('lang', ($element->getLanguage() ? $element->getLanguage() : 'en-US'));
+
+ $objWriter->writeAttributeIf($element->getFont()->isBold(), 'b', '1');
+ $objWriter->writeAttributeIf($element->getFont()->isItalic(), 'i', '1');
+
+ // Strikethrough
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
+
+ // Size
+ $objWriter->writeAttribute('sz', ($element->getFont()->getSize() * 100));
+
+ // Character spacing
+ $objWriter->writeAttribute('spc', $element->getFont()->getCharacterSpacing());
+
+ // Underline
+ $objWriter->writeAttribute('u', $element->getFont()->getUnderline());
+
+ // Capitalization
+ $objWriter->writeAttribute('cap', $element->getFont()->getCapitalization());
+
+ // Baseline
+ $objWriter->writeAttributeIf($element->getFont()->getBaseline() !== 0, 'baseline', $element->getFont()->getBaseline());
+
+ // Color - a:solidFill
+ $objWriter->startElement('a:solidFill');
+ $this->writeColor($objWriter, $element->getFont()->getColor());
+ $objWriter->endElement();
+
+ // Font
+ // - a:latin
+ // - a:ea
+ // - a:cs
+ $objWriter->startElement('a:' . $element->getFont()->getFormat());
+ $objWriter->writeAttribute('typeface', $element->getFont()->getName());
+ if ($element->getFont()->getPanose() !== '') {
+ $panose = array_map(function (string $value) {
+ return '0' . $value;
+ }, str_split($element->getFont()->getPanose()));
+
+ $objWriter->writeAttribute('panose', implode('', $panose));
+ }
+ $objWriter->writeAttributeIf(
+ $element->getFont()->getPitchFamily() !== 0,
+ 'pitchFamily',
+ $element->getFont()->getPitchFamily()
+ );
+ $objWriter->writeAttributeIf(
+ $element->getFont()->getCharset() !== Font::CHARSET_DEFAULT,
+ 'charset',
+ dechex($element->getFont()->getCharset())
+ );
+ $objWriter->endElement();
+
+ // a:hlinkClick
+ $this->writeHyperlink($objWriter, $element);
+
+ $objWriter->endElement();
+ }
+
/**
* Write Line Shape.
*
@@ -744,10 +798,6 @@ protected function writeShapeLine(XMLWriter $objWriter, Line $shape, int $shapeI
*/
protected function writeShadow(XMLWriter $objWriter, Shadow $oShadow): void
{
- if (!($oShadow instanceof Shadow)) {
- return;
- }
-
if (!$oShadow->isVisible()) {
return;
}
@@ -756,7 +806,7 @@ protected function writeShadow(XMLWriter $objWriter, Shadow $oShadow): void
$objWriter->startElement('a:effectLst');
// a:outerShdw
- $objWriter->startElement('a:outerShdw');
+ $objWriter->startElement('a:' . $oShadow->getType());
$objWriter->writeAttribute('blurRad', CommonDrawing::pixelsToEmu($oShadow->getBlurRadius()));
$objWriter->writeAttribute('dist', CommonDrawing::pixelsToEmu($oShadow->getDistance()));
$objWriter->writeAttribute('dir', CommonDrawing::degreesToAngle((int) $oShadow->getDirection()));
@@ -788,6 +838,19 @@ protected function writeHyperlink(XMLWriter $objWriter, $shape): void
if ($shape->getHyperlink()->isInternal()) {
$objWriter->writeAttribute('action', $shape->getHyperlink()->getUrl());
}
+
+ if ($shape->getHyperlink()->isTextColorUsed()) {
+ $objWriter->startElement('a:extLst');
+ $objWriter->startElement('a:ext');
+ $objWriter->writeAttribute('uri', '{A12FA001-AC4F-418D-AE19-62706E023703}');
+ $objWriter->startElement('ahyp:hlinkClr');
+ $objWriter->writeAttribute('xmlns:ahyp', 'http://schemas.microsoft.com/office/drawing/2018/hyperlinkcolor');
+ $objWriter->writeAttribute('val', 'tx');
+ $objWriter->endElement();
+ $objWriter->endElement();
+ $objWriter->endElement();
+ }
+
$objWriter->endElement();
}
@@ -1076,11 +1139,9 @@ protected function writeNote(Note $pNote): string
}
/**
- * Write AutoShape
+ * Write AutoShape.
*
* @param XMLWriter $objWriter XML Writer
- * @param AutoShape $shape
- * @param int $shapeId
*/
protected function writeShapeAutoShape(XMLWriter $objWriter, AutoShape $shape, int $shapeId): void
{
@@ -1173,7 +1234,7 @@ protected function writeShapeAutoShape(XMLWriter $objWriter, AutoShape $shape, i
}
/**
- * Write chart
+ * Write chart.
*
* @param XMLWriter $objWriter XML Writer
*/
@@ -1287,9 +1348,7 @@ protected function writeShapePic(XMLWriter $objWriter, AbstractGraphic $shape, i
$objWriter->writeAttribute('type', $shape->getPlaceholder()->getType());
$objWriter->endElement();
}
- /*
- * @link : https://github.com/stefslon/exportToPPTX/blob/master/exportToPPTX.m#L2128
- */
+ // @link : https://github.com/stefslon/exportToPPTX/blob/master/exportToPPTX.m#L2128
if ($shape instanceof Media) {
// p:nvPr > a:videoFile
$objWriter->startElement('a:videoFile');
@@ -1302,7 +1361,7 @@ protected function writeShapePic(XMLWriter $objWriter, AbstractGraphic $shape, i
$objWriter->writeAttribute('uri', '{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}');
// p:nvPr > p:extLst > p:ext > p14:media
$objWriter->startElement('p14:media');
- $objWriter->writeAttribute('r:embed', ((int) $shape->relationId + 1));
+ $objWriter->writeAttribute('r:embed', 'rId' . ((int) substr($shape->relationId, strlen('rId')) + 1));
$objWriter->writeAttribute('xmlns:p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
// p:nvPr > p:extLst > p:ext > ##p14:media
$objWriter->endElement();
@@ -1501,9 +1560,7 @@ protected function writeSlideBackground(AbstractSlideAlias $pSlide, XMLWriter $o
// > p:bgPr
$objWriter->endElement();
}
- /*
- * @link : http://www.officeopenxml.com/prSlide-background.php
- */
+ // @link : http://www.officeopenxml.com/prSlide-background.php
if ($oBackground instanceof Slide\Background\SchemeColor) {
// p:bgRef
$objWriter->startElement('p:bgRef');
@@ -1530,7 +1587,7 @@ protected function writeSlideTransition(XMLWriter $objWriter, ?Slide\Transition
return;
}
$objWriter->startElement('p:transition');
- if (!is_null($transition->getSpeed())) {
+ if (null !== $transition->getSpeed()) {
$objWriter->writeAttribute('spd', $transition->getSpeed());
}
$objWriter->writeAttribute('advClick', $transition->hasManualTrigger() ? '1' : '0');
@@ -1543,222 +1600,269 @@ protected function writeSlideTransition(XMLWriter $objWriter, ?Slide\Transition
$objWriter->startElement('p:blinds');
$objWriter->writeAttribute('dir', 'horz');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_BLINDS_VERTICAL:
$objWriter->startElement('p:blinds');
$objWriter->writeAttribute('dir', 'vert');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_CHECKER_HORIZONTAL:
$objWriter->startElement('p:checker');
$objWriter->writeAttribute('dir', 'horz');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_CHECKER_VERTICAL:
$objWriter->startElement('p:checker');
$objWriter->writeAttribute('dir', 'vert');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_CIRCLE:
$objWriter->writeElement('p:circle');
+
break;
case Slide\Transition::TRANSITION_COMB_HORIZONTAL:
$objWriter->startElement('p:comb');
$objWriter->writeAttribute('dir', 'horz');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_COMB_VERTICAL:
$objWriter->startElement('p:comb');
$objWriter->writeAttribute('dir', 'vert');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_COVER_DOWN:
$objWriter->startElement('p:cover');
$objWriter->writeAttribute('dir', 'd');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_COVER_LEFT:
$objWriter->startElement('p:cover');
$objWriter->writeAttribute('dir', 'l');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_COVER_LEFT_DOWN:
$objWriter->startElement('p:cover');
$objWriter->writeAttribute('dir', 'ld');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_COVER_LEFT_UP:
$objWriter->startElement('p:cover');
$objWriter->writeAttribute('dir', 'lu');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_COVER_RIGHT:
$objWriter->startElement('p:cover');
$objWriter->writeAttribute('dir', 'r');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_COVER_RIGHT_DOWN:
$objWriter->startElement('p:cover');
$objWriter->writeAttribute('dir', 'rd');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_COVER_RIGHT_UP:
$objWriter->startElement('p:cover');
$objWriter->writeAttribute('dir', 'ru');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_COVER_UP:
$objWriter->startElement('p:cover');
$objWriter->writeAttribute('dir', 'u');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_CUT:
$objWriter->writeElement('p:cut');
+
break;
case Slide\Transition::TRANSITION_DIAMOND:
$objWriter->writeElement('p:diamond');
+
break;
case Slide\Transition::TRANSITION_DISSOLVE:
$objWriter->writeElement('p:dissolve');
+
break;
case Slide\Transition::TRANSITION_FADE:
$objWriter->writeElement('p:fade');
+
break;
case Slide\Transition::TRANSITION_NEWSFLASH:
$objWriter->writeElement('p:newsflash');
+
break;
case Slide\Transition::TRANSITION_PLUS:
$objWriter->writeElement('p:plus');
+
break;
case Slide\Transition::TRANSITION_PULL_DOWN:
$objWriter->startElement('p:pull');
$objWriter->writeAttribute('dir', 'd');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_PULL_LEFT:
$objWriter->startElement('p:pull');
$objWriter->writeAttribute('dir', 'l');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_PULL_RIGHT:
$objWriter->startElement('p:pull');
$objWriter->writeAttribute('dir', 'r');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_PULL_UP:
$objWriter->startElement('p:pull');
$objWriter->writeAttribute('dir', 'u');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_PUSH_DOWN:
$objWriter->startElement('p:push');
$objWriter->writeAttribute('dir', 'd');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_PUSH_LEFT:
$objWriter->startElement('p:push');
$objWriter->writeAttribute('dir', 'l');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_PUSH_RIGHT:
$objWriter->startElement('p:push');
$objWriter->writeAttribute('dir', 'r');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_PUSH_UP:
$objWriter->startElement('p:push');
$objWriter->writeAttribute('dir', 'u');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_RANDOM:
$objWriter->writeElement('p:random');
+
break;
case Slide\Transition::TRANSITION_RANDOMBAR_HORIZONTAL:
$objWriter->startElement('p:randomBar');
$objWriter->writeAttribute('dir', 'horz');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_RANDOMBAR_VERTICAL:
$objWriter->startElement('p:randomBar');
$objWriter->writeAttribute('dir', 'vert');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_SPLIT_IN_HORIZONTAL:
$objWriter->startElement('p:split');
$objWriter->writeAttribute('dir', 'in');
$objWriter->writeAttribute('orient', 'horz');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_SPLIT_OUT_HORIZONTAL:
$objWriter->startElement('p:split');
$objWriter->writeAttribute('dir', 'out');
$objWriter->writeAttribute('orient', 'horz');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_SPLIT_IN_VERTICAL:
$objWriter->startElement('p:split');
$objWriter->writeAttribute('dir', 'in');
$objWriter->writeAttribute('orient', 'vert');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_SPLIT_OUT_VERTICAL:
$objWriter->startElement('p:split');
$objWriter->writeAttribute('dir', 'out');
$objWriter->writeAttribute('orient', 'vert');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_STRIPS_LEFT_DOWN:
$objWriter->startElement('p:strips');
$objWriter->writeAttribute('dir', 'ld');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_STRIPS_LEFT_UP:
$objWriter->startElement('p:strips');
$objWriter->writeAttribute('dir', 'lu');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_STRIPS_RIGHT_DOWN:
$objWriter->startElement('p:strips');
$objWriter->writeAttribute('dir', 'rd');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_STRIPS_RIGHT_UP:
$objWriter->startElement('p:strips');
$objWriter->writeAttribute('dir', 'ru');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_WEDGE:
$objWriter->writeElement('p:wedge');
+
break;
case Slide\Transition::TRANSITION_WIPE_DOWN:
$objWriter->startElement('p:wipe');
$objWriter->writeAttribute('dir', 'd');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_WIPE_LEFT:
$objWriter->startElement('p:wipe');
$objWriter->writeAttribute('dir', 'l');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_WIPE_RIGHT:
$objWriter->startElement('p:wipe');
$objWriter->writeAttribute('dir', 'r');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_WIPE_UP:
$objWriter->startElement('p:wipe');
$objWriter->writeAttribute('dir', 'u');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_ZOOM_IN:
$objWriter->startElement('p:zoom');
$objWriter->writeAttribute('dir', 'in');
$objWriter->endElement();
+
break;
case Slide\Transition::TRANSITION_ZOOM_OUT:
$objWriter->startElement('p:zoom');
$objWriter->writeAttribute('dir', 'out');
$objWriter->endElement();
+
break;
}
@@ -1769,19 +1873,18 @@ private function getGUID(): string
{
if (function_exists('com_create_guid')) {
return com_create_guid();
- } else {
- mt_srand(intval(microtime(true) * 10000));
- $charid = strtoupper(md5(uniqid((string) rand(), true)));
- $hyphen = chr(45); // "-"
- $uuid = chr(123)// "{"
- . substr($charid, 0, 8) . $hyphen
- . substr($charid, 8, 4) . $hyphen
- . substr($charid, 12, 4) . $hyphen
- . substr($charid, 16, 4) . $hyphen
- . substr($charid, 20, 12)
- . chr(125); // "}"
-
- return $uuid;
}
+ mt_srand((int) (microtime(true) * 10000));
+ $charid = strtoupper(md5(uniqid((string) mt_rand(), true)));
+ $hyphen = chr(45); // "-"
+ $uuid = chr(123)// "{"
+ . substr($charid, 0, 8) . $hyphen
+ . substr($charid, 8, 4) . $hyphen
+ . substr($charid, 12, 4) . $hyphen
+ . substr($charid, 16, 4) . $hyphen
+ . substr($charid, 20, 12)
+ . chr(125); // "}"
+
+ return $uuid;
}
}
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/CommentAuthors.php b/src/PhpPresentation/Writer/PowerPoint2007/CommentAuthors.php
index 35b90e1774..a73a88518c 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/CommentAuthors.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/CommentAuthors.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/ContentTypes.php b/src/PhpPresentation/Writer/PowerPoint2007/ContentTypes.php
index 6d0a6d7e34..aa8ea2a9d1 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/ContentTypes.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/ContentTypes.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -86,13 +85,14 @@ public function render(): ZipInterface
for ($i = 0; $i < $slideCount; ++$i) {
$oSlide = $this->oPresentation->getSlide($i);
$this->writeOverrideContentType($objWriter, '/ppt/slides/slide' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slide+xml');
- if ($oSlide->getNote()->getShapeCollection()->count() > 0) {
+ if (count($oSlide->getNote()->getShapeCollection()) > 0) {
$this->writeOverrideContentType($objWriter, '/ppt/notesSlides/notesSlide' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml');
}
foreach ($oSlide->getShapeCollection() as $oShape) {
if ($oShape instanceof Comment) {
$this->writeOverrideContentType($objWriter, '/ppt/comments/comment' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.comments+xml');
$hasComments = true;
+
break;
}
}
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsApp.php b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsApp.php
index fe81c5086c..882cf3c8cf 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsApp.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsApp.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCore.php b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCore.php
index f1afb28df9..d21f6863ac 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCore.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCore.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -50,13 +49,13 @@ public function render(): ZipInterface
// dcterms:created
$objWriter->startElement('dcterms:created');
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
- $objWriter->writeRaw(gmdate("Y-m-d\TH:i:s\Z", $this->oPresentation->getDocumentProperties()->getCreated()));
+ $objWriter->writeRaw(gmdate('Y-m-d\\TH:i:s\\Z', $this->oPresentation->getDocumentProperties()->getCreated()));
$objWriter->endElement();
// dcterms:modified
$objWriter->startElement('dcterms:modified');
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
- $objWriter->writeRaw(gmdate("Y-m-d\TH:i:s\Z", $this->oPresentation->getDocumentProperties()->getModified()));
+ $objWriter->writeRaw(gmdate('Y-m-d\\TH:i:s\\Z', $this->oPresentation->getDocumentProperties()->getModified()));
$objWriter->endElement();
// dc:title
@@ -74,9 +73,14 @@ public function render(): ZipInterface
// cp:category
$objWriter->writeElement('cp:category', $this->oPresentation->getDocumentProperties()->getCategory());
+ // cp:revision
+ $objWriter->writeElement('cp:revision', $this->oPresentation->getDocumentProperties()->getRevision());
+
+ // cp:contentStatus
if ($this->oPresentation->getPresentationProperties()->isMarkedAsFinal()) {
- // cp:contentStatus = Final
$objWriter->writeElement('cp:contentStatus', 'Final');
+ } else {
+ $objWriter->writeElement('cp:contentStatus', $this->oPresentation->getDocumentProperties()->getStatus());
}
$objWriter->endElement();
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCustom.php b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCustom.php
index ea651ac402..ccb257fa43 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCustom.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCustom.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -68,20 +67,25 @@ public function render(): ZipInterface
switch ($propertyType) {
case DocumentProperties::PROPERTY_TYPE_INTEGER:
$objWriter->writeElement('vt:i4', (string) $propertyValue);
+
break;
case DocumentProperties::PROPERTY_TYPE_FLOAT:
$objWriter->writeElement('vt:r8', (string) $propertyValue);
+
break;
case DocumentProperties::PROPERTY_TYPE_BOOLEAN:
$objWriter->writeElement('vt:bool', $propertyValue ? 'true' : 'false');
+
break;
case DocumentProperties::PROPERTY_TYPE_DATE:
$objWriter->startElement('vt:filetime');
$objWriter->writeRaw(date(DATE_W3C, (int) $propertyValue));
$objWriter->endElement();
+
break;
default:
$objWriter->writeElement('vt:lpwstr', (string) $propertyValue);
+
break;
}
$objWriter->endElement();
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php
index 6c54be1ecf..aac86bc75a 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,18 +25,15 @@ class DocPropsThumbnail extends AbstractDecoratorWriter
{
public function render(): ZipInterface
{
- $pathThumbnail = $this->getPresentation()->getPresentationProperties()->getThumbnailPath();
-
- if ($pathThumbnail) {
- $fileThumbnail = file_get_contents($pathThumbnail);
- $gdImage = imagecreatefromstring($fileThumbnail);
+ $thumnbail = $this->getPresentation()->getPresentationProperties()->getThumbnail();
+ if ($thumnbail) {
+ $gdImage = imagecreatefromstring($thumnbail);
if ($gdImage) {
ob_start();
imagejpeg($gdImage);
$imageContents = ob_get_contents();
ob_end_clean();
imagedestroy($gdImage);
-
$this->getZip()->addFromString('docProps/thumbnail.jpeg', $imageContents);
}
}
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
index 0010dac78a..f28fb74adc 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -48,9 +47,6 @@
class PptCharts extends AbstractDecoratorWriter
{
- /**
- * @throws FileRemoveException
- */
public function render(): ZipInterface
{
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
@@ -229,8 +225,6 @@ protected function writeChart(Chart $chart): string
* Write chart to XML format.
*
* @return string String output
- *
- * @throws FileRemoveException
*/
protected function writeSpreadsheet(PhpPresentation $presentation, Chart $chart, string $tempName): string
{
@@ -244,9 +238,11 @@ protected function writeSpreadsheet(PhpPresentation $presentation, Chart $chart,
}
$spreadsheet->getProperties()
->setCreator(
- $presentation->getDocumentProperties()->getCreator())->setLastModifiedBy(
- $presentation->getDocumentProperties()->getLastModifiedBy()
- )
+ $presentation->getDocumentProperties()->getCreator()
+ )
+ ->setLastModifiedBy(
+ $presentation->getDocumentProperties()->getLastModifiedBy()
+ )
->setTitle($title);
// Add chart data
@@ -257,20 +253,20 @@ protected function writeSpreadsheet(PhpPresentation $presentation, Chart $chart,
$seriesIndex = 0;
foreach ($chart->getPlotArea()->getType()->getSeries() as $series) {
// Title
- $sheet->setCellValueByColumnAndRow(1 + $seriesIndex, 1, $series->getTitle());
+ $sheet->setCellValueByColumnAndRow(2 + $seriesIndex, 1, $series->getTitle());
// X-axis
$axisXData = array_keys($series->getValues());
$numAxisXData = count($axisXData);
for ($i = 0; $i < $numAxisXData; ++$i) {
- $sheet->setCellValueByColumnAndRow(0, $i + 2, $axisXData[$i]);
+ $sheet->setCellValueByColumnAndRow(1, $i + 2, $axisXData[$i]);
}
// Y-axis
$axisYData = array_values($series->getValues());
$numAxisYData = count($axisYData);
for ($i = 0; $i < $numAxisYData; ++$i) {
- $sheet->setCellValueByColumnAndRow(1 + $seriesIndex, $i + 2, $axisYData[$i]);
+ $sheet->setCellValueByColumnAndRow(2 + $seriesIndex, $i + 2, $axisYData[$i]);
}
++$seriesIndex;
@@ -351,7 +347,16 @@ protected function writeMultipleValuesOrReference(XMLWriter $objWriter, bool $is
// c:strLit / c:numLit
// c:strRef / c:numRef
$referenceType = ($isReference ? 'Ref' : 'Lit');
- $dataType = is_numeric($values[0]) ? 'num' : 'str';
+
+ // Get data type from first non-null value
+ $dataType = array_reduce($values, function ($carry, $item) {
+ if (!isset($item)) {
+ return $carry;
+ }
+
+ return is_numeric($item) ? 'num' : 'str';
+ }, 'num');
+
$objWriter->startElement('c:' . $dataType . $referenceType);
$numValues = count($values);
@@ -368,7 +373,7 @@ protected function writeMultipleValuesOrReference(XMLWriter $objWriter, bool $is
// c:pt
$objWriter->startElement('c:pt');
$objWriter->writeAttribute('idx', $i);
- $objWriter->writeElement('c:v', strval($values[$i]));
+ $objWriter->writeElement('c:v', (string) ($values[$i]));
$objWriter->endElement();
}
} else {
@@ -386,7 +391,7 @@ protected function writeMultipleValuesOrReference(XMLWriter $objWriter, bool $is
// c:pt
$objWriter->startElement('c:pt');
$objWriter->writeAttribute('idx', $i);
- $objWriter->writeElement('c:v', strval($values[$i]));
+ $objWriter->writeElement('c:v', (string) ($values[$i]));
$objWriter->endElement();
}
@@ -397,7 +402,7 @@ protected function writeMultipleValuesOrReference(XMLWriter $objWriter, bool $is
}
/**
- * Write Title
+ * Write Title.
*/
protected function writeTitle(XMLWriter $objWriter, Title $subject): void
{
@@ -442,11 +447,11 @@ protected function writeTitle(XMLWriter $objWriter, Title $subject): void
$objWriter->writeAttribute('dirty', '0');
$objWriter->writeAttribute('b', ($subject->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($subject->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($subject->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $subject->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($subject->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $subject->getFont()->getUnderline());
- $objWriter->writeAttributeIf($subject->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($subject->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($subject->getFont()->getBaseline() !== 0, 'baseline', $subject->getFont()->getBaseline());
+ $objWriter->writeAttribute('cap', $subject->getFont()->getCapitalization());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -494,8 +499,6 @@ protected function writeTitle(XMLWriter $objWriter, Title $subject): void
* Write Plot Area.
*
* @param XMLWriter $objWriter XML Writer
- *
- * @throws UndefinedChartTypeException
*/
protected function writePlotArea(XMLWriter $objWriter, PlotArea $subject, Chart $chart): void
{
@@ -546,7 +549,6 @@ protected function writePlotArea(XMLWriter $objWriter, PlotArea $subject, Chart
* Write Legend.
*
* @param XMLWriter $objWriter XML Writer
- * @param Chart\Legend $subject
*/
protected function writeLegend(XMLWriter $objWriter, Legend $subject): void
{
@@ -605,11 +607,10 @@ protected function writeLegend(XMLWriter $objWriter, Legend $subject): void
$objWriter->writeAttribute('b', ($subject->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($subject->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($subject->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $subject->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($subject->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $subject->getFont()->getUnderline());
- $objWriter->writeAttributeIf($subject->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($subject->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($subject->getFont()->getBaseline() !== 0, 'baseline', $subject->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -699,8 +700,6 @@ protected function writeLayout(XMLWriter $objWriter, $subject): void
* Write Type Area.
*
* @param XMLWriter $objWriter XML Writer
- * @param Chart\Type\Area $subject
- * @param bool $includeSheet
*/
protected function writeTypeArea(XMLWriter $objWriter, Area $subject, bool $includeSheet = false): void
{
@@ -730,7 +729,7 @@ protected function writeTypeArea(XMLWriter $objWriter, Area $subject, bool $incl
// c:ser > c:tx
$objWriter->startElement('c:tx');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();
@@ -775,7 +774,7 @@ protected function writeTypeArea(XMLWriter $objWriter, Area $subject, bool $incl
// c:val
$objWriter->startElement('c:val');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();
@@ -801,8 +800,6 @@ protected function writeTypeArea(XMLWriter $objWriter, Area $subject, bool $incl
* Write Type Bar.
*
* @param XMLWriter $objWriter XML Writer
- * @param Chart\Type\Bar $subject
- * @param bool $includeSheet
*/
protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includeSheet = false): void
{
@@ -837,7 +834,7 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ
// c:tx
$objWriter->startElement('c:tx');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();
@@ -891,24 +888,26 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ
// a:defRPr
$objWriter->startElement('a:defRPr');
-
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $series->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// a:solidFill
$objWriter->startElement('a:solidFill');
$this->writeColor($objWriter, $series->getFont()->getColor());
- // >a:solidFill
$objWriter->endElement();
+
// a:latin
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', $series->getFont()->getName());
- // >a:latin
+ $objWriter->endElement();
+
+ // a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $series->getFont()->getName());
$objWriter->endElement();
// >a:defRPr
@@ -973,7 +972,7 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ
// c:val
$objWriter->startElement('c:val');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();
@@ -1013,8 +1012,6 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ
* Write Type Bar3D.
*
* @param XMLWriter $objWriter XML Writer
- * @param Chart\Type\Bar3D $subject
- * @param bool $includeSheet
*/
protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $includeSheet = false): void
{
@@ -1049,7 +1046,7 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in
// c:tx
$objWriter->startElement('c:tx');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();
@@ -1098,11 +1095,10 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $series->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1115,6 +1111,10 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', $series->getFont()->getName());
$objWriter->endElement();
+ // a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $series->getFont()->getName());
+ $objWriter->endElement();
$objWriter->endElement();
@@ -1170,7 +1170,7 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in
// c:val
$objWriter->startElement('c:val');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();
@@ -1206,8 +1206,6 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in
* Write Type Pie.
*
* @param XMLWriter $objWriter XML Writer
- * @param Doughnut $subject
- * @param bool $includeSheet
*/
protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bool $includeSheet = false): void
{
@@ -1237,7 +1235,7 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
// c:tx
$objWriter->startElement('c:tx');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();
@@ -1269,7 +1267,7 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
// c:val
$objWriter->startElement('c:val');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();
@@ -1282,14 +1280,6 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
// c:dLbls
$objWriter->startElement('c:dLbls');
- $this->writeElementWithValAttribute($objWriter, 'c:showLegendKey', $series->hasShowLegendKey() ? '1' : '0');
- $this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0');
- $this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0');
- $this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0');
- $this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0');
- $this->writeElementWithValAttribute($objWriter, 'c:showBubbleSize', '0');
- $this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0');
-
if ($series->hasDlblNumFormat()) {
//c:numFmt
$objWriter->startElement('c:numFmt');
@@ -1313,11 +1303,10 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
$objWriter->startElement('a:defRPr');
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $series->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// c:dLbls\c:txPr\a:p\a:pPr\a:defRPr\a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1328,6 +1317,10 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', $series->getFont()->getName());
$objWriter->endElement();
+ // a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $series->getFont()->getName());
+ $objWriter->endElement();
// c:dLbls\c:txPr\a:p\a:pPr\a:defRPr\
$objWriter->endElement();
@@ -1345,6 +1338,14 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
// c:dLbls\c:txPr\
$objWriter->endElement();
+ $this->writeElementWithValAttribute($objWriter, 'c:showLegendKey', $series->hasShowLegendKey() ? '1' : '0');
+ $this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0');
+ $this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0');
+ $this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0');
+ $this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0');
+ $this->writeElementWithValAttribute($objWriter, 'c:showBubbleSize', '0');
+ $this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0');
+
$separator = $series->getSeparator();
if (!empty($separator) && PHP_EOL != $separator) {
// c:dLbls\c:separator
@@ -1365,8 +1366,6 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
* Write Type Pie.
*
* @param XMLWriter $objWriter XML Writer
- * @param Pie $subject
- * @param bool $includeSheet
*/
protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includeSheet = false): void
{
@@ -1396,7 +1395,7 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ
// c:tx
$objWriter->startElement('c:tx');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();
@@ -1446,11 +1445,10 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $series->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1463,6 +1461,10 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', $series->getFont()->getName());
$objWriter->endElement();
+ // a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $series->getFont()->getName());
+ $objWriter->endElement();
$objWriter->endElement();
@@ -1514,7 +1516,7 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ
// c:val
$objWriter->startElement('c:val');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();
@@ -1530,8 +1532,6 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ
* Write Type Pie3D.
*
* @param XMLWriter $objWriter XML Writer
- * @param Pie3D $subject
- * @param bool $includeSheet
*/
protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $includeSheet = false): void
{
@@ -1561,7 +1561,7 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in
// c:tx
$objWriter->startElement('c:tx');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();
@@ -1608,11 +1608,10 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $series->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1625,6 +1624,10 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', $series->getFont()->getName());
$objWriter->endElement();
+ // a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $series->getFont()->getName());
+ $objWriter->endElement();
$objWriter->endElement();
@@ -1673,7 +1676,7 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in
// c:val
$objWriter->startElement('c:val');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();
@@ -1689,8 +1692,6 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in
* Write Type Line.
*
* @param XMLWriter $objWriter XML Writer
- * @param Line $subject
- * @param bool $includeSheet
*/
protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $includeSheet = false): void
{
@@ -1720,7 +1721,7 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl
// c:tx
$objWriter->startElement('c:tx');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();
@@ -1759,11 +1760,10 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $series->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1776,6 +1776,10 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', $series->getFont()->getName());
$objWriter->endElement();
+ // a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $series->getFont()->getName());
+ $objWriter->endElement();
$objWriter->endElement();
@@ -1822,7 +1826,7 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl
// c:val
$objWriter->startElement('c:val');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();
@@ -1855,11 +1859,9 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl
}
/**
- * Write Type Radar
+ * Write Type Radar.
*
* @param XMLWriter $objWriter XML Writer
- * @param Radar $subject
- * @param bool $includeSheet
*/
protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $includeSheet = false): void
{
@@ -1894,10 +1896,19 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in
// c:tx
$objWriter->startElement('c:tx');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();
+ // c:spPr
+ $objWriter->startElement('c:spPr');
+ // Write fill
+ $this->writeFill($objWriter, $series->getFill());
+ // Write outline
+ $this->writeOutline($objWriter, $series->getOutline());
+ // ## c:spPr
+ $objWriter->endElement();
+
// Marker
$this->writeSeriesMarker($objWriter, $series->getMarker());
@@ -1924,11 +1935,10 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $series->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '30000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-25000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1941,6 +1951,10 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', $series->getFont()->getName());
$objWriter->endElement();
+ // a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $series->getFont()->getName());
+ $objWriter->endElement();
$objWriter->endElement();
@@ -1976,15 +1990,6 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in
$objWriter->endElement();
- // c:spPr
- $objWriter->startElement('c:spPr');
- // Write fill
- $this->writeFill($objWriter, $series->getFill());
- // Write outline
- $this->writeOutline($objWriter, $series->getOutline());
- // ## c:spPr
- $objWriter->endElement();
-
// Write X axis data
$axisXData = array_keys($series->getValues());
@@ -1998,15 +2003,10 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in
// c:val
$objWriter->startElement('c:val');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();
- // c:smooth
- $objWriter->startElement('c:smooth');
- $objWriter->writeAttribute('val', '0');
- $objWriter->endElement();
-
$objWriter->endElement();
++$seriesIndex;
@@ -2026,11 +2026,7 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in
}
/**
- * Write Type Scatter
- *
- * @param XMLWriter $objWriter
- * @param Scatter $subject
- * @param bool $includeSheet
+ * Write Type Scatter.
*/
protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool $includeSheet = false): void
{
@@ -2065,7 +2061,7 @@ protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool
// c:tx
$objWriter->startElement('c:tx');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();
@@ -2104,11 +2100,10 @@ protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $series->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -2121,6 +2116,10 @@ protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', $series->getFont()->getName());
$objWriter->endElement();
+ // a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $series->getFont()->getName());
+ $objWriter->endElement();
$objWriter->endElement();
@@ -2176,7 +2175,7 @@ protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool
// c:yVal
$objWriter->startElement('c:yVal');
- $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
+ $coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();
@@ -2206,8 +2205,6 @@ protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool
/**
* Write chart relationships to XML format.
*
- * @param Chart $pChart
- *
* @return string XML Output
*/
protected function writeChartRelationships(Chart $pChart): string
@@ -2233,10 +2230,6 @@ protected function writeChartRelationships(Chart $pChart): string
return $objWriter->getData();
}
- /**
- * @param XMLWriter $objWriter
- * @param Chart\Marker $marker
- */
protected function writeSeriesMarker(XMLWriter $objWriter, Chart\Marker $marker): void
{
// c:marker
@@ -2276,27 +2269,24 @@ protected function writeSeriesMarker(XMLWriter $objWriter, Chart\Marker $marker)
$objWriter->endElement();
}
- /**
- * @param XMLWriter $objWriter
- * @param Chart\Axis $oAxis
- * @param string $typeAxis
- * @param Chart\Type\AbstractType $typeChart
- */
protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $typeAxis, Chart\Type\AbstractType $typeChart): void
{
if (Chart\Axis::AXIS_X != $typeAxis && Chart\Axis::AXIS_Y != $typeAxis) {
return;
}
+ $crossesAt = $oAxis->getCrossesAt();
+ $orientation = $oAxis->isReversedOrder() ? 'maxMin' : 'minMax';
+
if (Chart\Axis::AXIS_X == $typeAxis) {
$mainElement = 'c:catAx';
$axIdVal = '52743552';
- $axPosVal = 'b';
+ $axPosVal = $crossesAt === 'max' ? 't' : 'b';
$crossAxVal = '52749440';
} else {
$mainElement = 'c:valAx';
$axIdVal = '52749440';
- $axPosVal = 'l';
+ $axPosVal = $crossesAt === 'max' ? 'r' : 'l';
$crossAxVal = '52743552';
}
@@ -2313,16 +2303,16 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
// $mainElement > c:scaling > c:orientation
$objWriter->startElement('c:orientation');
- $objWriter->writeAttribute('val', 'minMax');
+ $objWriter->writeAttribute('val', $orientation);
$objWriter->endElement();
- if (null != $oAxis->getMaxBounds()) {
+ if (null !== $oAxis->getMaxBounds()) {
$objWriter->startElement('c:max');
$objWriter->writeAttribute('val', $oAxis->getMaxBounds());
$objWriter->endElement();
}
- if (null != $oAxis->getMinBounds()) {
+ if (null !== $oAxis->getMinBounds()) {
$objWriter->startElement('c:min');
$objWriter->writeAttribute('val', $oAxis->getMinBounds());
$objWriter->endElement();
@@ -2388,11 +2378,10 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->writeAttribute('b', ($oAxis->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($oAxis->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($oAxis->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $oAxis->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($oAxis->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $oAxis->getFont()->getUnderline());
- $objWriter->writeAttributeIf($oAxis->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($oAxis->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($oAxis->getFont()->getBaseline() !== 0, 'baseline', $oAxis->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -2403,6 +2392,10 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', $oAxis->getFont()->getName());
$objWriter->endElement();
+ // a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $oAxis->getFont()->getName());
+ $objWriter->endElement();
$objWriter->endElement();
@@ -2466,9 +2459,64 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
// c:spPr
$objWriter->startElement('c:spPr');
- // Outline
$this->writeOutline($objWriter, $oAxis->getOutline());
- // ##c:spPr
+ $objWriter->endElement();
+
+ // c:txPr
+ $objWriter->startElement('c:txPr');
+
+ // a:bodyPr
+ $objWriter->writeElement('a:bodyPr', null);
+
+ // a:lstStyle
+ $objWriter->writeElement('a:lstStyle', null);
+
+ // a:p
+ $objWriter->startElement('a:p');
+
+ // a:pPr
+ $objWriter->startElement('a:pPr');
+
+ // a:defRPr
+ $objWriter->startElement('a:defRPr');
+ $objWriter->writeAttribute('b', ($oAxis->getTickLabelFont()->isBold() ? 'true' : 'false'));
+ $objWriter->writeAttribute('i', ($oAxis->getTickLabelFont()->isItalic() ? 'true' : 'false'));
+ $objWriter->writeAttribute('strike', $oAxis->getFont()->getStrikethrough());
+ $objWriter->writeAttribute('sz', ($oAxis->getTickLabelFont()->getSize() * 100));
+ $objWriter->writeAttribute('u', $oAxis->getTickLabelFont()->getUnderline());
+ $objWriter->writeAttributeIf($oAxis->getTickLabelFont()->getBaseline() !== 0, 'baseline', $oAxis->getTickLabelFont()->getBaseline());
+
+ // Font - a:solidFill
+ $objWriter->startElement('a:solidFill');
+ $this->writeColor($objWriter, $oAxis->getTickLabelFont()->getColor());
+ $objWriter->endElement();
+
+ // Font - a:latin
+ $objWriter->startElement('a:latin');
+ $objWriter->writeAttribute('typeface', $oAxis->getTickLabelFont()->getName());
+ $objWriter->endElement();
+
+ // Font - a:ea
+ $objWriter->startElement('a:ea');
+ $objWriter->writeAttribute('typeface', $oAxis->getTickLabelFont()->getName());
+ $objWriter->endElement();
+
+ //## a:defRPr
+ $objWriter->endElement();
+
+ //## a:pPr
+ $objWriter->endElement();
+
+ // a:endParaRPr
+ $objWriter->startElement('a:endParaRPr');
+ $objWriter->writeAttribute('lang', 'en-US');
+ $objWriter->writeAttribute('dirty', '0');
+ $objWriter->endElement();
+
+ // ## a:p
+ $objWriter->endElement();
+
+ // ## c:txPr
$objWriter->endElement();
// c:crossAx
@@ -2476,10 +2524,16 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->writeAttribute('val', $crossAxVal);
$objWriter->endElement();
- // c:crosses
- $objWriter->startElement('c:crosses');
- $objWriter->writeAttribute('val', 'autoZero');
- $objWriter->endElement();
+ // c:crosses "autoZero" | "min" | "max" | custom string value
+ if (in_array($crossesAt, ['autoZero', 'min', 'max'])) {
+ $objWriter->startElement('c:crosses');
+ $objWriter->writeAttribute('val', $crossesAt);
+ $objWriter->endElement();
+ } else {
+ $objWriter->startElement('c:crossesAt');
+ $objWriter->writeAttribute('val', $crossesAt);
+ $objWriter->endElement();
+ }
if (Chart\Axis::AXIS_X == $typeAxis) {
// c:lblAlgn
@@ -2493,7 +2547,7 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->endElement();
// c:majorUnit
- if ($oAxis->getMajorUnit() != null) {
+ if ($oAxis->getMajorUnit() !== null) {
$objWriter->startElement('c:tickLblSkip');
$objWriter->writeAttribute('val', $oAxis->getMajorUnit());
$objWriter->endElement();
@@ -2513,14 +2567,14 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->endElement();
// c:majorUnit
- if (null != $oAxis->getMajorUnit()) {
+ if ($oAxis->getMajorUnit() !== null) {
$objWriter->startElement('c:majorUnit');
$objWriter->writeAttribute('val', $oAxis->getMajorUnit());
$objWriter->endElement();
}
// c:minorUnit
- if (null != $oAxis->getMinorUnit()) {
+ if ($oAxis->getMinorUnit() !== null) {
$objWriter->startElement('c:minorUnit');
$objWriter->writeAttribute('val', $oAxis->getMinorUnit());
$objWriter->endElement();
@@ -2530,10 +2584,6 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->endElement();
}
- /**
- * @param XMLWriter $objWriter
- * @param Gridlines $oGridlines
- */
protected function writeAxisGridlines(XMLWriter $objWriter, Gridlines $oGridlines): void
{
// c:spPr
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptComments.php b/src/PhpPresentation/Writer/PowerPoint2007/PptComments.php
index 5a30c08a4b..e585cd2472 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptComments.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptComments.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,9 +27,6 @@
class PptComments extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
foreach ($this->getPresentation()->getAllSlides() as $numSlide => $oSlide) {
@@ -44,9 +40,6 @@ public function render(): ZipInterface
return $this->getZip();
}
- /**
- * @return string
- */
protected function writeSlideComments(Slide $oSlide): string
{
/**
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptMedia.php b/src/PhpPresentation/Writer/PowerPoint2007/PptMedia.php
index 85a7acecc1..13caebfedc 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptMedia.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptMedia.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,9 +24,6 @@
class PptMedia extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptPresProps.php b/src/PhpPresentation/Writer/PowerPoint2007/PptPresProps.php
index c28f12d22f..05f0103d2d 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptPresProps.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptPresProps.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,9 +24,6 @@
class PptPresProps extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
$presentationPpts = $this->oPresentation->getPresentationProperties();
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptPresentation.php b/src/PhpPresentation/Writer/PowerPoint2007/PptPresentation.php
index a6aa3c1336..6f93dd4660 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptPresentation.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptPresentation.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,9 +25,6 @@
class PptPresentation extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
// Create XML writer
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideLayouts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideLayouts.php
index b482579d79..58a718a04b 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideLayouts.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideLayouts.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,9 +29,6 @@
class PptSlideLayouts extends AbstractSlide
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
foreach ($this->oPresentation->getAllMasterSlides() as $oSlideMaster) {
@@ -181,7 +177,7 @@ protected function writeSlideLayout(SlideLayout $pSlideLayout): string
// p:sldLayout\p:clrMapOvr\
$objWriter->endElement();
- if (!is_null($pSlideLayout->getTransition())) {
+ if (null !== $pSlideLayout->getTransition()) {
$this->writeSlideTransition($objWriter, $pSlideLayout->getTransition());
}
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php
index a7758a8984..7109caaa79 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,9 +29,6 @@
class PptSlideMasters extends AbstractSlide
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
foreach ($this->oPresentation->getAllMasterSlides() as $oMasterSlide) {
@@ -93,7 +89,7 @@ public function writeSlideMasterRelationships(SlideMaster $oMasterSlide): string
// Relationship theme/theme1.xml
$this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', '../theme/theme' . $oMasterSlide->getRelsIndex() . '.xml');
$objWriter->endElement();
- // Return
+
return $objWriter->getData();
}
@@ -178,7 +174,7 @@ protected function writeSlideMaster(SlideMaster $pSlide): string
// p:sldMaster\p:sldLayoutIdLst
$objWriter->startElement('p:sldLayoutIdLst');
foreach ($pSlide->getAllSlideLayouts() as $layout) {
- /* @var $layout Slide\SlideLayout */
+ // @var $layout Slide\SlideLayout
$objWriter->startElement('p:sldLayoutId');
$objWriter->writeAttribute('id', $layout->layoutId);
$objWriter->writeAttribute('r:id', $layout->relationId);
@@ -237,7 +233,7 @@ protected function writeSlideMaster(SlideMaster $pSlide): string
$objWriter->endElement();
// p:sldMaster\p:txStyles\
- if (!is_null($pSlide->getTransition())) {
+ if (null !== $pSlide->getTransition()) {
$this->writeSlideTransition($objWriter, $pSlide->getTransition());
}
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php
index 8c2999d04a..de600cdf15 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -32,6 +31,7 @@
use PhpOffice\PhpPresentation\Shape\RichText\Run;
use PhpOffice\PhpPresentation\Shape\RichText\TextElement;
use PhpOffice\PhpPresentation\Shape\Table as ShapeTable;
+use PhpOffice\PhpPresentation\ShapeContainerInterface;
use PhpOffice\PhpPresentation\Slide;
use PhpOffice\PhpPresentation\Slide\Background\Image;
use PhpOffice\PhpPresentation\Slide\Note;
@@ -40,8 +40,6 @@ class PptSlides extends AbstractSlide
{
/**
* Add slides (drawings, ...) and slide relationships (drawings, ...).
- *
- * @return ZipInterface
*/
public function render(): ZipInterface
{
@@ -51,7 +49,7 @@ public function render(): ZipInterface
// Add note slide
if ($oSlide->getNote() instanceof Note) {
- if ($oSlide->getNote()->getShapeCollection()->count() > 0) {
+ if (count($oSlide->getNote()->getShapeCollection()) > 0) {
$this->oZip->addFromString('ppt/notesSlides/notesSlide' . ($idx + 1) . '.xml', $this->writeNote($oSlide->getNote()));
}
}
@@ -98,57 +96,35 @@ protected function writeSlideRelationships(Slide $pSlide): string
++$relId;
// Write drawing relationships?
- if ($pSlide->getShapeCollection()->count() > 0) {
- // Loop trough images and write relationships
- $iterator = $pSlide->getShapeCollection()->getIterator();
- while ($iterator->valid()) {
- if ($iterator->current() instanceof Media) {
- // Write relationship for image drawing
- $iterator->current()->relationId = 'rId' . $relId;
- $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/video', '../media/' . $iterator->current()->getIndexedFilename());
- ++$relId;
- $this->writeRelationship($objWriter, $relId, 'http://schemas.microsoft.com/office/2007/relationships/media', '../media/' . $iterator->current()->getIndexedFilename());
- ++$relId;
- } elseif ($iterator->current() instanceof ShapeDrawing\AbstractDrawingAdapter) {
- // Write relationship for image drawing
- $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $iterator->current()->getIndexedFilename());
- $iterator->current()->relationId = 'rId' . $relId;
- ++$relId;
- } elseif ($iterator->current() instanceof ShapeChart) {
- // Write relationship for chart drawing
- $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/' . $iterator->current()->getIndexedFilename());
-
- $iterator->current()->relationId = 'rId' . $relId;
+ if (count($pSlide->getShapeCollection()) > 0) {
+ $collections = [$pSlide->getShapeCollection()];
- ++$relId;
- } elseif ($iterator->current() instanceof Group) {
- $iterator2 = $iterator->current()->getShapeCollection()->getIterator();
- while ($iterator2->valid()) {
- if ($iterator2->current() instanceof Media) {
- // Write relationship for image drawing
- $iterator2->current()->relationId = 'rId' . $relId;
- $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/video', '../media/' . $iterator2->current()->getIndexedFilename());
- ++$relId;
- $this->writeRelationship($objWriter, $relId, 'http://schemas.microsoft.com/office/2007/relationships/media', '../media/' . $iterator2->current()->getIndexedFilename());
- ++$relId;
- } elseif ($iterator2->current() instanceof ShapeDrawing\AbstractDrawingAdapter) {
- // Write relationship for image drawing
- $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $iterator2->current()->getIndexedFilename());
- $iterator2->current()->relationId = 'rId' . $relId;
-
- ++$relId;
- } elseif ($iterator2->current() instanceof ShapeChart) {
- // Write relationship for chart drawing
- $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/' . $iterator2->current()->getIndexedFilename());
- $iterator2->current()->relationId = 'rId' . $relId;
-
- ++$relId;
- }
- $iterator2->next();
+ // Loop trough images and write relationships
+ while (count($collections)) {
+ $collection = array_shift($collections);
+
+ foreach ($collection as $currentShape) {
+ if ($currentShape instanceof Media) {
+ // Write relationship for image drawing
+ $currentShape->relationId = 'rId' . $relId;
+ $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/video', '../media/' . $currentShape->getIndexedFilename());
+ ++$relId;
+ $this->writeRelationship($objWriter, $relId, 'http://schemas.microsoft.com/office/2007/relationships/media', '../media/' . $currentShape->getIndexedFilename());
+ ++$relId;
+ } elseif ($currentShape instanceof ShapeDrawing\AbstractDrawingAdapter) {
+ // Write relationship for image drawing
+ $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $currentShape->getIndexedFilename());
+ $currentShape->relationId = 'rId' . $relId;
+ ++$relId;
+ } elseif ($currentShape instanceof ShapeChart) {
+ // Write relationship for chart drawing
+ $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/' . $currentShape->getIndexedFilename());
+ $currentShape->relationId = 'rId' . $relId;
+ ++$relId;
+ } elseif ($currentShape instanceof ShapeContainerInterface) {
+ $collections[] = $currentShape->getShapeCollection();
}
}
-
- $iterator->next();
}
}
@@ -161,14 +137,13 @@ protected function writeSlideRelationships(Slide $pSlide): string
}
// Write hyperlink relationships?
- if ($pSlide->getShapeCollection()->count() > 0) {
+ if (count($pSlide->getShapeCollection()) > 0) {
// Loop trough hyperlinks and write relationships
- $iterator = $pSlide->getShapeCollection()->getIterator();
- while ($iterator->valid()) {
+ foreach ($pSlide->getShapeCollection() as $shape) {
// Hyperlink on shape
- if ($iterator->current()->hasHyperlink()) {
+ if ($shape->hasHyperlink()) {
// Write relationship for hyperlink
- $hyperlink = $iterator->current()->getHyperlink();
+ $hyperlink = $shape->getHyperlink();
$hyperlink->relationId = 'rId' . $relId;
if (!$hyperlink->isInternal()) {
@@ -181,8 +156,8 @@ protected function writeSlideRelationships(Slide $pSlide): string
}
// Hyperlink on rich text run
- if ($iterator->current() instanceof RichText) {
- foreach ($iterator->current()->getParagraphs() as $paragraph) {
+ if ($shape instanceof RichText) {
+ foreach ($shape->getParagraphs() as $paragraph) {
foreach ($paragraph->getRichTextElements() as $element) {
if ($element instanceof Run || $element instanceof TextElement) {
if ($element->hasHyperlink()) {
@@ -204,14 +179,14 @@ protected function writeSlideRelationships(Slide $pSlide): string
}
// Hyperlink in table
- if ($iterator->current() instanceof ShapeTable) {
+ if ($shape instanceof ShapeTable) {
// Rows
- $countRows = count($iterator->current()->getRows());
+ $countRows = count($shape->getRows());
for ($row = 0; $row < $countRows; ++$row) {
// Cells in rows
- $countCells = count($iterator->current()->getRow($row)->getCells());
+ $countCells = count($shape->getRow($row)->getCells());
for ($cell = 0; $cell < $countCells; ++$cell) {
- $currentCell = $iterator->current()->getRow($row)->getCell($cell);
+ $currentCell = $shape->getRow($row)->getCell($cell);
// Paragraphs in cell
foreach ($currentCell->getParagraphs() as $paragraph) {
// RichText in paragraph
@@ -238,13 +213,12 @@ protected function writeSlideRelationships(Slide $pSlide): string
}
}
- if ($iterator->current() instanceof Group) {
- $iterator2 = $pSlide->getShapeCollection()->getIterator();
- while ($iterator2->valid()) {
+ if ($shape instanceof Group) {
+ foreach ($shape->getShapeCollection() as $subShape) {
// Hyperlink on shape
- if ($iterator2->current()->hasHyperlink()) {
+ if ($subShape->hasHyperlink()) {
// Write relationship for hyperlink
- $hyperlink = $iterator2->current()->getHyperlink();
+ $hyperlink = $subShape->getHyperlink();
$hyperlink->relationId = 'rId' . $relId;
if (!$hyperlink->isInternal()) {
@@ -257,8 +231,8 @@ protected function writeSlideRelationships(Slide $pSlide): string
}
// Hyperlink on rich text run
- if ($iterator2->current() instanceof RichText) {
- foreach ($iterator2->current()->getParagraphs() as $paragraph) {
+ if ($subShape instanceof RichText) {
+ foreach ($subShape->getParagraphs() as $paragraph) {
foreach ($paragraph->getRichTextElements() as $element) {
if ($element instanceof Run || $element instanceof TextElement) {
if ($element->hasHyperlink()) {
@@ -280,14 +254,14 @@ protected function writeSlideRelationships(Slide $pSlide): string
}
// Hyperlink in table
- if ($iterator2->current() instanceof ShapeTable) {
+ if ($subShape instanceof ShapeTable) {
// Rows
- $countRows = count($iterator2->current()->getRows());
+ $countRows = count($subShape->getRows());
for ($row = 0; $row < $countRows; ++$row) {
// Cells in rows
- $countCells = count($iterator2->current()->getRow($row)->getCells());
+ $countCells = count($subShape->getRow($row)->getCells());
for ($cell = 0; $cell < $countCells; ++$cell) {
- $currentCell = $iterator2->current()->getRow($row)->getCell($cell);
+ $currentCell = $subShape->getRow($row)->getCell($cell);
// Paragraphs in cell
foreach ($currentCell->getParagraphs() as $paragraph) {
// RichText in paragraph
@@ -313,37 +287,30 @@ protected function writeSlideRelationships(Slide $pSlide): string
}
}
}
-
- $iterator2->next();
}
}
-
- $iterator->next();
}
}
// Write comment relationships
- if ($pSlide->getShapeCollection()->count() > 0) {
+ if (count($pSlide->getShapeCollection()) > 0) {
$hasSlideComment = false;
// Loop trough images and write relationships
- $iterator = $pSlide->getShapeCollection()->getIterator();
- while ($iterator->valid()) {
- if ($iterator->current() instanceof Comment) {
+ foreach ($pSlide->getShapeCollection() as $shape) {
+ if ($shape instanceof Comment) {
$hasSlideComment = true;
+
break;
- } elseif ($iterator->current() instanceof Group) {
- $iterator2 = $iterator->current()->getShapeCollection()->getIterator();
- while ($iterator2->valid()) {
- if ($iterator2->current() instanceof Comment) {
+ } elseif ($shape instanceof Group) {
+ foreach ($shape->getShapeCollection() as $subShape) {
+ if ($subShape instanceof Comment) {
$hasSlideComment = true;
+
break 2;
}
- $iterator2->next();
}
}
-
- $iterator->next();
}
if ($hasSlideComment) {
@@ -352,7 +319,7 @@ protected function writeSlideRelationships(Slide $pSlide): string
}
}
- if ($pSlide->getNote()->getShapeCollection()->count() > 0) {
+ if (count($pSlide->getNote()->getShapeCollection()) > 0) {
$this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide', '../notesSlides/notesSlide' . ($idxSlide + 1) . '.xml');
}
@@ -404,7 +371,7 @@ protected function writeSlide(Slide $pSlide): string
$objWriter->endElement();
}
- if ($oBackground instanceof Slide\Background\Image) {
+ if ($oBackground instanceof Image) {
// a:blipFill
$objWriter->startElement('a:blipFill');
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptTableProps.php b/src/PhpPresentation/Writer/PowerPoint2007/PptTableProps.php
index ff2c5f851f..f92f6ddb3a 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptTableProps.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptTableProps.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,9 +24,6 @@
class PptTableProps extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
// Create XML writer
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php b/src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php
index c2c9e8e9b5..9b53b7c1c1 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,9 +25,6 @@
class PptTheme extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
foreach ($this->oPresentation->getAllMasterSlides() as $oMasterSlide) {
@@ -80,7 +76,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide): string
// Create XML writer
$objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
- $name = 'Theme' . rand(1, 100);
+ $name = 'Theme' . mt_rand(1, 100);
// XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptViewProps.php b/src/PhpPresentation/Writer/PowerPoint2007/PptViewProps.php
index 2a89473843..17891a69a8 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptViewProps.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptViewProps.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,9 +24,6 @@
class PptViewProps extends AbstractDecoratorWriter
{
- /**
- * @return ZipInterface
- */
public function render(): ZipInterface
{
// Create XML writer
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/Relationships.php b/src/PhpPresentation/Writer/PowerPoint2007/Relationships.php
index 9069ed485f..7d652778c1 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/Relationships.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/Relationships.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -29,8 +28,6 @@ class Relationships extends AbstractDecoratorWriter
{
/**
* Add relationships to ZIP file.
- *
- * @return ZipInterface
*/
public function render(): ZipInterface
{
@@ -66,17 +63,18 @@ protected function writeRelationships(): string
$this->writeRelationship($objWriter, 4, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties', 'docProps/custom.xml');
$idxRelation = 5;
- // Thumbnail
- if ($this->getPresentation()->getPresentationProperties()->getThumbnailPath()) {
- $pathThumbnail = file_get_contents($this->getPresentation()->getPresentationProperties()->getThumbnailPath());
- $gdImage = imagecreatefromstring($pathThumbnail);
+
+ // Relationship docProps/thumbnail.jpeg
+ $thumnbail = $this->getPresentation()->getPresentationProperties()->getThumbnail();
+ if ($thumnbail) {
+ $gdImage = imagecreatefromstring($thumnbail);
if ($gdImage) {
imagedestroy($gdImage);
// Relationship docProps/thumbnail.jpeg
$this->writeRelationship($objWriter, $idxRelation, 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail', 'docProps/thumbnail.jpeg');
+ // $idxRelation++;
}
}
- // ++$idxRelation
$objWriter->endElement();
@@ -134,6 +132,7 @@ protected function writePresentationRelationships(): string
continue;
}
$this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors', 'commentAuthors.xml');
+
break 2;
}
}
diff --git a/src/PhpPresentation/Writer/Serialized.php b/src/PhpPresentation/Writer/Serialized.php
index 5482c1e2ee..34acb7d2e2 100644
--- a/src/PhpPresentation/Writer/Serialized.php
+++ b/src/PhpPresentation/Writer/Serialized.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,10 +34,8 @@ class Serialized extends AbstractWriter implements WriterInterface
{
/**
* Create a new \PhpOffice\PhpPresentation\Writer\Serialized.
- *
- * @param \PhpOffice\PhpPresentation\PhpPresentation $pPhpPresentation
*/
- public function __construct(PhpPresentation $pPhpPresentation = null)
+ public function __construct(?PhpPresentation $pPhpPresentation = null)
{
// Set PhpPresentation
$this->setPhpPresentation($pPhpPresentation ?? new PhpPresentation());
@@ -49,9 +46,6 @@ public function __construct(PhpPresentation $pPhpPresentation = null)
/**
* Save PhpPresentation to file.
- *
- * @throws DirectoryNotFoundException
- * @throws InvalidParameterException
*/
public function save(string $pFilename): void
{
@@ -72,12 +66,11 @@ public function save(string $pFilename): void
// Add media
$slideCount = $oPresentation->getSlideCount();
for ($i = 0; $i < $slideCount; ++$i) {
- for ($j = 0; $j < $oPresentation->getSlide($i)->getShapeCollection()->count(); ++$j) {
- if ($oPresentation->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawingAdapter) {
- $imgTemp = $oPresentation->getSlide($i)->getShapeCollection()->offsetGet($j);
+ foreach ($oPresentation->getSlide($i)->getShapeCollection() as $shape) {
+ if ($shape instanceof AbstractDrawingAdapter) {
$objZip->addFromString(
- 'media/' . $imgTemp->getImageIndex() . '/' . pathinfo($imgTemp->getPath(), PATHINFO_BASENAME),
- file_get_contents($imgTemp->getPath())
+ 'media/' . $shape->getImageIndex() . '/' . pathinfo($shape->getPath(), PATHINFO_BASENAME),
+ file_get_contents($shape->getPath())
);
}
}
@@ -93,12 +86,11 @@ public function save(string $pFilename): void
/**
* Serialize PhpPresentation object to XML.
*
- * @param PhpPresentation|null $pPhpPresentation
* @param string $pFilename
*
* @return string XML Output
*/
- protected function writeSerialized(PhpPresentation $pPhpPresentation = null, $pFilename = '')
+ protected function writeSerialized(?PhpPresentation $pPhpPresentation = null, $pFilename = '')
{
// Clone $pPhpPresentation
$pPhpPresentation = clone $pPhpPresentation;
@@ -106,14 +98,13 @@ protected function writeSerialized(PhpPresentation $pPhpPresentation = null, $pF
// Update media links
$slideCount = $pPhpPresentation->getSlideCount();
for ($i = 0; $i < $slideCount; ++$i) {
- for ($j = 0; $j < $pPhpPresentation->getSlide($i)->getShapeCollection()->count(); ++$j) {
- if ($pPhpPresentation->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawingAdapter) {
- $imgTemp = $pPhpPresentation->getSlide($i)->getShapeCollection()->offsetGet($j);
- $imgPath = 'zip://' . $pFilename . '#media/' . $imgTemp->getImageIndex() . '/' . pathinfo($imgTemp->getPath(), PATHINFO_BASENAME);
- if ($imgTemp instanceof File) {
- $imgTemp->setPath($imgPath, false);
+ foreach ($pPhpPresentation->getSlide($i)->getShapeCollection() as $shape) {
+ if ($shape instanceof AbstractDrawingAdapter) {
+ $imgPath = 'zip://' . $pFilename . '#media/' . $shape->getImageIndex() . '/' . pathinfo($shape->getPath(), PATHINFO_BASENAME);
+ if ($shape instanceof File) {
+ $shape->setPath($imgPath, false);
} else {
- $imgTemp->setPath($imgPath);
+ $shape->setPath($imgPath);
}
}
}
diff --git a/src/PhpPresentation/Writer/WriterInterface.php b/src/PhpPresentation/Writer/WriterInterface.php
index ab64192e1a..7c04b7adbf 100644
--- a/src/PhpPresentation/Writer/WriterInterface.php
+++ b/src/PhpPresentation/Writer/WriterInterface.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,7 +25,7 @@
interface WriterInterface
{
/**
- * Save PhpPresentation to file
+ * Save PhpPresentation to file.
*/
public function save(string $pFilename): void;
}
diff --git a/tests/PhpPresentation/Tests/AbstractShapeTest.php b/tests/PhpPresentation/Tests/AbstractShapeTest.php
index 8cb097b2d5..d254cc5eb7 100644
--- a/tests/PhpPresentation/Tests/AbstractShapeTest.php
+++ b/tests/PhpPresentation/Tests/AbstractShapeTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -43,25 +42,25 @@ public function testConstruct(): void
{
$object = new RichText();
- $this->assertEquals(0, $object->getOffsetX());
- $this->assertEquals(0, $object->getOffsetY());
- $this->assertEquals(0, $object->getHeight());
- $this->assertEquals(0, $object->getRotation());
- $this->assertEquals(0, $object->getWidth());
- $this->assertInstanceOf(Border::class, $object->getBorder());
- $this->assertEquals(Border::LINE_NONE, $object->getBorder()->getLineStyle());
- $this->assertInstanceOf(Fill::class, $object->getFill());
- $this->assertInstanceOf(Shadow::class, $object->getShadow());
+ self::assertEquals(0, $object->getOffsetX());
+ self::assertEquals(0, $object->getOffsetY());
+ self::assertEquals(0, $object->getHeight());
+ self::assertEquals(0, $object->getRotation());
+ self::assertEquals(0, $object->getWidth());
+ self::assertInstanceOf(Border::class, $object->getBorder());
+ self::assertEquals(Border::LINE_NONE, $object->getBorder()->getLineStyle());
+ self::assertInstanceOf(Fill::class, $object->getFill());
+ self::assertInstanceOf(Shadow::class, $object->getShadow());
}
public function testFill(): void
{
$object = new RichText();
- $this->assertInstanceOf(AbstractShape::class, $object->setFill());
- $this->assertNull($object->getFill());
- $this->assertInstanceOf(AbstractShape::class, $object->setFill(new Fill()));
- $this->assertInstanceOf(Fill::class, $object->getFill());
+ self::assertInstanceOf(AbstractShape::class, $object->setFill());
+ self::assertNull($object->getFill());
+ self::assertInstanceOf(AbstractShape::class, $object->setFill(new Fill()));
+ self::assertInstanceOf(Fill::class, $object->getFill());
}
public function testHeight(): void
@@ -69,24 +68,24 @@ public function testHeight(): void
$object = new RichText();
$value = mt_rand(1, 100);
- $this->assertInstanceOf(AbstractShape::class, $object->setHeight());
- $this->assertEquals(0, $object->getHeight());
- $this->assertInstanceOf(AbstractShape::class, $object->setHeight($value));
- $this->assertEquals($value, $object->getHeight());
+ self::assertInstanceOf(AbstractShape::class, $object->setHeight());
+ self::assertEquals(0, $object->getHeight());
+ self::assertInstanceOf(AbstractShape::class, $object->setHeight($value));
+ self::assertEquals($value, $object->getHeight());
}
public function testHyperlink(): void
{
$object = new RichText();
- $this->assertInstanceOf(AbstractShape::class, $object->setHyperlink());
- $this->assertFalse($object->hasHyperlink());
- $this->assertInstanceOf(Hyperlink::class, $object->getHyperlink());
- $this->assertTrue($object->hasHyperlink());
- $this->assertInstanceOf(AbstractShape::class, $object->setHyperlink(new Hyperlink('http://www.google.fr')));
- $this->assertTrue($object->hasHyperlink());
- $this->assertInstanceOf(Hyperlink::class, $object->getHyperlink());
- $this->assertTrue($object->hasHyperlink());
+ self::assertInstanceOf(AbstractShape::class, $object->setHyperlink());
+ self::assertFalse($object->hasHyperlink());
+ self::assertInstanceOf(Hyperlink::class, $object->getHyperlink());
+ self::assertTrue($object->hasHyperlink());
+ self::assertInstanceOf(AbstractShape::class, $object->setHyperlink(new Hyperlink('http://www.google.fr')));
+ self::assertTrue($object->hasHyperlink());
+ self::assertInstanceOf(Hyperlink::class, $object->getHyperlink());
+ self::assertTrue($object->hasHyperlink());
}
public function testOffsetX(): void
@@ -94,10 +93,10 @@ public function testOffsetX(): void
$object = new RichText();
$value = mt_rand(1, 100);
- $this->assertInstanceOf(AbstractShape::class, $object->setOffsetX());
- $this->assertEquals(0, $object->getOffsetX());
- $this->assertInstanceOf(AbstractShape::class, $object->setOffsetX($value));
- $this->assertEquals($value, $object->getOffsetX());
+ self::assertInstanceOf(AbstractShape::class, $object->setOffsetX());
+ self::assertEquals(0, $object->getOffsetX());
+ self::assertInstanceOf(AbstractShape::class, $object->setOffsetX($value));
+ self::assertEquals($value, $object->getOffsetX());
}
public function testOffsetY(): void
@@ -105,10 +104,10 @@ public function testOffsetY(): void
$object = new RichText();
$value = mt_rand(1, 100);
- $this->assertInstanceOf(AbstractShape::class, $object->setOffsetY());
- $this->assertEquals(0, $object->getOffsetY());
- $this->assertInstanceOf(AbstractShape::class, $object->setOffsetY($value));
- $this->assertEquals($value, $object->getOffsetY());
+ self::assertInstanceOf(AbstractShape::class, $object->setOffsetY());
+ self::assertEquals(0, $object->getOffsetY());
+ self::assertInstanceOf(AbstractShape::class, $object->setOffsetY($value));
+ self::assertEquals($value, $object->getOffsetY());
}
public function testRotation(): void
@@ -116,20 +115,20 @@ public function testRotation(): void
$object = new RichText();
$value = mt_rand(1, 100);
- $this->assertInstanceOf(AbstractShape::class, $object->setRotation());
- $this->assertEquals(0, $object->getRotation());
- $this->assertInstanceOf(AbstractShape::class, $object->setRotation($value));
- $this->assertEquals($value, $object->getRotation());
+ self::assertInstanceOf(AbstractShape::class, $object->setRotation());
+ self::assertEquals(0, $object->getRotation());
+ self::assertInstanceOf(AbstractShape::class, $object->setRotation($value));
+ self::assertEquals($value, $object->getRotation());
}
public function testShadow(): void
{
$object = new RichText();
- $this->assertInstanceOf(AbstractShape::class, $object->setShadow());
- $this->assertNull($object->getShadow());
- $this->assertInstanceOf(AbstractShape::class, $object->setShadow(new Shadow()));
- $this->assertInstanceOf(Shadow::class, $object->getShadow());
+ self::assertInstanceOf(AbstractShape::class, $object->setShadow());
+ self::assertNull($object->getShadow());
+ self::assertInstanceOf(AbstractShape::class, $object->setShadow(new Shadow()));
+ self::assertInstanceOf(Shadow::class, $object->getShadow());
}
public function testWidth(): void
@@ -137,10 +136,10 @@ public function testWidth(): void
$object = new RichText();
$value = mt_rand(1, 100);
- $this->assertInstanceOf(AbstractShape::class, $object->setWidth());
- $this->assertEquals(0, $object->getWidth());
- $this->assertInstanceOf(AbstractShape::class, $object->setWidth($value));
- $this->assertEquals($value, $object->getWidth());
+ self::assertInstanceOf(AbstractShape::class, $object->setWidth());
+ self::assertEquals(0, $object->getWidth());
+ self::assertInstanceOf(AbstractShape::class, $object->setWidth($value));
+ self::assertEquals($value, $object->getWidth());
}
public function testWidthAndHeight(): void
@@ -148,38 +147,38 @@ public function testWidthAndHeight(): void
$object = new RichText();
$value = mt_rand(1, 100);
- $this->assertInstanceOf(AbstractShape::class, $object->setWidthAndHeight());
- $this->assertEquals(0, $object->getWidth());
- $this->assertEquals(0, $object->getHeight());
- $this->assertInstanceOf(AbstractShape::class, $object->setWidthAndHeight($value));
- $this->assertEquals($value, $object->getWidth());
- $this->assertEquals(0, $object->getHeight());
- $this->assertInstanceOf(AbstractShape::class, $object->setWidthAndHeight($value, $value));
- $this->assertEquals($value, $object->getWidth());
- $this->assertEquals($value, $object->getHeight());
+ self::assertInstanceOf(AbstractShape::class, $object->setWidthAndHeight());
+ self::assertEquals(0, $object->getWidth());
+ self::assertEquals(0, $object->getHeight());
+ self::assertInstanceOf(AbstractShape::class, $object->setWidthAndHeight($value));
+ self::assertEquals($value, $object->getWidth());
+ self::assertEquals(0, $object->getHeight());
+ self::assertInstanceOf(AbstractShape::class, $object->setWidthAndHeight($value, $value));
+ self::assertEquals($value, $object->getWidth());
+ self::assertEquals($value, $object->getHeight());
}
public function testPlaceholder(): void
{
$object = new RichText();
- $this->assertFalse($object->isPlaceholder(), 'Standard Shape should not be a placeholder object');
- $this->assertNull($object->getPlaceholder());
- $this->assertInstanceOf(
+ self::assertFalse($object->isPlaceholder(), 'Standard Shape should not be a placeholder object');
+ self::assertNull($object->getPlaceholder());
+ self::assertInstanceOf(
AbstractShape::class,
$object->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_TITLE))
);
- $this->assertTrue($object->isPlaceholder());
- $this->assertInstanceOf(Placeholder::class, $object->getPlaceholder());
- $this->assertEquals('title', $object->getPlaceholder()->getType());
+ self::assertTrue($object->isPlaceholder());
+ self::assertInstanceOf(Placeholder::class, $object->getPlaceholder());
+ self::assertEquals('title', $object->getPlaceholder()->getType());
$object = new RichText();
- $this->assertFalse($object->isPlaceholder(), 'Standard Shape should not be a placeholder object');
+ self::assertFalse($object->isPlaceholder(), 'Standard Shape should not be a placeholder object');
$placeholder = new Placeholder(Placeholder::PH_TYPE_TITLE);
$placeholder->setType(Placeholder::PH_TYPE_SUBTITLE);
- $this->assertInstanceOf(AbstractShape::class, $object->setPlaceHolder($placeholder));
- $this->assertTrue($object->isPlaceholder());
- $this->assertInstanceOf(Placeholder::class, $object->getPlaceholder());
- $this->assertEquals('subTitle', $object->getPlaceholder()->getType());
+ self::assertInstanceOf(AbstractShape::class, $object->setPlaceHolder($placeholder));
+ self::assertTrue($object->isPlaceholder());
+ self::assertInstanceOf(Placeholder::class, $object->getPlaceholder());
+ self::assertEquals('subTitle', $object->getPlaceholder()->getType());
}
public function testContainer(): void
@@ -190,11 +189,11 @@ public function testContainer(): void
$oSlide = new Slide();
$oSlide->addShape($object2);
- $this->assertNull($object->getContainer());
- $this->assertInstanceOf(AbstractShape::class, $object->setContainer($oSlide));
- $this->assertInstanceOf(Slide::class, $object->getContainer());
- $this->assertInstanceOf(AbstractShape::class, $object->setContainer(null, true));
- $this->assertNull($object->getContainer());
+ self::assertNull($object->getContainer());
+ self::assertInstanceOf(AbstractShape::class, $object->setContainer($oSlide));
+ self::assertInstanceOf(Slide::class, $object->getContainer());
+ self::assertInstanceOf(AbstractShape::class, $object->setContainer(null, true));
+ self::assertNull($object->getContainer());
}
public function testContainerException(): void
@@ -202,9 +201,9 @@ public function testContainerException(): void
$object = new RichText();
$oSlide = new Slide();
- $this->assertNull($object->getContainer());
- $this->assertInstanceOf(AbstractShape::class, $object->setContainer($oSlide));
- $this->assertInstanceOf(Slide::class, $object->getContainer());
+ self::assertNull($object->getContainer());
+ self::assertInstanceOf(AbstractShape::class, $object->setContainer($oSlide));
+ self::assertInstanceOf(Slide::class, $object->getContainer());
$this->expectException(ShapeContainerAlreadyAssignedException::class);
$this->expectExceptionMessage('The shape PhpOffice\PhpPresentation\AbstractShape has already a container assigned');
$object->setContainer(null);
diff --git a/tests/PhpPresentation/Tests/AutoloaderTest.php b/tests/PhpPresentation/Tests/AutoloaderTest.php
index c1b32c0c4e..1d00718dc9 100644
--- a/tests/PhpPresentation/Tests/AutoloaderTest.php
+++ b/tests/PhpPresentation/Tests/AutoloaderTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -34,7 +33,7 @@ class AutoloaderTest extends TestCase
public function testRegister(): void
{
Autoloader::register();
- $this->assertContains(
+ self::assertContains(
['PhpOffice\\PhpPresentation\\Autoloader', 'autoload'],
spl_autoload_functions()
);
@@ -48,9 +47,9 @@ public function testAutoload(): void
$declared = get_declared_classes();
$declaredCount = count($declared);
Autoloader::autoload('Foo');
- $this->assertEquals(
+ self::assertCount(
$declaredCount,
- count(get_declared_classes()),
+ get_declared_classes(),
'PhpOffice\\PhpPresentation\\Autoloader::autoload() is trying to load ' .
'classes outside of the PhpOffice\\PhpPresentation namespace'
);
diff --git a/tests/PhpPresentation/Tests/DocumentLayoutTest.php b/tests/PhpPresentation/Tests/DocumentLayoutTest.php
index 1d1c1c4883..e5961edb59 100644
--- a/tests/PhpPresentation/Tests/DocumentLayoutTest.php
+++ b/tests/PhpPresentation/Tests/DocumentLayoutTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,9 +36,9 @@ public function testConstruct(): void
{
$object = new DocumentLayout();
- $this->assertEquals('screen4x3', $object->getDocumentLayout());
- $this->assertEquals(9144000, $object->getCX());
- $this->assertEquals(6858000, $object->getCY());
+ self::assertEquals('screen4x3', $object->getDocumentLayout());
+ self::assertEquals(9144000, $object->getCX());
+ self::assertEquals(6858000, $object->getCY());
}
/**
@@ -49,52 +48,70 @@ public function testSetCustomLayout(): void
{
$object = new DocumentLayout();
$object->setDocumentLayout(['cx' => 6858000, 'cy' => 9144000], false);
- $this->assertEquals(DocumentLayout::LAYOUT_CUSTOM, $object->getDocumentLayout());
- $this->assertEquals(9144000, $object->getCX());
- $this->assertEquals(6858000, $object->getCY());
+ self::assertEquals(DocumentLayout::LAYOUT_CUSTOM, $object->getDocumentLayout());
+ self::assertEquals(9144000, $object->getCX());
+ self::assertEquals(6858000, $object->getCY());
$object->setDocumentLayout(['cx' => 6858000, 'cy' => 9144000], true);
- $this->assertEquals(DocumentLayout::LAYOUT_CUSTOM, $object->getDocumentLayout());
- $this->assertEquals(6858000, $object->getCX());
- $this->assertEquals(9144000, $object->getCY());
+ self::assertEquals(DocumentLayout::LAYOUT_CUSTOM, $object->getDocumentLayout());
+ self::assertEquals(6858000, $object->getCX());
+ self::assertEquals(9144000, $object->getCY());
+ }
+
+ /**
+ * Test set custom layout.
+ */
+ public function testSetCustomLayoutWithString(): void
+ {
+ $object = new DocumentLayout();
+ $object->setDocumentLayout(DocumentLayout::LAYOUT_CUSTOM);
+ self::assertEquals(DocumentLayout::LAYOUT_CUSTOM, $object->getDocumentLayout());
+ // Default value
+ self::assertEquals(9144000, $object->getCX());
+ self::assertEquals(6858000, $object->getCY());
+
+ $object->setCX(13.333, DocumentLayout::UNIT_CENTIMETER);
+ $object->setCY(7.5, DocumentLayout::UNIT_CENTIMETER);
+ self::assertEquals(4799880, $object->getCX());
+ self::assertEquals(2700000, $object->getCY());
}
public function testCX(): void
{
$value = mt_rand(1, 100000);
$object = new DocumentLayout();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value));
- $this->assertEquals($value, $object->getCX());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_CENTIMETER));
- $this->assertEquals($value, $object->getCX(DocumentLayout::UNIT_CENTIMETER));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_EMU));
- $this->assertEquals($value, $object->getCX(DocumentLayout::UNIT_EMU));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_INCH));
- $this->assertEquals($value, $object->getCX(DocumentLayout::UNIT_INCH));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_MILLIMETER));
- $this->assertEquals($value, $object->getCX(DocumentLayout::UNIT_MILLIMETER));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_POINT));
- $this->assertEquals($value, $object->getCX(DocumentLayout::UNIT_POINT));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_PIXEL));
- $this->assertEquals($value, $object->getCX(DocumentLayout::UNIT_PIXEL));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value));
+ self::assertEquals($value, $object->getCX());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_CENTIMETER));
+ self::assertEquals($value, $object->getCX(DocumentLayout::UNIT_CENTIMETER));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_EMU));
+ self::assertEquals($value, $object->getCX(DocumentLayout::UNIT_EMU));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_INCH));
+ self::assertEquals($value, $object->getCX(DocumentLayout::UNIT_INCH));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_MILLIMETER));
+ self::assertEquals($value, $object->getCX(DocumentLayout::UNIT_MILLIMETER));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_POINT));
+ self::assertEquals($value, $object->getCX(DocumentLayout::UNIT_POINT));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCX($value, DocumentLayout::UNIT_PIXEL));
+ self::assertEquals($value, $object->getCX(DocumentLayout::UNIT_PIXEL));
}
public function testCY(): void
{
$value = mt_rand(1, 100000);
$object = new DocumentLayout();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value));
- $this->assertEquals($value, $object->getCY());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_CENTIMETER));
- $this->assertEquals($value, $object->getCY(DocumentLayout::UNIT_CENTIMETER));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_EMU));
- $this->assertEquals($value, $object->getCY(DocumentLayout::UNIT_EMU));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_INCH));
- $this->assertEquals($value, $object->getCY(DocumentLayout::UNIT_INCH));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_MILLIMETER));
- $this->assertEquals($value, $object->getCY(DocumentLayout::UNIT_MILLIMETER));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_POINT));
- $this->assertEquals($value, $object->getCY(DocumentLayout::UNIT_POINT));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_PIXEL));
- $this->assertEquals($value, $object->getCY(DocumentLayout::UNIT_PIXEL));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value));
+ self::assertEquals($value, $object->getCY());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_CENTIMETER));
+ self::assertEquals($value, $object->getCY(DocumentLayout::UNIT_CENTIMETER));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_EMU));
+ self::assertEquals($value, $object->getCY(DocumentLayout::UNIT_EMU));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_INCH));
+ self::assertEquals($value, $object->getCY(DocumentLayout::UNIT_INCH));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_MILLIMETER));
+ self::assertEquals($value, $object->getCY(DocumentLayout::UNIT_MILLIMETER));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_POINT));
+ self::assertEquals($value, $object->getCY(DocumentLayout::UNIT_POINT));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentLayout', $object->setCY($value, DocumentLayout::UNIT_PIXEL));
+ self::assertEquals($value, $object->getCY(DocumentLayout::UNIT_PIXEL));
}
}
diff --git a/tests/PhpPresentation/Tests/DocumentPropertiesTest.php b/tests/PhpPresentation/Tests/DocumentPropertiesTest.php
index 3e520d0457..dd2a4d9227 100644
--- a/tests/PhpPresentation/Tests/DocumentPropertiesTest.php
+++ b/tests/PhpPresentation/Tests/DocumentPropertiesTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -47,13 +46,15 @@ public function testGetSet(): void
'keywords' => '',
'category' => '',
'company' => '',
+ 'revision' => '',
+ 'status' => '',
];
foreach ($properties as $key => $val) {
$get = "get{$key}";
$set = "set{$key}";
$object->$set($val);
- $this->assertEquals($val, $object->$get());
+ self::assertEquals($val, $object->$get());
}
}
@@ -73,7 +74,7 @@ public function testGetSetNull(): void
$get = "get{$key}";
$set = "set{$key}";
$object->$set();
- $this->assertEquals($time, $object->$get());
+ self::assertEquals($time, $object->$get());
}
}
@@ -82,52 +83,52 @@ public function testCustomProperties(): void
$valueTime = time();
$object = new DocumentProperties();
- $this->assertIsArray($object->getCustomProperties());
- $this->assertCount(0, $object->getCustomProperties());
- $this->assertFalse($object->isCustomPropertySet('pName'));
- $this->assertNull($object->getCustomPropertyType('pName'));
- $this->assertNull($object->getCustomPropertyValue('pName'));
-
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', 'pValue', null));
- $this->assertCount(1, $object->getCustomProperties());
- $this->assertTrue($object->isCustomPropertySet('pName'));
- $this->assertEquals(DocumentProperties::PROPERTY_TYPE_STRING, $object->getCustomPropertyType('pName'));
- $this->assertEquals('pValue', $object->getCustomPropertyValue('pName'));
-
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', 2, null));
- $this->assertCount(1, $object->getCustomProperties());
- $this->assertTrue($object->isCustomPropertySet('pName'));
- $this->assertEquals(DocumentProperties::PROPERTY_TYPE_INTEGER, $object->getCustomPropertyType('pName'));
- $this->assertEquals(2, $object->getCustomPropertyValue('pName'));
-
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', 2.1, null));
- $this->assertCount(1, $object->getCustomProperties());
- $this->assertTrue($object->isCustomPropertySet('pName'));
- $this->assertEquals(DocumentProperties::PROPERTY_TYPE_FLOAT, $object->getCustomPropertyType('pName'));
- $this->assertEquals(2.1, $object->getCustomPropertyValue('pName'));
-
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', true, null));
- $this->assertCount(1, $object->getCustomProperties());
- $this->assertTrue($object->isCustomPropertySet('pName'));
- $this->assertEquals(DocumentProperties::PROPERTY_TYPE_BOOLEAN, $object->getCustomPropertyType('pName'));
- $this->assertEquals(true, $object->getCustomPropertyValue('pName'));
-
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', null, null));
- $this->assertCount(1, $object->getCustomProperties());
- $this->assertTrue($object->isCustomPropertySet('pName'));
- $this->assertEquals(DocumentProperties::PROPERTY_TYPE_STRING, $object->getCustomPropertyType('pName'));
- $this->assertEquals(null, $object->getCustomPropertyValue('pName'));
-
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', $valueTime, DocumentProperties::PROPERTY_TYPE_DATE));
- $this->assertCount(1, $object->getCustomProperties());
- $this->assertTrue($object->isCustomPropertySet('pName'));
- $this->assertEquals(DocumentProperties::PROPERTY_TYPE_DATE, $object->getCustomPropertyType('pName'));
- $this->assertEquals($valueTime, $object->getCustomPropertyValue('pName'));
-
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', (string) $valueTime, DocumentProperties::PROPERTY_TYPE_UNKNOWN));
- $this->assertCount(1, $object->getCustomProperties());
- $this->assertTrue($object->isCustomPropertySet('pName'));
- $this->assertEquals(DocumentProperties::PROPERTY_TYPE_STRING, $object->getCustomPropertyType('pName'));
- $this->assertEquals($valueTime, $object->getCustomPropertyValue('pName'));
+ self::assertIsArray($object->getCustomProperties());
+ self::assertCount(0, $object->getCustomProperties());
+ self::assertFalse($object->isCustomPropertySet('pName'));
+ self::assertNull($object->getCustomPropertyType('pName'));
+ self::assertNull($object->getCustomPropertyValue('pName'));
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', 'pValue', null));
+ self::assertCount(1, $object->getCustomProperties());
+ self::assertTrue($object->isCustomPropertySet('pName'));
+ self::assertEquals(DocumentProperties::PROPERTY_TYPE_STRING, $object->getCustomPropertyType('pName'));
+ self::assertEquals('pValue', $object->getCustomPropertyValue('pName'));
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', 2, null));
+ self::assertCount(1, $object->getCustomProperties());
+ self::assertTrue($object->isCustomPropertySet('pName'));
+ self::assertEquals(DocumentProperties::PROPERTY_TYPE_INTEGER, $object->getCustomPropertyType('pName'));
+ self::assertEquals(2, $object->getCustomPropertyValue('pName'));
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', 2.1, null));
+ self::assertCount(1, $object->getCustomProperties());
+ self::assertTrue($object->isCustomPropertySet('pName'));
+ self::assertEquals(DocumentProperties::PROPERTY_TYPE_FLOAT, $object->getCustomPropertyType('pName'));
+ self::assertEquals(2.1, $object->getCustomPropertyValue('pName'));
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', true, null));
+ self::assertCount(1, $object->getCustomProperties());
+ self::assertTrue($object->isCustomPropertySet('pName'));
+ self::assertEquals(DocumentProperties::PROPERTY_TYPE_BOOLEAN, $object->getCustomPropertyType('pName'));
+ self::assertTrue($object->getCustomPropertyValue('pName'));
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', null, null));
+ self::assertCount(1, $object->getCustomProperties());
+ self::assertTrue($object->isCustomPropertySet('pName'));
+ self::assertEquals(DocumentProperties::PROPERTY_TYPE_STRING, $object->getCustomPropertyType('pName'));
+ self::assertNull($object->getCustomPropertyValue('pName'));
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', $valueTime, DocumentProperties::PROPERTY_TYPE_DATE));
+ self::assertCount(1, $object->getCustomProperties());
+ self::assertTrue($object->isCustomPropertySet('pName'));
+ self::assertEquals(DocumentProperties::PROPERTY_TYPE_DATE, $object->getCustomPropertyType('pName'));
+ self::assertEquals($valueTime, $object->getCustomPropertyValue('pName'));
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->setCustomProperty('pName', (string) $valueTime, DocumentProperties::PROPERTY_TYPE_UNKNOWN));
+ self::assertCount(1, $object->getCustomProperties());
+ self::assertTrue($object->isCustomPropertySet('pName'));
+ self::assertEquals(DocumentProperties::PROPERTY_TYPE_STRING, $object->getCustomPropertyType('pName'));
+ self::assertEquals($valueTime, $object->getCustomPropertyValue('pName'));
}
}
diff --git a/tests/PhpPresentation/Tests/HashTableTest.php b/tests/PhpPresentation/Tests/HashTableTest.php
index 18c3a149a5..e6503135c6 100644
--- a/tests/PhpPresentation/Tests/HashTableTest.php
+++ b/tests/PhpPresentation/Tests/HashTableTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,11 +34,11 @@ public function testConstructNull(): void
{
$object = new HashTable();
- $this->assertEquals(0, $object->count());
- $this->assertNull($object->getByIndex());
- $this->assertNull($object->getByHashCode());
- $this->assertIsArray($object->toArray());
- $this->assertEmpty($object->toArray());
+ self::assertEquals(0, $object->count());
+ self::assertNull($object->getByIndex());
+ self::assertNull($object->getByHashCode());
+ self::assertIsArray($object->toArray());
+ self::assertEmpty($object->toArray());
}
public function testConstructSource(): void
@@ -49,9 +48,9 @@ public function testConstructSource(): void
new Slide(),
]);
- $this->assertEquals(2, $object->count());
- $this->assertIsArray($object->toArray());
- $this->assertCount(2, $object->toArray());
+ self::assertEquals(2, $object->count());
+ self::assertIsArray($object->toArray());
+ self::assertCount(2, $object->toArray());
}
public function testAdd(): void
@@ -63,22 +62,22 @@ public function testAdd(): void
$object->addFromSource();
// Add From Source : Array
$object->addFromSource([$oSlide]);
- $this->assertIsArray($object->toArray());
- $this->assertCount(1, $object->toArray());
+ self::assertIsArray($object->toArray());
+ self::assertCount(1, $object->toArray());
// Clear
$object->clear();
- $this->assertEmpty($object->toArray());
+ self::assertEmpty($object->toArray());
// Add Object
$object->add($oSlide);
- $this->assertCount(1, $object->toArray());
+ self::assertCount(1, $object->toArray());
$object->clear();
// Add Object w/Hash Index
- $oSlide->setHashIndex(rand(1, 100));
+ $oSlide->setHashIndex(mt_rand(1, 100));
$object->add($oSlide);
- $this->assertCount(1, $object->toArray());
+ self::assertCount(1, $object->toArray());
// Add Object w/the same Hash Index
$object->add($oSlide);
- $this->assertCount(1, $object->toArray());
+ self::assertCount(1, $object->toArray());
}
public function testIndex(): void
@@ -91,10 +90,10 @@ public function testIndex(): void
$object->add($oSlide1);
$object->add($oSlide2);
// Index
- $this->assertEquals(0, $object->getIndexForHashCode($oSlide1->getHashCode()));
- $this->assertEquals(1, $object->getIndexForHashCode($oSlide2->getHashCode()));
- $this->assertEquals($oSlide1, $object->getByIndex(0));
- $this->assertEquals($oSlide2, $object->getByIndex(1));
+ self::assertEquals(0, $object->getIndexForHashCode($oSlide1->getHashCode()));
+ self::assertEquals(1, $object->getIndexForHashCode($oSlide2->getHashCode()));
+ self::assertEquals($oSlide1, $object->getByIndex(0));
+ self::assertEquals($oSlide2, $object->getByIndex(1));
}
public function testRemove(): void
@@ -110,8 +109,8 @@ public function testRemove(): void
$object->add($oSlide3);
// Remove
$object->remove($oSlide2);
- $this->assertCount(2, $object->toArray());
+ self::assertCount(2, $object->toArray());
$object->remove($oSlide3);
- $this->assertCount(1, $object->toArray());
+ self::assertCount(1, $object->toArray());
}
}
diff --git a/tests/PhpPresentation/Tests/IOFactoryTest.php b/tests/PhpPresentation/Tests/IOFactoryTest.php
index d17f615482..504890891f 100644
--- a/tests/PhpPresentation/Tests/IOFactoryTest.php
+++ b/tests/PhpPresentation/Tests/IOFactoryTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -40,7 +39,7 @@ public function testCreateWriter(): void
{
$class = 'PhpOffice\\PhpPresentation\\Writer\\PowerPoint2007';
- $this->assertInstanceOf($class, IOFactory::createWriter(new PhpPresentation()));
+ self::assertInstanceOf($class, IOFactory::createWriter(new PhpPresentation()));
}
/**
@@ -50,7 +49,7 @@ public function testCreateReader(): void
{
$class = 'PhpOffice\\PhpPresentation\\Reader\\ReaderInterface';
- $this->assertInstanceOf($class, IOFactory::createReader('Serialized'));
+ self::assertInstanceOf($class, IOFactory::createReader('Serialized'));
}
/**
@@ -65,7 +64,7 @@ public function testLoadClassException(): void
public function testLoad(): void
{
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', IOFactory::load(PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'serialized.phppt'));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', IOFactory::load(PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'serialized.phppt'));
}
/**
diff --git a/tests/PhpPresentation/Tests/PhpPresentationTest.php b/tests/PhpPresentation/Tests/PhpPresentationTest.php
index 3370f92460..496db5e1e4 100644
--- a/tests/PhpPresentation/Tests/PhpPresentationTest.php
+++ b/tests/PhpPresentation/Tests/PhpPresentationTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,6 +24,7 @@
use PhpOffice\PhpPresentation\Exception\OutOfBoundsException;
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\PresentationProperties;
+use PhpOffice\PhpPresentation\Slide;
use PHPUnit\Framework\TestCase;
/**
@@ -42,30 +42,30 @@ public function testConstruct(): void
$object = new PhpPresentation();
$slide = $object->getSlide();
- $this->assertEquals(new DocumentProperties(), $object->getDocumentProperties());
- $this->assertEquals(new DocumentLayout(), $object->getLayout());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getSlide());
- $this->assertCount(1, $object->getAllSlides());
- $this->assertEquals(0, $object->getIndex($slide));
- $this->assertEquals(1, $object->getSlideCount());
- $this->assertEquals(0, $object->getActiveSlideIndex());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Iterator', $object->getSlideIterator());
+ self::assertEquals(new DocumentProperties(), $object->getDocumentProperties());
+ self::assertEquals(new DocumentLayout(), $object->getLayout());
+ self::assertInstanceOf(Slide::class, $object->getSlide());
+ self::assertCount(1, $object->getAllSlides());
+ self::assertEquals(0, $object->getIndex($slide));
+ self::assertEquals(1, $object->getSlideCount());
+ self::assertEquals(0, $object->getActiveSlideIndex());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Iterator', $object->getSlideIterator());
}
public function testProperties(): void
{
$object = new PhpPresentation();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setDocumentProperties(new DocumentProperties()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setDocumentProperties(new DocumentProperties()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
}
public function testPresentationProperties(): void
{
$object = new PhpPresentation();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->getPresentationProperties());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setPresentationProperties(new PresentationProperties()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->getPresentationProperties());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->getPresentationProperties());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setPresentationProperties(new PresentationProperties()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->getPresentationProperties());
}
/**
@@ -78,7 +78,7 @@ public function testAddExternalSlide(): void
$object = new PhpPresentation();
$object->addExternalSlide($slide);
- $this->assertEquals(2, $object->getSlideCount());
+ self::assertEquals(2, $object->getSlideCount());
}
/**
@@ -87,7 +87,12 @@ public function testAddExternalSlide(): void
public function testCopy(): void
{
$object = new PhpPresentation();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->copy());
+ $object->createSlide();
+
+ $copy = $object->copy();
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $copy);
+ self::assertEquals(2, $copy->getSlideCount());
}
/**
@@ -125,4 +130,64 @@ public function testSetActiveSlideIndexException(): void
$object = new PhpPresentation();
$object->setActiveSlideIndex(1);
}
+
+ public function testAddSlideAtStart(): void
+ {
+ $presentation = new PhpPresentation();
+ $presentation->removeSlideByIndex(0);
+ $slide1 = new Slide($presentation);
+ $slide1->setName('Slide 1');
+ $slide2 = new Slide($presentation);
+ $slide2->setName('Slide 2');
+ $slide3 = new Slide($presentation);
+ $slide3->setName('Slide 3');
+
+ $presentation->addSlide($slide1);
+ $presentation->addSlide($slide2);
+ $presentation->addSlide($slide3, 0);
+
+ self::assertEquals('Slide 3', $presentation->getSlide(0)->getName());
+ self::assertEquals('Slide 1', $presentation->getSlide(1)->getName());
+ self::assertEquals('Slide 2', $presentation->getSlide(2)->getName());
+ }
+
+ public function testAddSlideAtMiddle(): void
+ {
+ $presentation = new PhpPresentation();
+ $presentation->removeSlideByIndex(0);
+ $slide1 = new Slide($presentation);
+ $slide1->setName('Slide 1');
+ $slide2 = new Slide($presentation);
+ $slide2->setName('Slide 2');
+ $slide3 = new Slide($presentation);
+ $slide3->setName('Slide 3');
+
+ $presentation->addSlide($slide1);
+ $presentation->addSlide($slide2);
+ $presentation->addSlide($slide3, 1);
+
+ self::assertEquals('Slide 1', $presentation->getSlide(0)->getName());
+ self::assertEquals('Slide 3', $presentation->getSlide(1)->getName());
+ self::assertEquals('Slide 2', $presentation->getSlide(2)->getName());
+ }
+
+ public function testAddSlideAtEnd(): void
+ {
+ $presentation = new PhpPresentation();
+ $presentation->removeSlideByIndex(0);
+ $slide1 = new Slide($presentation);
+ $slide1->setName('Slide 1');
+ $slide2 = new Slide($presentation);
+ $slide2->setName('Slide 2');
+ $slide3 = new Slide($presentation);
+ $slide3->setName('Slide 3');
+
+ $presentation->addSlide($slide1);
+ $presentation->addSlide($slide2);
+ $presentation->addSlide($slide3);
+
+ self::assertEquals('Slide 1', $presentation->getSlide(0)->getName());
+ self::assertEquals('Slide 2', $presentation->getSlide(1)->getName());
+ self::assertEquals('Slide 3', $presentation->getSlide(2)->getName());
+ }
}
diff --git a/tests/PhpPresentation/Tests/PresentationPropertiesTest.php b/tests/PhpPresentation/Tests/PresentationPropertiesTest.php
index 56d88f5d4a..88b0920d79 100644
--- a/tests/PhpPresentation/Tests/PresentationPropertiesTest.php
+++ b/tests/PhpPresentation/Tests/PresentationPropertiesTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,49 +32,49 @@ class PresentationPropertiesTest extends TestCase
public function testCommentVisible(): void
{
$object = new PresentationProperties();
- $this->assertFalse($object->isCommentVisible());
- $this->assertInstanceOf(PresentationProperties::class, $object->setCommentVisible(true));
- $this->assertTrue($object->isCommentVisible());
- $this->assertInstanceOf(PresentationProperties::class, $object->setCommentVisible(false));
- $this->assertFalse($object->isCommentVisible());
- $this->assertInstanceOf(PresentationProperties::class, $object->setCommentVisible());
- $this->assertFalse($object->isCommentVisible());
+ self::assertFalse($object->isCommentVisible());
+ self::assertInstanceOf(PresentationProperties::class, $object->setCommentVisible(true));
+ self::assertTrue($object->isCommentVisible());
+ self::assertInstanceOf(PresentationProperties::class, $object->setCommentVisible(false));
+ self::assertFalse($object->isCommentVisible());
+ self::assertInstanceOf(PresentationProperties::class, $object->setCommentVisible());
+ self::assertFalse($object->isCommentVisible());
}
public function testLoopUntilEsc(): void
{
$object = new PresentationProperties();
- $this->assertFalse($object->isLoopContinuouslyUntilEsc());
- $this->assertInstanceOf(PresentationProperties::class, $object->setLoopContinuouslyUntilEsc(true));
- $this->assertTrue($object->isLoopContinuouslyUntilEsc());
- $this->assertInstanceOf(PresentationProperties::class, $object->setLoopContinuouslyUntilEsc(false));
- $this->assertFalse($object->isLoopContinuouslyUntilEsc());
- $this->assertInstanceOf(PresentationProperties::class, $object->setLoopContinuouslyUntilEsc());
- $this->assertFalse($object->isLoopContinuouslyUntilEsc());
+ self::assertFalse($object->isLoopContinuouslyUntilEsc());
+ self::assertInstanceOf(PresentationProperties::class, $object->setLoopContinuouslyUntilEsc(true));
+ self::assertTrue($object->isLoopContinuouslyUntilEsc());
+ self::assertInstanceOf(PresentationProperties::class, $object->setLoopContinuouslyUntilEsc(false));
+ self::assertFalse($object->isLoopContinuouslyUntilEsc());
+ self::assertInstanceOf(PresentationProperties::class, $object->setLoopContinuouslyUntilEsc());
+ self::assertFalse($object->isLoopContinuouslyUntilEsc());
}
public function testLastView(): void
{
$object = new PresentationProperties();
- $this->assertEquals(PresentationProperties::VIEW_SLIDE, $object->getLastView());
- $this->assertInstanceOf(PresentationProperties::class, $object->setLastView('AAAA'));
- $this->assertEquals(PresentationProperties::VIEW_SLIDE, $object->getLastView());
- $this->assertInstanceOf(PresentationProperties::class, $object->setLastView(PresentationProperties::VIEW_OUTLINE));
- $this->assertEquals(PresentationProperties::VIEW_OUTLINE, $object->getLastView());
- $this->assertInstanceOf(PresentationProperties::class, $object->setLastView());
- $this->assertEquals(PresentationProperties::VIEW_SLIDE, $object->getLastView());
+ self::assertEquals(PresentationProperties::VIEW_SLIDE, $object->getLastView());
+ self::assertInstanceOf(PresentationProperties::class, $object->setLastView('AAAA'));
+ self::assertEquals(PresentationProperties::VIEW_SLIDE, $object->getLastView());
+ self::assertInstanceOf(PresentationProperties::class, $object->setLastView(PresentationProperties::VIEW_OUTLINE));
+ self::assertEquals(PresentationProperties::VIEW_OUTLINE, $object->getLastView());
+ self::assertInstanceOf(PresentationProperties::class, $object->setLastView());
+ self::assertEquals(PresentationProperties::VIEW_SLIDE, $object->getLastView());
}
public function testMarkAsFinal(): void
{
$object = new PresentationProperties();
- $this->assertFalse($object->isMarkedAsFinal());
- $this->assertInstanceOf(PresentationProperties::class, $object->markAsFinal(true));
- $this->assertTrue($object->isMarkedAsFinal());
- $this->assertInstanceOf(PresentationProperties::class, $object->markAsFinal(false));
- $this->assertFalse($object->isMarkedAsFinal());
- $this->assertInstanceOf(PresentationProperties::class, $object->markAsFinal());
- $this->assertTrue($object->isMarkedAsFinal());
+ self::assertFalse($object->isMarkedAsFinal());
+ self::assertInstanceOf(PresentationProperties::class, $object->markAsFinal(true));
+ self::assertTrue($object->isMarkedAsFinal());
+ self::assertInstanceOf(PresentationProperties::class, $object->markAsFinal(false));
+ self::assertFalse($object->isMarkedAsFinal());
+ self::assertInstanceOf(PresentationProperties::class, $object->markAsFinal());
+ self::assertTrue($object->isMarkedAsFinal());
}
/**
@@ -85,21 +84,21 @@ public function testSlideshowType(?string $value, string $expected): void
{
$object = new PresentationProperties();
// Default
- $this->assertEquals(PresentationProperties::SLIDESHOW_TYPE_PRESENT, $object->getSlideshowType());
+ self::assertEquals(PresentationProperties::SLIDESHOW_TYPE_PRESENT, $object->getSlideshowType());
// Set value
- if (is_null($value)) {
- $this->assertInstanceOf(PresentationProperties::class, $object->setSlideshowType());
+ if (null === $value) {
+ self::assertInstanceOf(PresentationProperties::class, $object->setSlideshowType());
} else {
- $this->assertInstanceOf(PresentationProperties::class, $object->setSlideshowType($value));
+ self::assertInstanceOf(PresentationProperties::class, $object->setSlideshowType($value));
}
// Check value
- $this->assertEquals($expected, $object->getSlideshowType());
+ self::assertEquals($expected, $object->getSlideshowType());
}
/**
- * @return array>
+ * @return array>
*/
- public function dataProviderSlideshowType(): array
+ public static function dataProviderSlideshowType(): array
{
return [
[
@@ -130,24 +129,46 @@ public function testThumbnail(): void
$imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
$object = new PresentationProperties();
- $this->assertNull($object->getThumbnailPath());
- $this->assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath('AAAA'));
- $this->assertNull($object->getThumbnailPath());
- $this->assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath());
- $this->assertNull($object->getThumbnailPath());
- $this->assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath($imagePath));
- $this->assertEquals($imagePath, $object->getThumbnailPath());
- $this->assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath());
- $this->assertEquals($imagePath, $object->getThumbnailPath());
+ self::assertNull($object->getThumbnailPath());
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath('AAAA', PresentationProperties::THUMBNAIL_FILE));
+ self::assertNull($object->getThumbnailPath());
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath());
+ self::assertNull($object->getThumbnailPath());
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_FILE));
+ self::assertEquals($imagePath, $object->getThumbnailPath());
+ self::assertIsString($object->getThumbnail());
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath());
+ self::assertEquals($imagePath, $object->getThumbnailPath());
+ self::assertIsString($object->getThumbnail());
+ }
+
+ public function testThumbnailFileNotExisting(): void
+ {
+ $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'NotExistingFile.png';
+
+ $object = new PresentationProperties();
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_FILE));
+ self::assertNull($object->getThumbnailPath());
+ self::assertNull($object->getThumbnail());
+ }
+
+ public function testThumbnailFileData(): void
+ {
+ $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
+
+ $object = new PresentationProperties();
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_DATA, file_get_contents($imagePath)));
+ self::assertEquals('', $object->getThumbnailPath());
+ self::assertIsString($object->getThumbnail());
}
public function testZoom(): void
{
$object = new PresentationProperties();
- $this->assertEquals(1, $object->getZoom());
- $this->assertInstanceOf(PresentationProperties::class, $object->setZoom(2.3));
- $this->assertEquals(2.3, $object->getZoom());
- $this->assertInstanceOf(PresentationProperties::class, $object->setZoom());
- $this->assertEquals(1, $object->getZoom());
+ self::assertEquals(1, $object->getZoom());
+ self::assertInstanceOf(PresentationProperties::class, $object->setZoom(2.3));
+ self::assertEquals(2.3, $object->getZoom());
+ self::assertInstanceOf(PresentationProperties::class, $object->setZoom());
+ self::assertEquals(1, $object->getZoom());
}
}
diff --git a/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php b/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php
index 418215bbf5..2b50861dbb 100644
--- a/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php
+++ b/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -47,16 +46,16 @@ public function testCanRead(): void
$object = new ODPresentation();
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.ppt';
- $this->assertFalse($object->canRead($file));
+ self::assertFalse($object->canRead($file));
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/serialized.phppt';
- $this->assertFalse($object->canRead($file));
+ self::assertFalse($object->canRead($file));
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.pptx';
- $this->assertFalse($object->canRead($file));
+ self::assertFalse($object->canRead($file));
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.odp';
- $this->assertTrue($object->canRead($file));
+ self::assertTrue($object->canRead($file));
}
public function testLoadFileNotExists(): void
@@ -95,475 +94,493 @@ public function testLoadFile01(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.odp';
$object = new ODPresentation();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
// Document Properties
- $this->assertEquals('PHPOffice', $oPhpPresentation->getDocumentProperties()->getCreator());
- $this->assertEquals('PHPPresentation Team', $oPhpPresentation->getDocumentProperties()->getLastModifiedBy());
- $this->assertEquals('Sample 02 Title', $oPhpPresentation->getDocumentProperties()->getTitle());
- $this->assertEquals('Sample 02 Subject', $oPhpPresentation->getDocumentProperties()->getSubject());
- $this->assertEquals('Sample 02 Description', $oPhpPresentation->getDocumentProperties()->getDescription());
- $this->assertEquals('office 2007 openxml libreoffice odt php', $oPhpPresentation->getDocumentProperties()->getKeywords());
- $this->assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
- $this->assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());
+ self::assertEquals('PHPOffice', $oPhpPresentation->getDocumentProperties()->getCreator());
+ self::assertEquals('PHPPresentation Team', $oPhpPresentation->getDocumentProperties()->getLastModifiedBy());
+ self::assertEquals('Sample 02 Title', $oPhpPresentation->getDocumentProperties()->getTitle());
+ self::assertEquals('Sample 02 Subject', $oPhpPresentation->getDocumentProperties()->getSubject());
+ self::assertEquals('Sample 02 Description', $oPhpPresentation->getDocumentProperties()->getDescription());
+ self::assertEquals('office 2007 openxml libreoffice odt php', $oPhpPresentation->getDocumentProperties()->getKeywords());
+ self::assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
+ self::assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());
// Presentation Properties
- $this->assertEquals(PresentationProperties::SLIDESHOW_TYPE_PRESENT, $oPhpPresentation->getPresentationProperties()->getSlideshowType());
+ self::assertEquals(PresentationProperties::SLIDESHOW_TYPE_PRESENT, $oPhpPresentation->getPresentationProperties()->getSlideshowType());
- $this->assertCount(4, $oPhpPresentation->getAllSlides());
+ self::assertCount(4, $oPhpPresentation->getAllSlides());
// Slide 1
$oSlide1 = $oPhpPresentation->getSlide(0);
$arrayShape = (array) $oSlide1->getShapeCollection();
- $this->assertCount(2, $arrayShape);
+ self::assertCount(2, $arrayShape);
// Slide 1 : Shape 1
/** @var Gd $oShape */
$oShape = $arrayShape[0];
- $this->assertInstanceOf(Gd::class, $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertEquals('image/png', $oShape->getMimeType());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
+ self::assertInstanceOf(Gd::class, $oShape);
+ self::assertEquals('PHPPresentation logo', $oShape->getName());
+ self::assertEquals('PHPPresentation logo', $oShape->getDescription());
+ self::assertEquals(36, $oShape->getHeight());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(10, $oShape->getOffsetY());
+ self::assertEquals('image/png', $oShape->getMimeType());
+ self::assertTrue($oShape->getShadow()->isVisible());
+ self::assertEquals(45, $oShape->getShadow()->getDirection());
+ self::assertEquals(10, $oShape->getShadow()->getDistance());
// Slide 1 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[1];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(200, $oShape->getHeight());
- $this->assertEquals(600, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(400, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(200, $oShape->getHeight());
+ self::assertEquals(600, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(400, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $oParagraph);
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
- $this->assertEquals(0, $oParagraph->getSpacingAfter());
- $this->assertEquals(0, $oParagraph->getSpacingBefore());
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
- $this->assertEquals(100, $oParagraph->getLineSpacing());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $oParagraph);
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(0, $oParagraph->getSpacingAfter());
+ self::assertEquals(0, $oParagraph->getSpacingBefore());
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
+ self::assertEquals(100, $oParagraph->getLineSpacing());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(3, $arrayRichText);
+ self::assertCount(3, $arrayRichText);
// Slide 1 : Shape 2 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Introduction to', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(28, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Introduction to', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(28, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 1 : Shape 2 : Paragraph 2
$oRichText = $arrayRichText[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
// Slide 1 : Shape 2 : Paragraph 3
$oRichText = $arrayRichText[2];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('PHPPresentation', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(60, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('PHPPresentation', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(60, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 2
$oSlide2 = $oPhpPresentation->getSlide(1);
$arrayShape = (array) $oSlide2->getShapeCollection();
- $this->assertCount(3, $arrayShape);
+ self::assertCount(3, $arrayShape);
// Slide 2 : Shape 1
/** @var Gd $oShape */
$oShape = $arrayShape[0];
- $this->assertInstanceOf(Gd::class, $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertEquals('image/png', $oShape->getMimeType());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
+ self::assertInstanceOf(Gd::class, $oShape);
+ self::assertEquals('PHPPresentation logo', $oShape->getName());
+ self::assertEquals('PHPPresentation logo', $oShape->getDescription());
+ self::assertEquals(36, $oShape->getHeight());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(10, $oShape->getOffsetY());
+ self::assertEquals('image/png', $oShape->getMimeType());
+ self::assertTrue($oShape->getShadow()->isVisible());
+ self::assertEquals(45, $oShape->getShadow()->getDirection());
+ self::assertEquals(10, $oShape->getShadow()->getDistance());
// Slide 2 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[1];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(100, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(50, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(100, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(50, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
// Slide 2 : Shape 2 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('What is PHPPresentation?', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(48, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('What is PHPPresentation?', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(48, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
// Slide 2 : Shape 3
/** @var RichText $oShape */
$oShape = $arrayShape[2];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(600, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(130, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(600, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(130, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(4, $arrayParagraphs);
+ self::assertCount(4, $arrayParagraphs);
// Slide 2 : Shape 3 : Paragraph 1
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('A class library', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('A class library', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 2 : Shape 3 : Paragraph 2
$oParagraph = $arrayParagraphs[1];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Written in PHP', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Written in PHP', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 2 : Shape 3 : Paragraph 3
$oParagraph = $arrayParagraphs[2];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Representing a presentation', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Representing a presentation', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 2 : Shape 3 : Paragraph 4
$oParagraph = $arrayParagraphs[3];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Supports writing to different file formats', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Supports writing to different file formats', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3
$oSlide2 = $oPhpPresentation->getSlide(2);
$arrayShape = (array) $oSlide2->getShapeCollection();
- $this->assertCount(3, $arrayShape);
+ self::assertCount(3, $arrayShape);
// Slide 3 : Shape 1
/** @var Gd $oShape */
$oShape = $arrayShape[0];
- $this->assertInstanceOf(Gd::class, $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertEquals('image/png', $oShape->getMimeType());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
+ self::assertInstanceOf(Gd::class, $oShape);
+ self::assertEquals('PHPPresentation logo', $oShape->getName());
+ self::assertEquals('PHPPresentation logo', $oShape->getDescription());
+ self::assertEquals(36, $oShape->getHeight());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(10, $oShape->getOffsetY());
+ self::assertEquals('image/png', $oShape->getMimeType());
+ self::assertTrue($oShape->getShadow()->isVisible());
+ self::assertEquals(45, $oShape->getShadow()->getDirection());
+ self::assertEquals(10, $oShape->getShadow()->getDistance());
// Slide 3 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[1];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(100, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(50, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(100, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(50, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
- $this->assertEquals(0, $oParagraph->getSpacingAfter());
- $this->assertEquals(0, $oParagraph->getSpacingBefore());
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
- $this->assertEquals(100, $oParagraph->getLineSpacing());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(0, $oParagraph->getSpacingAfter());
+ self::assertEquals(0, $oParagraph->getSpacingBefore());
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
+ self::assertEquals(100, $oParagraph->getLineSpacing());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
// Slide 3 : Shape 2 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('What\'s the point?', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(48, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('What\'s the point?', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(48, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[2];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(600, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(130, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(600, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(130, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(8, $arrayParagraphs);
+ self::assertCount(8, $arrayParagraphs);
// Slide 3 : Shape 3 : Paragraph 1
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(0, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(0, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Generate slide decks', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Generate slide decks', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 2
$oParagraph = $arrayParagraphs[1];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Represent business data', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Represent business data', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 3
$oParagraph = $arrayParagraphs[2];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Show a family slide show', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Show a family slide show', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 4
$oParagraph = $arrayParagraphs[3];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('...', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('...', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 5
$oParagraph = $arrayParagraphs[4];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(0, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(0, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Export these to different formats', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Export these to different formats', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 6
$oParagraph = $arrayParagraphs[5];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('PHPPresentation 2007', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('PHPPresentation 2007', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 7
$oParagraph = $arrayParagraphs[6];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Serialized', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Serialized', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 8
$oParagraph = $arrayParagraphs[7];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
// $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
// $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('... (more to come) ...', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('... (more to come) ...', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 4
$oSlide3 = $oPhpPresentation->getSlide(3);
$arrayShape = (array) $oSlide3->getShapeCollection();
- $this->assertCount(3, $arrayShape);
+ self::assertCount(3, $arrayShape);
// Slide 4 : Shape 1
/** @var Gd $oShape */
$oShape = $arrayShape[0];
- $this->assertInstanceOf(Gd::class, $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertEquals('image/png', $oShape->getMimeType());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
+ self::assertInstanceOf(Gd::class, $oShape);
+ self::assertEquals('PHPPresentation logo', $oShape->getName());
+ self::assertEquals('PHPPresentation logo', $oShape->getDescription());
+ self::assertEquals(36, $oShape->getHeight());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(10, $oShape->getOffsetY());
+ self::assertEquals('image/png', $oShape->getMimeType());
+ self::assertTrue($oShape->getShadow()->isVisible());
+ self::assertEquals(45, $oShape->getShadow()->getDirection());
+ self::assertEquals(10, $oShape->getShadow()->getDistance());
// Slide 4 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[1];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(100, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(50, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(100, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(50, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
- $this->assertEquals(0, $oParagraph->getSpacingAfter());
- $this->assertEquals(0, $oParagraph->getSpacingBefore());
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
- $this->assertEquals(100, $oParagraph->getLineSpacing());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(0, $oParagraph->getSpacingAfter());
+ self::assertEquals(0, $oParagraph->getSpacingBefore());
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
+ self::assertEquals(100, $oParagraph->getLineSpacing());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
// Slide 4 : Shape 2 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Need more info?', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(48, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Need more info?', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(48, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 4 : Shape 3
/** @var RichText $oShape */
$oShape = $arrayShape[2];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(600, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(130, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(600, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(130, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
- $this->assertEquals(0, $oParagraph->getSpacingAfter());
- $this->assertEquals(0, $oParagraph->getSpacingBefore());
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
- $this->assertEquals(100, $oParagraph->getLineSpacing());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(0, $oParagraph->getSpacingAfter());
+ self::assertEquals(0, $oParagraph->getSpacingBefore());
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
+ self::assertEquals(100, $oParagraph->getLineSpacing());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(3, $arrayRichText);
+ self::assertCount(3, $arrayRichText);
// Slide 4 : Shape 3 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Check the project site on GitHub:', $oRichText->getText());
- $this->assertFalse($oRichText->getFont()->isBold());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Check the project site on GitHub:', $oRichText->getText());
+ self::assertFalse($oRichText->getFont()->isBold());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 4 : Shape 3 : Paragraph 2
$oRichText = $arrayRichText[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
// Slide 4 : Shape 3 : Paragraph 3
/** @var RichText\Run $oRichText */
$oRichText = $arrayRichText[2];
- $this->assertInstanceOf(RichText\Run::class, $oRichText);
- $this->assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getText());
- $this->assertFalse($oRichText->getFont()->isBold());
- $this->assertEquals(32, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
- $this->assertTrue($oRichText->hasHyperlink());
- $this->assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getHyperlink()->getUrl());
+ self::assertInstanceOf(RichText\Run::class, $oRichText);
+ self::assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getText());
+ self::assertFalse($oRichText->getFont()->isBold());
+ self::assertEquals(32, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
+ self::assertTrue($oRichText->hasHyperlink());
+ self::assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getHyperlink()->getUrl());
//$this->assertEquals('PHPPresentation', $oRichText->getHyperlink()->getTooltip());
}
@@ -572,11 +589,11 @@ public function testSlideName(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/ODP_Slide_Name.odp';
$object = new ODPresentation();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
- $this->assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
+ self::assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());
- $this->assertEquals('MaDiapo', $oPhpPresentation->getSlide(0)->getName());
+ self::assertEquals('MaDiapo', $oPhpPresentation->getSlide(0)->getName());
}
public function testIssue00141(): void
@@ -584,28 +601,28 @@ public function testIssue00141(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Issue_00141.odp';
$object = new ODPresentation();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
- $this->assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
+ self::assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());
- $this->assertCount(3, $oPhpPresentation->getAllSlides());
+ self::assertCount(3, $oPhpPresentation->getAllSlides());
// Slide 1
$oSlide = $oPhpPresentation->getSlide(1);
$arrayShape = (array) $oSlide->getShapeCollection();
- $this->assertCount(2, $arrayShape);
+ self::assertCount(2, $arrayShape);
// Slide 1 : Shape 1
/** @var RichText $oShape */
$oShape = reset($arrayShape);
- $this->assertInstanceOf(RichText::class, $oShape);
+ self::assertInstanceOf(RichText::class, $oShape);
// Slide 1 : Shape 1 : Paragraph 1
$oParagraph = $oShape->getParagraph();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $oParagraph);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $oParagraph);
// Slide 1 : Shape 1 : Paragraph 1 : RichText Elements
$arrayElements = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayElements);
+ self::assertCount(1, $arrayElements);
$oElement = reset($arrayElements);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $oElement);
- $this->assertEquals('TEST IMAGE', $oElement->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $oElement);
+ self::assertEquals('TEST IMAGE', $oElement->getText());
}
}
diff --git a/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php b/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php
index 7db18c9e1e..51b6ac3bfa 100644
--- a/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php
+++ b/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -48,13 +47,13 @@ public function testCanRead(): void
$object = new PowerPoint2007();
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.ppt';
- $this->assertFalse($object->canRead($file));
+ self::assertFalse($object->canRead($file));
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/serialized.phppt';
- $this->assertFalse($object->canRead($file));
+ self::assertFalse($object->canRead($file));
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.pptx';
- $this->assertTrue($object->canRead($file));
+ self::assertTrue($object->canRead($file));
}
public function testLoadFileNotExists(): void
@@ -93,483 +92,505 @@ public function testLoadFile01(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.pptx';
$object = new PowerPoint2007();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
// Document Properties
- $this->assertEquals('PHPOffice', $oPhpPresentation->getDocumentProperties()->getCreator());
- $this->assertEquals('PHPPresentation Team', $oPhpPresentation->getDocumentProperties()->getLastModifiedBy());
- $this->assertEquals('Sample 02 Title', $oPhpPresentation->getDocumentProperties()->getTitle());
- $this->assertEquals('Sample 02 Subject', $oPhpPresentation->getDocumentProperties()->getSubject());
- $this->assertEquals('Sample 02 Description', $oPhpPresentation->getDocumentProperties()->getDescription());
- $this->assertEquals('office 2007 openxml libreoffice odt php', $oPhpPresentation->getDocumentProperties()->getKeywords());
- $this->assertEquals('Sample Category', $oPhpPresentation->getDocumentProperties()->getCategory());
- $this->assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
- $this->assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());
+ self::assertEquals('PHPOffice', $oPhpPresentation->getDocumentProperties()->getCreator());
+ self::assertEquals('PHPPresentation Team', $oPhpPresentation->getDocumentProperties()->getLastModifiedBy());
+ self::assertEquals('Sample 02 Title', $oPhpPresentation->getDocumentProperties()->getTitle());
+ self::assertEquals('Sample 02 Subject', $oPhpPresentation->getDocumentProperties()->getSubject());
+ self::assertEquals('Sample 02 Description', $oPhpPresentation->getDocumentProperties()->getDescription());
+ self::assertEquals('office 2007 openxml libreoffice odt php', $oPhpPresentation->getDocumentProperties()->getKeywords());
+ self::assertEquals('Sample Category', $oPhpPresentation->getDocumentProperties()->getCategory());
+ self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getRevision());
+ self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getStatus());
+ self::assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
+ self::assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());
// Presentation Properties
- $this->assertEquals(PresentationProperties::SLIDESHOW_TYPE_PRESENT, $oPhpPresentation->getPresentationProperties()->getSlideshowType());
+ self::assertEquals(PresentationProperties::SLIDESHOW_TYPE_PRESENT, $oPhpPresentation->getPresentationProperties()->getSlideshowType());
// Document Layout
- $this->assertEquals(DocumentLayout::LAYOUT_SCREEN_4X3, $oPhpPresentation->getLayout()->getDocumentLayout());
- $this->assertEquals(254, $oPhpPresentation->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER));
- $this->assertEquals(190.5, $oPhpPresentation->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER));
+ self::assertEquals(DocumentLayout::LAYOUT_SCREEN_4X3, $oPhpPresentation->getLayout()->getDocumentLayout());
+ self::assertEquals(254, $oPhpPresentation->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER));
+ self::assertEquals(190.5, $oPhpPresentation->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER));
// Slides
- $this->assertCount(4, $oPhpPresentation->getAllSlides());
+ self::assertCount(4, $oPhpPresentation->getAllSlides());
// Slide 1
$oSlide1 = $oPhpPresentation->getSlide(0);
$arrayShape = (array) $oSlide1->getShapeCollection();
- $this->assertCount(2, $arrayShape);
+ self::assertCount(2, $arrayShape);
// Slide 1 : Shape 1
/** @var Gd $oShape */
$oShape = $arrayShape[0];
- $this->assertInstanceOf(Gd::class, $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertEquals('image/gif', $oShape->getMimeType());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
+ self::assertInstanceOf(Gd::class, $oShape);
+ self::assertEquals('PHPPresentation logo', $oShape->getName());
+ self::assertEquals('PHPPresentation logo', $oShape->getDescription());
+ self::assertEquals(36, $oShape->getHeight());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(10, $oShape->getOffsetY());
+ self::assertEquals('image/gif', $oShape->getMimeType());
+ self::assertTrue($oShape->getShadow()->isVisible());
+ self::assertEquals(45, $oShape->getShadow()->getDirection());
+ self::assertEquals(10, $oShape->getShadow()->getDistance());
// Slide 1 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[1];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(200, $oShape->getHeight());
- $this->assertEquals(600, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(400, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(200, $oShape->getHeight());
+ self::assertEquals(600, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(400, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
- $this->assertEquals(0, $oParagraph->getSpacingAfter());
- $this->assertEquals(0, $oParagraph->getSpacingBefore());
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
- $this->assertEquals(100, $oParagraph->getLineSpacing());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(0, $oParagraph->getSpacingAfter());
+ self::assertEquals(0, $oParagraph->getSpacingBefore());
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
+ self::assertEquals(100, $oParagraph->getLineSpacing());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(3, $arrayRichText);
+ self::assertCount(3, $arrayRichText);
// Slide 1 : Shape 2 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Introduction to', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(28, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Introduction to', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(28, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 1 : Shape 2 : Paragraph 2
$oRichText = $arrayRichText[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
// Slide 1 : Shape 2 : Paragraph 3
$oRichText = $arrayRichText[2];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('PHPPresentation', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(60, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('PHPPresentation', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(60, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 2
$oSlide2 = $oPhpPresentation->getSlide(1);
$arrayShape = (array) $oSlide2->getShapeCollection();
- $this->assertCount(3, $arrayShape);
+ self::assertCount(3, $arrayShape);
// Slide 2 : Shape 1
/** @var Gd $oShape */
$oShape = $arrayShape[0];
- $this->assertInstanceOf(Gd::class, $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertEquals('image/gif', $oShape->getMimeType());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
+ self::assertInstanceOf(Gd::class, $oShape);
+ self::assertEquals('PHPPresentation logo', $oShape->getName());
+ self::assertEquals('PHPPresentation logo', $oShape->getDescription());
+ self::assertEquals(36, $oShape->getHeight());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(10, $oShape->getOffsetY());
+ self::assertEquals('image/gif', $oShape->getMimeType());
+ self::assertTrue($oShape->getShadow()->isVisible());
+ self::assertEquals(45, $oShape->getShadow()->getDirection());
+ self::assertEquals(10, $oShape->getShadow()->getDistance());
// Slide 2 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[1];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(100, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(50, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(100, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(50, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
// Slide 2 : Shape 2 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('What is PHPPresentation?', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(48, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('What is PHPPresentation?', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(48, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 2 : Shape 3
/** @var RichText $oShape */
$oShape = $arrayShape[2];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(600, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(130, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(600, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(130, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(4, $arrayParagraphs);
+ self::assertCount(4, $arrayParagraphs);
// Slide 2 : Shape 3 : Paragraph 1
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('A class library', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('A class library', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 2 : Shape 3 : Paragraph 2
$oParagraph = $arrayParagraphs[1];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Written in PHP', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Written in PHP', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 2 : Shape 3 : Paragraph 3
$oParagraph = $arrayParagraphs[2];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Representing a presentation', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Representing a presentation', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 2 : Shape 3 : Paragraph 4
$oParagraph = $arrayParagraphs[3];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Supports writing to different file formats', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Supports writing to different file formats', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3
$oSlide2 = $oPhpPresentation->getSlide(2);
$arrayShape = (array) $oSlide2->getShapeCollection();
- $this->assertCount(3, $arrayShape);
+ self::assertCount(3, $arrayShape);
// Slide 3 : Shape 1
/** @var Gd $oShape */
$oShape = $arrayShape[0];
- $this->assertInstanceOf(Gd::class, $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertEquals('image/gif', $oShape->getMimeType());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
+ self::assertInstanceOf(Gd::class, $oShape);
+ self::assertEquals('PHPPresentation logo', $oShape->getName());
+ self::assertEquals('PHPPresentation logo', $oShape->getDescription());
+ self::assertEquals(36, $oShape->getHeight());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(10, $oShape->getOffsetY());
+ self::assertEquals('image/gif', $oShape->getMimeType());
+ self::assertTrue($oShape->getShadow()->isVisible());
+ self::assertEquals(45, $oShape->getShadow()->getDirection());
+ self::assertEquals(10, $oShape->getShadow()->getDistance());
// Slide 3 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[1];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(100, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(50, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(100, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(50, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
- $this->assertEquals(0, $oParagraph->getSpacingAfter());
- $this->assertEquals(0, $oParagraph->getSpacingBefore());
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
- $this->assertEquals(100, $oParagraph->getLineSpacing());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(0, $oParagraph->getSpacingAfter());
+ self::assertEquals(0, $oParagraph->getSpacingBefore());
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
+ self::assertEquals(100, $oParagraph->getLineSpacing());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
// Slide 3 : Shape 2 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('What\'s the point?', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(48, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('What\'s the point?', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(48, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[2];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(600, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(130, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(600, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(130, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(8, $arrayParagraphs);
+ self::assertCount(8, $arrayParagraphs);
// Slide 3 : Shape 3 : Paragraph 1
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(0, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(0, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Generate slide decks', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Generate slide decks', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 2
$oParagraph = $arrayParagraphs[1];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Represent business data', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Represent business data', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 3
$oParagraph = $arrayParagraphs[2];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Show a family slide show', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Show a family slide show', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 4
$oParagraph = $arrayParagraphs[3];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('...', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('...', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 5
$oParagraph = $arrayParagraphs[4];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(0, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(0, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Export these to different formats', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Export these to different formats', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 6
$oParagraph = $arrayParagraphs[5];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('PHPPresentation 2007', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('PHPPresentation 2007', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 7
$oParagraph = $arrayParagraphs[6];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Serialized', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Serialized', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 3 : Shape 3 : Paragraph 8
$oParagraph = $arrayParagraphs[7];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(-25, $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(1, $oParagraph->getAlignment()->getLevel());
+ self::assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('... (more to come) ...', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('... (more to come) ...', $oRichText->getText());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 4
$oSlide3 = $oPhpPresentation->getSlide(3);
$arrayShape = (array) $oSlide3->getShapeCollection();
- $this->assertCount(3, $arrayShape);
+ self::assertCount(3, $arrayShape);
// Slide 4 : Shape 1
/** @var Gd $oShape */
$oShape = $arrayShape[0];
- $this->assertInstanceOf(Gd::class, $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertEquals('image/gif', $oShape->getMimeType());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
+ self::assertInstanceOf(Gd::class, $oShape);
+ self::assertEquals('PHPPresentation logo', $oShape->getName());
+ self::assertEquals('PHPPresentation logo', $oShape->getDescription());
+ self::assertEquals(36, $oShape->getHeight());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(10, $oShape->getOffsetY());
+ self::assertEquals('image/gif', $oShape->getMimeType());
+ self::assertTrue($oShape->getShadow()->isVisible());
+ self::assertEquals(45, $oShape->getShadow()->getDirection());
+ self::assertEquals(10, $oShape->getShadow()->getDistance());
// Slide 4 : Shape 2
/** @var RichText $oShape */
$oShape = $arrayShape[1];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(100, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(50, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(100, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(50, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
- $this->assertEquals(0, $oParagraph->getSpacingAfter());
- $this->assertEquals(0, $oParagraph->getSpacingBefore());
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
- $this->assertEquals(100, $oParagraph->getLineSpacing());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(0, $oParagraph->getSpacingAfter());
+ self::assertEquals(0, $oParagraph->getSpacingBefore());
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
+ self::assertEquals(100, $oParagraph->getLineSpacing());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
+ self::assertCount(1, $arrayRichText);
// Slide 4 : Shape 2 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Need more info?', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(48, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Need more info?', $oRichText->getText());
+ self::assertTrue($oRichText->getFont()->isBold());
+ self::assertEquals(48, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 4 : Shape 3
/** @var RichText $oShape */
$oShape = $arrayShape[2];
- $this->assertInstanceOf(RichText::class, $oShape);
- $this->assertEquals(600, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(130, $oShape->getOffsetY());
+ self::assertInstanceOf(RichText::class, $oShape);
+ self::assertEquals(600, $oShape->getHeight());
+ self::assertEquals(930, $oShape->getWidth());
+ self::assertEquals(10, $oShape->getOffsetX());
+ self::assertEquals(130, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
+ self::assertCount(1, $arrayParagraphs);
$oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $this->assertFalse($oParagraph->getAlignment()->isRTL());
- $this->assertEquals(0, $oParagraph->getSpacingAfter());
- $this->assertEquals(0, $oParagraph->getSpacingBefore());
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
- $this->assertEquals(100, $oParagraph->getLineSpacing());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
+ self::assertFalse($oParagraph->getAlignment()->isRTL());
+ self::assertEquals(0, $oParagraph->getSpacingAfter());
+ self::assertEquals(0, $oParagraph->getSpacingBefore());
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
+ self::assertEquals(100, $oParagraph->getLineSpacing());
$arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(3, $arrayRichText);
+ self::assertCount(3, $arrayRichText);
// Slide 4 : Shape 3 : Paragraph 1
$oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Check the project site on GitHub:', $oRichText->getText());
- $this->assertFalse($oRichText->getFont()->isBold());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
+ self::assertEquals('Check the project site on GitHub:', $oRichText->getText());
+ self::assertFalse($oRichText->getFont()->isBold());
+ self::assertEquals(36, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
// Slide 4 : Shape 3 : Paragraph 2
$oRichText = $arrayRichText[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
// Slide 4 : Shape 3 : Paragraph 3
/** @var RichText\Run $oRichText */
$oRichText = $arrayRichText[2];
- $this->assertInstanceOf(RichText\Run::class, $oRichText);
- $this->assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getText());
- $this->assertFalse($oRichText->getFont()->isBold());
- $this->assertEquals(32, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- $this->assertTrue($oRichText->hasHyperlink());
- $this->assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getHyperlink()->getUrl());
- $this->assertEquals('PHPPresentation', $oRichText->getHyperlink()->getTooltip());
- $this->assertEquals('Calibri', $oRichText->getFont()->getName());
- $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertInstanceOf(RichText\Run::class, $oRichText);
+ self::assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getText());
+ self::assertFalse($oRichText->getFont()->isBold());
+ self::assertEquals(32, $oRichText->getFont()->getSize());
+ self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
+ self::assertTrue($oRichText->hasHyperlink());
+ self::assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getHyperlink()->getUrl());
+ self::assertEquals('PHPPresentation', $oRichText->getHyperlink()->getTooltip());
+ self::assertFalse($oRichText->getHyperlink()->isTextColorUsed());
+ self::assertEquals('Calibri', $oRichText->getFont()->getName());
+ self::assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
}
public function testMarkAsFinal(): void
@@ -577,14 +598,14 @@ public function testMarkAsFinal(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.pptx';
$object = new PowerPoint2007();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertFalse($oPhpPresentation->getPresentationProperties()->isMarkedAsFinal());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertFalse($oPhpPresentation->getPresentationProperties()->isMarkedAsFinal());
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/PPTX_MarkAsFinal.pptx';
$object = new PowerPoint2007();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertTrue($oPhpPresentation->getPresentationProperties()->isMarkedAsFinal());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertTrue($oPhpPresentation->getPresentationProperties()->isMarkedAsFinal());
}
public function testZoom(): void
@@ -592,14 +613,14 @@ public function testZoom(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.pptx';
$object = new PowerPoint2007();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertEquals(1, $oPhpPresentation->getPresentationProperties()->getZoom());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertEquals(1, $oPhpPresentation->getPresentationProperties()->getZoom());
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/PPTX_Zoom.pptx';
$object = new PowerPoint2007();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertEquals(2.68, $oPhpPresentation->getPresentationProperties()->getZoom());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertEquals(2.68, $oPhpPresentation->getPresentationProperties()->getZoom());
}
public function testSlideLayout(): void
@@ -607,12 +628,29 @@ public function testSlideLayout(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Issue_00150.pptx';
$object = new PowerPoint2007();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
$masterSlides = $oPhpPresentation->getAllMasterSlides();
- $this->assertCount(3, $masterSlides);
- $this->assertCount(11, $masterSlides[0]->getAllSlideLayouts());
- $this->assertCount(11, $masterSlides[1]->getAllSlideLayouts());
- $this->assertCount(11, $masterSlides[2]->getAllSlideLayouts());
+ self::assertCount(3, $masterSlides);
+ self::assertCount(11, $masterSlides[0]->getAllSlideLayouts());
+ self::assertCount(11, $masterSlides[1]->getAllSlideLayouts());
+ self::assertCount(11, $masterSlides[2]->getAllSlideLayouts());
+ }
+
+ public function testLoadFileWithInvalidImages(): void
+ {
+ $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/PPTX_InvalidImage.pptx';
+ $object = new PowerPoint2007();
+ $oPhpPresentation = $object->load($file);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertEquals(1, $oPhpPresentation->getSlideCount());
+ }
+
+ public function testLoadingFileWithNoteInSlide(): void
+ {
+ $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/PPTX_SlideNoteWithRichText.pptx';
+ $object = new PowerPoint2007();
+ $oPhpPresentation = $object->load($file);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
}
}
diff --git a/tests/PhpPresentation/Tests/Reader/PowerPoint97Test.php b/tests/PhpPresentation/Tests/Reader/PowerPoint97Test.php
index 73cfb5ab64..7b54ecf179 100644
--- a/tests/PhpPresentation/Tests/Reader/PowerPoint97Test.php
+++ b/tests/PhpPresentation/Tests/Reader/PowerPoint97Test.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -40,7 +39,7 @@ public function testCanRead(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.ppt';
$object = new PowerPoint97();
- $this->assertTrue($object->canRead($file));
+ self::assertTrue($object->canRead($file));
}
/**
@@ -51,7 +50,7 @@ public function testCantRead(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/serialized.phppt';
$object = new PowerPoint97();
- $this->assertFalse($object->canRead($file));
+ self::assertFalse($object->canRead($file));
}
public function testLoadFileNotExists(): void
@@ -90,11 +89,11 @@ public function testLoadFile01(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.ppt';
$object = new PowerPoint97();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertEquals(1, $oPhpPresentation->getSlideCount());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertEquals(1, $oPhpPresentation->getSlideCount());
$oSlide = $oPhpPresentation->getSlide(0);
- $this->assertCount(2, $oSlide->getShapeCollection());
+ self::assertCount(2, $oSlide->getShapeCollection());
}
public function testLoadFile02(): void
@@ -102,20 +101,20 @@ public function testLoadFile02(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_02.ppt';
$object = new PowerPoint97();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertEquals(4, $oPhpPresentation->getSlideCount());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertEquals(4, $oPhpPresentation->getSlideCount());
$oSlide = $oPhpPresentation->getSlide(0);
- $this->assertCount(2, $oSlide->getShapeCollection());
+ self::assertCount(2, $oSlide->getShapeCollection());
$oSlide = $oPhpPresentation->getSlide(1);
- $this->assertCount(3, $oSlide->getShapeCollection());
+ self::assertCount(3, $oSlide->getShapeCollection());
$oSlide = $oPhpPresentation->getSlide(2);
- $this->assertCount(3, $oSlide->getShapeCollection());
+ self::assertCount(3, $oSlide->getShapeCollection());
$oSlide = $oPhpPresentation->getSlide(3);
- $this->assertCount(3, $oSlide->getShapeCollection());
+ self::assertCount(3, $oSlide->getShapeCollection());
}
public function testLoadFile03(): void
@@ -123,11 +122,11 @@ public function testLoadFile03(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_03.ppt';
$object = new PowerPoint97();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertEquals(1, $oPhpPresentation->getSlideCount());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertEquals(1, $oPhpPresentation->getSlideCount());
$oSlide = $oPhpPresentation->getSlide(0);
- $this->assertCount(1, $oSlide->getShapeCollection());
+ self::assertCount(1, $oSlide->getShapeCollection());
}
public function testLoadFile04(): void
@@ -135,10 +134,10 @@ public function testLoadFile04(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_04.ppt';
$object = new PowerPoint97();
$oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertEquals(1, $oPhpPresentation->getSlideCount());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
+ self::assertEquals(1, $oPhpPresentation->getSlideCount());
$oSlide = $oPhpPresentation->getSlide(0);
- $this->assertCount(4, $oSlide->getShapeCollection());
+ self::assertCount(4, $oSlide->getShapeCollection());
}
}
diff --git a/tests/PhpPresentation/Tests/Reader/SerializedTest.php b/tests/PhpPresentation/Tests/Reader/SerializedTest.php
index a4d79d0a74..9a09df7d6a 100644
--- a/tests/PhpPresentation/Tests/Reader/SerializedTest.php
+++ b/tests/PhpPresentation/Tests/Reader/SerializedTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -41,7 +40,7 @@ public function testCanRead(): void
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/serialized.phppt';
$object = new Serialized();
- $this->assertTrue($object->canRead($file));
+ self::assertTrue($object->canRead($file));
}
public function testLoadFileNotExists(): void
@@ -86,7 +85,7 @@ public function testLoadSerializedFileNotExists(): void
));
$oArchive = new ZipArchive();
- $oArchive->open($file, ZipArchive::CREATE);
+ $oArchive->open($file, ZipArchive::OVERWRITE);
$oArchive->addFromString('PhpPresentation.xml', '');
$oArchive->close();
diff --git a/tests/PhpPresentation/Tests/Shape/AbstractGraphicTest.php b/tests/PhpPresentation/Tests/Shape/AbstractGraphicTest.php
index 54d6cf41ed..997aac77ea 100644
--- a/tests/PhpPresentation/Tests/Shape/AbstractGraphicTest.php
+++ b/tests/PhpPresentation/Tests/Shape/AbstractGraphicTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,31 +35,31 @@ public function testWidthAndHeight(): void
$max = 20;
/** @var AbstractGraphic $stub */
$stub = $this->getMockForAbstractClass('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic');
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setResizeProportional(false));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidth($min));
- $this->assertEquals($min, $stub->getWidth());
- $this->assertEquals(0, $stub->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setHeight($max));
- $this->assertEquals($min, $stub->getWidth());
- $this->assertEquals($max, $stub->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidthAndHeight($min, $max));
- $this->assertEquals($min, $stub->getWidth());
- $this->assertEquals($max, $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setResizeProportional(false));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidth($min));
+ self::assertEquals($min, $stub->getWidth());
+ self::assertEquals(0, $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setHeight($max));
+ self::assertEquals($min, $stub->getWidth());
+ self::assertEquals($max, $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidthAndHeight($min, $max));
+ self::assertEquals($min, $stub->getWidth());
+ self::assertEquals($max, $stub->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setResizeProportional(true));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidth($max));
- $this->assertEquals($max, $stub->getWidth());
- $this->assertEquals($max * ($max / $min), $stub->getHeight());
- $this->assertEquals($max, $stub->getWidth());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setHeight($min));
- $this->assertEquals($min * ($max / ($max * ($max / $min))), $stub->getWidth());
- $this->assertEquals($min, $stub->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidthAndHeight($min, $max));
- $this->assertEquals($min, $stub->getWidth());
- $this->assertEquals($max, $stub->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidthAndHeight($max, $min));
- $this->assertEquals($min * ($min / $max), $stub->getWidth());
- $this->assertEquals($min, $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setResizeProportional(true));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidth($max));
+ self::assertEquals($max, $stub->getWidth());
+ self::assertEquals($max * ($max / $min), $stub->getHeight());
+ self::assertEquals($max, $stub->getWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setHeight($min));
+ self::assertEquals($min * ($max / ($max * ($max / $min))), $stub->getWidth());
+ self::assertEquals($min, $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidthAndHeight($min, $max));
+ self::assertEquals($min, $stub->getWidth());
+ self::assertEquals($max, $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidthAndHeight($max, $min));
+ self::assertEquals($min * ($min / $max), $stub->getWidth());
+ self::assertEquals($min, $stub->getHeight());
}
public function testWidthAndHeight2(): void
@@ -69,24 +68,24 @@ public function testWidthAndHeight2(): void
$max = 20;
/** @var AbstractGraphic $stub */
$stub = $this->getMockForAbstractClass('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic');
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setResizeProportional(false));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidth($max));
- $this->assertEquals($max, $stub->getWidth());
- $this->assertEquals(0, $stub->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setHeight($min));
- $this->assertEquals($max, $stub->getWidth());
- $this->assertEquals($min, $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setResizeProportional(false));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidth($max));
+ self::assertEquals($max, $stub->getWidth());
+ self::assertEquals(0, $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setHeight($min));
+ self::assertEquals($max, $stub->getWidth());
+ self::assertEquals($min, $stub->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setResizeProportional(true));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidth($max));
- $this->assertEquals($max, $stub->getWidth());
- $this->assertEquals($max * ($min / $max), $stub->getHeight());
- $this->assertEquals($max, $stub->getWidth());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setHeight($min));
- $this->assertEquals($max * ($min / ($max * ($min / $max))), $stub->getWidth());
- $this->assertEquals($min, $stub->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidthAndHeight($min, $max));
- $this->assertEquals($min, $stub->getWidth());
- $this->assertEquals($min * ($min / ($max * ($min / ($max * ($min / $max))))), $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setResizeProportional(true));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidth($max));
+ self::assertEquals($max, $stub->getWidth());
+ self::assertEquals($max * ($min / $max), $stub->getHeight());
+ self::assertEquals($max, $stub->getWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setHeight($min));
+ self::assertEquals($max * ($min / ($max * ($min / $max))), $stub->getWidth());
+ self::assertEquals($min, $stub->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\AbstractGraphic', $stub->setWidthAndHeight($min, $max));
+ self::assertEquals($min, $stub->getWidth());
+ self::assertEquals($min * ($min / ($max * ($min / ($max * ($min / $max))))), $stub->getHeight());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/AutoShapeTest.php b/tests/PhpPresentation/Tests/Shape/AutoShapeTest.php
index 9e235e2df7..bc7d5636a3 100644
--- a/tests/PhpPresentation/Tests/Shape/AutoShapeTest.php
+++ b/tests/PhpPresentation/Tests/Shape/AutoShapeTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,10 +29,10 @@ public function testConstruct(): void
{
$object = new AutoShape();
- $this->assertEquals(AutoShape::TYPE_HEART, $object->getType());
- $this->assertEquals('', $object->getText());
- $this->assertInstanceOf(Outline::class, $object->getOutline());
- $this->assertIsString($object->getHashCode());
+ self::assertEquals(AutoShape::TYPE_HEART, $object->getType());
+ self::assertEquals('', $object->getText());
+ self::assertInstanceOf(Outline::class, $object->getOutline());
+ self::assertIsString($object->getHashCode());
}
public function testOutline(): void
@@ -42,26 +41,26 @@ public function testOutline(): void
$mock = $this->getMockBuilder(Outline::class)->getMock();
$object = new AutoShape();
- $this->assertInstanceOf(Outline::class, $object->getOutline());
- $this->assertInstanceOf(AutoShape::class, $object->setOutline($mock));
- $this->assertInstanceOf(Outline::class, $object->getOutline());
+ self::assertInstanceOf(Outline::class, $object->getOutline());
+ self::assertInstanceOf(AutoShape::class, $object->setOutline($mock));
+ self::assertInstanceOf(Outline::class, $object->getOutline());
}
public function testText(): void
{
$object = new AutoShape();
- $this->assertEquals('', $object->getText());
- $this->assertInstanceOf(AutoShape::class, $object->setText('Text'));
- $this->assertEquals('Text', $object->getText());
+ self::assertEquals('', $object->getText());
+ self::assertInstanceOf(AutoShape::class, $object->setText('Text'));
+ self::assertEquals('Text', $object->getText());
}
public function testType(): void
{
$object = new AutoShape();
- $this->assertEquals(AutoShape::TYPE_HEART, $object->getType());
- $this->assertInstanceOf(AutoShape::class, $object->setType(AutoShape::TYPE_HEXAGON));
- $this->assertEquals(AutoShape::TYPE_HEXAGON, $object->getType());
+ self::assertEquals(AutoShape::TYPE_HEART, $object->getType());
+ self::assertInstanceOf(AutoShape::class, $object->setType(AutoShape::TYPE_HEXAGON));
+ self::assertEquals(AutoShape::TYPE_HEXAGON, $object->getType());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php b/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php
index 8696d38742..59b360fe96 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,10 +36,10 @@ public function testConstruct(): void
{
$object = new Axis();
- $this->assertEquals('Axis Title', $object->getTitle());
- $this->assertInstanceOf(Font::class, $object->getFont());
- $this->assertNull($object->getMinorGridlines());
- $this->assertNull($object->getMajorGridlines());
+ self::assertEquals('Axis Title', $object->getTitle());
+ self::assertInstanceOf(Font::class, $object->getFont());
+ self::assertNull($object->getMinorGridlines());
+ self::assertNull($object->getMajorGridlines());
}
public function testBounds(): void
@@ -48,36 +47,56 @@ public function testBounds(): void
$value = mt_rand(0, 100);
$object = new Axis();
- $this->assertNull($object->getMinBounds());
- $this->assertInstanceOf(Axis::class, $object->setMinBounds($value));
- $this->assertEquals($value, $object->getMinBounds());
- $this->assertInstanceOf(Axis::class, $object->setMinBounds());
- $this->assertNull($object->getMinBounds());
+ self::assertNull($object->getMinBounds());
+ self::assertInstanceOf(Axis::class, $object->setMinBounds($value));
+ self::assertEquals($value, $object->getMinBounds());
+ self::assertInstanceOf(Axis::class, $object->setMinBounds());
+ self::assertNull($object->getMinBounds());
+
+ self::assertNull($object->getMaxBounds());
+ self::assertInstanceOf(Axis::class, $object->setMaxBounds($value));
+ self::assertEquals($value, $object->getMaxBounds());
+ self::assertInstanceOf(Axis::class, $object->setMaxBounds());
+ self::assertNull($object->getMaxBounds());
+ }
+
+ public function testCrossesAt(): void
+ {
+ $object = new Axis();
- $this->assertNull($object->getMaxBounds());
- $this->assertInstanceOf(Axis::class, $object->setMaxBounds($value));
- $this->assertEquals($value, $object->getMaxBounds());
- $this->assertInstanceOf(Axis::class, $object->setMaxBounds());
- $this->assertNull($object->getMaxBounds());
+ self::assertEquals(Axis::CROSSES_AUTO, $object->getCrossesAt());
+ self::assertInstanceOf(Axis::class, $object->setCrossesAt(Axis::CROSSES_MAX));
+ self::assertEquals(Axis::CROSSES_MAX, $object->getCrossesAt());
+ }
+
+ public function testIsReversedOrder(): void
+ {
+ $object = new Axis();
+ self::assertFalse($object->isReversedOrder());
+ self::assertInstanceOf(Axis::class, $object->setIsReversedOrder(true));
+ self::assertTrue($object->isReversedOrder());
+ self::assertInstanceOf(Axis::class, $object->setIsReversedOrder(false));
+ self::assertFalse($object->isReversedOrder());
}
public function testFont(): void
{
$object = new Axis();
- $this->assertInstanceOf(Axis::class, $object->setFont());
- $this->assertNull($object->getFont());
- $this->assertInstanceOf(Axis::class, $object->setFont(new Font()));
- $this->assertInstanceOf(Font::class, $object->getFont());
+ self::assertInstanceOf(Axis::class, $object->setFont());
+ self::assertNull($object->getFont());
+ self::assertInstanceOf(Axis::class, $object->setFont(new Font()));
+ self::assertInstanceOf(Font::class, $object->getFont());
}
public function testFormatCode(): void
{
$object = new Axis();
- $this->assertInstanceOf(Axis::class, $object->setFormatCode());
- $this->assertEquals('', $object->getFormatCode());
- $this->assertInstanceOf(Axis::class, $object->setFormatCode('AAAA'));
- $this->assertEquals('AAAA', $object->getFormatCode());
+ self::assertEquals(Axis::DEFAULT_FORMAT_CODE, $object->getFormatCode());
+ self::assertInstanceOf(Axis::class, $object->setFormatCode());
+ self::assertEquals(Axis::DEFAULT_FORMAT_CODE, $object->getFormatCode());
+ self::assertInstanceOf(Axis::class, $object->setFormatCode('AAAA'));
+ self::assertEquals('AAAA', $object->getFormatCode());
}
public function testGridLines(): void
@@ -87,10 +106,10 @@ public function testGridLines(): void
/** @var Gridlines $oMock */
$oMock = $this->getMockBuilder(Gridlines::class)->getMock();
- $this->assertInstanceOf(Axis::class, $object->setMajorGridlines($oMock));
- $this->assertInstanceOf(Gridlines::class, $object->getMajorGridlines());
- $this->assertInstanceOf(Axis::class, $object->setMinorGridlines($oMock));
- $this->assertInstanceOf(Gridlines::class, $object->getMinorGridlines());
+ self::assertInstanceOf(Axis::class, $object->setMajorGridlines($oMock));
+ self::assertInstanceOf(Gridlines::class, $object->getMajorGridlines());
+ self::assertInstanceOf(Axis::class, $object->setMinorGridlines($oMock));
+ self::assertInstanceOf(Gridlines::class, $object->getMinorGridlines());
}
public function testHashIndex(): void
@@ -98,32 +117,32 @@ public function testHashIndex(): void
$object = new Axis();
$value = mt_rand(1, 100);
- $this->assertEmpty($object->getHashIndex());
- $this->assertInstanceOf(Axis::class, $object->setHashIndex($value));
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEmpty($object->getHashIndex());
+ self::assertInstanceOf(Axis::class, $object->setHashIndex($value));
+ self::assertEquals($value, $object->getHashIndex());
}
public function testIsVisible(): void
{
$object = new Axis();
- $this->assertTrue($object->isVisible());
- $this->assertInstanceOf(Axis::class, $object->setIsVisible(false));
- $this->assertFalse($object->isVisible());
- $this->assertInstanceOf(Axis::class, $object->setIsVisible(true));
- $this->assertTrue($object->isVisible());
+ self::assertTrue($object->isVisible());
+ self::assertInstanceOf(Axis::class, $object->setIsVisible(false));
+ self::assertFalse($object->isVisible());
+ self::assertInstanceOf(Axis::class, $object->setIsVisible(true));
+ self::assertTrue($object->isVisible());
}
public function testLabelRotation(): void
{
$object = new Axis();
- $this->assertEquals(0, $object->getTitleRotation());
- $this->assertInstanceOf(Axis::class, $object->setTitleRotation(-1));
- $this->assertEquals(0, $object->getTitleRotation());
- $this->assertInstanceOf(Axis::class, $object->setTitleRotation(361));
- $this->assertEquals(360, $object->getTitleRotation());
- $value = rand(0, 360);
- $this->assertInstanceOf(Axis::class, $object->setTitleRotation($value));
- $this->assertEquals($value, $object->getTitleRotation());
+ self::assertEquals(0, $object->getTitleRotation());
+ self::assertInstanceOf(Axis::class, $object->setTitleRotation(-1));
+ self::assertEquals(0, $object->getTitleRotation());
+ self::assertInstanceOf(Axis::class, $object->setTitleRotation(361));
+ self::assertEquals(360, $object->getTitleRotation());
+ $value = mt_rand(0, 360);
+ self::assertInstanceOf(Axis::class, $object->setTitleRotation($value));
+ self::assertEquals($value, $object->getTitleRotation());
}
public function testOutline(): void
@@ -132,24 +151,35 @@ public function testOutline(): void
$oMock = $this->getMockBuilder(Outline::class)->getMock();
$object = new Axis();
- $this->assertInstanceOf(Outline::class, $object->getOutline());
- $this->assertInstanceOf(Axis::class, $object->setOutline($oMock));
- $this->assertInstanceOf(Outline::class, $object->getOutline());
+ self::assertInstanceOf(Outline::class, $object->getOutline());
+ self::assertInstanceOf(Axis::class, $object->setOutline($oMock));
+ self::assertInstanceOf(Outline::class, $object->getOutline());
+ }
+
+ public function testTickLabelFont(): void
+ {
+ $object = new Axis();
+
+ self::assertInstanceOf(Font::class, $object->getTickLabelFont());
+ self::assertInstanceOf(Axis::class, $object->setTickLabelFont());
+ self::assertNull($object->getTickLabelFont());
+ self::assertInstanceOf(Axis::class, $object->setTickLabelFont(new Font()));
+ self::assertInstanceOf(Font::class, $object->getTickLabelFont());
}
public function testTickLabelPosition(): void
{
$object = new Axis();
- $this->assertEquals(Axis::TICK_LABEL_POSITION_NEXT_TO, $object->getTickLabelPosition());
- $this->assertInstanceOf(Axis::class, $object->setTickLabelPosition(Axis::TICK_LABEL_POSITION_HIGH));
- $this->assertEquals(Axis::TICK_LABEL_POSITION_HIGH, $object->getTickLabelPosition());
- $this->assertInstanceOf(Axis::class, $object->setTickLabelPosition(Axis::TICK_LABEL_POSITION_NEXT_TO));
- $this->assertEquals(Axis::TICK_LABEL_POSITION_NEXT_TO, $object->getTickLabelPosition());
- $this->assertInstanceOf(Axis::class, $object->setTickLabelPosition(Axis::TICK_LABEL_POSITION_LOW));
- $this->assertEquals(Axis::TICK_LABEL_POSITION_LOW, $object->getTickLabelPosition());
- $this->assertInstanceOf(Axis::class, $object->setTickLabelPosition('Unauthorized'));
- $this->assertEquals(Axis::TICK_LABEL_POSITION_LOW, $object->getTickLabelPosition());
+ self::assertEquals(Axis::TICK_LABEL_POSITION_NEXT_TO, $object->getTickLabelPosition());
+ self::assertInstanceOf(Axis::class, $object->setTickLabelPosition(Axis::TICK_LABEL_POSITION_HIGH));
+ self::assertEquals(Axis::TICK_LABEL_POSITION_HIGH, $object->getTickLabelPosition());
+ self::assertInstanceOf(Axis::class, $object->setTickLabelPosition(Axis::TICK_LABEL_POSITION_NEXT_TO));
+ self::assertEquals(Axis::TICK_LABEL_POSITION_NEXT_TO, $object->getTickLabelPosition());
+ self::assertInstanceOf(Axis::class, $object->setTickLabelPosition(Axis::TICK_LABEL_POSITION_LOW));
+ self::assertEquals(Axis::TICK_LABEL_POSITION_LOW, $object->getTickLabelPosition());
+ self::assertInstanceOf(Axis::class, $object->setTickLabelPosition('Unauthorized'));
+ self::assertEquals(Axis::TICK_LABEL_POSITION_LOW, $object->getTickLabelPosition());
}
public function testTickMark(): void
@@ -157,25 +187,25 @@ public function testTickMark(): void
$value = Axis::TICK_MARK_INSIDE;
$object = new Axis();
- $this->assertEquals(Axis::TICK_MARK_NONE, $object->getMinorTickMark());
- $this->assertInstanceOf(Axis::class, $object->setMinorTickMark($value));
- $this->assertEquals($value, $object->getMinorTickMark());
- $this->assertInstanceOf(Axis::class, $object->setMinorTickMark());
- $this->assertEquals(Axis::TICK_MARK_NONE, $object->getMinorTickMark());
-
- $this->assertEquals(Axis::TICK_MARK_NONE, $object->getMajorTickMark());
- $this->assertInstanceOf(Axis::class, $object->setMajorTickMark($value));
- $this->assertEquals($value, $object->getMajorTickMark());
- $this->assertInstanceOf(Axis::class, $object->setMajorTickMark());
- $this->assertEquals(Axis::TICK_MARK_NONE, $object->getMajorTickMark());
+ self::assertEquals(Axis::TICK_MARK_NONE, $object->getMinorTickMark());
+ self::assertInstanceOf(Axis::class, $object->setMinorTickMark($value));
+ self::assertEquals($value, $object->getMinorTickMark());
+ self::assertInstanceOf(Axis::class, $object->setMinorTickMark());
+ self::assertEquals(Axis::TICK_MARK_NONE, $object->getMinorTickMark());
+
+ self::assertEquals(Axis::TICK_MARK_NONE, $object->getMajorTickMark());
+ self::assertInstanceOf(Axis::class, $object->setMajorTickMark($value));
+ self::assertEquals($value, $object->getMajorTickMark());
+ self::assertInstanceOf(Axis::class, $object->setMajorTickMark());
+ self::assertEquals(Axis::TICK_MARK_NONE, $object->getMajorTickMark());
}
public function testTitle(): void
{
$object = new Axis();
- $this->assertEquals('Axis Title', $object->getTitle());
- $this->assertInstanceOf(Axis::class, $object->setTitle('AAAA'));
- $this->assertEquals('AAAA', $object->getTitle());
+ self::assertEquals('Axis Title', $object->getTitle());
+ self::assertInstanceOf(Axis::class, $object->setTitle('AAAA'));
+ self::assertEquals('AAAA', $object->getTitle());
}
public function testUnit(): void
@@ -183,16 +213,16 @@ public function testUnit(): void
$value = mt_rand(0, 100);
$object = new Axis();
- $this->assertNull($object->getMinorUnit());
- $this->assertInstanceOf(Axis::class, $object->setMinorUnit($value));
- $this->assertEquals($value, $object->getMinorUnit());
- $this->assertInstanceOf(Axis::class, $object->setMinorUnit());
- $this->assertNull($object->getMinorUnit());
-
- $this->assertNull($object->getMajorUnit());
- $this->assertInstanceOf(Axis::class, $object->setMajorUnit($value));
- $this->assertEquals($value, $object->getMajorUnit());
- $this->assertInstanceOf(Axis::class, $object->setMajorUnit());
- $this->assertNull($object->getMajorUnit());
+ self::assertNull($object->getMinorUnit());
+ self::assertInstanceOf(Axis::class, $object->setMinorUnit($value));
+ self::assertEquals($value, $object->getMinorUnit());
+ self::assertInstanceOf(Axis::class, $object->setMinorUnit());
+ self::assertNull($object->getMinorUnit());
+
+ self::assertNull($object->getMajorUnit());
+ self::assertInstanceOf(Axis::class, $object->setMajorUnit($value));
+ self::assertEquals($value, $object->getMajorUnit());
+ self::assertInstanceOf(Axis::class, $object->setMajorUnit());
+ self::assertNull($object->getMajorUnit());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php b/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php
index fe0e964519..3b7e37fd29 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,7 +29,7 @@ public function testConstruct(): void
{
$object = new Gridlines();
- $this->assertInstanceOf(Outline::class, $object->getOutline());
+ self::assertInstanceOf(Outline::class, $object->getOutline());
}
public function testGetSetOutline(): void
@@ -40,8 +39,8 @@ public function testGetSetOutline(): void
/** @var Outline $oStub */
$oStub = $this->getMockBuilder(Outline::class)->getMock();
- $this->assertInstanceOf(Outline::class, $object->getOutline());
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Gridlines', $object->setOutline($oStub));
- $this->assertInstanceOf(Outline::class, $object->getOutline());
+ self::assertInstanceOf(Outline::class, $object->getOutline());
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Gridlines', $object->setOutline($oStub));
+ self::assertInstanceOf(Outline::class, $object->getOutline());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/LegendTest.php b/tests/PhpPresentation/Tests/Shape/Chart/LegendTest.php
index 3b57adbb25..6ee4ce60de 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/LegendTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/LegendTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -38,46 +37,46 @@ public function testConstruct(): void
{
$object = new Legend();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getBorder());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->getAlignment());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getBorder());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->getAlignment());
}
public function testAlignment(): void
{
$object = new Legend();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setAlignment(new Alignment()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->getAlignment());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setAlignment(new Alignment()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->getAlignment());
}
public function testBorder(): void
{
$object = new Legend();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getBorder());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setBorder(new Border()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getBorder());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getBorder());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setBorder(new Border()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getBorder());
}
public function testFill(): void
{
$object = new Legend();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setFill(new Fill()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setFill(new Fill()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
}
public function testFont(): void
{
$object = new Legend();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setFont());
- $this->assertNull($object->getFont());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setFont(new Font()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setFont());
+ self::assertNull($object->getFont());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setFont(new Font()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
}
public function testHashIndex(): void
@@ -85,9 +84,9 @@ public function testHashIndex(): void
$object = new Legend();
$value = mt_rand(1, 100);
- $this->assertEmpty($object->getHashIndex());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setHashIndex($value));
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEmpty($object->getHashIndex());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setHashIndex($value));
+ self::assertEquals($value, $object->getHashIndex());
}
public function testHeight(): void
@@ -95,10 +94,10 @@ public function testHeight(): void
$object = new Legend();
$value = mt_rand(0, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setHeight());
- $this->assertEquals(0, $object->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setHeight($value));
- $this->assertEquals($value, $object->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setHeight());
+ self::assertEquals(0, $object->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setHeight($value));
+ self::assertEquals($value, $object->getHeight());
}
public function testOffsetX(): void
@@ -106,10 +105,10 @@ public function testOffsetX(): void
$object = new Legend();
$value = mt_rand(0, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setOffsetX());
- $this->assertEquals(0, $object->getOffsetX());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setOffsetX($value));
- $this->assertEquals($value, $object->getOffsetX());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setOffsetX());
+ self::assertEquals(0, $object->getOffsetX());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setOffsetX($value));
+ self::assertEquals($value, $object->getOffsetX());
}
public function testOffsetY(): void
@@ -117,32 +116,32 @@ public function testOffsetY(): void
$object = new Legend();
$value = mt_rand(0, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setOffsetY());
- $this->assertEquals(0, $object->getOffsetY());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setOffsetY($value));
- $this->assertEquals($value, $object->getOffsetY());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setOffsetY());
+ self::assertEquals(0, $object->getOffsetY());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setOffsetY($value));
+ self::assertEquals($value, $object->getOffsetY());
}
public function testPosition(): void
{
$object = new Legend();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setPosition());
- $this->assertEquals(Legend::POSITION_RIGHT, $object->getPosition());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setPosition(Legend::POSITION_BOTTOM));
- $this->assertEquals(Legend::POSITION_BOTTOM, $object->getPosition());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setPosition());
+ self::assertEquals(Legend::POSITION_RIGHT, $object->getPosition());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setPosition(Legend::POSITION_BOTTOM));
+ self::assertEquals(Legend::POSITION_BOTTOM, $object->getPosition());
}
public function testVisible(): void
{
$object = new Legend();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setVisible());
- $this->assertTrue($object->isVisible());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setVisible(true));
- $this->assertTrue($object->isVisible());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setVisible(false));
- $this->assertFalse($object->isVisible());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setVisible());
+ self::assertTrue($object->isVisible());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setVisible(true));
+ self::assertTrue($object->isVisible());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setVisible(false));
+ self::assertFalse($object->isVisible());
}
public function testWidth(): void
@@ -150,9 +149,9 @@ public function testWidth(): void
$object = new Legend();
$value = mt_rand(0, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setWidth());
- $this->assertEquals(0, $object->getWidth());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setWidth($value));
- $this->assertEquals($value, $object->getWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setWidth());
+ self::assertEquals(0, $object->getWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setWidth($value));
+ self::assertEquals($value, $object->getWidth());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/MarkerTest.php b/tests/PhpPresentation/Tests/Shape/Chart/MarkerTest.php
index 9904ea6607..5ecf537f25 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/MarkerTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/MarkerTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,24 +35,24 @@ public function testConstruct(): void
{
$object = new Marker();
- $this->assertEquals(Marker::SYMBOL_NONE, $object->getSymbol());
- $this->assertEquals(5, $object->getSize());
+ self::assertEquals(Marker::SYMBOL_NONE, $object->getSymbol());
+ self::assertEquals(5, $object->getSize());
}
public function testBorder(): void
{
$object = new Marker();
- $this->assertInstanceOf(Border::class, $object->getBorder());
- $this->assertInstanceOf(Marker::class, $object->setBorder(new Border()));
+ self::assertInstanceOf(Border::class, $object->getBorder());
+ self::assertInstanceOf(Marker::class, $object->setBorder(new Border()));
}
public function testFill(): void
{
$object = new Marker();
- $this->assertInstanceOf(Fill::class, $object->getFill());
- $this->assertInstanceOf(Marker::class, $object->setFill(new Fill()));
+ self::assertInstanceOf(Fill::class, $object->getFill());
+ self::assertInstanceOf(Marker::class, $object->setFill(new Fill()));
}
public function testSize(): void
@@ -61,8 +60,8 @@ public function testSize(): void
$object = new Marker();
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Marker::class, $object->setSize($value));
- $this->assertEquals($value, $object->getSize());
+ self::assertInstanceOf(Marker::class, $object->setSize($value));
+ self::assertEquals($value, $object->getSize());
}
public function testSymbol(): void
@@ -71,7 +70,7 @@ public function testSymbol(): void
$expected = Marker::$arraySymbol[array_rand(Marker::$arraySymbol)];
- $this->assertInstanceOf(Marker::class, $object->setSymbol($expected));
- $this->assertEquals($expected, $object->getSymbol());
+ self::assertInstanceOf(Marker::class, $object->setSymbol($expected));
+ self::assertEquals($expected, $object->getSymbol());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/PlotAreaTest.php b/tests/PhpPresentation/Tests/Shape/Chart/PlotAreaTest.php
index 42c6a193b4..eb2fac276f 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/PlotAreaTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/PlotAreaTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -38,8 +37,8 @@ public function testConstruct(): void
{
$object = new PlotArea();
- $this->assertInstanceOf(Axis::class, $object->getAxisX());
- $this->assertInstanceOf(Axis::class, $object->getAxisY());
+ self::assertInstanceOf(Axis::class, $object->getAxisX());
+ self::assertInstanceOf(Axis::class, $object->getAxisY());
}
public function testHashIndex(): void
@@ -47,9 +46,9 @@ public function testHashIndex(): void
$object = new PlotArea();
$value = mt_rand(1, 100);
- $this->assertEmpty($object->getHashIndex());
- $this->assertInstanceOf(PlotArea::class, $object->setHashIndex($value));
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEmpty($object->getHashIndex());
+ self::assertInstanceOf(PlotArea::class, $object->setHashIndex($value));
+ self::assertEquals($value, $object->getHashIndex());
}
public function testHeight(): void
@@ -57,10 +56,10 @@ public function testHeight(): void
$object = new PlotArea();
$value = mt_rand(0, 100);
- $this->assertInstanceOf(PlotArea::class, $object->setHeight());
- $this->assertEquals(0, $object->getHeight());
- $this->assertInstanceOf(PlotArea::class, $object->setHeight($value));
- $this->assertEquals($value, $object->getHeight());
+ self::assertInstanceOf(PlotArea::class, $object->setHeight());
+ self::assertEquals(0, $object->getHeight());
+ self::assertInstanceOf(PlotArea::class, $object->setHeight($value));
+ self::assertEquals($value, $object->getHeight());
}
public function testOffsetX(): void
@@ -68,10 +67,10 @@ public function testOffsetX(): void
$object = new PlotArea();
$value = mt_rand(0, 100);
- $this->assertInstanceOf(PlotArea::class, $object->setOffsetX());
- $this->assertEquals(0, $object->getOffsetX());
- $this->assertInstanceOf(PlotArea::class, $object->setOffsetX($value));
- $this->assertEquals($value, $object->getOffsetX());
+ self::assertInstanceOf(PlotArea::class, $object->setOffsetX());
+ self::assertEquals(0, $object->getOffsetX());
+ self::assertInstanceOf(PlotArea::class, $object->setOffsetX($value));
+ self::assertEquals($value, $object->getOffsetX());
}
public function testOffsetY(): void
@@ -79,18 +78,18 @@ public function testOffsetY(): void
$object = new PlotArea();
$value = mt_rand(0, 100);
- $this->assertInstanceOf(PlotArea::class, $object->setOffsetY());
- $this->assertEquals(0, $object->getOffsetY());
- $this->assertInstanceOf(PlotArea::class, $object->setOffsetY($value));
- $this->assertEquals($value, $object->getOffsetY());
+ self::assertInstanceOf(PlotArea::class, $object->setOffsetY());
+ self::assertEquals(0, $object->getOffsetY());
+ self::assertInstanceOf(PlotArea::class, $object->setOffsetY($value));
+ self::assertEquals($value, $object->getOffsetY());
}
public function testType(): void
{
$object = new PlotArea();
- $this->assertInstanceOf(PlotArea::class, $object->setType(new Bar3D()));
- $this->assertInstanceOf(AbstractType::class, $object->getType());
+ self::assertInstanceOf(PlotArea::class, $object->setType(new Bar3D()));
+ self::assertInstanceOf(AbstractType::class, $object->getType());
}
public function testTypeException(): void
@@ -107,9 +106,9 @@ public function testWidth(): void
$object = new PlotArea();
$value = mt_rand(0, 100);
- $this->assertInstanceOf(PlotArea::class, $object->setWidth());
- $this->assertEquals(0, $object->getWidth());
- $this->assertInstanceOf(PlotArea::class, $object->setWidth($value));
- $this->assertEquals($value, $object->getWidth());
+ self::assertInstanceOf(PlotArea::class, $object->setWidth());
+ self::assertEquals(0, $object->getWidth());
+ self::assertInstanceOf(PlotArea::class, $object->setWidth($value));
+ self::assertEquals($value, $object->getWidth());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/SeriesTest.php b/tests/PhpPresentation/Tests/Shape/Chart/SeriesTest.php
index f3cc6b7b16..fb613676ec 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/SeriesTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/SeriesTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -38,64 +37,64 @@ public function testConstruct(): void
{
$object = new Series();
- $this->assertInstanceOf(Fill::class, $object->getFill());
- $this->assertInstanceOf(Font::class, $object->getFont());
- $this->assertEquals('Calibri', $object->getFont()->getName());
- $this->assertEquals(9, $object->getFont()->getSize());
- $this->assertEquals('Series Title', $object->getTitle());
- $this->assertIsArray($object->getValues());
- $this->assertEmpty($object->getValues());
- $this->assertInstanceOf(Marker::class, $object->getMarker());
- $this->assertNull($object->getOutline());
- $this->assertFalse($object->hasShowLegendKey());
+ self::assertInstanceOf(Fill::class, $object->getFill());
+ self::assertInstanceOf(Font::class, $object->getFont());
+ self::assertEquals('Calibri', $object->getFont()->getName());
+ self::assertEquals(9, $object->getFont()->getSize());
+ self::assertEquals('Series Title', $object->getTitle());
+ self::assertIsArray($object->getValues());
+ self::assertEmpty($object->getValues());
+ self::assertInstanceOf(Marker::class, $object->getMarker());
+ self::assertNull($object->getOutline());
+ self::assertFalse($object->hasShowLegendKey());
}
public function testDataLabelNumFormat(): void
{
$object = new Series();
- $this->assertEmpty($object->getDlblNumFormat());
- $this->assertFalse($object->hasDlblNumFormat());
+ self::assertEmpty($object->getDlblNumFormat());
+ self::assertFalse($object->hasDlblNumFormat());
- $this->assertInstanceOf(Series::class, $object->setDlblNumFormat('#%'));
+ self::assertInstanceOf(Series::class, $object->setDlblNumFormat('#%'));
- $this->assertEquals('#%', $object->getDlblNumFormat());
- $this->assertTrue($object->hasDlblNumFormat());
+ self::assertEquals('#%', $object->getDlblNumFormat());
+ self::assertTrue($object->hasDlblNumFormat());
- $this->assertInstanceOf(Series::class, $object->setDlblNumFormat());
+ self::assertInstanceOf(Series::class, $object->setDlblNumFormat());
- $this->assertEmpty($object->getDlblNumFormat());
- $this->assertFalse($object->hasDlblNumFormat());
+ self::assertEmpty($object->getDlblNumFormat());
+ self::assertFalse($object->hasDlblNumFormat());
}
public function testDataPointFills(): void
{
$object = new Series();
- $this->assertIsArray($object->getDataPointFills());
- $this->assertEmpty($object->getDataPointFills());
+ self::assertIsArray($object->getDataPointFills());
+ self::assertEmpty($object->getDataPointFills());
- $this->assertInstanceOf(Fill::class, $object->getDataPointFill(0));
+ self::assertInstanceOf(Fill::class, $object->getDataPointFill(0));
}
public function testFill(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setFill());
- $this->assertNull($object->getFill());
- $this->assertInstanceOf(Series::class, $object->setFill(new Fill()));
- $this->assertInstanceOf(Fill::class, $object->getFill());
+ self::assertInstanceOf(Series::class, $object->setFill());
+ self::assertNull($object->getFill());
+ self::assertInstanceOf(Series::class, $object->setFill(new Fill()));
+ self::assertInstanceOf(Fill::class, $object->getFill());
}
public function testFont(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setFont());
- $this->assertNull($object->getFont());
- $this->assertInstanceOf(Series::class, $object->setFont(new Font()));
- $this->assertInstanceOf(Font::class, $object->getFont());
+ self::assertInstanceOf(Series::class, $object->setFont());
+ self::assertNull($object->getFont());
+ self::assertInstanceOf(Series::class, $object->setFont(new Font()));
+ self::assertInstanceOf(Font::class, $object->getFont());
}
public function testHashIndex(): void
@@ -103,82 +102,82 @@ public function testHashIndex(): void
$object = new Series();
$value = mt_rand(1, 100);
- $this->assertEmpty($object->getHashIndex());
- $this->assertInstanceOf(Series::class, $object->setHashIndex($value));
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEmpty($object->getHashIndex());
+ self::assertInstanceOf(Series::class, $object->setHashIndex($value));
+ self::assertEquals($value, $object->getHashIndex());
}
public function testHashCode(): void
{
$object = new Series();
- $this->assertEquals(md5($object->getFill()->getHashCode() . $object->getFont()->getHashCode() . var_export($object->getValues(), true) . var_export($object, true) . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($object->getFill()->getHashCode() . $object->getFont()->getHashCode() . var_export($object->getValues(), true) . var_export($object, true) . get_class($object)), $object->getHashCode());
}
public function testLabelPosition(): void
{
$object = new Series();
- $this->assertEmpty($object->getHashIndex());
- $this->assertInstanceOf(Series::class, $object->setLabelPosition(Series::LABEL_INSIDEBASE));
- $this->assertEquals(Series::LABEL_INSIDEBASE, $object->getLabelPosition());
+ self::assertEmpty($object->getHashIndex());
+ self::assertInstanceOf(Series::class, $object->setLabelPosition(Series::LABEL_INSIDEBASE));
+ self::assertEquals(Series::LABEL_INSIDEBASE, $object->getLabelPosition());
}
public function testMarker(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setMarker(new Marker()));
- $this->assertInstanceOf(Marker::class, $object->getMarker());
+ self::assertInstanceOf(Series::class, $object->setMarker(new Marker()));
+ self::assertInstanceOf(Marker::class, $object->getMarker());
}
public function testOutline(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setOutline(new Outline()));
- $this->assertInstanceOf(Outline::class, $object->getOutline());
+ self::assertInstanceOf(Series::class, $object->setOutline(new Outline()));
+ self::assertInstanceOf(Outline::class, $object->getOutline());
}
public function testShowCategoryName(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setShowCategoryName(true));
- $this->assertTrue($object->hasShowCategoryName());
- $this->assertInstanceOf(Series::class, $object->setShowCategoryName(false));
- $this->assertFalse($object->hasShowCategoryName());
+ self::assertInstanceOf(Series::class, $object->setShowCategoryName(true));
+ self::assertTrue($object->hasShowCategoryName());
+ self::assertInstanceOf(Series::class, $object->setShowCategoryName(false));
+ self::assertFalse($object->hasShowCategoryName());
}
public function testShowLeaderLines(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setShowLeaderLines(true));
- $this->assertTrue($object->hasShowLeaderLines());
- $this->assertInstanceOf(Series::class, $object->setShowLeaderLines(false));
- $this->assertFalse($object->hasShowLeaderLines());
+ self::assertInstanceOf(Series::class, $object->setShowLeaderLines(true));
+ self::assertTrue($object->hasShowLeaderLines());
+ self::assertInstanceOf(Series::class, $object->setShowLeaderLines(false));
+ self::assertFalse($object->hasShowLeaderLines());
}
public function testShowLegendKey(): void
{
$object = new Series();
- $this->assertFalse($object->hasShowLegendKey());
- $this->assertInstanceOf(Series::class, $object->setShowLegendKey(true));
- $this->assertTrue($object->hasShowLegendKey());
- $this->assertInstanceOf(Series::class, $object->setShowLegendKey(false));
- $this->assertFalse($object->hasShowLegendKey());
+ self::assertFalse($object->hasShowLegendKey());
+ self::assertInstanceOf(Series::class, $object->setShowLegendKey(true));
+ self::assertTrue($object->hasShowLegendKey());
+ self::assertInstanceOf(Series::class, $object->setShowLegendKey(false));
+ self::assertFalse($object->hasShowLegendKey());
}
public function testShowPercentage(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setShowPercentage(true));
- $this->assertTrue($object->hasShowPercentage());
- $this->assertInstanceOf(Series::class, $object->setShowPercentage(false));
- $this->assertFalse($object->hasShowPercentage());
+ self::assertInstanceOf(Series::class, $object->setShowPercentage(true));
+ self::assertTrue($object->hasShowPercentage());
+ self::assertInstanceOf(Series::class, $object->setShowPercentage(false));
+ self::assertFalse($object->hasShowPercentage());
}
public function testShowSeparator(): void
@@ -186,42 +185,42 @@ public function testShowSeparator(): void
$value = ';';
$object = new Series();
- $this->assertFalse($object->hasShowSeparator());
- $this->assertInstanceOf(Series::class, $object->setSeparator($value));
- $this->assertEquals($value, $object->getSeparator());
- $this->assertTrue($object->hasShowSeparator());
- $this->assertInstanceOf(Series::class, $object->setSeparator(''));
- $this->assertFalse($object->hasShowPercentage());
+ self::assertFalse($object->hasShowSeparator());
+ self::assertInstanceOf(Series::class, $object->setSeparator($value));
+ self::assertEquals($value, $object->getSeparator());
+ self::assertTrue($object->hasShowSeparator());
+ self::assertInstanceOf(Series::class, $object->setSeparator(''));
+ self::assertFalse($object->hasShowPercentage());
}
public function testShowSeriesName(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setShowSeriesName(true));
- $this->assertTrue($object->hasShowSeriesName());
- $this->assertInstanceOf(Series::class, $object->setShowSeriesName(false));
- $this->assertFalse($object->hasShowSeriesName());
+ self::assertInstanceOf(Series::class, $object->setShowSeriesName(true));
+ self::assertTrue($object->hasShowSeriesName());
+ self::assertInstanceOf(Series::class, $object->setShowSeriesName(false));
+ self::assertFalse($object->hasShowSeriesName());
}
public function testShowValue(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setShowValue(true));
- $this->assertTrue($object->hasShowValue());
- $this->assertInstanceOf(Series::class, $object->setShowValue(false));
- $this->assertFalse($object->hasShowValue());
+ self::assertInstanceOf(Series::class, $object->setShowValue(true));
+ self::assertTrue($object->hasShowValue());
+ self::assertInstanceOf(Series::class, $object->setShowValue(false));
+ self::assertFalse($object->hasShowValue());
}
public function testTitle(): void
{
$object = new Series();
- $this->assertInstanceOf(Series::class, $object->setTitle());
- $this->assertEquals('Series Title', $object->getTitle());
- $this->assertInstanceOf(Series::class, $object->setTitle('AAAA'));
- $this->assertEquals('AAAA', $object->getTitle());
+ self::assertInstanceOf(Series::class, $object->setTitle());
+ self::assertEquals('Series Title', $object->getTitle());
+ self::assertInstanceOf(Series::class, $object->setTitle('AAAA'));
+ self::assertEquals('AAAA', $object->getTitle());
}
public function testValue(): void
@@ -236,14 +235,14 @@ public function testValue(): void
'3' => 'd',
];
- $this->assertIsArray($object->getValues());
- $this->assertEmpty($object->getValues());
- $this->assertInstanceOf(Series::class, $object->setValues());
- $this->assertEmpty($object->getValues());
- $this->assertInstanceOf(Series::class, $object->setValues($array));
- $this->assertCount(count($array), $object->getValues());
- $this->assertInstanceOf(Series::class, $object->addValue('4', 'e'));
- $this->assertCount(count($array) + 1, $object->getValues());
+ self::assertIsArray($object->getValues());
+ self::assertEmpty($object->getValues());
+ self::assertInstanceOf(Series::class, $object->setValues());
+ self::assertEmpty($object->getValues());
+ self::assertInstanceOf(Series::class, $object->setValues($array));
+ self::assertCount(count($array), $object->getValues());
+ self::assertInstanceOf(Series::class, $object->addValue('4', 'e'));
+ self::assertCount(count($array) + 1, $object->getValues());
}
public function testClone(): void
@@ -252,7 +251,7 @@ public function testClone(): void
$object->setOutline(new Outline());
$clone = clone $object;
- $this->assertInstanceOf(Series::class, $clone);
- $this->assertInstanceOf(Outline::class, $clone->getOutline());
+ self::assertInstanceOf(Series::class, $clone);
+ self::assertInstanceOf(Outline::class, $clone->getOutline());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/TitleTest.php b/tests/PhpPresentation/Tests/Shape/Chart/TitleTest.php
index a2e076451b..8867186258 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/TitleTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/TitleTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,28 +35,28 @@ public function testConstruct(): void
{
$object = new Title();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->getAlignment());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
- $this->assertEquals('Calibri', $object->getFont()->getName());
- $this->assertEquals(18, $object->getFont()->getSize());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->getAlignment());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
+ self::assertEquals('Calibri', $object->getFont()->getName());
+ self::assertEquals(18, $object->getFont()->getSize());
}
public function testAlignment(): void
{
$object = new Title();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setAlignment(new Alignment()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->getAlignment());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setAlignment(new Alignment()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->getAlignment());
}
public function testFont(): void
{
$object = new Title();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setFont());
- $this->assertNull($object->getFont());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setFont(new Font()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setFont());
+ self::assertNull($object->getFont());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setFont(new Font()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
}
public function testHashIndex(): void
@@ -65,9 +64,9 @@ public function testHashIndex(): void
$object = new Title();
$value = mt_rand(1, 100);
- $this->assertEmpty($object->getHashIndex());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setHashIndex($value));
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEmpty($object->getHashIndex());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setHashIndex($value));
+ self::assertEquals($value, $object->getHashIndex());
}
public function testHeight(): void
@@ -75,10 +74,10 @@ public function testHeight(): void
$object = new Title();
$value = mt_rand(0, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setHeight());
- $this->assertEquals(0, $object->getHeight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setHeight($value));
- $this->assertEquals($value, $object->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setHeight());
+ self::assertEquals(0, $object->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setHeight($value));
+ self::assertEquals($value, $object->getHeight());
}
public function testOffsetX(): void
@@ -86,10 +85,10 @@ public function testOffsetX(): void
$object = new Title();
$value = mt_rand(0, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setOffsetX());
- $this->assertEquals(0.01, $object->getOffsetX());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setOffsetX($value));
- $this->assertEquals($value, $object->getOffsetX());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setOffsetX());
+ self::assertEquals(0.01, $object->getOffsetX());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setOffsetX($value));
+ self::assertEquals($value, $object->getOffsetX());
}
public function testOffsetY(): void
@@ -97,32 +96,32 @@ public function testOffsetY(): void
$object = new Title();
$value = mt_rand(0, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setOffsetY());
- $this->assertEquals(0.01, $object->getOffsetY());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setOffsetY($value));
- $this->assertEquals($value, $object->getOffsetY());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setOffsetY());
+ self::assertEquals(0.01, $object->getOffsetY());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setOffsetY($value));
+ self::assertEquals($value, $object->getOffsetY());
}
public function testText(): void
{
$object = new Title();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setText());
- $this->assertNull($object->getText());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setText('AAAA'));
- $this->assertEquals('AAAA', $object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setText());
+ self::assertNull($object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setText('AAAA'));
+ self::assertEquals('AAAA', $object->getText());
}
public function testVisible(): void
{
$object = new Title();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setVisible());
- $this->assertTrue($object->isVisible());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setVisible(true));
- $this->assertTrue($object->isVisible());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setVisible(false));
- $this->assertFalse($object->isVisible());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setVisible());
+ self::assertTrue($object->isVisible());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setVisible(true));
+ self::assertTrue($object->isVisible());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setVisible(false));
+ self::assertFalse($object->isVisible());
}
public function testWidth(): void
@@ -130,9 +129,9 @@ public function testWidth(): void
$object = new Title();
$value = mt_rand(0, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setWidth());
- $this->assertEquals(0, $object->getWidth());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setWidth($value));
- $this->assertEquals($value, $object->getWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setWidth());
+ self::assertEquals(0, $object->getWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setWidth($value));
+ self::assertEquals($value, $object->getWidth());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/AbstractTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/AbstractTest.php
index d19327eba2..0addee5996 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/AbstractTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/AbstractTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,8 +35,8 @@ public function testAxis(): void
{
$object = new Scatter();
- $this->assertTrue($object->hasAxisX());
- $this->assertTrue($object->hasAxisY());
+ self::assertTrue($object->hasAxisX());
+ self::assertTrue($object->hasAxisY());
}
public function testHashIndex(): void
@@ -45,25 +44,25 @@ public function testHashIndex(): void
$object = new Scatter();
$value = mt_rand(1, 100);
- $this->assertEmpty($object->getHashIndex());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Scatter', $object->setHashIndex($value));
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEmpty($object->getHashIndex());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Scatter', $object->setHashIndex($value));
+ self::assertEquals($value, $object->getHashIndex());
}
public function testSeries(): void
{
/** @var AbstractType $stub */
$stub = $this->getMockForAbstractClass(AbstractType::class);
- $this->assertEmpty($stub->getSeries());
- $this->assertIsArray($stub->getSeries());
+ self::assertEmpty($stub->getSeries());
+ self::assertIsArray($stub->getSeries());
$arraySeries = [
new Series(),
new Series(),
];
- $this->assertInstanceOf(AbstractType::class, $stub->setSeries($arraySeries));
- $this->assertIsArray($stub->getSeries());
- $this->assertCount(count($arraySeries), $stub->getSeries());
+ self::assertInstanceOf(AbstractType::class, $stub->setSeries($arraySeries));
+ self::assertIsArray($stub->getSeries());
+ self::assertCount(count($arraySeries), $stub->getSeries());
}
public function testClone(): void
@@ -80,8 +79,8 @@ public function testClone(): void
$stub->setSeries($arraySeries);
$clone = clone $stub;
- $this->assertInstanceOf(AbstractType::class, $clone);
- $this->assertIsArray($stub->getSeries());
- $this->assertCount(count($arraySeries), $stub->getSeries());
+ self::assertInstanceOf(AbstractType::class, $clone);
+ self::assertIsArray($stub->getSeries());
+ self::assertCount(count($arraySeries), $stub->getSeries());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/AreaTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/AreaTest.php
index e1eba28f60..af93fa19c7 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/AreaTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/AreaTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,26 +34,26 @@ public function testData(): void
{
$object = new Area();
- $this->assertIsArray($object->getSeries());
- $this->assertEmpty($object->getSeries());
+ self::assertIsArray($object->getSeries());
+ self::assertEmpty($object->getSeries());
$array = [
new Series(),
new Series(),
];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Area', $object->setSeries());
- $this->assertEmpty($object->getSeries());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Area', $object->setSeries($array));
- $this->assertCount(count($array), $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Area', $object->setSeries());
+ self::assertEmpty($object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Area', $object->setSeries($array));
+ self::assertCount(count($array), $object->getSeries());
}
public function testSeries(): void
{
$object = new Area();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Area', $object->addSeries(new Series()));
- $this->assertCount(1, $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Area', $object->addSeries(new Series()));
+ self::assertCount(1, $object->getSeries());
}
public function testHashCode(): void
@@ -64,6 +63,6 @@ public function testHashCode(): void
$object = new Area();
$object->addSeries($oSeries);
- $this->assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/Bar3DTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/Bar3DTest.php
index 68df16e1f9..137d577293 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/Bar3DTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/Bar3DTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,61 +34,61 @@ public function testData(): void
{
$object = new Bar3D();
- $this->assertIsArray($object->getSeries());
- $this->assertEmpty($object->getSeries());
+ self::assertIsArray($object->getSeries());
+ self::assertEmpty($object->getSeries());
$array = [
new Series(),
new Series(),
];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setSeries());
- $this->assertEmpty($object->getSeries());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setSeries($array));
- $this->assertCount(count($array), $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setSeries());
+ self::assertEmpty($object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setSeries($array));
+ self::assertCount(count($array), $object->getSeries());
}
public function testSeries(): void
{
$object = new Bar3D();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->addSeries(new Series()));
- $this->assertCount(1, $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->addSeries(new Series()));
+ self::assertCount(1, $object->getSeries());
}
public function testBarDirection(): void
{
$object = new Bar3D();
- $this->assertEquals(Bar3D::DIRECTION_VERTICAL, $object->getBarDirection());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarDirection(Bar3D::DIRECTION_HORIZONTAL));
- $this->assertEquals(Bar3D::DIRECTION_HORIZONTAL, $object->getBarDirection());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarDirection(Bar3D::DIRECTION_VERTICAL));
- $this->assertEquals(Bar3D::DIRECTION_VERTICAL, $object->getBarDirection());
+ self::assertEquals(Bar3D::DIRECTION_VERTICAL, $object->getBarDirection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarDirection(Bar3D::DIRECTION_HORIZONTAL));
+ self::assertEquals(Bar3D::DIRECTION_HORIZONTAL, $object->getBarDirection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarDirection(Bar3D::DIRECTION_VERTICAL));
+ self::assertEquals(Bar3D::DIRECTION_VERTICAL, $object->getBarDirection());
}
public function testBarGrouping(): void
{
$object = new Bar3D();
- $this->assertEquals(Bar3D::GROUPING_CLUSTERED, $object->getBarGrouping());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarGrouping(Bar3D::GROUPING_CLUSTERED));
- $this->assertEquals(Bar3D::GROUPING_CLUSTERED, $object->getBarGrouping());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarGrouping(Bar3D::GROUPING_STACKED));
- $this->assertEquals(Bar3D::GROUPING_STACKED, $object->getBarGrouping());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarGrouping(Bar3D::GROUPING_PERCENTSTACKED));
- $this->assertEquals(Bar3D::GROUPING_PERCENTSTACKED, $object->getBarGrouping());
+ self::assertEquals(Bar3D::GROUPING_CLUSTERED, $object->getBarGrouping());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarGrouping(Bar3D::GROUPING_CLUSTERED));
+ self::assertEquals(Bar3D::GROUPING_CLUSTERED, $object->getBarGrouping());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarGrouping(Bar3D::GROUPING_STACKED));
+ self::assertEquals(Bar3D::GROUPING_STACKED, $object->getBarGrouping());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setBarGrouping(Bar3D::GROUPING_PERCENTSTACKED));
+ self::assertEquals(Bar3D::GROUPING_PERCENTSTACKED, $object->getBarGrouping());
}
public function testGapWidthPercent(): void
{
$value = mt_rand(0, 500);
$object = new Bar3D();
- $this->assertEquals(150, $object->getGapWidthPercent());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setGapWidthPercent($value));
- $this->assertEquals($value, $object->getGapWidthPercent());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setGapWidthPercent(-1));
- $this->assertEquals(0, $object->getGapWidthPercent());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setGapWidthPercent(501));
- $this->assertEquals(500, $object->getGapWidthPercent());
+ self::assertEquals(150, $object->getGapWidthPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setGapWidthPercent($value));
+ self::assertEquals($value, $object->getGapWidthPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setGapWidthPercent(-1));
+ self::assertEquals(0, $object->getGapWidthPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setGapWidthPercent(501));
+ self::assertEquals(500, $object->getGapWidthPercent());
}
public function testHashCode(): void
@@ -99,6 +98,6 @@ public function testHashCode(): void
$object = new Bar3D();
$object->addSeries($oSeries);
- $this->assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/BarTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/BarTest.php
index 8b7dbd7dc9..88dd6dab8f 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/BarTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/BarTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,87 +34,87 @@ public function testData(): void
{
$object = new Bar();
- $this->assertIsArray($object->getSeries());
- $this->assertEmpty($object->getSeries());
+ self::assertIsArray($object->getSeries());
+ self::assertEmpty($object->getSeries());
$array = [
new Series(),
new Series(),
];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setSeries());
- $this->assertEmpty($object->getSeries());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setSeries($array));
- $this->assertCount(count($array), $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setSeries());
+ self::assertEmpty($object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setSeries($array));
+ self::assertCount(count($array), $object->getSeries());
}
public function testSeries(): void
{
$object = new Bar();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->addSeries(new Series()));
- $this->assertCount(1, $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->addSeries(new Series()));
+ self::assertCount(1, $object->getSeries());
}
public function testBarDirection(): void
{
$object = new Bar();
- $this->assertEquals(Bar::DIRECTION_VERTICAL, $object->getBarDirection());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarDirection(Bar::DIRECTION_HORIZONTAL));
- $this->assertEquals(Bar::DIRECTION_HORIZONTAL, $object->getBarDirection());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarDirection(Bar::DIRECTION_VERTICAL));
- $this->assertEquals(Bar::DIRECTION_VERTICAL, $object->getBarDirection());
+ self::assertEquals(Bar::DIRECTION_VERTICAL, $object->getBarDirection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarDirection(Bar::DIRECTION_HORIZONTAL));
+ self::assertEquals(Bar::DIRECTION_HORIZONTAL, $object->getBarDirection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarDirection(Bar::DIRECTION_VERTICAL));
+ self::assertEquals(Bar::DIRECTION_VERTICAL, $object->getBarDirection());
}
public function testBarGrouping(): void
{
$object = new Bar();
- $this->assertEquals(Bar::GROUPING_CLUSTERED, $object->getBarGrouping());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarGrouping(Bar::GROUPING_CLUSTERED));
- $this->assertEquals(Bar::GROUPING_CLUSTERED, $object->getBarGrouping());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarGrouping(Bar::GROUPING_STACKED));
- $this->assertEquals(Bar::GROUPING_STACKED, $object->getBarGrouping());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarGrouping(Bar::GROUPING_PERCENTSTACKED));
- $this->assertEquals(Bar::GROUPING_PERCENTSTACKED, $object->getBarGrouping());
+ self::assertEquals(Bar::GROUPING_CLUSTERED, $object->getBarGrouping());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarGrouping(Bar::GROUPING_CLUSTERED));
+ self::assertEquals(Bar::GROUPING_CLUSTERED, $object->getBarGrouping());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarGrouping(Bar::GROUPING_STACKED));
+ self::assertEquals(Bar::GROUPING_STACKED, $object->getBarGrouping());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setBarGrouping(Bar::GROUPING_PERCENTSTACKED));
+ self::assertEquals(Bar::GROUPING_PERCENTSTACKED, $object->getBarGrouping());
}
public function testGapWidthPercent(): void
{
$value = mt_rand(0, 500);
$object = new Bar();
- $this->assertEquals(150, $object->getGapWidthPercent());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setGapWidthPercent($value));
- $this->assertEquals($value, $object->getGapWidthPercent());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setGapWidthPercent(-1));
- $this->assertEquals(0, $object->getGapWidthPercent());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setGapWidthPercent(501));
- $this->assertEquals(500, $object->getGapWidthPercent());
+ self::assertEquals(150, $object->getGapWidthPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setGapWidthPercent($value));
+ self::assertEquals($value, $object->getGapWidthPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setGapWidthPercent(-1));
+ self::assertEquals(0, $object->getGapWidthPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setGapWidthPercent(501));
+ self::assertEquals(500, $object->getGapWidthPercent());
}
public function testOverlapWidthPercentDefaults(): void
{
$object = new Bar();
- $this->assertEquals(0, $object->getOverlapWidthPercent());
+ self::assertEquals(0, $object->getOverlapWidthPercent());
$object->setBarGrouping(Bar::GROUPING_STACKED);
- $this->assertEquals(100, $object->getOverlapWidthPercent());
+ self::assertEquals(100, $object->getOverlapWidthPercent());
$object->setBarGrouping(Bar::GROUPING_CLUSTERED);
- $this->assertEquals(0, $object->getOverlapWidthPercent());
+ self::assertEquals(0, $object->getOverlapWidthPercent());
$object->setBarGrouping(Bar::GROUPING_PERCENTSTACKED);
- $this->assertEquals(100, $object->getOverlapWidthPercent());
+ self::assertEquals(100, $object->getOverlapWidthPercent());
}
public function testOverlapWidthPercent(): void
{
$value = mt_rand(-100, 100);
$object = new Bar();
- $this->assertEquals(0, $object->getOverlapWidthPercent());
- $this->assertInstanceOf(Bar::class, $object->setOverlapWidthPercent($value));
- $this->assertEquals($value, $object->getOverlapWidthPercent());
- $this->assertInstanceOf(Bar::class, $object->setOverlapWidthPercent(101));
- $this->assertEquals(100, $object->getOverlapWidthPercent());
- $this->assertInstanceOf(Bar::class, $object->setOverlapWidthPercent(-101));
- $this->assertEquals(-100, $object->getOverlapWidthPercent());
+ self::assertEquals(0, $object->getOverlapWidthPercent());
+ self::assertInstanceOf(Bar::class, $object->setOverlapWidthPercent($value));
+ self::assertEquals($value, $object->getOverlapWidthPercent());
+ self::assertInstanceOf(Bar::class, $object->setOverlapWidthPercent(101));
+ self::assertEquals(100, $object->getOverlapWidthPercent());
+ self::assertInstanceOf(Bar::class, $object->setOverlapWidthPercent(-101));
+ self::assertEquals(-100, $object->getOverlapWidthPercent());
}
public function testHashCode(): void
@@ -125,6 +124,6 @@ public function testHashCode(): void
$object = new Bar();
$object->addSeries($oSeries);
- $this->assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/DoughnutTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/DoughnutTest.php
index a6c8a22045..8b13b5043b 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/DoughnutTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/DoughnutTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,18 +34,18 @@ public function testData(): void
{
$object = new Doughnut();
- $this->assertIsArray($object->getSeries());
- $this->assertEmpty($object->getSeries());
+ self::assertIsArray($object->getSeries());
+ self::assertEmpty($object->getSeries());
$array = [
new Series(),
new Series(),
];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setSeries());
- $this->assertEmpty($object->getSeries());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setSeries($array));
- $this->assertCount(count($array), $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setSeries());
+ self::assertEmpty($object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setSeries($array));
+ self::assertCount(count($array), $object->getSeries());
}
public function testHoleSize(): void
@@ -54,23 +53,23 @@ public function testHoleSize(): void
$rand = mt_rand(10, 90);
$object = new Doughnut();
- $this->assertEquals(50, $object->getHoleSize());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setHoleSize(9));
- $this->assertEquals(10, $object->getHoleSize());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setHoleSize(91));
- $this->assertEquals(90, $object->getHoleSize());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setHoleSize($rand));
- $this->assertEquals($rand, $object->getHoleSize());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setHoleSize());
- $this->assertEquals(50, $object->getHoleSize());
+ self::assertEquals(50, $object->getHoleSize());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setHoleSize(9));
+ self::assertEquals(10, $object->getHoleSize());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setHoleSize(91));
+ self::assertEquals(90, $object->getHoleSize());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setHoleSize($rand));
+ self::assertEquals($rand, $object->getHoleSize());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->setHoleSize());
+ self::assertEquals(50, $object->getHoleSize());
}
public function testSeries(): void
{
$object = new Doughnut();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->addSeries(new Series()));
- $this->assertCount(1, $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Doughnut', $object->addSeries(new Series()));
+ self::assertCount(1, $object->getSeries());
}
public function testHashCode(): void
@@ -80,6 +79,6 @@ public function testHashCode(): void
$object = new Doughnut();
$object->addSeries($oSeries);
- $this->assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/LineTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/LineTest.php
index 05b6cb6f3f..2a077b2ed9 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/LineTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/LineTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,35 +34,35 @@ public function testData(): void
{
$object = new Line();
- $this->assertIsArray($object->getSeries());
- $this->assertEmpty($object->getSeries());
+ self::assertIsArray($object->getSeries());
+ self::assertEmpty($object->getSeries());
$array = [
new Series(),
new Series(),
];
- $this->assertInstanceOf(Line::class, $object->setSeries());
- $this->assertEmpty($object->getSeries());
- $this->assertInstanceOf(Line::class, $object->setSeries($array));
- $this->assertCount(count($array), $object->getSeries());
+ self::assertInstanceOf(Line::class, $object->setSeries());
+ self::assertEmpty($object->getSeries());
+ self::assertInstanceOf(Line::class, $object->setSeries($array));
+ self::assertCount(count($array), $object->getSeries());
}
public function testSeries(): void
{
$object = new Line();
- $this->assertInstanceOf(Line::class, $object->addSeries(new Series()));
- $this->assertCount(1, $object->getSeries());
+ self::assertInstanceOf(Line::class, $object->addSeries(new Series()));
+ self::assertCount(1, $object->getSeries());
}
public function testSmooth(): void
{
$object = new Line();
- $this->assertFalse($object->isSmooth());
- $this->assertInstanceOf(Line::class, $object->setIsSmooth(true));
- $this->assertTrue($object->isSmooth());
+ self::assertFalse($object->isSmooth());
+ self::assertInstanceOf(Line::class, $object->setIsSmooth(true));
+ self::assertTrue($object->isSmooth());
}
public function testHashCode(): void
@@ -73,7 +72,7 @@ public function testHashCode(): void
$object = new Line();
$object->addSeries($series);
- $this->assertEquals(
+ self::assertEquals(
md5(md5($object->isSmooth() ? '1' : '0') . $series->getHashCode() . get_class($object)),
$object->getHashCode()
);
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/Pie3DTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/Pie3DTest.php
index 33f825c179..dd259108bf 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/Pie3DTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/Pie3DTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,26 +34,26 @@ public function testData(): void
{
$object = new Pie3D();
- $this->assertIsArray($object->getSeries());
- $this->assertEmpty($object->getSeries());
+ self::assertIsArray($object->getSeries());
+ self::assertEmpty($object->getSeries());
$array = [
new Series(),
new Series(),
];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie3D', $object->setSeries());
- $this->assertEmpty($object->getSeries());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie3D', $object->setSeries($array));
- $this->assertCount(count($array), $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie3D', $object->setSeries());
+ self::assertEmpty($object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie3D', $object->setSeries($array));
+ self::assertCount(count($array), $object->getSeries());
}
public function testSeries(): void
{
$object = new Pie3D();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie3D', $object->addSeries(new Series()));
- $this->assertCount(1, $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie3D', $object->addSeries(new Series()));
+ self::assertCount(1, $object->getSeries());
}
public function testExplosion(): void
@@ -62,9 +61,9 @@ public function testExplosion(): void
$value = mt_rand(0, 100);
$object = new Pie3D();
- $this->assertEquals(0, $object->getExplosion());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie3D', $object->setExplosion($value));
- $this->assertEquals($value, $object->getExplosion());
+ self::assertEquals(0, $object->getExplosion());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie3D', $object->setExplosion($value));
+ self::assertEquals($value, $object->getExplosion());
}
public function testHashCode(): void
@@ -74,6 +73,6 @@ public function testHashCode(): void
$object = new Pie3D();
$object->addSeries($oSeries);
- $this->assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/PieTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/PieTest.php
index 42f5b5d6aa..0ba4387a2a 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/PieTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/PieTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,26 +34,26 @@ public function testData(): void
{
$object = new Pie();
- $this->assertIsArray($object->getSeries());
- $this->assertEmpty($object->getSeries());
+ self::assertIsArray($object->getSeries());
+ self::assertEmpty($object->getSeries());
$array = [
new Series(),
new Series(),
];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie', $object->setSeries());
- $this->assertEmpty($object->getSeries());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie', $object->setSeries($array));
- $this->assertCount(count($array), $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie', $object->setSeries());
+ self::assertEmpty($object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie', $object->setSeries($array));
+ self::assertCount(count($array), $object->getSeries());
}
public function testSeries(): void
{
$object = new Pie();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie', $object->addSeries(new Series()));
- $this->assertCount(1, $object->getSeries());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Pie', $object->addSeries(new Series()));
+ self::assertCount(1, $object->getSeries());
}
public function testHashCode(): void
@@ -64,6 +63,6 @@ public function testHashCode(): void
$object = new Pie();
$object->addSeries($oSeries);
- $this->assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/RadarTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/RadarTest.php
index 07a3cb2f97..e64621861c 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/RadarTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/RadarTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,6 +32,6 @@ public function testHashCode(): void
$object = new Radar();
$object->addSeries($series);
- $this->assertEquals(md5($series->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($series->getHashCode() . get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/ScatterTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/ScatterTest.php
index ca8134be77..36727ddbfa 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/Type/ScatterTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/ScatterTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,35 +34,35 @@ public function testData(): void
{
$object = new Scatter();
- $this->assertIsArray($object->getSeries());
- $this->assertEmpty($object->getSeries());
+ self::assertIsArray($object->getSeries());
+ self::assertEmpty($object->getSeries());
$array = [
new Series(),
new Series(),
];
- $this->assertInstanceOf(Scatter::class, $object->setSeries());
- $this->assertEmpty($object->getSeries());
- $this->assertInstanceOf(Scatter::class, $object->setSeries($array));
- $this->assertCount(count($array), $object->getSeries());
+ self::assertInstanceOf(Scatter::class, $object->setSeries());
+ self::assertEmpty($object->getSeries());
+ self::assertInstanceOf(Scatter::class, $object->setSeries($array));
+ self::assertCount(count($array), $object->getSeries());
}
public function testSeries(): void
{
$object = new Scatter();
- $this->assertInstanceOf(Scatter::class, $object->addSeries(new Series()));
- $this->assertCount(1, $object->getSeries());
+ self::assertInstanceOf(Scatter::class, $object->addSeries(new Series()));
+ self::assertCount(1, $object->getSeries());
}
public function testSmooth(): void
{
$object = new Scatter();
- $this->assertFalse($object->isSmooth());
- $this->assertInstanceOf(Scatter::class, $object->setIsSmooth(true));
- $this->assertTrue($object->isSmooth());
+ self::assertFalse($object->isSmooth());
+ self::assertInstanceOf(Scatter::class, $object->setIsSmooth(true));
+ self::assertTrue($object->isSmooth());
}
public function testHashCode(): void
@@ -73,7 +72,7 @@ public function testHashCode(): void
$object = new Scatter();
$object->addSeries($series);
- $this->assertEquals(
+ self::assertEquals(
md5(md5($object->isSmooth() ? '1' : '0') . $series->getHashCode() . get_class($object)),
$object->getHashCode()
);
diff --git a/tests/PhpPresentation/Tests/Shape/Chart/View3DTest.php b/tests/PhpPresentation/Tests/Shape/Chart/View3DTest.php
index f86d39fb15..cbe311aa9c 100644
--- a/tests/PhpPresentation/Tests/Shape/Chart/View3DTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Chart/View3DTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,10 +34,10 @@ public function testDepthPercent(): void
$object = new View3D();
$value = mt_rand(20, 20000);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setDepthPercent());
- $this->assertEquals(100, $object->getDepthPercent());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setDepthPercent($value));
- $this->assertEquals($value, $object->getDepthPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setDepthPercent());
+ self::assertEquals(100, $object->getDepthPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setDepthPercent($value));
+ self::assertEquals($value, $object->getDepthPercent());
}
public function testHashIndex(): void
@@ -46,9 +45,9 @@ public function testHashIndex(): void
$object = new View3D();
$value = mt_rand(1, 100);
- $this->assertEmpty($object->getHashIndex());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setHashIndex($value));
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEmpty($object->getHashIndex());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setHashIndex($value));
+ self::assertEquals($value, $object->getHashIndex());
}
public function testHeightPercent(): void
@@ -56,10 +55,10 @@ public function testHeightPercent(): void
$object = new View3D();
$value = mt_rand(5, 500);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setHeightPercent());
- $this->assertEquals(100, $object->getHeightPercent());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setHeightPercent($value));
- $this->assertEquals($value, $object->getHeightPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setHeightPercent());
+ self::assertEquals(100, $object->getHeightPercent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setHeightPercent($value));
+ self::assertEquals($value, $object->getHeightPercent());
}
public function testPerspective(): void
@@ -67,22 +66,22 @@ public function testPerspective(): void
$object = new View3D();
$value = mt_rand(0, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setPerspective());
- $this->assertEquals(30, $object->getPerspective());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setPerspective($value));
- $this->assertEquals($value, $object->getPerspective());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setPerspective());
+ self::assertEquals(30, $object->getPerspective());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setPerspective($value));
+ self::assertEquals($value, $object->getPerspective());
}
public function testRightAngleAxes(): void
{
$object = new View3D();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRightAngleAxes());
- $this->assertTrue($object->hasRightAngleAxes());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRightAngleAxes(true));
- $this->assertTrue($object->hasRightAngleAxes());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRightAngleAxes(false));
- $this->assertFalse($object->hasRightAngleAxes());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRightAngleAxes());
+ self::assertTrue($object->hasRightAngleAxes());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRightAngleAxes(true));
+ self::assertTrue($object->hasRightAngleAxes());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRightAngleAxes(false));
+ self::assertFalse($object->hasRightAngleAxes());
}
public function testRotationX(): void
@@ -90,10 +89,10 @@ public function testRotationX(): void
$object = new View3D();
$value = mt_rand(-90, 90);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationX());
- $this->assertEquals(0, $object->getRotationX());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationX($value));
- $this->assertEquals($value, $object->getRotationX());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationX());
+ self::assertEquals(0, $object->getRotationX());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationX($value));
+ self::assertEquals($value, $object->getRotationX());
}
public function testRotationY(): void
@@ -101,9 +100,9 @@ public function testRotationY(): void
$object = new View3D();
$value = mt_rand(-90, 90);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationY());
- $this->assertEquals(0, $object->getRotationY());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationY($value));
- $this->assertEquals($value, $object->getRotationY());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationY());
+ self::assertEquals(0, $object->getRotationY());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationY($value));
+ self::assertEquals($value, $object->getRotationY());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/ChartTest.php b/tests/PhpPresentation/Tests/Shape/ChartTest.php
index b51d857757..2322df83f9 100644
--- a/tests/PhpPresentation/Tests/Shape/ChartTest.php
+++ b/tests/PhpPresentation/Tests/Shape/ChartTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -34,10 +33,10 @@ public function testConstruct(): void
{
$object = new Chart();
- $this->assertInstanceOf(Chart\Title::class, $object->getTitle());
- $this->assertInstanceOf(Chart\Legend::class, $object->getLegend());
- $this->assertInstanceOf(Chart\PlotArea::class, $object->getPlotArea());
- $this->assertInstanceOf(Chart\View3D::class, $object->getView3D());
+ self::assertInstanceOf(Chart\Title::class, $object->getTitle());
+ self::assertInstanceOf(Chart\Legend::class, $object->getLegend());
+ self::assertInstanceOf(Chart\PlotArea::class, $object->getPlotArea());
+ self::assertInstanceOf(Chart\View3D::class, $object->getView3D());
}
public function testClone(): void
@@ -46,38 +45,38 @@ public function testClone(): void
$oClone = clone $object;
- $this->assertInstanceOf(Chart::class, $oClone);
- $this->assertInstanceOf(Chart\Title::class, $oClone->getTitle());
- $this->assertInstanceOf(Chart\Legend::class, $oClone->getLegend());
- $this->assertInstanceOf(Chart\PlotArea::class, $oClone->getPlotArea());
- $this->assertInstanceOf(Chart\View3D::class, $oClone->getView3D());
+ self::assertInstanceOf(Chart::class, $oClone);
+ self::assertInstanceOf(Chart\Title::class, $oClone->getTitle());
+ self::assertInstanceOf(Chart\Legend::class, $oClone->getLegend());
+ self::assertInstanceOf(Chart\PlotArea::class, $oClone->getPlotArea());
+ self::assertInstanceOf(Chart\View3D::class, $oClone->getView3D());
}
public function testDisplayBlankAs(): void
{
$object = new Chart();
- $this->assertEquals(Chart::BLANKAS_ZERO, $object->getDisplayBlankAs());
- $this->assertInstanceOf(Chart::class, $object->setDisplayBlankAs(Chart::BLANKAS_GAP));
- $this->assertEquals(Chart::BLANKAS_GAP, $object->getDisplayBlankAs());
- $this->assertInstanceOf(Chart::class, $object->setDisplayBlankAs(Chart::BLANKAS_ZERO));
- $this->assertEquals(Chart::BLANKAS_ZERO, $object->getDisplayBlankAs());
- $this->assertInstanceOf(Chart::class, $object->setDisplayBlankAs(Chart::BLANKAS_SPAN));
- $this->assertEquals(Chart::BLANKAS_SPAN, $object->getDisplayBlankAs());
- $this->assertInstanceOf(Chart::class, $object->setDisplayBlankAs('Unauthorized value'));
- $this->assertEquals(Chart::BLANKAS_SPAN, $object->getDisplayBlankAs());
+ self::assertEquals(Chart::BLANKAS_ZERO, $object->getDisplayBlankAs());
+ self::assertInstanceOf(Chart::class, $object->setDisplayBlankAs(Chart::BLANKAS_GAP));
+ self::assertEquals(Chart::BLANKAS_GAP, $object->getDisplayBlankAs());
+ self::assertInstanceOf(Chart::class, $object->setDisplayBlankAs(Chart::BLANKAS_ZERO));
+ self::assertEquals(Chart::BLANKAS_ZERO, $object->getDisplayBlankAs());
+ self::assertInstanceOf(Chart::class, $object->setDisplayBlankAs(Chart::BLANKAS_SPAN));
+ self::assertEquals(Chart::BLANKAS_SPAN, $object->getDisplayBlankAs());
+ self::assertInstanceOf(Chart::class, $object->setDisplayBlankAs('Unauthorized value'));
+ self::assertEquals(Chart::BLANKAS_SPAN, $object->getDisplayBlankAs());
}
public function testIncludeSpreadsheet(): void
{
$object = new Chart();
- $this->assertFalse($object->hasIncludedSpreadsheet());
- $this->assertInstanceOf(Chart::class, $object->setIncludeSpreadsheet());
- $this->assertFalse($object->hasIncludedSpreadsheet());
- $this->assertInstanceOf(Chart::class, $object->setIncludeSpreadsheet(false));
- $this->assertFalse($object->hasIncludedSpreadsheet());
- $this->assertInstanceOf(Chart::class, $object->setIncludeSpreadsheet(true));
- $this->assertTrue($object->hasIncludedSpreadsheet());
+ self::assertFalse($object->hasIncludedSpreadsheet());
+ self::assertInstanceOf(Chart::class, $object->setIncludeSpreadsheet());
+ self::assertFalse($object->hasIncludedSpreadsheet());
+ self::assertInstanceOf(Chart::class, $object->setIncludeSpreadsheet(false));
+ self::assertFalse($object->hasIncludedSpreadsheet());
+ self::assertInstanceOf(Chart::class, $object->setIncludeSpreadsheet(true));
+ self::assertTrue($object->hasIncludedSpreadsheet());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Comment/AuthorTest.php b/tests/PhpPresentation/Tests/Shape/Comment/AuthorTest.php
index e705542467..202275113e 100644
--- a/tests/PhpPresentation/Tests/Shape/Comment/AuthorTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Comment/AuthorTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -34,9 +33,9 @@ public function testConstruct(): void
{
$object = new Author();
- $this->assertNull($object->getName());
- $this->assertNull($object->getIndex());
- $this->assertNull($object->getInitials());
+ self::assertNull($object->getName());
+ self::assertNull($object->getIndex());
+ self::assertNull($object->getInitials());
}
public function testGetSetIndex(): void
@@ -44,9 +43,9 @@ public function testGetSetIndex(): void
$expectedVal = mt_rand(1, 100);
$object = new Author();
- $this->assertNull($object->getIndex());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment\\Author', $object->setIndex($expectedVal));
- $this->assertEquals($expectedVal, $object->getIndex());
+ self::assertNull($object->getIndex());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment\\Author', $object->setIndex($expectedVal));
+ self::assertEquals($expectedVal, $object->getIndex());
}
public function testGetSetInitials(): void
@@ -54,9 +53,9 @@ public function testGetSetInitials(): void
$expectedVal = 'AABBCCDD';
$object = new Author();
- $this->assertNull($object->getInitials());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment\\Author', $object->setInitials($expectedVal));
- $this->assertEquals($expectedVal, $object->getInitials());
+ self::assertNull($object->getInitials());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment\\Author', $object->setInitials($expectedVal));
+ self::assertEquals($expectedVal, $object->getInitials());
}
public function testGetSetName(): void
@@ -64,8 +63,8 @@ public function testGetSetName(): void
$expectedVal = 'AABBCCDD';
$object = new Author();
- $this->assertNull($object->getName());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment\\Author', $object->setName($expectedVal));
- $this->assertEquals($expectedVal, $object->getName());
+ self::assertNull($object->getName());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment\\Author', $object->setName($expectedVal));
+ self::assertEquals($expectedVal, $object->getName());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/CommentTest.php b/tests/PhpPresentation/Tests/Shape/CommentTest.php
index b1c3490e7d..37d7dd708f 100644
--- a/tests/PhpPresentation/Tests/Shape/CommentTest.php
+++ b/tests/PhpPresentation/Tests/Shape/CommentTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,11 +34,11 @@ public function testConstruct(): void
{
$object = new Comment();
- $this->assertNull($object->getAuthor());
- $this->assertNull($object->getText());
- $this->assertIsInt($object->getDate());
- $this->assertNull($object->getHeight());
- $this->assertNull($object->getWidth());
+ self::assertNull($object->getAuthor());
+ self::assertNull($object->getText());
+ self::assertIsInt($object->getDate());
+ self::assertNull($object->getHeight());
+ self::assertNull($object->getWidth());
}
public function testGetSetAuthor(): void
@@ -49,9 +48,9 @@ public function testGetSetAuthor(): void
/** @var Author $oStub */
$oStub = $this->getMockBuilder(Author::class)->getMock();
- $this->assertNull($object->getAuthor());
- $this->assertInstanceOf(Comment::class, $object->setAuthor($oStub));
- $this->assertInstanceOf(Author::class, $object->getAuthor());
+ self::assertNull($object->getAuthor());
+ self::assertInstanceOf(Comment::class, $object->setAuthor($oStub));
+ self::assertInstanceOf(Author::class, $object->getAuthor());
}
public function testGetSetDate(): void
@@ -59,10 +58,10 @@ public function testGetSetDate(): void
$expectedDate = time();
$object = new Comment();
- $this->assertIsInt($object->getDate());
- $this->assertInstanceOf(Comment::class, $object->setDate($expectedDate));
- $this->assertEquals($expectedDate, $object->getDate());
- $this->assertIsInt($object->getDate());
+ self::assertIsInt($object->getDate());
+ self::assertInstanceOf(Comment::class, $object->setDate($expectedDate));
+ self::assertEquals($expectedDate, $object->getDate());
+ self::assertIsInt($object->getDate());
}
public function testGetSetText(): void
@@ -70,19 +69,19 @@ public function testGetSetText(): void
$expectedText = 'AABBCCDD';
$object = new Comment();
- $this->assertNull($object->getText());
- $this->assertInstanceOf(Comment::class, $object->setText($expectedText));
- $this->assertEquals($expectedText, $object->getText());
+ self::assertNull($object->getText());
+ self::assertInstanceOf(Comment::class, $object->setText($expectedText));
+ self::assertEquals($expectedText, $object->getText());
}
public function testGetSetHeightAndWidtg(): void
{
$object = new Comment();
- $this->assertNull($object->getHeight());
- $this->assertNull($object->getWidth());
- $this->assertInstanceOf(Comment::class, $object->setHeight(1));
- $this->assertInstanceOf(Comment::class, $object->setWidth(1));
- $this->assertNull($object->getHeight());
- $this->assertNull($object->getWidth());
+ self::assertNull($object->getHeight());
+ self::assertNull($object->getWidth());
+ self::assertInstanceOf(Comment::class, $object->setHeight(1));
+ self::assertInstanceOf(Comment::class, $object->setWidth(1));
+ self::assertNull($object->getHeight());
+ self::assertNull($object->getWidth());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Drawing/Base64Test.php b/tests/PhpPresentation/Tests/Shape/Drawing/Base64Test.php
index c73b8af448..515f4c12a7 100644
--- a/tests/PhpPresentation/Tests/Shape/Drawing/Base64Test.php
+++ b/tests/PhpPresentation/Tests/Shape/Drawing/Base64Test.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -50,16 +49,16 @@ public function testData(): void
{
$oDrawing = new Base64();
- $this->assertEmpty($oDrawing->getData());
+ self::assertEmpty($oDrawing->getData());
$oDrawing->setData($this->imageDataPNG);
- $this->assertNotEmpty($oDrawing->getData());
+ self::assertNotEmpty($oDrawing->getData());
}
public function testExtension(): void
{
$oDrawing = new Base64();
$oDrawing->setData($this->imageDataPNG);
- $this->assertEquals('jpg', $oDrawing->getExtension());
+ self::assertEquals('jpg', $oDrawing->getExtension());
}
public function testExtensionException(): void
@@ -78,20 +77,20 @@ public function testMimeType(): void
{
$oDrawing = new Base64();
$oDrawing->setData($this->imageDataPNG);
- $this->assertEquals('image/jpeg', $oDrawing->getMimeType());
+ self::assertEquals('image/jpeg', $oDrawing->getMimeType());
}
public function testMimeTypeSVG(): void
{
$oDrawing = new Base64();
$oDrawing->setData($this->imageDataSVG);
- $this->assertEquals('image/svg+xml', $oDrawing->getMimeType());
+ self::assertEquals('image/svg+xml', $oDrawing->getMimeType());
}
public function testMimeTypeFunctionNotExists(): void
{
$oDrawing = new Base64();
$oDrawing->setData($this->imageDataPNG);
- $this->assertEquals('image/jpeg', $oDrawing->getMimeType());
+ self::assertEquals('image/jpeg', $oDrawing->getMimeType());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Drawing/FileTest.php b/tests/PhpPresentation/Tests/Shape/Drawing/FileTest.php
index 479f64c1a6..14d02c8dad 100644
--- a/tests/PhpPresentation/Tests/Shape/Drawing/FileTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Drawing/FileTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -34,7 +33,7 @@ class FileTest extends TestCase
public function testConstruct(): void
{
$object = new File();
- $this->assertEmpty($object->getPath());
+ self::assertEmpty($object->getPath());
}
public function testPathBasic(): void
@@ -43,15 +42,15 @@ public function testPathBasic(): void
$this->expectExceptionMessage('The file "" doesn\'t exist');
$object = new File();
- $this->assertInstanceOf(File::class, $object->setPath());
+ self::assertInstanceOf(File::class, $object->setPath());
}
public function testPathWithoutVerifyFile(): void
{
$object = new File();
- $this->assertInstanceOf(File::class, $object->setPath('', false));
- $this->assertEmpty($object->getPath());
+ self::assertInstanceOf(File::class, $object->setPath('', false));
+ self::assertEmpty($object->getPath());
}
public function testPathWithRealFile(): void
@@ -60,10 +59,10 @@ public function testPathWithRealFile(): void
$imagePath = dirname(__DIR__, 4) . '/resources/images/PhpPresentationLogo.png';
- $this->assertInstanceOf(File::class, $object->setPath($imagePath, false));
- $this->assertEquals($imagePath, $object->getPath());
- $this->assertEquals(0, $object->getWidth());
- $this->assertEquals(0, $object->getHeight());
+ self::assertInstanceOf(File::class, $object->setPath($imagePath, false));
+ self::assertEquals($imagePath, $object->getPath());
+ self::assertEquals(0, $object->getWidth());
+ self::assertEquals(0, $object->getHeight());
}
/**
@@ -72,14 +71,14 @@ public function testPathWithRealFile(): void
public function testMimeType(string $pathFile, string $mimeType): void
{
$object = new File();
- $this->assertInstanceOf(File::class, $object->setPath($pathFile));
- $this->assertEquals($mimeType, $object->getMimeType());
+ self::assertInstanceOf(File::class, $object->setPath($pathFile));
+ self::assertEquals($mimeType, $object->getMimeType());
}
/**
* @return array>
*/
- public function dataProviderMimeType(): array
+ public static function dataProviderMimeType(): array
{
return [
[
diff --git a/tests/PhpPresentation/Tests/Shape/Drawing/ZipFileTest.php b/tests/PhpPresentation/Tests/Shape/Drawing/ZipFileTest.php
index 3a5a7fbb25..bd35ac9c72 100644
--- a/tests/PhpPresentation/Tests/Shape/Drawing/ZipFileTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Drawing/ZipFileTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -72,13 +71,13 @@ public function testExtension(): void
{
$oDrawing = new ZipFile();
$oDrawing->setPath($this->fileOk);
- $this->assertEquals('gif', $oDrawing->getExtension());
+ self::assertEquals('gif', $oDrawing->getExtension());
}
public function testMimeType(): void
{
$oDrawing = new ZipFile();
$oDrawing->setPath($this->fileOk);
- $this->assertEquals('image/gif', $oDrawing->getMimeType());
+ self::assertEquals('image/gif', $oDrawing->getMimeType());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/GroupTest.php b/tests/PhpPresentation/Tests/Shape/GroupTest.php
index 85cb4cd607..f5b0eefc56 100644
--- a/tests/PhpPresentation/Tests/Shape/GroupTest.php
+++ b/tests/PhpPresentation/Tests/Shape/GroupTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,25 +34,25 @@ public function testConstruct(): void
{
$object = new Group();
- $this->assertEquals(0, $object->getOffsetX());
- $this->assertEquals(0, $object->getOffsetY());
- $this->assertEquals(0, $object->getExtentX());
- $this->assertEquals(0, $object->getExtentY());
- $this->assertEquals(0, $object->getShapeCollection()->count());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->setWidth(rand(1, 100)));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->setHeight(rand(1, 100)));
+ self::assertEquals(0, $object->getOffsetX());
+ self::assertEquals(0, $object->getOffsetY());
+ self::assertEquals(0, $object->getExtentX());
+ self::assertEquals(0, $object->getExtentY());
+ self::assertCount(0, $object->getShapeCollection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->setWidth(mt_rand(1, 100)));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->setHeight(mt_rand(1, 100)));
}
public function testAdd(): void
{
$object = new Group();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart', $object->createChartShape());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\File', $object->createDrawingShape());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Line', $object->createLineShape(10, 10, 10, 10));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $object->createRichTextShape());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table', $object->createTableShape());
- $this->assertEquals(5, $object->getShapeCollection()->count());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart', $object->createChartShape());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\File', $object->createDrawingShape());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Line', $object->createLineShape(10, 10, 10, 10));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $object->createRichTextShape());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table', $object->createTableShape());
+ self::assertCount(5, $object->getShapeCollection());
}
public function testExtentX(): void
@@ -62,7 +61,7 @@ public function testExtentX(): void
$line1 = new Line(10, 20, 30, 50);
$object->addShape($line1);
- $this->assertEquals(20, $object->getExtentX());
+ self::assertEquals(20, $object->getExtentX());
}
public function testExtentY(): void
@@ -71,7 +70,7 @@ public function testExtentY(): void
$line1 = new Line(10, 20, 30, 50);
$object->addShape($line1);
- $this->assertEquals(30, $object->getExtentY());
+ self::assertEquals(30, $object->getExtentY());
}
public function testOffsetX(): void
@@ -80,10 +79,10 @@ public function testOffsetX(): void
$line1 = new Line(10, 20, 30, 50);
$object->addShape($line1);
- $this->assertEquals(10, $object->getOffsetX());
+ self::assertEquals(10, $object->getOffsetX());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->setOffsetX(rand(1, 100)));
- $this->assertEquals(10, $object->getOffsetX());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->setOffsetX(mt_rand(1, 100)));
+ self::assertEquals(10, $object->getOffsetX());
}
public function testOffsetY(): void
@@ -92,10 +91,10 @@ public function testOffsetY(): void
$line1 = new Line(10, 20, 30, 50);
$object->addShape($line1);
- $this->assertEquals(20, $object->getOffsetY());
+ self::assertEquals(20, $object->getOffsetY());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->setOffsetY(rand(1, 100)));
- $this->assertEquals(20, $object->getOffsetY());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->setOffsetY(mt_rand(1, 100)));
+ self::assertEquals(20, $object->getOffsetY());
}
public function testExtentsAndOffsetsForOneShape(): void
@@ -114,10 +113,10 @@ public function testExtentsAndOffsetsForOneShape(): void
$line1 = new Line($offsetX, $offsetY, $endX, $endY);
$object->addShape($line1);
- $this->assertEquals($offsetX, $object->getOffsetX());
- $this->assertEquals($offsetY, $object->getOffsetY());
- $this->assertEquals($extentX, $object->getExtentX());
- $this->assertEquals($extentY, $object->getExtentY());
+ self::assertEquals($offsetX, $object->getOffsetX());
+ self::assertEquals($offsetY, $object->getOffsetY());
+ self::assertEquals($extentX, $object->getExtentX());
+ self::assertEquals($extentY, $object->getExtentY());
}
public function testExtentsAndOffsetsForTwoShapes(): void
@@ -147,9 +146,9 @@ public function testExtentsAndOffsetsForTwoShapes(): void
$object->addShape($line1);
$object->addShape($line2);
- $this->assertEquals($offsetX, $object->getOffsetX());
- $this->assertEquals($offsetY, $object->getOffsetY());
- $this->assertEquals($extentX, $object->getExtentX());
- $this->assertEquals($extentY, $object->getExtentY());
+ self::assertEquals($offsetX, $object->getOffsetX());
+ self::assertEquals($offsetY, $object->getOffsetY());
+ self::assertEquals($extentX, $object->getExtentX());
+ self::assertEquals($extentY, $object->getExtentY());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/HyperlinkTest.php b/tests/PhpPresentation/Tests/Shape/HyperlinkTest.php
index 991f728525..1b79991c18 100644
--- a/tests/PhpPresentation/Tests/Shape/HyperlinkTest.php
+++ b/tests/PhpPresentation/Tests/Shape/HyperlinkTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,16 +35,16 @@ class HyperlinkTest extends TestCase
public function testConstruct(): void
{
$object = new Hyperlink();
- $this->assertEmpty($object->getUrl());
- $this->assertEmpty($object->getTooltip());
+ self::assertEmpty($object->getUrl());
+ self::assertEmpty($object->getTooltip());
$object = new Hyperlink('http://test.com');
- $this->assertEquals('http://test.com', $object->getUrl());
- $this->assertEmpty($object->getTooltip());
+ self::assertEquals('http://test.com', $object->getUrl());
+ self::assertEmpty($object->getTooltip());
$object = new Hyperlink('http://test.com', 'Test');
- $this->assertEquals('http://test.com', $object->getUrl());
- $this->assertEquals('Test', $object->getTooltip());
+ self::assertEquals('http://test.com', $object->getUrl());
+ self::assertEquals('Test', $object->getTooltip());
}
/**
@@ -54,13 +53,13 @@ public function testConstruct(): void
public function testGetHashCode(): void
{
$object = new Hyperlink();
- $this->assertEquals(md5(get_class($object)), $object->getHashCode());
+ self::assertEquals(md5(get_class($object)), $object->getHashCode());
$object = new Hyperlink('http://test.com');
- $this->assertEquals(md5('http://test.com' . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5('http://test.com' . get_class($object)), $object->getHashCode());
$object = new Hyperlink('http://test.com', 'Test');
- $this->assertEquals(md5('http://test.com' . 'Test' . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5('http://test.com' . 'Test' . get_class($object)), $object->getHashCode());
}
/**
@@ -71,54 +70,66 @@ public function testSetGetHashIndex(): void
$object = new Hyperlink();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
public function testGetSetSlideNumber(): void
{
$object = new Hyperlink();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setSlideNumber());
- $this->assertEquals(1, $object->getSlideNumber());
- $this->assertEquals('ppaction://hlinksldjump', $object->getUrl());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setSlideNumber());
+ self::assertEquals(1, $object->getSlideNumber());
+ self::assertEquals('ppaction://hlinksldjump', $object->getUrl());
$value = mt_rand(1, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setSlideNumber($value));
- $this->assertEquals($value, $object->getSlideNumber());
- $this->assertEquals('ppaction://hlinksldjump', $object->getUrl());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setSlideNumber($value));
+ self::assertEquals($value, $object->getSlideNumber());
+ self::assertEquals('ppaction://hlinksldjump', $object->getUrl());
}
public function testGetSetTooltip(): void
{
$object = new Hyperlink();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setTooltip());
- $this->assertEmpty($object->getTooltip());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setTooltip());
+ self::assertEmpty($object->getTooltip());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setTooltip('TEST'));
- $this->assertEquals('TEST', $object->getTooltip());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setTooltip('TEST'));
+ self::assertEquals('TEST', $object->getTooltip());
}
public function testGetSetUrl(): void
{
$object = new Hyperlink();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setUrl());
- $this->assertEmpty($object->getUrl());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setUrl());
+ self::assertEmpty($object->getUrl());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setUrl('http://www.github.com'));
- $this->assertEquals('http://www.github.com', $object->getUrl());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setUrl('http://www.github.com'));
+ self::assertEquals('http://www.github.com', $object->getUrl());
}
public function testIsInternal(): void
{
$object = new Hyperlink();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setSlideNumber());
- $this->assertTrue($object->isInternal());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setSlideNumber());
+ self::assertTrue($object->isInternal());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setUrl('http://www.github.com'));
- $this->assertFalse($object->isInternal());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setUrl('http://www.github.com'));
+ self::assertFalse($object->isInternal());
+ }
+
+ public function testIsTextColorUsed(): void
+ {
+ $object = new Hyperlink();
+ self::assertFalse($object->isTextColorUsed());
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setIsTextColorUsed(true));
+ self::assertTrue($object->isTextColorUsed());
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->setIsTextColorUsed(false));
+ self::assertFalse($object->isTextColorUsed());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/LineTest.php b/tests/PhpPresentation/Tests/Shape/LineTest.php
index 12ada15315..4bbfeecd9a 100644
--- a/tests/PhpPresentation/Tests/Shape/LineTest.php
+++ b/tests/PhpPresentation/Tests/Shape/LineTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -39,11 +38,11 @@ public function testConstruct(): void
$value = mt_rand(1, 100);
$object = new Line($value, $value, $value, $value);
- $this->assertEquals(Border::LINE_SINGLE, $object->getBorder()->getLineStyle());
- $this->assertEquals($value, $object->getOffsetX());
- $this->assertEquals($value, $object->getOffsetY());
- $this->assertEquals(0, $object->getWidth());
- $this->assertEquals(0, $object->getHeight());
- $this->assertIsString($object->getHashCode());
+ self::assertEquals(Border::LINE_SINGLE, $object->getBorder()->getLineStyle());
+ self::assertEquals($value, $object->getOffsetX());
+ self::assertEquals($value, $object->getOffsetY());
+ self::assertEquals(0, $object->getWidth());
+ self::assertEquals(0, $object->getHeight());
+ self::assertIsString($object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/MediaTest.php b/tests/PhpPresentation/Tests/Shape/MediaTest.php
index 14508464c6..cd6e6502ba 100644
--- a/tests/PhpPresentation/Tests/Shape/MediaTest.php
+++ b/tests/PhpPresentation/Tests/Shape/MediaTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -29,19 +28,19 @@ public function testInheritance(): void
{
$object = new Media();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\File', $object);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\File', $object);
}
public function testMimeType(): void
{
$object = new Media();
$object->setPath('file.mp4', false);
- $this->assertEquals('video/mp4', $object->getMimeType());
+ self::assertEquals('video/mp4', $object->getMimeType());
$object->setPath('file.ogv', false);
- $this->assertEquals('video/ogg', $object->getMimeType());
+ self::assertEquals('video/ogg', $object->getMimeType());
$object->setPath('file.wmv', false);
- $this->assertEquals('video/x-ms-wmv', $object->getMimeType());
+ self::assertEquals('video/x-ms-wmv', $object->getMimeType());
$object->setPath('file.xxx', false);
- $this->assertEquals('application/octet-stream', $object->getMimeType());
+ self::assertEquals('application/octet-stream', $object->getMimeType());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/PlaceholderTest.php b/tests/PhpPresentation/Tests/Shape/PlaceholderTest.php
index eb741d24f3..bdc81e7775 100644
--- a/tests/PhpPresentation/Tests/Shape/PlaceholderTest.php
+++ b/tests/PhpPresentation/Tests/Shape/PlaceholderTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,6 +21,7 @@
use PhpOffice\PhpPresentation\Shape\Placeholder;
use PHPUnit\Framework\TestCase;
+use ReflectionClass;
/**
* Test class for Table element.
@@ -33,8 +33,8 @@ class PlaceholderTest extends TestCase
public function testConstruct(): void
{
$object = new Placeholder(Placeholder::PH_TYPE_BODY);
- $this->assertEquals(Placeholder::PH_TYPE_BODY, $object->getType());
- $this->assertNull($object->getIdx());
+ self::assertEquals(Placeholder::PH_TYPE_BODY, $object->getType());
+ self::assertNull($object->getIdx());
}
public function testIdx(): void
@@ -42,20 +42,20 @@ public function testIdx(): void
$value = mt_rand(0, 100);
$object = new Placeholder(Placeholder::PH_TYPE_BODY);
- $this->assertNull($object->getIdx());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Placeholder', $object->setIdx($value));
- $this->assertEquals($value, $object->getIdx());
+ self::assertNull($object->getIdx());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Placeholder', $object->setIdx($value));
+ self::assertEquals($value, $object->getIdx());
}
public function testType(): void
{
- $rcPlaceholder = new \ReflectionClass('PhpOffice\PhpPresentation\Shape\Placeholder');
+ $rcPlaceholder = new ReflectionClass('PhpOffice\PhpPresentation\Shape\Placeholder');
$arrayConstants = $rcPlaceholder->getConstants();
$value = array_rand($arrayConstants);
$object = new Placeholder(Placeholder::PH_TYPE_BODY);
- $this->assertEquals(Placeholder::PH_TYPE_BODY, $object->getType());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Placeholder', $object->setType($value));
- $this->assertEquals($value, $object->getType());
+ self::assertEquals(Placeholder::PH_TYPE_BODY, $object->getType());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Placeholder', $object->setType($value));
+ self::assertEquals($value, $object->getType());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/RichText/BreakElementTest.php b/tests/PhpPresentation/Tests/Shape/RichText/BreakElementTest.php
index 512af22a9d..085d7aadf0 100644
--- a/tests/PhpPresentation/Tests/Shape/RichText/BreakElementTest.php
+++ b/tests/PhpPresentation/Tests/Shape/RichText/BreakElementTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,25 +35,25 @@ class BreakElementTest extends TestCase
public function testText(): void
{
$object = new BreakElement();
- $this->assertEquals("\r\n", $object->getText());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->setText());
- $this->assertEquals("\r\n", $object->getText());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->setText('AAA'));
- $this->assertEquals("\r\n", $object->getText());
+ self::assertEquals("\r\n", $object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->setText());
+ self::assertEquals("\r\n", $object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->setText('AAA'));
+ self::assertEquals("\r\n", $object->getText());
}
public function testFont(): void
{
$object = new BreakElement();
- $this->assertNull($object->getFont());
+ self::assertNull($object->getFont());
}
public function testLanguage(): void
{
$object = new BreakElement();
- $this->assertNull($object->getLanguage());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->setLanguage('en-US'));
- $this->assertNull($object->getLanguage());
+ self::assertNull($object->getLanguage());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->setLanguage('en-US'));
+ self::assertNull($object->getLanguage());
}
/**
@@ -63,6 +62,6 @@ public function testLanguage(): void
public function testHashCode(): void
{
$object = new BreakElement();
- $this->assertEquals(md5(get_class($object)), $object->getHashCode());
+ self::assertEquals(md5(get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/RichText/ParagraphTest.php b/tests/PhpPresentation/Tests/Shape/RichText/ParagraphTest.php
index be34b6f1cf..57f9d6fc8b 100644
--- a/tests/PhpPresentation/Tests/Shape/RichText/ParagraphTest.php
+++ b/tests/PhpPresentation/Tests/Shape/RichText/ParagraphTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -40,17 +39,17 @@ class ParagraphTest extends TestCase
public function testConstruct(): void
{
$object = new Paragraph();
- $this->assertEmpty($object->getRichTextElements());
- $this->assertInstanceOf(Alignment::class, $object->getAlignment());
- $this->assertInstanceOf(Font::class, $object->getFont());
- $this->assertInstanceOf(Bullet::class, $object->getBulletStyle());
+ self::assertEmpty($object->getRichTextElements());
+ self::assertInstanceOf(Alignment::class, $object->getAlignment());
+ self::assertInstanceOf(Font::class, $object->getFont());
+ self::assertInstanceOf(Bullet::class, $object->getBulletStyle());
}
public function testAlignment(): void
{
$object = new Paragraph();
- $this->assertInstanceOf(Alignment::class, $object->getAlignment());
- $this->assertInstanceOf(Paragraph::class, $object->setAlignment(new Alignment()));
+ self::assertInstanceOf(Alignment::class, $object->getAlignment());
+ self::assertInstanceOf(Paragraph::class, $object->setAlignment(new Alignment()));
}
/**
@@ -59,11 +58,11 @@ public function testAlignment(): void
public function testBulletStyle(): void
{
$object = new Paragraph();
- $this->assertInstanceOf(Bullet::class, $object->getBulletStyle());
- $this->assertInstanceOf(Paragraph::class, $object->setBulletStyle());
- $this->assertNull($object->getBulletStyle());
- $this->assertInstanceOf(Paragraph::class, $object->setBulletStyle(new Bullet()));
- $this->assertInstanceOf(Bullet::class, $object->getBulletStyle());
+ self::assertInstanceOf(Bullet::class, $object->getBulletStyle());
+ self::assertInstanceOf(Paragraph::class, $object->setBulletStyle());
+ self::assertNull($object->getBulletStyle());
+ self::assertInstanceOf(Paragraph::class, $object->setBulletStyle(new Bullet()));
+ self::assertInstanceOf(Bullet::class, $object->getBulletStyle());
}
/**
@@ -72,11 +71,11 @@ public function testBulletStyle(): void
public function testFont(): void
{
$object = new Paragraph();
- $this->assertInstanceOf(Font::class, $object->getFont());
- $this->assertInstanceOf(Paragraph::class, $object->setFont());
- $this->assertNull($object->getFont());
- $this->assertInstanceOf(Paragraph::class, $object->setFont(new Font()));
- $this->assertInstanceOf(Font::class, $object->getFont());
+ self::assertInstanceOf(Font::class, $object->getFont());
+ self::assertInstanceOf(Paragraph::class, $object->setFont());
+ self::assertNull($object->getFont());
+ self::assertInstanceOf(Paragraph::class, $object->setFont(new Font()));
+ self::assertInstanceOf(Font::class, $object->getFont());
}
/**
@@ -87,7 +86,7 @@ public function testHashCode(): void
$object = new Paragraph();
$oElement = new TextElement();
$object->addText($oElement);
- $this->assertEquals(md5($oElement->getHashCode() . $object->getFont()->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($oElement->getHashCode() . $object->getFont()->getHashCode() . get_class($object)), $object->getHashCode());
}
/**
@@ -98,7 +97,7 @@ public function testHashIndex(): void
$object = new Paragraph();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
/**
@@ -108,9 +107,9 @@ public function testLineSpacing(): void
{
$object = new Paragraph();
$valueExpected = mt_rand(1, 100);
- $this->assertEquals(100, $object->getLineSpacing());
- $this->assertInstanceOf(Paragraph::class, $object->setLineSpacing($valueExpected));
- $this->assertEquals($valueExpected, $object->getLineSpacing());
+ self::assertEquals(100, $object->getLineSpacing());
+ self::assertInstanceOf(Paragraph::class, $object->setLineSpacing($valueExpected));
+ self::assertEquals($valueExpected, $object->getLineSpacing());
}
/**
@@ -119,13 +118,13 @@ public function testLineSpacing(): void
public function testLineSpacingMode(): void
{
$object = new Paragraph();
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $object->getLineSpacingMode());
- $this->assertInstanceOf(Paragraph::class, $object->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT));
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_POINT, $object->getLineSpacingMode());
- $this->assertInstanceOf(Paragraph::class, $object->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_PERCENT));
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $object->getLineSpacingMode());
- $this->assertInstanceOf(Paragraph::class, $object->setLineSpacingMode('Unauthorized'));
- $this->assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $object->getLineSpacingMode());
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $object->getLineSpacingMode());
+ self::assertInstanceOf(Paragraph::class, $object->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT));
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_POINT, $object->getLineSpacingMode());
+ self::assertInstanceOf(Paragraph::class, $object->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_PERCENT));
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $object->getLineSpacingMode());
+ self::assertInstanceOf(Paragraph::class, $object->setLineSpacingMode('Unauthorized'));
+ self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $object->getLineSpacingMode());
}
/**
@@ -134,34 +133,34 @@ public function testLineSpacingMode(): void
public function testRichTextElements(): void
{
$object = new Paragraph();
- $this->assertIsArray($object->getRichTextElements());
- $this->assertEmpty($object->getRichTextElements());
+ self::assertIsArray($object->getRichTextElements());
+ self::assertEmpty($object->getRichTextElements());
$object->createBreak();
- $this->assertCount(1, $object->getRichTextElements());
+ self::assertCount(1, $object->getRichTextElements());
$array = [
new TextElement(),
new TextElement(),
new TextElement(),
];
- $this->assertInstanceOf(Paragraph::class, $object->setRichTextElements($array));
- $this->assertCount(3, $object->getRichTextElements());
+ self::assertInstanceOf(Paragraph::class, $object->setRichTextElements($array));
+ self::assertCount(3, $object->getRichTextElements());
}
public function testSpacingAfter(): void
{
$object = new Paragraph();
- $this->assertEquals(0, $object->getSpacingAfter());
- $this->assertInstanceOf(Paragraph::class, $object->setSpacingAfter(1));
- $this->assertEquals(1, $object->getSpacingAfter());
+ self::assertEquals(0, $object->getSpacingAfter());
+ self::assertInstanceOf(Paragraph::class, $object->setSpacingAfter(1));
+ self::assertEquals(1, $object->getSpacingAfter());
}
public function testSpacingBefore(): void
{
$object = new Paragraph();
- $this->assertEquals(0, $object->getSpacingBefore());
- $this->assertInstanceOf(Paragraph::class, $object->setSpacingBefore(1));
- $this->assertEquals(1, $object->getSpacingBefore());
+ self::assertEquals(0, $object->getSpacingBefore());
+ self::assertInstanceOf(Paragraph::class, $object->setSpacingBefore(1));
+ self::assertEquals(1, $object->getSpacingBefore());
}
/**
@@ -170,19 +169,19 @@ public function testSpacingBefore(): void
public function testText(): void
{
$object = new Paragraph();
- $this->assertInstanceOf(Paragraph::class, $object->addText(new TextElement()));
- $this->assertCount(1, $object->getRichTextElements());
- $this->assertInstanceOf(TextElement::class, $object->createText());
- $this->assertCount(2, $object->getRichTextElements());
- $this->assertInstanceOf(TextElement::class, $object->createText('AAA'));
- $this->assertCount(3, $object->getRichTextElements());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->createBreak());
- $this->assertCount(4, $object->getRichTextElements());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun());
- $this->assertCount(5, $object->getRichTextElements());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun('BBB'));
- $this->assertCount(6, $object->getRichTextElements());
- $this->assertEquals('AAA' . "\r\n" . 'BBB', $object->getPlainText());
- $this->assertEquals('AAA' . "\r\n" . 'BBB', (string) $object);
+ self::assertInstanceOf(Paragraph::class, $object->addText(new TextElement()));
+ self::assertCount(1, $object->getRichTextElements());
+ self::assertInstanceOf(TextElement::class, $object->createText());
+ self::assertCount(2, $object->getRichTextElements());
+ self::assertInstanceOf(TextElement::class, $object->createText('AAA'));
+ self::assertCount(3, $object->getRichTextElements());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->createBreak());
+ self::assertCount(4, $object->getRichTextElements());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun());
+ self::assertCount(5, $object->getRichTextElements());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun('BBB'));
+ self::assertCount(6, $object->getRichTextElements());
+ self::assertEquals('AAA' . "\r\n" . 'BBB', $object->getPlainText());
+ self::assertEquals('AAA' . "\r\n" . 'BBB', (string) $object);
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/RichText/RunTest.php b/tests/PhpPresentation/Tests/Shape/RichText/RunTest.php
index 0deb0b3336..213bb2982f 100644
--- a/tests/PhpPresentation/Tests/Shape/RichText/RunTest.php
+++ b/tests/PhpPresentation/Tests/Shape/RichText/RunTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,40 +36,40 @@ class RunTest extends TestCase
public function testConstruct(): void
{
$object = new Run();
- $this->assertEquals('', $object->getText());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
+ self::assertEquals('', $object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
$object = new Run('BBB');
- $this->assertEquals('BBB', $object->getText());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
+ self::assertEquals('BBB', $object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
}
public function testFont(): void
{
$object = new Run();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setFont(new Font()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setFont(new Font()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
}
public function testLanguage(): void
{
$object = new Run();
- $this->assertNull($object->getLanguage());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setLanguage('en-US'));
- $this->assertEquals('en-US', $object->getLanguage());
+ self::assertNull($object->getLanguage());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setLanguage('en-US'));
+ self::assertEquals('en-US', $object->getLanguage());
}
public function testText(): void
{
$object = new Run();
- $this->assertEquals('', $object->getText());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setText());
- $this->assertEquals('', $object->getText());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setText('AAA'));
- $this->assertEquals('AAA', $object->getText());
+ self::assertEquals('', $object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setText());
+ self::assertEquals('', $object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setText('AAA'));
+ self::assertEquals('AAA', $object->getText());
$object = new Run('BBB');
- $this->assertEquals('BBB', $object->getText());
+ self::assertEquals('BBB', $object->getText());
}
/**
@@ -79,6 +78,6 @@ public function testText(): void
public function testHashCode(): void
{
$object = new Run();
- $this->assertEquals(md5($object->getFont()->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($object->getFont()->getHashCode() . get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/RichText/TextElementTest.php b/tests/PhpPresentation/Tests/Shape/RichText/TextElementTest.php
index f63de69d45..0a0eb7f146 100644
--- a/tests/PhpPresentation/Tests/Shape/RichText/TextElementTest.php
+++ b/tests/PhpPresentation/Tests/Shape/RichText/TextElementTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,47 +36,47 @@ class TextElementTest extends TestCase
public function testConstruct(): void
{
$object = new TextElement();
- $this->assertEquals('', $object->getText());
+ self::assertEquals('', $object->getText());
$object = new TextElement('AAA');
- $this->assertEquals('AAA', $object->getText());
+ self::assertEquals('AAA', $object->getText());
}
public function testFont(): void
{
$object = new TextElement();
- $this->assertNull($object->getFont());
+ self::assertNull($object->getFont());
}
public function testHyperlink(): void
{
$object = new TextElement();
- $this->assertFalse($object->hasHyperlink());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setHyperlink());
- $this->assertFalse($object->hasHyperlink());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->getHyperlink());
- $this->assertTrue($object->hasHyperlink());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setHyperlink(new Hyperlink('http://www.google.fr')));
- $this->assertTrue($object->hasHyperlink());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->getHyperlink());
+ self::assertFalse($object->hasHyperlink());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setHyperlink());
+ self::assertFalse($object->hasHyperlink());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->getHyperlink());
+ self::assertTrue($object->hasHyperlink());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setHyperlink(new Hyperlink('http://www.google.fr')));
+ self::assertTrue($object->hasHyperlink());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Hyperlink', $object->getHyperlink());
}
public function testLanguage(): void
{
$object = new TextElement();
- $this->assertNull($object->getLanguage());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setLanguage('en-US'));
- $this->assertEquals('en-US', $object->getLanguage());
+ self::assertNull($object->getLanguage());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setLanguage('en-US'));
+ self::assertEquals('en-US', $object->getLanguage());
}
public function testText(): void
{
$object = new TextElement();
- $this->assertEquals('', $object->getText());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setText());
- $this->assertEquals('', $object->getText());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setText('AAA'));
- $this->assertEquals('AAA', $object->getText());
+ self::assertEquals('', $object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setText());
+ self::assertEquals('', $object->getText());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->setText('AAA'));
+ self::assertEquals('AAA', $object->getText());
}
/**
@@ -86,6 +85,6 @@ public function testText(): void
public function testHashCode(): void
{
$object = new TextElement();
- $this->assertEquals(md5(get_class($object)), $object->getHashCode());
+ self::assertEquals(md5(get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/RichTextTest.php b/tests/PhpPresentation/Tests/Shape/RichTextTest.php
index 7019fc292a..e75137a1ea 100644
--- a/tests/PhpPresentation/Tests/Shape/RichTextTest.php
+++ b/tests/PhpPresentation/Tests/Shape/RichTextTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -38,23 +37,23 @@ class RichTextTest extends TestCase
public function testConstruct(): void
{
$object = new RichText();
- $this->assertEquals(0, $object->getActiveParagraphIndex());
- $this->assertCount(1, $object->getParagraphs());
+ self::assertEquals(0, $object->getActiveParagraphIndex());
+ self::assertCount(1, $object->getParagraphs());
}
public function testActiveParagraph(): void
{
$object = new RichText();
- $this->assertEquals(0, $object->getActiveParagraphIndex());
- $this->assertInstanceOf(Paragraph::class, $object->createParagraph());
- $this->assertCount(2, $object->getParagraphs());
+ self::assertEquals(0, $object->getActiveParagraphIndex());
+ self::assertInstanceOf(Paragraph::class, $object->createParagraph());
+ self::assertCount(2, $object->getParagraphs());
$value = mt_rand(0, 1);
- $this->assertInstanceOf(Paragraph::class, $object->setActiveParagraph($value));
- $this->assertEquals($value, $object->getActiveParagraphIndex());
- $this->assertInstanceOf(Paragraph::class, $object->getActiveParagraph());
- $this->assertInstanceOf(Paragraph::class, $object->getParagraph());
+ self::assertInstanceOf(Paragraph::class, $object->setActiveParagraph($value));
+ self::assertEquals($value, $object->getActiveParagraphIndex());
+ self::assertInstanceOf(Paragraph::class, $object->getActiveParagraph());
+ self::assertInstanceOf(Paragraph::class, $object->getParagraph());
$value = mt_rand(0, 1);
- $this->assertInstanceOf(Paragraph::class, $object->getParagraph($value));
+ self::assertInstanceOf(Paragraph::class, $object->getParagraph($value));
}
public function testActiveParagraphException(): void
@@ -80,20 +79,20 @@ public function testColumns(): void
$object = new RichText();
$value = mt_rand(1, 16);
- $this->assertInstanceOf(RichText::class, $object->setColumns($value));
- $this->assertEquals($value, $object->getColumns());
+ self::assertInstanceOf(RichText::class, $object->setColumns($value));
+ self::assertEquals($value, $object->getColumns());
}
public function testColumnSpacing(): void
{
$object = new RichText();
- $this->assertEquals(0, $object->getColumnSpacing());
+ self::assertEquals(0, $object->getColumnSpacing());
$value = mt_rand(1, 16);
- $this->assertInstanceOf(RichText::class, $object->setColumnSpacing($value));
- $this->assertEquals($value, $object->getColumnSpacing());
- $this->assertInstanceOf(RichText::class, $object->setColumnSpacing(-1));
- $this->assertEquals($value, $object->getColumnSpacing());
+ self::assertInstanceOf(RichText::class, $object->setColumnSpacing($value));
+ self::assertEquals($value, $object->getColumnSpacing());
+ self::assertInstanceOf(RichText::class, $object->setColumnSpacing(-1));
+ self::assertEquals($value, $object->getColumnSpacing());
}
public function testColumnsException(): void
@@ -115,86 +114,86 @@ public function testParagraphs(): void
new Paragraph(),
];
- $this->assertInstanceOf(RichText::class, $object->setParagraphs($array));
- $this->assertCount(3, $object->getParagraphs());
- $this->assertEquals(2, $object->getActiveParagraphIndex());
+ self::assertInstanceOf(RichText::class, $object->setParagraphs($array));
+ self::assertCount(3, $object->getParagraphs());
+ self::assertEquals(2, $object->getActiveParagraphIndex());
}
public function testText(): void
{
$object = new RichText();
- $this->assertInstanceOf(RichText::class, $object->addText());
- $this->assertCount(1, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf(RichText::class, $object->addText(new TextElement()));
- $this->assertCount(2, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf(TextElement::class, $object->createText());
- $this->assertCount(3, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf(TextElement::class, $object->createText('ALPHA'));
- $this->assertCount(4, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf(BreakElement::class, $object->createBreak());
- $this->assertCount(5, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf(Run::class, $object->createTextRun());
- $this->assertCount(6, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf(Run::class, $object->createTextRun('BETA'));
- $this->assertCount(7, $object->getActiveParagraph()->getRichTextElements());
- $this->assertEquals('ALPHA' . "\r\n" . 'BETA', $object->getPlainText());
- $this->assertEquals('ALPHA' . "\r\n" . 'BETA', (string) $object);
+ self::assertInstanceOf(RichText::class, $object->addText());
+ self::assertCount(1, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf(RichText::class, $object->addText(new TextElement()));
+ self::assertCount(2, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf(TextElement::class, $object->createText());
+ self::assertCount(3, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf(TextElement::class, $object->createText('ALPHA'));
+ self::assertCount(4, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf(BreakElement::class, $object->createBreak());
+ self::assertCount(5, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf(Run::class, $object->createTextRun());
+ self::assertCount(6, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf(Run::class, $object->createTextRun('BETA'));
+ self::assertCount(7, $object->getActiveParagraph()->getRichTextElements());
+ self::assertEquals('ALPHA' . "\r\n" . 'BETA', $object->getPlainText());
+ self::assertEquals('ALPHA' . "\r\n" . 'BETA', (string) $object);
}
public function testGetSetAutoFit(): void
{
$object = new RichText();
- $this->assertInstanceOf(RichText::class, $object->setAutoFit());
- $this->assertEquals(RichText::AUTOFIT_DEFAULT, $object->getAutoFit());
+ self::assertInstanceOf(RichText::class, $object->setAutoFit());
+ self::assertEquals(RichText::AUTOFIT_DEFAULT, $object->getAutoFit());
- $this->assertInstanceOf(RichText::class, $object->setAutoFit(RichText::AUTOFIT_NORMAL));
- $this->assertEquals(RichText::AUTOFIT_NORMAL, $object->getAutoFit());
+ self::assertInstanceOf(RichText::class, $object->setAutoFit(RichText::AUTOFIT_NORMAL));
+ self::assertEquals(RichText::AUTOFIT_NORMAL, $object->getAutoFit());
}
public function testGetSetHAutoShrink(): void
{
$object = new RichText();
- $this->assertInstanceOf(RichText::class, $object->setAutoShrinkHorizontal());
- $this->assertNull($object->hasAutoShrinkHorizontal());
+ self::assertInstanceOf(RichText::class, $object->setAutoShrinkHorizontal());
+ self::assertNull($object->hasAutoShrinkHorizontal());
- $this->assertInstanceOf(RichText::class, $object->setAutoShrinkHorizontal(null));
- $this->assertNull($object->hasAutoShrinkHorizontal());
+ self::assertInstanceOf(RichText::class, $object->setAutoShrinkHorizontal(null));
+ self::assertNull($object->hasAutoShrinkHorizontal());
- $this->assertInstanceOf(RichText::class, $object->setAutoShrinkHorizontal(true));
- $this->assertTrue($object->hasAutoShrinkHorizontal());
+ self::assertInstanceOf(RichText::class, $object->setAutoShrinkHorizontal(true));
+ self::assertTrue($object->hasAutoShrinkHorizontal());
- $this->assertInstanceOf(RichText::class, $object->setAutoShrinkHorizontal(false));
- $this->assertFalse($object->hasAutoShrinkHorizontal());
+ self::assertInstanceOf(RichText::class, $object->setAutoShrinkHorizontal(false));
+ self::assertFalse($object->hasAutoShrinkHorizontal());
}
public function testGetSetVAutoShrink(): void
{
$object = new RichText();
- $this->assertInstanceOf(RichText::class, $object->setAutoShrinkVertical());
- $this->assertNull($object->hasAutoShrinkVertical());
+ self::assertInstanceOf(RichText::class, $object->setAutoShrinkVertical());
+ self::assertNull($object->hasAutoShrinkVertical());
- $this->assertInstanceOf(RichText::class, $object->setAutoShrinkVertical(null));
- $this->assertNull($object->hasAutoShrinkVertical());
+ self::assertInstanceOf(RichText::class, $object->setAutoShrinkVertical(null));
+ self::assertNull($object->hasAutoShrinkVertical());
- $this->assertInstanceOf(RichText::class, $object->setAutoShrinkVertical(true));
- $this->assertTrue($object->hasAutoShrinkVertical());
+ self::assertInstanceOf(RichText::class, $object->setAutoShrinkVertical(true));
+ self::assertTrue($object->hasAutoShrinkVertical());
- $this->assertInstanceOf(RichText::class, $object->setAutoShrinkVertical(false));
- $this->assertFalse($object->hasAutoShrinkVertical());
+ self::assertInstanceOf(RichText::class, $object->setAutoShrinkVertical(false));
+ self::assertFalse($object->hasAutoShrinkVertical());
}
public function testGetSetHOverflow(): void
{
$object = new RichText();
- $this->assertInstanceOf(RichText::class, $object->setHorizontalOverflow());
- $this->assertEquals(RichText::OVERFLOW_OVERFLOW, $object->getHorizontalOverflow());
+ self::assertInstanceOf(RichText::class, $object->setHorizontalOverflow());
+ self::assertEquals(RichText::OVERFLOW_OVERFLOW, $object->getHorizontalOverflow());
- $this->assertInstanceOf(RichText::class, $object->setHorizontalOverflow(RichText::OVERFLOW_CLIP));
- $this->assertEquals(RichText::OVERFLOW_CLIP, $object->getHorizontalOverflow());
+ self::assertInstanceOf(RichText::class, $object->setHorizontalOverflow(RichText::OVERFLOW_CLIP));
+ self::assertEquals(RichText::OVERFLOW_CLIP, $object->getHorizontalOverflow());
}
public function testGetSetInset(): void
@@ -202,75 +201,75 @@ public function testGetSetInset(): void
$object = new RichText();
// Default
- $this->assertInstanceOf(RichText::class, $object->setInsetBottom());
- $this->assertEquals(4.8, $object->getInsetBottom());
- $this->assertInstanceOf(RichText::class, $object->setInsetLeft());
- $this->assertEquals(9.6, $object->getInsetLeft());
- $this->assertInstanceOf(RichText::class, $object->setInsetRight());
- $this->assertEquals(9.6, $object->getInsetRight());
- $this->assertInstanceOf(RichText::class, $object->setInsetTop());
- $this->assertEquals(4.8, $object->getInsetTop());
+ self::assertInstanceOf(RichText::class, $object->setInsetBottom());
+ self::assertEquals(4.8, $object->getInsetBottom());
+ self::assertInstanceOf(RichText::class, $object->setInsetLeft());
+ self::assertEquals(9.6, $object->getInsetLeft());
+ self::assertInstanceOf(RichText::class, $object->setInsetRight());
+ self::assertEquals(9.6, $object->getInsetRight());
+ self::assertInstanceOf(RichText::class, $object->setInsetTop());
+ self::assertEquals(4.8, $object->getInsetTop());
// Value
$value = mt_rand(1, 100);
- $this->assertInstanceOf(RichText::class, $object->setInsetBottom($value));
- $this->assertEquals($value, $object->getInsetBottom());
- $this->assertInstanceOf(RichText::class, $object->setInsetLeft($value));
- $this->assertEquals($value, $object->getInsetLeft());
- $this->assertInstanceOf(RichText::class, $object->setInsetRight($value));
- $this->assertEquals($value, $object->getInsetRight());
- $this->assertInstanceOf(RichText::class, $object->setInsetTop($value));
- $this->assertEquals($value, $object->getInsetTop());
+ self::assertInstanceOf(RichText::class, $object->setInsetBottom($value));
+ self::assertEquals($value, $object->getInsetBottom());
+ self::assertInstanceOf(RichText::class, $object->setInsetLeft($value));
+ self::assertEquals($value, $object->getInsetLeft());
+ self::assertInstanceOf(RichText::class, $object->setInsetRight($value));
+ self::assertEquals($value, $object->getInsetRight());
+ self::assertInstanceOf(RichText::class, $object->setInsetTop($value));
+ self::assertEquals($value, $object->getInsetTop());
}
public function testGetSetUpright(): void
{
$object = new RichText();
- $this->assertInstanceOf(RichText::class, $object->setUpright());
- $this->assertFalse($object->isUpright());
+ self::assertInstanceOf(RichText::class, $object->setUpright());
+ self::assertFalse($object->isUpright());
- $this->assertInstanceOf(RichText::class, $object->setUpright(true));
- $this->assertTrue($object->isUpright());
+ self::assertInstanceOf(RichText::class, $object->setUpright(true));
+ self::assertTrue($object->isUpright());
- $this->assertInstanceOf(RichText::class, $object->setUpright(false));
- $this->assertFalse($object->isUpright());
+ self::assertInstanceOf(RichText::class, $object->setUpright(false));
+ self::assertFalse($object->isUpright());
}
public function testGetSetVertical(): void
{
$object = new RichText();
- $this->assertInstanceOf(RichText::class, $object->setVertical());
- $this->assertFalse($object->isVertical());
+ self::assertInstanceOf(RichText::class, $object->setVertical());
+ self::assertFalse($object->isVertical());
- $this->assertInstanceOf(RichText::class, $object->setVertical(true));
- $this->assertTrue($object->isVertical());
+ self::assertInstanceOf(RichText::class, $object->setVertical(true));
+ self::assertTrue($object->isVertical());
- $this->assertInstanceOf(RichText::class, $object->setVertical(false));
- $this->assertFalse($object->isVertical());
+ self::assertInstanceOf(RichText::class, $object->setVertical(false));
+ self::assertFalse($object->isVertical());
}
public function testGetSetVOverflow(): void
{
$object = new RichText();
- $this->assertInstanceOf(RichText::class, $object->setVerticalOverflow());
- $this->assertEquals(RichText::OVERFLOW_OVERFLOW, $object->getVerticalOverflow());
+ self::assertInstanceOf(RichText::class, $object->setVerticalOverflow());
+ self::assertEquals(RichText::OVERFLOW_OVERFLOW, $object->getVerticalOverflow());
- $this->assertInstanceOf(RichText::class, $object->setVerticalOverflow(RichText::OVERFLOW_CLIP));
- $this->assertEquals(RichText::OVERFLOW_CLIP, $object->getVerticalOverflow());
+ self::assertInstanceOf(RichText::class, $object->setVerticalOverflow(RichText::OVERFLOW_CLIP));
+ self::assertEquals(RichText::OVERFLOW_CLIP, $object->getVerticalOverflow());
}
public function testGetSetWrap(): void
{
$object = new RichText();
- $this->assertInstanceOf(RichText::class, $object->setWrap());
- $this->assertEquals(RichText::WRAP_SQUARE, $object->getWrap());
+ self::assertInstanceOf(RichText::class, $object->setWrap());
+ self::assertEquals(RichText::WRAP_SQUARE, $object->getWrap());
- $this->assertInstanceOf(RichText::class, $object->setWrap(RichText::WRAP_NONE));
- $this->assertEquals(RichText::WRAP_NONE, $object->getWrap());
+ self::assertInstanceOf(RichText::class, $object->setWrap(RichText::WRAP_NONE));
+ self::assertEquals(RichText::WRAP_NONE, $object->getWrap());
}
public function testHashCode(): void
@@ -278,9 +277,9 @@ public function testHashCode(): void
$object = new RichText();
$hash = $object->getActiveParagraph()->getHashCode();
- $hash .= RichText::WRAP_SQUARE . RichText::AUTOFIT_DEFAULT . RichText::OVERFLOW_OVERFLOW . RichText::OVERFLOW_OVERFLOW . '00104.89.69.64.8';
+ $hash .= RichText::WRAP_SQUARE . RichText::AUTOFIT_DEFAULT . RichText::OVERFLOW_OVERFLOW . RichText::OVERFLOW_OVERFLOW . '00104.89.69.64.80';
$hash .= md5('00000' . $object->getFill()->getHashCode() . $object->getShadow()->getHashCode() . '' . get_parent_class($object));
$hash .= get_class($object);
- $this->assertEquals(md5($hash), $object->getHashCode());
+ self::assertEquals(md5($hash), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Table/CellTest.php b/tests/PhpPresentation/Tests/Shape/Table/CellTest.php
index 7f0ccc502a..c4e1ee8b6e 100644
--- a/tests/PhpPresentation/Tests/Shape/Table/CellTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Table/CellTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -41,30 +40,30 @@ class CellTest extends TestCase
public function testConstruct(): void
{
$object = new Cell();
- $this->assertEquals(0, $object->getActiveParagraphIndex());
- $this->assertCount(1, $object->getParagraphs());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Borders', $object->getBorders());
+ self::assertEquals(0, $object->getActiveParagraphIndex());
+ self::assertCount(1, $object->getParagraphs());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Borders', $object->getBorders());
}
public function testActiveParagraph(): void
{
$object = new Cell();
- $this->assertEquals(0, $object->getActiveParagraphIndex());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->createParagraph());
- $this->assertCount(2, $object->getParagraphs());
+ self::assertEquals(0, $object->getActiveParagraphIndex());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->createParagraph());
+ self::assertCount(2, $object->getParagraphs());
$value = mt_rand(0, 1);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->setActiveParagraph($value));
- $this->assertEquals($value, $object->getActiveParagraphIndex());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->getActiveParagraph());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->getParagraph());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->setActiveParagraph($value));
+ self::assertEquals($value, $object->getActiveParagraphIndex());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->getActiveParagraph());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->getParagraph());
$value = mt_rand(0, 1);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->getParagraph($value));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->getParagraph($value));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setParagraphs([]));
- $this->assertCount(0, $object->getParagraphs());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->createParagraph());
- $this->assertCount(1, $object->getParagraphs());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setParagraphs([]));
+ self::assertCount(0, $object->getParagraphs());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->createParagraph());
+ self::assertCount(1, $object->getParagraphs());
}
public function testActiveParagraphException(): void
@@ -93,28 +92,28 @@ public function testSetGetHashIndex(): void
$object = new Cell();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
public function testText(): void
{
$object = new Cell();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->addText());
- $this->assertCount(1, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->addText(new TextElement()));
- $this->assertCount(2, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->createText());
- $this->assertCount(3, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->createText('ALPHA'));
- $this->assertCount(4, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->createBreak());
- $this->assertCount(5, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun());
- $this->assertCount(6, $object->getActiveParagraph()->getRichTextElements());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun('BETA'));
- $this->assertCount(7, $object->getActiveParagraph()->getRichTextElements());
- $this->assertEquals('ALPHA' . "\r\n" . 'BETA', $object->getPlainText());
- $this->assertEquals('ALPHA' . "\r\n" . 'BETA', (string) $object);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->addText());
+ self::assertCount(1, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->addText(new TextElement()));
+ self::assertCount(2, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->createText());
+ self::assertCount(3, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->createText('ALPHA'));
+ self::assertCount(4, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->createBreak());
+ self::assertCount(5, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun());
+ self::assertCount(6, $object->getActiveParagraph()->getRichTextElements());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun('BETA'));
+ self::assertCount(7, $object->getActiveParagraph()->getRichTextElements());
+ self::assertEquals('ALPHA' . "\r\n" . 'BETA', $object->getPlainText());
+ self::assertEquals('ALPHA' . "\r\n" . 'BETA', (string) $object);
}
public function testParagraphs(): void
@@ -127,60 +126,60 @@ public function testParagraphs(): void
new Paragraph(),
];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setParagraphs($array));
- $this->assertCount(3, $object->getParagraphs());
- $this->assertEquals(2, $object->getActiveParagraphIndex());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setParagraphs($array));
+ self::assertCount(3, $object->getParagraphs());
+ self::assertEquals(2, $object->getActiveParagraphIndex());
}
public function testGetSetBorders(): void
{
$object = new Cell();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setBorders(new Borders()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Borders', $object->getBorders());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setBorders(new Borders()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Borders', $object->getBorders());
}
public function testGetSetColspan(): void
{
$object = new Cell();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setColSpan());
- $this->assertEquals(0, $object->getColSpan());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setColSpan());
+ self::assertEquals(0, $object->getColSpan());
$value = mt_rand(1, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setColSpan($value));
- $this->assertEquals($value, $object->getColSpan());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setColSpan($value));
+ self::assertEquals($value, $object->getColSpan());
}
public function testGetSetFill(): void
{
$object = new Cell();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setFill(new Fill()));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setFill(new Fill()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->getFill());
}
public function testGetSetRowspan(): void
{
$object = new Cell();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setRowSpan());
- $this->assertEquals(0, $object->getRowSpan());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setRowSpan());
+ self::assertEquals(0, $object->getRowSpan());
$value = mt_rand(1, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setRowSpan($value));
- $this->assertEquals($value, $object->getRowSpan());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setRowSpan($value));
+ self::assertEquals($value, $object->getRowSpan());
}
public function testGetSetWidth(): void
{
$object = new Cell();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setWidth());
- $this->assertEquals(0, $object->getWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setWidth());
+ self::assertEquals(0, $object->getWidth());
$value = mt_rand(1, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setWidth($value));
- $this->assertEquals($value, $object->getWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Cell', $object->setWidth($value));
+ self::assertEquals($value, $object->getWidth());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/Table/RowTest.php b/tests/PhpPresentation/Tests/Shape/Table/RowTest.php
index 2e8ed0595e..26597a5faf 100644
--- a/tests/PhpPresentation/Tests/Shape/Table/RowTest.php
+++ b/tests/PhpPresentation/Tests/Shape/Table/RowTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -39,20 +38,20 @@ class RowTest extends TestCase
public function testConstruct(): void
{
$object = new Row();
- $this->assertCount(1, $object->getCells());
- $this->assertInstanceOf(Fill::class, $object->getFill());
+ self::assertCount(1, $object->getCells());
+ self::assertInstanceOf(Fill::class, $object->getFill());
$value = mt_rand(1, 100);
$object = new Row($value);
- $this->assertCount($value, $object->getCells());
- $this->assertInstanceOf(Fill::class, $object->getFill());
+ self::assertCount($value, $object->getCells());
+ self::assertInstanceOf(Fill::class, $object->getFill());
}
public function testGetCell(): void
{
$object = new Row();
- $this->assertInstanceOf(Cell::class, $object->getCell(0));
+ self::assertInstanceOf(Cell::class, $object->getCell(0));
}
public function testGetCellException(): void
@@ -68,7 +67,7 @@ public function testNextCell(): void
{
$object = new Row(2);
- $this->assertInstanceOf(Cell::class, $object->nextCell());
+ self::assertInstanceOf(Cell::class, $object->nextCell());
}
public function testNextCellException(): void
@@ -89,26 +88,26 @@ public function testSetGetHashIndex(): void
$object = new Row();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
public function testGetSetFill(): void
{
$object = new Row();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Row', $object->setFill(new Fill()));
- $this->assertInstanceOf(Fill::class, $object->getFill());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Row', $object->setFill(new Fill()));
+ self::assertInstanceOf(Fill::class, $object->getFill());
}
public function testGetSetHeight(): void
{
$object = new Row();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Row', $object->setHeight());
- $this->assertEquals(0, $object->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Row', $object->setHeight());
+ self::assertEquals(0, $object->getHeight());
$value = mt_rand(1, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Row', $object->setHeight($value));
- $this->assertEquals($value, $object->getHeight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Row', $object->setHeight($value));
+ self::assertEquals($value, $object->getHeight());
}
}
diff --git a/tests/PhpPresentation/Tests/Shape/TableTest.php b/tests/PhpPresentation/Tests/Shape/TableTest.php
index 286b151e9c..524aa29a99 100644
--- a/tests/PhpPresentation/Tests/Shape/TableTest.php
+++ b/tests/PhpPresentation/Tests/Shape/TableTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,8 +34,8 @@ class TableTest extends TestCase
public function testConstruct(): void
{
$object = new Table();
- $this->assertEmpty($object->getRows());
- $this->assertFalse($object->isResizeProportional());
+ self::assertEmpty($object->getRows());
+ self::assertFalse($object->isResizeProportional());
}
public function testNumColums(): void
@@ -44,19 +43,19 @@ public function testNumColums(): void
$value = mt_rand(1, 100);
$object = new Table();
- $this->assertEquals(1, $object->getNumColumns());
- $this->assertInstanceOf(Table::class, $object->setNumColumns($value));
- $this->assertEquals($value, $object->getNumColumns());
+ self::assertEquals(1, $object->getNumColumns());
+ self::assertInstanceOf(Table::class, $object->setNumColumns($value));
+ self::assertEquals($value, $object->getNumColumns());
}
public function testRows(): void
{
$object = new Table();
- $this->assertInstanceOf(Row::class, $object->createRow());
- $this->assertCount(1, $object->getRows());
+ self::assertInstanceOf(Row::class, $object->createRow());
+ self::assertCount(1, $object->getRows());
- $this->assertInstanceOf(Row::class, $object->getRow(0));
+ self::assertInstanceOf(Row::class, $object->getRow(0));
}
public function testGetRowException(): void
@@ -71,9 +70,9 @@ public function testGetRowException(): void
public function testHashCode(): void
{
$object = new Table();
- $this->assertEquals(md5(get_class($object)), $object->getHashCode());
+ self::assertEquals(md5(get_class($object)), $object->getHashCode());
$row = $object->createRow();
- $this->assertEquals(md5($row->getHashCode() . get_class($object)), $object->getHashCode());
+ self::assertEquals(md5($row->getHashCode() . get_class($object)), $object->getHashCode());
}
}
diff --git a/tests/PhpPresentation/Tests/Slide/AbstractSlideTest.php b/tests/PhpPresentation/Tests/Slide/AbstractSlideTest.php
index 16fd597785..bb93cc7562 100644
--- a/tests/PhpPresentation/Tests/Slide/AbstractSlideTest.php
+++ b/tests/PhpPresentation/Tests/Slide/AbstractSlideTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +19,9 @@
namespace PhpOffice\PhpPresentation\Tests\Slide;
+use PhpOffice\PhpPresentation\Shape\Chart;
use PhpOffice\PhpPresentation\Shape\RichText;
+use PhpOffice\PhpPresentation\Shape\Table;
use PhpOffice\PhpPresentation\Slide\AbstractSlide;
use PHPUnit\Framework\TestCase;
@@ -37,17 +38,49 @@ public function testCollection(): void
$stub = $this->getMockForAbstractClass('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide');
$array = [];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $stub->setShapeCollection($array));
- $this->assertIsArray($stub->getShapeCollection());
- $this->assertCount(count($array), $stub->getShapeCollection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $stub->setShapeCollection($array));
+ self::assertIsArray($stub->getShapeCollection());
+ self::assertCount(count($array), $stub->getShapeCollection());
$array = [
new RichText(),
new RichText(),
new RichText(),
];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $stub->setShapeCollection($array));
- $this->assertIsArray($stub->getShapeCollection());
- $this->assertCount(count($array), $stub->getShapeCollection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $stub->setShapeCollection($array));
+ self::assertIsArray($stub->getShapeCollection());
+ self::assertCount(count($array), $stub->getShapeCollection());
+ }
+
+ public function testsearchShapes(): void
+ {
+ /** @var AbstractSlide $stub */
+ $stub = $this->getMockForAbstractClass('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide');
+
+ $array = [
+ (new RichText())->setName('AAA'),
+ (new Table())->setName('BBB'),
+ (new Chart())->setName('AAA'),
+ ];
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $stub->setShapeCollection($array));
+
+ // Search by Name
+ $result = $stub->searchShapes('AAA', null);
+ self::assertIsArray($result);
+ self::assertCount(2, $result);
+ self::assertInstanceOf(RichText::class, $result[0]);
+ self::assertInstanceOf(Chart::class, $result[1]);
+
+ // Search by Name && Type
+ $result = $stub->searchShapes('AAA', Chart::class);
+ self::assertIsArray($result);
+ self::assertCount(1, $result);
+ self::assertInstanceOf(Chart::class, $result[0]);
+
+ // Search by Type
+ $result = $stub->searchShapes(null, Table::class);
+ self::assertIsArray($result);
+ self::assertCount(1, $result);
+ self::assertInstanceOf(Table::class, $result[0]);
}
}
diff --git a/tests/PhpPresentation/Tests/Slide/AnimationTest.php b/tests/PhpPresentation/Tests/Slide/AnimationTest.php
index 84d48cee0a..6056202cc2 100644
--- a/tests/PhpPresentation/Tests/Slide/AnimationTest.php
+++ b/tests/PhpPresentation/Tests/Slide/AnimationTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -38,16 +37,16 @@ public function testShape(): void
$object = new Animation();
- $this->assertIsArray($object->getShapeCollection());
- $this->assertCount(0, $object->getShapeCollection());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Animation', $object->addShape($oStub));
- $this->assertIsArray($object->getShapeCollection());
- $this->assertCount(1, $object->getShapeCollection());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Animation', $object->setShapeCollection());
- $this->assertIsArray($object->getShapeCollection());
- $this->assertCount(0, $object->getShapeCollection());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Animation', $object->setShapeCollection([$oStub]));
- $this->assertIsArray($object->getShapeCollection());
- $this->assertCount(1, $object->getShapeCollection());
+ self::assertIsArray($object->getShapeCollection());
+ self::assertCount(0, $object->getShapeCollection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Animation', $object->addShape($oStub));
+ self::assertIsArray($object->getShapeCollection());
+ self::assertCount(1, $object->getShapeCollection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Animation', $object->setShapeCollection());
+ self::assertIsArray($object->getShapeCollection());
+ self::assertCount(0, $object->getShapeCollection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Animation', $object->setShapeCollection([$oStub]));
+ self::assertIsArray($object->getShapeCollection());
+ self::assertCount(1, $object->getShapeCollection());
}
}
diff --git a/tests/PhpPresentation/Tests/Slide/Background/ColorTest.php b/tests/PhpPresentation/Tests/Slide/Background/ColorTest.php
index 02946f7a86..a26e10d50b 100644
--- a/tests/PhpPresentation/Tests/Slide/Background/ColorTest.php
+++ b/tests/PhpPresentation/Tests/Slide/Background/ColorTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,10 +32,10 @@ public function testColor(): void
$oStyleColor = new StyleColor();
$oStyleColor->setRGB('123456');
- $this->assertNull($object->getColor());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Color', $object->setColor($oStyleColor));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Color', $object->setColor());
- $this->assertNull($object->getColor());
+ self::assertNull($object->getColor());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Color', $object->setColor($oStyleColor));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Color', $object->setColor());
+ self::assertNull($object->getColor());
}
}
diff --git a/tests/PhpPresentation/Tests/Slide/Background/ImageTest.php b/tests/PhpPresentation/Tests/Slide/Background/ImageTest.php
index be9251773b..a4efc0525c 100644
--- a/tests/PhpPresentation/Tests/Slide/Background/ImageTest.php
+++ b/tests/PhpPresentation/Tests/Slide/Background/ImageTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,22 +32,22 @@ public function testColor(): void
$imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
$numSlide = (string) mt_rand(1, 100);
- $this->assertNull($object->getPath());
- $this->assertEmpty($object->getFilename());
- $this->assertEmpty($object->getExtension());
- $this->assertEquals('background_' . $numSlide . '.', $object->getIndexedFilename($numSlide));
-
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Image', $object->setPath($imagePath));
- $this->assertEquals($imagePath, $object->getPath());
- $this->assertEquals('PhpPresentationLogo.png', $object->getFilename());
- $this->assertEquals('png', $object->getExtension());
- $this->assertEquals('background_' . $numSlide . '.png', $object->getIndexedFilename($numSlide));
-
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Image', $object->setPath('', false));
- $this->assertEquals('', $object->getPath());
- $this->assertEmpty($object->getFilename());
- $this->assertEmpty($object->getExtension());
- $this->assertEquals('background_' . $numSlide . '.', $object->getIndexedFilename($numSlide));
+ self::assertNull($object->getPath());
+ self::assertEmpty($object->getFilename());
+ self::assertEmpty($object->getExtension());
+ self::assertEquals('background_' . $numSlide . '.', $object->getIndexedFilename($numSlide));
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Image', $object->setPath($imagePath));
+ self::assertEquals($imagePath, $object->getPath());
+ self::assertEquals('PhpPresentationLogo.png', $object->getFilename());
+ self::assertEquals('png', $object->getExtension());
+ self::assertEquals('background_' . $numSlide . '.png', $object->getIndexedFilename($numSlide));
+
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Image', $object->setPath('', false));
+ self::assertEquals('', $object->getPath());
+ self::assertEmpty($object->getFilename());
+ self::assertEmpty($object->getExtension());
+ self::assertEquals('background_' . $numSlide . '.', $object->getIndexedFilename($numSlide));
}
public function testPathException(): void
diff --git a/tests/PhpPresentation/Tests/Slide/Background/SchemeColorTest.php b/tests/PhpPresentation/Tests/Slide/Background/SchemeColorTest.php
index cdf5142ff1..c1cb4890cf 100644
--- a/tests/PhpPresentation/Tests/Slide/Background/SchemeColorTest.php
+++ b/tests/PhpPresentation/Tests/Slide/Background/SchemeColorTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -32,12 +31,12 @@ public function testBasic(): void
$object = new SchemeColor();
- $this->assertNull($object->getSchemeColor());
+ self::assertNull($object->getSchemeColor());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\SchemeColor', $object->setSchemeColor($oStyle));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\SchemeColor', $object->getSchemeColor());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\SchemeColor', $object->setSchemeColor($oStyle));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\SchemeColor', $object->getSchemeColor());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\SchemeColor', $object->setSchemeColor());
- $this->assertNull($object->getSchemeColor());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\SchemeColor', $object->setSchemeColor());
+ self::assertNull($object->getSchemeColor());
}
}
diff --git a/tests/PhpPresentation/Tests/Slide/IteratorTest.php b/tests/PhpPresentation/Tests/Slide/IteratorTest.php
index 480e874d4d..5ab9666961 100644
--- a/tests/PhpPresentation/Tests/Slide/IteratorTest.php
+++ b/tests/PhpPresentation/Tests/Slide/IteratorTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -39,15 +38,15 @@ public function testMethod(): void
$object = new Iterator($oPhpPresentation);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
- $this->assertEquals(0, $object->key());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
+ self::assertEquals(0, $object->key());
$object->next();
- $this->assertEquals(1, $object->key());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
- $this->assertTrue($object->valid());
+ self::assertEquals(1, $object->key());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
+ self::assertTrue($object->valid());
$object->next();
- $this->assertFalse($object->valid());
+ self::assertFalse($object->valid());
$object->rewind();
- $this->assertEquals(0, $object->key());
+ self::assertEquals(0, $object->key());
}
}
diff --git a/tests/PhpPresentation/Tests/Slide/NoteTest.php b/tests/PhpPresentation/Tests/Slide/NoteTest.php
index 7b40555fb8..145b864a0b 100644
--- a/tests/PhpPresentation/Tests/Slide/NoteTest.php
+++ b/tests/PhpPresentation/Tests/Slide/NoteTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,48 +34,48 @@ class NoteTest extends TestCase
public function testParent(): void
{
$object = new Note();
- $this->assertNull($object->getParent());
+ self::assertNull($object->getParent());
$oPhpPresentation = new PhpPresentation();
$oSlide = $oPhpPresentation->createSlide();
$oSlide->setNote($object);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getParent());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getParent());
}
public function testExtent(): void
{
$object = new Note();
- $this->assertNotNull($object->getExtentX());
+ self::assertNotNull($object->getExtentX());
$object = new Note();
- $this->assertNotNull($object->getExtentY());
+ self::assertNotNull($object->getExtentY());
}
public function testHashCode(): void
{
$object = new Note();
- $this->assertIsString($object->getHashCode());
+ self::assertIsString($object->getHashCode());
}
public function testOffset(): void
{
$object = new Note();
- $this->assertNotNull($object->getOffsetX());
+ self::assertNotNull($object->getOffsetX());
$object = new Note();
- $this->assertNotNull($object->getOffsetY());
+ self::assertNotNull($object->getOffsetY());
}
public function testShape(): void
{
$object = new Note();
- $this->assertEquals(0, $object->getShapeCollection()->count());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $object->createRichTextShape());
- $this->assertEquals(1, $object->getShapeCollection()->count());
+ self::assertCount(0, $object->getShapeCollection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $object->createRichTextShape());
+ self::assertCount(1, $object->getShapeCollection());
$oRichText = new RichText();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $object->addShape($oRichText));
- $this->assertEquals(2, $object->getShapeCollection()->count());
+ self::assertInstanceOf(Note::class, $object->addShape($oRichText));
+ self::assertCount(2, $object->getShapeCollection());
}
/**
@@ -86,8 +85,8 @@ public function testSetGetHashIndex(): void
{
$object = new Note();
$value = mt_rand(1, 100);
- $this->assertNull($object->getHashIndex());
+ self::assertNull($object->getHashIndex());
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
}
diff --git a/tests/PhpPresentation/Tests/Slide/SlideLayoutTest.php b/tests/PhpPresentation/Tests/Slide/SlideLayoutTest.php
index 2fc7f7df00..daea51b229 100644
--- a/tests/PhpPresentation/Tests/Slide/SlideLayoutTest.php
+++ b/tests/PhpPresentation/Tests/Slide/SlideLayoutTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,9 +36,9 @@ public function testBase(): void
$mockSlideMaster = $this->getMockForAbstractClass(SlideMaster::class);
$object = new SlideLayout($mockSlideMaster);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $object);
- $this->assertInstanceOf('\\ArrayObject', $object->getShapeCollection());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->colorMap);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $object);
+ self::assertIsArray($object->getShapeCollection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->colorMap);
}
public function testLayoutName(): void
@@ -48,13 +47,13 @@ public function testLayoutName(): void
$mockSlideMaster = $this->getMockForAbstractClass(SlideMaster::class);
// Expected
- $expectedLayoutName = 'Title' . rand(1, 100);
+ $expectedLayoutName = 'Title' . mt_rand(1, 100);
$object = new SlideLayout($mockSlideMaster);
- $this->assertNull($object->getLayoutName());
- $this->assertInstanceOf(SlideLayout::class, $object->setLayoutName($expectedLayoutName));
- $this->assertEquals($expectedLayoutName, $object->getLayoutName());
+ self::assertNull($object->getLayoutName());
+ self::assertInstanceOf(SlideLayout::class, $object->setLayoutName($expectedLayoutName));
+ self::assertEquals($expectedLayoutName, $object->getLayoutName());
}
public function testSlideMaster(): void
@@ -64,6 +63,6 @@ public function testSlideMaster(): void
$object = new SlideLayout($mockSlideMaster);
- $this->assertInstanceOf(SlideMaster::class, $object->getSlideMaster());
+ self::assertInstanceOf(SlideMaster::class, $object->getSlideMaster());
}
}
diff --git a/tests/PhpPresentation/Tests/Slide/SlideMasterTest.php b/tests/PhpPresentation/Tests/Slide/SlideMasterTest.php
index 4bda4aa516..b79cc1c31f 100644
--- a/tests/PhpPresentation/Tests/Slide/SlideMasterTest.php
+++ b/tests/PhpPresentation/Tests/Slide/SlideMasterTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,15 +36,15 @@ class SlideMasterTest extends TestCase
public function testBase(): void
{
$object = new SlideMaster();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $object);
- $this->assertNull($object->getParent());
- $this->assertInstanceOf('\\ArrayObject', $object->getShapeCollection());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->colorMap);
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $object);
+ self::assertNull($object->getParent());
+ self::assertIsArray($object->getShapeCollection());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->colorMap);
/** @var Color $background */
$background = $object->getBackground();
- $this->assertInstanceOf(Color::class, $background);
- $this->assertEquals('FFFFFF', $background->getColor()->getRGB());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->getTextStyles());
+ self::assertInstanceOf(Color::class, $background);
+ self::assertEquals('FFFFFF', $background->getColor()->getRGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->getTextStyles());
}
public function testLayout(): void
@@ -56,10 +55,10 @@ public function testLayout(): void
/** @var SlideLayout $mockSlideLayout */
$mockSlideLayout = $this->getMockForAbstractClass(SlideLayout::class, [$object]);
- $this->assertEmpty($object->getAllSlideLayouts());
- $this->assertInstanceOf(SlideLayout::class, $object->createSlideLayout());
- $this->assertInstanceOf(SlideLayout::class, $object->addSlideLayout($mockSlideLayout));
- $this->assertCount(2, $object->getAllSlideLayouts());
+ self::assertEmpty($object->getAllSlideLayouts());
+ self::assertInstanceOf(SlideLayout::class, $object->createSlideLayout());
+ self::assertInstanceOf(SlideLayout::class, $object->addSlideLayout($mockSlideLayout));
+ self::assertCount(2, $object->getAllSlideLayouts());
}
public function testSchemeColors(): void
@@ -76,14 +75,14 @@ public function testSchemeColors(): void
$object = new SlideMaster();
- $this->assertIsArray($object->getAllSchemeColors());
- $this->assertCount(12, $object->getAllSchemeColors());
+ self::assertIsArray($object->getAllSchemeColors());
+ self::assertCount(12, $object->getAllSchemeColors());
// Add idem value
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideMaster', $object->addSchemeColor($mockSchemeColorAccent1));
- $this->assertCount(12, $object->getAllSchemeColors());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideMaster', $object->addSchemeColor($mockSchemeColorAccent1));
+ self::assertCount(12, $object->getAllSchemeColors());
// Add new value
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideMaster', $object->addSchemeColor($mockSchemeColorNew));
- $this->assertCount(13, $object->getAllSchemeColors());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideMaster', $object->addSchemeColor($mockSchemeColorNew));
+ self::assertCount(13, $object->getAllSchemeColors());
}
public function testTextStyles(): void
@@ -94,8 +93,8 @@ public function testTextStyles(): void
$object = new SlideMaster();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->getTextStyles());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideMaster', $object->setTextStyles($mockTextStyle));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->getTextStyles());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->getTextStyles());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideMaster', $object->setTextStyles($mockTextStyle));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->getTextStyles());
}
}
diff --git a/tests/PhpPresentation/Tests/Slide/TransitionTest.php b/tests/PhpPresentation/Tests/Slide/TransitionTest.php
index 5afda6050a..836cc49372 100644
--- a/tests/PhpPresentation/Tests/Slide/TransitionTest.php
+++ b/tests/PhpPresentation/Tests/Slide/TransitionTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,52 +32,52 @@ class TransitionTest extends TestCase
public function testSpeed(): void
{
$object = new Transition();
- $this->assertNull($object->getSpeed());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setSpeed());
- $this->assertEquals(Transition::SPEED_MEDIUM, $object->getSpeed());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setSpeed(Transition::SPEED_FAST));
- $this->assertEquals(Transition::SPEED_FAST, $object->getSpeed());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setSpeed('notagoodvalue'));
- $this->assertNull($object->getSpeed());
+ self::assertNull($object->getSpeed());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setSpeed());
+ self::assertEquals(Transition::SPEED_MEDIUM, $object->getSpeed());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setSpeed(Transition::SPEED_FAST));
+ self::assertEquals(Transition::SPEED_FAST, $object->getSpeed());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setSpeed('notagoodvalue'));
+ self::assertNull($object->getSpeed());
}
public function testManualTrigger(): void
{
$object = new Transition();
- $this->assertFalse($object->hasManualTrigger());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger());
- $this->assertFalse($object->hasManualTrigger());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger(true));
- $this->assertTrue($object->hasManualTrigger());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger(false));
- $this->assertFalse($object->hasManualTrigger());
+ self::assertFalse($object->hasManualTrigger());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger());
+ self::assertFalse($object->hasManualTrigger());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger(true));
+ self::assertTrue($object->hasManualTrigger());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger(false));
+ self::assertFalse($object->hasManualTrigger());
}
public function testTimeTrigger(): void
{
$object = new Transition();
- $this->assertFalse($object->hasTimeTrigger());
- $this->assertNull($object->getAdvanceTimeTrigger());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger());
- $this->assertFalse($object->hasTimeTrigger());
- $this->assertNull($object->getAdvanceTimeTrigger());
+ self::assertFalse($object->hasTimeTrigger());
+ self::assertNull($object->getAdvanceTimeTrigger());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger());
+ self::assertFalse($object->hasTimeTrigger());
+ self::assertNull($object->getAdvanceTimeTrigger());
$value = mt_rand(1, 1000);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger(true, $value));
- $this->assertTrue($object->hasTimeTrigger());
- $this->assertEquals($value, $object->getAdvanceTimeTrigger());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger(true, $value));
+ self::assertTrue($object->hasTimeTrigger());
+ self::assertEquals($value, $object->getAdvanceTimeTrigger());
$value = mt_rand(1, 1000);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger(false, $value));
- $this->assertFalse($object->hasTimeTrigger());
- $this->assertNull($object->getAdvanceTimeTrigger());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger(false, $value));
+ self::assertFalse($object->hasTimeTrigger());
+ self::assertNull($object->getAdvanceTimeTrigger());
}
public function testTransitionType(): void
{
$object = new Transition();
- $this->assertNull($object->getTransitionType());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTransitionType());
- $this->assertNull($object->getTransitionType());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTransitionType(Transition::TRANSITION_RANDOM));
- $this->assertEquals(Transition::TRANSITION_RANDOM, $object->getTransitionType());
+ self::assertNull($object->getTransitionType());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTransitionType());
+ self::assertNull($object->getTransitionType());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTransitionType(Transition::TRANSITION_RANDOM));
+ self::assertEquals(Transition::TRANSITION_RANDOM, $object->getTransitionType());
}
}
diff --git a/tests/PhpPresentation/Tests/SlideTest.php b/tests/PhpPresentation/Tests/SlideTest.php
index eea3f731d9..99fff513c1 100644
--- a/tests/PhpPresentation/Tests/SlideTest.php
+++ b/tests/PhpPresentation/Tests/SlideTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,40 +36,40 @@ class SlideTest extends TestCase
public function testExtents(): void
{
$object = new Slide();
- $this->assertNotNull($object->getExtentX());
+ self::assertNotNull($object->getExtentX());
$object = new Slide();
- $this->assertNotNull($object->getExtentY());
+ self::assertNotNull($object->getExtentY());
}
public function testOffset(): void
{
$object = new Slide();
- $this->assertNotNull($object->getOffsetX());
+ self::assertNotNull($object->getOffsetX());
$object = new Slide();
- $this->assertNotNull($object->getOffsetY());
+ self::assertNotNull($object->getOffsetY());
}
public function testParent(): void
{
$object = new Slide();
- $this->assertNull($object->getParent());
+ self::assertNull($object->getParent());
$oPhpPresentation = new PhpPresentation();
$object = new Slide($oPhpPresentation);
- $this->assertInstanceOf(PhpPresentation::class, $object->getParent());
+ self::assertInstanceOf(PhpPresentation::class, $object->getParent());
}
public function testSlideMasterId(): void
{
$value = mt_rand(1, 100);
$object = new Slide();
- $this->assertEquals(1, $object->getSlideMasterId());
- $this->assertInstanceOf(Slide::class, $object->setSlideMasterId());
- $this->assertEquals(1, $object->getSlideMasterId());
- $this->assertInstanceOf(Slide::class, $object->setSlideMasterId($value));
- $this->assertEquals($value, $object->getSlideMasterId());
+ self::assertEquals(1, $object->getSlideMasterId());
+ self::assertInstanceOf(Slide::class, $object->setSlideMasterId());
+ self::assertEquals(1, $object->getSlideMasterId());
+ self::assertInstanceOf(Slide::class, $object->setSlideMasterId($value));
+ self::assertEquals($value, $object->getSlideMasterId());
}
public function testAnimations(): void
@@ -79,17 +78,17 @@ public function testAnimations(): void
$oStub = $this->getMockForAbstractClass(Animation::class);
$object = new Slide();
- $this->assertIsArray($object->getAnimations());
- $this->assertCount(0, $object->getAnimations());
- $this->assertInstanceOf(Slide::class, $object->addAnimation($oStub));
- $this->assertIsArray($object->getAnimations());
- $this->assertCount(1, $object->getAnimations());
- $this->assertInstanceOf(Slide::class, $object->setAnimations());
- $this->assertIsArray($object->getAnimations());
- $this->assertCount(0, $object->getAnimations());
- $this->assertInstanceOf(Slide::class, $object->setAnimations([$oStub]));
- $this->assertIsArray($object->getAnimations());
- $this->assertCount(1, $object->getAnimations());
+ self::assertIsArray($object->getAnimations());
+ self::assertCount(0, $object->getAnimations());
+ self::assertInstanceOf(Slide::class, $object->addAnimation($oStub));
+ self::assertIsArray($object->getAnimations());
+ self::assertCount(1, $object->getAnimations());
+ self::assertInstanceOf(Slide::class, $object->setAnimations());
+ self::assertIsArray($object->getAnimations());
+ self::assertCount(0, $object->getAnimations());
+ self::assertInstanceOf(Slide::class, $object->setAnimations([$oStub]));
+ self::assertIsArray($object->getAnimations());
+ self::assertCount(1, $object->getAnimations());
}
public function testBackground(): void
@@ -98,49 +97,49 @@ public function testBackground(): void
$oStub = $this->getMockForAbstractClass(AbstractBackground::class);
$object = new Slide();
- $this->assertNull($object->getBackground());
- $this->assertInstanceOf(Slide::class, $object->setBackground($oStub));
- $this->assertInstanceOf(AbstractBackground::class, $object->getBackground());
- $this->assertInstanceOf(Slide::class, $object->setBackground());
- $this->assertNull($object->getBackground());
+ self::assertNull($object->getBackground());
+ self::assertInstanceOf(Slide::class, $object->setBackground($oStub));
+ self::assertInstanceOf(AbstractBackground::class, $object->getBackground());
+ self::assertInstanceOf(Slide::class, $object->setBackground());
+ self::assertNull($object->getBackground());
}
public function testGroup(): void
{
$object = new Slide();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->createGroup());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->createGroup());
}
public function testName(): void
{
$object = new Slide();
- $this->assertNull($object->getName());
- $this->assertInstanceOf(Slide::class, $object->setName('AAAA'));
- $this->assertEquals('AAAA', $object->getName());
- $this->assertInstanceOf(Slide::class, $object->setName());
- $this->assertNull($object->getName());
+ self::assertNull($object->getName());
+ self::assertInstanceOf(Slide::class, $object->setName('AAAA'));
+ self::assertEquals('AAAA', $object->getName());
+ self::assertInstanceOf(Slide::class, $object->setName());
+ self::assertNull($object->getName());
}
public function testTransition(): void
{
$object = new Slide();
$oTransition = new Transition();
- $this->assertNull($object->getTransition());
- $this->assertInstanceOf(Slide::class, $object->setTransition());
- $this->assertNull($object->getTransition());
- $this->assertInstanceOf(Slide::class, $object->setTransition($oTransition));
- $this->assertInstanceOf(Transition::class, $object->getTransition());
- $this->assertInstanceOf(Slide::class, $object->setTransition(null));
- $this->assertNull($object->getTransition());
+ self::assertNull($object->getTransition());
+ self::assertInstanceOf(Slide::class, $object->setTransition());
+ self::assertNull($object->getTransition());
+ self::assertInstanceOf(Slide::class, $object->setTransition($oTransition));
+ self::assertInstanceOf(Transition::class, $object->getTransition());
+ self::assertInstanceOf(Slide::class, $object->setTransition(null));
+ self::assertNull($object->getTransition());
}
public function testVisible(): void
{
$object = new Slide();
- $this->assertTrue($object->isVisible());
- $this->assertInstanceOf(Slide::class, $object->setIsVisible(false));
- $this->assertFalse($object->isVisible());
- $this->assertInstanceOf(Slide::class, $object->setIsVisible());
- $this->assertTrue($object->isVisible());
+ self::assertTrue($object->isVisible());
+ self::assertInstanceOf(Slide::class, $object->setIsVisible(false));
+ self::assertFalse($object->isVisible());
+ self::assertInstanceOf(Slide::class, $object->setIsVisible());
+ self::assertTrue($object->isVisible());
}
}
diff --git a/tests/PhpPresentation/Tests/Style/AlignmentTest.php b/tests/PhpPresentation/Tests/Style/AlignmentTest.php
index 510811fb48..ca16511747 100644
--- a/tests/PhpPresentation/Tests/Style/AlignmentTest.php
+++ b/tests/PhpPresentation/Tests/Style/AlignmentTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,15 +36,15 @@ class AlignmentTest extends TestCase
public function testConstruct(): void
{
$object = new Alignment();
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $object->getHorizontal());
- $this->assertEquals(Alignment::VERTICAL_BASE, $object->getVertical());
- $this->assertEquals(Alignment::TEXT_DIRECTION_HORIZONTAL, $object->getTextDirection());
- $this->assertEquals(0, $object->getLevel());
- $this->assertEquals(0, $object->getIndent());
- $this->assertEquals(0, $object->getMarginLeft());
- $this->assertEquals(0, $object->getMarginRight());
- $this->assertEquals(0, $object->getMarginTop());
- $this->assertEquals(0, $object->getMarginBottom());
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $object->getHorizontal());
+ self::assertEquals(Alignment::VERTICAL_BASE, $object->getVertical());
+ self::assertEquals(Alignment::TEXT_DIRECTION_HORIZONTAL, $object->getTextDirection());
+ self::assertEquals(0, $object->getLevel());
+ self::assertEquals(0, $object->getIndent());
+ self::assertEquals(0, $object->getMarginLeft());
+ self::assertEquals(0, $object->getMarginRight());
+ self::assertEquals(0, $object->getMarginTop());
+ self::assertEquals(0, $object->getMarginBottom());
}
/**
@@ -54,10 +53,10 @@ public function testConstruct(): void
public function testSetGetHorizontal(): void
{
$object = new Alignment();
- $this->assertInstanceOf(Alignment::class, $object->setHorizontal(''));
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $object->getHorizontal());
- $this->assertInstanceOf(Alignment::class, $object->setHorizontal(Alignment::HORIZONTAL_GENERAL));
- $this->assertEquals(Alignment::HORIZONTAL_GENERAL, $object->getHorizontal());
+ self::assertInstanceOf(Alignment::class, $object->setHorizontal(''));
+ self::assertEquals(Alignment::HORIZONTAL_LEFT, $object->getHorizontal());
+ self::assertInstanceOf(Alignment::class, $object->setHorizontal(Alignment::HORIZONTAL_GENERAL));
+ self::assertEquals(Alignment::HORIZONTAL_GENERAL, $object->getHorizontal());
}
/**
@@ -66,12 +65,12 @@ public function testSetGetHorizontal(): void
public function testTextDirection(): void
{
$object = new Alignment();
- $this->assertInstanceOf(Alignment::class, $object->setTextDirection(''));
- $this->assertEquals(Alignment::TEXT_DIRECTION_HORIZONTAL, $object->getTextDirection());
- $this->assertInstanceOf(Alignment::class, $object->setTextDirection(Alignment::TEXT_DIRECTION_VERTICAL_90));
- $this->assertEquals(Alignment::TEXT_DIRECTION_VERTICAL_90, $object->getTextDirection());
- $this->assertInstanceOf(Alignment::class, $object->setTextDirection());
- $this->assertEquals(Alignment::TEXT_DIRECTION_HORIZONTAL, $object->getTextDirection());
+ self::assertInstanceOf(Alignment::class, $object->setTextDirection(''));
+ self::assertEquals(Alignment::TEXT_DIRECTION_HORIZONTAL, $object->getTextDirection());
+ self::assertInstanceOf(Alignment::class, $object->setTextDirection(Alignment::TEXT_DIRECTION_VERTICAL_90));
+ self::assertEquals(Alignment::TEXT_DIRECTION_VERTICAL_90, $object->getTextDirection());
+ self::assertInstanceOf(Alignment::class, $object->setTextDirection());
+ self::assertEquals(Alignment::TEXT_DIRECTION_HORIZONTAL, $object->getTextDirection());
}
/**
@@ -80,10 +79,10 @@ public function testTextDirection(): void
public function testSetGetVertical(): void
{
$object = new Alignment();
- $this->assertInstanceOf(Alignment::class, $object->setVertical(''));
- $this->assertEquals(Alignment::VERTICAL_BASE, $object->getVertical());
- $this->assertInstanceOf(Alignment::class, $object->setVertical(Alignment::VERTICAL_AUTO));
- $this->assertEquals(Alignment::VERTICAL_AUTO, $object->getVertical());
+ self::assertInstanceOf(Alignment::class, $object->setVertical(''));
+ self::assertEquals(Alignment::VERTICAL_BASE, $object->getVertical());
+ self::assertInstanceOf(Alignment::class, $object->setVertical(Alignment::VERTICAL_AUTO));
+ self::assertEquals(Alignment::VERTICAL_AUTO, $object->getVertical());
}
/**
@@ -105,8 +104,8 @@ public function testSetGetLevel(): void
{
$object = new Alignment();
$value = mt_rand(1, 8);
- $this->assertInstanceOf(Alignment::class, $object->setLevel($value));
- $this->assertEquals($value, $object->getLevel());
+ self::assertInstanceOf(Alignment::class, $object->setLevel($value));
+ self::assertEquals($value, $object->getLevel());
}
/**
@@ -118,19 +117,19 @@ public function testSetGetIndent(): void
// != Alignment::HORIZONTAL_GENERAL
$object->setHorizontal(Alignment::HORIZONTAL_CENTER);
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Alignment::class, $object->setIndent($value));
- $this->assertEquals(0, $object->getIndent());
+ self::assertInstanceOf(Alignment::class, $object->setIndent($value));
+ self::assertEquals(0, $object->getIndent());
$value = mt_rand(-100, 0);
- $this->assertInstanceOf(Alignment::class, $object->setIndent($value));
- $this->assertEquals($value, $object->getIndent());
+ self::assertInstanceOf(Alignment::class, $object->setIndent($value));
+ self::assertEquals($value, $object->getIndent());
$object->setHorizontal(Alignment::HORIZONTAL_GENERAL);
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Alignment::class, $object->setIndent($value));
- $this->assertEquals($value, $object->getIndent());
+ self::assertInstanceOf(Alignment::class, $object->setIndent($value));
+ self::assertEquals($value, $object->getIndent());
$value = mt_rand(-100, 0);
- $this->assertInstanceOf(Alignment::class, $object->setIndent($value));
- $this->assertEquals($value, $object->getIndent());
+ self::assertInstanceOf(Alignment::class, $object->setIndent($value));
+ self::assertEquals($value, $object->getIndent());
}
/**
@@ -140,10 +139,10 @@ public function testSetGetMarginBottom(): void
{
$object = new Alignment();
$value = mt_rand(0, 100);
- $this->assertInstanceOf(Alignment::class, $object->setMarginBottom($value));
- $this->assertEquals($value, $object->getMarginBottom());
- $this->assertInstanceOf(Alignment::class, $object->setMarginBottom());
- $this->assertEquals(0, $object->getMarginBottom());
+ self::assertInstanceOf(Alignment::class, $object->setMarginBottom($value));
+ self::assertEquals($value, $object->getMarginBottom());
+ self::assertInstanceOf(Alignment::class, $object->setMarginBottom());
+ self::assertEquals(0, $object->getMarginBottom());
}
/**
@@ -155,19 +154,19 @@ public function testSetGetMarginLeft(): void
// != Alignment::HORIZONTAL_GENERAL
$object->setHorizontal(Alignment::HORIZONTAL_CENTER);
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Alignment::class, $object->setMarginLeft($value));
- $this->assertEquals(0, $object->getMarginLeft());
+ self::assertInstanceOf(Alignment::class, $object->setMarginLeft($value));
+ self::assertEquals(0, $object->getMarginLeft());
$value = mt_rand(-100, 0);
- $this->assertInstanceOf(Alignment::class, $object->setMarginLeft($value));
- $this->assertEquals($value, $object->getMarginLeft());
+ self::assertInstanceOf(Alignment::class, $object->setMarginLeft($value));
+ self::assertEquals($value, $object->getMarginLeft());
$object->setHorizontal(Alignment::HORIZONTAL_GENERAL);
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Alignment::class, $object->setMarginLeft($value));
- $this->assertEquals($value, $object->getMarginLeft());
+ self::assertInstanceOf(Alignment::class, $object->setMarginLeft($value));
+ self::assertEquals($value, $object->getMarginLeft());
$value = mt_rand(-100, 0);
- $this->assertInstanceOf(Alignment::class, $object->setMarginLeft($value));
- $this->assertEquals($value, $object->getMarginLeft());
+ self::assertInstanceOf(Alignment::class, $object->setMarginLeft($value));
+ self::assertEquals($value, $object->getMarginLeft());
}
/**
@@ -179,19 +178,19 @@ public function testSetGetMarginRight(): void
// != Alignment::HORIZONTAL_GENERAL
$object->setHorizontal(Alignment::HORIZONTAL_CENTER);
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Alignment::class, $object->setMarginRight($value));
- $this->assertEquals(0, $object->getMarginRight());
+ self::assertInstanceOf(Alignment::class, $object->setMarginRight($value));
+ self::assertEquals(0, $object->getMarginRight());
$value = mt_rand(-100, 0);
- $this->assertInstanceOf(Alignment::class, $object->setMarginRight($value));
- $this->assertEquals($value, $object->getMarginRight());
+ self::assertInstanceOf(Alignment::class, $object->setMarginRight($value));
+ self::assertEquals($value, $object->getMarginRight());
$object->setHorizontal(Alignment::HORIZONTAL_GENERAL);
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Alignment::class, $object->setMarginRight($value));
- $this->assertEquals($value, $object->getMarginRight());
+ self::assertInstanceOf(Alignment::class, $object->setMarginRight($value));
+ self::assertEquals($value, $object->getMarginRight());
$value = mt_rand(-100, 0);
- $this->assertInstanceOf(Alignment::class, $object->setMarginRight($value));
- $this->assertEquals($value, $object->getMarginRight());
+ self::assertInstanceOf(Alignment::class, $object->setMarginRight($value));
+ self::assertEquals($value, $object->getMarginRight());
}
/**
@@ -201,22 +200,22 @@ public function testSetGetMarginTop(): void
{
$object = new Alignment();
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Alignment::class, $object->setMarginTop($value));
- $this->assertEquals($value, $object->getMarginTop());
- $this->assertInstanceOf(Alignment::class, $object->setMarginTop());
- $this->assertEquals(0, $object->getMarginTop());
+ self::assertInstanceOf(Alignment::class, $object->setMarginTop($value));
+ self::assertEquals($value, $object->getMarginTop());
+ self::assertInstanceOf(Alignment::class, $object->setMarginTop());
+ self::assertEquals(0, $object->getMarginTop());
}
public function testRTL(): void
{
$object = new Alignment();
- $this->assertFalse($object->isRTL());
- $this->assertInstanceOf(Alignment::class, $object->setIsRTL(true));
- $this->assertTrue($object->isRTL());
- $this->assertInstanceOf(Alignment::class, $object->setIsRTL(false));
- $this->assertFalse($object->isRTL());
- $this->assertInstanceOf(Alignment::class, $object->setIsRTL());
- $this->assertFalse($object->isRTL());
+ self::assertFalse($object->isRTL());
+ self::assertInstanceOf(Alignment::class, $object->setIsRTL(true));
+ self::assertTrue($object->isRTL());
+ self::assertInstanceOf(Alignment::class, $object->setIsRTL(false));
+ self::assertFalse($object->isRTL());
+ self::assertInstanceOf(Alignment::class, $object->setIsRTL());
+ self::assertFalse($object->isRTL());
}
/**
@@ -224,10 +223,10 @@ public function testRTL(): void
*/
public function testSetGetHashIndex(): void
{
- $value = rand(1, 100);
+ $value = mt_rand(1, 100);
$object = new Alignment();
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
}
diff --git a/tests/PhpPresentation/Tests/Style/BorderTest.php b/tests/PhpPresentation/Tests/Style/BorderTest.php
index 6084fa10c7..279f0b345f 100644
--- a/tests/PhpPresentation/Tests/Style/BorderTest.php
+++ b/tests/PhpPresentation/Tests/Style/BorderTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,11 +36,11 @@ class BorderTest extends TestCase
public function testConstruct(): void
{
$object = new Border();
- $this->assertEquals(1, $object->getLineWidth());
- $this->assertEquals(Border::LINE_SINGLE, $object->getLineStyle());
- $this->assertEquals(Border::DASH_SOLID, $object->getDashStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
- $this->assertEquals('FF000000', $object->getColor()->getARGB());
+ self::assertEquals(1, $object->getLineWidth());
+ self::assertEquals(Border::LINE_SINGLE, $object->getLineStyle());
+ self::assertEquals(Border::DASH_SOLID, $object->getDashStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
+ self::assertEquals('FF000000', $object->getColor()->getARGB());
}
/**
@@ -50,11 +49,11 @@ public function testConstruct(): void
public function testSetGetColor(): void
{
$object = new Border();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setColor());
- $this->assertNull($object->getColor());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setColor(new Color(COLOR::COLOR_BLUE)));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
- $this->assertEquals('FF0000FF', $object->getColor()->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setColor());
+ self::assertNull($object->getColor());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setColor(new Color(Color::COLOR_BLUE)));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
+ self::assertEquals('FF0000FF', $object->getColor()->getARGB());
}
/**
@@ -63,12 +62,12 @@ public function testSetGetColor(): void
public function testSetGetDashStyle(): void
{
$object = new Border();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setDashStyle());
- $this->assertEquals(Border::DASH_SOLID, $object->getDashStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setDashStyle(''));
- $this->assertEquals(Border::DASH_SOLID, $object->getDashStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setDashStyle(BORDER::DASH_DASH));
- $this->assertEquals(Border::DASH_DASH, $object->getDashStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setDashStyle());
+ self::assertEquals(Border::DASH_SOLID, $object->getDashStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setDashStyle(''));
+ self::assertEquals(Border::DASH_SOLID, $object->getDashStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setDashStyle(Border::DASH_DASH));
+ self::assertEquals(Border::DASH_DASH, $object->getDashStyle());
}
/**
@@ -79,7 +78,7 @@ public function testSetGetHashIndex(): void
$object = new Border();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
/**
@@ -88,12 +87,12 @@ public function testSetGetHashIndex(): void
public function testSetGetLineStyle(): void
{
$object = new Border();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineStyle());
- $this->assertEquals(Border::LINE_SINGLE, $object->getLineStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineStyle(''));
- $this->assertEquals(Border::LINE_SINGLE, $object->getLineStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineStyle(BORDER::LINE_DOUBLE));
- $this->assertEquals(Border::LINE_DOUBLE, $object->getLineStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineStyle());
+ self::assertEquals(Border::LINE_SINGLE, $object->getLineStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineStyle(''));
+ self::assertEquals(Border::LINE_SINGLE, $object->getLineStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineStyle(Border::LINE_DOUBLE));
+ self::assertEquals(Border::LINE_DOUBLE, $object->getLineStyle());
}
/**
@@ -102,10 +101,10 @@ public function testSetGetLineStyle(): void
public function testSetGetLineWidth(): void
{
$object = new Border();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineWidth());
- $this->assertEquals(1, $object->getLineWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineWidth());
+ self::assertEquals(1, $object->getLineWidth());
$value = mt_rand(1, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineWidth($value));
- $this->assertEquals($value, $object->getLineWidth());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineWidth($value));
+ self::assertEquals($value, $object->getLineWidth());
}
}
diff --git a/tests/PhpPresentation/Tests/Style/BordersTest.php b/tests/PhpPresentation/Tests/Style/BordersTest.php
index 72e9ce8bf4..20fcb28557 100644
--- a/tests/PhpPresentation/Tests/Style/BordersTest.php
+++ b/tests/PhpPresentation/Tests/Style/BordersTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,14 +36,14 @@ class BordersTest extends TestCase
public function testConstruct(): void
{
$object = new Borders();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getBottom());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getLeft());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getRight());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getTop());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getDiagonalDown());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getDiagonalUp());
- $this->assertEquals(Border::LINE_NONE, $object->getDiagonalDown()->getLineStyle());
- $this->assertEquals(Border::LINE_NONE, $object->getDiagonalUp()->getLineStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getBottom());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getLeft());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getRight());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getTop());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getDiagonalDown());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getDiagonalUp());
+ self::assertEquals(Border::LINE_NONE, $object->getDiagonalDown()->getLineStyle());
+ self::assertEquals(Border::LINE_NONE, $object->getDiagonalUp()->getLineStyle());
}
/**
@@ -55,7 +54,7 @@ public function testSetGetHashIndex(): void
$object = new Borders();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
/**
@@ -64,7 +63,7 @@ public function testSetGetHashIndex(): void
public function testGetHashCode(): void
{
$object = new Borders();
- $this->assertEquals(
+ self::assertEquals(
md5(
$object->getLeft()->getHashCode() .
$object->getRight()->getHashCode() .
diff --git a/tests/PhpPresentation/Tests/Style/BulletTest.php b/tests/PhpPresentation/Tests/Style/BulletTest.php
index 8d8b965630..e884249871 100644
--- a/tests/PhpPresentation/Tests/Style/BulletTest.php
+++ b/tests/PhpPresentation/Tests/Style/BulletTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,11 +36,11 @@ class BulletTest extends TestCase
public function testConstruct(): void
{
$object = new Bullet();
- $this->assertEquals(Bullet::TYPE_NONE, $object->getBulletType());
- $this->assertEquals('Calibri', $object->getBulletFont());
- $this->assertEquals('-', $object->getBulletChar());
- $this->assertEquals(Bullet::NUMERIC_DEFAULT, $object->getBulletNumericStyle());
- $this->assertEquals(1, $object->getBulletNumericStartAt());
+ self::assertEquals(Bullet::TYPE_NONE, $object->getBulletType());
+ self::assertEquals('Calibri', $object->getBulletFont());
+ self::assertEquals('-', $object->getBulletChar());
+ self::assertEquals(Bullet::NUMERIC_DEFAULT, $object->getBulletNumericStyle());
+ self::assertEquals(1, $object->getBulletNumericStartAt());
}
/**
@@ -50,10 +49,10 @@ public function testConstruct(): void
public function testSetGetBulletChar(): void
{
$object = new Bullet();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletChar());
- $this->assertEquals('-', $object->getBulletChar());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletChar('a'));
- $this->assertEquals('a', $object->getBulletChar());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletChar());
+ self::assertEquals('-', $object->getBulletChar());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletChar('a'));
+ self::assertEquals('a', $object->getBulletChar());
}
/**
@@ -66,12 +65,12 @@ public function testSetGetBulletColor(): void
$expectedARGB = '01234567';
// default
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getBulletColor());
- $this->assertEquals(Color::COLOR_BLACK, $object->getBulletColor()->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getBulletColor());
+ self::assertEquals(Color::COLOR_BLACK, $object->getBulletColor()->getARGB());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletColor(new Color($expectedARGB)));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getBulletColor());
- $this->assertEquals($expectedARGB, $object->getBulletColor()->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletColor(new Color($expectedARGB)));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getBulletColor());
+ self::assertEquals($expectedARGB, $object->getBulletColor()->getARGB());
}
/**
@@ -80,12 +79,12 @@ public function testSetGetBulletColor(): void
public function testSetGetBulletFont(): void
{
$object = new Bullet();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletFont());
- $this->assertEquals('Calibri', $object->getBulletFont());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletFont(''));
- $this->assertEquals('Calibri', $object->getBulletFont());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletFont('Arial'));
- $this->assertEquals('Arial', $object->getBulletFont());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletFont());
+ self::assertEquals('Calibri', $object->getBulletFont());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletFont(''));
+ self::assertEquals('Calibri', $object->getBulletFont());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletFont('Arial'));
+ self::assertEquals('Arial', $object->getBulletFont());
}
/**
@@ -94,11 +93,11 @@ public function testSetGetBulletFont(): void
public function testSetGetBulletNumericStartAt(): void
{
$object = new Bullet();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStartAt());
- $this->assertEquals(1, $object->getBulletNumericStartAt());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStartAt());
+ self::assertEquals(1, $object->getBulletNumericStartAt());
$value = mt_rand(1, 100);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStartAt($value));
- $this->assertEquals($value, $object->getBulletNumericStartAt());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStartAt($value));
+ self::assertEquals($value, $object->getBulletNumericStartAt());
}
/**
@@ -107,10 +106,10 @@ public function testSetGetBulletNumericStartAt(): void
public function testSetGetBulletNumericStyle(): void
{
$object = new Bullet();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStyle());
- $this->assertEquals(Bullet::NUMERIC_DEFAULT, $object->getBulletNumericStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStyle(Bullet::NUMERIC_ALPHALCPARENBOTH));
- $this->assertEquals(Bullet::NUMERIC_ALPHALCPARENBOTH, $object->getBulletNumericStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStyle());
+ self::assertEquals(Bullet::NUMERIC_DEFAULT, $object->getBulletNumericStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStyle(Bullet::NUMERIC_ALPHALCPARENBOTH));
+ self::assertEquals(Bullet::NUMERIC_ALPHALCPARENBOTH, $object->getBulletNumericStyle());
}
/**
@@ -119,10 +118,10 @@ public function testSetGetBulletNumericStyle(): void
public function testSetGetBulletType(): void
{
$object = new Bullet();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletType());
- $this->assertEquals(Bullet::TYPE_NONE, $object->getBulletType());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletType(Bullet::TYPE_BULLET));
- $this->assertEquals(Bullet::TYPE_BULLET, $object->getBulletType());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletType());
+ self::assertEquals(Bullet::TYPE_NONE, $object->getBulletType());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletType(Bullet::TYPE_BULLET));
+ self::assertEquals(Bullet::TYPE_BULLET, $object->getBulletType());
}
/**
@@ -133,6 +132,6 @@ public function testSetGetHashIndex(): void
$object = new Bullet();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
}
diff --git a/tests/PhpPresentation/Tests/Style/ColorMapTest.php b/tests/PhpPresentation/Tests/Style/ColorMapTest.php
index 126c80ac11..8f2ed75806 100644
--- a/tests/PhpPresentation/Tests/Style/ColorMapTest.php
+++ b/tests/PhpPresentation/Tests/Style/ColorMapTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,28 +27,28 @@ class ColorMapTest extends TestCase
public function testConstruct(): void
{
$object = new ColorMap();
- $this->assertIsArray($object->getMapping());
- $this->assertEquals(ColorMap::$mappingDefault, $object->getMapping());
+ self::assertIsArray($object->getMapping());
+ self::assertEquals(ColorMap::$mappingDefault, $object->getMapping());
}
public function testMapping(): void
{
$object = new ColorMap();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->setMapping([]));
- $this->assertIsArray($object->getMapping());
- $this->assertCount(0, $object->getMapping());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->setMapping([]));
+ self::assertIsArray($object->getMapping());
+ self::assertCount(0, $object->getMapping());
$array = ColorMap::$mappingDefault;
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->setMapping($array));
- $this->assertIsArray($object->getMapping());
- $this->assertEquals(ColorMap::$mappingDefault, $object->getMapping());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->setMapping($array));
+ self::assertIsArray($object->getMapping());
+ self::assertEquals(ColorMap::$mappingDefault, $object->getMapping());
}
public function testModifier(): void
{
$object = new ColorMap();
$key = array_rand(ColorMap::$mappingDefault);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->changeColor($key, 'AlphaBeta'));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->changeColor($key, 'AlphaBeta'));
$array = $object->getMapping();
- $this->assertEquals('AlphaBeta', $array[$key]);
+ self::assertEquals('AlphaBeta', $array[$key]);
}
}
diff --git a/tests/PhpPresentation/Tests/Style/ColorTest.php b/tests/PhpPresentation/Tests/Style/ColorTest.php
index afdfcd26ac..c4b5055f5b 100644
--- a/tests/PhpPresentation/Tests/Style/ColorTest.php
+++ b/tests/PhpPresentation/Tests/Style/ColorTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,9 +35,9 @@ class ColorTest extends TestCase
public function testConstruct(): void
{
$object = new Color();
- $this->assertEquals(Color::COLOR_BLACK, $object->getARGB());
- $object = new Color(COLOR::COLOR_BLUE);
- $this->assertEquals(Color::COLOR_BLUE, $object->getARGB());
+ self::assertEquals(Color::COLOR_BLACK, $object->getARGB());
+ $object = new Color(Color::COLOR_BLUE);
+ self::assertEquals(Color::COLOR_BLUE, $object->getARGB());
}
/**
@@ -48,14 +47,14 @@ public function testAlpha(): void
{
$randAlpha = mt_rand(0, 100);
$object = new Color();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB());
- $this->assertEquals(100, $object->getAlpha());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB('AA0000FF'));
- $this->assertEquals(67, $object->getAlpha());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB(Color::COLOR_BLUE));
- $this->assertEquals(100, $object->getAlpha());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setAlpha($randAlpha));
- $this->assertEquals($randAlpha, round($object->getAlpha()));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB());
+ self::assertEquals(100, $object->getAlpha());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB('AA0000FF'));
+ self::assertEquals(67, $object->getAlpha());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB(Color::COLOR_BLUE));
+ self::assertEquals(100, $object->getAlpha());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setAlpha($randAlpha));
+ self::assertEquals($randAlpha, round($object->getAlpha()));
}
/**
@@ -64,12 +63,12 @@ public function testAlpha(): void
public function testSetGetARGB(): void
{
$object = new Color();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB());
- $this->assertEquals(Color::COLOR_BLACK, $object->getARGB());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB(''));
- $this->assertEquals(Color::COLOR_BLACK, $object->getARGB());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB(Color::COLOR_BLUE));
- $this->assertEquals(Color::COLOR_BLUE, $object->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB());
+ self::assertEquals(Color::COLOR_BLACK, $object->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB(''));
+ self::assertEquals(Color::COLOR_BLACK, $object->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB(Color::COLOR_BLUE));
+ self::assertEquals(Color::COLOR_BLUE, $object->getARGB());
}
/**
@@ -78,18 +77,18 @@ public function testSetGetARGB(): void
public function testSetGetRGB(): void
{
$object = new Color();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB());
- $this->assertEquals('000000', $object->getRGB());
- $this->assertEquals('FF000000', $object->getARGB());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB(''));
- $this->assertEquals('000000', $object->getRGB());
- $this->assertEquals('FF000000', $object->getARGB());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB('555'));
- $this->assertEquals('555', $object->getRGB());
- $this->assertEquals('FF555', $object->getARGB());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB('6666'));
- $this->assertEquals('FF6666', $object->getRGB());
- $this->assertEquals('FF6666', $object->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB());
+ self::assertEquals('000000', $object->getRGB());
+ self::assertEquals('FF000000', $object->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB(''));
+ self::assertEquals('000000', $object->getRGB());
+ self::assertEquals('FF000000', $object->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB('555'));
+ self::assertEquals('555', $object->getRGB());
+ self::assertEquals('FF555', $object->getARGB());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setRGB('6666'));
+ self::assertEquals('FF6666', $object->getRGB());
+ self::assertEquals('FF6666', $object->getARGB());
}
/**
@@ -100,6 +99,6 @@ public function testSetGetHashIndex(): void
$object = new Color();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
}
diff --git a/tests/PhpPresentation/Tests/Style/FillTest.php b/tests/PhpPresentation/Tests/Style/FillTest.php
index 2ac5eb183d..676156ed38 100644
--- a/tests/PhpPresentation/Tests/Style/FillTest.php
+++ b/tests/PhpPresentation/Tests/Style/FillTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,12 +36,12 @@ class FillTest extends TestCase
public function testConstruct(): void
{
$object = new Fill();
- $this->assertEquals(Fill::FILL_NONE, $object->getFillType());
- $this->assertEquals(0, $object->getRotation());
- $this->assertInstanceOf(Color::class, $object->getStartColor());
- $this->assertEquals(Color::COLOR_WHITE, $object->getEndColor()->getARGB());
- $this->assertInstanceOf(Color::class, $object->getEndColor());
- $this->assertEquals(Color::COLOR_BLACK, $object->getStartColor()->getARGB());
+ self::assertEquals(Fill::FILL_NONE, $object->getFillType());
+ self::assertEquals(0, $object->getRotation());
+ self::assertInstanceOf(Color::class, $object->getStartColor());
+ self::assertEquals(Color::COLOR_WHITE, $object->getEndColor()->getARGB());
+ self::assertInstanceOf(Color::class, $object->getEndColor());
+ self::assertEquals(Color::COLOR_BLACK, $object->getStartColor()->getARGB());
}
/**
@@ -51,9 +50,9 @@ public function testConstruct(): void
public function testSetGetEndColor(): void
{
$object = new Fill();
- $this->assertInstanceOf(Fill::class, $object->setEndColor(new Color(COLOR::COLOR_BLUE)));
- $this->assertInstanceOf(Color::class, $object->getEndColor());
- $this->assertEquals(COLOR::COLOR_BLUE, $object->getEndColor()->getARGB());
+ self::assertInstanceOf(Fill::class, $object->setEndColor(new Color(Color::COLOR_BLUE)));
+ self::assertInstanceOf(Color::class, $object->getEndColor());
+ self::assertEquals(Color::COLOR_BLUE, $object->getEndColor()->getARGB());
}
/**
@@ -62,10 +61,10 @@ public function testSetGetEndColor(): void
public function testSetGetFillType(): void
{
$object = new Fill();
- $this->assertInstanceOf(Fill::class, $object->setFillType());
- $this->assertEquals(Fill::FILL_NONE, $object->getFillType());
- $this->assertInstanceOf(Fill::class, $object->setFillType(Fill::FILL_GRADIENT_LINEAR));
- $this->assertEquals(Fill::FILL_GRADIENT_LINEAR, $object->getFillType());
+ self::assertInstanceOf(Fill::class, $object->setFillType());
+ self::assertEquals(Fill::FILL_NONE, $object->getFillType());
+ self::assertInstanceOf(Fill::class, $object->setFillType(Fill::FILL_GRADIENT_LINEAR));
+ self::assertEquals(Fill::FILL_GRADIENT_LINEAR, $object->getFillType());
}
/**
@@ -74,11 +73,11 @@ public function testSetGetFillType(): void
public function testSetGetRotation(): void
{
$object = new Fill();
- $this->assertInstanceOf(Fill::class, $object->setRotation());
- $this->assertEquals(0, $object->getRotation());
+ self::assertInstanceOf(Fill::class, $object->setRotation());
+ self::assertEquals(0, $object->getRotation());
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Fill::class, $object->setRotation($value));
- $this->assertEquals($value, $object->getRotation());
+ self::assertInstanceOf(Fill::class, $object->setRotation($value));
+ self::assertEquals($value, $object->getRotation());
}
/**
@@ -87,9 +86,9 @@ public function testSetGetRotation(): void
public function testSetGetStartColor(): void
{
$object = new Fill();
- $this->assertInstanceOf(Fill::class, $object->setStartColor(new Color(COLOR::COLOR_BLUE)));
- $this->assertInstanceOf(Color::class, $object->getStartColor());
- $this->assertEquals(COLOR::COLOR_BLUE, $object->getStartColor()->getARGB());
+ self::assertInstanceOf(Fill::class, $object->setStartColor(new Color(Color::COLOR_BLUE)));
+ self::assertInstanceOf(Color::class, $object->getStartColor());
+ self::assertEquals(Color::COLOR_BLUE, $object->getStartColor()->getARGB());
}
/**
@@ -100,6 +99,6 @@ public function testSetGetHashIndex(): void
$object = new Fill();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
}
diff --git a/tests/PhpPresentation/Tests/Style/FontTest.php b/tests/PhpPresentation/Tests/Style/FontTest.php
index 47deb3f0ba..6eabdd74bf 100644
--- a/tests/PhpPresentation/Tests/Style/FontTest.php
+++ b/tests/PhpPresentation/Tests/Style/FontTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,6 +19,8 @@
namespace PhpOffice\PhpPresentation\Tests\Style;
+use PhpOffice\PhpPresentation\Exception\InvalidParameterException;
+use PhpOffice\PhpPresentation\Exception\NotAllowedValueException;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\Style\Font;
use PHPUnit\Framework\TestCase;
@@ -37,17 +38,66 @@ class FontTest extends TestCase
public function testConstruct(): void
{
$object = new Font();
- $this->assertEquals('Calibri', $object->getName());
- $this->assertEquals(10, $object->getSize());
- $this->assertFalse($object->isBold());
- $this->assertFalse($object->isItalic());
- $this->assertFalse($object->isSuperScript());
- $this->assertFalse($object->isSubScript());
- $this->assertFalse($object->isStrikethrough());
- $this->assertEquals(Font::UNDERLINE_NONE, $object->getUnderline());
- $this->assertEquals(0, $object->getCharacterSpacing());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
- $this->assertEquals(Color::COLOR_BLACK, $object->getColor()->getARGB());
+ self::assertEquals('Calibri', $object->getName());
+ self::assertEquals(10, $object->getSize());
+ self::assertFalse($object->isBold());
+ self::assertFalse($object->isItalic());
+ self::assertFalse($object->isSuperScript());
+ self::assertFalse($object->isSubScript());
+ self::assertFalse($object->isStrikethrough());
+ self::assertEquals(Font::UNDERLINE_NONE, $object->getUnderline());
+ self::assertEquals(0, $object->getCharacterSpacing());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $object->getCapitalization());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
+ self::assertEquals(Color::COLOR_BLACK, $object->getColor()->getARGB());
+ self::assertEquals(0, $object->getBaseline());
+ }
+
+ /**
+ * Test get/set Baseline.
+ */
+ public function testBaseline(): void
+ {
+ $object = new Font();
+ self::assertEquals(0, $object->getBaseline());
+ self::assertInstanceOf(Font::class, $object->setBaseline(Font::BASELINE_SUBSCRIPT));
+ self::assertEquals(Font::BASELINE_SUBSCRIPT, $object->getBaseline());
+ }
+
+ /**
+ * Test get/set Capitalization.
+ */
+ public function testCapitalization(): void
+ {
+ $object = new Font();
+ self::assertEquals(Font::CAPITALIZATION_NONE, $object->getCapitalization());
+ self::assertInstanceOf(Font::class, $object->setCapitalization(Font::CAPITALIZATION_ALL));
+ self::assertEquals(Font::CAPITALIZATION_ALL, $object->getCapitalization());
+ self::assertInstanceOf(Font::class, $object->setCapitalization());
+ self::assertEquals(Font::CAPITALIZATION_NONE, $object->getCapitalization());
+ }
+
+ /**
+ * Test get/set Capitalization exception.
+ */
+ public function testCapitalizationException(): void
+ {
+ $this->expectException(NotAllowedValueException::class);
+ $this->expectExceptionMessage('The value "Invalid" is not in allowed values ("none", "all", "small")');
+
+ $object = new Font();
+ $object->setCapitalization('Invalid');
+ }
+
+ /**
+ * Test get/set charset.
+ */
+ public function testCharset(): void
+ {
+ $object = new Font();
+ self::assertEquals(Font::CHARSET_DEFAULT, $object->getCharset());
+ self::assertInstanceOf(Font::class, $object->setCharset(12));
+ self::assertEquals(12, $object->getCharset());
}
/**
@@ -56,13 +106,13 @@ public function testConstruct(): void
public function testCharacterSpacing(): void
{
$object = new Font();
- $this->assertEquals(0, $object->getCharacterSpacing());
- $this->assertInstanceOf(Font::class, $object->setCharacterSpacing(0));
- $this->assertEquals(0, $object->getCharacterSpacing());
- $this->assertInstanceOf(Font::class, $object->setCharacterSpacing(10));
- $this->assertEquals(1000, $object->getCharacterSpacing());
- $this->assertInstanceOf(Font::class, $object->setCharacterSpacing());
- $this->assertEquals(0, $object->getCharacterSpacing());
+ self::assertEquals(0, $object->getCharacterSpacing());
+ self::assertInstanceOf(Font::class, $object->setCharacterSpacing(0));
+ self::assertEquals(0, $object->getCharacterSpacing());
+ self::assertInstanceOf(Font::class, $object->setCharacterSpacing(10));
+ self::assertEquals(1000, $object->getCharacterSpacing());
+ self::assertInstanceOf(Font::class, $object->setCharacterSpacing());
+ self::assertEquals(0, $object->getCharacterSpacing());
}
/**
@@ -71,10 +121,10 @@ public function testCharacterSpacing(): void
public function testColor(): void
{
$object = new Font();
- $this->assertEquals(Color::COLOR_BLACK, $object->getColor()->getARGB());
- $this->assertInstanceOf(Font::class, $object->setColor(new Color(Color::COLOR_BLUE)));
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
- $this->assertEquals(Color::COLOR_BLUE, $object->getColor()->getARGB());
+ self::assertEquals(Color::COLOR_BLACK, $object->getColor()->getARGB());
+ self::assertInstanceOf(Font::class, $object->setColor(new Color(Color::COLOR_BLUE)));
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
+ self::assertEquals(Color::COLOR_BLUE, $object->getColor()->getARGB());
}
/**
@@ -83,15 +133,15 @@ public function testColor(): void
public function testFormat(): void
{
$object = new Font();
- $this->assertEquals(Font::FORMAT_LATIN, $object->getFormat());
- $this->assertInstanceOf(Font::class, $object->setFormat());
- $this->assertEquals(Font::FORMAT_LATIN, $object->getFormat());
- $this->assertInstanceOf(Font::class, $object->setFormat('UnAuthorized'));
- $this->assertEquals(Font::FORMAT_LATIN, $object->getFormat());
- $this->assertInstanceOf(Font::class, $object->setFormat(Font::FORMAT_EAST_ASIAN));
- $this->assertEquals(Font::FORMAT_EAST_ASIAN, $object->getFormat());
- $this->assertInstanceOf(Font::class, $object->setFormat(Font::FORMAT_COMPLEX_SCRIPT));
- $this->assertEquals(Font::FORMAT_COMPLEX_SCRIPT, $object->getFormat());
+ self::assertEquals(Font::FORMAT_LATIN, $object->getFormat());
+ self::assertInstanceOf(Font::class, $object->setFormat());
+ self::assertEquals(Font::FORMAT_LATIN, $object->getFormat());
+ self::assertInstanceOf(Font::class, $object->setFormat('UnAuthorized'));
+ self::assertEquals(Font::FORMAT_LATIN, $object->getFormat());
+ self::assertInstanceOf(Font::class, $object->setFormat(Font::FORMAT_EAST_ASIAN));
+ self::assertEquals(Font::FORMAT_EAST_ASIAN, $object->getFormat());
+ self::assertInstanceOf(Font::class, $object->setFormat(Font::FORMAT_COMPLEX_SCRIPT));
+ self::assertEquals(Font::FORMAT_COMPLEX_SCRIPT, $object->getFormat());
}
/**
@@ -100,12 +150,58 @@ public function testFormat(): void
public function testName(): void
{
$object = new Font();
- $this->assertInstanceOf(Font::class, $object->setName());
- $this->assertEquals('Calibri', $object->getName());
- $this->assertInstanceOf(Font::class, $object->setName(''));
- $this->assertEquals('Calibri', $object->getName());
- $this->assertInstanceOf(Font::class, $object->setName('Arial'));
- $this->assertEquals('Arial', $object->getName());
+ self::assertInstanceOf(Font::class, $object->setName());
+ self::assertEquals('Calibri', $object->getName());
+ self::assertInstanceOf(Font::class, $object->setName(''));
+ self::assertEquals('Calibri', $object->getName());
+ self::assertInstanceOf(Font::class, $object->setName('Arial'));
+ self::assertEquals('Arial', $object->getName());
+ }
+
+ /**
+ * Test get/set panose.
+ */
+ public function testPanose(): void
+ {
+ $object = new Font();
+ self::assertEquals('', $object->getPanose());
+ self::assertInstanceOf(Font::class, $object->setPanose('4494D72242'));
+ self::assertEquals('4494D72242', $object->getPanose());
+ }
+
+ /**
+ * Test get/set panose (Exception : Invalid Length).
+ */
+ public function testPanoseExceptionInvalidLength(): void
+ {
+ $this->expectException(InvalidParameterException::class);
+ $this->expectExceptionMessage('The parameter pValue can\'t have the value "12345" (Validation: The length is not equals to 10)');
+
+ $object = new Font();
+ $object->setPanose('12345');
+ }
+
+ /**
+ * Test get/set panose (Exception : Invalid Char).
+ */
+ public function testPanoseExceptionInvalidChar(): void
+ {
+ $this->expectException(InvalidParameterException::class);
+ $this->expectExceptionMessage('The parameter pValue can\'t have the value "4494D7224X" (Validation: The character "X" is not allowed)');
+
+ $object = new Font();
+ $object->setPanose('4494D7224X');
+ }
+
+ /**
+ * Test get/set pitch family.
+ */
+ public function testPitchFamily(): void
+ {
+ $object = new Font();
+ self::assertEquals(0, $object->getPitchFamily());
+ self::assertInstanceOf(Font::class, $object->setPitchFamily(12));
+ self::assertEquals(12, $object->getPitchFamily());
}
/**
@@ -114,11 +210,11 @@ public function testName(): void
public function testSize(): void
{
$object = new Font();
- $this->assertInstanceOf(Font::class, $object->setSize());
- $this->assertEquals(10, $object->getSize());
+ self::assertInstanceOf(Font::class, $object->setSize());
+ self::assertEquals(10, $object->getSize());
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Font::class, $object->setSize($value));
- $this->assertEquals($value, $object->getSize());
+ self::assertInstanceOf(Font::class, $object->setSize($value));
+ self::assertEquals($value, $object->getSize());
}
/**
@@ -127,12 +223,12 @@ public function testSize(): void
public function testUnderline(): void
{
$object = new Font();
- $this->assertInstanceOf(Font::class, $object->setUnderline());
- $this->assertEquals(FONT::UNDERLINE_NONE, $object->getUnderline());
- $this->assertInstanceOf(Font::class, $object->setUnderline(''));
- $this->assertEquals(FONT::UNDERLINE_NONE, $object->getUnderline());
- $this->assertInstanceOf(Font::class, $object->setUnderline(FONT::UNDERLINE_DASH));
- $this->assertEquals(FONT::UNDERLINE_DASH, $object->getUnderline());
+ self::assertInstanceOf(Font::class, $object->setUnderline());
+ self::assertEquals(Font::UNDERLINE_NONE, $object->getUnderline());
+ self::assertInstanceOf(Font::class, $object->setUnderline(''));
+ self::assertEquals(Font::UNDERLINE_NONE, $object->getUnderline());
+ self::assertInstanceOf(Font::class, $object->setUnderline(Font::UNDERLINE_DASH));
+ self::assertEquals(Font::UNDERLINE_DASH, $object->getUnderline());
}
/**
@@ -141,12 +237,12 @@ public function testUnderline(): void
public function testSetIsBold(): void
{
$object = new Font();
- $this->assertInstanceOf(Font::class, $object->setBold());
- $this->assertFalse($object->isBold());
- $this->assertInstanceOf(Font::class, $object->setBold(false));
- $this->assertFalse($object->isBold());
- $this->assertInstanceOf(Font::class, $object->setBold(true));
- $this->assertTrue($object->isBold());
+ self::assertInstanceOf(Font::class, $object->setBold());
+ self::assertFalse($object->isBold());
+ self::assertInstanceOf(Font::class, $object->setBold(false));
+ self::assertFalse($object->isBold());
+ self::assertInstanceOf(Font::class, $object->setBold(true));
+ self::assertTrue($object->isBold());
}
/**
@@ -155,12 +251,12 @@ public function testSetIsBold(): void
public function testSetIsItalic(): void
{
$object = new Font();
- $this->assertInstanceOf(Font::class, $object->setItalic());
- $this->assertFalse($object->isItalic());
- $this->assertInstanceOf(Font::class, $object->setItalic(false));
- $this->assertFalse($object->isItalic());
- $this->assertInstanceOf(Font::class, $object->setItalic(true));
- $this->assertTrue($object->isItalic());
+ self::assertInstanceOf(Font::class, $object->setItalic());
+ self::assertFalse($object->isItalic());
+ self::assertInstanceOf(Font::class, $object->setItalic(false));
+ self::assertFalse($object->isItalic());
+ self::assertInstanceOf(Font::class, $object->setItalic(true));
+ self::assertTrue($object->isItalic());
}
/**
@@ -169,12 +265,20 @@ public function testSetIsItalic(): void
public function testSetIsStriketrough(): void
{
$object = new Font();
- $this->assertInstanceOf(Font::class, $object->setStrikethrough());
- $this->assertFalse($object->isStrikethrough());
- $this->assertInstanceOf(Font::class, $object->setStrikethrough(false));
- $this->assertFalse($object->isStrikethrough());
- $this->assertInstanceOf(Font::class, $object->setStrikethrough(true));
- $this->assertTrue($object->isStrikethrough());
+ self::assertInstanceOf(Font::class, $object->setStrikethrough());
+ self::assertFalse($object->isStrikethrough());
+ self::assertEquals(Font::STRIKE_NONE, $object->getStrikethrough());
+ // boolean
+ self::assertInstanceOf(Font::class, $object->setStrikethrough(false));
+ self::assertFalse($object->isStrikethrough());
+ self::assertEquals(Font::STRIKE_NONE, $object->getStrikethrough());
+ self::assertInstanceOf(Font::class, $object->setStrikethrough(true));
+ self::assertTrue($object->isStrikethrough());
+ self::assertEquals(Font::STRIKE_SINGLE, $object->getStrikethrough());
+ // string
+ self::assertInstanceOf(Font::class, $object->setStrikethrough(Font::STRIKE_DOUBLE));
+ self::assertTrue($object->isStrikethrough());
+ self::assertEquals(Font::STRIKE_DOUBLE, $object->getStrikethrough());
}
/**
@@ -183,25 +287,25 @@ public function testSetIsStriketrough(): void
public function testSetIsSubScript(): void
{
$object = new Font();
- $this->assertInstanceOf(Font::class, $object->setSubScript());
- $this->assertFalse($object->isSubScript());
- $this->assertInstanceOf(Font::class, $object->setSubScript(false));
- $this->assertFalse($object->isSubScript());
- $this->assertInstanceOf(Font::class, $object->setSubScript(true));
- $this->assertTrue($object->isSubScript());
+ self::assertInstanceOf(Font::class, $object->setSubScript());
+ self::assertFalse($object->isSubScript());
+ self::assertInstanceOf(Font::class, $object->setSubScript(false));
+ self::assertFalse($object->isSubScript());
+ self::assertInstanceOf(Font::class, $object->setSubScript(true));
+ self::assertTrue($object->isSubScript());
// Test toggle of SubScript
- $this->assertInstanceOf(Font::class, $object->setSubScript(false));
- $this->assertInstanceOf(Font::class, $object->setSuperScript(false));
- $this->assertFalse($object->isSubScript());
+ self::assertInstanceOf(Font::class, $object->setSubScript(false));
+ self::assertInstanceOf(Font::class, $object->setSuperScript(false));
+ self::assertFalse($object->isSubScript());
- $this->assertInstanceOf(Font::class, $object->setSubScript(true));
- $this->assertInstanceOf(Font::class, $object->setSuperScript(true));
- $this->assertFalse($object->isSubScript());
+ self::assertInstanceOf(Font::class, $object->setSubScript(true));
+ self::assertInstanceOf(Font::class, $object->setSuperScript(true));
+ self::assertFalse($object->isSubScript());
- $this->assertInstanceOf(Font::class, $object->setSubScript(true));
- $this->assertInstanceOf(Font::class, $object->setSuperScript(false));
- $this->assertTrue($object->isSubScript());
+ self::assertInstanceOf(Font::class, $object->setSubScript(true));
+ self::assertInstanceOf(Font::class, $object->setSuperScript(false));
+ self::assertTrue($object->isSubScript());
}
/**
@@ -210,25 +314,25 @@ public function testSetIsSubScript(): void
public function testSetIsSuperScript(): void
{
$object = new Font();
- $this->assertInstanceOf(Font::class, $object->setSuperScript());
- $this->assertFalse($object->isSuperScript());
- $this->assertInstanceOf(Font::class, $object->setSuperScript(false));
- $this->assertFalse($object->isSuperScript());
- $this->assertInstanceOf(Font::class, $object->setSuperScript(true));
- $this->assertTrue($object->isSuperScript());
+ self::assertInstanceOf(Font::class, $object->setSuperScript());
+ self::assertFalse($object->isSuperScript());
+ self::assertInstanceOf(Font::class, $object->setSuperScript(false));
+ self::assertFalse($object->isSuperScript());
+ self::assertInstanceOf(Font::class, $object->setSuperScript(true));
+ self::assertTrue($object->isSuperScript());
// Test toggle of SubScript
- $this->assertInstanceOf(Font::class, $object->setSuperScript(false));
- $this->assertInstanceOf(Font::class, $object->setSubScript(false));
- $this->assertFalse($object->isSuperScript());
+ self::assertInstanceOf(Font::class, $object->setSuperScript(false));
+ self::assertInstanceOf(Font::class, $object->setSubScript(false));
+ self::assertFalse($object->isSuperScript());
- $this->assertInstanceOf(Font::class, $object->setSuperScript(true));
- $this->assertInstanceOf(Font::class, $object->setSubScript(true));
- $this->assertFalse($object->isSuperScript());
+ self::assertInstanceOf(Font::class, $object->setSuperScript(true));
+ self::assertInstanceOf(Font::class, $object->setSubScript(true));
+ self::assertFalse($object->isSuperScript());
- $this->assertInstanceOf(Font::class, $object->setSuperScript(true));
- $this->assertInstanceOf(Font::class, $object->setSubScript(false));
- $this->assertTrue($object->isSuperScript());
+ self::assertInstanceOf(Font::class, $object->setSuperScript(true));
+ self::assertInstanceOf(Font::class, $object->setSubScript(false));
+ self::assertTrue($object->isSuperScript());
}
/**
@@ -239,6 +343,6 @@ public function testHashIndex(): void
$object = new Font();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
}
diff --git a/tests/PhpPresentation/Tests/Style/OutlineTest.php b/tests/PhpPresentation/Tests/Style/OutlineTest.php
index 30411f12b2..340b178efd 100644
--- a/tests/PhpPresentation/Tests/Style/OutlineTest.php
+++ b/tests/PhpPresentation/Tests/Style/OutlineTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,8 +36,8 @@ class OutlineTest extends TestCase
public function testConstruct(): void
{
$object = new Outline();
- $this->assertEquals(1, $object->getWidth());
- $this->assertInstanceOf(Fill::class, $object->getFill());
+ self::assertEquals(1, $object->getWidth());
+ self::assertInstanceOf(Fill::class, $object->getFill());
}
/**
@@ -47,9 +46,9 @@ public function testConstruct(): void
public function testSetGetFill(): void
{
$object = new Outline();
- $this->assertInstanceOf(Fill::class, $object->getFill());
- $this->assertInstanceOf(Outline::class, $object->setFill(new Fill()));
- $this->assertInstanceOf(Fill::class, $object->getFill());
+ self::assertInstanceOf(Fill::class, $object->getFill());
+ self::assertInstanceOf(Outline::class, $object->setFill(new Fill()));
+ self::assertInstanceOf(Fill::class, $object->getFill());
}
/**
@@ -58,9 +57,9 @@ public function testSetGetFill(): void
public function testSetGetWidth(): void
{
$object = new Outline();
- $this->assertEquals(1, $object->getWidth());
+ self::assertEquals(1, $object->getWidth());
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Outline::class, $object->setWidth($value));
- $this->assertEquals($value, $object->getWidth());
+ self::assertInstanceOf(Outline::class, $object->setWidth($value));
+ self::assertEquals($value, $object->getWidth());
}
}
diff --git a/tests/PhpPresentation/Tests/Style/ShadowTest.php b/tests/PhpPresentation/Tests/Style/ShadowTest.php
index ec22869827..5e834fd343 100644
--- a/tests/PhpPresentation/Tests/Style/ShadowTest.php
+++ b/tests/PhpPresentation/Tests/Style/ShadowTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,14 +36,14 @@ class ShadowTest extends TestCase
public function testConstruct(): void
{
$object = new Shadow();
- $this->assertFalse($object->isVisible());
- $this->assertEquals(6, $object->getBlurRadius());
- $this->assertEquals(2, $object->getDistance());
- $this->assertEquals(0, $object->getDirection());
- $this->assertEquals(Shadow::SHADOW_BOTTOM_RIGHT, $object->getAlignment());
- $this->assertInstanceOf(Color::class, $object->getColor());
- $this->assertEquals(Color::COLOR_BLACK, $object->getColor()->getARGB());
- $this->assertEquals(50, $object->getAlpha());
+ self::assertFalse($object->isVisible());
+ self::assertEquals(6, $object->getBlurRadius());
+ self::assertEquals(2, $object->getDistance());
+ self::assertEquals(0, $object->getDirection());
+ self::assertEquals(Shadow::SHADOW_BOTTOM_RIGHT, $object->getAlignment());
+ self::assertInstanceOf(Color::class, $object->getColor());
+ self::assertEquals(Color::COLOR_BLACK, $object->getColor()->getARGB());
+ self::assertEquals(50, $object->getAlpha());
}
/**
@@ -53,10 +52,10 @@ public function testConstruct(): void
public function testSetGetAlignment(): void
{
$object = new Shadow();
- $this->assertInstanceOf(Shadow::class, $object->setAlignment());
- $this->assertEquals(Shadow::SHADOW_BOTTOM_RIGHT, $object->getAlignment());
- $this->assertInstanceOf(Shadow::class, $object->setAlignment(Shadow::SHADOW_CENTER));
- $this->assertEquals(Shadow::SHADOW_CENTER, $object->getAlignment());
+ self::assertInstanceOf(Shadow::class, $object->setAlignment());
+ self::assertEquals(Shadow::SHADOW_BOTTOM_RIGHT, $object->getAlignment());
+ self::assertInstanceOf(Shadow::class, $object->setAlignment(Shadow::SHADOW_CENTER));
+ self::assertEquals(Shadow::SHADOW_CENTER, $object->getAlignment());
}
/**
@@ -65,11 +64,11 @@ public function testSetGetAlignment(): void
public function testSetGetAlpha(): void
{
$object = new Shadow();
- $this->assertInstanceOf(Shadow::class, $object->setAlpha());
- $this->assertEquals(0, $object->getAlpha());
+ self::assertInstanceOf(Shadow::class, $object->setAlpha());
+ self::assertEquals(0, $object->getAlpha());
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Shadow::class, $object->setAlpha($value));
- $this->assertEquals($value, $object->getAlpha());
+ self::assertInstanceOf(Shadow::class, $object->setAlpha($value));
+ self::assertEquals($value, $object->getAlpha());
}
/**
@@ -78,11 +77,11 @@ public function testSetGetAlpha(): void
public function testSetGetBlurRadius(): void
{
$object = new Shadow();
- $this->assertInstanceOf(Shadow::class, $object->setBlurRadius());
- $this->assertEquals(6, $object->getBlurRadius());
+ self::assertInstanceOf(Shadow::class, $object->setBlurRadius());
+ self::assertEquals(6, $object->getBlurRadius());
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Shadow::class, $object->setBlurRadius($value));
- $this->assertEquals($value, $object->getBlurRadius());
+ self::assertInstanceOf(Shadow::class, $object->setBlurRadius($value));
+ self::assertEquals($value, $object->getBlurRadius());
}
/**
@@ -91,11 +90,11 @@ public function testSetGetBlurRadius(): void
public function testSetGetColor(): void
{
$object = new Shadow();
- $this->assertInstanceOf(Shadow::class, $object->setColor());
- $this->assertNull($object->getColor());
- $this->assertInstanceOf(Shadow::class, $object->setColor(new Color(Color::COLOR_BLUE)));
- $this->assertInstanceOf(Color::class, $object->getColor());
- $this->assertEquals(Color::COLOR_BLUE, $object->getColor()->getARGB());
+ self::assertInstanceOf(Shadow::class, $object->setColor());
+ self::assertNull($object->getColor());
+ self::assertInstanceOf(Shadow::class, $object->setColor(new Color(Color::COLOR_BLUE)));
+ self::assertInstanceOf(Color::class, $object->getColor());
+ self::assertEquals(Color::COLOR_BLUE, $object->getColor()->getARGB());
}
/**
@@ -104,11 +103,11 @@ public function testSetGetColor(): void
public function testSetGetDirection(): void
{
$object = new Shadow();
- $this->assertInstanceOf(Shadow::class, $object->setDirection());
- $this->assertEquals(0, $object->getDirection());
+ self::assertInstanceOf(Shadow::class, $object->setDirection());
+ self::assertEquals(0, $object->getDirection());
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Shadow::class, $object->setDirection($value));
- $this->assertEquals($value, $object->getDirection());
+ self::assertInstanceOf(Shadow::class, $object->setDirection($value));
+ self::assertEquals($value, $object->getDirection());
}
/**
@@ -117,11 +116,11 @@ public function testSetGetDirection(): void
public function testSetGetDistance(): void
{
$object = new Shadow();
- $this->assertInstanceOf(Shadow::class, $object->setDistance());
- $this->assertEquals(2, $object->getDistance());
+ self::assertInstanceOf(Shadow::class, $object->setDistance());
+ self::assertEquals(2, $object->getDistance());
$value = mt_rand(1, 100);
- $this->assertInstanceOf(Shadow::class, $object->setDistance($value));
- $this->assertEquals($value, $object->getDistance());
+ self::assertInstanceOf(Shadow::class, $object->setDistance($value));
+ self::assertEquals($value, $object->getDistance());
}
/**
@@ -132,7 +131,7 @@ public function testSetGetHashIndex(): void
$object = new Shadow();
$value = mt_rand(1, 100);
$object->setHashIndex($value);
- $this->assertEquals($value, $object->getHashIndex());
+ self::assertEquals($value, $object->getHashIndex());
}
/**
@@ -141,11 +140,11 @@ public function testSetGetHashIndex(): void
public function testSetIsVisible(): void
{
$object = new Shadow();
- $this->assertInstanceOf(Shadow::class, $object->setVisible());
- $this->assertFalse($object->isVisible());
- $this->assertInstanceOf(Shadow::class, $object->setVisible(false));
- $this->assertFalse($object->isVisible());
- $this->assertInstanceOf(Shadow::class, $object->setVisible(true));
- $this->assertTrue($object->isVisible());
+ self::assertInstanceOf(Shadow::class, $object->setVisible());
+ self::assertFalse($object->isVisible());
+ self::assertInstanceOf(Shadow::class, $object->setVisible(false));
+ self::assertFalse($object->isVisible());
+ self::assertInstanceOf(Shadow::class, $object->setVisible(true));
+ self::assertTrue($object->isVisible());
}
}
diff --git a/tests/PhpPresentation/Tests/Style/TextStyleTest.php b/tests/PhpPresentation/Tests/Style/TextStyleTest.php
index b85da8f1fe..a021c09d7d 100644
--- a/tests/PhpPresentation/Tests/Style/TextStyleTest.php
+++ b/tests/PhpPresentation/Tests/Style/TextStyleTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -34,63 +33,63 @@ public function testConstructDefaultTrue(): void
$object = new TextStyle();
$arrayBodyStyle = $object->getBodyStyle();
- $this->assertIsArray($arrayBodyStyle);
- $this->assertCount(1, $arrayBodyStyle);
- $this->assertArrayHasKey(1, $arrayBodyStyle);
- $this->assertNull($object->getBodyStyleAtLvl(0));
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getBodyStyleAtLvl(1));
+ self::assertIsArray($arrayBodyStyle);
+ self::assertCount(1, $arrayBodyStyle);
+ self::assertArrayHasKey(1, $arrayBodyStyle);
+ self::assertNull($object->getBodyStyleAtLvl(0));
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getBodyStyleAtLvl(1));
$oParagraph = $object->getBodyStyleAtLvl(1);
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $oParagraph);
- $this->assertEquals(Alignment::HORIZONTAL_CENTER, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals((-324900 / 9525), $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(0, $oParagraph->getAlignment()->getMarginLeft());
- $this->assertEquals(32, $oParagraph->getFont()->getSize());
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $oParagraph);
+ self::assertEquals(Alignment::HORIZONTAL_CENTER, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals((-324900 / 9525), $oParagraph->getAlignment()->getIndent());
+ self::assertEquals(0, $oParagraph->getAlignment()->getMarginLeft());
+ self::assertEquals(32, $oParagraph->getFont()->getSize());
/** @var SchemeColor $color */
$color = $oParagraph->getFont()->getColor();
- $this->assertInstanceOf(SchemeColor::class, $color);
- $this->assertEquals('tx1', $color->getValue());
+ self::assertInstanceOf(SchemeColor::class, $color);
+ self::assertEquals('tx1', $color->getValue());
$arrayOtherStyle = $object->getOtherStyle();
- $this->assertIsArray($arrayOtherStyle);
- $this->assertCount(1, $arrayOtherStyle);
- $this->assertArrayHasKey(0, $arrayOtherStyle);
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getOtherStyleAtLvl(0));
- $this->assertNull($object->getOtherStyleAtLvl(1));
+ self::assertIsArray($arrayOtherStyle);
+ self::assertCount(1, $arrayOtherStyle);
+ self::assertArrayHasKey(0, $arrayOtherStyle);
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getOtherStyleAtLvl(0));
+ self::assertNull($object->getOtherStyleAtLvl(1));
$oParagraph = $object->getOtherStyleAtLvl(0);
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $oParagraph);
- $this->assertEquals(Alignment::HORIZONTAL_CENTER, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(10, $oParagraph->getFont()->getSize());
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $oParagraph);
+ self::assertEquals(Alignment::HORIZONTAL_CENTER, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(10, $oParagraph->getFont()->getSize());
/** @var SchemeColor $color */
$color = $oParagraph->getFont()->getColor();
- $this->assertInstanceOf(SchemeColor::class, $color);
- $this->assertEquals('tx1', $color->getValue());
+ self::assertInstanceOf(SchemeColor::class, $color);
+ self::assertEquals('tx1', $color->getValue());
$arrayTitleStyle = $object->getTitleStyle();
- $this->assertIsArray($arrayTitleStyle);
- $this->assertCount(1, $arrayTitleStyle);
- $this->assertArrayHasKey(1, $arrayTitleStyle);
- $this->assertNull($object->getTitleStyleAtLvl(0));
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getTitleStyleAtLvl(1));
+ self::assertIsArray($arrayTitleStyle);
+ self::assertCount(1, $arrayTitleStyle);
+ self::assertArrayHasKey(1, $arrayTitleStyle);
+ self::assertNull($object->getTitleStyleAtLvl(0));
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getTitleStyleAtLvl(1));
$oParagraph = $object->getTitleStyleAtLvl(1);
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $oParagraph);
- $this->assertEquals(Alignment::HORIZONTAL_CENTER, $oParagraph->getAlignment()->getHorizontal());
- $this->assertEquals(44, $oParagraph->getFont()->getSize());
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $oParagraph);
+ self::assertEquals(Alignment::HORIZONTAL_CENTER, $oParagraph->getAlignment()->getHorizontal());
+ self::assertEquals(44, $oParagraph->getFont()->getSize());
/** @var SchemeColor $color */
$color = $oParagraph->getFont()->getColor();
- $this->assertInstanceOf(SchemeColor::class, $color);
- $this->assertEquals('lt1', $color->getValue());
+ self::assertInstanceOf(SchemeColor::class, $color);
+ self::assertEquals('lt1', $color->getValue());
}
public function testConstructDefaultFalse(): void
{
$object = new TextStyle(false);
- $this->assertIsArray($object->getBodyStyle());
- $this->assertCount(0, $object->getBodyStyle());
- $this->assertIsArray($object->getOtherStyle());
- $this->assertCount(0, $object->getOtherStyle());
- $this->assertIsArray($object->getTitleStyle());
- $this->assertCount(0, $object->getTitleStyle());
+ self::assertIsArray($object->getBodyStyle());
+ self::assertCount(0, $object->getBodyStyle());
+ self::assertIsArray($object->getOtherStyle());
+ self::assertCount(0, $object->getOtherStyle());
+ self::assertIsArray($object->getTitleStyle());
+ self::assertCount(0, $object->getTitleStyle());
}
public function testLevel(): void
@@ -99,34 +98,34 @@ public function testLevel(): void
$object = new TextStyle(false);
$oParagraph = new Paragraph();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setBodyStyleAtLvl($oParagraph, null));
- $this->assertNull($object->getBodyStyleAtLvl(null));
- $this->assertCount(0, $object->getBodyStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setBodyStyleAtLvl($oParagraph, 10));
- $this->assertNull($object->getBodyStyleAtLvl(10));
- $this->assertCount(0, $object->getBodyStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setBodyStyleAtLvl($oParagraph, $value));
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getBodyStyleAtLvl($value));
- $this->assertCount(1, $object->getBodyStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setBodyStyleAtLvl($oParagraph, null));
+ self::assertNull($object->getBodyStyleAtLvl(null));
+ self::assertCount(0, $object->getBodyStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setBodyStyleAtLvl($oParagraph, 10));
+ self::assertNull($object->getBodyStyleAtLvl(10));
+ self::assertCount(0, $object->getBodyStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setBodyStyleAtLvl($oParagraph, $value));
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getBodyStyleAtLvl($value));
+ self::assertCount(1, $object->getBodyStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setOtherStyleAtLvl($oParagraph, null));
- $this->assertNull($object->getOtherStyleAtLvl(null));
- $this->assertCount(0, $object->getOtherStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setOtherStyleAtLvl($oParagraph, 10));
- $this->assertNull($object->getOtherStyleAtLvl(10));
- $this->assertCount(0, $object->getOtherStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setOtherStyleAtLvl($oParagraph, $value));
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getOtherStyleAtLvl($value));
- $this->assertCount(1, $object->getOtherStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setOtherStyleAtLvl($oParagraph, null));
+ self::assertNull($object->getOtherStyleAtLvl(null));
+ self::assertCount(0, $object->getOtherStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setOtherStyleAtLvl($oParagraph, 10));
+ self::assertNull($object->getOtherStyleAtLvl(10));
+ self::assertCount(0, $object->getOtherStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setOtherStyleAtLvl($oParagraph, $value));
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getOtherStyleAtLvl($value));
+ self::assertCount(1, $object->getOtherStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setTitleStyleAtLvl($oParagraph, null));
- $this->assertNull($object->getTitleStyleAtLvl(null));
- $this->assertCount(0, $object->getTitleStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setTitleStyleAtLvl($oParagraph, 10));
- $this->assertNull($object->getTitleStyleAtLvl(10));
- $this->assertCount(0, $object->getTitleStyle());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setTitleStyleAtLvl($oParagraph, $value));
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getTitleStyleAtLvl($value));
- $this->assertCount(1, $object->getTitleStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setTitleStyleAtLvl($oParagraph, null));
+ self::assertNull($object->getTitleStyleAtLvl(null));
+ self::assertCount(0, $object->getTitleStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setTitleStyleAtLvl($oParagraph, 10));
+ self::assertNull($object->getTitleStyleAtLvl(10));
+ self::assertCount(0, $object->getTitleStyle());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->setTitleStyleAtLvl($oParagraph, $value));
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\RichText\Paragraph', $object->getTitleStyleAtLvl($value));
+ self::assertCount(1, $object->getTitleStyle());
}
}
diff --git a/tests/PhpPresentation/Tests/Writer/AbstractWriter.php b/tests/PhpPresentation/Tests/Writer/AbstractWriter.php
index 7da382b974..a54b7d929e 100644
--- a/tests/PhpPresentation/Tests/Writer/AbstractWriter.php
+++ b/tests/PhpPresentation/Tests/Writer/AbstractWriter.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -32,8 +31,6 @@ class AbstractWriter extends Writer\AbstractWriter
* public wrapper for protected method.
*
* @return AbstractShape[] All drawings in PhpPresentation
- *
- * @throws \Exception
*/
public function allDrawings(): array
{
diff --git a/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php b/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php
index 101ed117ca..4dfbd2b042 100644
--- a/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php
+++ b/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -45,9 +44,9 @@ public function testConstruct(): void
/** @var ZipInterface $oStubZip */
$oStubZip = $this->getMockForAbstractClass(ZipInterface::class);
- $this->assertNull($oStubWriter->getZipAdapter());
- $this->assertInstanceOf(AbstractWriter::class, $oStubWriter->setZipAdapter($oStubZip));
- $this->assertInstanceOf(ZipInterface::class, $oStubWriter->getZipAdapter());
+ self::assertNull($oStubWriter->getZipAdapter());
+ self::assertInstanceOf(AbstractWriter::class, $oStubWriter->setZipAdapter($oStubZip));
+ self::assertInstanceOf(ZipInterface::class, $oStubWriter->getZipAdapter());
}
/**
@@ -69,6 +68,6 @@ public function testAllDrawingsIncludesMasterSlides(): void
$writer->setPhpPresentation($presentation);
$drawings = $writer->allDrawings();
- $this->assertCount(2, $drawings, 'Number of drawings should equal two: one from normal slide and one from master slide');
+ self::assertCount(2, $drawings, 'Number of drawings should equal two: one from normal slide and one from master slide');
}
}
diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php
index c67a78bc96..1e6f95324a 100644
--- a/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php
+++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,6 +35,7 @@
use PhpOffice\PhpPresentation\Style\Fill;
use PhpOffice\PhpPresentation\Style\Font;
use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase;
+use ReflectionClass;
/**
* Test class for PhpOffice\PhpPresentation\Writer\ODPresentation\Manifest.
@@ -118,7 +118,7 @@ public function testDrawingShapeFill(): void
$this->assertIsSchemaOpenDocumentNotValid('1.2');
$oColor = new Color(Color::COLOR_DARKRED);
- $oColor->setAlpha(rand(0, 100));
+ $oColor->setAlpha(mt_rand(0, 100));
$oShape->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor($oColor);
$this->resetPresentationFile();
@@ -539,7 +539,7 @@ public function testRichTextShadow(): void
if (0 == $inc || 180 == $inc || 360 == $inc) {
$this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-y', '0cm');
} else {
- if (($inc > 0 && $inc < 180) || 360 == $inc) {
+ if ($inc < 180) {
$this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-y', Drawing::pixelsToCentimeters((int) $randDistance) . 'cm');
} else {
$this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-y', '-' . Drawing::pixelsToCentimeters((int) $randDistance) . 'cm');
@@ -763,6 +763,40 @@ public function testStyleFontFormat(): void
$this->assertIsSchemaOpenDocumentValid('1.2');
}
+ public function testStyleFontCapitalization(): void
+ {
+ $oRichText = $this->oPresentation->getActiveSlide()->createRichTextShape();
+ $oRun = $oRichText->createTextRun('Run1');
+ $oRun->getFont()->setCapitalization(Font::CAPITALIZATION_ALL);
+
+ $expectedHashCode = $oRun->getHashCode();
+ $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties';
+ $this->assertZipXmlElementExists('content.xml', $element);
+ $this->assertZipXmlAttributeExists('content.xml', $element, 'fo:text-transform');
+ $this->assertZipXmlAttributeEquals('content.xml', $element, 'fo:text-transform', 'uppercase');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
+
+ $oRun->getFont()->setCapitalization(Font::CAPITALIZATION_SMALL);
+ $this->resetPresentationFile();
+
+ $expectedHashCode = $oRun->getHashCode();
+ $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties';
+ $this->assertZipXmlElementExists('content.xml', $element);
+ $this->assertZipXmlAttributeExists('content.xml', $element, 'fo:text-transform');
+ $this->assertZipXmlAttributeEquals('content.xml', $element, 'fo:text-transform', 'lowercase');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
+
+ $oRun->getFont()->setCapitalization(Font::CAPITALIZATION_NONE);
+ $this->resetPresentationFile();
+
+ $expectedHashCode = $oRun->getHashCode();
+ $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties';
+ $this->assertZipXmlElementExists('content.xml', $element);
+ $this->assertZipXmlAttributeExists('content.xml', $element, 'fo:text-transform');
+ $this->assertZipXmlAttributeEquals('content.xml', $element, 'fo:text-transform', 'none');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
+ }
+
public function testStyleFontName(): void
{
$oRichText = $this->oPresentation->getActiveSlide()->createRichTextShape();
@@ -989,7 +1023,7 @@ public function testTransition(): void
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-speed', 'slow');
$this->assertIsSchemaOpenDocumentValid('1.2');
- $rcTransition = new \ReflectionClass('PhpOffice\PhpPresentation\Slide\Transition');
+ $rcTransition = new ReflectionClass('PhpOffice\PhpPresentation\Slide\Transition');
$arrayConstants = $rcTransition->getConstants();
foreach ($arrayConstants as $key => $value) {
if (0 !== strpos($key, 'TRANSITION_')) {
@@ -1001,147 +1035,195 @@ public function testTransition(): void
switch ($key) {
case 'TRANSITION_BLINDS_HORIZONTAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'horizontal-stripes');
+
break;
case 'TRANSITION_BLINDS_VERTICAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'vertical-stripes');
+
break;
case 'TRANSITION_CHECKER_HORIZONTAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'horizontal-checkerboard');
+
break;
case 'TRANSITION_CHECKER_VERTICAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'vertical-checkerboard');
+
break;
case 'TRANSITION_CIRCLE_HORIZONTAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_CIRCLE_VERTICAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_COMB_HORIZONTAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_COMB_VERTICAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_COVER_DOWN':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'uncover-to-bottom');
+
break;
case 'TRANSITION_COVER_LEFT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'uncover-to-left');
+
break;
case 'TRANSITION_COVER_LEFT_DOWN':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'uncover-to-lowerleft');
+
break;
case 'TRANSITION_COVER_LEFT_UP':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'uncover-to-upperleft');
+
break;
case 'TRANSITION_COVER_RIGHT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'uncover-to-right');
+
break;
case 'TRANSITION_COVER_RIGHT_DOWN':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'uncover-to-lowerright');
+
break;
case 'TRANSITION_COVER_RIGHT_UP':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'uncover-to-upperright');
+
break;
case 'TRANSITION_COVER_UP':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'uncover-to-top');
+
break;
case 'TRANSITION_CUT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_DIAMOND':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_DISSOLVE':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'dissolve');
+
break;
case 'TRANSITION_FADE':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'fade-from-center');
+
break;
case 'TRANSITION_NEWSFLASH':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_PLUS':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'close');
+
break;
case 'TRANSITION_PULL_DOWN':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'stretch-from-bottom');
+
break;
case 'TRANSITION_PULL_LEFT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'stretch-from-left');
+
break;
case 'TRANSITION_PULL_RIGHT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'stretch-from-right');
+
break;
case 'TRANSITION_PULL_UP':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'stretch-from-top');
+
break;
case 'TRANSITION_PUSH_DOWN':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'roll-from-bottom');
+
break;
case 'TRANSITION_PUSH_LEFT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'roll-from-left');
+
break;
case 'TRANSITION_PUSH_RIGHT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'roll-from-right');
+
break;
case 'TRANSITION_PUSH_UP':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'roll-from-top');
+
break;
case 'TRANSITION_RANDOM':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'random');
+
break;
case 'TRANSITION_RANDOMBAR_HORIZONTAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'horizontal-lines');
+
break;
case 'TRANSITION_RANDOMBAR_VERTICAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'vertical-lines');
+
break;
case 'TRANSITION_SPLIT_IN_HORIZONTAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'close-horizontal');
+
break;
case 'TRANSITION_SPLIT_OUT_HORIZONTAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'open-horizontal');
+
break;
case 'TRANSITION_SPLIT_IN_VERTICAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'close-vertical');
+
break;
case 'TRANSITION_SPLIT_OUT_VERTICAL':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'open-vertical');
+
break;
case 'TRANSITION_STRIPS_LEFT_DOWN':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_STRIPS_LEFT_UP':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_STRIPS_RIGHT_DOWN':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_STRIPS_RIGHT_UP':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_WEDGE':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_WIPE_DOWN':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'fade-from-bottom');
+
break;
case 'TRANSITION_WIPE_LEFT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'fade-from-left');
+
break;
case 'TRANSITION_WIPE_RIGHT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'fade-from-right');
+
break;
case 'TRANSITION_WIPE_UP':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'fade-from-top');
+
break;
case 'TRANSITION_ZOOM_IN':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
case 'TRANSITION_ZOOM_OUT':
$this->assertZipXmlAttributeContains('content.xml', $element, 'presentation:transition-style', 'none');
+
break;
}
$this->assertIsSchemaOpenDocumentValid('1.2');
@@ -1192,9 +1274,9 @@ public function testShowType(string $slideshowType, bool $withAttribute): void
}
/**
- * @return array>
+ * @return array>
*/
- public function dataProviderShowType(): array
+ public static function dataProviderShowType(): array
{
return [
[
@@ -1240,7 +1322,7 @@ public function testLoopContinuouslyUntilEsc(bool $isLoopContinuouslyUntilEsc):
/**
* @return array>
*/
- public function dataProviderLoopContinuouslyUntilEsc(): array
+ public static function dataProviderLoopContinuouslyUntilEsc(): array
{
return [
[
diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaInfManifestTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaInfManifestTest.php
index 6019d6666e..223330864a 100644
--- a/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaInfManifestTest.php
+++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaInfManifestTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaTest.php
index a6a142e699..e3dd0723b1 100644
--- a/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaTest.php
+++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -31,9 +30,6 @@ class MetaTest extends PhpPresentationTestCase
* @dataProvider dataProviderCustomProperties
*
* @param mixed $propertyValue
- * @param string|null $propertyType
- * @param string $expectedValue
- * @param string $expectedValueType
*/
public function testCustomProperties($propertyValue, ?string $propertyType, string $expectedValue, string $expectedValueType): void
{
@@ -50,9 +46,9 @@ public function testCustomProperties($propertyValue, ?string $propertyType, stri
}
/**
- * @return array>
+ * @return array>
*/
- public function dataProviderCustomProperties(): array
+ public static function dataProviderCustomProperties(): array
{
$valueTime = time();
diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php
index 59e668c8ae..10115bd880 100644
--- a/tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php
+++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -95,8 +94,7 @@ public function testAxisFont(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:font-size', '16pt');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'fo:font-family', 'Arial');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testAxisTitleRotation(): void
@@ -115,10 +113,9 @@ public function testAxisTitleRotation(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'style:rotation-angle');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
- $value = rand(1, 360);
+ $value = mt_rand(1, 360);
$oShape->getPlotArea()->getAxisX()->setTitleRotation($value);
$this->resetPresentationFile();
@@ -127,8 +124,7 @@ public function testAxisTitleRotation(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'style:rotation-angle');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'style:rotation-angle', '-' . $value);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testAxisVisibility(): void
@@ -156,8 +152,7 @@ public function testAxisVisibility(): void
$this->assertZipXmlElementNotExists('Object 1/content.xml', $element);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oShape->getPlotArea()->getAxisX()->setIsVisible(true);
$oShape->getPlotArea()->getAxisY()->setIsVisible(true);
@@ -183,8 +178,7 @@ public function testAxisVisibility(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlElementEquals('Object 1/content.xml', $element, 'Axis Y');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testChartDisplayBlankAs(): void
@@ -203,8 +197,7 @@ public function testChartDisplayBlankAs(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:treat-empty-cells');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:treat-empty-cells', 'use-zero');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$this->resetPresentationFile();
$oShape->setDisplayBlankAs(Chart::BLANKAS_SPAN);
@@ -213,8 +206,7 @@ public function testChartDisplayBlankAs(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:treat-empty-cells');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:treat-empty-cells', 'ignore');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$this->resetPresentationFile();
$oShape->setDisplayBlankAs(Chart::BLANKAS_GAP);
@@ -223,8 +215,7 @@ public function testChartDisplayBlankAs(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:treat-empty-cells');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:treat-empty-cells', 'leave-gap');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testLegend(): void
@@ -250,8 +241,7 @@ public function testLegend(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row/table:table-cell[@office:value-type=\'string\']';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oChart->getLegend()->setPosition(Legend::POSITION_RIGHT);
$this->resetPresentationFile();
@@ -259,8 +249,7 @@ public function testLegend(): void
$element = '/office:document-content/office:body/office:chart/chart:chart/chart:legend';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:legend-position', 'end');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oChart->getLegend()->setPosition(Legend::POSITION_LEFT);
$this->resetPresentationFile();
@@ -268,8 +257,7 @@ public function testLegend(): void
$element = '/office:document-content/office:body/office:chart/chart:chart/chart:legend';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:legend-position', 'start');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oChart->getLegend()->setPosition(Legend::POSITION_BOTTOM);
$this->resetPresentationFile();
@@ -277,8 +265,7 @@ public function testLegend(): void
$element = '/office:document-content/office:body/office:chart/chart:chart/chart:legend';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:legend-position', 'bottom');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oChart->getLegend()->setPosition(Legend::POSITION_TOP);
$this->resetPresentationFile();
@@ -286,8 +273,7 @@ public function testLegend(): void
$element = '/office:document-content/office:body/office:chart/chart:chart/chart:legend';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:legend-position', 'top');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oChart->getLegend()->setPosition(Legend::POSITION_TOPRIGHT);
$this->resetPresentationFile();
@@ -295,8 +281,7 @@ public function testLegend(): void
$element = '/office:document-content/office:body/office:chart/chart:chart/chart:legend';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:legend-position', 'top-end');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testSeriesValues(): void
@@ -321,8 +306,7 @@ public function testSeriesValues(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlElementEquals('Object 1/content.xml', $element, 'NaN');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$this->resetPresentationFile();
@@ -341,8 +325,7 @@ public function testSeriesValues(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlElementEquals('Object 1/content.xml', $element, '12.3');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$this->resetPresentationFile();
@@ -360,8 +343,7 @@ public function testSeriesValues(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlElementEquals('Object 1/content.xml', $element, 'data');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testSeriesShowConfig(): void
@@ -379,8 +361,7 @@ public function testSeriesShowConfig(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:data-label-number');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'value');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-text');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->setShowValue(false);
$this->resetPresentationFile();
@@ -389,8 +370,7 @@ public function testSeriesShowConfig(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-number');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-text');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
// $showCategoryName = false / $showPercentage = true / $showValue = true
$oSeries->setShowValue(true);
@@ -401,8 +381,7 @@ public function testSeriesShowConfig(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:data-label-number');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'value-and-percentage');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-text');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
// $showCategoryName = false / $showPercentage = true / $showValue = false
$oSeries->setShowValue(false);
@@ -412,8 +391,7 @@ public function testSeriesShowConfig(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:data-label-number');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'percentage');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:data-label-text');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
// $showCategoryName = false / $showPercentage = true / $showValue = false
$oSeries->setShowCategoryName(true);
@@ -422,8 +400,7 @@ public function testSeriesShowConfig(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:data-label-text');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-text', 'true');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTitleVisibility(): void
@@ -435,21 +412,19 @@ public function testTitleVisibility(): void
$elementTitle = '/office:document-content/office:body/office:chart/chart:chart/chart:title';
$elementStyle = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleTitle\']';
- $this->assertTrue($oShape->getTitle()->isVisible());
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(true));
+ self::assertTrue($oShape->getTitle()->isVisible());
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(true));
$this->assertZipXmlElementExists('Object 1/content.xml', $elementTitle);
$this->assertZipXmlElementExists('Object 1/content.xml', $elementStyle);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(false));
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(false));
$this->resetPresentationFile();
$this->assertZipXmlElementNotExists('Object 1/content.xml', $elementTitle);
$this->assertZipXmlElementNotExists('Object 1/content.xml', $elementStyle);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeArea(): void
@@ -474,8 +449,7 @@ public function testTypeArea(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'draw:fill-color');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'draw:fill-color', '#93A9CE');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeAxisBounds(): void
@@ -493,8 +467,7 @@ public function testTypeAxisBounds(): void
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:minimum');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:maximum');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oShape->getPlotArea()->getAxisX()->setMinBounds($value);
$this->resetPresentationFile();
@@ -503,8 +476,7 @@ public function testTypeAxisBounds(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:minimum');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:minimum', $value);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oShape->getPlotArea()->getAxisX()->setMinBounds(null);
$oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
@@ -514,8 +486,7 @@ public function testTypeAxisBounds(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:maximum');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:maximum', $value);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oShape->getPlotArea()->getAxisX()->setMinBounds($value);
$oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
@@ -526,8 +497,7 @@ public function testTypeAxisBounds(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:maximum');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:maximum', $value);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeAxisOutline(): void
@@ -547,8 +517,7 @@ public function testTypeAxisOutline(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'svg:stroke-color');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'svg:stroke-color', '#000000');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$this->resetPresentationFile();
$shape->getPlotArea()->getAxisX()->getOutline()->setWidth(10);
@@ -562,8 +531,7 @@ public function testTypeAxisOutline(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'svg:stroke-color');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'svg:stroke-color', '#ABCDEF');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeAxisTickLabelPosition(): void
@@ -581,8 +549,7 @@ public function testTypeAxisTickLabelPosition(): void
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:axis-position');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:tick-mark-position');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$this->resetPresentationFile();
$oShape->getPlotArea()->getAxisX()->setTickLabelPosition(Axis::TICK_LABEL_POSITION_HIGH);
@@ -593,8 +560,7 @@ public function testTypeAxisTickLabelPosition(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:axis-position', '0');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:tick-mark-position');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$this->resetPresentationFile();
$oShape->getPlotArea()->getAxisX()->setTickLabelPosition(Axis::TICK_LABEL_POSITION_LOW);
@@ -606,8 +572,7 @@ public function testTypeAxisTickLabelPosition(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:tick-mark-position');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:tick-mark-position', 'at-axis');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeAxisUnit(): void
@@ -625,8 +590,7 @@ public function testTypeAxisUnit(): void
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:interval-minor-divisor');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:interval-major');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$shape->getPlotArea()->getAxisX()->setMinorUnit($value);
$this->resetPresentationFile();
@@ -635,8 +599,7 @@ public function testTypeAxisUnit(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:interval-minor-divisor');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:interval-minor-divisor', $value);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$shape->getPlotArea()->getAxisX()->setMinorUnit(null);
$shape->getPlotArea()->getAxisX()->setMajorUnit($value);
@@ -646,8 +609,7 @@ public function testTypeAxisUnit(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:interval-major');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:interval-major', $value);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$shape->getPlotArea()->getAxisX()->setMinorUnit($value);
$shape->getPlotArea()->getAxisX()->setMajorUnit($value);
@@ -658,8 +620,7 @@ public function testTypeAxisUnit(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:interval-major');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:interval-major', $value);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeBar(): void
@@ -691,8 +652,7 @@ public function testTypeBar(): void
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:percentage');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'value');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeBarGroupingStacked(): void
@@ -710,8 +670,7 @@ public function testTypeBarGroupingStacked(): void
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:percentage');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'value');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeBarGroupingPercentStacked(): void
@@ -729,8 +688,7 @@ public function testTypeBarGroupingPercentStacked(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:percentage', 'true');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:data-label-number', 'percentage');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeBarHorizontal(): void
@@ -756,8 +714,7 @@ public function testTypeBarHorizontal(): void
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:three-dimensional');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:right-angled-axes');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeBar3D(): void
@@ -787,8 +744,7 @@ public function testTypeBar3D(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:right-angled-axes');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:right-angled-axes', 'true');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeBar3DHorizontal(): void
@@ -816,8 +772,7 @@ public function testTypeBar3DHorizontal(): void
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:right-angled-axes');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:right-angled-axes', 'true');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeDoughnut(): void
@@ -843,8 +798,7 @@ public function testTypeDoughnut(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:ring');
$element = '/office:document-content/office:automatic-styles/style:style/style:chart-properties/chart:label-separator/text:p';
$this->assertZipXmlElementNotExists('Object 1/content.xml', $element);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
// $oDoughnut->setHoleSize($randHoleSize);
// $this->resetPresentationFile();
@@ -855,8 +809,7 @@ public function testTypeDoughnut(): void
$element = '/office:document-content/office:automatic-styles/style:style/style:chart-properties/chart:label-separator/text:p';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlElementEquals('Object 1/content.xml', $element, $randSeparator);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeLine(): void
@@ -892,8 +845,7 @@ public function testTypeLine(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'svg:stroke-width', '0.035cm');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'svg:stroke-color', '#000000');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeLineGridlines(): void
@@ -961,8 +913,7 @@ public function testTypeLineGridlines(): void
$this->assertZipXmlAttributeStartsWith('Object 1/content.xml', $expectedElementStyle, 'svg:stroke-color', '#');
$this->assertZipXmlAttributeEndsWith('Object 1/content.xml', $expectedElementStyle, 'svg:stroke-color', $expectedColor->getRGB());
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
}
@@ -991,8 +942,7 @@ public function testTypeLineMarker(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-width', $expectedSizeCm);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-height', $expectedSizeCm);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->getMarker()->setSymbol($expectedSymbol2);
$oLine->setSeries([$oSeries]);
@@ -1000,8 +950,7 @@ public function testTypeLineMarker(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'horizontal-bar');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->getMarker()->setSymbol($expectedSymbol3);
$oLine->setSeries([$oSeries]);
@@ -1009,8 +958,7 @@ public function testTypeLineMarker(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'circle');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->getMarker()->setSymbol($expectedSymbol4);
$oLine->setSeries([$oSeries]);
@@ -1018,8 +966,7 @@ public function testTypeLineMarker(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'arrow-up');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->getMarker()->setSymbol($expectedSymbol5);
$oLine->setSeries([$oSeries]);
@@ -1029,14 +976,13 @@ public function testTypeLineMarker(): void
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-width');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-height');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeLineSeriesOutline(): void
{
$expectedWidth = mt_rand(1, 100);
- $expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
+ $expectedWidthCm = number_format(CommonDrawing::pixelsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
$expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties';
@@ -1059,8 +1005,7 @@ public function testTypeLineSeriesOutline(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', '0.079cm');
$this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#4a7ebb');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->setOutline($oOutline);
$oLine->setSeries([$oSeries]);
@@ -1072,8 +1017,7 @@ public function testTypeLineSeriesOutline(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', $expectedWidthCm);
$this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#' . $oColor->getRGB());
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeLineSmooth(): void
@@ -1092,8 +1036,7 @@ public function testTypeLineSmooth(): void
$this->assertZipFileExists('Object 1/content.xml');
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:interpolation');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$this->resetPresentationFile();
$oLine->setIsSmooth(true);
@@ -1103,8 +1046,7 @@ public function testTypeLineSmooth(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:interpolation');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:interpolation', 'cubic-spline');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypePie(): void
@@ -1134,8 +1076,7 @@ public function testTypePie(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:reverse-direction', 'true');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypePie3D(): void
@@ -1165,8 +1106,7 @@ public function testTypePie3D(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:reverse-direction', 'true');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypePie3DExplosion(): void
@@ -1184,8 +1124,7 @@ public function testTypePie3DExplosion(): void
$element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:chart-properties';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:pie-offset', $value);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeRadar(): void
@@ -1210,14 +1149,13 @@ public function testTypeRadar(): void
$element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleAxisY\']/style:chart-properties';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:reverse-direction');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeRadarSeriesOutline(): void
{
$expectedWidth = mt_rand(1, 100);
- $expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
+ $expectedWidthCm = number_format(CommonDrawing::pixelsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
$expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties';
@@ -1241,8 +1179,7 @@ public function testTypeRadarSeriesOutline(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', '0.079cm');
$this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#4a7ebb');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$series->setOutline($outline);
$radarChart->setSeries([$series]);
@@ -1254,8 +1191,7 @@ public function testTypeRadarSeriesOutline(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', $expectedWidthCm);
$this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#' . $color->getRGB());
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeScatter(): void
@@ -1270,8 +1206,7 @@ public function testTypeScatter(): void
$element = '/office:document-content/office:body/office:chart/chart:chart';
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:class', 'chart:scatter');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeScatterMarker(): void
@@ -1298,8 +1233,7 @@ public function testTypeScatterMarker(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-width', $expectedSizeCm);
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-height', $expectedSizeCm);
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->getMarker()->setSymbol($expectedSymbol2);
$oScatter->setSeries([$oSeries]);
@@ -1307,8 +1241,7 @@ public function testTypeScatterMarker(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'horizontal-bar');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->getMarker()->setSymbol($expectedSymbol3);
$oScatter->setSeries([$oSeries]);
@@ -1316,8 +1249,7 @@ public function testTypeScatterMarker(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'circle');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->getMarker()->setSymbol($expectedSymbol4);
$oScatter->setSeries([$oSeries]);
@@ -1325,8 +1257,7 @@ public function testTypeScatterMarker(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'chart:symbol-name', 'arrow-up');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->getMarker()->setSymbol($expectedSymbol5);
$oScatter->setSeries([$oSeries]);
@@ -1336,14 +1267,13 @@ public function testTypeScatterMarker(): void
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-width');
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $expectedElement, 'chart:symbol-height');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeScatterSeriesOutline(): void
{
$expectedWidth = mt_rand(1, 100);
- $expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
+ $expectedWidthCm = number_format(CommonDrawing::pixelsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
$expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties';
@@ -1365,8 +1295,7 @@ public function testTypeScatterSeriesOutline(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', '0.079cm');
$this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#4a7ebb');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$oSeries->setOutline($oOutline);
$oScatter->setSeries([$oSeries]);
@@ -1378,8 +1307,7 @@ public function testTypeScatterSeriesOutline(): void
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-width', $expectedWidthCm);
$this->assertZipXmlAttributeExists('Object 1/content.xml', $expectedElement, 'svg:stroke-color');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $expectedElement, 'svg:stroke-color', '#' . $oColor->getRGB());
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
public function testTypeScatterSmooth(): void
@@ -1398,8 +1326,7 @@ public function testTypeScatterSmooth(): void
$this->assertZipFileExists('Object 1/content.xml');
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeNotExists('Object 1/content.xml', $element, 'chart:interpolation');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
$this->resetPresentationFile();
$scatter->setIsSmooth(true);
@@ -1409,7 +1336,6 @@ public function testTypeScatterSmooth(): void
$this->assertZipXmlElementExists('Object 1/content.xml', $element);
$this->assertZipXmlAttributeExists('Object 1/content.xml', $element, 'chart:interpolation');
$this->assertZipXmlAttributeEquals('Object 1/content.xml', $element, 'chart:interpolation', 'cubic-spline');
- // chart:title : Element chart failed to validate attributes
- $this->assertIsSchemaOpenDocumentNotValid('1.2');
+ $this->assertIsSchemaOpenDocumentValid('1.2');
}
}
diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/StylesTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/StylesTest.php
index 523087adfd..a6332b6382 100644
--- a/tests/PhpPresentation/Tests/Writer/ODPresentation/StylesTest.php
+++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/StylesTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -59,7 +58,7 @@ public function testDocumentLayout(): void
public function testCustomDocumentLayout(): void
{
$oDocumentLayout = new DocumentLayout();
- $oDocumentLayout->setDocumentLayout(['cx' => rand(1, 100), 'cy' => rand(1, 100)]);
+ $oDocumentLayout->setDocumentLayout(['cx' => mt_rand(1, 100), 'cy' => mt_rand(1, 100)]);
$this->oPresentation->setLayout($oDocumentLayout);
$element = '/office:document-styles/office:automatic-styles/style:page-layout';
@@ -118,12 +117,14 @@ public function testStrokeDash(): void
case Border::DASH_SYSDOT:
$this->assertZipXmlAttributeExists('styles.xml', $element, 'draw:dots1');
$this->assertZipXmlAttributeExists('styles.xml', $element, 'draw:dots1-length');
+
break;
case Border::DASH_DASH:
case Border::DASH_LARGEDASH:
case Border::DASH_SYSDASH:
$this->assertZipXmlAttributeExists('styles.xml', $element, 'draw:dots2');
$this->assertZipXmlAttributeExists('styles.xml', $element, 'draw:dots2-length');
+
break;
case Border::DASH_DASHDOT:
case Border::DASH_LARGEDASHDOT:
@@ -134,6 +135,7 @@ public function testStrokeDash(): void
$this->assertZipXmlAttributeExists('styles.xml', $element, 'draw:dots1-length');
$this->assertZipXmlAttributeExists('styles.xml', $element, 'draw:dots2');
$this->assertZipXmlAttributeExists('styles.xml', $element, 'draw:dots2-length');
+
break;
}
$this->assertIsSchemaOpenDocumentValid('1.2');
diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentationTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentationTest.php
index ba8724708d..52f4e47c97 100644
--- a/tests/PhpPresentation/Tests/Writer/ODPresentationTest.php
+++ b/tests/PhpPresentation/Tests/Writer/ODPresentationTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -43,9 +42,9 @@ public function testConstruct(): void
$this->oPresentation->getActiveSlide()->createDrawingShape();
$object = new ODPresentation($this->oPresentation);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->getPhpPresentation());
- $this->assertEquals('./', $object->getDiskCachingDirectory());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\HashTable', $object->getDrawingHashTable());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->getPhpPresentation());
+ self::assertEquals('./', $object->getDiskCachingDirectory());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\HashTable', $object->getDrawingHashTable());
}
/**
@@ -66,7 +65,7 @@ public function testSave(): void
$object = new ODPresentation($this->oPresentation);
$object->save($filename);
- $this->assertTrue(file_exists($filename));
+ self::assertFileExists($filename);
unlink($filename);
}
@@ -89,11 +88,11 @@ public function testSaveEmpty(): void
public function testSetGetUseDiskCaching(): void
{
$object = new ODPresentation($this->oPresentation);
- $this->assertFalse($object->hasDiskCaching());
+ self::assertFalse($object->hasDiskCaching());
$object->setUseDiskCaching(true, sys_get_temp_dir());
- $this->assertTrue($object->hasDiskCaching());
- $this->assertEquals(sys_get_temp_dir(), $object->getDiskCachingDirectory());
+ self::assertTrue($object->hasDiskCaching());
+ self::assertEquals(sys_get_temp_dir(), $object->getDiskCachingDirectory());
}
/**
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/CommentAuthorsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/CommentAuthorsTest.php
index 18552dbbc9..6fdf967f66 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/CommentAuthorsTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/CommentAuthorsTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsAppTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsAppTest.php
index fc9ba5aefa..3ec8812f24 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsAppTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsAppTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCoreTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCoreTest.php
index 2f7f87732c..5c79a1ee88 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCoreTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCoreTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,13 +25,6 @@ class DocPropsCoreTest extends PhpPresentationTestCase
{
protected $writerName = 'PowerPoint2007';
- public function testRender(): void
- {
- $this->assertZipFileExists('docProps/core.xml');
- $this->assertZipXmlElementNotExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
- $this->assertIsSchemaECMA376Valid();
- }
-
public function testDocumentProperties(): void
{
$expected = 'aAbBcDeE';
@@ -43,7 +35,9 @@ public function testDocumentProperties(): void
->setDescription($expected)
->setSubject($expected)
->setKeywords($expected)
- ->setCategory($expected);
+ ->setCategory($expected)
+ ->setRevision($expected)
+ ->setStatus($expected);
$this->assertZipFileExists('docProps/core.xml');
$this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/dc:creator');
@@ -58,6 +52,10 @@ public function testDocumentProperties(): void
$this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:keywords', $expected);
$this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:category');
$this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:category', $expected);
+ $this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:revision');
+ $this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:revision', $expected);
+ $this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
+ $this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:contentStatus', $expected);
$this->assertIsSchemaECMA376Valid();
}
@@ -74,7 +72,8 @@ public function testMarkAsFinalFalse(): void
{
$this->oPresentation->getPresentationProperties()->markAsFinal(false);
- $this->assertZipXmlElementNotExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
+ $this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
+ $this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:contentStatus', '');
$this->assertIsSchemaECMA376Valid();
}
}
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCustomTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCustomTest.php
index 057b2b8397..098f72a339 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCustomTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCustomTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsThumbnailTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsThumbnailTest.php
index c65bba64ec..ddab8a1ccd 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsThumbnailTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsThumbnailTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,6 +19,7 @@
namespace PhpPresentation\Tests\Writer\PowerPoint2007;
+use PhpOffice\PhpPresentation\PresentationProperties;
use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase;
/**
@@ -32,15 +32,40 @@ class DocPropsThumbnailTest extends PhpPresentationTestCase
public function testRender(): void
{
$this->assertZipFileNotExists('docProps/thumbnail.jpeg');
+ $this->assertZipXmlElementNotExists('_rels/.rels', '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"]');
$this->assertIsSchemaECMA376Valid();
}
- public function testFeatureThumbnail(): void
+ public function testFeatureThumbnailFile(): void
{
$imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
- $this->oPresentation->getPresentationProperties()->setThumbnailPath($imagePath);
+ $this->oPresentation->getPresentationProperties()
+ ->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_FILE);
$this->assertZipFileExists('docProps/thumbnail.jpeg');
+ $this->assertZipXmlElementExists('_rels/.rels', '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"]');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
+ public function testFeatureThumbnailFileNotExisting(): void
+ {
+ $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'NotExistingFile.png';
+
+ $this->oPresentation->getPresentationProperties()
+ ->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_FILE);
+ $this->assertZipFileNotExists('docProps/thumbnail.jpeg');
+ $this->assertZipXmlElementNotExists('_rels/.rels', '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"]');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
+ public function testFeatureThumbnailData(): void
+ {
+ $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
+
+ $this->oPresentation->getPresentationProperties()
+ ->setThumbnailPath('', PresentationProperties::THUMBNAIL_DATA, file_get_contents($imagePath));
+ $this->assertZipFileExists('docProps/thumbnail.jpeg');
+ $this->assertZipXmlElementExists('_rels/.rels', '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"]');
$this->assertIsSchemaECMA376Valid();
}
}
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php
index a7a2fb53b7..97200913e3 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -100,17 +99,93 @@ public function testChartDisplayBlankAs(): void
$this->assertIsSchemaECMA376Valid();
}
- public function testChartIncludeSpreadsheet(): void
+ /**
+ * @dataProvider dataProviderIncludedSpreadsheet
+ */
+ public function testChartIncludeSpreadsheetNullValue(string $chartType, string $chartElementName): void
{
+ $seriesData = array_merge(['Z' => null], $this->seriesData);
+
$oSlide = $this->oPresentation->getActiveSlide();
$oShape = $oSlide->createChartShape();
$oShape->setIncludeSpreadsheet(true);
- $oLine = new Line();
+ /** @var AbstractType $oChart */
+ $oChart = new $chartType();
+ $oSeries = new Series('Downloads', $seriesData);
+ $oChart->addSeries($oSeries);
+ $oShape->getPlotArea()->setType($oChart);
+
+ $chartBaseXmlPath = sprintf('/c:chartSpace/c:chart/c:plotArea/%s', $chartElementName);
+
+ self::assertTrue($oShape->hasIncludedSpreadsheet());
+
+ $this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
+ $this->assertZipFileExists('ppt/embeddings/' . $oShape->getIndexedFilename() . '.xlsx');
+
+ $this->assertZipFileExists('ppt/charts/_rels/' . $oShape->getIndexedFilename() . '.rels');
+ $element = '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"]';
+ $this->assertZipXmlElementExists('ppt/charts/_rels/' . $oShape->getIndexedFilename() . '.rels', $element);
+
+ $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $element = $chartBaseXmlPath;
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:ser';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $this->assertZipXmlElementCount('ppt/charts/' . $oShape->getIndexedFilename(), $element, 1);
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:v';
+ $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef/c:f';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'Sheet1!$B$1');
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef/c:strCache';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef/c:strCache/c:pt';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef/c:strCache/c:pt/c:v';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'Downloads');
+
+ $element = $chartBaseXmlPath . '/c:ser/c:val/c:numRef/c:numCache/c:pt/c:v';
+ if ($oChart instanceof Scatter) {
+ $element = $chartBaseXmlPath . '/c:ser/c:yVal/c:numRef/c:numCache/c:pt/c:v';
+ }
+ $this->assertZipXmlElementCount('ppt/charts/' . $oShape->getIndexedFilename(), $element, count($seriesData));
+ foreach (array_values($seriesData) as $index => $value) {
+ $this->assertZipXmlElementAtIndexEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $index, $value);
+ }
+
+ $element = '/c:chartSpace/c:externalData';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $this->assertZipXmlAttributeExists('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'r:id');
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'r:id', 'rId1');
+ $element = '/c:chartSpace/c:externalData/c:autoUpdate';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $this->assertZipXmlAttributeExists('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val');
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '0');
+
+ $this->assertIsSchemaECMA376Valid();
+ }
+
+ /**
+ * @dataProvider dataProviderIncludedSpreadsheet
+ */
+ public function testChartIncludeSpreadsheet(string $chartType, string $chartElementName): void
+ {
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oShape = $oSlide->createChartShape();
+ $oShape->setIncludeSpreadsheet(true);
+ /** @var AbstractType $oChart */
+ $oChart = new $chartType();
$oSeries = new Series('Downloads', $this->seriesData);
- $oLine->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oLine);
+ $oChart->addSeries($oSeries);
+ $oShape->getPlotArea()->setType($oChart);
+
+ $chartBaseXmlPath = sprintf('/c:chartSpace/c:chart/c:plotArea/%s', $chartElementName);
- $this->assertTrue($oShape->hasIncludedSpreadsheet());
+ self::assertTrue($oShape->hasIncludedSpreadsheet());
$this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
$this->assertZipFileExists('ppt/embeddings/' . $oShape->getIndexedFilename() . '.xlsx');
@@ -121,24 +196,35 @@ public function testChartIncludeSpreadsheet(): void
$element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart';
+ $element = $chartBaseXmlPath;
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser';
+ $element = $chartBaseXmlPath . '/c:ser';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:tx/c:v';
+ $this->assertZipXmlElementCount('ppt/charts/' . $oShape->getIndexedFilename(), $element, 1);
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:v';
$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:tx/c:strRef';
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:tx/c:strRef/c:f';
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef/c:f';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'Sheet1!$A$1');
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:tx/c:strRef/c:strCache';
+ $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'Sheet1!$B$1');
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef/c:strCache';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:tx/c:strRef/c:strCache/c:pt';
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef/c:strCache/c:pt';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:tx/c:strRef/c:strCache/c:pt/c:v';
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:strRef/c:strCache/c:pt/c:v';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'Downloads');
+
+ $element = $chartBaseXmlPath . '/c:ser/c:val/c:numRef/c:numCache/c:pt/c:v';
+ if ($oChart instanceof Scatter) {
+ $element = $chartBaseXmlPath . '/c:ser/c:yVal/c:numRef/c:numCache/c:pt/c:v';
+ }
+ $this->assertZipXmlElementCount('ppt/charts/' . $oShape->getIndexedFilename(), $element, count($this->seriesData));
+ foreach (array_values($this->seriesData) as $index => $value) {
+ $this->assertZipXmlElementAtIndexEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $index, $value);
+ }
+
$element = '/c:chartSpace/c:externalData';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeExists('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'r:id');
@@ -153,7 +239,7 @@ public function testChartIncludeSpreadsheet(): void
$this->resetPresentationFile();
$oShape->setIncludeSpreadsheet(false);
- $this->assertFalse($oShape->hasIncludedSpreadsheet());
+ self::assertFalse($oShape->hasIncludedSpreadsheet());
$this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
$this->assertZipFileNotExists('ppt/charts/_rels/' . $oShape->getIndexedFilename() . '.rels');
@@ -161,11 +247,11 @@ public function testChartIncludeSpreadsheet(): void
$element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart';
+ $element = $chartBaseXmlPath;
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser';
+ $element = $chartBaseXmlPath . '/c:ser';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:tx/c:v';
+ $element = $chartBaseXmlPath . '/c:ser/c:tx/c:v';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'Downloads');
$element = '/c:chartSpace/c:externalData';
@@ -199,11 +285,11 @@ public function testTitleVisibilityTrue(): void
$oShape->getPlotArea()->setType($oLine);
// Default
- $this->assertTrue($oShape->getTitle()->isVisible());
+ self::assertTrue($oShape->getTitle()->isVisible());
// Set Visible : TRUE
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(true));
- $this->assertTrue($oShape->getTitle()->isVisible());
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(true));
+ self::assertTrue($oShape->getTitle()->isVisible());
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '0');
$this->assertIsSchemaECMA376Valid();
@@ -219,8 +305,8 @@ public function testTitleVisibilityFalse(): void
$oShape->getPlotArea()->setType($oLine);
// Set Visible : FALSE
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(false));
- $this->assertFalse($oShape->getTitle()->isVisible());
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(false));
+ self::assertFalse($oShape->getTitle()->isVisible());
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '1');
$this->assertIsSchemaECMA376Valid();
@@ -276,6 +362,135 @@ public function testAxisBounds(): void
$this->assertIsSchemaECMA376Valid();
}
+ public function testAxisBoundsIfZero(): void
+ {
+ $value = 0;
+
+ $oSeries = new Series('Downloads', $this->seriesData);
+ $oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
+ $oLine = new Line();
+ $oLine->addSeries($oSeries);
+ $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
+ $oShape->getPlotArea()->setType($oLine);
+
+ $elementMax = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:scaling/c:max';
+ $elementMin = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:scaling/c:min';
+
+ $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
+ $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
+
+ $this->assertIsSchemaECMA376Valid();
+
+ $oShape->getPlotArea()->getAxisX()->setMinBounds($value);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', $value);
+
+ $this->assertIsSchemaECMA376Valid();
+
+ $oShape->getPlotArea()->getAxisX()->setMinBounds(null);
+ $oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', $value);
+
+ $this->assertIsSchemaECMA376Valid();
+
+ $oShape->getPlotArea()->getAxisX()->setMinBounds($value);
+ $oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', $value);
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', $value);
+
+ $this->assertIsSchemaECMA376Valid();
+ }
+
+ public function testAxisCrosses(): void
+ {
+ $oSeries = new Series('Downloads', $this->seriesData);
+ $oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
+ $oLine = new Line();
+ $oLine->addSeries($oSeries);
+ $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
+ $oShape->getPlotArea()->setType($oLine);
+
+ $elementCrosses = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:crosses';
+ $elementCrossesAt = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:crossesAt';
+ $elementAxPos = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:axPos';
+
+ // Default autoZero
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementCrosses);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementCrosses, 'val', 'autoZero');
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementAxPos, 'val', 'b');
+ $this->assertIsSchemaECMA376Valid();
+
+ // Crosses max
+ $oShape->getPlotArea()->getAxisX()->setCrossesAt(Axis::CROSSES_MAX);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementCrosses);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementCrosses, 'val', 'max');
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementAxPos, 'val', 't');
+ $this->assertIsSchemaECMA376Valid();
+
+ // Crosses min
+ $oShape->getPlotArea()->getAxisX()->setCrossesAt(Axis::CROSSES_MIN);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementCrosses);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementCrosses, 'val', 'min');
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementAxPos, 'val', 'b');
+ $this->assertIsSchemaECMA376Valid();
+
+ // Crosses custom value
+ $oShape->getPlotArea()->getAxisX()->setCrossesAt('10');
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementCrosses);
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementCrossesAt);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementCrossesAt, 'val', '10');
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementAxPos, 'val', 'b');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
+ public function testIsReversedOrder(): void
+ {
+ $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:scaling/c:orientation';
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oShape = $oSlide->createChartShape();
+ $oLine = new Line();
+ $oShape->getPlotArea()->setType($oLine);
+
+ // default
+ self::assertFalse($oShape->getPlotArea()->getAxisX()->isReversedOrder());
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 'minMax');
+ $this->assertIsSchemaECMA376Valid();
+
+ // reversed order
+ self::assertInstanceOf(Axis::class, $oShape->getPlotArea()->getAxisX()->setIsReversedOrder(true));
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 'maxMin');
+ $this->assertIsSchemaECMA376Valid();
+
+ // reset reversed order
+ self::assertInstanceOf(Axis::class, $oShape->getPlotArea()->getAxisX()->setIsReversedOrder(false));
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 'minMax');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
public function testAxisFont(): void
{
$oSlide = $this->oPresentation->getActiveSlide();
@@ -303,6 +518,14 @@ public function testAxisFont(): void
$this->assertZipXmlAttributeEquals($pathShape, $element, 'strike', 'sngStrike');
$this->assertZipXmlAttributeEquals($pathShape, $element, 'u', Font::UNDERLINE_NONE);
+ $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:latin';
+ $this->assertZipXmlElementExists($pathShape, $element);
+ $this->assertZipXmlAttributeEquals($pathShape, $element, 'typeface', 'Calibri');
+
+ $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:ea';
+ $this->assertZipXmlElementExists($pathShape, $element);
+ $this->assertZipXmlAttributeEquals($pathShape, $element, 'typeface', 'Calibri');
+
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr';
$this->assertZipXmlElementExists($pathShape, $element);
$this->assertZipXmlAttributeEquals($pathShape, $element, 'val', '00FF00');
@@ -314,6 +537,14 @@ public function testAxisFont(): void
$this->assertZipXmlAttributeEquals($pathShape, $element, 'strike', 'noStrike');
$this->assertZipXmlAttributeEquals($pathShape, $element, 'u', Font::UNDERLINE_DASH);
+ $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:latin';
+ $this->assertZipXmlElementExists($pathShape, $element);
+ $this->assertZipXmlAttributeEquals($pathShape, $element, 'typeface', 'Calibri');
+
+ $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:ea';
+ $this->assertZipXmlElementExists($pathShape, $element);
+ $this->assertZipXmlAttributeEquals($pathShape, $element, 'typeface', 'Calibri');
+
$this->assertIsSchemaECMA376Valid();
}
@@ -341,7 +572,7 @@ public function testAxisOutline(): void
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pointsToEmu($expectedWidthX));
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu($expectedWidthX));
$element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln/a:solidFill/a:srgbClr';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorX);
@@ -349,7 +580,7 @@ public function testAxisOutline(): void
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pointsToEmu($expectedWidthY));
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu($expectedWidthY));
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln/a:solidFill/a:srgbClr';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorY);
@@ -357,6 +588,26 @@ public function testAxisOutline(): void
$this->assertIsSchemaECMA376Valid();
}
+ public function testAxisTickLabelFont(): void
+ {
+ $oLine = new Line();
+ $oLine->addSeries(new Series('Downloads', $this->seriesData));
+ $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
+ $oShape->getPlotArea()->setType($oLine);
+ $oShape->getPlotArea()->getAxisY()->getTickLabelFont()->setName('RandomFont');
+
+ $pathShape = 'ppt/charts/' . $oShape->getIndexedFilename();
+ $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr/a:latin';
+ $this->assertZipXmlElementExists($pathShape, $element);
+ $this->assertZipXmlAttributeEquals($pathShape, $element, 'typeface', 'RandomFont');
+
+ $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:txPr/a:p/a:pPr/a:defRPr/a:ea';
+ $this->assertZipXmlElementExists($pathShape, $element);
+ $this->assertZipXmlAttributeEquals($pathShape, $element, 'typeface', 'RandomFont');
+
+ $this->assertIsSchemaECMA376Valid();
+ }
+
public function testAxisTickLabelPosition(): void
{
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:tickLblPos';
@@ -459,7 +710,7 @@ public function testAxisTitleRotation(): void
$this->assertZipXmlAttributeNotExists($pathShape, $element, 'rot');
$this->resetPresentationFile();
- $value = rand(0, 360);
+ $value = mt_rand(0, 360);
$oShape->getPlotArea()->getAxisX()->setTitleRotation($value);
$pathShape = 'ppt/charts/' . $oShape->getIndexedFilename();
@@ -479,8 +730,8 @@ public function testAxisVisibility(): void
$oShape->getPlotArea()->setType($oLine);
// Set Visible : FALSE
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(false));
- $this->assertFalse($oShape->getPlotArea()->getAxisX()->isVisible());
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(false));
+ self::assertFalse($oShape->getPlotArea()->getAxisX()->isVisible());
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '1');
@@ -489,8 +740,8 @@ public function testAxisVisibility(): void
$this->resetPresentationFile();
// Set Visible : TRUE
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(true));
- $this->assertTrue($oShape->getPlotArea()->getAxisX()->isVisible());
+ self::assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(true));
+ self::assertTrue($oShape->getPlotArea()->getAxisX()->isVisible());
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '0');
@@ -571,6 +822,52 @@ public function testAxisYUnit(): void
$this->assertIsSchemaECMA376Valid();
}
+ /**
+ * @dataProvider dataProviderFont
+ */
+ public function testSeriesFont(string $chartType, string $chartElementName): void
+ {
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oShape = $oSlide->createChartShape();
+ $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
+ /** @var AbstractType $oChart */
+ $oChart = new $chartType();
+ $oChart->addSeries(new Series('Downloads', $this->seriesData));
+ $oShape->getPlotArea()->setType($oChart);
+
+ $this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
+
+ $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+
+ $chartBaseXmlPath = sprintf(
+ '/c:chartSpace/c:chart/c:plotArea/%s%s',
+ $chartElementName,
+ $chartType === Doughnut::class ? '' : '/c:ser'
+ );
+ $element = $chartBaseXmlPath;
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:dLbls';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:dLbls/c:txPr';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:dLbls/c:txPr/a:p';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:dLbls/c:txPr/a:p/a:pPr';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $element = $chartBaseXmlPath . '/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr/a:latin';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'typeface', 'Calibri');
+ $element = $chartBaseXmlPath . '/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr/a:ea';
+ $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
+ $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'typeface', 'Calibri');
+ $this->assertIsSchemaECMA376Valid();
+
+ $this->assertIsSchemaECMA376Valid();
+ }
+
public function testTypeArea(): void
{
$oSlide = $this->oPresentation->getActiveSlide();
@@ -698,7 +995,7 @@ public function testTypeBar3DSuperScript(): void
public function testTypeDoughnut(): void
{
$randHoleSize = mt_rand(10, 90);
- $randSeparator = chr(rand(ord('A'), ord('Z')));
+ $randSeparator = chr(mt_rand(ord('A'), ord('Z')));
$oSlide = $this->oPresentation->getActiveSlide();
$oShape = $oSlide->createChartShape();
@@ -821,7 +1118,7 @@ public function testTypeLineGridlines(): void
$expectedColor = new Color(Color::COLOR_BLUE);
foreach ($arrayTests as $arrayTest) {
$expectedSizePts = mt_rand(1, 100);
- $expectedSizeEmu = Drawing::pointsToEmu($expectedSizePts);
+ $expectedSizeEmu = Drawing::pixelsToEmu($expectedSizePts);
$this->oPresentation->removeSlideByIndex()->createSlide();
$oShape = $this->oPresentation->getActiveSlide()->createChartShape();
@@ -948,7 +1245,7 @@ public function testTypeLineMarkerFill(): void
public function testTypeLineSeriesOutline(): void
{
$expectedWidth = mt_rand(1, 100);
- $expectedWidthEmu = Drawing::pointsToEmu($expectedWidth);
+ $expectedWidthEmu = Drawing::pixelsToEmu($expectedWidth);
$expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:spPr/a:ln';
$oOutline = new Outline();
@@ -1355,7 +1652,7 @@ public function testTypeScatterSeparator(): void
public function testTypeScatterSeriesOutline(): void
{
$expectedWidth = mt_rand(1, 100);
- $expectedWidthEmu = Drawing::pointsToEmu($expectedWidth);
+ $expectedWidthEmu = Drawing::pixelsToEmu($expectedWidth);
$expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:spPr/a:ln';
$oOutline = new Outline();
@@ -1486,7 +1783,7 @@ public function testView3D(): void
/**
* @return array>
*/
- public function dataProviderMarkerSymbol(): iterable
+ public static function dataProviderMarkerSymbol(): iterable
{
foreach (Marker::$arraySymbol as $symbol) {
if ($symbol === Marker::SYMBOL_NONE) {
@@ -1495,4 +1792,43 @@ public function dataProviderMarkerSymbol(): iterable
yield [$symbol];
}
}
+
+ /**
+ * @return array>
+ */
+ public static function dataProviderFont(): iterable
+ {
+ foreach ([
+ [Bar::class, 'c:barChart'],
+ [Bar3D::class, 'c:bar3DChart'],
+ [Doughnut::class, 'c:doughnutChart'],
+ [Pie::class, 'c:pieChart'],
+ [Pie3D::class, 'c:pie3DChart'],
+ [Line::class, 'c:lineChart'],
+ [Radar::class, 'c:radarChart'],
+ [Scatter::class, 'c:scatterChart'],
+ ] as $chartType) {
+ yield $chartType;
+ }
+ }
+
+ /**
+ * @return array>
+ */
+ public static function dataProviderIncludedSpreadsheet(): iterable
+ {
+ foreach ([
+ [Area::class, 'c:areaChart'],
+ [Bar::class, 'c:barChart'],
+ [Bar3D::class, 'c:bar3DChart'],
+ [Doughnut::class, 'c:doughnutChart'],
+ [Pie::class, 'c:pieChart'],
+ [Pie3D::class, 'c:pie3DChart'],
+ [Line::class, 'c:lineChart'],
+ [Radar::class, 'c:radarChart'],
+ [Scatter::class, 'c:scatterChart'],
+ ] as $chartType) {
+ yield $chartType;
+ }
+ }
}
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptCommentsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptCommentsTest.php
index 8c67c8ac76..d41b8d47d6 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptCommentsTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptCommentsTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptMediaTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptMediaTest.php
index ca77f4d336..637851dd97 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptMediaTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptMediaTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptPresPropsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptPresPropsTest.php
index 6acf0e83be..a3122fe86d 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptPresPropsTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptPresPropsTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -70,7 +69,7 @@ public function testShowType(string $slideshowType, string $element): void
/**
* @return array>
*/
- public function dataProviderShowType(): array
+ public static function dataProviderShowType(): array
{
return [
[
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptPresentationTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptPresentationTest.php
index b3b02454a4..47ac1c3e43 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptPresentationTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptPresentationTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php
index bc99f27c71..67181ac061 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,6 +27,7 @@
use PhpOffice\PhpPresentation\Slide\SlideLayout;
use PhpOffice\PhpPresentation\Slide\SlideMaster;
use PhpOffice\PhpPresentation\Writer\PowerPoint2007\PptSlideMasters;
+use PHPUnit\Framework\MockObject\MockBuilder;
use PHPUnit\Framework\TestCase;
/**
@@ -40,25 +40,36 @@ class PptSlideMastersTest extends TestCase
public function testWriteSlideMasterRelationships(): void
{
$writer = new PptSlideMasters();
- /** @var \PHPUnit\Framework\MockObject\MockObject|SlideMaster $slideMaster */
- $slideMaster = $this->getMockBuilder(SlideMaster::class)
- ->setMethods(['getAllSlideLayouts', 'getRelsIndex', 'getShapeCollection'])
- ->getMock();
+ /** @var MockBuilder $mockBuilder */
+ // @phpstan-ignore-next-line
+ $mockBuilder = $this->getMockBuilder(SlideMaster::class);
+ if (method_exists(get_class($mockBuilder), 'onlyMethods')) {
+ /** @var \PHPUnit\Framework\MockObject\MockObject|SlideMaster $slideMaster */
+ // @phpstan-ignore-next-line
+ $slideMaster = $mockBuilder->onlyMethods(['getAllSlideLayouts', 'getRelsIndex', 'getShapeCollection'])
+ ->getMock();
+ } else {
+ /** @var \PHPUnit\Framework\MockObject\MockObject|SlideMaster $slideMaster */
+ // @phpstan-ignore-next-line
+ $slideMaster = $mockBuilder->setMethods(['getAllSlideLayouts', 'getRelsIndex', 'getShapeCollection'])
+ ->getMock();
+ }
$layouts = [new SlideLayout($slideMaster)];
- $slideMaster->expects($this->once())
+ $slideMaster->expects(self::once())
->method('getAllSlideLayouts')
- ->will($this->returnValue($layouts));
+ ->willReturn($layouts);
- $collection = new ArrayObject();
+ /** @var ArrayObject $collection */
+ $collection = [];
$collection[] = new ShapeDrawingFile();
$collection[] = new ShapeDrawingFile();
$collection[] = new ShapeDrawingFile();
- $slideMaster->expects($this->exactly(2))
+ $slideMaster->expects(self::exactly(2))
->method('getShapeCollection')
- ->will($this->returnValue($collection));
+ ->willReturn($collection);
$data = $writer->writeSlideMasterRelationships($slideMaster);
@@ -69,13 +80,13 @@ public function testWriteSlideMasterRelationships(): void
$xpath->registerNamespace('r', 'http://schemas.openxmlformats.org/package/2006/relationships');
$list = $xpath->query('//r:Relationship');
- $this->assertEquals(5, $list->length);
+ self::assertEquals(5, $list->length);
foreach (range(0, 4) as $id) {
/** @var DOMElement $domItem */
$domItem = $list->item($id);
- $this->assertInstanceOf(DOMElement::class, $domItem);
- $this->assertEquals('rId' . (string) ($id + 1), $domItem->getAttribute('Id'));
+ self::assertInstanceOf(DOMElement::class, $domItem);
+ self::assertEquals('rId' . (string) ($id + 1), $domItem->getAttribute('Id'));
}
}
}
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php
index 0d0f60681d..652ebd5b4c 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,6 +24,7 @@
use PhpOffice\PhpPresentation\Shape\Comment;
use PhpOffice\PhpPresentation\Shape\Group;
use PhpOffice\PhpPresentation\Shape\Media;
+use PhpOffice\PhpPresentation\Shape\Placeholder;
use PhpOffice\PhpPresentation\Shape\RichText;
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
use PhpOffice\PhpPresentation\Slide\Animation;
@@ -36,6 +36,7 @@
use PhpOffice\PhpPresentation\Style\Fill;
use PhpOffice\PhpPresentation\Style\Font;
use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase;
+use ReflectionClass;
class PptSlidesTest extends PhpPresentationTestCase
{
@@ -130,7 +131,7 @@ public function testAnimation(): void
{
$oSlide = $this->oPresentation->getActiveSlide();
$oShape1 = $oSlide->createRichTextShape();
- $oShape2 = $oSlide->createRichTextShape();
+ $oShape2 = $oSlide->createLineShape(10, 10, 10, 10);
$oAnimation = new Animation();
$oAnimation->addShape($oShape1);
$oAnimation->addShape($oShape2);
@@ -142,6 +143,12 @@ public function testAnimation(): void
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
$element = '/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par';
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $element = '/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par[1]/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'spid', 2);
+ $element = '/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par[2]/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'spid', 3);
$this->assertIsSchemaECMA376Valid();
}
@@ -452,6 +459,36 @@ public function testHyperlinkInternal(): void
$this->assertIsSchemaECMA376Valid();
}
+ public function testHyperlinkTextColorUsed(): void
+ {
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRun = $oRichText->createTextRun('Delta');
+ $oRun->getHyperlink()->setIsTextColorUsed(true);
+
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:hlinkClick';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:hlinkClick/a:extLst';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:hlinkClick/a:extLst/a:ext';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'uri', '{A12FA001-AC4F-418D-AE19-62706E023703}');
+
+ $this->assertIsSchemaECMA376Valid();
+
+ $this->resetPresentationFile();
+
+ $oRun->getHyperlink()->setIsTextColorUsed(false);
+
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:hlinkClick';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:hlinkClick/a:extLst';
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $element);
+ }
+
public function testListBullet(): void
{
$oSlide = $this->oPresentation->getActiveSlide();
@@ -559,9 +596,14 @@ public function testMedia(): void
$element = '/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/a:videoFile';
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'r:link', 'rId2');
$element = '/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/p:extLst/p:ext';
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'uri', '{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}');
+ $element = '/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/p:extLst/p:ext/p14:media';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'r:embed', 'rId3');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'xmlns:p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
$this->assertIsSchemaECMA376Valid();
}
@@ -696,6 +738,97 @@ public function testParagraphSpacingBefore(): void
$this->assertIsSchemaECMA376Valid();
}
+ public function testPlaceHolder(): void
+ {
+ $expectedType = Placeholder::PH_TYPE_SLIDENUM;
+ $expectedX = mt_rand(1, 100);
+ $expectedY = mt_rand(1, 100);
+ $expectedW = mt_rand(1, 100);
+ $expectedH = mt_rand(1, 100);
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRichText
+ ->setPlaceHolder(new Placeholder($expectedType))
+ ->setOffsetX($expectedX)
+ ->setOffsetY($expectedY)
+ ->setWidth($expectedW)
+ ->setHeight($expectedH);
+ $oRichText->createTextRun('Test');
+
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:nvSpPr/p:cNvPr';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'name', 'Placeholder for sldNum');
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:nvSpPr/p:nvPr/p:ph';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'type', $expectedType);
+ $this->assertZipXmlAttributeNotExists('ppt/slides/slide1.xml', $element, 'idx');
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:off';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'x', Drawing::pixelsToEmu($expectedX));
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'y', Drawing::pixelsToEmu($expectedY));
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:ext';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'cx', Drawing::pixelsToEmu($expectedW));
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'cy', Drawing::pixelsToEmu($expectedH));
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:fld';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'type', 'slidenum');
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:fld/a:rPr';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:fld/a:t';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlElementEquals('ppt/slides/slide1.xml', $element, '');
+ }
+
+ public function testPlaceHolderWithIdx(): void
+ {
+ $expectedType = Placeholder::PH_TYPE_DATETIME;
+ $expectedIdx = 1;
+ $expectedX = mt_rand(1, 100);
+ $expectedY = mt_rand(1, 100);
+ $expectedW = mt_rand(1, 100);
+ $expectedH = mt_rand(1, 100);
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRichText
+ ->setPlaceHolder((new Placeholder($expectedType))->setIdx($expectedIdx))
+ ->setOffsetX($expectedX)
+ ->setOffsetY($expectedY)
+ ->setWidth($expectedW)
+ ->setHeight($expectedH);
+ $oRichText->createTextRun('Test');
+
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:nvSpPr/p:cNvPr';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'name', 'Placeholder for dt');
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:nvSpPr/p:nvPr/p:ph';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'type', $expectedType);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'idx', $expectedIdx);
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:off';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'x', Drawing::pixelsToEmu($expectedX));
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'y', Drawing::pixelsToEmu($expectedY));
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:ext';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'cx', Drawing::pixelsToEmu($expectedW));
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'cy', Drawing::pixelsToEmu($expectedH));
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:fld';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'type', 'datetime');
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:fld/a:rPr';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:fld/a:t';
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlElementEquals('ppt/slides/slide1.xml', $element, '03-04-05');
+ }
+
public function testRichTextAutoFitNormal(): void
{
$expectedFontScale = 47.5;
@@ -735,6 +868,53 @@ public function testRichTextHyperlink(): void
$this->assertIsSchemaECMA376Valid();
}
+ public function testRichTextRunFontCharset(): void
+ {
+ $latinElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:latin';
+ $eastAsianElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:ea';
+ $complexScriptElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:cs';
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRun = $oRichText->createTextRun('MyText');
+ $oRun->getFont()->setCharset(18);
+
+ $oRun->getFont()->setFormat(Font::FORMAT_LATIN);
+
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'charset');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'charset', '12');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'charset');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'charset', '12');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'charset');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'charset', '12');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
public function testRichTextRunFontFormat(): void
{
$latinElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:latin';
@@ -774,6 +954,100 @@ public function testRichTextRunFontFormat(): void
$this->assertIsSchemaECMA376Valid();
}
+ public function testRichTextRunFontPanose(): void
+ {
+ $latinElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:latin';
+ $eastAsianElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:ea';
+ $complexScriptElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:cs';
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRun = $oRichText->createTextRun('MyText');
+ $oRun->getFont()->setPanose('4494D72242');
+
+ $oRun->getFont()->setFormat(Font::FORMAT_LATIN);
+
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'panose');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'panose', '040409040D0702020402');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'panose');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'panose', '040409040D0702020402');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'panose');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'panose', '040409040D0702020402');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
+ public function testRichTextRunFontPitchFamily(): void
+ {
+ $latinElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:latin';
+ $eastAsianElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:ea';
+ $complexScriptElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:cs';
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRun = $oRichText->createTextRun('MyText');
+ $oRun->getFont()->setPitchFamily(42);
+
+ $oRun->getFont()->setFormat(Font::FORMAT_LATIN);
+
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'pitchFamily');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'pitchFamily', '42');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'pitchFamily');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'pitchFamily', '42');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'pitchFamily');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'pitchFamily', '42');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
public function testRichTextRunLanguage(): void
{
$oSlide = $this->oPresentation->getActiveSlide();
@@ -840,6 +1114,27 @@ public function testSlideLayoutExists(): void
$this->assertIsSchemaECMA376Valid();
}
+ public function testStyleCapitalization(): void
+ {
+ $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr';
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRun = $oRichText->createTextRun('pText');
+ // Default : $oRun->getFont()->setCapitalization(Font::CAPITALIZATION_NONE);
+
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'cap', 'none');
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setCapitalization(Font::CAPITALIZATION_ALL);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'cap', 'all');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
public function testStyleCharacterSpacing(): void
{
$element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr';
@@ -1063,7 +1358,7 @@ public function testTransition(): void
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'spd', 'slow');
$this->assertIsSchemaECMA376Valid();
- $rcTransition = new \ReflectionClass('PhpOffice\PhpPresentation\Slide\Transition');
+ $rcTransition = new ReflectionClass('PhpOffice\PhpPresentation\Slide\Transition');
$arrayConstants = $rcTransition->getConstants();
foreach ($arrayConstants as $key => $value) {
if (0 !== strpos($key, 'TRANSITION_')) {
@@ -1076,144 +1371,191 @@ public function testTransition(): void
switch ($key) {
case 'TRANSITION_BLINDS_HORIZONTAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:blinds[@dir=\'horz\']');
+
break;
case 'TRANSITION_BLINDS_VERTICAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:blinds[@dir=\'vert\']');
+
break;
case 'TRANSITION_CHECKER_HORIZONTAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:checker[@dir=\'horz\']');
+
break;
case 'TRANSITION_CHECKER_VERTICAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:checker[@dir=\'vert\']');
+
break;
case 'TRANSITION_CIRCLE':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:circle');
+
break;
case 'TRANSITION_COMB_HORIZONTAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:comb[@dir=\'horz\']');
+
break;
case 'TRANSITION_COMB_VERTICAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:comb[@dir=\'vert\']');
+
break;
case 'TRANSITION_COVER_DOWN':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:cover[@dir=\'d\']');
+
break;
case 'TRANSITION_COVER_LEFT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:cover[@dir=\'l\']');
+
break;
case 'TRANSITION_COVER_LEFT_DOWN':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:cover[@dir=\'ld\']');
+
break;
case 'TRANSITION_COVER_LEFT_UP':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:cover[@dir=\'lu\']');
+
break;
case 'TRANSITION_COVER_RIGHT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:cover[@dir=\'r\']');
+
break;
case 'TRANSITION_COVER_RIGHT_DOWN':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:cover[@dir=\'rd\']');
+
break;
case 'TRANSITION_COVER_RIGHT_UP':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:cover[@dir=\'ru\']');
+
break;
case 'TRANSITION_COVER_UP':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:cover[@dir=\'u\']');
+
break;
case 'TRANSITION_CUT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:cut');
+
break;
case 'TRANSITION_DIAMOND':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:diamond');
+
break;
case 'TRANSITION_DISSOLVE':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:dissolve');
+
break;
case 'TRANSITION_FADE':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:fade');
+
break;
case 'TRANSITION_NEWSFLASH':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:newsflash');
+
break;
case 'TRANSITION_PLUS':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:plus');
+
break;
case 'TRANSITION_PULL_DOWN':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:pull[@dir=\'d\']');
+
break;
case 'TRANSITION_PULL_LEFT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:pull[@dir=\'l\']');
+
break;
case 'TRANSITION_PULL_RIGHT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:pull[@dir=\'r\']');
+
break;
case 'TRANSITION_PULL_UP':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:pull[@dir=\'u\']');
+
break;
case 'TRANSITION_PUSH_DOWN':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:push[@dir=\'d\']');
+
break;
case 'TRANSITION_PUSH_LEFT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:push[@dir=\'l\']');
+
break;
case 'TRANSITION_PUSH_RIGHT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:push[@dir=\'r\']');
+
break;
case 'TRANSITION_PUSH_UP':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:push[@dir=\'u\']');
+
break;
case 'TRANSITION_RANDOM':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:random');
+
break;
case 'TRANSITION_RANDOMBAR_HORIZONTAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:randomBar[@dir=\'horz\']');
+
break;
case 'TRANSITION_RANDOMBAR_VERTICAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:randomBar[@dir=\'vert\']');
+
break;
case 'TRANSITION_SPLIT_IN_HORIZONTAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:split[@dir=\'in\'][@orient=\'horz\']');
+
break;
case 'TRANSITION_SPLIT_OUT_HORIZONTAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:split[@dir=\'out\'][@orient=\'horz\']');
+
break;
case 'TRANSITION_SPLIT_IN_VERTICAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:split[@dir=\'in\'][@orient=\'vert\']');
+
break;
case 'TRANSITION_SPLIT_OUT_VERTICAL':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:split[@dir=\'out\'][@orient=\'vert\']');
+
break;
case 'TRANSITION_STRIPS_LEFT_DOWN':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:strips[@dir=\'ld\']');
+
break;
case 'TRANSITION_STRIPS_LEFT_UP':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:strips[@dir=\'lu\']');
+
break;
case 'TRANSITION_STRIPS_RIGHT_DOWN':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:strips[@dir=\'rd\']');
+
break;
case 'TRANSITION_STRIPS_RIGHT_UP':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:strips[@dir=\'ru\']');
+
break;
case 'TRANSITION_WEDGE':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:wedge');
+
break;
case 'TRANSITION_WIPE_DOWN':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:wipe[@dir=\'d\']');
+
break;
case 'TRANSITION_WIPE_LEFT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:wipe[@dir=\'l\']');
+
break;
case 'TRANSITION_WIPE_RIGHT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:wipe[@dir=\'r\']');
+
break;
case 'TRANSITION_WIPE_UP':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:wipe[@dir=\'u\']');
+
break;
case 'TRANSITION_ZOOM_IN':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:zoom[@dir=\'in\']');
+
break;
case 'TRANSITION_ZOOM_OUT':
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element . '/p:zoom[@dir=\'out\']');
+
break;
}
$this->assertIsSchemaECMA376Valid();
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptTablePropsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptTablePropsTest.php
index dd4957b0d9..50322e7747 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptTablePropsTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptTablePropsTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptViewPropsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptViewPropsTest.php
index a2bed9edfa..3bed78410e 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptViewPropsTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptViewPropsTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/RelationshipsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/RelationshipsTest.php
index 015e5464c1..e8dcbaec3b 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/RelationshipsTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/RelationshipsTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php
index e8b283b572..b51edfe28b 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -41,8 +40,8 @@ public function testConstruct(): void
{
$object = new PowerPoint2007($this->oPresentation);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->getPhpPresentation());
- $this->assertEquals('./', $object->getDiskCachingDirectory());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->getPhpPresentation());
+ self::assertEquals('./', $object->getDiskCachingDirectory());
}
/**
@@ -55,7 +54,7 @@ public function testSave(): void
$object = new PowerPoint2007($this->oPresentation);
$object->save($filename);
- $this->assertTrue(file_exists($filename));
+ self::assertFileExists($filename);
unlink($filename);
}
@@ -78,15 +77,15 @@ public function testSaveEmptyException(): void
public function testDiskCaching(): void
{
$object = new PowerPoint2007($this->oPresentation);
- $this->assertFalse($object->hasDiskCaching());
+ self::assertFalse($object->hasDiskCaching());
$object->setUseDiskCaching(true);
- $this->assertTrue($object->hasDiskCaching());
- $this->assertEquals('./', $object->getDiskCachingDirectory());
+ self::assertTrue($object->hasDiskCaching());
+ self::assertEquals('./', $object->getDiskCachingDirectory());
$object->setUseDiskCaching(true, sys_get_temp_dir());
- $this->assertTrue($object->hasDiskCaching());
- $this->assertEquals(sys_get_temp_dir(), $object->getDiskCachingDirectory());
+ self::assertTrue($object->hasDiskCaching());
+ self::assertEquals(sys_get_temp_dir(), $object->getDiskCachingDirectory());
}
/**
diff --git a/tests/PhpPresentation/Tests/Writer/SerializedTest.php b/tests/PhpPresentation/Tests/Writer/SerializedTest.php
index 4d495d6d1b..77cc19a798 100644
--- a/tests/PhpPresentation/Tests/Writer/SerializedTest.php
+++ b/tests/PhpPresentation/Tests/Writer/SerializedTest.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,7 +35,7 @@ class SerializedTest extends TestCase
public function testConstruct(): void
{
$object = new Serialized(new PhpPresentation());
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->getPhpPresentation());
+ self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->getPhpPresentation());
}
public function testSaveEmpty(): void
@@ -58,7 +57,7 @@ public function testSave(): void
$object = new Serialized($oPhpPresentation);
$object->save($file);
- $this->assertFileExists($file);
+ self::assertFileExists($file);
}
public function testSaveNotExistingDir(): void
@@ -88,11 +87,11 @@ public function testSaveOverwriting(): void
$oImage->setPath(PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png');
$file = tempnam(sys_get_temp_dir(), 'PhpPresentation_Serialized');
- file_put_contents($file, rand(1, 100));
+ file_put_contents($file, mt_rand(1, 100));
$object = new Serialized($oPhpPresentation);
$object->save($file);
- $this->assertFileExists($file);
+ self::assertFileExists($file);
}
}
diff --git a/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php b/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php
index 77cba12ca8..120ffe0c9b 100644
--- a/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php
+++ b/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -29,11 +28,15 @@
use PhpOffice\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\PhpPresentation;
use PHPUnit\Framework\TestCase;
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
+use SplFileInfo;
+use ZipArchive;
class PhpPresentationTestCase extends TestCase
{
/**
- * @var PhpPresentation|null
+ * @var null|PhpPresentation
*/
protected $oPresentation;
@@ -55,19 +58,19 @@ class PhpPresentationTestCase extends TestCase
/**
* DOMDocument object.
*
- * @var DOMDocument|null
+ * @var null|DOMDocument
*/
private $xmlDom;
/**
- * @var DOMXPath|null
+ * @var null|DOMXPath
*/
private $xmlXPath;
/**
* File name.
*
- * @var string|null
+ * @var null|string
*/
private $xmlFile;
@@ -104,7 +107,9 @@ class PhpPresentationTestCase extends TestCase
*/
protected function setUp(): void
{
- $this->xmlDisableEntityLoader = libxml_disable_entity_loader(false);
+ if (\PHP_VERSION_ID < 80000) {
+ $this->xmlDisableEntityLoader = libxml_disable_entity_loader(false);
+ }
$this->workDirectory = sys_get_temp_dir() . '/PhpPresentation_Unit_Test/';
$this->oPresentation = new PhpPresentation();
$this->filePath = tempnam(sys_get_temp_dir(), 'PhpPresentation');
@@ -122,7 +127,9 @@ protected function setUp(): void
*/
protected function tearDown(): void
{
- libxml_disable_entity_loader($this->xmlDisableEntityLoader);
+ if (\PHP_VERSION_ID < 80000) {
+ libxml_disable_entity_loader($this->xmlDisableEntityLoader);
+ }
libxml_use_internal_errors($this->xmlInternalErrors);
$this->oPresentation = null;
$this->resetPresentationFile();
@@ -187,6 +194,7 @@ private function getXmlNodeList(string $file, string $xpath): DOMNodeList
if (null === $this->xmlXPath) {
$this->xmlXPath = new DOMXPath($this->xmlDom);
+ $this->xmlXPath->registerNamespace('p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
}
return $this->xmlXPath->query($xpath);
@@ -204,7 +212,7 @@ protected function writePresentationFile(PhpPresentation $oPhpPresentation, $wri
$xmlWriter = IOFactory::createWriter($oPhpPresentation, $writerName);
$xmlWriter->save($this->filePath);
- $zip = new \ZipArchive();
+ $zip = new ZipArchive();
$res = $zip->open($this->filePath);
if (true === $res) {
$zip->extractTo($this->workDirectory);
@@ -265,6 +273,22 @@ public function assertZipXmlElementExists($filePath, $xPath): void
);
}
+ public function assertZipXmlElementAtIndexExists(string $filePath, string $xPath, int $index): void
+ {
+ $this->writePresentationFile($this->oPresentation, $this->writerName);
+ $nodeList = $this->getXmlNodeList($filePath, $xPath);
+ $element = $nodeList->item($index);
+ self::assertNotNull(
+ $element,
+ sprintf(
+ 'The element "%s" at index %d doesn\'t exist in the file "%s"',
+ $xPath,
+ $index,
+ $filePath
+ )
+ );
+ }
+
/**
* @param string $filePath
* @param string $xPath
@@ -296,6 +320,28 @@ public function assertZipXmlElementEquals($filePath, $xPath, $value): void
self::assertEquals($nodeList->item(0)->nodeValue, $value);
}
+ /**
+ * @param string $filePath
+ * @param string $xPath
+ * @param mixed $value
+ */
+ public function assertZipXmlElementNotEquals($filePath, $xPath, $value): void
+ {
+ $this->writePresentationFile($this->oPresentation, $this->writerName);
+ $nodeList = $this->getXmlNodeList($filePath, $xPath);
+ self::assertNotEquals($nodeList->item(0)->nodeValue, $value);
+ }
+
+ /**
+ * @param mixed $value
+ */
+ public function assertZipXmlElementAtIndexEquals(string $filePath, string $xPath, int $index, $value): void
+ {
+ $this->writePresentationFile($this->oPresentation, $this->writerName);
+ $nodeList = $this->getXmlNodeList($filePath, $xPath);
+ self::assertEquals($nodeList->item($index)->nodeValue, $value);
+ }
+
/**
* @param string $filePath
* @param string $xPath
@@ -305,7 +351,7 @@ public function assertZipXmlElementCount($filePath, $xPath, $num): void
{
$this->writePresentationFile($this->oPresentation, $this->writerName);
$nodeList = $this->getXmlNodeList($filePath, $xPath);
- self::assertEquals($nodeList->length, $num);
+ self::assertEquals($num, $nodeList->length);
}
/**
@@ -406,10 +452,10 @@ public function assertIsSchemaECMA376Valid(): void
{
// validate all XML files
$path = realpath($this->workDirectory . '/ppt');
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
+ $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
foreach ($iterator as $file) {
- /** @var \SplFileInfo $file */
+ /** @var SplFileInfo $file */
if ('xml' !== $file->getExtension()) {
continue;
}
@@ -433,10 +479,10 @@ public function assertIsSchemaOOXMLValid(): void
{
// validate all XML files
$path = realpath($this->workDirectory . '/ppt');
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
+ $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
foreach ($iterator as $file) {
- /** @var \SplFileInfo $file */
+ /** @var SplFileInfo $file */
if ('xml' !== $file->getExtension()) {
continue;
}
@@ -479,11 +525,11 @@ public function assertIsSchemaOpenDocumentValid(string $version = '1.0', bool $t
// validate all XML files
$path = realpath($this->workDirectory);
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
+ $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
$isValid = true;
foreach ($iterator as $file) {
- /** @var \SplFileInfo $file */
+ /** @var SplFileInfo $file */
if ('xml' !== $file->getExtension()) {
continue;
}
@@ -530,15 +576,19 @@ protected function failXmlError(LibXMLError $error, string $fileName, string $so
switch ($error->level) {
case LIBXML_ERR_WARNING:
$errorType = 'warning';
+
break;
case LIBXML_ERR_ERROR:
$errorType = 'error';
+
break;
case LIBXML_ERR_FATAL:
$errorType = 'fatal';
+
break;
default:
$errorType = 'Error';
+
break;
}
$errorLine = (int) $error->line;
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 88d30d03ca..b674b39bde 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -12,7 +12,6 @@
*
* @see https://github.com/PHPOffice/PHPPresentation
*
- * @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,12 +36,12 @@
}
}
-spl_autoload_register(function ($class) {
+spl_autoload_register(function ($class): void {
$class = ltrim($class, '\\');
$prefix = 'PhpOffice\\PhpPresentation\\Tests';
if (0 === strpos($class, $prefix)) {
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
- $class = join(DIRECTORY_SEPARATOR, ['PhpPresentation', 'Tests', '_includes']) .
+ $class = implode(DIRECTORY_SEPARATOR, ['PhpPresentation', 'Tests', '_includes']) .
substr($class, strlen($prefix));
$file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php';
if (file_exists($file)) {
@@ -52,4 +51,4 @@
});
require_once __DIR__ . '/../src/PhpPresentation/Autoloader.php';
-\PhpOffice\PhpPresentation\Autoloader::register();
+PhpOffice\PhpPresentation\Autoloader::register();
diff --git a/tests/resources/files/PPTX_InvalidImage.pptx b/tests/resources/files/PPTX_InvalidImage.pptx
new file mode 100644
index 0000000000..6b8a398519
Binary files /dev/null and b/tests/resources/files/PPTX_InvalidImage.pptx differ
diff --git a/tests/resources/files/PPTX_SlideNoteWithRichText.pptx b/tests/resources/files/PPTX_SlideNoteWithRichText.pptx
new file mode 100644
index 0000000000..812dd0cddd
Binary files /dev/null and b/tests/resources/files/PPTX_SlideNoteWithRichText.pptx differ
diff --git a/tests/resources/files/serialized.phppt b/tests/resources/files/serialized.phppt
index 44b1903515..8c213110fa 100644
Binary files a/tests/resources/files/serialized.phppt and b/tests/resources/files/serialized.phppt differ