commit
dfa2f36cad
|
|
@ -0,0 +1,21 @@
|
|||
# build config
|
||||
/.scrutinizer.yml export-ignore
|
||||
/.travis.yml export-ignore
|
||||
/php_cs.dist export-ignore
|
||||
/phpmd.xml.dist export-ignore
|
||||
/phpstan.neon export-ignore
|
||||
|
||||
/composer.lock export-ignore
|
||||
|
||||
# git files
|
||||
/.gitignore export-ignore
|
||||
/.gitattributes export-ignore
|
||||
|
||||
# project directories
|
||||
/build export-ignore
|
||||
/docs export-ignore
|
||||
/samples export-ignore
|
||||
|
||||
# tests
|
||||
/phpunit.xml.dist export-ignore
|
||||
/tests export-ignore
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
build:
|
||||
nodes:
|
||||
analysis:
|
||||
tests:
|
||||
override: [php-scrutinizer-run]
|
||||
filter:
|
||||
excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ]
|
||||
|
||||
|
|
@ -14,7 +19,7 @@ tools:
|
|||
config:
|
||||
ruleset: phpmd.xml.dist
|
||||
external_code_coverage:
|
||||
enabled: true
|
||||
enabled: false
|
||||
timeout: 1200
|
||||
php_cpd: true
|
||||
# php_sim: # Temporarily disabled to allow focus on things other than duplicates
|
||||
|
|
|
|||
19
.travis.yml
19
.travis.yml
|
|
@ -13,14 +13,11 @@ php:
|
|||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
- php: 7.0
|
||||
env: COVERAGE=1
|
||||
allow_failures:
|
||||
- php: 7.2
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- vendor
|
||||
- $HOME/.composer/cache
|
||||
- .php-cs.cache
|
||||
|
||||
|
|
@ -38,9 +35,9 @@ before_script:
|
|||
- if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini ; fi
|
||||
## Composer
|
||||
- composer self-update
|
||||
- composer install --prefer-source
|
||||
- travis_wait composer install --prefer-source
|
||||
## PHPDocumentor
|
||||
- mkdir -p build/docs
|
||||
##- mkdir -p build/docs
|
||||
- mkdir -p build/coverage
|
||||
|
||||
script:
|
||||
|
|
@ -55,10 +52,8 @@ script:
|
|||
## PHPLOC
|
||||
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phploc src/ ; fi
|
||||
## PHPDocumentor
|
||||
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" ; fi
|
||||
##- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" ; fi
|
||||
|
||||
after_script:
|
||||
## PHPDocumentor
|
||||
- bash .travis_shell_after_success.sh
|
||||
## Scrutinizer
|
||||
- if [ -n "$COVERAGE" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml ; fi
|
||||
after_success:
|
||||
## Coveralls
|
||||
- if [ -n "$COVERAGE" ]; then travis_retry php vendor/bin/php-coveralls -v ; fi
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "--DEBUG--"
|
||||
echo "TRAVIS_REPO_SLUG: $TRAVIS_REPO_SLUG"
|
||||
echo "TRAVIS_PHP_VERSION: $TRAVIS_PHP_VERSION"
|
||||
echo "TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST"
|
||||
|
||||
if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then
|
||||
|
||||
echo -e "Publishing PHPDoc...\n"
|
||||
|
||||
cp -R build/docs $HOME/docs-latest
|
||||
cp -R build/coverage $HOME/coverage-latest
|
||||
|
||||
cd $HOME
|
||||
git config --global user.email "travis@travis-ci.org"
|
||||
git config --global user.name "travis-ci"
|
||||
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/PHPOffice/PHPWord gh-pages > /dev/null
|
||||
|
||||
cd gh-pages
|
||||
echo "--DEBUG : Suppression"
|
||||
git rm -rf ./docs/$TRAVIS_BRANCH
|
||||
|
||||
echo "--DEBUG : Dossier"
|
||||
mkdir -p docs/$TRAVIS_BRANCH
|
||||
mkdir -p coverage/$TRAVIS_BRANCH
|
||||
|
||||
echo "--DEBUG : Copie"
|
||||
cp -Rf $HOME/docs-latest/* ./docs/$TRAVIS_BRANCH/
|
||||
cp -Rf $HOME/coverage-latest/* ./coverage/$TRAVIS_BRANCH/
|
||||
|
||||
echo "--DEBUG : Git"
|
||||
git add -f .
|
||||
git commit -m "PHPDocumentor (Travis Build: $TRAVIS_BUILD_NUMBER - Branch: $TRAVIS_BRANCH)"
|
||||
git push -fq origin gh-pages > /dev/null
|
||||
|
||||
echo -e "Published PHPDoc to gh-pages.\n"
|
||||
|
||||
fi
|
||||
55
CHANGELOG.md
55
CHANGELOG.md
|
|
@ -3,6 +3,52 @@ Change Log
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
v0.15.0 (14 Jul 2018)
|
||||
----------------------
|
||||
### Added
|
||||
- Parsing of `align` HTML attribute - @troosan #1231
|
||||
- Parse formatting inside HTML lists - @troosan @samimussbach #1239 #945 #1215 #508
|
||||
- Parsing of CSS `direction` instruction, HTML `lang` attribute, formatting inside table cell - @troosan #1273 #1252 #1254
|
||||
- Add support for Track changes @Cip @troosan #354 #1262
|
||||
- Add support for fixed Table Layout @aoloe @ekopach @troosan #841 #1276
|
||||
- Add support for Cell Spacing @dox07 @troosan #1040
|
||||
- Add parsing of formatting inside lists @atomicalnet @troosan #594
|
||||
- Added support for Vertically Raised or Lowered Text (w:position) @anrikun @troosan #640
|
||||
- Add support for MACROBUTTON field @phryneas @troosan #1021
|
||||
- Add support for Hyphenation @Trainmaster #1282 (Document: `autoHyphenation`, `consecutiveHyphenLimit`, `hyphenationZone`, `doNotHyphenateCaps`, Paragraph: `suppressAutoHyphens`)
|
||||
- Added support for Floating Table Positioning (tblpPr) @anrikun #639
|
||||
- Added support for Image text wrapping distance @troosan #1310
|
||||
- Added parsing of CSS line-height and text-indent in HTML reader @troosan #1316
|
||||
- Added the ability to enable gridlines and axislabels on charts @FrankMeyer #576
|
||||
- Add support for table indent (tblInd) @Trainmaster #1343
|
||||
- Added parsing of internal links in HTML reader @lalop #1336
|
||||
- Several improvements to charts @JAEK-S #1332
|
||||
- Add parsing of html image in base64 format @jgpATs2w #1382
|
||||
- Added Support for Indentation & Tabs on RTF Writer. @smaug1985 #1405
|
||||
- Allows decimal numbers in HTML line-height style @jgpATs2w #1413
|
||||
|
||||
### Fixed
|
||||
- Fix reading of docx default style - @troosan #1238
|
||||
- Fix the size unit of when parsing html images - @troosan #1254
|
||||
- Fixed HTML parsing of nested lists - @troosan #1265
|
||||
- Save PNG alpha information when using remote images. @samsullivan #779
|
||||
- Fix parsing of `<w:br/>` tag. @troosan #1274
|
||||
- Bookmark are not writton as internal link in html writer @troosan #1263
|
||||
- It should be possible to add a Footnote in a ListItemRun @troosan #1287 #1287
|
||||
- Fix colspan and rowspan for tables in HTML Writer @mattbolt #1292
|
||||
- Fix parsing of Heading and Title formating @troosan @gthomas2 #465
|
||||
- Fix Dateformat typo, fix hours casing, add Month-Day-Year formats @ComputerTinker #591
|
||||
- Support reading of w:drawing for documents produced by word 2011+ @gthomas2 #464 #1324
|
||||
- Fix missing column width in ODText writer @potofcoffee #413
|
||||
- Disable entity loader before parsing XML to avoid XXE injection @Tom4t0 #1427
|
||||
|
||||
### Changed
|
||||
- Remove zend-stdlib dependency @Trainmaster #1284
|
||||
- The default unit for `\PhpOffice\PhpWord\Style\Image` changed from `px` to `pt`.
|
||||
|
||||
### Miscelaneous
|
||||
- Drop GitHub pages, switch to coveralls for code coverage analysis @czosel #1360
|
||||
|
||||
v0.14.0 (29 Dec 2017)
|
||||
----------------------
|
||||
This release fixes several bugs and adds some new features.
|
||||
|
|
@ -30,7 +76,8 @@ This version brings compatibility with PHP 7.0 & 7.1
|
|||
### Fixed
|
||||
- Loosen dependency to Zend
|
||||
- Images are not being printed when generating PDF - @hubertinio #1074 #431
|
||||
- Fixed some PHP 7 warnings - @likeuntomurphy #927
|
||||
- Fixed some PHP 7 warnings - @ likeuntomurphy #927
|
||||
- Fixed PHP 7.2 compatibility (renamed `Object` class names to `ObjectElement`) - @SailorMax #1185
|
||||
- Fixed Word 97 reader - @alsofronie @Benpxpx @mario-rivera #912 #920 #892
|
||||
- Fixed image loading over https - @troosan #988
|
||||
- Impossibility to set different even and odd page headers - @troosan #981
|
||||
|
|
@ -50,6 +97,8 @@ This version brings compatibility with PHP 7.0 & 7.1
|
|||
### Deprecated
|
||||
- PhpWord->getProtection(), get it from the settings instead PhpWord->getSettings()->getDocumentProtection();
|
||||
|
||||
|
||||
|
||||
v0.13.0 (31 July 2016)
|
||||
-------------------
|
||||
This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).
|
||||
|
|
@ -69,7 +118,7 @@ Manual installation feature has been dropped since the release. Please, use [Com
|
|||
- Improved error message for the case when `autoload.php` is not found. - @RomanSyroeshko #371
|
||||
- Renamed the `align` option of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles into `alignment`. - @RomanSyroeshko
|
||||
- Improved performance of `TemplateProcessor::setValue()`. - @kazitanvirahsan #614, #617
|
||||
- Fixed some HTML tags not rendering any output (p, header & table) - #257, #324 - @twmobius and @garethellis
|
||||
- Fixed some HTML tags not rendering any output (p, header & table) - #257, #324 - @twmobius and @garethellis
|
||||
|
||||
### Deprecated
|
||||
- `getAlign` and `setAlign` methods of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles.
|
||||
|
|
@ -447,4 +496,4 @@ This is the first release after a long development hiatus in [CodePlex](https://
|
|||
- Basic CI with Travis - @Progi1984
|
||||
- Added PHPWord_Exception and exception when could not copy the template - @Progi1984
|
||||
- IMPROVED: Moved examples out of Classes directory - @Progi1984
|
||||
- IMPROVED: Advanced string replace in setValue for Template - @Esmeraldo [#49](http://phpword.codeplex.com/workitem/49)
|
||||
- IMPROVED: Advanced string replace in setValue for Template - @Esmeraldo [#49](http://phpword.codeplex.com/workitem/49)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ We want to create a high quality document writer and reader library that people
|
|||
|
||||
- **Be brief, but be bold**. State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations.
|
||||
- **Follow PHP-FIG standards**. We follow PHP Standards Recommendations (PSRs) by [PHP Framework Interoperability Group](http://www.php-fig.org/). If you're not familiar with these standards, please, [familiarize yourself now](https://github.com/php-fig/fig-standards). Also, please, use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to validate your code against PSRs.
|
||||
- **Test your code**. Nobody else knows your code better than you. So, it's completely yours mission to test the changes you made before pull request submission. We use [PHPUnit](https://phpunit.de/) for our testing purposes and recommend you using this tool too. [Here](https://phpunit.de/presentations.html) you can find PHPUnit best practices and additional information on effective unit testing, which helps us making PHPWord better day to day. Do not hesitate to smoke it carefully. It's a great investment in quality of your work, and it saves you years of life.
|
||||
- **Test your code**. Nobody else knows your code better than you. So, it's completely your mission to test the changes you made before pull request submission. We use [PHPUnit](https://phpunit.de/) for our testing purposes and recommend you using this tool too. [Here](https://phpunit.de/presentations.html) you can find PHPUnit best practices and additional information on effective unit testing, which helps us making PHPWord better day to day. Do not hesitate to smoke it carefully. It's a great investment in quality of your work, and it saves you years of life.
|
||||
- **Request pull in separate branch**. Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. [This video](http://www.youtube.com/watch?v=-zvHQXnBO6c) explains how to synchronize your Github Fork with the Branch of PHPWord.
|
||||
|
||||
That's it. Thank you for your interest in PHPWord, and welcome!
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@
|
|||
[](https://packagist.org/packages/phpoffice/phpword)
|
||||
[](https://travis-ci.org/PHPOffice/PHPWord)
|
||||
[](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/)
|
||||
[](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/)
|
||||
[](https://coveralls.io/github/PHPOffice/PHPWord?branch=develop)
|
||||
[](https://packagist.org/packages/phpoffice/phpword)
|
||||
[](https://packagist.org/packages/phpoffice/phpword)
|
||||
[](https://gitter.im/PHPOffice/PHPWord)
|
||||
|
||||
PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF), HTML, and PDF.
|
||||
|
||||
PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/).
|
||||
PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/).
|
||||
|
||||
If you have any questions, please ask on [StackOverFlow](https://stackoverflow.com/questions/tagged/phpword)
|
||||
|
||||
|
|
@ -160,7 +160,8 @@ $objWriter->save('helloWorld.html');
|
|||
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
||||
```
|
||||
|
||||
More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail.
|
||||
More examples are provided in the [samples folder](samples/). For an easy access to those samples launch `php -S localhost:8000` in the samples directory then browse to [http://localhost:8000](http://localhost:8000) to view the samples.
|
||||
You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -35,33 +35,46 @@
|
|||
}
|
||||
],
|
||||
"scripts": {
|
||||
"test": [
|
||||
"phpunit --color=always"
|
||||
],
|
||||
"test-no-coverage": [
|
||||
"phpunit --color=always --no-coverage"
|
||||
],
|
||||
"check": [
|
||||
"./vendor/bin/php-cs-fixer fix --ansi --dry-run --diff",
|
||||
"./vendor/bin/phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --ignore=src/PhpWord/Shared/PCLZip --standard=PSR2 -n",
|
||||
"./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php",
|
||||
"./vendor/bin/phpunit --color=always"
|
||||
"php-cs-fixer fix --ansi --dry-run --diff",
|
||||
"phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --ignore=src/PhpWord/Shared/PCLZip --standard=PSR2 -n",
|
||||
"phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php",
|
||||
"@test"
|
||||
],
|
||||
"fix": [
|
||||
"./vendor/bin/php-cs-fixer fix --ansi"
|
||||
"php-cs-fixer fix --ansi"
|
||||
]
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"test": "Runs all unit tests",
|
||||
"test-no-coverage": "Runs all unit tests, without code coverage",
|
||||
"check": "Runs PHP CheckStyle and PHP Mess detector",
|
||||
"fix": "Fixes issues found by PHP-CS"
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3.3 || ^7.0",
|
||||
"ext-xml": "*",
|
||||
"zendframework/zend-escaper": "^2.2",
|
||||
"zendframework/zend-stdlib": "^2.2 || ^3.0",
|
||||
"phpoffice/common": "^0.2"
|
||||
"phpoffice/common": "^0.2.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.36 || ^5.0",
|
||||
"phpdocumentor/phpdocumentor":"2.*",
|
||||
"squizlabs/php_codesniffer": "^2.7",
|
||||
"friendsofphp/php-cs-fixer": "^2.0",
|
||||
"ext-zip": "*",
|
||||
"ext-gd": "*",
|
||||
"phpunit/phpunit": "^4.8.36 || ^7.0",
|
||||
"squizlabs/php_codesniffer": "^2.9",
|
||||
"friendsofphp/php-cs-fixer": "^2.2",
|
||||
"phpmd/phpmd": "2.*",
|
||||
"phploc/phploc": "2.* || 3.* || 4.*",
|
||||
"dompdf/dompdf":"0.8.*",
|
||||
"tecnickcom/tcpdf": "6.*",
|
||||
"mpdf/mpdf": "5.* || 6.* || 7.*"
|
||||
"mpdf/mpdf": "5.7.4 || 6.* || 7.*",
|
||||
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-zip": "Allows writing OOXML and ODF",
|
||||
|
|
@ -77,7 +90,7 @@
|
|||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.15-dev"
|
||||
"dev-develop": "0.16-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ This is:
|
|||
- [ ] a feature request
|
||||
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpword)
|
||||
|
||||
# Expected Behavior
|
||||
### Expected Behavior
|
||||
|
||||
Please describe the behavior you are expecting.
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ Fixes # (issue)
|
|||
|
||||
### Checklist:
|
||||
|
||||
- [ ] I have run `composer check` and no errors were reported
|
||||
- [ ] The new code is covered by unit tests
|
||||
- [ ] I have run `composer run-script check --timeout=0` and no errors were reported
|
||||
- [ ] The new code is covered by unit tests (check build/coverage for coverage report)
|
||||
- [ ] I have update the documentation to describe the changes
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ Below are the properties of the line numbering style.
|
|||
|
||||
- ``start`` Line numbering starting value
|
||||
- ``increment`` Line number increments
|
||||
- ``distance`` Distance between text and line numbering in twip
|
||||
- ``distance`` Distance between text and line numbering in *twip*
|
||||
- ``restart`` Line numbering restart setting
|
||||
continuous\|newPage\|newSection
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ column shows the containers while the rows lists the elements.
|
|||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
||||
| 11 | Watermark | - | v | - | - | - | - |
|
||||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
||||
| 12 | Object | v | v | v | v | v | v |
|
||||
| 12 | OLEObject | v | v | v | v | v | v |
|
||||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
||||
| 13 | TOC | v | - | - | - | - | - |
|
||||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
||||
|
|
@ -77,11 +77,19 @@ italics, etc) or other elements, e.g. images or links. The syntaxes are as follo
|
|||
|
||||
For available styling options see :ref:`font-style` and :ref:`paragraph-style`.
|
||||
|
||||
If you want to enable track changes on added text you can mark it as INSERTED or DELETED by a specific user at a given time:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$text = $section->addText('Hello World!');
|
||||
$text->setChanged(\PhpOffice\PhpWord\Element\ChangedElement::TYPE_INSERTED, 'Fred', (new \DateTime()));
|
||||
|
||||
Titles
|
||||
~~~~~~
|
||||
|
||||
If you want to structure your document or build table of contents, you need titles or headings.
|
||||
To add a title to the document, use the ``addTitleStyle`` and ``addTitle`` method.
|
||||
If `depth` is 0, a Title will be inserted, otherwise a Heading1, Heading2, ...
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
|
@ -91,7 +99,7 @@ To add a title to the document, use the ``addTitleStyle`` and ``addTitle`` metho
|
|||
- ``depth``.
|
||||
- ``$fontStyle``. See :ref:`font-style`.
|
||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||
- ``$text``. Text to be displayed in the document.
|
||||
- ``$text``. Text to be displayed in the document. This can be `string` or a `\PhpOffice\PhpWord\Element\TextRun`
|
||||
|
||||
It's necessary to add a title style to your document because otherwise the title won't be detected as a real title.
|
||||
|
||||
|
|
@ -160,7 +168,7 @@ Parameters:
|
|||
- ``$text``. Text that appears in the document.
|
||||
- ``$depth``. Depth of list item.
|
||||
- ``$fontStyle``. See :ref:`font-style`.
|
||||
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
|
||||
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
|
||||
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\\Style\\ListItem.
|
||||
- ``$paragraphStyle``. See :ref:`paragraph-style`.
|
||||
|
||||
|
|
@ -234,7 +242,7 @@ To add an image, use the ``addImage`` method to sections, headers, footers, text
|
|||
|
||||
$section->addImage($src, [$style]);
|
||||
|
||||
- ``$src``. String path to a local image, URL of a remote image or the image data, as a string.
|
||||
- ``$src``. String path to a local image, URL of a remote image or the image data, as a string. Warning: Do not pass user-generated strings here, as that would allow an attacker to read arbitrary files or perform server-side request forgery by passing file paths or URLs instead of image data.
|
||||
- ``$style``. See :ref:`image-style`.
|
||||
|
||||
Examples:
|
||||
|
|
@ -276,11 +284,11 @@ Objects
|
|||
-------
|
||||
|
||||
You can add OLE embeddings, such as Excel spreadsheets or PowerPoint
|
||||
presentations to the document by using ``addObject`` method.
|
||||
presentations to the document by using ``addOLEObject`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$section->addObject($src, [$style]);
|
||||
$section->addOLEObject($src, [$style]);
|
||||
|
||||
Table of contents
|
||||
-----------------
|
||||
|
|
@ -300,8 +308,8 @@ Your TOC can only be generated if you have add at least one title (See "Titles")
|
|||
Options for ``$tocStyle``:
|
||||
|
||||
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in ``\PhpOffice\PhpWord\Style\TOC``.
|
||||
- ``tabPos``. The position of the tab where the page number appears in twips.
|
||||
- ``indent``. The indent factor of the titles in twips.
|
||||
- ``tabPos``. The position of the tab where the page number appears in *twip*.
|
||||
- ``indent``. The indent factor of the titles in *twip*.
|
||||
|
||||
Footnotes & endnotes
|
||||
--------------------
|
||||
|
|
@ -309,7 +317,7 @@ Footnotes & endnotes
|
|||
You can create footnotes with ``addFootnote`` and endnotes with
|
||||
``addEndnote`` in texts or textruns, but it's recommended to use textrun
|
||||
to have better layout. You can use ``addText``, ``addLink``,
|
||||
``addTextBreak``, ``addImage``, ``addObject`` on footnotes and endnotes.
|
||||
``addTextBreak``, ``addImage``, ``addOLEObject`` on footnotes and endnotes.
|
||||
|
||||
On textrun:
|
||||
|
||||
|
|
@ -345,7 +353,7 @@ The footnote numbering can be controlled by setting the FootnoteProperties on th
|
|||
.. code-block:: php
|
||||
|
||||
$fp = new PhpWord\SimpleType\FootnoteProperties();
|
||||
//sets the position of the footnote (pageBottom (default), beneathText, sectEnd, docEnd)
|
||||
//sets the position of the footnote (pageBottom (default), beneathText, sectEnd, docEnd)
|
||||
$fp->setPos(FootnoteProperties::POSITION_DOC_END);
|
||||
//set the number format to use (decimal (default), upperRoman, upperLetter, ...)
|
||||
$fp->setNumFmt(FootnoteProperties::NUMBER_FORMAT_LOWER_ROMAN);
|
||||
|
|
@ -353,7 +361,6 @@ The footnote numbering can be controlled by setting the FootnoteProperties on th
|
|||
$fp->setNumStart(2);
|
||||
//when to restart counting (continuous (default), eachSect, eachPage)
|
||||
$fp->setNumRestart(FootnoteProperties::RESTART_NUMBER_EACH_PAGE);
|
||||
|
||||
//And finaly, set it on the Section
|
||||
$section->setFootnoteProperties($properties);
|
||||
|
||||
|
|
@ -379,7 +386,7 @@ To be completed
|
|||
Fields
|
||||
------
|
||||
|
||||
Currently the following fields are supported:
|
||||
Currently the following fields are supported:
|
||||
|
||||
- PAGE
|
||||
- NUMPAGES
|
||||
|
|
@ -406,8 +413,10 @@ For instance for the INDEX field, you can do the following (See `Index Field for
|
|||
$fieldText->addText('My ');
|
||||
$fieldText->addText('bold index', ['bold' => true]);
|
||||
$fieldText->addText(' entry');
|
||||
$section->addField('XE', array(), array(), $fieldText);
|
||||
|
||||
$section->addField('INDEX', array(), array('\\e " " \\h "A" \\c "3"'), $fieldText);
|
||||
//this actually adds the index
|
||||
$section->addField('INDEX', array(), array('\\e " " \\h "A" \\c "3"'), 'right click to update index');
|
||||
|
||||
Line
|
||||
----
|
||||
|
|
@ -421,13 +430,13 @@ Line elements can be added to sections by using ``addLine``.
|
|||
|
||||
Available line style attributes:
|
||||
|
||||
- ``weight``. Line width in twips.
|
||||
- ``weight``. Line width in *twip*.
|
||||
- ``color``. Defines the color of stroke.
|
||||
- ``dash``. Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot.
|
||||
- ``beginArrow``. Start type of arrow: block, open, classic, diamond, oval.
|
||||
- ``endArrow``. End type of arrow: block, open, classic, diamond, oval.
|
||||
- ``width``. Line-object width in pt.
|
||||
- ``height``. Line-object height in pt.
|
||||
- ``width``. Line-object width in *pt*.
|
||||
- ``height``. Line-object height in *pt*.
|
||||
- ``flip``. Flip the line element: true, false.
|
||||
|
||||
Chart
|
||||
|
|
@ -439,7 +448,9 @@ Charts can be added using
|
|||
|
||||
$categories = array('A', 'B', 'C', 'D', 'E');
|
||||
$series = array(1, 3, 2, 5, 4);
|
||||
$chart = $section->addChart('line', $categories, $series);
|
||||
$chart = $section->addChart('line', $categories, $series, $style);
|
||||
|
||||
For available styling options see :ref:`chart-style`.
|
||||
|
||||
check out the Sample_32_Chart.php for more options and styling.
|
||||
|
||||
|
|
@ -464,4 +475,29 @@ The comment can contain formatted text. Once the comment has been added, it can
|
|||
// link the comment to the text you just created
|
||||
$text->setCommentStart($comment);
|
||||
|
||||
If no end is set for a comment using the ``setCommentEnd``, the comment will be ended automatically at the end of the element it is started on.
|
||||
If no end is set for a comment using the ``setCommentEnd``, the comment will be ended automatically at the end of the element it is started on.
|
||||
|
||||
Track Changes
|
||||
-------------
|
||||
|
||||
Track changes can be set on text elements. There are 2 ways to set the change information on an element.
|
||||
Either by calling the `setChangeInfo()`, or by setting the `TrackChange` instance on the element with `setTrackChange()`.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
|
||||
// New portrait section
|
||||
$section = $phpWord->addSection();
|
||||
$textRun = $section->addTextRun();
|
||||
|
||||
$text = $textRun->addText('Hello World! Time to ');
|
||||
|
||||
$text = $textRun->addText('wake ', array('bold' => true));
|
||||
$text->setChangeInfo(TrackChange::INSERTED, 'Fred', time() - 1800);
|
||||
|
||||
$text = $textRun->addText('up');
|
||||
$text->setTrackChange(new TrackChange(TrackChange::INSERTED, 'Fred'));
|
||||
|
||||
$text = $textRun->addText('go to sleep');
|
||||
$text->setChangeInfo(TrackChange::DELETED, 'Barney', new \DateTime('@' . (time() - 3600)));
|
||||
|
|
|
|||
|
|
@ -167,7 +167,6 @@ Use mirror margins to set up facing pages for double-sided documents, such as bo
|
|||
|
||||
$phpWord->getSettings()->setMirrorMargins(true);
|
||||
|
||||
|
||||
Spelling and grammatical checks
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -191,7 +190,7 @@ You can also specify the status of the spell and grammar checks, marking spellin
|
|||
|
||||
Track Revisions
|
||||
~~~~~~~~~~~~~~~
|
||||
Track changes can be activated using ``setTrackRevisions``, you can furture specify
|
||||
Track changes can be activated using ``setTrackRevisions``, you can furture specify
|
||||
|
||||
- Not to use move syntax, instead moved items will be seen as deleted in one place and added in another
|
||||
- Not track formatting revisions
|
||||
|
|
@ -218,10 +217,10 @@ The default language of the document can be change with the following.
|
|||
|
||||
$phpWord->getSettings()->setThemeFontLang(new Language(Language::FR_BE));
|
||||
|
||||
``Languge`` has 3 parameters, one for Latin languages, one for East Asian languages and one for Complex (Bi-Directional) languages.
|
||||
``Language`` has 3 parameters, one for Latin languages, one for East Asian languages and one for Complex (Bi-Directional) languages.
|
||||
A couple of language codes are provided in the ``PhpOffice\PhpWord\ComplexType\Language`` class but any valid code/ID can be used.
|
||||
|
||||
In case you are generating an RTF document the Language need to be set differently.
|
||||
In case you are generating an RTF document the language need to be set differently.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
|
@ -256,7 +255,7 @@ The base length unit in Open Office XML is twip. Twip means "TWentieth
|
|||
of an Inch Point", i.e. 1 twip = 1/1440 inch.
|
||||
|
||||
You can use PHPWord helper functions to convert inches, centimeters, or
|
||||
points to twips.
|
||||
points to twip.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
|
@ -291,3 +290,45 @@ To force an update of the fields present in the document, set updateFields to tr
|
|||
.. code-block:: php
|
||||
|
||||
$phpWord->getSettings()->setUpdateFields(true);
|
||||
|
||||
Hyphenation
|
||||
-----------
|
||||
Hyphenation describes the process of breaking words with hyphens. There are several options to control hyphenation.
|
||||
|
||||
Auto hyphenation
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
To automatically hyphenate text set ``autoHyphenation`` to ``true``.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$phpWord->getSettings()->setAutoHyphenation(true);
|
||||
|
||||
Consecutive Hyphen Limit
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The maximum number of consecutive lines of text ending with a hyphen can be controlled by the ``consecutiveHyphenLimit`` option.
|
||||
There is no limit if the option is not set or the provided value is ``0``.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$phpWord->getSettings()->setConsecutiveHyphenLimit(2);
|
||||
|
||||
Hyphenation Zone
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
The hyphenation zone (in *twip*) is the allowed amount of whitespace before hyphenation is applied.
|
||||
The smaller the hyphenation zone the more words are hyphenated. Or in other words, the wider the hyphenation zone the less words are hyphenated.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$phpWord->getSettings()->setHyphenationZone(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(1));
|
||||
|
||||
Hyphenate Caps
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
To control whether or not words in all capital letters shall be hyphenated use the `doNotHyphenateCaps` option.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$phpWord->getSettings()->setDoNotHyphenateCaps(true);
|
||||
|
|
|
|||
|
|
@ -51,11 +51,8 @@ Example:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Using samples
|
||||
-------------
|
||||
|
||||
After installation, you can browse and use the samples that we've
|
||||
provided, either by command line or using browser. If you can access
|
||||
your PHPWord library folder using browser, point your browser to the
|
||||
``samples`` folder, e.g. ``http://localhost/PhpWord/samples/``.
|
||||
More examples are provided in the ``samples`` directory.
|
||||
For an easy access to those samples launch ``php -S localhost:8000`` in the samples directory then browse to http://localhost:8000 to view the samples.
|
||||
|
|
|
|||
|
|
@ -11,26 +11,26 @@ Section
|
|||
Available Section style options:
|
||||
|
||||
- ``borderBottomColor``. Border bottom color.
|
||||
- ``borderBottomSize``. Border bottom size (in twips).
|
||||
- ``borderBottomSize``. Border bottom size in *twip*.
|
||||
- ``borderLeftColor``. Border left color.
|
||||
- ``borderLeftSize``. Border left size (in twips).
|
||||
- ``borderLeftSize``. Border left size in *twip*.
|
||||
- ``borderRightColor``. Border right color.
|
||||
- ``borderRightSize``. Border right size (in twips).
|
||||
- ``borderRightSize``. Border right size in *twip*.
|
||||
- ``borderTopColor``. Border top color.
|
||||
- ``borderTopSize``. Border top size (in twips).
|
||||
- ``borderTopSize``. Border top size in *twip*.
|
||||
- ``breakType``. Section break type (nextPage, nextColumn, continuous, evenPage, oddPage).
|
||||
- ``colsNum``. Number of columns.
|
||||
- ``colsSpace``. Spacing between columns.
|
||||
- ``footerHeight``. Spacing to bottom of footer.
|
||||
- ``gutter``. Page gutter spacing.
|
||||
- ``headerHeight``. Spacing to top of header.
|
||||
- ``marginTop``. Page margin top (in twips).
|
||||
- ``marginLeft``. Page margin left (in twips).
|
||||
- ``marginRight``. Page margin right (in twips).
|
||||
- ``marginBottom``. Page margin bottom (in twips).
|
||||
- ``marginTop``. Page margin top in *twip*.
|
||||
- ``marginLeft``. Page margin left in *twip*.
|
||||
- ``marginRight``. Page margin right in *twip*.
|
||||
- ``marginBottom``. Page margin bottom in *twip*.
|
||||
- ``orientation``. Page orientation (``portrait``, which is default, or ``landscape``).
|
||||
- ``pageSizeH``. Page height (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
||||
- ``pageSizeW``. Page width (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
||||
- ``pageSizeH``. Page height in *twip*. Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
||||
- ``pageSizeW``. Page width in *twip*. Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
||||
|
||||
.. _font-style:
|
||||
|
||||
|
|
@ -59,6 +59,7 @@ Available Font style options:
|
|||
See ``\PhpOffice\PhpWord\Style\Font::UNDERLINE_...`` constants for more values
|
||||
- ``lang``. Language, either a language code like *en-US*, *fr-BE*, etc. or an object (or as an array) if you need to set eastAsian or bidirectional languages
|
||||
See ``\PhpOffice\PhpWord\Style\Language`` class for some language codes.
|
||||
- ``position``. The text position, raised or lowered, in half points
|
||||
|
||||
.. _paragraph-style:
|
||||
|
||||
|
|
@ -70,17 +71,18 @@ Available Paragraph style options:
|
|||
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
|
||||
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||
- ``basedOn``. Parent style.
|
||||
- ``hanging``. Hanging by how much.
|
||||
- ``indent``. Indent by how much.
|
||||
- ``hanging``. Hanging in *twip*.
|
||||
- ``indent``. Indent in *twip*.
|
||||
- ``keepLines``. Keep all lines on one page, *true* or *false*.
|
||||
- ``keepNext``. Keep paragraph with next paragraph, *true* or *false*.
|
||||
- ``lineHeight``. Text line height, e.g. *1.0*, *1.5*, etc.
|
||||
- ``next``. Style for next paragraph.
|
||||
- ``pageBreakBefore``. Start paragraph on next page, *true* or *false*.
|
||||
- ``spaceBefore``. Space before paragraph.
|
||||
- ``spaceAfter``. Space after paragraph.
|
||||
- ``spaceBefore``. Space before paragraph in *twip*.
|
||||
- ``spaceAfter``. Space after paragraph in *twip*.
|
||||
- ``spacing``. Space between lines.
|
||||
- ``spacingLineRule``. Line Spacing Rule. *auto*, *exact*, *atLeast*
|
||||
- ``suppressAutoHyphens``. Hyphenation for paragraph, *true* or *false*.
|
||||
- ``tabs``. Set of custom tab stops.
|
||||
- ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*.
|
||||
- ``contextualSpacing``. Ignore Spacing Above and Below When Using Identical Styles, *true* or *false*.
|
||||
|
|
@ -100,9 +102,27 @@ Available Table style options:
|
|||
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
|
||||
- ``bgColor``. Background color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||
- ``cellMargin(Top|Right|Bottom|Left)``. Cell margin in twips.
|
||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in *twip*.
|
||||
- ``cellMargin(Top|Right|Bottom|Left)``. Cell margin in *twip*.
|
||||
- ``indent``. Table indent from leading margin. Must be an instance of ``\PhpOffice\PhpWord\ComplexType\TblWidth``.
|
||||
- ``width``. Table width in percent.
|
||||
- ``unit``. The unit to use for the width. One of ``\PhpOffice\PhpWord\SimpleType\TblWidth``. Defaults to *auto*.
|
||||
- ``layout``. Table layout, either *fixed* or *autofit* See ``\PhpOffice\PhpWord\Style\Table`` for constants.
|
||||
- ``cellSpacing`` Cell spacing in *twip*
|
||||
- ``position`` Floating Table Positioning, see below for options
|
||||
|
||||
Floating Table Positioning options:
|
||||
|
||||
- ``leftFromText`` Distance From Left of Table to Text in *twip*
|
||||
- ``rightFromText`` Distance From Right of Table to Text in *twip*
|
||||
- ``topFromText`` Distance From Top of Table to Text in *twip*
|
||||
- ``bottomFromText`` Distance From Top of Table to Text in *twip*
|
||||
- ``vertAnchor`` Table Vertical Anchor, one of ``\PhpOffice\PhpWord\Style\TablePosition::VANCHOR_*``
|
||||
- ``horzAnchor`` Table Horizontal Anchor, one of ``\PhpOffice\PhpWord\Style\TablePosition::HANCHOR_*``
|
||||
- ``tblpXSpec`` Relative Horizontal Alignment From Anchor, one of ``\PhpOffice\PhpWord\Style\TablePosition::XALIGN_*``
|
||||
- ``tblpX`` Absolute Horizontal Distance From Anchorin *twip*
|
||||
- ``tblpYSpec`` Relative Vertical Alignment From Anchor, one of ``\PhpOffice\PhpWord\Style\TablePosition::YALIGN_*``
|
||||
- ``tblpY`` Absolute Vertical Distance From Anchorin *twip*
|
||||
|
||||
Available Row style options:
|
||||
|
||||
|
|
@ -114,13 +134,13 @@ Available Cell style options:
|
|||
|
||||
- ``bgColor``. Background color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
|
||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in *twip*.
|
||||
- ``gridSpan``. Number of columns spanned.
|
||||
- ``textDirection(btLr|tbRl)``. Direction of text.
|
||||
You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
|
||||
- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
|
||||
- ``vMerge``. *restart* or *continue*.
|
||||
- ``width``. Cell width in twips.
|
||||
- ``width``. Cell width in *twip*.
|
||||
|
||||
.. _image-style:
|
||||
|
||||
|
|
@ -130,11 +150,15 @@ Image
|
|||
Available Image style options:
|
||||
|
||||
- ``alignment``. See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
|
||||
- ``height``. Height in pixels.
|
||||
- ``height``. Height in *pt*.
|
||||
- ``marginLeft``. Left margin in inches, can be negative.
|
||||
- ``marginTop``. Top margin in inches, can be negative.
|
||||
- ``width``. Width in pixels.
|
||||
- ``width``. Width in *pt*.
|
||||
- ``wrappingStyle``. Wrapping style, *inline*, *square*, *tight*, *behind*, or *infront*.
|
||||
- ``wrapDistanceTop``. Top text wrapping in pixels.
|
||||
- ``wrapDistanceBottom``. Bottom text wrapping in pixels.
|
||||
- ``wrapDistanceLeft``. Left text wrapping in pixels.
|
||||
- ``wrapDistanceRight``. Right text wrapping in pixels.
|
||||
|
||||
.. _numbering-level-style:
|
||||
|
||||
|
|
@ -155,3 +179,17 @@ Available NumberingLevel style options:
|
|||
- ``suffix``. Content between numbering symbol and paragraph text tab\|space\|nothing.
|
||||
- ``tabPos``. See paragraph style.
|
||||
- ``text``. Numbering level text e.g. %1 for nonbullet or bullet character.
|
||||
|
||||
.. _chart-style:
|
||||
|
||||
Chart
|
||||
-----
|
||||
|
||||
Available Chart style options:
|
||||
|
||||
- ``width``. Width (in EMU).
|
||||
- ``height``. Height (in EMU).
|
||||
- ``3d``. Is 3D; applies to pie, bar, line, area, *true* or *false*.
|
||||
- ``showAxisLabels``. Show labels for axis, *true* or *false*.
|
||||
- ``gridX``. Show Gridlines for X-Axis, *true* or *false*.
|
||||
- ``gridY``. Show Gridlines for Y-Axis, *true* or *false*.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
includes:
|
||||
- vendor/phpstan/phpstan/conf/config.level1.neon
|
||||
parameters:
|
||||
memory-limit: 200000
|
||||
memory-limit: 20000000
|
||||
autoload_directories:
|
||||
- tests
|
||||
autoload_files:
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false">
|
||||
stopOnFailure="false">
|
||||
<testsuites>
|
||||
<testsuite name="PhpWord Test Suite">
|
||||
<directory>./tests/PhpWord</directory>
|
||||
|
|
@ -22,7 +21,7 @@
|
|||
</whitelist>
|
||||
</filter>
|
||||
<logging>
|
||||
<log type="coverage-html" target="./build/coverage" charset="UTF-8" highlight="true" />
|
||||
<log type="coverage-html" target="./build/coverage" />
|
||||
<log type="coverage-clover" target="./build/logs/clover.xml" />
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ $templateProcessor->setValue('userPhone#3', '+1 428 889 775');
|
|||
echo date('H:i:s'), ' Saving the result document...', EOL;
|
||||
$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
|
||||
|
||||
echo getEndingNotes(array('Word2007' => 'docx'));
|
||||
echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_07_TemplateCloneRow.docx');
|
||||
if (!CLI) {
|
||||
include_once 'Sample_Footer.php';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
use PhpOffice\PhpWord\Shared\Converter;
|
||||
use PhpOffice\PhpWord\Style\TablePosition;
|
||||
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
// New Word Document
|
||||
|
|
@ -27,7 +30,7 @@ $section->addTextBreak(1);
|
|||
$section->addText('Fancy table', $header);
|
||||
|
||||
$fancyTableStyleName = 'Fancy Table';
|
||||
$fancyTableStyle = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER);
|
||||
$fancyTableStyle = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80, 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER, 'cellSpacing' => 50);
|
||||
$fancyTableFirstRowStyle = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
|
||||
$fancyTableCellStyle = array('valign' => 'center');
|
||||
$fancyTableCellBtlrStyle = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
|
||||
|
|
@ -113,20 +116,20 @@ $phpWord->addTableStyle('Colspan Rowspan', $styleTable);
|
|||
$table = $section->addTable('Colspan Rowspan');
|
||||
|
||||
$row = $table->addRow();
|
||||
|
||||
$row->addCell(null, array('vMerge' => 'restart'))->addText('A');
|
||||
$row->addCell(null, array('gridSpan' => 2, 'vMerge' => 'restart'))->addText('B');
|
||||
$row->addCell()->addText('1');
|
||||
$row->addCell(1000, array('vMerge' => 'restart'))->addText('A');
|
||||
$row->addCell(1000, array('gridSpan' => 2, 'vMerge' => 'restart'))->addText('B');
|
||||
$row->addCell(1000)->addText('1');
|
||||
|
||||
$row = $table->addRow();
|
||||
$row->addCell(null, array('vMerge' => 'continue'));
|
||||
$row->addCell(null, array('vMerge' => 'continue', 'gridSpan' => 2));
|
||||
$row->addCell()->addText('2');
|
||||
$row->addCell(1000, array('vMerge' => 'continue'));
|
||||
$row->addCell(1000, array('vMerge' => 'continue', 'gridSpan' => 2));
|
||||
$row->addCell(1000)->addText('2');
|
||||
|
||||
$row = $table->addRow();
|
||||
$row->addCell(null, array('vMerge' => 'continue'));
|
||||
$row->addCell()->addText('C');
|
||||
$row->addCell()->addText('D');
|
||||
$row->addCell()->addText('3');
|
||||
$row->addCell(1000, array('vMerge' => 'continue'));
|
||||
$row->addCell(1000)->addText('C');
|
||||
$row->addCell(1000)->addText('D');
|
||||
$row->addCell(1000)->addText('3');
|
||||
|
||||
// 5. Nested table
|
||||
|
||||
|
|
@ -139,6 +142,15 @@ $cell->addText('This cell contains nested table.');
|
|||
$innerCell = $cell->addTable(array('alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER))->addRow()->addCell();
|
||||
$innerCell->addText('Inside nested table');
|
||||
|
||||
// 6. Table with floating position
|
||||
|
||||
$section->addTextBreak(2);
|
||||
$section->addText('Table with floating positioning.', $header);
|
||||
|
||||
$table = $section->addTable(array('borderSize' => 6, 'borderColor' => '999999', 'position' => array('vertAnchor' => TablePosition::VANCHOR_TEXT, 'bottomFromText' => Converter::cmToTwip(1))));
|
||||
$cell = $table->addRow()->addCell();
|
||||
$cell->addText('This is a single cell.');
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
if (!CLI) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
use PhpOffice\PhpWord\Element\Section;
|
||||
use PhpOffice\PhpWord\Shared\Converter;
|
||||
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
// New Word document
|
||||
|
|
@ -9,45 +12,48 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|||
$section = $phpWord->addSection();
|
||||
$section->addText('Local image without any styles:');
|
||||
$section->addImage('resources/_mars.jpg');
|
||||
$section->addTextBreak(2);
|
||||
|
||||
printSeparator($section);
|
||||
$section->addText('Local image with styles:');
|
||||
$section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
|
||||
$section->addTextBreak(2);
|
||||
|
||||
// Remote image
|
||||
printSeparator($section);
|
||||
$source = 'http://php.net/images/logos/php-med-trans-light.gif';
|
||||
$section->addText("Remote image from: {$source}");
|
||||
$section->addImage($source);
|
||||
|
||||
// Image from string
|
||||
printSeparator($section);
|
||||
$source = 'resources/_mars.jpg';
|
||||
$fileContent = file_get_contents($source);
|
||||
$section->addText('Image from string');
|
||||
$section->addImage($fileContent);
|
||||
|
||||
//Wrapping style
|
||||
$text = str_repeat('Hello World! ', 15);
|
||||
printSeparator($section);
|
||||
$text = str_repeat('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 2);
|
||||
$wrappingStyles = array('inline', 'behind', 'infront', 'square', 'tight');
|
||||
foreach ($wrappingStyles as $wrappingStyle) {
|
||||
$section->addTextBreak(5);
|
||||
$section->addText("Wrapping style {$wrappingStyle}");
|
||||
$section->addImage(
|
||||
'resources/_earth.jpg',
|
||||
array(
|
||||
'positioning' => 'relative',
|
||||
'marginTop' => -1,
|
||||
'marginLeft' => 1,
|
||||
'width' => 80,
|
||||
'height' => 80,
|
||||
'wrappingStyle' => $wrappingStyle,
|
||||
'positioning' => 'relative',
|
||||
'marginTop' => -1,
|
||||
'marginLeft' => 1,
|
||||
'width' => 80,
|
||||
'height' => 80,
|
||||
'wrappingStyle' => $wrappingStyle,
|
||||
'wrapDistanceRight' => Converter::cmToPoint(1),
|
||||
'wrapDistanceBottom' => Converter::cmToPoint(1),
|
||||
)
|
||||
);
|
||||
$section->addText($text);
|
||||
printSeparator($section);
|
||||
}
|
||||
|
||||
//Absolute positioning
|
||||
$section->addTextBreak(3);
|
||||
$section->addText('Absolute positioning: see top right corner of page');
|
||||
$section->addImage(
|
||||
'resources/_mars.jpg',
|
||||
|
|
@ -64,7 +70,7 @@ $section->addImage(
|
|||
);
|
||||
|
||||
//Relative positioning
|
||||
$section->addTextBreak(3);
|
||||
printSeparator($section);
|
||||
$section->addText('Relative positioning: Horizontal position center relative to column,');
|
||||
$section->addText('Vertical position top relative to line');
|
||||
$section->addImage(
|
||||
|
|
@ -80,6 +86,14 @@ $section->addImage(
|
|||
)
|
||||
);
|
||||
|
||||
function printSeparator(Section $section)
|
||||
{
|
||||
$section->addTextBreak();
|
||||
$lineStyle = array('weight' => 0.2, 'width' => 150, 'height' => 0, 'align' => 'center');
|
||||
$section->addLine($lineStyle);
|
||||
$section->addTextBreak(2);
|
||||
}
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
if (!CLI) {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ $listItemRun->addText(' in bold', array('bold' => true));
|
|||
$listItemRun = $section->addListItemRun();
|
||||
$listItemRun->addText('List item 2');
|
||||
$listItemRun->addText(' in italic', array('italic' => true));
|
||||
$footnote = $listItemRun->addFootnote();
|
||||
$footnote->addText('this is a footnote on a list item');
|
||||
$listItemRun = $section->addListItemRun();
|
||||
$listItemRun->addText('List item 3');
|
||||
$listItemRun->addText(' underlined', array('underline' => 'dash'));
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|||
$section = $phpWord->addSection();
|
||||
$section->addText('You can open this OLE object by double clicking on the icon:');
|
||||
$section->addTextBreak(2);
|
||||
$section->addObject('resources/_sheet.xls');
|
||||
$section->addOLEObject('resources/_sheet.xls');
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
|
|
|
|||
|
|
@ -12,13 +12,14 @@ $section = $phpWord->addSection();
|
|||
// Define styles
|
||||
$fontStyle12 = array('spaceAfter' => 60, 'size' => 12);
|
||||
$fontStyle10 = array('size' => 10);
|
||||
$phpWord->addTitleStyle(null, array('size' => 22, 'bold' => true));
|
||||
$phpWord->addTitleStyle(1, array('size' => 20, 'color' => '333333', 'bold' => true));
|
||||
$phpWord->addTitleStyle(2, array('size' => 16, 'color' => '666666'));
|
||||
$phpWord->addTitleStyle(3, array('size' => 14, 'italic' => true));
|
||||
$phpWord->addTitleStyle(4, array('size' => 12));
|
||||
|
||||
// Add text elements
|
||||
$section->addText('Table of contents 1');
|
||||
$section->addTitle('Table of contents 1', 0);
|
||||
$section->addTextBreak(2);
|
||||
|
||||
// Add TOC #1
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ $templateProcessor->deleteBlock('DELETEME');
|
|||
echo date('H:i:s'), ' Saving the result document...', EOL;
|
||||
$templateProcessor->saveAs('results/Sample_23_TemplateBlock.docx');
|
||||
|
||||
echo getEndingNotes(array('Word2007' => 'docx'));
|
||||
echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_23_TemplateBlock.docx');
|
||||
if (!CLI) {
|
||||
include_once 'Sample_Footer.php';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,31 +4,68 @@ include_once 'Sample_Header.php';
|
|||
// New Word Document
|
||||
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
$phpWord->addParagraphStyle('Heading2', array('alignment' => 'center'));
|
||||
|
||||
$section = $phpWord->addSection();
|
||||
$html = '<h1>Adding element via HTML</h1>';
|
||||
$html .= '<p>Some well formed HTML snippet needs to be used</p>';
|
||||
$html .= '<p>Some well-formed HTML snippet needs to be used</p>';
|
||||
$html .= '<p>With for example <strong>some<sup>1</sup> <em>inline</em> formatting</strong><sub>1</sub></p>';
|
||||
$html .= '<p>Unordered (bulleted) list:</p>';
|
||||
$html .= '<ul><li>Item 1</li><li>Item 2</li><ul><li>Item 2.1</li><li>Item 2.1</li></ul></ul>';
|
||||
$html .= '<p>Ordered (numbered) list:</p>';
|
||||
$html .= '<ol><li>Item 1</li><li>Item 2</li></ol>';
|
||||
|
||||
$html .= '<p>List with complex content:</p>';
|
||||
$html .= '<p>A link to <a href="http://phpword.readthedocs.io/" style="text-decoration: underline">Read the docs</a></p>';
|
||||
|
||||
$html .= '<p lang="he-IL" style="text-align: right; direction: rtl">היי, זה פסקה מימין לשמאל</p>';
|
||||
|
||||
$html .= '<p style="margin-top: 240pt;">Unordered (bulleted) list:</p>';
|
||||
$html .= '<ul><li>Item 1</li><li>Item 2</li><ul><li>Item 2.1</li><li>Item 2.1</li></ul></ul>';
|
||||
|
||||
$html .= '<p style="margin-top: 240pt;">1.5 line height with first line text indent:</p>';
|
||||
$html .= '<p style="text-align: justify; text-indent: 70.9pt; line-height: 150%;">Lorem ipsum dolor sit amet, <strong>consectetur adipiscing elit</strong>, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>';
|
||||
|
||||
$html .= '<h2 style="align: center">centered title</h2>';
|
||||
|
||||
$html .= '<p style="margin-top: 240pt;">Ordered (numbered) list:</p>';
|
||||
$html .= '<ol>
|
||||
<li><p style="font-weight: bold;">List 1 item 1</p></li>
|
||||
<li>List 1 item 2</li>
|
||||
<ol>
|
||||
<li>sub list 1</li>
|
||||
<li>sub list 2</li>
|
||||
</ol>
|
||||
<li>List 1 item 3</li>
|
||||
</ol>
|
||||
<p style="margin-top: 15px;">A second list, numbering should restart</p>
|
||||
<ol>
|
||||
<li>List 2 item 1</li>
|
||||
<li>List 2 item 2</li>
|
||||
<li>
|
||||
<ol>
|
||||
<li>sub list 1</li>
|
||||
<li>sub list 2</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>List 2 item 3</li>
|
||||
<ol>
|
||||
<li>sub list 1, restarts with a</li>
|
||||
<li>sub list 2</li>
|
||||
</ol>
|
||||
</ol>';
|
||||
|
||||
$html .= '<p style="margin-top: 240pt;">List with formatted content:</p>';
|
||||
$html .= '<ul>
|
||||
<li>
|
||||
<span style="font-family: arial,helvetica,sans-serif;">
|
||||
<span style="font-size: 12px;">list item1</span>
|
||||
<span style="font-size: 16px;">big list item1</span>
|
||||
</span>
|
||||
</li>
|
||||
<li>
|
||||
<span style="font-family: arial,helvetica,sans-serif;">
|
||||
<span style="font-size: 12px;">list item2</span>
|
||||
<span style="font-size: 10px; font-weight: bold;">list item2 in bold</span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>';
|
||||
|
||||
$html .= '<table style="width: 50%; border: 6px #0000FF double;">
|
||||
$html .= '<p style="margin-top: 240pt;">A table with formatting:</p>';
|
||||
$html .= '<table align="center" style="width: 50%; border: 6px #0000FF double;">
|
||||
<thead>
|
||||
<tr style="background-color: #FF0000; text-align: center; color: #FFFFFF; font-weight: bold; ">
|
||||
<th style="width: 50pt">header a</th>
|
||||
|
|
@ -38,10 +75,20 @@ $html .= '<table style="width: 50%; border: 6px #0000FF double;">
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr><td style="border-style: dotted;">1</td><td colspan="2">2</td></tr>
|
||||
<tr><td>4</td><td>5</td><td>6</td></tr>
|
||||
<tr><td>This is <b>bold</b> text</td><td></td><td>6</td></tr>
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
$html .= '<p style="margin-top: 240pt;">Table inside another table:</p>';
|
||||
$html .= '<table align="center" style="width: 80%; border: 6px #0000FF double;">
|
||||
<tr><td>
|
||||
<table style="width: 100%; border: 4px #FF0000 dotted;">
|
||||
<tr><td>column 1</td><td>column 2</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td style="text-align: center;">Cell in parent table</td></tr>
|
||||
</table>';
|
||||
|
||||
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html, false, false);
|
||||
|
||||
// Save file
|
||||
|
|
|
|||
|
|
@ -6,20 +6,26 @@ include_once 'Sample_Header.php';
|
|||
// New Word document
|
||||
echo date('H:i:s'), ' Create new PhpWord object', EOL;
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
PhpOffice\PhpWord\Style::addTitleStyle(1, array('size' => 14));
|
||||
|
||||
// New section
|
||||
$section = $phpWord->addSection();
|
||||
$section->addTitle('This page demos fields');
|
||||
|
||||
// Add Field elements
|
||||
// See Element/Field.php for all options
|
||||
$section->addText('Date field:');
|
||||
$section->addField('DATE', array('dateformat' => 'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat'));
|
||||
|
||||
$section->addText('Style Ref field:');
|
||||
$section->addField('STYLEREF', array('StyleIdentifier' => 'Heading 1'));
|
||||
|
||||
$section->addText('Page field:');
|
||||
$section->addField('PAGE', array('format' => 'Arabic'));
|
||||
|
||||
$section->addText('Number of pages field:');
|
||||
$section->addField('NUMPAGES', array('numformat' => '0,00', 'format' => 'Arabic'), array('PreserveFormat'));
|
||||
$section->addTextBreak();
|
||||
|
||||
$textrun = $section->addTextRun();
|
||||
$textrun->addText('An index field is ');
|
||||
|
|
@ -43,6 +49,19 @@ $textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleTy
|
|||
$textrun->addText('This is the date of lunar calendar ');
|
||||
$textrun->addField('DATE', array('dateformat' => 'd-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar'));
|
||||
$textrun->addText(' written in a textrun.');
|
||||
$section->addTextBreak();
|
||||
|
||||
$macroText = new TextRun();
|
||||
$macroText->addText('Double click', array('bold' => true));
|
||||
$macroText->addText(' to ');
|
||||
$macroText->addText('zoom to 100%', array('italic' => true));
|
||||
|
||||
$section->addText('A macro button with styled text:');
|
||||
$section->addField('MACROBUTTON', array('macroname' => 'Zoom100'), array(), $macroText);
|
||||
$section->addTextBreak();
|
||||
|
||||
$section->addText('A macro button with simple text:');
|
||||
$section->addField('MACROBUTTON', array('macroname' => 'Zoom100'), array(), 'double click to zoom');
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
|
|
|
|||
|
|
@ -16,18 +16,23 @@ $section = $phpWord->addSection();
|
|||
$section->addTitle('2D charts', 1);
|
||||
$section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous'));
|
||||
|
||||
$chartTypes = array('pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar');
|
||||
$twoSeries = array('bar', 'column', 'line', 'area', 'scatter', 'radar');
|
||||
$chartTypes = array('pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column');
|
||||
$twoSeries = array('bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column');
|
||||
$threeSeries = array('bar', 'line');
|
||||
$categories = array('A', 'B', 'C', 'D', 'E');
|
||||
$series1 = array(1, 3, 2, 5, 4);
|
||||
$series2 = array(3, 1, 7, 2, 6);
|
||||
$series3 = array(8, 3, 2, 5, 4);
|
||||
$showGridLines = false;
|
||||
$showAxisLabels = false;
|
||||
|
||||
foreach ($chartTypes as $chartType) {
|
||||
$section->addTitle(ucfirst($chartType), 2);
|
||||
$chart = $section->addChart($chartType, $categories, $series1);
|
||||
$chart->getStyle()->setWidth(Converter::inchToEmu(2.5))->setHeight(Converter::inchToEmu(2));
|
||||
$chart->getStyle()->setShowGridX($showGridLines);
|
||||
$chart->getStyle()->setShowGridY($showGridLines);
|
||||
$chart->getStyle()->setShowAxisLabels($showAxisLabels);
|
||||
if (in_array($chartType, $twoSeries)) {
|
||||
$chart->addSeries($categories, $series2);
|
||||
}
|
||||
|
|
@ -44,7 +49,14 @@ $section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous
|
|||
|
||||
$chartTypes = array('pie', 'bar', 'column', 'line', 'area');
|
||||
$multiSeries = array('bar', 'column', 'line', 'area');
|
||||
$style = array('width' => Converter::cmToEmu(5), 'height' => Converter::cmToEmu(4), '3d' => true);
|
||||
$style = array(
|
||||
'width' => Converter::cmToEmu(5),
|
||||
'height' => Converter::cmToEmu(4),
|
||||
'3d' => true,
|
||||
'showAxisLabels' => $showAxisLabels,
|
||||
'showGridX' => $showGridLines,
|
||||
'showGridY' => $showGridLines,
|
||||
);
|
||||
foreach ($chartTypes as $chartType) {
|
||||
$section->addTitle(ucfirst($chartType), 2);
|
||||
$chart = $section->addChart($chartType, $categories, $series1, $style);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
use PhpOffice\PhpWord\Element\TrackChange;
|
||||
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
// New Word Document
|
||||
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
|
||||
// New portrait section
|
||||
$section = $phpWord->addSection();
|
||||
$textRun = $section->addTextRun();
|
||||
|
||||
$text = $textRun->addText('Hello World! Time to ');
|
||||
|
||||
$text = $textRun->addText('wake ', array('bold' => true));
|
||||
$text->setChangeInfo(TrackChange::INSERTED, 'Fred', time() - 1800);
|
||||
|
||||
$text = $textRun->addText('up');
|
||||
$text->setTrackChange(new TrackChange(TrackChange::INSERTED, 'Fred'));
|
||||
|
||||
$text = $textRun->addText('go to sleep');
|
||||
$text->setChangeInfo(TrackChange::DELETED, 'Barney', new \DateTime('@' . (time() - 3600)));
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
if (!CLI) {
|
||||
include_once 'Sample_Footer.php';
|
||||
}
|
||||
|
|
@ -43,13 +43,19 @@ $pageHeading = IS_INDEX ? '' : "<h1>{$pageHeading}</h1>";
|
|||
// Populate samples
|
||||
$files = '';
|
||||
if ($handle = opendir('.')) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
$sampleFiles = array();
|
||||
while (false !== ($sampleFile = readdir($handle))) {
|
||||
$sampleFiles[] = $sampleFile;
|
||||
}
|
||||
sort($sampleFiles);
|
||||
closedir($handle);
|
||||
|
||||
foreach ($sampleFiles as $file) {
|
||||
if (preg_match('/^Sample_\d+_/', $file)) {
|
||||
$name = str_replace('_', ' ', preg_replace('/(Sample_|\.php)/', '', $file));
|
||||
$files .= "<li><a href='{$file}'>{$name}</a></li>";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -77,7 +83,7 @@ function write($phpWord, $filename, $writers)
|
|||
$result .= EOL;
|
||||
}
|
||||
|
||||
$result .= getEndingNotes($writers);
|
||||
$result .= getEndingNotes($writers, $filename);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
@ -86,10 +92,10 @@ function write($phpWord, $filename, $writers)
|
|||
* Get ending notes
|
||||
*
|
||||
* @param array $writers
|
||||
*
|
||||
* @param mixed $filename
|
||||
* @return string
|
||||
*/
|
||||
function getEndingNotes($writers)
|
||||
function getEndingNotes($writers, $filename)
|
||||
{
|
||||
$result = '';
|
||||
|
||||
|
|
@ -116,6 +122,12 @@ function getEndingNotes($writers)
|
|||
}
|
||||
}
|
||||
$result .= '</p>';
|
||||
|
||||
$result .= '<pre>';
|
||||
if (file_exists($filename . '.php')) {
|
||||
$result .= highlight_file($filename . '.php', true);
|
||||
}
|
||||
$result .= '</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -11,5 +11,15 @@
|
|||
<ul><li>Item 1</li><li>Item 2</li><ul><li>Item 2.1</li><li>Item 2.1</li></ul></ul>
|
||||
<p>Ordered (numbered) list:</p>
|
||||
<ol><li>Item 1</li><li>Item 2</li></ol>
|
||||
|
||||
<p style="line-height:2">Double height</p>
|
||||
|
||||
<h2>Includes images</h2>
|
||||
<img src="https://phpword.readthedocs.io/en/latest/_images/phpword.png" alt=""/>
|
||||
|
||||
<img src="https://localhost/gev/desarrollo/actividades/pruebas_14/5b064503587f7.jpeg" name="Imagen 12" align="bottom" width="208" height="183" border="0"/>
|
||||
<img src="http://localhost/gev/desarrollo/actividades/pruebas_14/5b064503589db.png" name="Imagen 13" align="bottom" width="143" height="202" border="0"/>
|
||||
<img src="http://localhost/gev/desarrollo/actividades/pruebas_14/5b0645035aac8.jpeg" name="Imagen 14" align="bottom" width="194" height="188" border="0"/>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -27,14 +27,14 @@ abstract class AbstractCollection
|
|||
/**
|
||||
* Items
|
||||
*
|
||||
* @var array
|
||||
* @var \PhpOffice\PhpWord\Element\AbstractContainer[]
|
||||
*/
|
||||
private $items = array();
|
||||
|
||||
/**
|
||||
* Get items
|
||||
*
|
||||
* @return array
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractContainer[]
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
|
|
@ -45,7 +45,7 @@ abstract class AbstractCollection
|
|||
* Get item by index
|
||||
*
|
||||
* @param int $index
|
||||
* @return mixed
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractContainer
|
||||
*/
|
||||
public function getItem($index)
|
||||
{
|
||||
|
|
@ -60,7 +60,7 @@ abstract class AbstractCollection
|
|||
* Set item.
|
||||
*
|
||||
* @param int $index
|
||||
* @param mixed $item
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $item
|
||||
*/
|
||||
public function setItem($index, $item)
|
||||
{
|
||||
|
|
@ -72,7 +72,7 @@ abstract class AbstractCollection
|
|||
/**
|
||||
* Add new item
|
||||
*
|
||||
* @param mixed $item
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $item
|
||||
* @return int
|
||||
*/
|
||||
public function addItem($item)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\ComplexType;
|
||||
|
||||
use PhpOffice\PhpWord\SimpleType\TblWidth as TblWidthSimpleType;
|
||||
|
||||
/**
|
||||
* @see http://www.datypic.com/sc/ooxml/t-w_CT_TblWidth.html
|
||||
*/
|
||||
final class TblWidth
|
||||
{
|
||||
/** @var string */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param int $value If omitted, then its value shall be assumed to be 0
|
||||
* @param string $type If omitted, then its value shall be assumed to be dxa
|
||||
*/
|
||||
public function __construct($value = 0, $type = TblWidthSimpleType::TWIP)
|
||||
{
|
||||
$this->value = $value;
|
||||
TblWidthSimpleType::validate($type);
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -33,11 +33,10 @@ namespace PhpOffice\PhpWord\Element;
|
|||
* @method CheckBox addCheckBox(string $name, $text, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method Title addTitle(string $text, int $depth = 1)
|
||||
* @method TOC addTOC(mixed $fontStyle = null, mixed $tocStyle = null, int $minDepth = 1, int $maxDepth = 9)
|
||||
*
|
||||
* @method PageBreak addPageBreak()
|
||||
* @method Table addTable(mixed $style = null)
|
||||
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false)
|
||||
* @method \PhpOffice\PhpWord\Element\Object addObject(string $source, mixed $style = null)
|
||||
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false, $name = null)
|
||||
* @method OLEObject addOLEObject(string $source, mixed $style = null)
|
||||
* @method TextBox addTextBox(mixed $style = null)
|
||||
* @method Field addField(string $type = null, array $properties = array(), array $options = array(), mixed $text = null)
|
||||
* @method Line addLine(mixed $lineStyle = null)
|
||||
|
|
@ -46,6 +45,8 @@ namespace PhpOffice\PhpWord\Element;
|
|||
* @method FormField addFormField(string $type, mixed $fStyle = null, mixed $pStyle = null)
|
||||
* @method SDT addSDT(string $type)
|
||||
*
|
||||
* @method \PhpOffice\PhpWord\Element\OLEObject addObject(string $source, mixed $style = null) deprecated, use addOLEObject instead
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
abstract class AbstractContainer extends AbstractElement
|
||||
|
|
@ -53,7 +54,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
/**
|
||||
* Elements collection
|
||||
*
|
||||
* @var array
|
||||
* @var \PhpOffice\PhpWord\Element\AbstractElement[]
|
||||
*/
|
||||
protected $elements = array();
|
||||
|
||||
|
|
@ -80,14 +81,14 @@ abstract class AbstractContainer extends AbstractElement
|
|||
{
|
||||
$elements = array(
|
||||
'Text', 'TextRun', 'Bookmark', 'Link', 'PreserveText', 'TextBreak',
|
||||
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object',
|
||||
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'OLEObject',
|
||||
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
|
||||
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
|
||||
'Chart', 'FormField', 'SDT', 'Comment',
|
||||
);
|
||||
$functions = array();
|
||||
foreach ($elements as $element) {
|
||||
$functions['add' . strtolower($element)] = $element;
|
||||
$functions['add' . strtolower($element)] = $element == 'Object' ? 'OLEObject' : $element;
|
||||
}
|
||||
|
||||
// Run valid `add` command
|
||||
|
|
@ -156,13 +157,48 @@ abstract class AbstractContainer extends AbstractElement
|
|||
/**
|
||||
* Get all elements
|
||||
*
|
||||
* @return array
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement[]
|
||||
*/
|
||||
public function getElements()
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the element at the requested position
|
||||
*
|
||||
* @param int $index
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement|null
|
||||
*/
|
||||
public function getElement($index)
|
||||
{
|
||||
if (array_key_exists($index, $this->elements)) {
|
||||
return $this->elements[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the element at requested index
|
||||
*
|
||||
* @param int|\PhpOffice\PhpWord\Element\AbstractElement $toRemove
|
||||
*/
|
||||
public function removeElement($toRemove)
|
||||
{
|
||||
if (is_int($toRemove) && array_key_exists($toRemove, $this->elements)) {
|
||||
unset($this->elements[$toRemove]);
|
||||
} elseif ($toRemove instanceof \PhpOffice\PhpWord\Element\AbstractElement) {
|
||||
foreach ($this->elements as $key => $element) {
|
||||
if ($element->getElementId() === $toRemove->getElementId()) {
|
||||
unset($this->elements[$key]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count elements
|
||||
*
|
||||
|
|
@ -193,20 +229,20 @@ abstract class AbstractContainer extends AbstractElement
|
|||
'Link' => $generalContainers,
|
||||
'TextBreak' => $generalContainers,
|
||||
'Image' => $generalContainers,
|
||||
'Object' => $generalContainers,
|
||||
'OLEObject' => $generalContainers,
|
||||
'Field' => $generalContainers,
|
||||
'Line' => $generalContainers,
|
||||
'Shape' => $generalContainers,
|
||||
'FormField' => $generalContainers,
|
||||
'SDT' => $generalContainers,
|
||||
'TrackChange' => $generalContainers,
|
||||
'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox', 'TrackChange'),
|
||||
'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox', 'TrackChange', 'ListItemRun'),
|
||||
'ListItem' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
||||
'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
||||
'Table' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
|
||||
'CheckBox' => array('Section', 'Header', 'Footer', 'Cell', 'TextRun'),
|
||||
'TextBox' => array('Section', 'Header', 'Footer', 'Cell'),
|
||||
'Footnote' => array('Section', 'TextRun', 'Cell'),
|
||||
'Footnote' => array('Section', 'TextRun', 'Cell', 'ListItemRun'),
|
||||
'Endnote' => array('Section', 'TextRun', 'Cell'),
|
||||
'PreserveText' => array('Section', 'Header', 'Footer', 'Cell'),
|
||||
'Title' => array('Section', 'Cell'),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -93,6 +93,20 @@ abstract class AbstractElement
|
|||
*/
|
||||
private $nestedLevel = 0;
|
||||
|
||||
/**
|
||||
* A reference to the parent
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* changed element info
|
||||
*
|
||||
* @var TrackChange
|
||||
*/
|
||||
private $trackChange;
|
||||
|
||||
/**
|
||||
* Parent container type
|
||||
*
|
||||
|
|
@ -321,6 +335,11 @@ abstract class AbstractElement
|
|||
$this->commentRangeEnd->setEndElement($this);
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent container
|
||||
*
|
||||
|
|
@ -328,9 +347,10 @@ abstract class AbstractElement
|
|||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $container
|
||||
*/
|
||||
public function setParentContainer(AbstractElement $container)
|
||||
public function setParentContainer(self $container)
|
||||
{
|
||||
$this->parentContainer = substr(get_class($container), strrpos(get_class($container), '\\') + 1);
|
||||
$this->parent = $container;
|
||||
|
||||
// Set nested level
|
||||
$this->nestedLevel = $container->getNestedLevel();
|
||||
|
|
@ -358,11 +378,14 @@ abstract class AbstractElement
|
|||
*/
|
||||
private function setMediaRelation()
|
||||
{
|
||||
if (!$this instanceof Link && !$this instanceof Image && !$this instanceof Object) {
|
||||
if (!$this instanceof Link && !$this instanceof Image && !$this instanceof OLEObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
$elementName = substr(get_class($this), strrpos(get_class($this), '\\') + 1);
|
||||
if ($elementName == 'OLEObject') {
|
||||
$elementName = 'Object';
|
||||
}
|
||||
$mediaPart = $this->getMediaPart();
|
||||
$source = $this->getSource();
|
||||
$image = null;
|
||||
|
|
@ -372,7 +395,7 @@ abstract class AbstractElement
|
|||
$rId = Media::addElement($mediaPart, strtolower($elementName), $source, $image);
|
||||
$this->setRelationId($rId);
|
||||
|
||||
if ($this instanceof Object) {
|
||||
if ($this instanceof OLEObject) {
|
||||
$icon = $this->getIcon();
|
||||
$rId = Media::addElement($mediaPart, 'image', $icon, new Image($icon));
|
||||
$this->setImageRelationId($rId);
|
||||
|
|
@ -422,6 +445,38 @@ abstract class AbstractElement
|
|||
return $style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the trackChange information
|
||||
*
|
||||
* @param TrackChange $trackChange
|
||||
*/
|
||||
public function setTrackChange(TrackChange $trackChange)
|
||||
{
|
||||
$this->trackChange = $trackChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the trackChange information
|
||||
*
|
||||
* @return TrackChange
|
||||
*/
|
||||
public function getTrackChange()
|
||||
{
|
||||
return $this->trackChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set changed
|
||||
*
|
||||
* @param string $type INSERTED|DELETED
|
||||
* @param string $author
|
||||
* @param null|int|\DateTime $date allways in UTC
|
||||
*/
|
||||
public function setChangeInfo($type, $author, $date = null)
|
||||
{
|
||||
$this->trackChange = new TrackChange($type, $author, $date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set enum value
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ class Bookmark extends AbstractElement
|
|||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($name)
|
||||
public function __construct($name = '')
|
||||
{
|
||||
$this->name = CommonText::toUTF8($name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -61,11 +61,12 @@ class Chart extends AbstractElement
|
|||
* @param array $categories
|
||||
* @param array $values
|
||||
* @param array $style
|
||||
* @param null|mixed $seriesName
|
||||
*/
|
||||
public function __construct($type, $categories, $values, $style = null)
|
||||
public function __construct($type, $categories, $values, $style = null, $seriesName = null)
|
||||
{
|
||||
$this->setType($type);
|
||||
$this->addSeries($categories, $values);
|
||||
$this->addSeries($categories, $values, $seriesName);
|
||||
$this->style = $this->setNewStyle(new ChartStyle(), $style, true);
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +87,7 @@ class Chart extends AbstractElement
|
|||
*/
|
||||
public function setType($value)
|
||||
{
|
||||
$enum = array('pie', 'doughnut', 'line', 'bar', 'column', 'area', 'radar', 'scatter');
|
||||
$enum = array('pie', 'doughnut', 'line', 'bar', 'stacked_bar', 'percent_stacked_bar', 'column', 'stacked_column', 'percent_stacked_column', 'area', 'radar', 'scatter');
|
||||
$this->type = $this->setEnumVal($value, $enum, 'pie');
|
||||
}
|
||||
|
||||
|
|
@ -95,10 +96,15 @@ class Chart extends AbstractElement
|
|||
*
|
||||
* @param array $categories
|
||||
* @param array $values
|
||||
* @param null|mixed $name
|
||||
*/
|
||||
public function addSeries($categories, $values)
|
||||
public function addSeries($categories, $values, $name = null)
|
||||
{
|
||||
$this->series[] = array('categories' => $categories, 'values' => $values);
|
||||
$this->series[] = array(
|
||||
'categories' => $categories,
|
||||
'values' => $values,
|
||||
'name' => $name,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -55,12 +55,12 @@ class Comment extends TrackChange
|
|||
* Create a new Comment Element
|
||||
*
|
||||
* @param string $author
|
||||
* @param \DateTime $date
|
||||
* @param null|\DateTime $date
|
||||
* @param string $initials
|
||||
*/
|
||||
public function __construct($author, $date = null, $initials = null)
|
||||
{
|
||||
parent::__construct($author, $date);
|
||||
parent::__construct(null, $author, $date);
|
||||
$this->initials = $initials;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -48,12 +48,28 @@ class Field extends AbstractElement
|
|||
),
|
||||
'DATE' => array(
|
||||
'properties' => array(
|
||||
'dateformat' => array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd',
|
||||
'd-MMM-yy', 'd/M/yyyy', 'd MMM. yy', 'd/M/yy', 'MMM-yy', 'd-M-yyy H:mm', 'd-M-yyyy H:mm:ss',
|
||||
'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss', ),
|
||||
'dateformat' => array(
|
||||
/* Generic formats */
|
||||
'yyyy-MM-dd', 'yyyy-MM', 'MMM-yy', 'MMM-yyyy', 'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss',
|
||||
/* Day-Month-Year formats */
|
||||
'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-MMM-yy', 'd MMM. yy',
|
||||
'd-M-yy', 'd-M-yy h:mm', 'd-M-yy h:mm:ss', 'd-M-yy h:mm am/pm', 'd-M-yy h:mm:ss am/pm', 'd-M-yy HH:mm', 'd-M-yy HH:mm:ss',
|
||||
'd/M/yy', 'd/M/yy h:mm', 'd/M/yy h:mm:ss', 'd/M/yy h:mm am/pm', 'd/M/yy h:mm:ss am/pm', 'd/M/yy HH:mm', 'd/M/yy HH:mm:ss',
|
||||
'd-M-yyyy', 'd-M-yyyy h:mm', 'd-M-yyyy h:mm:ss', 'd-M-yyyy h:mm am/pm', 'd-M-yyyy h:mm:ss am/pm', 'd-M-yyyy HH:mm', 'd-M-yyyy HH:mm:ss',
|
||||
'd/M/yyyy', 'd/M/yyyy h:mm', 'd/M/yyyy h:mm:ss', 'd/M/yyyy h:mm am/pm', 'd/M/yyyy h:mm:ss am/pm', 'd/M/yyyy HH:mm', 'd/M/yyyy HH:mm:ss',
|
||||
/* Month-Day-Year formats */
|
||||
'dddd, MMMM d yyyy', 'MMMM d yyyy', 'MMM-d-yy', 'MMM. d yy',
|
||||
'M-d-yy', 'M-d-yy h:mm', 'M-d-yy h:mm:ss', 'M-d-yy h:mm am/pm', 'M-d-yy h:mm:ss am/pm', 'M-d-yy HH:mm', 'M-d-yy HH:mm:ss',
|
||||
'M/d/yy', 'M/d/yy h:mm', 'M/d/yy h:mm:ss', 'M/d/yy h:mm am/pm', 'M/d/yy h:mm:ss am/pm', 'M/d/yy HH:mm', 'M/d/yy HH:mm:ss',
|
||||
'M-d-yyyy', 'M-d-yyyy h:mm', 'M-d-yyyy h:mm:ss', 'M-d-yyyy h:mm am/pm', 'M-d-yyyy h:mm:ss am/pm', 'M-d-yyyy HH:mm', 'M-d-yyyy HH:mm:ss',
|
||||
'M/d/yyyy', 'M/d/yyyy h:mm', 'M/d/yyyy h:mm:ss', 'M/d/yyyy h:mm am/pm', 'M/d/yyyy h:mm:ss am/pm', 'M/d/yyyy HH:mm', 'M/d/yyyy HH:mm:ss',
|
||||
),
|
||||
),
|
||||
'options' => array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat'),
|
||||
),
|
||||
'MACROBUTTON' => array(
|
||||
'properties' => array('macroname' => ''),
|
||||
),
|
||||
'XE' => array(
|
||||
'properties' => array(),
|
||||
'options' => array('Bold', 'Italic'),
|
||||
|
|
@ -62,6 +78,10 @@ class Field extends AbstractElement
|
|||
'properties' => array(),
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
'STYLEREF' => array(
|
||||
'properties' => array('StyleIdentifier' => ''),
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
@ -92,6 +112,13 @@ class Field extends AbstractElement
|
|||
*/
|
||||
protected $options = array();
|
||||
|
||||
/**
|
||||
* Font style
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font
|
||||
*/
|
||||
protected $fontStyle;
|
||||
|
||||
/**
|
||||
* Create a new Field Element
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -65,6 +65,13 @@ class Image extends AbstractElement
|
|||
*/
|
||||
private $watermark;
|
||||
|
||||
/**
|
||||
* Name of image
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Image type
|
||||
*
|
||||
|
|
@ -127,15 +134,17 @@ class Image extends AbstractElement
|
|||
* @param string $source
|
||||
* @param mixed $style
|
||||
* @param bool $watermark
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||
*/
|
||||
public function __construct($source, $style = null, $watermark = false)
|
||||
public function __construct($source, $style = null, $watermark = false, $name = null)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->setIsWatermark($watermark);
|
||||
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
||||
$this->setIsWatermark($watermark);
|
||||
$this->setName($name);
|
||||
|
||||
$this->checkImage();
|
||||
}
|
||||
|
|
@ -170,6 +179,26 @@ class Image extends AbstractElement
|
|||
return $this->sourceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image name
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setName($value)
|
||||
{
|
||||
$this->name = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image name
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image media ID
|
||||
*
|
||||
|
|
@ -313,7 +342,7 @@ class Image extends AbstractElement
|
|||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFilename) !== false) {
|
||||
if ($zip->locateName($imageFilename)) {
|
||||
if ($zip->locateName($imageFilename) !== false) {
|
||||
$isTemp = true;
|
||||
$zip->extractTo(Settings::getTempDir(), $imageFilename);
|
||||
$actualSource = Settings::getTempDir() . DIRECTORY_SEPARATOR . $imageFilename;
|
||||
|
|
@ -334,6 +363,10 @@ class Image extends AbstractElement
|
|||
// Read image binary data and convert to hex/base64 string
|
||||
if ($this->sourceType == self::SOURCE_GD) {
|
||||
$imageResource = call_user_func($this->imageCreateFunc, $actualSource);
|
||||
if ($this->imageType === 'image/png') {
|
||||
// PNG images need to preserve alpha channel information
|
||||
imagesavealpha($imageResource, true);
|
||||
}
|
||||
ob_start();
|
||||
call_user_func($this->imageFunc, $imageResource);
|
||||
$imageBinary = ob_get_contents();
|
||||
|
|
@ -454,7 +487,7 @@ class Image extends AbstractElement
|
|||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFilename) !== false) {
|
||||
if ($zip->locateName($imageFilename)) {
|
||||
if ($zip->locateName($imageFilename) !== false) {
|
||||
$imageContent = $zip->getFromName($imageFilename);
|
||||
if ($imageContent !== false) {
|
||||
file_put_contents($tempFilename, $imageContent);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ class ListItem extends AbstractElement
|
|||
|
||||
// Version >= 0.10.0 will pass numbering style name. Older version will use old method
|
||||
if (!is_null($listStyle) && is_string($listStyle)) {
|
||||
$this->style = new ListItemStyle($listStyle);
|
||||
$this->style = new ListItemStyle($listStyle); // @codeCoverageIgnore
|
||||
} else {
|
||||
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -21,9 +21,9 @@ use PhpOffice\PhpWord\Exception\InvalidObjectException;
|
|||
use PhpOffice\PhpWord\Style\Image as ImageStyle;
|
||||
|
||||
/**
|
||||
* Object element
|
||||
* OLEObject element
|
||||
*/
|
||||
class Object extends AbstractElement
|
||||
class OLEObject extends AbstractElement
|
||||
{
|
||||
/**
|
||||
* Ole-Object Src
|
||||
|
|
@ -83,7 +83,7 @@ class Object extends AbstractElement
|
|||
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
||||
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
|
||||
|
||||
return $this;
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidObjectException();
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class PreserveText extends AbstractElement
|
|||
/**
|
||||
* Text content
|
||||
*
|
||||
* @var string
|
||||
* @var string|array
|
||||
*/
|
||||
private $text;
|
||||
|
||||
|
|
@ -64,8 +64,6 @@ class PreserveText extends AbstractElement
|
|||
if (isset($matches[0])) {
|
||||
$this->text = $matches;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -91,7 +89,7 @@ class PreserveText extends AbstractElement
|
|||
/**
|
||||
* Get Text content
|
||||
*
|
||||
* @return string
|
||||
* @return string|array
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -135,18 +135,40 @@ class Table extends AbstractElement
|
|||
public function countColumns()
|
||||
{
|
||||
$columnCount = 0;
|
||||
if (is_array($this->rows)) {
|
||||
$rowCount = count($this->rows);
|
||||
for ($i = 0; $i < $rowCount; $i++) {
|
||||
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
|
||||
$row = $this->rows[$i];
|
||||
$cellCount = count($row->getCells());
|
||||
if ($columnCount < $cellCount) {
|
||||
$columnCount = $cellCount;
|
||||
}
|
||||
|
||||
$rowCount = count($this->rows);
|
||||
for ($i = 0; $i < $rowCount; $i++) {
|
||||
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
|
||||
$row = $this->rows[$i];
|
||||
$cellCount = count($row->getCells());
|
||||
if ($columnCount < $cellCount) {
|
||||
$columnCount = $cellCount;
|
||||
}
|
||||
}
|
||||
|
||||
return $columnCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* The first declared cell width for each column
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function findFirstDefinedCellWidths()
|
||||
{
|
||||
$cellWidths = array();
|
||||
|
||||
foreach ($this->rows as $row) {
|
||||
$cells = $row->getCells();
|
||||
if (count($cells) <= count($cellWidths)) {
|
||||
continue;
|
||||
}
|
||||
$cellWidths = array();
|
||||
foreach ($cells as $cell) {
|
||||
$cellWidths[] = $cell->getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
return $cellWidths;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ class Title extends AbstractElement
|
|||
/**
|
||||
* Title Text content
|
||||
*
|
||||
* @var string
|
||||
* @var string|TextRun
|
||||
*/
|
||||
private $text;
|
||||
|
||||
|
|
@ -56,18 +56,24 @@ class Title extends AbstractElement
|
|||
/**
|
||||
* Create a new Title Element
|
||||
*
|
||||
* @param string $text
|
||||
* @param string|TextRun $text
|
||||
* @param int $depth
|
||||
*/
|
||||
public function __construct($text, $depth = 1)
|
||||
{
|
||||
$this->text = CommonText::toUTF8($text);
|
||||
$this->depth = $depth;
|
||||
if (array_key_exists("Heading_{$this->depth}", Style::getStyles())) {
|
||||
$this->style = "Heading{$this->depth}";
|
||||
if (is_string($text)) {
|
||||
$this->text = CommonText::toUTF8($text);
|
||||
} elseif ($text instanceof TextRun) {
|
||||
$this->text = $text;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid text, should be a string or a TextRun');
|
||||
}
|
||||
|
||||
return $this;
|
||||
$this->depth = $depth;
|
||||
$styleName = $depth === 0 ? 'Title' : "Heading_{$this->depth}";
|
||||
if (array_key_exists($styleName, Style::getStyles())) {
|
||||
$this->style = str_replace('_', '', $styleName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -20,14 +20,25 @@ namespace PhpOffice\PhpWord\Element;
|
|||
/**
|
||||
* TrackChange element
|
||||
* @see http://datypic.com/sc/ooxml/t-w_CT_TrackChange.html
|
||||
* @see http://datypic.com/sc/ooxml/t-w_CT_RunTrackChange.html
|
||||
*/
|
||||
class TrackChange extends AbstractContainer
|
||||
{
|
||||
const INSERTED = 'INSERTED';
|
||||
const DELETED = 'DELETED';
|
||||
|
||||
/**
|
||||
* @var string Container type
|
||||
*/
|
||||
protected $container = 'TrackChange';
|
||||
|
||||
/**
|
||||
* The type of change, (insert or delete), not applicable for PhpOffice\PhpWord\Element\Comment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $changeType;
|
||||
|
||||
/**
|
||||
* Author
|
||||
*
|
||||
|
|
@ -45,13 +56,17 @@ class TrackChange extends AbstractContainer
|
|||
/**
|
||||
* Create a new TrackChange Element
|
||||
*
|
||||
* @param string $changeType
|
||||
* @param string $author
|
||||
* @param \DateTime $date
|
||||
* @param null|int|\DateTime $date
|
||||
*/
|
||||
public function __construct($author, \DateTime $date = null)
|
||||
public function __construct($changeType = null, $author = null, $date = null)
|
||||
{
|
||||
$this->changeType = $changeType;
|
||||
$this->author = $author;
|
||||
$this->date = $date;
|
||||
if ($date !== null) {
|
||||
$this->date = ($date instanceof \DateTime) ? $date : new \DateTime('@' . $date);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,4 +88,14 @@ class TrackChange extends AbstractContainer
|
|||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Change type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getChangeType()
|
||||
{
|
||||
return $this->changeType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Metadata;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder;
|
||||
use PhpOffice\Common\Microsoft\PasswordEncoder;
|
||||
use PhpOffice\PhpWord\SimpleType\DocProtect;
|
||||
|
||||
/**
|
||||
|
|
@ -113,7 +113,7 @@ class Protection
|
|||
/**
|
||||
* Set password
|
||||
*
|
||||
* @param $password
|
||||
* @param string $password
|
||||
* @return self
|
||||
*/
|
||||
public function setPassword($password)
|
||||
|
|
@ -136,7 +136,7 @@ class Protection
|
|||
/**
|
||||
* Set count for hash iterations
|
||||
*
|
||||
* @param $spinCount
|
||||
* @param int $spinCount
|
||||
* @return self
|
||||
*/
|
||||
public function setSpinCount($spinCount)
|
||||
|
|
@ -159,7 +159,7 @@ class Protection
|
|||
/**
|
||||
* Set algorithm
|
||||
*
|
||||
* @param $algorithm
|
||||
* @param string $algorithm
|
||||
* @return self
|
||||
*/
|
||||
public function setAlgorithm($algorithm)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -130,6 +130,32 @@ class Settings
|
|||
*/
|
||||
private $decimalSymbol = '.';
|
||||
|
||||
/**
|
||||
* Automatically hyphenate document contents when displayed
|
||||
*
|
||||
* @var bool|null
|
||||
*/
|
||||
private $autoHyphenation;
|
||||
|
||||
/**
|
||||
* Maximum number of consecutively hyphenated lines
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private $consecutiveHyphenLimit;
|
||||
|
||||
/**
|
||||
* The allowed amount of whitespace before hyphenation is applied
|
||||
* @var float|null
|
||||
*/
|
||||
private $hyphenationZone;
|
||||
|
||||
/**
|
||||
* Do not hyphenate words in all capital letters
|
||||
* @var bool|null
|
||||
*/
|
||||
private $doNotHyphenateCaps;
|
||||
|
||||
/**
|
||||
* @return Protection
|
||||
*/
|
||||
|
|
@ -387,4 +413,68 @@ class Settings
|
|||
{
|
||||
$this->decimalSymbol = $decimalSymbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|null
|
||||
*/
|
||||
public function hasAutoHyphenation()
|
||||
{
|
||||
return $this->autoHyphenation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $autoHyphenation
|
||||
*/
|
||||
public function setAutoHyphenation($autoHyphenation)
|
||||
{
|
||||
$this->autoHyphenation = (bool) $autoHyphenation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getConsecutiveHyphenLimit()
|
||||
{
|
||||
return $this->consecutiveHyphenLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $consecutiveHyphenLimit
|
||||
*/
|
||||
public function setConsecutiveHyphenLimit($consecutiveHyphenLimit)
|
||||
{
|
||||
$this->consecutiveHyphenLimit = (int) $consecutiveHyphenLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float|null
|
||||
*/
|
||||
public function getHyphenationZone()
|
||||
{
|
||||
return $this->hyphenationZone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $hyphenationZone Measurement unit is twip
|
||||
*/
|
||||
public function setHyphenationZone($hyphenationZone)
|
||||
{
|
||||
$this->hyphenationZone = $hyphenationZone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|bool
|
||||
*/
|
||||
public function hasDoNotHyphenateCaps()
|
||||
{
|
||||
return $this->doNotHyphenateCaps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $doNotHyphenateCaps
|
||||
*/
|
||||
public function setDoNotHyphenateCaps($doNotHyphenateCaps)
|
||||
{
|
||||
$this->doNotHyphenateCaps = (bool) $doNotHyphenateCaps;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
@ -35,10 +35,10 @@ use PhpOffice\PhpWord\Exception\Exception;
|
|||
* @method int addChart(Element\Chart $chart)
|
||||
* @method int addComment(Element\Comment $comment)
|
||||
*
|
||||
* @method Style\Paragraph addParagraphStyle(string $styleName, array $styles)
|
||||
* @method Style\Paragraph addParagraphStyle(string $styleName, mixed $styles)
|
||||
* @method Style\Font addFontStyle(string $styleName, mixed $fontStyle, mixed $paragraphStyle = null)
|
||||
* @method Style\Font addLinkStyle(string $styleName, mixed $styles)
|
||||
* @method Style\Font addTitleStyle(int $depth, mixed $fontStyle, mixed $paragraphStyle = null)
|
||||
* @method Style\Font addTitleStyle(mixed $depth, mixed $fontStyle, mixed $paragraphStyle = null)
|
||||
* @method Style\Table addTableStyle(string $styleName, mixed $styleTable, mixed $styleFirstRow = null)
|
||||
* @method Style\Numbering addNumberingStyle(string $styleName, mixed $styles)
|
||||
*/
|
||||
|
|
@ -52,8 +52,17 @@ class PhpWord
|
|||
* @const string|int
|
||||
*/
|
||||
const DEFAULT_FONT_NAME = Settings::DEFAULT_FONT_NAME;
|
||||
/**
|
||||
* @deprecated 0.11.0 Use Settings constants
|
||||
*/
|
||||
const DEFAULT_FONT_SIZE = Settings::DEFAULT_FONT_SIZE;
|
||||
/**
|
||||
* @deprecated 0.11.0 Use Settings constants
|
||||
*/
|
||||
const DEFAULT_FONT_COLOR = Settings::DEFAULT_FONT_COLOR;
|
||||
/**
|
||||
* @deprecated 0.11.0 Use Settings constants
|
||||
*/
|
||||
const DEFAULT_FONT_CONTENT_TYPE = Settings::DEFAULT_FONT_CONTENT_TYPE;
|
||||
|
||||
/**
|
||||
|
|
@ -85,6 +94,10 @@ class PhpWord
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Reset Media and styles
|
||||
Media::resetElements();
|
||||
Style::resetStyles();
|
||||
|
||||
// Collection
|
||||
$collections = array('Bookmarks', 'Titles', 'Footnotes', 'Endnotes', 'Charts', 'Comments');
|
||||
foreach ($collections as $collection) {
|
||||
|
|
@ -212,6 +225,21 @@ class PhpWord
|
|||
return $this->sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the section at the requested position
|
||||
*
|
||||
* @param int $index
|
||||
* @return \PhpOffice\PhpWord\Element\Section|null
|
||||
*/
|
||||
public function getSection($index)
|
||||
{
|
||||
if (array_key_exists($index, $this->sections)) {
|
||||
return $this->sections[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new section
|
||||
*
|
||||
|
|
@ -227,6 +255,17 @@ class PhpWord
|
|||
return $section;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the sections using the callable passed
|
||||
*
|
||||
* @see http://php.net/manual/en/function.usort.php for usage
|
||||
* @param callable $sorter
|
||||
*/
|
||||
public function sortSections($sorter)
|
||||
{
|
||||
usort($this->sections, $sorter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default font name
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2017 PHPWord contributors
|
||||
* @copyright 2010-2018 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue