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('