Compare commits

...

419 Commits

Author SHA1 Message Date
Ahmad Syamim
08064480ea
Update recipes.rst (#2367) 2023-01-08 09:39:08 +01:00
Erik Hazington
aac3a601e1
Add support for fractional font sizes (#2363)
* Add support for fractional font sizes

Word supports fractional font sizes like 8.5pt, but PHPWord doesn't.

* Add background color support for textboxes

* Add background color support for text boxes for Word writer

* Added period to the comments to match the cs-fixer configuration

* Fixed cs-fixer issues.

* Added type hints and matching PHPDoc. Also added @return void.

* Added bgcolor unit test coverage

* Removed @return void as not compatible with projects coding standard.

* Fixed several CS-Fixer issues

* Replaced deprecated "assertRegExp" test method by assertMatchesRegularExpression.

* Address the CI coverage issue for the regex match assertion.

* Add support for fractional font sizes

Word supports fractional font sizes like 8.5pt, but PHPWord doesn't.

* The default font size method now supports int and float font sizes. Added type hinting to settings class and unit test coverage for fractional (float) font size.

* The default font size method now supports int and float font sizes. Added type hinting to settings class and unit test coverage for fractional (float) font size.

Co-authored-by: hazington <hazington@eweso.de>
Co-authored-by: Progi1984 <progi1984@gmail.com>
2023-01-06 21:04:39 +01:00
Yohann Tilotti
ef99fac8e1
Add support table row height when importing HTML (#2350)
* Add support table row height when importing HTML

* fix space

* fix phpcsfixer

* Add test table row height

* Fix xpath test table row height

* Fix attribute first test table row height

* Fix $cValue

Co-authored-by: Progi1984 <progi1984@gmail.com>

* Fix css

* Fix test on pt

Co-authored-by: Progi1984 <progi1984@gmail.com>
2023-01-06 16:26:34 +01:00
Progi1984
60734dd7f1
Merge pull request #2277 from amir9480/patch-1
Add softhyphen support to Word2007 Reader
2023-01-05 22:04:27 +01:00
Progi1984
ed8d9ff420
Fixed some stylelint 2023-01-05 21:53:50 +01:00
Progi1984
a379577ac9
Merge pull request #2364 from hazington/patch-5
Add background color support for text box element for Word writer
2023-01-04 09:23:26 +01:00
hazington
53d34fd049 Address the CI coverage issue for the regex match assertion. 2023-01-04 00:07:39 +01:00
hazington
679a738c42 Replaced deprecated "assertRegExp" test method by assertMatchesRegularExpression. 2023-01-03 23:56:04 +01:00
hazington
0f6fbf2b11 Fixed several CS-Fixer issues 2023-01-03 23:44:51 +01:00
hazington
050802bdb5 Removed @return void as not compatible with projects coding standard. 2023-01-03 23:38:08 +01:00
hazington
a215501cc9 Added bgcolor unit test coverage 2023-01-03 23:35:37 +01:00
hazington
1a80aacb4f Added type hints and matching PHPDoc. Also added @return void. 2023-01-03 23:26:02 +01:00
Erik Hazington
40d5770651
Fixed cs-fixer issues. 2022-12-30 21:50:28 +01:00
Erik Hazington
143e01b29b
Added period to the comments to match the cs-fixer configuration 2022-12-30 21:46:44 +01:00
Erik Hazington
25575c80ca
Add background color support for text boxes for Word writer 2022-12-30 21:34:47 +01:00
Erik Hazington
1dc3dc6ce5
Add background color support for textboxes 2022-12-30 21:32:48 +01:00
Progi1984
b453cf00ff
Merge pull request #2261 from ismail1432/customize-macro
Allow to customize macro delimiters in TemplateProcessor
2022-12-23 19:36:07 +01:00
Progi1984
f195d282d0
Merge pull request #2111 from brammeleman/patch-1
Fixed code example
2022-11-29 22:04:08 +01:00
Progi1984
b2dfa65698
Merge pull request #1848 from rikvdlooi/patch-1
Fixed setting width of Cell Style
2022-11-29 21:46:07 +01:00
Progi1984
be499388da
Merge pull request #2336 from kernusr/read-empty-vmerge
Word2007 : Read empty vmerge
2022-11-29 21:40:09 +01:00
Adrien Crivelli
20f3a3e370
Use pcov instead of xdebug because it is much faster 2022-11-29 11:09:02 +01:00
Adrien Crivelli
803cdee4f3
Use local install of friendsofphp/php-cs-fixer
Otherwise, `composer check` and `composer fix` are broken and contributing
becomes much harder than it should be. Also using the same version
everywhere is a benefit to get consistent result locally and on CI.
2022-11-29 10:50:45 +01:00
Progi1984
25de4b819c Fixed PHPCSFixer error 2022-11-23 20:36:39 +00:00
Progi1984
6041bb3fb5
Merge pull request #2339 from Progi1984/className
HTML Reader : Set style name from the CSS class (and if not CSS is loaded)
2022-11-23 13:47:30 +01:00
Progi1984
249e049894
Merge pull request #2171 from amgad-naiem/patch-1
Added Swedish language
2022-11-23 13:44:11 +01:00
Progi1984
9658c12084
Merge pull request #2308 from fbclol/develop
Call static instead of self on protected method
2022-11-23 13:41:37 +01:00
Progi1984
83f6b020b3
Merge pull request #2329 from nicoder/improve-phpdoc
improve TemplateProcessor#setValueForPart parameter phpdoc
2022-11-23 13:34:28 +01:00
Progi1984
d721b5eda7 HTML Reader : Set style name from the CSS class (and if not CSS is loaded) 2022-11-23 13:32:03 +01:00
Progi1984
02e3aa96b6
Merge pull request #2338 from Progi1984/className
HTML Reader : Set style name from the CSS class
2022-11-22 21:53:53 +01:00
Progi1984
02a92c8924 HTML Reader : Set style name from the CSS class 2022-11-22 21:38:41 +01:00
Artem Vasilev
b457ff5f7f set default value for vMerge 2022-11-22 13:45:55 +03:00
Artem Vasilev
573f1c3ea1 set default value on empty value attribute 2022-11-22 13:43:03 +03:00
Nicolas Dermine
0189977743 improve phpdoc
The `tempDocumentHeaders` and `tempDocumentFooters` array attributes are
passed to this method parameter
2022-11-20 07:56:42 +01:00
Franck Boué
9afd53d622
remove - 2022-11-18 13:44:35 +01:00
Franck Boué
a075740e32
remove espaces 2022-11-18 13:38:18 +01:00
Franck Boué
ecd2fcbda8
add blank lines 2022-11-18 13:34:21 +01:00
Franck Boué
9ed82d1f5a
delete blank lines 2022-11-18 13:31:04 +01:00
Progi1984
0af4ca1f6e
Merge pull request #2327 from Progi1984/htmlReaderExtractCssStyle
HTML Reader : Add basic support for CSS Style Tag
2022-11-18 10:42:04 +01:00
Progi1984
228bada972
Remove stale Github Actions 2022-11-18 10:37:07 +01:00
Adrien Crivelli
6deea59905
Update GitHub Actions 2022-11-17 14:39:30 +01:00
Adrien Crivelli
95ce998651
Drop obsolete coverall references
Instead, we've been using Scrutinizer for a while
2022-11-17 09:53:27 +01:00
Adrien Crivelli
c37be288a5
Consume half of the 1000 operations per hour limit of GitHub API 2022-11-17 09:45:21 +01:00
Adrien Crivelli
28ca75eca4
Close oldest stale issues first 2022-11-16 22:55:44 +01:00
Adrien Crivelli
0b9f30fc77
Remove all traces of Travis 2022-11-16 22:35:01 +01:00
Adrien Crivelli
d2c6b9f790
master is the new default branch
`master` is now the only permanent branch. Features and fixes should be merged
into `master` when stable. Pull requests should be forked from `master`.

`develop` branch disappear entirely in favor of temporary features/fixes branches.
2022-11-16 22:27:10 +01:00
Adrien Crivelli
a771de75b9
Keep things as private as possible 2022-11-16 22:02:21 +01:00
Progi1984
ab3a2c0418 HTML Reader : Add basic support for CSS Style Tag 2022-11-16 22:02:07 +01:00
Adrien Crivelli
14c6e6f370
Merge pull request #2104 from simivar/feature/delete-row
Introduce deleteRow() method for TemplateProcessor
2022-11-16 21:58:25 +01:00
Adrien Crivelli
8521612b39
1.0.0 2022-11-15 21:24:50 +01:00
simivar
f482f2600b CS Fixer 2022-11-07 22:38:19 +01:00
Krystian Marcisz
46e61d4c18 Apply suggestions from code review
Co-authored-by: Progi1984 <progi1984@gmail.com>
2022-11-06 19:19:25 +01:00
Krystian Marcisz
4b7e7e4612 Update src/PhpWord/TemplateProcessor.php
Co-authored-by: Progi1984 <progi1984@gmail.com>
2022-11-06 19:19:25 +01:00
Krystian Marcisz
9a6eb6970d Update src/PhpWord/TemplateProcessor.php
Co-authored-by: Progi1984 <progi1984@gmail.com>
2022-11-06 19:19:25 +01:00
simivar
91504dfddc Introduce deleteRow() method for TemplateProcessor 2022-11-06 19:19:23 +01:00
Adrien Crivelli
fab9966b8c
Code style 2022-10-24 11:25:54 +02:00
Adrien Crivelli
e81520f94c
Document PHP 7.1 support
Fixes #2302
2022-10-24 11:08:15 +02:00
Franck
024fdf9c1a call static instead of self on protected method 2022-10-07 16:04:39 +02:00
Smaine Milianni
c4bcba9741 allow to customize macro in TemplateProcessor 2022-09-30 11:51:05 +01:00
Progi1984
f92ec7e3ad
Merge pull request #2302 from Progi1984/php7.1+
Support for PHP7.1 (min.)
2022-09-26 08:52:37 +02:00
Progi1984
c3e34a0d24 Support for PHP7.1 (min.) 2022-09-25 22:15:11 +02:00
Progi1984
c467fe02d3
Merge pull request #2301 from Progi1984/htmlTableStyleAttribute
HTML Reader : Override inline style on HTML attribute for table
2022-09-25 21:34:08 +02:00
Progi1984
f8d0b2ad87 HTML Reader : Override inline style on HTML attribute for table 2022-09-25 21:18:39 +02:00
Adrien Crivelli
02ccca1551
Configure actions/stale 2022-09-20 11:50:08 +02:00
Manunchik
f80f660457
Add PhpOffice\PhpWord\Cell\IOFactory::createWriter unit test 2022-09-20 11:12:53 +02:00
Adrien Crivelli
2b7b4ddc5f
Revert "Add destructor wich will try to clean up temp file of the template"
This reverts commit e9cd17d4c7bc0ab4df09e858284369dbf7a98fff. Because
the temp file is the result of the `save()` method and it's up to the calling
code to handle the result appropriately. Or alternatively use `saveAs()` to
avoid handling it.
2022-09-20 11:05:16 +02:00
Adrien Crivelli
99d4b29471
Use PSR autoloading 2022-09-20 10:05:08 +02:00
Adrien Crivelli
62444d2161
Merge pull request #2176 from maartendekeizer/cleanuptempfile
[TemplateProcessor] Clean up temp files
2022-09-17 23:21:07 +02:00
Adrien Crivelli
969448ff12
Merge pull request #2177 from tvbeek/patch-1
Update homepage in composer.json
2022-09-17 23:20:16 +02:00
Adrien Crivelli
b9f1151bc6
Drop most deprecations 2022-09-16 16:29:15 +02:00
Adrien Crivelli
c5e7a535e6
Fix phpmd violation 2022-09-16 14:24:22 +02:00
Adrien Crivelli
a49618f248
Don't hardcode version number in documentation 2022-09-16 14:23:58 +02:00
Adrien Crivelli
d59591b7ab
Automatic code style 2022-09-16 14:14:57 +02:00
Adrien Crivelli
5b5de9e514
symfony/process is only a dep for dev 2022-09-16 14:11:55 +02:00
Adrien Crivelli
c8d360e095
Use PSR autoload mechanism for tests 2022-09-16 14:09:17 +02:00
Adrien Crivelli
2bc75771cc
Use same code style as PhpSpreadsheet 2022-09-16 11:45:45 +02:00
Adrien Crivelli
25c56a3e2d
Update all PHP dependencies
This way we can share the same dependencies across PHP 7.4 to PHP 8.1,
and simplify our CI pipeline
2022-09-16 11:27:29 +02:00
Adrien Crivelli
207438270f
Drop implicit code coverage
Because not all PHP installs have code coverage enabled, and that makes
testing more difficult, and slower than necessary. Instead, use local config
if you need to always have code coverage.
2022-09-16 10:19:51 +02:00
Adrien Crivelli
0e8bcb63e7
Drop PHP 7.3 and older
This is according to our formal, published, policy to only support
eol PHP after 6 months within PHPOffice organisation.

See https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support
2022-09-16 10:17:31 +02:00
Adrien Crivelli
2ee6df65bc
Merge pull request #2272 from seamuslee001/php81_locale
PHP8.1 Fix issue with passing NULL value for locale into string function
2022-09-16 00:16:31 +02:00
Adrien Crivelli
82769b9736
Merge pull request #2209 from RismaSystems/PHP8.1-fixes
PHP 8.1 compatability fix for PreserveText and XMLWriter
2022-09-16 00:14:09 +02:00
Adrien Crivelli
93e16d4001
Merge pull request #2292 from neopheus/php8.1-fix-2290
Php 8.1 fix #2290
2022-09-16 00:12:45 +02:00
Adrien Crivelli
f853b9f125
Tolerate small imprecisions 2022-09-15 21:43:36 +02:00
Adrien Crivelli
ecee8339c3
Don't use teamcity format in CI
It's much harder to read for human
2022-09-15 19:10:04 +02:00
Adrien Crivelli
301e481fbe
loadConfig returns config that was actually applied 2022-09-15 19:07:28 +02:00
Adrien Crivelli
54415c113b
Fix code style 2022-09-15 17:55:24 +02:00
Adrien Crivelli
26532b5f3f
Test PHP 8.1 2022-09-15 17:45:46 +02:00
Progi1984
7df75b2efe
Merge pull request #2294 from Progi1984/htmlTableBorder
HTML Reader : Use `border` attribute for tables
2022-09-14 18:16:34 +02:00
Progi1984
62584900b5
Merge pull request #2239 from cscrewsandcaptains/develop
PHP 8.1 Support for addPreserveText
2022-09-14 18:12:50 +02:00
Progi1984
a4cdcd6250 HTML Reader : Use border attribute for tables 2022-09-14 17:50:54 +02:00
neopheus
fa84160f7f str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated" 2022-09-12 13:59:21 +02:00
neopheus
077175efbe Fix : htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated
htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated
2022-09-12 13:48:13 +02:00
neopheus
83b0bef3a8 Fix #2290 2022-09-12 12:56:45 +02:00
Progi1984
a006aa8780
Merge pull request #2289 from Progi1984/htmlBlockPageBreak
HTML Reader : Style page-break-after in paragraph
2022-09-07 21:14:10 +02:00
Progi1984
2de551647b HTML Reader : Style page-break-after in paragraph 2022-09-06 22:05:33 +02:00
amir
26757c29bb
Add softhyphen support to word reader 2022-08-12 14:38:49 +04:00
Seamus Lee
2f93873a7c PHP8.1 Fix issue with passing NULL value for locale into string function 2022-07-30 07:28:01 +00:00
Progi1984
4dc34d43d8
Merge pull request #2266 from Progi1984/htmlBlockHeadingInTextRun
HTML Reader : Heading in Text Run is not allowed
2022-07-25 22:07:06 +02:00
Progi1984
945cbd9b93 HTML Reader : Heading in Text Run is not allowed 2022-07-20 14:04:04 +02:00
Christian Stein
91416e48ac
XMLWriter ReturnTypeWillChange fix
add  #[\ReturnTypeWillChange] Attribute to the function writeAttribute (php 8.1 deprecate warning)
2022-06-08 14:22:51 +02:00
Christian Stein
fc18246b20
PreserveText preg_split fix
third parameter must be -1 not null (php 8.1 deprecate warning)
2022-06-08 14:14:25 +02:00
Michael Als
6b331603e6 Added return type will change to XMLWriter.php 2022-03-30 12:42:45 +00:00
Michael Als
2bba013311 PHP 8.1 compatability fix for PreserveText 2022-03-29 13:13:45 +00:00
Adrien Crivelli
be0190cd5d
0.18.3 2022-02-17 16:40:03 +01:00
Adrien Crivelli
3bcd4b5370
PHP 8.1 compatibility 2022-02-17 16:37:24 +01:00
Adrien Crivelli
01d87e17fb
Merge pull request #2193 from garethellis36/2187-php8.1-deprecation
#2187 Addresses deprecation on PHP 8.1 in ZipArchi
2022-02-17 16:35:57 +01:00
Gareth Ellis
c57c292915 #2187 Addresses deprecation on PHP 8.1 in ZipArchi 2022-02-08 12:40:06 +00:00
Tobias van Beek
e159b723bd
Update homepage in composer.json
I found out that the homepage link on packagist.org points to: http://phpoffice.github.io/ but that site doesn't exist. So this PR updates the link to the documentation site.
2022-01-04 14:02:52 +01:00
Maarten de Keizer
e9cd17d4c7 Add destructor wich will try to clean up temp file of the template
processor
2022-01-04 10:35:29 +01:00
Amgad Naiem
d9c1daa89c
Added Swedish language 2021-12-06 22:39:26 +02:00
brammeleman
5bd4ad39a5
fixed code example
classes not found and missing dollar sign
2021-06-29 11:57:41 +02:00
troosan
aca10785cf Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into develop 2021-06-04 22:58:45 +02:00
troosan
e37b22bf2b prepare release 18.2.0 2021-06-04 22:58:27 +02:00
troosan
5a5562cd99 Merge branch 'master' of https://github.com/PHPOffice/PHPWord into develop 2021-06-04 22:50:17 +02:00
troosan
bb106f9052
Merge pull request #2090 from DShkrabak/DShkrabak-patch-1
Add BorderStyle for Cell Style to documentation
2021-06-04 22:37:26 +02:00
Artem Kolotilkin
eec9e975da Added support for Garamond font 2021-06-04 22:29:29 +02:00
DDim
7744ef2234
Add BorderStyle for Cell Style to documentation
Add BorderStyle for Cell Style  to documentation.
2021-06-02 13:52:49 +03:00
troosan
d905e764e3
Merge pull request #2063 from tpv-ebben/develop
when adding image to relationship first check that the generated RID is actually unique
2021-05-29 17:58:25 +02:00
troosan
612fefd636
Merge pull request #2087 from MegaChriz/patch-1
Corrected namespace for Language class in docs.
2021-05-29 17:56:41 +02:00
Youri
1e0157f184
Corrected namespace for Language class in docs.
The docs referenced the wrong namespace for the Language class. It said ``PhpOffice\PhpWord\ComplexType\Language``, but there's no Language class in the namespace ``PhpOffice\PhpWord\ComplexType``. I searched in the tests to figure out where the Language class has moved to and found in ``PhpOffice\PhpWord\Writer\Word2007\Part\SettingsTest::testLanguage()`` this had to be ``PhpOffice\PhpWord\Style\Language``.
2021-05-25 15:48:13 +02:00
troosan
d6e0a3ebdb
Merge pull request #2070 from PHPOffice/dependabot/add-v2-config-file
Upgrade to GitHub-native Dependabot
2021-05-05 21:01:50 +02:00
dependabot-preview[bot]
a9deeb8c25
Upgrade to GitHub-native Dependabot 2021-04-29 21:47:21 +00:00
troosan
7fd0489567 fix checkstyle issues 2021-04-16 23:38:14 +02:00
Ebben Feagan
524c08bafb running composer fix 2021-04-16 15:19:55 -05:00
Ebben Feagan
94b74c27a4 when adding image to relationship list check that the generated relationship id is actually unique 2021-04-16 15:06:37 -05:00
troosan
ab7d82274e
Merge pull request #2052 from dfsd534/develop
Update chart, don't write 'c:overlap' if grouping is 'clustered'
2021-04-15 22:23:24 +02:00
troosan
fa52c92561
Merge pull request #2041 from joelgo/patch-1
Update Html parser to accept line-height:normal
2021-04-15 22:23:08 +02:00
DE TROOSTEMBERGH Antoine
3a7301c700 try to fix the php-cs-fixer pr annotation 2021-04-15 21:44:37 +02:00
DE TROOSTEMBERGH Antoine
0692a55fa4 checkstyle fixes 2021-04-15 21:19:38 +02:00
DE TROOSTEMBERGH Antoine
a4055fb7a0 'normal' line-height means default line height
Add unit test
2021-04-15 21:04:45 +02:00
DE TROOSTEMBERGH Antoine
8efd9ff9da Merge branch 'develop' into develop_tmp 2021-04-14 22:19:05 +02:00
DE TROOSTEMBERGH Antoine
d731e9284f fix checkstyle issues 2021-04-14 22:15:58 +02:00
troosan
55defcc892 relax some phpmd rules 2021-04-14 00:16:28 +02:00
dfsd534
afed126ab1 update 2021-04-10 11:49:32 +08:00
joelgo
7f78322d04
Update html.php
For acept text in line-height how "line-height:normal", etc.
2021-03-17 13:09:13 -05:00
troosan
a30bbbdc62
Merge pull request #2021 from kamilmmach/develop
Fix image border in Word2007 Writer for LibreOffice 7
2021-03-13 17:27:03 +01:00
Adrien Crivelli
06b90e39a3
0.18.1 2021-03-08 10:06:35 +09:00
Adrien Crivelli
84d1da6ce2
Merge pull request #2032 from mussbach/f_2028_dont_replace_package
Fix BC break in #1946. This package does not replace laminas/laminas-zendframework-bridge
2021-03-08 10:02:32 +09:00
Sami Mussbach
556a250fb3 Fix BC break in #1946. This package does not replace laminas/laminas-zendframework-bridge
This commit fixes the BC break introduced by #1946 where it was stated
that phpword replaces package laminas/laminas-zendframework-bridge which
is not the case. Package laminas/laminas-zendframework-bridge only was
replaced from phpword.
2021-03-04 17:50:16 +01:00
troosan
5dcb3e53ee coverage with xdebug 2021-02-21 21:46:22 +01:00
troosan
2ae000cbad hack for phpunit 8 compatibility 2021-02-21 21:32:45 +01:00
troosan
b71b4fdb71 update phpunit params 2021-02-21 21:16:27 +01:00
troosan
2961b72c7a don't fail on non existing lock file 2021-02-21 21:07:20 +01:00
troosan
1e5fd83222 remove travis config file 2021-02-21 21:01:01 +01:00
troosan
67ea85688e add git workflow 2021-02-21 20:53:45 +01:00
Kamil Mach
68cbca530f Fix image border in Word2007 Writer for LibreOffice 7 2021-02-17 09:22:32 +01:00
troosan
1bd7cd6238 set release date 2021-02-12 22:28:06 +01:00
troosan
c2e2ec4004
Merge pull request #1832 from Matze2010/udz-checkbox-feature
Add parsing of HTML checkbox input field
2021-02-12 20:37:35 +01:00
troosan
659d3d7b4b
Update Html.php
fix
2021-02-12 20:16:18 +01:00
troosan
bed1f7afbf
pass the paragraph style 2021-02-11 21:44:20 +01:00
troosan
4c5e760871 Merge branch 'master' of https://github.com/PHPOffice/PHPWord.git into develop 2021-02-11 20:39:01 +01:00
troosan
c550a53c3e prepare changelog for 0.18.0 2021-02-11 20:38:40 +01:00
troosan
a382f9d754
fix 2021-02-11 19:25:28 +01:00
troosan
8bb0b73733 fix merge 2021-02-10 21:10:06 +01:00
troosan
d4f08a3f8a Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into tmp
Conflicts:
	tests/PhpWord/Shared/HtmlTest.php
2021-02-10 21:04:16 +01:00
troosan
9736d37bc9
Merge pull request #1986 from emnabs/develop
add/setting page element border style.
2021-02-10 20:49:37 +01:00
troosan
81d613bc4d php 5.3 compatible code 2021-02-10 08:25:09 +01:00
troosan
4840faa422
Merge pull request #1922 from csk83/develop
Add Option for Dynamic Chart Legend Position #1699
2021-02-09 21:26:47 +01:00
troosan
1b7b43a4e5 fix code formatting 2021-02-08 22:58:14 +01:00
troosan
e1bbc85cc4
Make syntax php 5.3 compliant 2021-02-08 22:40:46 +01:00
troosan
b2585dfd28 move constants to simpleType 2021-02-08 22:20:00 +01:00
troosan
1c3fdd2719 prepare release 0.18.0 2021-02-08 22:12:24 +01:00
troosan
264f1590f0 make xmlReplaceBlock public 2021-02-08 22:08:29 +01:00
troosan
cba1edc9e8
remove trailing whitespaces 2021-02-08 00:59:44 +01:00
troosan
486321bb02
Compatibility with old PHP versions 2021-02-08 00:58:00 +01:00
troosan
6db2927484
Merge pull request #1965 from naept/feature_handle-style-inheritance-for-html
feat: Update addHtml to handle style inheritance
2021-02-08 00:51:34 +01:00
troosan
f832a7c9db
Merge branch 'develop' into develop 2021-02-08 00:37:42 +01:00
troosan
ca45d14511
Merge pull request #1809 from juzser/dev-master
Update the regexp to avoid catastrophic backtracking
2021-02-07 23:42:57 +01:00
troosan
5080139511
Merge pull request #1824 from ErnestStaug/locale_support
Some document have non-standard locale code
2021-02-07 23:33:14 +01:00
troosan
6baf287a5f
Merge branch 'develop' into udz-checkbox-feature 2021-02-07 23:30:28 +01:00
troosan
d592b8e4c9
Merge pull request #1877 from ThanasisMpalatsoukas/patch-1
Unused variables $rows, $cols
2021-02-07 23:26:48 +01:00
troosan
9e322dd6e7
Merge pull request #1902 from lubosdz/develop
Enhancements to addHTML parser
2021-02-07 22:53:53 +01:00
troosan
bf8f2ac12f
Merge pull request #1763 from TimeTonic/fixes-1750-block-with-images-inside
TemplateProcessor cloneBlock wrongly clones images
2021-02-07 22:27:40 +01:00
troosan
137238faed
Merge pull request #1967 from jsochor/develop
fix image limit
2021-02-07 22:09:34 +01:00
troosan
f5c96beedd
Merge pull request #2012 from dbarzin/develop
Add support for charts in template processor
2021-02-07 22:08:26 +01:00
troosan
26e479422a
Fix formatting 2021-02-07 15:06:01 +01:00
troosan
dc9b1edb5b fix formatting 2021-02-06 22:50:11 +01:00
Antoine de Troostembergh
31259f6448 fix 2021-02-06 22:12:19 +01:00
Antoine de Troostembergh
1168789e8a fix formatting 2021-02-06 21:32:30 +01:00
dbarzin
214df1a1cb fix unit test 2021-02-06 12:57:16 +01:00
dbarzin
48ee2eb78a fix param error 2021-02-06 10:50:21 +01:00
dbarzin
31002fc6e8 add chart in template 2021-02-06 10:40:52 +01:00
troosan
4e87e72110
Merge pull request #1716 from enflow/allowImageClosure
Allow a closure to be passed with image replacement tags
2021-02-05 22:08:56 +01:00
troosan
8922632ead
Merge pull request #1936 from YannikFirre/patch-1
Add null check when setComplexValue is not found
2021-02-05 21:26:02 +01:00
troosan
24e46544d8
remove space 2021-02-05 21:25:21 +01:00
troosan
3c66ce9a73
Merge pull request #1988 from Ciki/patch-1
Fix deprecated warning for non-hexadecimal number
2021-02-05 21:16:25 +01:00
troosan
13384f63d3
update comment 2021-02-05 21:15:51 +01:00
Antoine de Troostembergh
83ba5a7b57 Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into patch-1 2021-02-05 21:12:43 +01:00
troosan
ca1272bd69
remove whitespace 2021-02-05 20:48:05 +01:00
troosan
554e90a46c
Merge pull request #1851 from oleibman/defaultpaper
Make Default Paper Configurable
2021-01-12 21:40:26 +01:00
troosan
c391b90823
Merge pull request #1924 from sven-ahrens/feature/parse-shapes
Feature Request: Read shape node values
2021-01-12 21:37:23 +01:00
troosan
06c82488a8
Merge pull request #1996 from liborm85/drop-common-package
Remove legacy PHPOffice/Common package, fix PHP 8.0 compatibility
2021-01-12 21:30:49 +01:00
Libor M
40966dd5c5 remove allow failures for PHP 8.0 2021-01-10 14:56:54 +01:00
Libor M
293efab0c2 TCPDF doesn't support PHP 8.0, skip test 2021-01-10 14:33:13 +01:00
Libor M
ea917c28da fix coverage 2021-01-10 14:06:19 +01:00
Libor M
7a131d0ae1 allow dompdf/dompdf 1.0 version 2021-01-02 09:37:43 +01:00
Libor M
681d5c4709 fix PHP 8.0 compatibility 2021-01-02 09:08:43 +01:00
Libor M
67b15986a7 remove require phpoffice/common package 2021-01-02 08:36:05 +01:00
Libor M
a2c8d8c2d5 \PhpOffice\Common\XMLWriter -> \PhpOffice\PhpWord\Shared\XMLWriter 2021-01-02 08:26:46 +01:00
Libor M
357e905e8b fix PasswordEncoder namespace 2021-01-01 16:52:15 +01:00
Libor M
0cca050bcd \PhpOffice\Common\XMLReader -> \PhpOffice\PhpWord\Shared\XMLReader 2021-01-01 16:33:27 +01:00
Libor M
9a26ad9189 \PhpOffice\Common\Microsoft\PasswordEncoder -> \PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder 2021-01-01 16:23:58 +01:00
Libor M
b656720619 \PhpOffice\Common\Drawing -> \PhpOffice\PhpWord\Shared\Drawing 2021-01-01 16:15:24 +01:00
Libor M
c52686c243 \PhpOffice\Common\Text -> \PhpOffice\PhpWord\Shared\Text 2021-01-01 16:09:16 +01:00
Antoine de Troostembergh
cf808cb3fc Fix merge issue 2020-12-31 21:56:45 +01:00
Antoine de Troostembergh
834a95c503 fix formatting 2020-12-30 20:29:43 +01:00
Yannik Firre
15ee5dee05
Fix missing space after if keyword 2020-12-30 14:02:29 +01:00
troosan
20856fc102
Merge pull request #1858 from oleibman/wordcoverage
Improve Word2007 Test Coverage
2020-12-29 23:56:22 +01:00
troosan
f780c5d18f
Merge pull request #1866 from manishbhatias/patch-1
Fix example for cloneRowAndSetValues
2020-12-29 23:44:49 +01:00
troosan
7c7d7fd405
Merge pull request #1983 from FCG-Group/allow_to_use_customized_pdf_libraries
allow to use customized pdf library
2020-12-29 23:41:23 +01:00
troosan
31d8b547c8
Merge pull request #1992 from Adizbek/develop
Fix image stroke in libreoffice 7.x
2020-12-29 23:32:32 +01:00
troosan
e3732ef610
Merge pull request #1907 from SailorMax/patch-2
Allow to redefine TCPDF object
2020-12-29 23:19:47 +01:00
troosan
b2335d2b73
Merge pull request #1796 from oleibman/odtchanges
ODT Changes
2020-12-29 23:18:23 +01:00
troosan
6126080cdf
Merge pull request #1952 from mnvx/develop
Fix typo in docs. Update templates-processing.rst
2020-12-29 22:53:22 +01:00
troosan
7a97d24c77
Merge pull request #1946 from liborm85/php80
Compatibility with PHP 7.4, PHP 8.0 and migrate to Laminas Escaper
2020-12-29 22:42:02 +01:00
Ergashev Adizbek
18e41a1c4e
Update TemplateProcessor.php 2020-12-23 16:00:06 +05:00
Ciki
1f67c993e2
Fix deprecated warning for non-hexadecimal number
I've come across this deprecated warning when trying to save docx to pdf.. if cellBgColor is set to `auto` it should be converted back to `null` which has in practice the same functionality.
2020-12-22 12:12:18 +01:00
emhome
cc9dfb8630 add/setting page element border style. 2020-12-19 16:46:14 +08:00
SailorMax
c8de86a7ec allow to use customized pdf library 2020-12-16 17:24:42 +03:00
Libor M
36b63a107c skip test, because php 8.0 contain internally validation 2020-12-11 12:43:15 +01:00
Libor M
4b4dfb4ccd update ugly hack for PHPUnit 8 support 2020-12-10 16:54:49 +01:00
Libor M
a9e012530d
travis support latest php as 8.0 now 2020-12-09 13:03:49 +01:00
Johannes Sochor
f7242e1250 fix image limit 2020-11-11 17:18:52 +01:00
Julien Aupart
b86c60694c feat: Update addHtml to handle style inheritance
The aim is to get the output closer to the source html
2020-11-09 11:41:03 +01:00
Nicholas Moore
ecc13ff62a
Update templates-processing.rst
fix typo in doc
2020-10-22 13:53:28 +03:00
Libor M
6b99923363 travis php 8 - convert tests from phpunit 7 format to phpunit 8 format 2020-10-19 15:05:14 +02:00
Libor M
4cc2cc1aeb travis upgrade to PHPUnit 8 for PHP 8 2020-10-19 14:23:42 +02:00
Libor M
f2516b08b1 migrate from abandoned Zend\Escaper to Laminas Escaper 2020-10-18 13:16:43 +02:00
Libor M
4e4282a76e refixed "must not contain any null bytes" 2020-10-18 10:56:24 +02:00
Libor M
b8ffe0477b fix cs issue: "Arguments with default values must be at the end of the argument list" 2020-10-18 08:54:12 +02:00
Libor M
b7dc71ab1b scrutinizer fix, allow zip extension 2020-10-18 08:37:53 +02:00
Libor M
6d49b28678 skip TCPDF test in PHP 5.3, because
version 6.3.5 doesn't support PHP 5.3, fixed via https://github.com/tecnickcom/TCPDF/pull/197, pending new release.
2020-10-18 07:47:25 +02:00
Libor M
eaf2212aa8 fix format for coverage 2020-10-18 07:45:57 +02:00
Libor M
0edcab0da6 allow php 5.3, 5.4, 5.5 except xenial os 2020-10-18 07:26:06 +02:00
Libor M
236c7c4499 fix code format 2020-10-17 17:34:51 +02:00
Libor M
2845284284 revert from develop branch 2020-10-17 17:25:02 +02:00
Libor M
bf1bb2b7ca PHP 8.0 - fixed Error: Unknown named parameter $styles 2020-10-17 17:17:46 +02:00
Libor M
a36a429128 rewrite check to local file 2020-10-17 17:08:23 +02:00
Libor M
93579e90ef forgotten condition for libxml_disable_entity_loader 2020-10-17 16:05:30 +02:00
Libor M
9c6cf6fdb6 PHP 8.0 fix - ValueError: file_exists(): Argument #1 ($filename) must not contain any null bytes 2020-10-17 15:56:40 +02:00
Libor M
93978211a1 PHP 8.0 - depracated libxml_disable_entity_loader, is disabled by default 2020-10-17 15:48:39 +02:00
Libor M
7fd4b64e8a - composer in php 5.x require increase memory limit
- in PHP 7.3, 7.4 not necessary remove ignore platforms
2020-10-17 15:47:27 +02:00
Libor M
9dad1d20e8 PHP 7.4 - fixed invalid value in hexdec
avoid notice: "Invalid characters passed for attempted conversion, these have been ignored"
2020-10-17 14:05:52 +02:00
Libor M
e334ecf059 compatibility with phpmd 2.9 2020-10-17 13:39:22 +02:00
Libor M
adb917273c allow PHP 7.4, 8.0 2020-10-17 12:56:06 +02:00
Yannik Firre
aa7c1d0fe8
FIX - When setComplexValue is not found 2020-09-22 16:28:52 +02:00
Sven Ahrens
166a136f22 Fix spacing 2020-09-02 14:36:08 +02:00
Sven Ahrens
51034af207 Remove filter option 2020-09-02 13:03:49 +02:00
Sven Ahrens
ae34ae9518 Add testcase 2020-09-02 13:03:29 +02:00
Sven Ahrens
58e0200fbd Get fallback value instead of taking the last element 2020-09-02 12:12:48 +02:00
Sven Ahrens
63d1ffceb8 Restore gitignore 2020-09-01 18:14:27 +02:00
Sven Ahrens
3a7dd774a2 Add support for mc:AlternateContent 2020-09-01 18:13:25 +02:00
csk83
9a59cf0590 format check 2020-08-31 11:56:21 +08:00
troosan
ec1b3d35ee
Merge pull request #1818 from caugner/patch-1
Fixes PHPDoc @param and @return types for several Converter methods
2020-08-30 19:56:35 +02:00
csk83
d42854ddb6 chart doc/sample/code comments 2020-08-29 20:41:25 +08:00
csk83
6f1b18937c code format 2020-08-26 12:50:08 +08:00
csk83
9945240ea8
Merge pull request #1 from Stephan212/develop
Add Option for Dynamic Chart Legend Position
2020-08-25 12:16:15 +08:00
Maxim
d6260988bd
Allow to redefine TCPDF object
Sometimes we need create TCPDF object with modified initial arguments.
This change allow rewrite only createExternalWriterInstance() in user defined TCPDF class.
2020-07-23 18:49:25 +03:00
lubosdz
69632b3f03 remove extra line at the end, which possibly causes CI job fail 2020-07-22 10:46:23 +02:00
lubosdz
f69885e7b9 fix bug - don't decode double quotes inside double quoted string 2020-07-22 10:04:12 +02:00
lubosdz
4448bda721 Better normalization for width of borders 2020-07-14 01:31:16 +02:00
lubosdz
70ad01550b Make scrunitizer happier 2020-07-13 19:16:38 +02:00
lubosdz
38788e0c7e Code style 2020-07-13 18:48:27 +02:00
lubosdz
889f4e3381 fix converting margin to incorrect unit (points instead of twips)
fix image alignment on float - relative to inner margin instead of page margin
2020-07-11 23:03:51 +02:00
lubosdz
3066d47003 Html parser (addHtml) - support vertical-align, valign 2020-07-11 22:47:40 +02:00
lubosdz
108c1cdc55 Html parser (addHtml) - support attributes start, type in ordered list <ol> 2020-07-11 17:20:36 +02:00
lubosdz
ca5f081302 Html parser (addHtml) - support horizontal rule <hr/> 2020-07-11 15:42:28 +02:00
lubosdz
e180cfe456 Html parser (addHtml) - support cellspacing, bgColor 2020-07-11 00:24:08 +02:00
lubosdz
701f770ab7 Html parser (addHtml) - support width in tables & cells 2020-07-10 23:44:25 +02:00
troosan
21f4bb3053
Merge pull request #1794 from ErnestStaug/image_conversion_support
Added support for "cloudConvert" images
2020-07-07 23:18:32 +02:00
troosan
250e206b59
Merge pull request #1775 from oleibman/rtfchanges
Add support for several features for the RTF writer
2020-07-06 08:36:38 +02:00
troosan
e7f70f3450
Merge pull request #1774 from oleibman/fieldstyle
Add font style for Field elements
2020-07-06 08:34:30 +02:00
Sakis bal
2c7a306961
Unused variables $rows, $cols
Columns are hardcoded in the basic table loop instead of using the predefined $rows and $cols variables
2020-06-01 12:28:11 +03:00
Manish Bhatia
1587c59f40
Fix example for cloneRowAndSetValues
Added a fix for missing parameter to the cloneRowAndSetValues function call in its example.
2020-05-13 12:48:54 +05:30
Owen Leibman
3738a6806e Improve Word2007 Test Coverage
After this change, Writer/Word2007 is 100% covered.
One source change is required. Writer/Word2007/Style/AbstractStyle
has incorrectly searched Measurement Array using
in_array (which searches values) rather than array_key_exists (keys).
There was no test for this, and now there is.

3 changes in tests/PhpWord/_includes are borrowed from "ODT Changes"
(pull request 1796, not yet merged)
and "Fix PHPUnit Tests" (pull request 1771,
merged after work on this change was started).

Writer/Word2007/ElementTest was becoming too unwieldy. Tests for
Chart and FormFields were moved to their own members.
2020-04-27 21:29:27 -07:00
Owen Leibman
ba3d616282 Improve Test Coverage
Coverage for Writer/ODText is now 100%.
2020-04-23 17:25:56 -07:00
oleibman
6da3fd3c06
Correct Scrutinizer Warning
Type was declared incorrectly in comment.
2020-04-16 23:55:24 -07:00
Owen Leibman
41a5b74f93 Make Default Paper Configurable
Each section currently has a hard-coded default paper of A4.
It would make sense to allow the user to set this default,
and specify it in a configuration file, just as is done
with default font name and size.
2020-04-16 23:30:27 -07:00
rikvdlooi
04b224caa5
Fixed setting width of Cell Style
The setWidth method did not change the width in the style, seems to be a small mistake.
Now the width is correctly for the Cell Style.
2020-04-15 22:34:19 +02:00
Matze2010
258b9a65c8 fix 2020-03-02 06:10:14 +00:00
Matze2010
ad8eeccd72 remove dead code 2020-03-02 06:00:51 +00:00
Matze2010
726c8caf54 HTML checkbox input field 2020-03-01 18:15:27 +00:00
Ernestas Staugaitis
37c15e66cd Some document have non-standard locale code 2020-02-17 11:44:27 +02:00
Ernestas Staugaitis
a0e57459dc Some document have non-standard locale code 2020-02-16 22:12:34 +02:00
Owen Leibman
4e347b33d7 One Additional Coveralls Test
Cover one line previously omitted from coverage.
2020-02-06 23:34:24 -08:00
Owen Leibman
677e042c3a Scrutinizer Workaroun
Attempt to work around demonstrably incorrect Scrutinizer analysis
  (flags code as bug because "condition is always false"
   even though Coveralls reports that code which would be
   executed only if condition is true is indeed executed).
2020-02-06 20:41:40 -08:00
Owen Leibman
d5149b2867 Coveralls Changes
Changes to improve test coverage based on Coveralls report.
2020-02-06 19:20:13 -08:00
Claas Augner
1dee5f33cf
docs(Converter): fix @param allowing float 2020-02-04 20:36:03 +01:00
oe.sonnh
608730531f Fix: Catastrophic Backtracking RegExp 2020-01-21 16:48:27 +07:00
oe.sonnh
d965a69601 Fix: CloneBlock regexp for different regexp engine with xml line-drop 2020-01-07 13:52:13 +07:00
Owen Leibman
46c41c5ac1 More Scrutinizer Changes
Still one report that I don't understand at all, and one I'm not sure of.
2020-01-05 15:05:00 -08:00
Owen Leibman
cfa29cc1c2 Applying Scrutinizer Suggestions
I do not understand one suggestion, and I believe one is wrong.
I will add comments to my ticket once this is pushed.

One that I can discuss up front
PhpWord/Style/Paragraph indicates that Indentation must be of type
   \PhpOffice\PhpWord\Style\Indentation, but it can also be null.
   My test for instanceof ... is one of the Scrutinizer reports.
   I did not change PhpWord/Style/Paragraph, but this commit does so
   by updating @var for indentation.
2020-01-05 13:52:20 -08:00
Owen Leibman
e24b2e1ba7 ODT Changes
Implement a number of features implemented in PhpWord,
   but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
   considerably easier to test ODT changes (and Word2007 changes involving
   files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
   orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
    indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.

Item 11 above needs 1 module from Pull Request 1775, which is targeted
    for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
    for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
    merged after my fork.
2020-01-05 10:27:45 -08:00
Ernestas Staugaitis
fa0ba2e2ab Added support for cloud convert image inclusion 2020-01-02 00:34:30 +02:00
troosan
8b2e21b634
Merge branch 'develop' into fieldstyle 2019-12-09 22:56:08 +01:00
troosan
c52c7abb65
Merge branch 'develop' into rtfchanges 2019-12-09 21:10:31 +01:00
troosan
733f845f8f
Merge pull request #1776 from mdupont/footnotes-typo
Fix documentation and method name for FootnoteProperties
2019-12-09 21:08:39 +01:00
Michaël Dupont
cb3e211135 fix(documentation): snippet for FootnoteProperties
The documentation contained an incorrect code snippet for
configuring FootnoteProperties. Now the code is valid.
2019-12-09 11:29:39 +01:00
Michaël Dupont
4852028743 fix: typo in getFootnoteProperties() method name
Was "getFootnotePropoperties()".
Former bogus spelling is still working, albeit deprecated.
2019-12-09 11:29:39 +01:00
troosan
dfea4e12a6
Merge pull request #1766 from stefan-91/develop
Add support for ListItemRun in HTML writer
2019-12-08 20:38:03 +01:00
troosan
5940d18ab2
Merge pull request #1755 from oleibman/master
Improvements in RTF writer
2019-12-08 20:32:09 +01:00
DE TROOSTEMBERGH Antoine
9fe6a58669 Merge remote-tracking branch 'upstream/master' into develop 2019-12-08 18:22:01 +01:00
Michaël Dupont
072c3bfdb3 fix: PHPUnit test Process() format
\Symfony\Component\Process\Process refuses being passed a string
with version > 5, which is installed with PHP > 7.2.5.

It also refuses being passed an array with version < 3.3, which is
installed with PHP < 5.5.9.

Solved by checking if Process::fromShellCommandLine() exists, which
was introduced in version 4.2.0.
2019-12-08 15:47:53 +01:00
troosan
d9cb88e987
Merge branch 'develop' into fixes-1750-block-with-images-inside 2019-12-08 14:35:14 +01:00
troosan
5a7a11a62b
Merge pull request #1729 from hcdias/patch-1
Update templates processing docs
2019-12-08 14:32:03 +01:00
troosan
9020e6769e
Merge pull request #1764 from mdupont/358-paragraph-indent
fix: documentation about paragraph indentation
2019-12-08 13:28:35 +01:00
troosan
d423e9bb57
Merge pull request #1745 from igronus/patch-1
Update templates-processing.rst
2019-12-08 13:16:03 +01:00
troosan
38345041fd
Merge pull request #1744 from Manunchik/Manunchik-patch-4
Improve unit test
2019-12-08 13:15:28 +01:00
troosan
777b48f184
Merge pull request #1743 from Manunchik/Manunchik-patch-3
Improve unit test
2019-12-08 13:15:18 +01:00
troosan
3583cfe7eb
Merge pull request #1742 from Manunchik/Manunchik-patch-2
Improve unit test
2019-12-08 13:15:08 +01:00
troosan
638154936c
Merge pull request #1771 from mdupont/fix-tests
Fix PHPUnit tests on develop branch
2019-12-08 13:14:37 +01:00
owen
122aaf17b1 Incorporate Pull Request 1771
Fix PHPUnit tests on develop branch
2019-12-05 23:48:44 -08:00
Owen Leibman
9b5483a1e0 Incorporating Pull Request 1771
That Pull Request is "Fix PHPUnit tests on Develop Branch".
2019-12-05 23:42:54 -08:00
owen
5e64b26451 Additional Scrutinizer Recommendations
Some more editorial changes.
2019-12-05 23:24:03 -08:00
owen
7657992a83 Scrutinizer-suggested changes
Changes to doc-blocks and code suggested by Scrutinizer.
2019-12-05 22:51:00 -08:00
Owen Leibman
30e3981ed2 Documentation Change
Changed 1 doc-block comment suggested by Scrutinizer.
2019-12-05 21:51:09 -08:00
Owen Leibman
11d82be21c Word2007 Writer - Field Style, RTL, noProof
1. Add support for font styles for fields, and write those to Word docs.
2. Word seems to require explicit inline w:rtl tag even when rtl is specified
   in a named style. Without this tag, words are placed in ltr order.
   Allow PhpWord doc to specify rtl in named style and have it
   display correctly in resulting doc.
3. A recent change incorrectly changed how noProof tag was generated,
   omitting the third parameter of 4 parameters in the call. There was
   no test case for this change. The call is now corrected, and a
   test case has been added.
2019-12-05 21:04:12 -08:00
owen
ecfafd7576 RTF Changes
1. Converter is currently expecting colors as strings of hex digits,
   but PhpWord allows specification of colors by named constant, so
   result is random when one of those is used. This change handles
   all the named colors.
2. Table needs \pard at end; formatting may be wrong without it.
3. RTF writer will no longer ignore paragraph style for TextRun.
4. RTF writer will no longer ignore paragraph and font style for Title.
5. Add support for RTF headers and footers.
6. Add support for right-to-left in font.
7. Add support for PageBreakBefore and LineHeight for paragraphs.
8. Add support for PageNumberingStart for sections.

There are test cases for all of these changes.
2019-12-03 07:46:16 -08:00
Michaël Dupont
f51811b96b fix: documentation about paragraph indentation
Documentation contained the wrong unit for Paragraph indentation.
2019-12-02 16:40:58 +01:00
Michaël Dupont
aa44594ed3 fix: PHPUnit test Process() format
\Symfony\Component\Process\Process refuses being passed a string
with version > 5, which is installed with PHP > 7.2.5.

It also refuses being passed an array with version < 3.3, which is
installed with PHP < 5.5.9.

Solved by checking if Process::fromShellCommandLine() exists, which
was introduced in version 4.2.0.
2019-12-02 16:17:26 +01:00
Aurélien Vandoorine
0945a37c61 Fixed block capture so that it would work properly with blocks to be cloned in rows 2019-12-02 08:54:45 +01:00
Bc. Štefan Kubini
1451fadc4a Add List for docx to html writer #1717 2019-11-28 23:33:10 +01:00
Aurélien Vandoorine
d9ea617545 Fixes #1750 added proper block cloning to put the image size part after the #number and fixing Process call to array instead of string 2019-11-28 09:24:06 +01:00
owen
ebf5cf784f Convert named constant colors to RGB in Shared/Converter.
Otherwise, colors will not be as expected for RTF and ODT.
2019-11-19 14:24:29 -08:00
oleibman
2d60f3220d
Merge pull request #1 from oleibman/master
Master
2019-11-17 02:38:34 -08:00
Owen Leibman
00f9bb5897 Formatting changes in source code. 2019-11-17 00:07:02 -08:00
Owen Leibman
2513e54540 Errors in RTF Escaping
1. Codes meant to be in hex are specified in decimal.
   Consequently characters which don't need escaping are escaped.
2. Special handling (prepend backslash) needed for {, }, and .
   RTF docs generated with those characters cannot be opened in Word.
3. Tab character needs to be escaped as \tab.
   RTF docs drop these characters.
While running test suite, found that Writer/RTF/ElementTest was coded
only for Unix line endings, and fails on Windows. Changed so that it
    would work on either.
2019-11-16 23:20:02 -08:00
Owen Leibman
a10fe823b2 Errors in RTF Escaping
1. Codes meant to be in hex are specified in decimal.
   Consequently characters which don't need escaping are escaped.
2. Special handling (prepend backslash) needed for {, }, and \.
   RTF docs generated with those characters cannot be opened in Word.
3. Tab character needs to be escaped as \tab.
   RTF docs drop these characters.
While running test suite, found that Writer/RTF/ElementTest was coded
only for Unix line endings, and fails on Windows. Changed so that it
would work on either.
2019-11-16 21:37:57 -08:00
Bc. Štefan Kubini
b230242127 fixed List item fail #1711 2019-11-05 10:46:24 +01:00
igronus
0ce843016b
Update templates-processing.rst
Typo fix.
2019-10-24 11:07:33 +03:00
Manunchik
21db2d40a4
Improve unit test 2019-10-23 13:46:58 +05:00
Manunchik
cb7ffd0ac2
Improve unit test 2019-10-23 13:44:47 +05:00
Manunchik
b0de8e7d1d
Improve unit test 2019-10-23 13:41:35 +05:00
Michel Bardelmeijer
68118685d0 Merge branch 'master' into allowImageClosure 2019-10-21 12:33:12 +02:00
Hugo Carvalho
5e93950bc3
Update templates processing docs
Adding save() and saveAs() methods docs
2019-10-02 22:15:14 -03:00
troosan
b8346af548 update changelog for version 0.17 2019-10-01 22:43:33 +02:00
troosan
4f0d6f78ba
Merge pull request #1717 from Samuel-BF/rtf-basic-fields
Add support for basic fields in RTF writer.
2019-09-30 21:56:00 +02:00
troosan
dfa0b5f8ce
Merge pull request #1712 from fmasa/fix/return-types
Added return type
2019-09-30 21:38:38 +02:00
Samuel BF
7628b41fdf Add support for basic fields in RTF writer. 2019-09-10 11:24:59 +02:00
Michel Bardelmeijer
6ed320311e Add documentation for image closure support 2019-09-09 13:55:59 +02:00
Michel Bardelmeijer
5a68ef600b Allow a closure to be passed with image replacement tags 2019-09-09 13:49:16 +02:00
František Maša
8f4f4dcd48 Added return type 2019-09-02 18:13:10 +02:00
troosan
8fbd060148
Merge pull request #1661 from andreybolonin/patch-1
add php 7.4snapshot
2019-09-01 22:30:21 +02:00
troosan
aec9582d83
allow php 7.4 build to fail 2019-09-01 22:12:34 +02:00
troosan
18664fb955
Merge branch 'develop' into patch-1 2019-09-01 21:57:27 +02:00
troosan
e9a4251c7e Use precise only for php 5.3 2019-09-01 21:54:28 +02:00
troosan
5b34391eea
Merge pull request #1707 from mdupont/fix-travis-ci
Fix apt-get crash in Travis CI for PHP 5.3
2019-09-01 21:06:24 +02:00
troosan
18ec5d63f3 fix phpmd config 2019-09-01 21:03:22 +02:00
Michaël Dupont
72311767c5 Fix Travis crash with Composer memory usage 2019-08-28 11:11:19 +02:00
Michaël Dupont
41227e8e08 Fix apt-get crash in Travis CI 2019-08-28 10:59:06 +02:00
Stephan212
90a8900208
Stephan212 chart dynamic legend position (#2)
* Writer/Part/Chart.php Add dynamic Legend positions

The position of the legend of charts was always fixed to the right. Adding in the option to set it dynamically via a new option under styles/chart

* Update Syle/Chart.php

Add in the public functions to getStyle() to get and set the legend position
2019-08-21 10:54:43 +01:00
Stephan212
9e572ecd9b
chart - Add dynamic Legend positions (#1)
* Writer/Part/chart.php - Add dynamic Legend positions

The position of the legend of charts was always fixed to the right. Adding in the option to set it dynamically via a new option under styles/chart

* Update Styles/Chart.php

Add in the public functions to getStyle() to get and set the legend position
2019-08-21 10:18:33 +01:00
troosan
85e9144822
Merge pull request #1329 from eweso/patch-1
Adding setNumId method for ListItem style
2019-08-08 07:13:03 +02:00
troosan
815bb52ebf
Merge pull request #1628 from waltertamboer/feature/fix-issue-1529
No nested w:pPr elements in ListItemRun.
2019-08-08 07:11:05 +02:00
troosan
24d120baf1
Merge pull request #1646 from SpinyMan/develop
Change private to protected to be able extending class Html
2019-08-08 07:09:35 +02:00
troosan
487622bb9e
Merge pull request #1637 from bhattnishant/master
To support PreserveText inside sub container
2019-08-08 07:08:13 +02:00
troosan
fa6a80fb4d
Merge pull request #1658 from 0b10011/readmelinks
Use relative links in README to ensure they go to the correct branch
2019-07-28 21:21:44 +02:00
Andrey Bolonin
5fe485adac
add php 7.4snapshot 2019-07-14 15:26:23 +03:00
Brandon Frohs
5f8fad3985 Use relative links in README to ensure they go to the correct branch 2019-07-11 17:14:35 -04:00
troosan
06c2f5683b
Merge pull request #1653 from auipga/patch-1
Fix link anchor
2019-07-10 23:59:34 +02:00
troosan
58adc1eb1f
Merge pull request #1644 from 0b10011/contributing
Update CONTRIBUTING to match reality and add issue templates for bug reports, feature requests, and usage questions
2019-07-10 23:55:57 +02:00
Manuel Transfeld
4f7790baab
Fix link anchor
Fix a typo in a link
2019-07-09 17:22:30 +02:00
troosan
7768c56a56
Merge pull request #1645 from JBlond/develop
Update Wrong definition
2019-07-09 07:43:10 +02:00
Andrew Busel
415bdb378d
Update Html.php 2019-07-03 19:25:29 +03:00
Andrew Busel
9e93d5eae5
Update Html.php 2019-07-03 19:24:15 +03:00
Mario
9abf4473b0
Update Wrong definition 2019-07-02 16:02:52 +02:00
Brandon Frohs
b13aa70ae9 Move pull request template to avoid confusion 2019-07-01 13:36:41 -04:00
Brandon Frohs
71ac081cfa Add note about using composer check before submitting pull requests 2019-07-01 13:34:05 -04:00
Brandon Frohs
74e52ce71b Remove the existing issue template 2019-07-01 13:33:48 -04:00
Brandon Frohs
e401adeb7e Update CONTRIBUTING to match reality and account for new issue templates 2019-07-01 13:10:55 -04:00
Brandon Frohs
d6b0977afe Add issue templates for bug reports, feature requests, and usage questions 2019-07-01 13:09:36 -04:00
troosan
d7ed18c39d fix test 2019-06-14 00:19:44 +02:00
troosan
3c6a1a1568 add unit test 2019-06-13 23:03:09 +02:00
Nishant Bhatt
b209fec72b To suport preseve text inside sub container
if we use preseve text inside table, issue fix

https://stackoverflow.com/questions/33070424/phpword-cannot-add-preservetext-in-section
2019-06-03 15:44:10 +02:00
Walter Tamboer
18b3c754ef No nested w:pPr elements in ListItemRun.
This commit fixes issue #1529

This commit prevents nested w:pPr elements when using a ListItemRun with
a paragraph style. The different between a ListItem and a ListItem run
is that the setWithoutPPR method is called on the ParagraphStyleWriter
(PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph).

According to the specs it's not allowed to have nested w:pPr elements.
See http://www.datypic.com/sc/ooxml/e-w_pPr-2.html
2019-05-09 15:29:25 +02:00
troosan
fe531cae55
Merge pull request #1616 from nicoder/patch-5
fix typo in changelog
2019-04-24 22:00:31 +02:00
Nicolas Dermine
c00c77c4c1
fix typo in changelog 2019-04-17 18:27:33 +02:00
troosan
b1903524b9
Merge pull request #1611 from zearg/develop
call static instead of self on protected method
2019-04-16 20:40:48 +02:00
arthur
2045e52db7 call static instead of self on protected method 2019-04-09 10:55:43 +02:00
troosan
1534dc23c3
Merge pull request #1595 from NickCoolii/patch-1
Added new constant to russian language
2019-03-31 20:48:10 +02:00
troosan
8cea3221dc
remove trailing spaces 2019-03-31 13:20:51 +02:00
troosan
6e4f18c2b0
Merge pull request #1585 from seamuslee001/libxml_improve
Ensure that entity_loader disable variable is re-set back to the orig…
2019-03-31 13:19:25 +02:00
Seamus Lee
607378b8fb Ensure that entity_loader disable variable is re-set back to the original setting
Simplify the setting of libxml_disable_entity_loader
2019-03-31 08:31:49 +11:00
Mykola Nicholas
014ff7d261
Added new constant to russian language 2019-03-13 16:39:32 +03:00
troosan
2d2fe52b7a
Merge pull request #1387 from SailorMax/html_writer_auto_invert_text_color
Html writer auto invert text color
2019-03-05 23:05:37 +01:00
Maxim
8931ab12b2
Merge branch 'develop' into html_writer_auto_invert_text_color 2019-03-01 16:33:50 +02:00
Maxim Bulygin
57ae7008b2 add test to auto invert text color 2019-03-01 16:31:47 +02:00
troosan
81af913a66
Update CONTRIBUTING.md 2019-02-24 21:23:59 +01:00
Nick Winfield
81a1b2acff TrackChange doesn't handle all return types of \DateTime::createFromFormat(...) (#1584)
* Added boolean check before setting the date
2019-02-24 00:24:49 +01:00
troosan
9958a4825f allow other streams 2019-02-22 22:06:54 +01:00
troosan
b3982ebb70 fix documentation 2019-02-22 22:06:30 +01:00
troosan
0a73bfd115
Merge pull request #1570 from troosan/fix_parsing_html_border_color
fix parsing of border-color and add test
2019-02-06 22:43:41 +01:00
troosan
3219950d59 trim color codes and add tests 2019-02-06 22:07:42 +01:00
troosan
5206c7f690 fix parsing of border-color and add test 2019-02-06 18:19:01 +01:00
troosan
6e172747ec
Merge pull request #1569 from troosan/page_vertical_align
implement support for section vAlign
2019-02-06 07:44:10 +01:00
troosan
e3020c0db3 fix warnings 2019-02-05 23:05:18 +01:00
troosan
235cc1205c implement support for section vAlign 2019-02-05 21:42:14 +01:00
troosan
5b0c8a3e28 Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into rebase_pull_request 2019-02-05 00:09:27 +01:00
troosan
58a2849e38 Add reading of the settings part 2019-02-04 23:59:37 +01:00
troosan
98026aefaf
Merge pull request #1565 from troosan/set_complex_type_in_template
Set complex type in template
2019-02-04 23:27:13 +01:00
troosan
d2b0b317e0 fix scrutinizer warnings 2019-02-04 22:57:33 +01:00
troosan
bc448aed6c improve code coverage 2019-02-04 21:53:19 +01:00
troosan
d862b1f267 update documentation 2019-01-31 01:32:00 +01:00
troosan
67f3bd369c Add methods to replace macro with ComplexType 2019-01-31 01:26:19 +01:00
troosan
af31fc5340
Merge pull request #1558 from ramsalt/develop
Language::validateLocale should pass with locale 'zxx'.
2019-01-30 20:18:20 +01:00
Stathis Papadopoulos
3c9fa2df13 Language::validateLocale should pass with locale 'zxx'. 2019-01-28 10:50:28 +01:00
troosan
1956908aa7 Merge remote-tracking branch
'geraldb-nicat/PHPWord/templateProcessingViaArray' into develop

Conflicts:
	docs/templates-processing.rst
2019-01-03 18:57:00 +01:00
troosan
3a7b8aba44
Merge pull request #1550 from troosan/add_support_for_table_rtl
Add RightToLeft table presentation
2019-01-03 12:44:49 +01:00
troosan
6aae8bdccb update doc and release note 2019-01-03 11:36:28 +01:00
troosan
f91863ed64 Add RTL aligning of tables 2019-01-03 11:33:56 +01:00
troosan
4d76baea42
Merge pull request #1544 from troosan/avoid_remote_image_loading_during_tests
Use embedded http server to test loading of remote images
2019-01-02 14:36:54 +01:00
troosan
c408ac5d50 Use embedded http server to test loading of remote images 2018-12-30 14:14:27 +01:00
Maxim Bulygin
e40449e7c8 fix variable names 2018-05-24 17:40:21 +03:00
Maxim Bulygin
13fc647d01 html writes / setup table cell color 2018-05-24 17:03:35 +03:00
Maxim Bulygin
d1ce0c366a Merge remote-tracking branch 'PHPOffice/develop' into develop 2018-05-24 16:19:00 +03:00
eweso
91ada213c5
Update ListItem.php 2018-03-31 00:38:43 +02:00
eweso
5741e47129
Update ListItem.php 2018-03-31 00:37:50 +02:00
eweso
a09e7151ac
Update ListItem.php 2018-03-30 22:58:03 +02:00
eweso
71618f704d
Adding setNumId method for ListItem style
By allowing to set the numId in the ListItem style manually, you can separate lists. Every ListItem with the same numId belongs to one list. This allows you to restart list counting.
2018-03-30 19:24:45 +02:00
Gerald Buttinger
bcfb3e868c Add methods setValuesFromArray and cloneRowFromArray to the TemplateProcessor-class and update samples and docs accordingly 2015-11-27 14:30:22 +01:00
575 changed files with 23507 additions and 15358 deletions

4
.gitattributes vendored
View File

@ -1,6 +1,6 @@
# build config
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/.github export-ignore
/php_cs.dist export-ignore
/phpmd.xml.dist export-ignore
/phpstan.neon export-ignore
@ -18,4 +18,4 @@
# tests
/phpunit.xml.dist export-ignore
/tests export-ignore
/tests export-ignore

38
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help improve PHPWord
labels: Bug Report
---
### Describe the Bug
A clear and concise description of what the bug is.
### Steps to Reproduce
Please provide a code sample that reproduces the issue.
```php
<?php
require __DIR__ . '/vendor/autoload.php';
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->...
```
### Expected Behavior
A clear and concise description of what you expected to happen.
### Current Behavior
What is the current behavior?
### Context
Please fill in your environment information:
- PHP Version:
- PHPWord Version:

View File

@ -0,0 +1,22 @@
---
name: Feature request
about: Suggest an idea for this project
labels: Change Request
---
### Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
### Describe the solution you'd like
A clear and concise description of what you want to happen.
### Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
### Additional context
Add any other context or screenshots about the feature request here.

14
.github/ISSUE_TEMPLATE/how-to-use.md vendored Normal file
View File

@ -0,0 +1,14 @@
---
name: How to Use PHPWord
about: Find out how to use PHPWord
labels: WontFix
---
***Please do not use the issue tracker to ask how to use PHPWord.***
Documentation is available on [Read the Docs](https://phpword.readthedocs.io/en/latest/).
Sample code is in the [`/samples/` directory](https://github.com/PHPOffice/PHPWord/tree/master/samples).
Usage questions belong on [Stack Overflow](https://stackoverflow.com/questions/tagged/phpword).

8
.github/dependabot.yml vendored Normal file
View File

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

15
.github/support.yml vendored Normal file
View File

@ -0,0 +1,15 @@
# Label used to mark issues as support requests
supportLabel: Question
# Comment to post on issues marked as support requests. Add a link
# to a support page, or set to `false` to disable
supportComment: >
This looks like a support question. Please ask your support questions on
[StackOverflow](http://stackoverflow.com/questions/tagged/phpword),
or [Gitter](https://gitter.im/PHPOffice/PHPWord).
Thank you for your contributions.
# Whether to close issues marked as support requests
close: true
# Whether to lock issues marked as support requests
lock: false

119
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,119 @@
name: CI
on:
- push
- pull_request
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
name: PHP ${{ matrix.php-version }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Configure matchers
uses: mheap/phpunit-matcher-action@v1
- name: Test with PHPUnit
run: ./vendor/bin/phpunit --no-coverage
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: none
tools: cs2pr
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Code style with PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: pcov
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Coverage
run: |
./vendor/bin/phpunit --coverage-clover coverage-clover.xml
curl -LO https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage-clover.xml

29
.github/workflows/github-pages.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: GithHub Pages
on:
push:
tags:
- '*'
jobs:
github-pages:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none # remove xdebug
- name: Build API documentation
run: |
curl -LO https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0/phpDocumentor.phar
php phpDocumentor.phar --directory src/ --target docs/api
- name: Deploy to GithHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/api

View File

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

2
.gitignore vendored
View File

@ -13,7 +13,6 @@ composer.phar
vendor
/report
/build
/samples/resources
/samples/results
/.settings
phpword.ini
@ -22,3 +21,4 @@ phpword.ini
/.project
/nbproject
/.php_cs.cache
/.phpunit.result.cache

227
.php-cs-fixer.dist.php Normal file
View File

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

View File

@ -1,146 +0,0 @@
<?php
$finder = PhpCsFixer\Finder::create()
->notName('pclzip.lib.php')
->notName('OLERead.php')
->in('samples')
->in('src')
->in('tests');
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setFinder($finder)
->setRules(array(
'array_syntax' => array('syntax' => 'long'),
'binary_operator_spaces' => array('align_double_arrow' => true),
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => false,
'blank_line_before_return' => true,
'braces' => true,
'cast_spaces' => true,
'class_definition' => true,
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
'combine_consecutive_unsets' => true,
'concat_space' => array('spacing' => 'one'),
'declare_equal_normalize' => true,
'declare_strict_types' => false, // Too early to adopt strict types
'dir_constant' => true,
'elseif' => true,
'encoding' => true,
'ereg_to_preg' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false, // No use for that
'hash_to_slash_comment' => true,
'header_comment' => false, // We don't use common header in all our files
'heredoc_to_nowdoc' => false, // Not sure about this one
'is_null' => false, // Risky
'include' => true,
'indentation_type' => true,
'line_ending' => true,
'linebreak_after_opening_tag' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'mb_str_functions' => false, // No, too dangerous to change that
'method_argument_space' => true,
'method_separation' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'native_function_invocation'=> false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'useTrait', 'curly_brace_block', 'parenthesis_brace_block', 'square_brace_block'),
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
'not_operator_with_successor_space' => false, // idem
'object_operator_without_whitespace' => true,
'ordered_class_elements' => false, // We prefer to keep some freedom
'ordered_imports' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'php_unit_fqcn_annotation' => true,
'php_unit_strict' => false, // We sometime actually need assertEquals
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => false, // Waste of time
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => false,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => false,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => false,
'pre_increment' => false,
'protected_to_private' => true,
'psr0' => true,
'psr4' => true,
'random_api_migration' => false, // This breaks our unit tests
'return_type_declaration' => true,
'self_accessor' => true,
'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
'short_scalar_cast' => true,
'silenced_deprecation_error' => true,
'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'strict_comparison' => false, // No, too dangerous to change that
'strict_param' => false, // No, too dangerous to change that
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'ternary_to_null_coalescing' => false, // Cannot use that with PHP 5.6
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => false,
'unary_operator_spaces' => true,
'visibility_required' => true,
'whitespace_after_comma_in_array' => true,
));

View File

@ -3,6 +3,12 @@ build:
analysis:
tests:
override: [php-scrutinizer-run]
environment:
php:
version: '7.4'
pecl_extensions:
- zip
filter:
excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ]

View File

@ -1,68 +0,0 @@
language: php
dist: precise
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
matrix:
include:
- php: 7.0
env: COVERAGE=1
- php: 5.3
env: COMPOSER_MEMORY_LIMIT=2G
- php: 7.3
env: DEPENDENCIES="--ignore-platform-reqs"
exclude:
- php: 5.3
- php: 7.0
- php: 7.3
cache:
directories:
- $HOME/.composer/cache
- .php-cs.cache
env:
global:
- secure: "Sq+6bVtnPsu0mWX8DWQ+9bGAjxMcGorksUiHc4YIXEJsuDfVmVlH8tTD547IeCjDAx9MxXerZ2Z4HSjxTB70VEnJPvZMHI/EZn4Ny31YLHEthdZbV5Gd1h0TGp8VOzPKGShvGrtGBX6MvMfgpK4zuieVWbSfdKeecm8ZNLMpUd4="
before_install:
## Packages
- sudo apt-get update -qq
- sudo apt-get install -y graphviz
before_script:
## Deactivate xdebug if we don't do code coverage
- if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini || echo "xdebug not available" ; fi
## Composer
- composer self-update
- travis_wait composer install --prefer-source $(if [ -n "$DEPENDENCIES" ]; then echo $DEPENDENCIES; fi)
## PHPDocumentor
##- mkdir -p build/docs
- mkdir -p build/coverage
script:
## PHP_CodeSniffer
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ; fi
## PHP-CS-Fixer
- if [ -n "$COVERAGE" ]; then ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run ; fi
## PHP Mess Detector
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ; fi
## PHPUnit
- ./vendor/bin/phpunit -c ./ $(if [ -n "$COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi)
## 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
after_success:
## Coveralls
- if [ -n "$COVERAGE" ]; then travis_retry php vendor/bin/php-coveralls -v ; fi

View File

@ -1,8 +1,223 @@
Change Log
==========
# Changelog
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [1.0.0](https://github.com/PHPOffice/PHPWord/tree/1.0.0) (2022-11-15)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.18.3...1.0.0)
### BREAKING CHANGE
Most deprecated things were dropped. See details in
https://github.com/PHPOffice/PHPWord/commit/b9f1151bc6f90c276153c3c9dca10a5fc7f355fb.
#### Dropped classes:
- `PhpOffice\PhpWord\Template`
#### Dropped constants:
- `PhpOffice\PhpWord\Style\Font::UNDERLINE_DOTHASH`
- `PhpOffice\PhpWord\Style\Font::UNDERLINE_DOTHASHHEAVY`
- `PhpOffice\PhpWord\Style\Cell::VALIGN_TOP`
- `PhpOffice\PhpWord\Style\Cell::VALIGN_CENTER`
- `PhpOffice\PhpWord\Style\Cell::VALIGN_BOTTOM`
- `PhpOffice\PhpWord\Style\Cell::VALIGN_BOTH`
- `PhpOffice\PhpWord\Style\TOC::TABLEADER_DOT`
- `PhpOffice\PhpWord\Style\TOC::TABLEADER_UNDERSCORE`
- `PhpOffice\PhpWord\Style\TOC::TABLEADER_LINE`
- `PhpOffice\PhpWord\Style\TOC::TABLEADER_NONE`
- `PhpOffice\PhpWord\Style\Table::WIDTH_AUTO`
- `PhpOffice\PhpWord\Style\Table::WIDTH_PERCENT`
- `PhpOffice\PhpWord\Style\Table::WIDTH_TWIP`
- `PhpOffice\PhpWord\PhpWord::DEFAULT_FONT_NAME`
- `PhpOffice\PhpWord\PhpWord::DEFAULT_FONT_SIZE`
- `PhpOffice\PhpWord\PhpWord::DEFAULT_FONT_COLOR`
- `PhpOffice\PhpWord\PhpWord::DEFAULT_FONT_CONTENT_TYPE`
-
#### Dropped methods:
- `PhpOffice\PhpWord\Ekement\AbstractContainer::createTextRun()`
- `PhpOffice\PhpWord\Ekement\AbstractContainer::createFootnote()`
- `PhpOffice\PhpWord\Ekement\Footnote::getReferenceId()`
- `PhpOffice\PhpWord\Ekement\Footnote::setReferenceId()`
- `PhpOffice\PhpWord\Ekement\Image::getIsWatermark()`
- `PhpOffice\PhpWord\Ekement\Image::getIsMemImage()`
- `PhpOffice\PhpWord\Ekement\Link::getTarget()`
- `PhpOffice\PhpWord\Ekement\Link::getLinkSrc()`
- `PhpOffice\PhpWord\Ekement\Link::getLinkName()`
- `PhpOffice\PhpWord\Ekement\OLEObject::getObjectId()`
- `PhpOffice\PhpWord\Ekement\OLEObject::setObjectId()`
- `PhpOffice\PhpWord\Ekement\Section::getFootnotePropoperties()`
- `PhpOffice\PhpWord\Ekement\Section::setSettings()`
- `PhpOffice\PhpWord\Ekement\Section::getSettings()`
- `PhpOffice\PhpWord\Ekement\Section::createHeader()`
- `PhpOffice\PhpWord\Ekement\Section::createFooter()`
- `PhpOffice\PhpWord\Ekement\Section::getFooter()`
- `PhpOffice\PhpWord\Media::addSectionMediaElement()`
- `PhpOffice\PhpWord\Media::addSectionLinkElement()`
- `PhpOffice\PhpWord\Media::getSectionMediaElements()`
- `PhpOffice\PhpWord\Media::countSectionMediaElements()`
- `PhpOffice\PhpWord\Media::addHeaderMediaElement()`
- `PhpOffice\PhpWord\Media::countHeaderMediaElements()`
- `PhpOffice\PhpWord\Media::getHeaderMediaElements()`
- `PhpOffice\PhpWord\Media::addFooterMediaElement()`
- `PhpOffice\PhpWord\Media::countFooterMediaElements()`
- `PhpOffice\PhpWord\Media::getFooterMediaElements()`
- `PhpOffice\PhpWord\PhpWord::getProtection()`
- `PhpOffice\PhpWord\PhpWord::loadTemplate()`
- `PhpOffice\PhpWord\PhpWord::createSection()`
- `PhpOffice\PhpWord\PhpWord::getDocumentProperties()`
- `PhpOffice\PhpWord\PhpWord::setDocumentProperties()`
- `PhpOffice\PhpWord\Reader\AbstractReader::getReadDataOnly()`
- `PhpOffice\PhpWord\Settings::getCompatibility()`
- `PhpOffice\PhpWord\Style\AbstractStyle::setArrayStyle()`
- `PhpOffice\PhpWord\Style\Cell::getDefaultBorderColor()`
- `PhpOffice\PhpWord\Style\Font::getBold()`
- `PhpOffice\PhpWord\Style\Font::getItalic()`
- `PhpOffice\PhpWord\Style\Font::getSuperScript()`
- `PhpOffice\PhpWord\Style\Font::getSubScript()`
- `PhpOffice\PhpWord\Style\Font::getStrikethrough()`
- `PhpOffice\PhpWord\Style\Font::getParagraphStyle()`
- `PhpOffice\PhpWord\Style\Frame::getAlign()`
- `PhpOffice\PhpWord\Style\Frame::setAlign()`
- `PhpOffice\PhpWord\Style\NumberingLevel::getAlign()`
- `PhpOffice\PhpWord\Style\NumberingLevel::setAlign()`
- `PhpOffice\PhpWord\Style\Paragraph::getAlign()`
- `PhpOffice\PhpWord\Style\Paragraph::setAlign()`
- `PhpOffice\PhpWord\Style\Paragraph::getWidowControl()`
- `PhpOffice\PhpWord\Style\Paragraph::getKeepNext()`
- `PhpOffice\PhpWord\Style\Paragraph::getKeepLines()`
- `PhpOffice\PhpWord\Style\Paragraph::getPageBreakBefore()`
- `PhpOffice\PhpWord\Style\Row::getTblHeader()`
- `PhpOffice\PhpWord\Style\Row::isTblHeader()`
- `PhpOffice\PhpWord\Style\Row::getCantSplit()`
- `PhpOffice\PhpWord\Style\Row::getExactHeight()`
- `PhpOffice\PhpWord\Style\Spacing::getRule()`
- `PhpOffice\PhpWord\Style\Spacing::setRule()`
- `PhpOffice\PhpWord\Style\Table::getAlign()`
- `PhpOffice\PhpWord\Style\Table::setAlign()`
- `PhpOffice\PhpWord\Writer\AbstractWriter::getUseDiskCaching()`
- `PhpOffice\PhpWord\Writer\HTML::writeDocument()`
### Bug fixes
- Multiple PHP 8.1 fixes
- `loadConfig` returns config that was actually applied
- HTML Reader : Override inline style on HTML attribute for table
- HTML Reader : Use `border` attribute for tables
- HTML Reader : Style page-break-after in paragraph
- HTML Reader : Heading in Text Run is not allowed
-
### Miscellaneous
- Drop support for PHP 7.0 and older
## [0.18.3](https://github.com/PHPOffice/PHPWord/tree/0.18.3) (2022-02-17)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.18.2...0.18.3)
### Bug fixes
- PHP 8.1 compatibility
## [0.18.2](https://github.com/PHPOffice/PHPWord/tree/0.18.2) (2021-06-04)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.18.1...0.18.2)
### Bug fixes
- when adding image to relationship first check that the generated RID is actually unique [\#2063](https://github.com/PHPOffice/PHPWord/pull/2063) ([tpv-ebben](https://github.com/tpv-ebben))
- Update chart, don't write 'c:overlap' if grouping is 'clustered' [\#2052](https://github.com/PHPOffice/PHPWord/pull/2052) ([dfsd534](https://github.com/dfsd534))
- Update Html parser to accept line-height:normal [\#2041](https://github.com/PHPOffice/PHPWord/pull/2041) ([joelgo](https://github.com/joelgo))
- Fix image border in Word2007 Writer for LibreOffice 7 [\#2021](https://github.com/PHPOffice/PHPWord/pull/2021) ([kamilmmach](https://github.com/kamilmmach))
### Miscellaneous
- Corrected namespace for Language class in docs. [\#2087](https://github.com/PHPOffice/PHPWord/pull/2087) ([MegaChriz](https://github.com/MegaChriz))
- Added support for Garamond font [\#2078](https://github.com/PHPOffice/PHPWord/pull/2078) ([artemkolotilkin](https://github.com/artemkolotilkin))
- Add BorderStyle for Cell Style to documentation [\#2090](https://github.com/PHPOffice/PHPWord/pull/2090) ([DShkrabak](https://github.com/DShkrabak))
## [0.18.1](https://github.com/PHPOffice/PHPWord/tree/0.18.1) (2021-03-08)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.18.0...0.18.1)
### Bug fixes
- Fix BC break in #1946. This package does not replace laminas/laminas-zendframework-bridge [\#2032](https://github.com/PHPOffice/PHPWord/pull/2032) ([mussbach](https://github.com/mussbach))
## [0.18.0](https://github.com/PHPOffice/PHPWord/tree/0.18.0) (2021-02-12)
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/0.17.0...0.18.0)
### Enhancements
- Add support for charts in template processor [\#2012](https://github.com/PHPOffice/PHPWord/pull/2012) ([dbarzin](https://github.com/dbarzin))
- add/setting page element border style. [\#1986](https://github.com/PHPOffice/PHPWord/pull/1986) ([emnabs](https://github.com/emnabs))
- allow to use customized pdf library [\#1983](https://github.com/PHPOffice/PHPWord/pull/1983) ([SailorMax](https://github.com/SailorMax))
- feat: Update addHtml to handle style inheritance [\#1965](https://github.com/PHPOffice/PHPWord/pull/1965) ([Julien1138](https://github.com/Julien1138))
- Add parsing of Shape node values [\#1924](https://github.com/PHPOffice/PHPWord/pull/1924) ([sven-ahrens](https://github.com/sven-ahrens))
- Allow to redefine TCPDF object [\#1907](https://github.com/PHPOffice/PHPWord/pull/1907) ([SailorMax](https://github.com/SailorMax))
- Enhancements to addHTML parser [\#1902](https://github.com/PHPOffice/PHPWord/pull/1902) ([lubosdz](https://github.com/lubosdz))
- Make Default Paper Configurable [\#1851](https://github.com/PHPOffice/PHPWord/pull/1851) ([oleibman](https://github.com/oleibman))
- Implement various missing features for the ODT writer [\#1796](https://github.com/PHPOffice/PHPWord/pull/1796) ([oleibman](https://github.com/oleibman))
- Added support for "cloudConvert" images [\#1794](https://github.com/PHPOffice/PHPWord/pull/1794) ([ErnestStaug](https://github.com/ErnestStaug))
- Add support for several features for the RTF writer [\#1775](https://github.com/PHPOffice/PHPWord/pull/1775) ([oleibman](https://github.com/oleibman))
- Add font style for Field elements [\#1774](https://github.com/PHPOffice/PHPWord/pull/1774) ([oleibman](https://github.com/oleibman))
- Add support for ListItemRun in HTML writer [\#1766](https://github.com/PHPOffice/PHPWord/pull/1766) ([stefan-91](https://github.com/stefan-91))
- Improvements in RTF writer [\#1755](https://github.com/PHPOffice/PHPWord/pull/1755) ([oleibman](https://github.com/oleibman))
- Allow a closure to be passed with image replacement tags [\#1716](https://github.com/PHPOffice/PHPWord/pull/1716) ([mbardelmeijer](https://github.com/mbardelmeijer))
- Add Option for Dynamic Chart Legend Position [\#1699](https://github.com/PHPOffice/PHPWord/pull/1699) ([Stephan212](https://github.com/Stephan212))
- Add parsing of HTML checkbox input field [\#1832](https://github.com/PHPOffice/PHPWord/pull/1832) ([Matze2010](https://github.com/Matze2010))
### Bug fixes
- Fix image stroke in libreoffice 7.x [\#1992](https://github.com/PHPOffice/PHPWord/pull/1992) ([Adizbek](https://github.com/Adizbek))
- Fix deprecated warning for non-hexadecimal number [\#1988](https://github.com/PHPOffice/PHPWord/pull/1988) ([Ciki](https://github.com/Ciki))
- Fix limit not taken into account when adding image in template [\#1967](https://github.com/PHPOffice/PHPWord/pull/1967) ([jsochor](https://github.com/jsochor))
- Add null check when setComplexValue is not found [\#1936](https://github.com/PHPOffice/PHPWord/pull/1936) ([YannikFirre](https://github.com/YannikFirre))
- Some document have non-standard locale code [\#1824](https://github.com/PHPOffice/PHPWord/pull/1824) ([ErnestStaug](https://github.com/ErnestStaug))
- Fixes PHPDoc @param and @return types for several Converter methods [\#1818](https://github.com/PHPOffice/PHPWord/pull/1818) ([caugner](https://github.com/caugner))
- Update the regexp to avoid catastrophic backtracking [\#1809](https://github.com/PHPOffice/PHPWord/pull/1809) ([juzser](https://github.com/juzser))
- Fix PHPUnit tests on develop branch [\#1771](https://github.com/PHPOffice/PHPWord/pull/1771) ([mdupont](https://github.com/mdupont))
- TemplateProcessor cloneBlock wrongly clones images [\#1763](https://github.com/PHPOffice/PHPWord/pull/1763) ([alarai](https://github.com/alarai))
### Miscellaneous
- Compatibility with PHP 7.4, PHP 8.0 and migrate to Laminas Escaper [\#1946](https://github.com/PHPOffice/PHPWord/pull/1946) ([liborm85](https://github.com/liborm85))
- Remove legacy PHPOffice/Common package, fix PHP 8.0 compatibility [\#1996](https://github.com/PHPOffice/PHPWord/pull/1996) ([liborm85](https://github.com/liborm85))
- Improve Word2007 Test Coverage [\#1858](https://github.com/PHPOffice/PHPWord/pull/1858) ([oleibman](https://github.com/oleibman))
- Fix typo in docs. Update templates-processing.rst [\#1952](https://github.com/PHPOffice/PHPWord/pull/1952) ([mnvx](https://github.com/mnvx))
- Fix documentation and method name for FootnoteProperties [\#1776](https://github.com/PHPOffice/PHPWord/pull/1776) ([mdupont](https://github.com/mdupont))
- fix: documentation about paragraph indentation [\#1764](https://github.com/PHPOffice/PHPWord/pull/1764) ([mdupont](https://github.com/mdupont))
- Update templates-processing.rst [\#1745](https://github.com/PHPOffice/PHPWord/pull/1745) ([igronus](https://github.com/igronus))
- Unused variables $rows, $cols in sample [\#1877](https://github.com/PHPOffice/PHPWord/pull/1877) ([ThanasisMpalatsoukas](https://github.com/ThanasisMpalatsoukas))
- Add unit test for NumberingStyle [\#1744](https://github.com/PHPOffice/PHPWord/pull/1744) ([Manunchik](https://github.com/Manunchik))
- Add unit test for PhpWord Settings [\#1743](https://github.com/PHPOffice/PHPWord/pull/1743) ([Manunchik](https://github.com/Manunchik))
- Add unit test for Media elements [\#1742](https://github.com/PHPOffice/PHPWord/pull/1742) ([Manunchik](https://github.com/Manunchik))
- Update templates processing docs [\#1729](https://github.com/PHPOffice/PHPWord/pull/1729) ([hcdias](https://github.com/hcdias))
v0.17.0 (01 oct 2019)
----------------------
### Added
- Add methods setValuesFromArray and cloneRowFromArray to the TemplateProcessor @geraldb-nicat #670
- Set complex type in template @troosan #1565
- implement support for section vAlign @troosan #1569
- ParseStyle for border-color @Gllrm0 #1551
- Html writer auto invert text color @SailorMax #1387
- Add RightToLeft table presentation. @troosan #1550
- Add support for page vertical alignment. @troosan #672 #1569
- Adding setNumId method for ListItem style @eweso #1329
- Add support for basic fields in RTF writer. @Samuel-BF #1717
### Fixed
- Fix HTML border-color parsing. @troosan #1551 #1570
- Language::validateLocale should pass with locale 'zxx'. @efpapado #1558
- can't align center vertically with the text @ter987 #672
- fix parsing of border-color and add test @troosan #1570
- TrackChange doesn't handle all return types of \DateTime::createFromFormat(...) @superhaggis #1584
- To support PreserveText inside sub container @bhattnishant #1637
- No nested w:pPr elements in ListItemRun. @waltertamboer #1628
- Ensure that entity_loader disable variable is re-set back to the original setting @seamuslee001 #1585
### Miscellaneous
- Use embedded http server to test loading of remote images @troosan #1544
- Change private to protected to be able extending class Html @SpinyMan #1646
- Fix apt-get crash in Travis CI for PHP 5.3 @mdupont #1707
v0.16.0 (30 dec 2018)
----------------------
### Added
@ -27,7 +242,7 @@ v0.16.0 (30 dec 2018)
- For RTF writers, sizes should should never have decimals @Samuel-BF #1536
- Style Name Parsing fails if document generated by a non-english word version @begnini #1434
### Miscelaneous
### Miscellaneous
- Get rid of duplicated code in TemplateProcessor @abcdmitry #1161
v0.15.0 (14 Jul 2018)
@ -73,7 +288,7 @@ v0.15.0 (14 Jul 2018)
- Remove zend-stdlib dependency @Trainmaster #1284
- The default unit for `\PhpOffice\PhpWord\Style\Image` changed from `px` to `pt`.
### Miscelaneous
### Miscellaneous
- Drop GitHub pages, switch to coveralls for code coverage analysis @czosel #1360
v0.14.0 (29 Dec 2017)

View File

@ -1,13 +1,30 @@
# Contributing to PHPWord
PHPWord is built by the crowd and for the crowd. Every contribution is welcome; either by [submitting](https://github.com/PHPOffice/PHPWord/issues) bug issues or suggesting improvements, or in a more active form like [requesting](https://github.com/PHPOffice/PHPWord/pulls) a pull.
PHPWord is built by the crowd and for the crowd. Every contribution is welcome; either by [reporting a bug](https://github.com/PHPOffice/PHPWord/issues/new?labels=Bug+Report&template=bug_report.md) or [suggesting improvements](https://github.com/PHPOffice/PHPWord/issues/new?labels=Change+Request&template=feature_request.md), or in a more active form like [requesting a pull](https://github.com/PHPOffice/PHPWord/pulls).
We want to create a high quality document writer and reader library that people can use with more confidence and less bugs. We want to collaborate happily, code joyfully, and get alive merrily. Thus, below are some guidelines, that we expect to be followed by each contributor.
We want to create a high quality document writer and reader library that people can use with more confidence and fewer bugs. We want to collaborate happily, code joyfully, and live merrily. Thus, below are some guidelines that we expect to be followed by each contributor:
- **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 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.
- **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 them 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, [familiarize yourself now](https://github.com/php-fig/fig-standards). Also, please run `composer fix` to automatically fix your code to match these recommendations.
- **Test your code**. No one knows your code better than you, so we depend on you to test the changes you make before pull request submission. We use [PHPUnit](https://phpunit.de/) for our testing purposes and request that you use this tool too. Tests can be ran with `composer test`. [Documentation for writing tests with PHPUnit is available on Read the Docs.](https://phpunit.readthedocs.io)
- **Use best practices when submitting pull requests**. Create a separate branch named specifically for the issue that you are addressing. Read the [GitHub manual](https://help.github.com/articles/about-pull-requests) to learn more about pull requests and GitHub. 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 fork on GitHub with the upstream branch from PHPWord.
## Getting Started
1. [Clone](https://help.github.com/en/articles/cloning-a-repository) [PHPWord](https://github.com/PHPOffice/PHPWord/)
2. [Install Composer](https://getcomposer.org/download/) if you don't already have it
3. Open your terminal and:
1. Switch to the directory PHPWord was cloned to (e.g., `cd ~/Projects/PHPWord/`)
2. Run `composer install` to install the dependencies
You're ready to start working on PHPWord! Tests belong in the `/tests/PhpWord/` directory, the source code is in `/src/PhpWord/`, and any documentation should go in `/docs/`. Familiarize yourself with the codebase and try your hand at fixing [one of our outstanding issues](https://github.com/PHPOffice/PHPWord/issues). Before you get started, check the [existing pull requests](https://github.com/PHPOffice/PHPWord/pulls) to make sure no one else is already working on it.
Once you have an issue you want to start working on, you'll need to write tests for it, and then you can start implementing the changes necessary to pass the new tests. To run the tests, you can run one of the following commands in your terminal:
- `composer test-no-coverage` to run all of the tests
- `composer test` to run all of the tests and generate test coverage reports
When you're ready to submit your new (and fully tested) feature, ensure `composer check` passes and [submit a pull request to PHPWord](https://github.com/PHPOffice/PHPWord/issues/new).
That's it. Thank you for your interest in PHPWord, and welcome!

View File

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

View File

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

View File

@ -1,35 +0,0 @@
This is:
- [ ] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpword)
### Expected Behavior
Please describe the behavior you are expecting.
### Current Behavior
What is the current behavior?
### Failure Information
Please help provide information about the failure.
### How to Reproduce
Please provide a code sample that reproduces the issue.
```php
<?php
require __DIR__ . '/vendor/autoload.php';
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->...
```
### Context
* PHP version:
* PHPWord version: 0.14

View File

@ -41,14 +41,14 @@ master_doc = 'index'
# General information about the project.
project = u'PHPWord'
copyright = u'2014-2017, PHPWord Contributors'
copyright = u'2014-2021, PHPWord Contributors'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.16.0'
version = '0.18.2'
# The full version, including alpha/beta/rc tags.
release = version

View File

@ -359,17 +359,17 @@ The footnote numbering can be controlled by setting the FootnoteProperties on th
.. code-block:: php
$fp = new PhpWord\SimpleType\FootnoteProperties();
$fp = new \PhpOffice\PhpWord\ComplexType\FootnoteProperties();
//sets the position of the footnote (pageBottom (default), beneathText, sectEnd, docEnd)
$fp->setPos(FootnoteProperties::POSITION_DOC_END);
$fp->setPos(\PhpOffice\PhpWord\ComplexType\FootnoteProperties::POSITION_BENEATH_TEXT);
//set the number format to use (decimal (default), upperRoman, upperLetter, ...)
$fp->setNumFmt(FootnoteProperties::NUMBER_FORMAT_LOWER_ROMAN);
$fp->setNumFmt(\PhpOffice\PhpWord\SimpleType\NumberFormat::LOWER_ROMAN);
//force starting at other than 1
$fp->setNumStart(2);
//when to restart counting (continuous (default), eachSect, eachPage)
$fp->setNumRestart(FootnoteProperties::RESTART_NUMBER_EACH_PAGE);
$fp->setNumRestart(\PhpOffice\PhpWord\ComplexType\FootnoteProperties::RESTART_NUMBER_EACH_PAGE);
//And finaly, set it on the Section
$section->setFootnoteProperties($properties);
$section->setFootnoteProperties($fp);
Checkboxes
----------
@ -403,7 +403,9 @@ Currently the following fields are supported:
.. code-block:: php
$section->addField($fieldType, [$properties], [$options], [$fieldText])
$section->addField($fieldType, [$properties], [$options], [$fieldText], [$fontStyle])
- ``$fontStyle``. See :ref:`font-style`.
See ``\PhpOffice\PhpWord\Element\Field`` for list of properties and options available for each field type.
Options which are not specifically defined can be added. Those must start with a ``\``.

View File

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

View File

@ -130,6 +130,16 @@ To turn it on set ``outputEscapingEnabled`` option to ``true`` in your PHPWord c
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
Default Paper
~~~~~~~~~~~~~
By default, all sections of the document will print on A4 paper.
You can alter the default paper by using the following function:
.. code-block:: php
\PhpOffice\PhpWord\Settings::setDefaultPaper('Letter');
Default font
~~~~~~~~~~~~
@ -182,11 +192,11 @@ You can also specify the status of the spell and grammar checks, marking spellin
.. code-block:: php
$proofState = new ProofState();
$proofState->setGrammar(ProofState::CLEAN);
$proofState->setSpelling(ProofState::DIRTY);
$proofState = new \PhpOffice\PhpWord\ComplexType\ProofState();
$proofState->setGrammar(\PhpOffice\PhpWord\ComplexType\ProofState::CLEAN);
$proofState->setSpelling(\PhpOffice\PhpWord\ComplexType\ProofState::DIRTY);
$phpWord->getSettings()->setProofState(proofState);
$phpWord->getSettings()->setProofState($proofState);
Track Revisions
~~~~~~~~~~~~~~~
@ -218,7 +228,7 @@ The default language of the document can be change with the following.
$phpWord->getSettings()->setThemeFontLang(new Language(Language::FR_BE));
``Language`` has 3 parameters, one for Latin languages, one for East Asian languages and one for Complex (Bi-Directional) languages.
A couple of language codes are provided in the ``PhpOffice\PhpWord\ComplexType\Language`` class but any valid code/ID can be used.
A couple of language codes are provided in the ``PhpOffice\PhpWord\Style\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.

View File

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

View File

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

View File

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

View File

@ -32,6 +32,8 @@ Available Section style options:
See ``\PhpOffice\PhpWord\Style\Section::ORIENTATION_...`` class constants for possible values
- ``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.
- ``vAlign``. Vertical Page Alignment
See ``\PhpOffice\PhpWord\SimpleType\VerticalJc`` for possible values
.. _font-style:
@ -73,8 +75,10 @@ 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 constants for possible values.
- ``basedOn``. Parent style.
- ``hanging``. Hanging in *twip*.
- ``indent``. Indent in *twip*.
- ``hanging``. Hanging indentation in *half inches*.
- ``indent``. Indent (left indentation) in *half inches*.
- ``indentation``. An array of indentation key => value pairs in *twip*. Supports *left*, *right*, *firstLine* and *hanging* indentation.
See ``\PhpOffice\PhpWord\Style\Indentation`` for possible identation types.
- ``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.
@ -108,11 +112,12 @@ Available Table style options:
- ``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.
- ``width``. Table width in Fiftieths of a Percent or Twentieths of a Point.
- ``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
- ``bidiVisual`` Present table as Right-To-Left
Floating Table Positioning options:
@ -138,6 +143,7 @@ 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 *twip*.
- ``border(Top|Right|Bottom|Left)Style``. Border style. You can use constants from ``\PhpOffice\PhpWord\SimpleType\Border``
- ``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``
@ -196,6 +202,7 @@ Available Chart style options:
- ``colors``. A list of colors to use in the chart.
- ``title``. The title for the chart.
- ``showLegend``. Show legend, *true* or *false*.
- ``LegendPosition``. Legend position, *r* (default), *b*, *t*, *l* or *tr*.
- ``categoryLabelPosition``. Label position for categories, *nextTo* (default), *low* or *high*.
- ``valueLabelPosition``. Label position for values, *nextTo* (default), *low* or *high*.
- ``categoryAxisTitle``. The title for the category axis.

View File

@ -4,7 +4,7 @@ Templates processing
====================
You can create an OOXML document template with included search-patterns (macros) which can be replaced by any value you wish. Only single-line values can be replaced.
Macros are defined like this: ``${search-pattern}``.
By default Macros are defined like this: ``${search-pattern}`` but you can define custom macros.
To load a template file, create a new instance of the TemplateProcessor.
.. code-block:: php
@ -17,13 +17,47 @@ Given a template containing
.. code-block:: clean
Hello ${name}!
Hello ${firstname} ${lastname}!
The following will replace ``${name}`` with ``World``. The resulting document will now contain ``Hello World!``
The following will replace ``${firstname}`` with ``John``, and ``${lastname}`` with ``Doe`` .
The resulting document will now contain ``Hello John Doe!``
.. code-block:: php
$templateProcessor->setValue('name', 'World');
$templateProcessor->setValue('firstname', 'John');
$templateProcessor->setValue('lastname', 'Doe');
setValues
"""""""""
You can also set multiple values by passing all of them in an array.
.. code-block:: php
$templateProcessor->setValues(array('firstname' => 'John', 'lastname' => 'Doe'));
setMacroOpeningChars
""""""""
You can define a custom opening macro. The following will set ``{#`` as the opening search pattern.
.. code-block:: php
$templateProcessor->setMacroOpeningChars('{#');
setMacroClosingChars
""""""""
You can define a custom closing macro. The following will set ``#}`` as the closing search pattern.
.. code-block:: php
$templateProcessor->setMacroClosingChars('#}');
setMacroChars
""""""""
You can define a custom opening and closing macro at the same time . The following will set the search-pattern like this: ``{#search-pattern#}`` .
.. code-block:: php
$templateProcessor->setMacroChars('{#', '#}');
setImageValue
"""""""""""""
@ -53,6 +87,11 @@ Example:
$templateProcessor->setImageValue('CompanyLogo', 'path/to/company/logo.png');
$templateProcessor->setImageValue('UserLogo', array('path' => 'path/to/logo.png', 'width' => 100, 'height' => 100, 'ratio' => false));
$templateProcessor->setImageValue('FeatureImage', function () {
// Closure will only be executed if the replacement tag is found in the template
return array('path' => SlowFeatureImageGenerator::make(), 'width' => 100, 'height' => 100, 'ratio' => false);
});
cloneBlock
""""""""""
@ -117,7 +156,7 @@ Given a template containing
This block content will be replaced
${/block_name}
The following will replace everything between``${block_name}`` and ``${/block_name}`` with the value passed.
The following will replace everything between ``${block_name}`` and ``${/block_name}`` with the value passed.
.. code-block:: php
@ -138,11 +177,11 @@ See ``Sample_07_TemplateCloneRow.php`` for an example.
.. code-block:: clean
------------------------------
+-----------+----------------+
| ${userId} | ${userName} |
| |----------------|
| |----------------+
| | ${userAddress} |
------------------------------
+-----------+----------------+
.. code-block:: php
@ -152,15 +191,49 @@ Will result in
.. code-block:: clean
----------------------------------
+-------------+------------------+
| ${userId#1} | ${userName#1} |
| |------------------|
| |------------------+
| | ${userAddress#1} |
---------------------------------|
+-------------+------------------+
| ${userId#2} | ${userName#2} |
| |------------------|
| |------------------+
| | ${userAddress#2} |
----------------------------------
+-------------+------------------+
cloneRowAndSetValues
""""""""""""""""""""
Finds a row in a table row identified by `$search` param and clones it as many times as there are entries in `$values`.
.. code-block:: clean
+-----------+----------------+
| ${userId} | ${userName} |
| |----------------+
| | ${userAddress} |
+-----------+----------------+
.. code-block:: php
$values = [
['userId' => 1, 'userName' => 'Batman', 'userAddress' => 'Gotham City'],
['userId' => 2, 'userName' => 'Superman', 'userAddress' => 'Metropolis'],
];
$templateProcessor->cloneRowAndSetValues('userId', $values);
Will result in
.. code-block:: clean
+---+-------------+
| 1 | Batman |
| |-------------+
| | Gotham City |
+---+-------------+
| 2 | Superman |
| |-------------+
| | Metropolis |
+---+-------------+
applyXslStyleSheet
""""""""""""""""""
@ -171,3 +244,60 @@ Applies the XSL stylesheet passed to header part, footer part and main part
$xslDomDocument = new \DOMDocument();
$xslDomDocument->load('/path/to/my/stylesheet.xsl');
$templateProcessor->applyXslStyleSheet($xslDomDocument);
setComplexValue
"""""""""""""""
Raplaces a ${macro} with the ComplexType passed.
See ``Sample_40_TemplateSetComplexValue.php`` for examples.
.. code-block:: php
$inline = new TextRun();
$inline->addText('by a red italic text', array('italic' => true, 'color' => 'red'));
$templateProcessor->setComplexValue('inline', $inline);
setComplexBlock
"""""""""""""""
Raplaces a ${macro} with the ComplexType passed.
See ``Sample_40_TemplateSetComplexValue.php`` for examples.
.. code-block:: php
$table = new Table(array('borderSize' => 12, 'borderColor' => 'green', 'width' => 6000, 'unit' => TblWidth::TWIP));
$table->addRow();
$table->addCell(150)->addText('Cell A1');
$table->addCell(150)->addText('Cell A2');
$table->addCell(150)->addText('Cell A3');
$table->addRow();
$table->addCell(150)->addText('Cell B1');
$table->addCell(150)->addText('Cell B2');
$table->addCell(150)->addText('Cell B3');
$templateProcessor->setComplexBlock('table', $table);
setChartValue
"""""""""""""
Replace a variable by a chart.
.. code-block:: php
$categories = array('A', 'B', 'C', 'D', 'E');
$series1 = array(1, 3, 2, 5, 4);
$chart = new Chart('doughnut', $categories, $series1);
$templateProcessor->setChartValue('myChart', $chart);
save
""""
Saves the loaded template within the current directory. Returns the file path.
.. code-block:: php
$filepath = $templateProcessor->save();
saveAs
""""""
Saves a copy of the loaded template in the indicated path.
.. code-block:: php
$pathToSave = 'path/to/save/file.ext';
$templateProcessor->saveAs($pathToSave);

View File

@ -5,6 +5,8 @@
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<rule ref="rulesets/naming.xml">
<exclude name="ShortVariable" />
<exclude name="ShortClassName" />
<exclude name="LongVariable" />
</rule>
<rule ref="rulesets/naming.xml/LongVariable">
@ -17,9 +19,9 @@
<rule ref="rulesets/design.xml/GotoStatement" />
<rule ref="rulesets/design.xml/DepthOfInheritance" />
<rule ref="rulesets/design.xml/CouplingBetweenObjects">
<!-- AbstractContainer needs more coupling (default: 13) -->
<!-- AbstractContainer and Html need more coupling (default: 13) -->
<properties>
<property name="minimum" value="20" />
<property name="maximum" value="25" />
</properties>
</rule>
<rule ref="rulesets/design.xml/NumberOfChildren">
@ -28,6 +30,5 @@
<property name="minimum" value="30" />
</properties>
</rule>
<rule ref="rulesets/unusedcode.xml" />
<rule ref="rulesets/controversial.xml" />
</ruleset>

View File

@ -9,20 +9,15 @@
stopOnFailure="false">
<testsuites>
<testsuite name="PhpWord Test Suite">
<directory>./tests/PhpWord</directory>
<directory>./tests/PhpWordTests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
<exclude>
<directory suffix=".php">./src/PhpWord/Shared/PCLZip</directory>
<directory suffix=".php">./src/PhpWordTests/Shared/PCLZip</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./build/coverage" />
<log type="coverage-clover" target="./build/logs/clover.xml" />
<log type="junit" target="./build/logs/logfile.xml"/>
</logging>
</phpunit>
</phpunit>

View File

@ -14,3 +14,7 @@ outputEscapingEnabled = false
defaultFontName = Arial
defaultFontSize = 10
[Paper]
defaultPaper = "A4"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
<?php
include_once 'Sample_Header.php';
// Template processor instance creation
@ -36,27 +37,51 @@ $templateProcessor->setValue('rowNumber#9', '9');
$templateProcessor->setValue('rowNumber#10', '10');
// Table with a spanned cell
$templateProcessor->cloneRow('userId', 3);
$values = [
[
'userId' => 1,
'userFirstName' => 'James',
'userName' => 'Taylor',
'userPhone' => '+1 428 889 773',
],
[
'userId' => 2,
'userFirstName' => 'Robert',
'userName' => 'Bell',
'userPhone' => '+1 428 889 774',
],
[
'userId' => 3,
'userFirstName' => 'Michael',
'userName' => 'Ray',
'userPhone' => '+1 428 889 775',
],
];
$templateProcessor->setValue('userId#1', '1');
$templateProcessor->setValue('userFirstName#1', 'James');
$templateProcessor->setValue('userName#1', 'Taylor');
$templateProcessor->setValue('userPhone#1', '+1 428 889 773');
$templateProcessor->cloneRowAndSetValues('userId', $values);
$templateProcessor->setValue('userId#2', '2');
$templateProcessor->setValue('userFirstName#2', 'Robert');
$templateProcessor->setValue('userName#2', 'Bell');
$templateProcessor->setValue('userPhone#2', '+1 428 889 774');
//this is equivalent to cloning and settings values with cloneRowAndSetValues
// $templateProcessor->cloneRow('userId', 3);
$templateProcessor->setValue('userId#3', '3');
$templateProcessor->setValue('userFirstName#3', 'Michael');
$templateProcessor->setValue('userName#3', 'Ray');
$templateProcessor->setValue('userPhone#3', '+1 428 889 775');
// $templateProcessor->setValue('userId#1', '1');
// $templateProcessor->setValue('userFirstName#1', 'James');
// $templateProcessor->setValue('userName#1', 'Taylor');
// $templateProcessor->setValue('userPhone#1', '+1 428 889 773');
// $templateProcessor->setValue('userId#2', '2');
// $templateProcessor->setValue('userFirstName#2', 'Robert');
// $templateProcessor->setValue('userName#2', 'Bell');
// $templateProcessor->setValue('userPhone#2', '+1 428 889 774');
// $templateProcessor->setValue('userId#3', '3');
// $templateProcessor->setValue('userFirstName#3', 'Michael');
// $templateProcessor->setValue('userName#3', 'Ray');
// $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'), 'results/Sample_07_TemplateCloneRow.docx');
echo getEndingNotes(['Word2007' => 'docx'], 'results/Sample_07_TemplateCloneRow.docx');
if (!CLI) {
include_once 'Sample_Footer.php';
}

View File

@ -1,15 +1,16 @@
<?php
include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->setDefaultParagraphStyle(
array(
'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::BOTH,
[
'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::BOTH,
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12),
'spacing' => 120,
)
'spacing' => 120,
]
);
// New section
@ -19,8 +20,8 @@ $section->addText(
'Below are the samples on how to control your paragraph '
. 'pagination. See "Line and Page Break" tab on paragraph properties '
. 'window to see the attribute set by these controls.',
array('bold' => true),
array('space' => array('before' => 360, 'after' => 480))
['bold' => true],
['space' => ['before' => 360, 'after' => 480]]
);
$section->addText(
@ -30,7 +31,7 @@ $section->addText(
. 'itself at the bottom of a page. Set this option to "false" if you want '
. 'to disable this automatic control.',
null,
array('widowControl' => false, 'indentation' => array('left' => 240, 'right' => 120))
['widowControl' => false, 'indentation' => ['left' => 240, 'right' => 120]]
);
$section->addText(
@ -39,7 +40,7 @@ $section->addText(
. 'breaks between paragraphs. Set this option to "true" if you do not want '
. 'your paragraph to be separated with the next paragraph.',
null,
array('keepNext' => true, 'indentation' => array('firstLine' => 240))
['keepNext' => true, 'indentation' => ['firstLine' => 240]]
);
$section->addText(
@ -48,7 +49,7 @@ $section->addText(
. 'break within a paragraph. Set this option to "true" if you do not want '
. 'all lines of your paragraph to be in the same page.',
null,
array('keepLines' => true, 'indentation' => array('left' => 240, 'hanging' => 240))
['keepLines' => true, 'indentation' => ['left' => 240, 'hanging' => 240]]
);
$section->addText('Keep scrolling. More below.');
@ -59,7 +60,7 @@ $section->addText(
. 'your paragraph into the next page. This option is most useful for '
. 'heading styles.',
null,
array('pageBreakBefore' => true)
['pageBreakBefore' => true]
);
// Save file

View File

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

View File

@ -1,13 +1,14 @@
<?php
include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$header = array('size' => 16, 'bold' => true);
$header = ['size' => 16, 'bold' => true];
//1.Use EastAisa FontStyle
$section->addText('中文楷体样式测试', array('name' => '楷体', 'size' => 16, 'color' => '1B2232', 'lang' => array('latin' => 'en-US', 'eastAsia' => 'zh-CN')));
$section->addText('中文楷体样式测试', ['name' => '楷体', 'size' => 16, 'color' => '1B2232', 'lang' => ['latin' => 'en-US', 'eastAsia' => 'zh-CN']]);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
<?php
use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Shared\Converter;
@ -15,7 +16,7 @@ $section->addImage('resources/_mars.jpg');
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->addImage('resources/_earth.jpg', ['width' => 210, 'height' => 210, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER]);
// Remote image
printSeparator($section);
@ -33,21 +34,21 @@ $section->addImage($fileContent);
//Wrapping style
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');
$wrappingStyles = ['inline', 'behind', 'infront', 'square', 'tight'];
foreach ($wrappingStyles as $wrappingStyle) {
$section->addText("Wrapping style {$wrappingStyle}");
$section->addImage(
'resources/_earth.jpg',
array(
'positioning' => 'relative',
'marginTop' => -1,
'marginLeft' => 1,
'width' => 80,
'height' => 80,
'wrappingStyle' => $wrappingStyle,
'wrapDistanceRight' => Converter::cmToPoint(1),
[
'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);
@ -57,16 +58,16 @@ foreach ($wrappingStyles as $wrappingStyle) {
$section->addText('Absolute positioning: see top right corner of page');
$section->addImage(
'resources/_mars.jpg',
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT,
[
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT,
'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE,
'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE,
'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15.5),
'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1.55),
)
'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE,
'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15.5),
'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1.55),
]
);
//Relative positioning
@ -75,21 +76,21 @@ $section->addText('Relative positioning: Horizontal position center relative to
$section->addText('Vertical position top relative to line');
$section->addImage(
'resources/_mars.jpg',
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE,
'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER,
[
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3),
'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE,
'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER,
'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_COLUMN,
'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP,
'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_LINE,
)
'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP,
'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_LINE,
]
);
function printSeparator(Section $section)
function printSeparator(Section $section): void
{
$section->addTextBreak();
$lineStyle = array('weight' => 0.2, 'width' => 150, 'height' => 0, 'align' => 'center');
$lineStyle = ['weight' => 0.2, 'width' => 150, 'height' => 0, 'align' => 'center'];
$section->addLine($lineStyle);
$section->addTextBreak(2);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
<?php
include_once 'Sample_Header.php';
// Template processor instance creation
@ -14,7 +15,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'), 'Sample_23_TemplateBlock');
echo getEndingNotes(['Word2007' => 'docx'], 'Sample_23_TemplateBlock');
if (!CLI) {
include_once 'Sample_Footer.php';
}

View File

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

View File

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

View File

@ -1,10 +1,11 @@
<?php
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'));
$phpWord->addParagraphStyle('Heading2', ['alignment' => 'center']);
$section = $phpWord->addSection();
$html = '<h1>Adding element via HTML</h1>';
@ -74,7 +75,7 @@ $html .= '<table align="center" style="width: 50%; border: 6px #0000FF double;">
</tr>
</thead>
<tbody>
<tr><td style="border-style: dotted;">1</td><td colspan="2">2</td></tr>
<tr><td style="border-style: dotted; border-color: #FF0000">1</td><td colspan="2">2</td></tr>
<tr><td>This is <b>bold</b> text</td><td></td><td>6</td></tr>
</tbody>
</table>';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
<?php
include_once 'Sample_Header.php';
use PhpOffice\PhpWord\Shared\Converter;
@ -8,23 +9,26 @@ echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Define styles
$phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240));
$phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240));
$phpWord->addTitleStyle(1, ['size' => 14, 'bold' => true], ['keepNext' => true, 'spaceBefore' => 240]);
$phpWord->addTitleStyle(2, ['size' => 14, 'bold' => true], ['keepNext' => true, 'spaceBefore' => 240]);
// 2D charts
$section = $phpWord->addSection();
$section->addTitle('2D charts', 1);
$section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous'));
$section = $phpWord->addSection(['colsNum' => 2, 'breakType' => 'continuous']);
$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);
$chartTypes = ['pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column'];
$twoSeries = ['bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column'];
$threeSeries = ['bar', 'line'];
$categories = ['A', 'B', 'C', 'D', 'E'];
$series1 = [1, 3, 2, 5, 4];
$series2 = [3, 1, 7, 2, 6];
$series3 = [8, 3, 2, 5, 4];
$showGridLines = false;
$showAxisLabels = false;
$showLegend = true;
$legendPosition = 't';
// r = right, l = left, t = top, b = bottom, tr = top right
foreach ($chartTypes as $chartType) {
$section->addTitle(ucfirst($chartType), 2);
@ -33,6 +37,8 @@ foreach ($chartTypes as $chartType) {
$chart->getStyle()->setShowGridX($showGridLines);
$chart->getStyle()->setShowGridY($showGridLines);
$chart->getStyle()->setShowAxisLabels($showAxisLabels);
$chart->getStyle()->setShowLegend($showLegend);
$chart->getStyle()->setLegendPosition($legendPosition);
if (in_array($chartType, $twoSeries)) {
$chart->addSeries($categories, $series2);
}
@ -43,20 +49,20 @@ foreach ($chartTypes as $chartType) {
}
// 3D charts
$section = $phpWord->addSection(array('breakType' => 'continuous'));
$section = $phpWord->addSection(['breakType' => 'continuous']);
$section->addTitle('3D charts', 1);
$section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous'));
$section = $phpWord->addSection(['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,
$chartTypes = ['pie', 'bar', 'column', 'line', 'area'];
$multiSeries = ['bar', 'column', 'line', 'area'];
$style = [
'width' => Converter::cmToEmu(5),
'height' => Converter::cmToEmu(4),
'3d' => true,
'showAxisLabels' => $showAxisLabels,
'showGridX' => $showGridLines,
'showGridY' => $showGridLines,
);
'showGridX' => $showGridLines,
'showGridY' => $showGridLines,
];
foreach ($chartTypes as $chartType) {
$section->addTitle(ucfirst($chartType), 2);
$chart = $section->addChart($chartType, $categories, $series1, $style);

View File

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

View File

@ -1,4 +1,5 @@
<?php
include_once 'Sample_Header.php';
// New Word document
@ -10,7 +11,7 @@ $section = $phpWord->addSection();
$textrun = $section->addTextRun();
$textrun->addText('Combobox: ');
$textrun->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'));
$textrun->addSDT('comboBox')->setListItems(['1' => 'Choice 1', '2' => 'Choice 2']);
$textrun = $section->addTextRun();
$textrun->addText('Date: ');
@ -24,7 +25,7 @@ $textrun->addSDT('date')->setValue('30.03.2017');
$textrun = $section->addTextRun();
$textrun->addText('Drop down list: ');
$textrun->addSDT('dropDownList')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2'))->setValue('Choice 1');
$textrun->addSDT('dropDownList')->setListItems(['1' => 'Choice 1', '2' => 'Choice 2'])->setValue('Choice 1');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,15 +3,15 @@ include_once 'Sample_Header.php';
use PhpOffice\PhpWord\Settings;
$requirements = array(
'php' => array('PHP 5.3.3', version_compare(PHP_VERSION, '5.3.3', '>=')),
'xml' => array('PHP extension XML', extension_loaded('xml')),
'temp' => array('Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())),
'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')),
'gd' => array('PHP extension GD (optional)', extension_loaded('gd')),
'xmlw' => array('PHP extension XMLWriter (optional)', extension_loaded('xmlwriter')),
'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')),
);
$requirements = [
'php' => ['PHP 7.1', version_compare(PHP_VERSION, '7.1', '>=')],
'xml' => ['PHP extension XML', extension_loaded('xml')],
'temp' => ['Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())],
'zip' => ['PHP extension ZipArchive (optional)', extension_loaded('zip')],
'gd' => ['PHP extension GD (optional)', extension_loaded('gd')],
'xmlw' => ['PHP extension XMLWriter (optional)', extension_loaded('xmlwriter')],
'xsl' => ['PHP extension XSL (optional)', extension_loaded('xsl')],
];
if (!CLI) {
?>
<div class="jumbotron">
@ -22,13 +22,13 @@ if (!CLI) {
<a class="btn btn-lg btn-primary" href="http://phpword.readthedocs.org/" role="button"><i class="fa fa-book fa-lg" title="Docs"></i> Read the Docs</a>
</p>
</div>
<?php
<?php
}
if (!CLI) {
echo '<h3>Requirement check:</h3>';
echo '<ul>';
foreach ($requirements as $key => $value) {
list($label, $result) = $value;
[$label, $result] = $value;
$status = $result ? 'passed' : 'failed';
echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>";
}
@ -37,7 +37,7 @@ if (!CLI) {
} else {
echo 'Requirement check:' . PHP_EOL;
foreach ($requirements as $key => $value) {
list($label, $result) = $value;
[$label, $result] = $value;
$label = strip_tags($label);
$status = $result ? '32m passed' : '31m failed';
echo "{$label} ... \033[{$status}\033[0m" . PHP_EOL;

Binary file not shown.

View File

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

View File

@ -11,14 +11,14 @@
* 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\Collection;
/**
* Bookmarks collection
* Bookmarks collection.
*
* @since 0.12.0
*/

View File

@ -11,14 +11,14 @@
* 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\Collection;
/**
* Charts collection
* Charts collection.
*
* @since 0.12.0
*/

View File

@ -11,14 +11,14 @@
* 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\Collection;
/**
* Comments collection
* Comments collection.
*
* @since 0.12.0
*/

View File

@ -11,14 +11,14 @@
* 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\Collection;
/**
* Endnotes collection
* Endnotes collection.
*
* @since 0.10.0
*/

View File

@ -11,14 +11,14 @@
* 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\Collection;
/**
* Footnotes collection
* Footnotes collection.
*
* @since 0.10.0
*/

View File

@ -11,14 +11,14 @@
* 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\Collection;
/**
* Titles collection
* Titles collection.
*
* @since 0.10.0
*/

View File

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

View File

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

View File

@ -11,7 +11,7 @@
* 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
*/

View File

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

View File

@ -11,14 +11,17 @@
* 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\Element;
use BadMethodCallException;
use ReflectionClass;
/**
* Container abstract class
* Container abstract class.
*
* @method Text addText(string $text, mixed $fStyle = null, mixed $pStyle = null)
* @method TextRun addTextRun(mixed $pStyle = null)
@ -31,7 +34,7 @@ namespace PhpOffice\PhpWord\Element;
* @method Footnote addFootnote(mixed $pStyle = null)
* @method Endnote addEndnote(mixed $pStyle = null)
* @method CheckBox addCheckBox(string $name, $text, mixed $fStyle = null, mixed $pStyle = null)
* @method Title addTitle(string $text, int $depth = 1)
* @method Title addTitle(mixed $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)
@ -41,10 +44,9 @@ namespace PhpOffice\PhpWord\Element;
* @method Field addField(string $type = null, array $properties = array(), array $options = array(), mixed $text = null)
* @method Line addLine(mixed $lineStyle = null)
* @method Shape addShape(string $type, mixed $style = null)
* @method Chart addChart(string $type, array $categories, array $values, array $style = null)
* @method Chart addChart(string $type, array $categories, array $values, array $style = null, $seriesName = null)
* @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
@ -52,21 +54,21 @@ namespace PhpOffice\PhpWord\Element;
abstract class AbstractContainer extends AbstractElement
{
/**
* Elements collection
* Elements collection.
*
* @var \PhpOffice\PhpWord\Element\AbstractElement[]
*/
protected $elements = array();
protected $elements = [];
/**
* Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange
* Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange.
*
* @var string
*/
protected $container;
/**
* Magic method to catch all 'addElement' variation
* Magic method to catch all 'addElement' variation.
*
* This removes addText, addTextRun, etc. When adding new element, we have to
* add the model in the class docblock with `@method`.
@ -75,18 +77,19 @@ abstract class AbstractContainer extends AbstractElement
*
* @param mixed $function
* @param mixed $args
*
* @return \PhpOffice\PhpWord\Element\AbstractElement
*/
public function __call($function, $args)
{
$elements = array(
$elements = [
'Text', 'TextRun', 'Bookmark', 'Link', 'PreserveText', 'TextBreak',
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'OLEObject',
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
'Chart', 'FormField', 'SDT', 'Comment',
);
$functions = array();
];
$functions = [];
foreach ($elements as $element) {
$functions['add' . strtolower($element)] = $element == 'Object' ? 'OLEObject' : $element;
}
@ -99,17 +102,18 @@ abstract class AbstractContainer extends AbstractElement
// Special case for TextBreak
// @todo Remove the `$count` parameter in 1.0.0 to make this element similiar to other elements?
if ($element == 'TextBreak') {
list($count, $fontStyle, $paragraphStyle) = array_pad($args, 3, null);
[$count, $fontStyle, $paragraphStyle] = array_pad($args, 3, null);
if ($count === null) {
$count = 1;
}
for ($i = 1; $i <= $count; $i++) {
for ($i = 1; $i <= $count; ++$i) {
$this->addElement($element, $fontStyle, $paragraphStyle);
}
} else {
// All other elements
array_unshift($args, $element); // Prepend element name to the beginning of args array
return call_user_func_array(array($this, 'addElement'), $args);
return call_user_func_array([$this, 'addElement'], $args);
}
}
@ -117,11 +121,12 @@ abstract class AbstractContainer extends AbstractElement
}
/**
* Add element
* Add element.
*
* Each element has different number of parameters passed
*
* @param string $elementName
*
* @return \PhpOffice\PhpWord\Element\AbstractElement
*/
protected function addElement($elementName)
@ -131,13 +136,13 @@ abstract class AbstractContainer extends AbstractElement
// Get arguments
$args = func_get_args();
$withoutP = in_array($this->container, array('TextRun', 'Footnote', 'Endnote', 'ListItemRun', 'Field'));
$withoutP = in_array($this->container, ['TextRun', 'Footnote', 'Endnote', 'ListItemRun', 'Field']);
if ($withoutP && ($elementName == 'Text' || $elementName == 'PreserveText')) {
$args[3] = null; // Remove paragraph style for texts in textrun
}
// Create element using reflection
$reflection = new \ReflectionClass($elementClass);
$reflection = new ReflectionClass($elementClass);
$elementArgs = $args;
array_shift($elementArgs); // Shift the $elementName off the beginning of array
@ -155,7 +160,7 @@ abstract class AbstractContainer extends AbstractElement
}
/**
* Get all elements
* Get all elements.
*
* @return \PhpOffice\PhpWord\Element\AbstractElement[]
*/
@ -165,10 +170,11 @@ abstract class AbstractContainer extends AbstractElement
}
/**
* Returns the element at the requested position
* Returns the element at the requested position.
*
* @param int $index
* @return \PhpOffice\PhpWord\Element\AbstractElement|null
*
* @return null|\PhpOffice\PhpWord\Element\AbstractElement
*/
public function getElement($index)
{
@ -180,11 +186,11 @@ abstract class AbstractContainer extends AbstractElement
}
/**
* Removes the element at requested index
* Removes the element at requested index.
*
* @param int|\PhpOffice\PhpWord\Element\AbstractElement $toRemove
*/
public function removeElement($toRemove)
public function removeElement($toRemove): void
{
if (is_int($toRemove) && array_key_exists($toRemove, $this->elements)) {
unset($this->elements[$toRemove]);
@ -200,7 +206,7 @@ abstract class AbstractContainer extends AbstractElement
}
/**
* Count elements
* Count elements.
*
* @return int
*/
@ -210,59 +216,58 @@ abstract class AbstractContainer extends AbstractElement
}
/**
* Check if a method is allowed for the current container
* Check if a method is allowed for the current container.
*
* @param string $method
*
* @throws \BadMethodCallException
* @return bool
*/
private function checkValidity($method)
{
$generalContainers = array(
$generalContainers = [
'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun', 'TrackChange',
);
];
$validContainers = array(
'Text' => $generalContainers,
'Bookmark' => $generalContainers,
'Link' => $generalContainers,
'TextBreak' => $generalContainers,
'Image' => $generalContainers,
'OLEObject' => $generalContainers,
'Field' => $generalContainers,
'Line' => $generalContainers,
'Shape' => $generalContainers,
'FormField' => $generalContainers,
'SDT' => $generalContainers,
'TrackChange' => $generalContainers,
'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', 'ListItemRun'),
'Endnote' => array('Section', 'TextRun', 'Cell'),
'PreserveText' => array('Section', 'Header', 'Footer', 'Cell'),
'Title' => array('Section', 'Cell'),
'TOC' => array('Section'),
'PageBreak' => array('Section'),
'Chart' => array('Section', 'Cell'),
);
$validContainers = [
'Text' => $generalContainers,
'Bookmark' => $generalContainers,
'Link' => $generalContainers,
'TextBreak' => $generalContainers,
'Image' => $generalContainers,
'OLEObject' => $generalContainers,
'Field' => $generalContainers,
'Line' => $generalContainers,
'Shape' => $generalContainers,
'FormField' => $generalContainers,
'SDT' => $generalContainers,
'TrackChange' => $generalContainers,
'TextRun' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox', 'TrackChange', 'ListItemRun'],
'ListItem' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox'],
'ListItemRun' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox'],
'Table' => ['Section', 'Header', 'Footer', 'Cell', 'TextBox'],
'CheckBox' => ['Section', 'Header', 'Footer', 'Cell', 'TextRun'],
'TextBox' => ['Section', 'Header', 'Footer', 'Cell'],
'Footnote' => ['Section', 'TextRun', 'Cell', 'ListItemRun'],
'Endnote' => ['Section', 'TextRun', 'Cell'],
'PreserveText' => ['Section', 'Header', 'Footer', 'Cell'],
'Title' => ['Section', 'Cell'],
'TOC' => ['Section'],
'PageBreak' => ['Section'],
'Chart' => ['Section', 'Cell'],
];
// Special condition, e.g. preservetext can only exists in cell when
// the cell is located in header or footer
$validSubcontainers = array(
'PreserveText' => array(array('Cell'), array('Header', 'Footer')),
'Footnote' => array(array('Cell', 'TextRun'), array('Section')),
'Endnote' => array(array('Cell', 'TextRun'), array('Section')),
);
$validSubcontainers = [
'PreserveText' => [['Cell'], ['Header', 'Footer', 'Section']],
'Footnote' => [['Cell', 'TextRun'], ['Section']],
'Endnote' => [['Cell', 'TextRun'], ['Section']],
];
// Check if a method is valid for current container
if (isset($validContainers[$method])) {
if (!in_array($this->container, $validContainers[$method])) {
throw new \BadMethodCallException("Cannot add {$method} in {$this->container}.");
throw new BadMethodCallException("Cannot add {$method} in {$this->container}.");
}
}
@ -273,43 +278,11 @@ abstract class AbstractContainer extends AbstractElement
$allowedDocParts = $rules[1];
foreach ($containers as $container) {
if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) {
throw new \BadMethodCallException("Cannot add {$method} in {$this->container}.");
throw new BadMethodCallException("Cannot add {$method} in {$this->container}.");
}
}
}
return true;
}
/**
* Create textrun element
*
* @deprecated 0.10.0
*
* @param mixed $paragraphStyle
*
* @return \PhpOffice\PhpWord\Element\TextRun
*
* @codeCoverageIgnore
*/
public function createTextRun($paragraphStyle = null)
{
return $this->addTextRun($paragraphStyle);
}
/**
* Create footnote element
*
* @deprecated 0.10.0
*
* @param mixed $paragraphStyle
*
* @return \PhpOffice\PhpWord\Element\Footnote
*
* @codeCoverageIgnore
*/
public function createFootnote($paragraphStyle = null)
{
return $this->addFootnote($paragraphStyle);
}
}

View File

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

View File

@ -11,45 +11,45 @@
* 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\Element;
use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Shared\Text as SharedText;
/**
* Bookmark element
* Bookmark element.
*/
class Bookmark extends AbstractElement
{
/**
* Bookmark Name
* Bookmark Name.
*
* @var string
*/
private $name;
/**
* Is part of collection
* Is part of collection.
*
* @var bool
*/
protected $collectionRelation = true;
/**
* Create a new Bookmark Element
* Create a new Bookmark Element.
*
* @param string $name
*/
public function __construct($name = '')
{
$this->name = CommonText::toUTF8($name);
$this->name = SharedText::toUTF8($name);
}
/**
* Get Bookmark name
* Get Bookmark name.
*
* @return string
*/

View File

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

View File

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

View File

@ -11,30 +11,30 @@
* 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\Element;
use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Shared\Text as SharedText;
/**
* Check box element
* Check box element.
*
* @since 0.10.0
*/
class CheckBox extends Text
{
/**
* Name content
* Name content.
*
* @var string
*/
private $name;
/**
* Create new instance
* Create new instance.
*
* @param string $name
* @param string $text
@ -48,20 +48,21 @@ class CheckBox extends Text
}
/**
* Set name content
* Set name content.
*
* @param string $name
*
* @return self
*/
public function setName($name)
{
$this->name = CommonText::toUTF8($name);
$this->name = SharedText::toUTF8($name);
return $this;
}
/**
* Get name content
* Get name content.
*
* @return string
*/

View File

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

View File

@ -11,14 +11,14 @@
* 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\Element;
/**
* Endnote element
* Endnote element.
*
* @since 0.10.0
*/
@ -30,9 +30,9 @@ class Endnote extends Footnote
protected $container = 'Endnote';
/**
* Create new instance
* Create new instance.
*
* @param string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
* @param array|\PhpOffice\PhpWord\Style\Paragraph|string $paragraphStyle
*/
public function __construct($paragraphStyle = null)
{

View File

@ -11,14 +11,17 @@
* 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\Element;
use InvalidArgumentException;
use PhpOffice\PhpWord\Style\Font;
/**
* Field element
* Field element.
*
* @since 0.11.0
* @see http://www.schemacentral.com/sc/ooxml/t-w_CT_SimpleField.html
@ -27,120 +30,154 @@ class Field extends AbstractElement
{
/**
* Field properties and options. Depending on type, a field can have different properties
* and options
* and options.
*
* @var array
*/
protected $fieldsArray = array(
'PAGE' => array(
'properties' => array(
'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
),
'options' => array('PreserveFormat'),
),
'NUMPAGES' => array(
'properties' => array(
'format' => array('Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText',
'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper', ),
'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%'),
),
'options' => array('PreserveFormat'),
),
'DATE' => array(
'properties' => array(
'dateformat' => array(
/* Generic formats */
protected $fieldsArray = [
'PAGE' => [
'properties' => [
'format' => ['Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'],
],
'options' => ['PreserveFormat'],
],
'NUMPAGES' => [
'properties' => [
'format' => ['Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText',
'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper', ],
'numformat' => ['0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%'],
],
'options' => ['PreserveFormat'],
],
'DATE' => [
'properties' => [
'dateformat' => [
// 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 */
// 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 */
// 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'),
),
'INDEX' => array(
'properties' => array(),
'options' => array('PreserveFormat'),
),
'STYLEREF' => array(
'properties' => array('StyleIdentifier' => ''),
'options' => array('PreserveFormat'),
),
);
],
],
'options' => ['PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat'],
],
'MACROBUTTON' => [
'properties' => ['macroname' => ''],
],
'XE' => [
'properties' => [],
'options' => ['Bold', 'Italic'],
],
'INDEX' => [
'properties' => [],
'options' => ['PreserveFormat'],
],
'STYLEREF' => [
'properties' => ['StyleIdentifier' => ''],
'options' => ['PreserveFormat'],
],
];
/**
* Field type
* Field type.
*
* @var string
*/
protected $type;
/**
* Field text
* Field text.
*
* @var TextRun|string
* @var string|TextRun
*/
protected $text;
/**
* Field properties
* Field properties.
*
* @var array
*/
protected $properties = array();
protected $properties = [];
/**
* Field options
* Field options.
*
* @var array
*/
protected $options = array();
protected $options = [];
/**
* Font style
* Font style.
*
* @var \PhpOffice\PhpWord\Style\Font
* @var \PhpOffice\PhpWord\Style\Font|string
*/
protected $fontStyle;
/**
* Create a new Field Element
* Set Font style.
*
* @param array|\PhpOffice\PhpWord\Style\Font|string $style
*
* @return \PhpOffice\PhpWord\Style\Font|string
*/
public function setFontStyle($style = null)
{
if ($style instanceof Font) {
$this->fontStyle = $style;
} elseif (is_array($style)) {
$this->fontStyle = new Font('text');
$this->fontStyle->setStyleByArray($style);
} elseif (null === $style) {
$this->fontStyle = null;
} else {
$this->fontStyle = $style;
}
return $this->fontStyle;
}
/**
* Get Font style.
*
* @return \PhpOffice\PhpWord\Style\Font|string
*/
public function getFontStyle()
{
return $this->fontStyle;
}
/**
* Create a new Field Element.
*
* @param string $type
* @param array $properties
* @param array $options
* @param TextRun|string|null $text
* @param null|string|TextRun $text
* @param array|\PhpOffice\PhpWord\Style\Font|string $fontStyle
*/
public function __construct($type = null, $properties = array(), $options = array(), $text = null)
public function __construct($type = null, $properties = [], $options = [], $text = null, $fontStyle = null)
{
$this->setType($type);
$this->setProperties($properties);
$this->setOptions($options);
$this->setText($text);
$this->setFontStyle($fontStyle);
}
/**
* Set Field type
* Set Field type.
*
* @param string $type
*
* @throws \InvalidArgumentException
* @return string
*/
public function setType($type = null)
@ -149,7 +186,7 @@ class Field extends AbstractElement
if (isset($this->fieldsArray[$type])) {
$this->type = $type;
} else {
throw new \InvalidArgumentException("Invalid type '$type'");
throw new InvalidArgumentException("Invalid type '$type'");
}
}
@ -157,7 +194,7 @@ class Field extends AbstractElement
}
/**
* Get Field type
* Get Field type.
*
* @return string
*/
@ -167,19 +204,18 @@ class Field extends AbstractElement
}
/**
* Set Field properties
* Set Field properties.
*
* @param array $properties
*
* @throws \InvalidArgumentException
* @return self
*/
public function setProperties($properties = array())
public function setProperties($properties = [])
{
if (is_array($properties)) {
foreach (array_keys($properties) as $propkey) {
if (!(isset($this->fieldsArray[$this->type]['properties'][$propkey]))) {
throw new \InvalidArgumentException("Invalid property '$propkey'");
throw new InvalidArgumentException("Invalid property '$propkey'");
}
}
$this->properties = array_merge($this->properties, $properties);
@ -189,7 +225,7 @@ class Field extends AbstractElement
}
/**
* Get Field properties
* Get Field properties.
*
* @return array
*/
@ -199,19 +235,18 @@ class Field extends AbstractElement
}
/**
* Set Field options
* Set Field options.
*
* @param array $options
*
* @throws \InvalidArgumentException
* @return self
*/
public function setOptions($options = array())
public function setOptions($options = [])
{
if (is_array($options)) {
foreach (array_keys($options) as $optionkey) {
if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey])) && substr($optionkey, 0, 1) !== '\\') {
throw new \InvalidArgumentException("Invalid option '$optionkey', possible values are " . implode(', ', $this->fieldsArray[$this->type]['options']));
throw new InvalidArgumentException("Invalid option '$optionkey', possible values are " . implode(', ', $this->fieldsArray[$this->type]['options']));
}
}
$this->options = array_merge($this->options, $options);
@ -221,7 +256,7 @@ class Field extends AbstractElement
}
/**
* Get Field properties
* Get Field properties.
*
* @return array
*/
@ -231,11 +266,10 @@ class Field extends AbstractElement
}
/**
* Set Field text
* Set Field text.
*
* @param string|TextRun $text
*
* @throws \InvalidArgumentException
* @return null|string|TextRun
*/
public function setText($text = null)
@ -244,7 +278,7 @@ class Field extends AbstractElement
if (is_string($text) || $text instanceof TextRun) {
$this->text = $text;
} else {
throw new \InvalidArgumentException('Invalid text');
throw new InvalidArgumentException('Invalid text');
}
}
@ -252,7 +286,7 @@ class Field extends AbstractElement
}
/**
* Get Field text
* Get Field text.
*
* @return string|TextRun
*/

View File

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

View File

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

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