Compare commits

...

1015 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
troosan
7b7d4e4936 release version 0.16.0 2018-12-30 01:35:03 +01:00
troosan
b375b8580f fix broken samples 2018-12-30 01:13:54 +01:00
troosan
54e7c6dd5a don't default styles to false
this allows us to for instance make part of a Heading not bold, which
would otherwise be the default.
2018-12-30 00:45:45 +01:00
troosan
1c35c4871a update develop badge 2018-12-30 00:41:58 +01:00
troosan
481f2c7310 fix code indenting 2018-12-29 23:30:23 +01:00
troosan
067c4f6809 update badges 2018-12-29 23:17:17 +01:00
troosan
3390c907dc fix scrutiniser warning 2018-12-29 23:16:56 +01:00
troosan
54b94be65a fix doc 2018-12-29 23:14:18 +01:00
troosan
23407c99dd Add unit tests 2018-12-29 22:03:01 +01:00
troosan
5057617de7 change regex instead of checking twice 2018-12-29 14:56:11 +01:00
Antonio Malatesta
7c8cfb7b8a Adding condition for document template saving using libreoffice
When  I save document template with libreoffice (in .docx format) the cloneRow with nested table doesn't work.
The problem is that the regular expression, that used for search if row is no longer part of the spanned row, was wrong: 
<w:vMerge w:val="continue" /> became <w:vMerge w:val="continue"/> without space at the closure tag.
Sorry for my English.
2018-12-29 14:50:30 +01:00
troosan
b2c627d57c Merge branch 'parsing_heading2' develop
Conflicts:
	src/PhpWord/Reader/Word2007/Styles.php
	tests/PhpWord/Reader/Word2007/StyleTest.php
2018-12-28 22:33:48 +01:00
troosan
9e5da1e025 update changelog 2018-12-28 22:26:30 +01:00
troosan
ccf291234e Avoid warning if variable is null 2018-12-28 20:32:10 +01:00
troosan
d8d697c848 added convertors with test 2018-12-28 18:04:36 +01:00
troosan
a4b532083b
Merge pull request #1162 from abcdmitry/patch-2
Break the references in foreach within TemplateProcessor
2018-12-27 22:22:20 +01:00
troosan
7790b6a6b0 Pass values to replace macros with in cloneBlock 2018-12-27 22:13:48 +01:00
troosan
01209ddbd1 improve template processor documentation 2018-12-27 21:05:56 +01:00
troosan
75620caf51 add parameter to keep backward compatibility + add test 2018-12-27 01:44:37 +01:00
troosan
1bcef04ddc Merge remote-tracking branch 'JPBetley/PHPWord/clone-block-variables' into rebase_pull_request 2018-12-27 01:29:51 +01:00
troosan
1717bd4978 add test for cloneBlock operation 2018-12-27 00:30:04 +01:00
troosan
0f963e40a7
Merge pull request #1536 from Samuel-BF/fix-RTF-numerals
For RTF writers, sizes should should never have decimals
2018-12-26 23:16:22 +01:00
troosan
bbe517aa60
Merge pull request #1541 from morrisdj/develop
Add "Plain Text" type to SDT (Structured Document Tags)
2018-12-26 23:16:06 +01:00
troosan
254d300ea7
Merge pull request #1511 from carusogabriel/ternary-expressions
Remove unnecessary ternary expressions
2018-12-26 23:15:49 +01:00
troosan
dcf637df5a update changelog 2018-12-26 22:53:49 +01:00
troosan
d84da93a36 Add test and fix warnings 2018-12-26 22:50:19 +01:00
troosan
8ffaa1c8b7 add test to cover get TemplateProcessor::getVariables 2018-12-26 22:27:17 +01:00
Daniel Morris
5e2374be4a Merge remote-tracking branch 'upstream/develop' into develop 2018-12-26 21:49:41 +02:00
Daniel Morris
a5ec49d99d Add plain text SDT type 2018-12-26 21:45:32 +02:00
troosan
575c5531b8 replace self with static 2018-12-26 20:07:53 +01:00
troosan
2a088fb45b Update changelog 2018-12-26 20:07:32 +01:00
troosan
6cf10b4562
Merge pull request #1161 from abcdmitry/patch-1
Get rid of duplicated code in TemplateProcessor
call static methods with static:: instead of self::
2018-12-26 20:04:18 +01:00
troosan
c9b19cf65b Merge remote-tracking branch 'upstream/master' into rebase_pull_request 2018-12-26 19:54:41 +01:00
troosan
10b106ce05
Update CHANGELOG.md 2018-12-26 17:20:15 +01:00
troosan
56ca30ab95
Merge pull request #1539 from GautierDele/develop
Update documentation on usage of ListItemRun
2018-12-26 14:35:42 +01:00
Maxim
d5da80b56e Support adding images in Templates (#1170)
* setImageValue() + fix adding files via ZipArchive
* fix phpdoc variable name
* Changed logic that determines extension image file extension for document to depend on MIME type. This same logic is used in Element/Image.php
* support <w:t> tags with arguments
* allow setup size of image into template variable
* support of 'ratio' replace attribute + documentation
2018-12-26 14:35:21 +01:00
Gautier
0b99f8f3e2 docs: ListItemRun 2018-12-26 11:23:43 +01:00
troosan
e6496bf411
Merge pull request #1537 from isometriks/patch-1
[WIP] Still add text if link missing
2018-12-23 21:11:30 +01:00
Craig Blanchette
b1661af71a
Still add text if link missing
If link target doesn't exist, still add the text anyway.
2018-12-19 15:17:42 -05:00
Samuel BF
c0f8cae55c Fixing RTF writers : numbers should be printed as integers and not float.
This is specified in the spec, for example here :
http://www.biblioscape.com/rtf15_spec.htm#Heading2
« The delimiter marks the end of an RTF control word, and can be one of the following : [...]
* A digit or a hyphen (-), which indicates that a numeric parameter follows. The subsequent digital sequence is then delimited by a space or any character other than a letter or a digit. »
2018-12-18 15:04:25 +01:00
troosan
0db21ae115
Merge pull request #1272 from nicoder/add-getVariableCount-method
Add getVariableCount method in TemplateProcessor
2018-12-11 21:56:14 +01:00
troosan
b188ab94e1
Merge branch 'develop' into add-getVariableCount-method 2018-12-11 21:31:18 +01:00
troosan
8f85424fb7 update changelog 2018-12-11 21:30:18 +01:00
Nathan Dench
cf3132acac Add ability to pass a Style object to a Section element (#1416)
* Add ability to pass a Style object to a Section
* Fix typo
* update changelog
2018-12-08 23:35:32 +01:00
Alex Morozov
c2b54cc343 add support for hidden text (#1527)
* added hidden text word 2007
* update changelog
* update documentation
* added unit test
* docx reader
* html reader/writer
* odt writer
* updated samples
2018-12-08 23:21:59 +01:00
Yurii.sio2
260bb75fc2 Fix TemplateProcessor :: fixBrokenMacros; (#1502)
* Fix TemplateProcessor :: fixBrokenMacros;
* add unit test for fixBrokenMacros
2018-12-07 23:22:04 +01:00
troosan
af5a271e9e
Line spacing is wrong when using "exact" line spacing rule (#1509)
* Only add 240 twips when in auto lineRule
* don't add 1 line when using EXACT line spacing rule
* fix style & scrutinizer warning
2018-12-03 16:09:20 +01:00
troosan
c15d4d155d
Merge pull request #1521 from bulbaka/patch-1
Update Language.php
2018-12-03 16:08:03 +01:00
Eugene Bulbaka
7930f5d136
Update Language.php
Added Language constants and values for Ukrainian (lines 71, 72):
const UK_UA = 'uk-UA';
const UK_UA_ID = 1058;
2018-12-03 16:04:19 +02:00
troosan
7b3b723646
Merge pull request #1430 from nicoder/patch-4
allow to override TemplateProcessor#ensureUtf8Encoded
2018-12-03 01:01:51 +01:00
troosan
c177c55d07
Merge pull request #1433 from Tom-Magill/develop
Add feature to set Chart Title and Legend visibility
2018-12-03 00:58:54 +01:00
troosan
9f684c745e update changelog 2018-12-02 23:54:40 +01:00
troosan
0c4bd1d02f update documentation 2018-12-02 23:54:32 +01:00
troosan
5b688d50d8 fix formatting 2018-12-02 23:54:25 +01:00
troosan
31968fa814 Merge branch 'develop' of https://github.com/Tom-Magill/PHPWord into develop_upstream 2018-12-02 23:38:08 +01:00
troosan
fb60865b8d test build php 7.3 2018-12-02 22:09:24 +01:00
troosan
a44aee8c34 fix some sonar warnings 2018-12-01 21:13:11 +01:00
troosan
6a7594630c add sonar config files 2018-12-01 21:12:41 +01:00
troosan
d9165f00fa
Merge pull request #1513 from carusogabriel/phpunit
Use dedicated PHPUnit assertions
2018-11-30 22:58:01 +01:00
troosan
9dd5e0c27d
Merge pull request #1441 from aarangara/add_html_table_layout
Adding table layout to the generated HTML
2018-11-29 17:39:31 +01:00
troosan
f472bfbc75
Merge branch 'develop' into add_html_table_layout 2018-11-28 22:58:29 +01:00
troosan
b50de97a41 support auto table layout too 2018-11-28 22:54:57 +01:00
Christopher ARZUR
32fb85fc8e Added PHP 7.3 support for travis (#1495)
* Added PHP 7.3 support for travis
* mark php 7.3 as failable
2018-11-28 22:06:32 +01:00
troosan
7aef21faca add test for parsing HTML containing entities 2018-11-28 22:03:43 +01:00
troosan
78ffbff0c1
Merge pull request #1498 from Garrcomm/fix-sharepoint
Fix loading of Sharepoint document
2018-11-25 01:40:12 +01:00
troosan
a7bfc8da51
Merge pull request #1485 from Timanx/develop
Fix parsing of Office 365 documents
2018-11-25 01:38:48 +01:00
troosan
d0bcfea4a4
Merge branch 'develop' into fix-sharepoint 2018-11-22 23:07:01 +01:00
troosan
a2a70736ad update changelog 2018-11-22 23:05:43 +01:00
Christopher ARZUR
5ccf985f9a Added PHP 7.3 support for travis (#1495)
* Added PHP 7.3 support for travis
* mark php 7.3 as failable
2018-11-22 23:04:31 +01:00
troosan
c12f98f69a fix check style warning 2018-11-20 22:40:54 +01:00
troosan
1c20a4ed22 update changelog 2018-11-20 21:22:50 +01:00
troosan
79a7d5fe0e Merge remote-tracking branch 'upstream/develop' into rebase_pull_request 2018-11-20 21:17:51 +01:00
troosan
55da063ed9 Merge remote-tracking branch 'upstream/develop' into rebase_pull_request 2018-11-20 21:15:26 +01:00
troosan
586f45efea
Merge pull request #1493 from Patrick64/develop
RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals
2018-11-20 21:06:29 +01:00
troosan
718f84c8f6 Merge remote-tracking branch 'Patrick64/PHPWord/develop' into round_page_size_for_rtf 2018-11-20 20:00:26 +01:00
troosan
b5865b2fc2 update changelog 2018-11-20 19:59:30 +01:00
Ralph02
d9d79c0666 RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals 2018-11-20 19:57:35 +01:00
troosan
1a03a6cf58
Merge pull request #1512 from carusogabriel/patch-1
Fix typo in the PR template
2018-11-19 09:08:54 +01:00
troosan
25348c6e49
Merge pull request #1504 from gimler/patch-1
[Doc] add/align possible values from class constant
2018-11-19 09:08:28 +01:00
Gabriel Caruso
663fb036d0
Use dedicated PHPUnit assertions 2018-11-19 01:36:23 -02:00
Gabriel Caruso
9b174e52c1
Fix typo in the PR template 2018-11-19 01:35:03 -02:00
Gabriel Caruso
3cf0770376
Remove unnecessary ternary expressions 2018-11-19 01:32:28 -02:00
troosan
49eb9d1f17
Fix non auto line spacing (#1508)
* Only add 240 twips when in auto lineRule
2018-11-17 15:03:29 +01:00
Christopher ARZUR
ea6edf95cc Added PHP 7.3 support for travis (#1495)
* Added PHP 7.3 support for travis
* mark php 7.3 as failable
2018-11-17 00:35:57 +01:00
troosan
925e9e0919
remove trailing spaces 2018-11-16 23:33:38 +01:00
troosan
c51b6febc0
rename variable to comply with rules 2018-11-16 23:00:23 +01:00
troosan
9f28ece4e9
Fix path to test document 2018-11-16 22:40:37 +01:00
Gordon Franke
768a070715
add/align possible values from class constant 2018-11-12 08:02:15 +01:00
Stefan Thoolen
54eb6e6f2c Fix for undefined index
PHP Notice:  Undefined index: document in /home/stefan/Projects/garrcomm/PHPWord/src/PhpWord/Reader/Word2007.php on line 65
PHP Warning:  Invalid argument supplied for foreach() in /home/stefan/Projects/garrcomm/PHPWord/src/PhpWord/Reader/Word2007.php on line 65
2018-11-06 14:24:56 +01:00
Ralph02
28505b0b77 RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals 2018-10-25 11:23:53 +01:00
Martin Hanzl
e19de8e8a4 #1253 - add explanatory comment 2018-10-11 11:28:44 +02:00
Martin Hanzl
7eb19c8f76 add test case for issue #1253 2018-10-11 09:40:12 +02:00
Martin Hanzl
7f55816eba detect actual filename of document xml (prevent mismatching document22.xml as in #1253) 2018-10-11 08:55:38 +02:00
troosan
18760620b3
Merge pull request #1445 from FCG-Group/writer_fixes_valign_watermark
writer / word2007 / support valign and watermark without paragraph
2018-10-03 23:28:05 +02:00
troosan
8a20678a7a
Merge pull request #1455 from vblinden/feature-dutch-language
Added Dutch (nl-NL)
2018-10-03 23:17:32 +02:00
troosan
9d65414684
Merge pull request #1476 from kisabelle/patch-1
Add documentation for enabling evenAndOddHeaders
2018-10-03 23:15:31 +02:00
kisabelle
45ee8b7faf
Add documentation for enabling evenAndOddHeaders 2018-09-21 11:53:16 -07:00
vblinden
d8c0441975 Fix indenting 2018-09-03 13:32:00 +02:00
vblinden
683d91990f
Added Dutch (nl-NL) 2018-09-03 12:30:05 +02:00
Maxim Bulygin
677e3f6a19 writer / word2007 / support valign and watermark withouth paragraph 2018-07-31 18:25:29 +03:00
Abubakkar Rangara
4b9ae18d5a Adding table layout to the generated HTML - fixed php-cs-fixer error 2018-07-24 14:23:23 +01:00
Abubakkar Rangara
e61c40e71d Adding table layout to the generated HTML if element has layout style. This is useful when using creating PDF from PHPWord (e.g. using dompdf), otherwise the PDF does not contain any layout for table. 2018-07-24 13:59:16 +01:00
troosan
aa49536e3e
Merge branch 'develop' into add-getVariableCount-method 2018-07-21 14:48:24 +02:00
troosan
2bfd82e229
Merge pull request #1439 from PHPOffice/master
Merge pull request #1429 from PHPOffice/develop [ci skip]
2018-07-21 14:31:53 +02:00
troosan
d09da0b6f2
Update CHANGELOG.md 2018-07-19 02:01:40 +02:00
troosan
18c26f9218
Merge pull request #1436 from begnini/fixing_title
HTML Title Writer loses text when Title contains a TextRun instead a string.
2018-07-19 02:00:36 +02:00
troosan
f376f207b8
Merge pull request #1269 from nicoder/improve-cloneBlock-regex
Fix regex in `cloneBlock` function
2018-07-19 01:43:37 +02:00
troosan
1951db58c1 update changelog 2018-07-19 01:16:25 +02:00
troosan
e07c6559a9 adapt test 2018-07-19 00:52:22 +02:00
Humberto Pereira
8c62cea580 Fix Writer losing text when Title contains a TextRun instead a string. 2018-07-17 21:10:53 -04:00
Humberto Pereira
f5e3807654 Improving Style Parsing - handling Heading style 2018-07-17 19:35:31 -04:00
Tom-Magill
139242612d
Update Chart.php 2018-07-17 14:11:55 +01:00
Tom-Magill
0c3eb4bafc
Update Chart.php 2018-07-17 14:10:02 +01:00
troosan
affccc7937 Merge branch 'improve-cloneBlock-regex' of https://github.com/nicoder/PHPWord into fix_clone_block 2018-07-17 08:03:35 +02:00
Nicolas Dermine
198165ce59
allow to override TemplateProcessor#ensureUtf8Encoded
the method is `protected`,
but since it is called with `self` instead of `static`
it does not allow for subclasses to override it
2018-07-16 19:49:30 +02:00
troosan
dfa2f36cad
Merge pull request #1429 from PHPOffice/develop
Merge 0.15 to master
2018-07-14 18:59:43 +02:00
troosan
4c9e75088a alias for develop branch
[ci skip]
2018-07-14 18:36:29 +02:00
troosan
fe454dbaf3
Merge pull request #1428 from troosan/parse_short_lang_code
Allow passing short lang code
2018-07-14 18:11:50 +02:00
troosan
27946cad30
Merge pull request #1413 from jgpATs2w/develop
allows decimal numbers in line-height style
2018-07-14 17:53:14 +02:00
troosan
8fa1d4f224 run checks with php 7.0 2018-07-14 17:47:34 +02:00
troosan
87498e43e1 Allow passing short lang code 2018-07-14 17:21:30 +02:00
troosan
54155bf5a9
Update Sample_30_ReadHTML.html 2018-07-14 17:16:24 +02:00
troosan
af4f834149
Merge branch 'develop' into develop 2018-07-14 17:12:45 +02:00
troosan
9ee99d2c45
Merge pull request #1324 from troosan/parse_drawings
Support reading of w:drawing for documents produced by word 2011+
2018-07-14 10:23:44 +02:00
troosan
de83da2bbf
Merge branch 'develop' into parse_drawings 2018-07-14 03:30:11 +02:00
troosan
6475812e82 fix documentation 2018-07-14 03:28:09 +02:00
troosan
32907215ed fix phpstan issues 2018-07-14 02:54:17 +02:00
troosan
adc1428607 use PasswordEncoder from phpoffice/common instead 2018-07-14 02:51:08 +02:00
troosan
e028aef6d2 update to final phpoffice/common version 2018-07-14 02:26:47 +02:00
smaug1985
3906be19ee Added Support for Indentation & Tabs on RTF Writer. (#1405)
* Added Support for Indentation  & Tabs on RTF Writer.
* add decimal tab writer + tests
* Update CHANGELOG.md
2018-07-14 02:13:45 +02:00
troosan
cdc18522a2
Merge pull request #1427 from troosan/libxml_disable_entity_loader
disable entity loader before parsing XML to avoid XXE injection
2018-07-14 01:01:49 +02:00
troosan
4c4c6f43ca remove options not compatible with latest phpunit version 2018-07-14 00:59:54 +02:00
troosan
96b21badaf update changelog 2018-07-14 00:54:41 +02:00
troosan
536a1b89d7 disable entity loader 2018-07-14 00:50:01 +02:00
Jonathan Jefferies
94cf1aecb6 Require ext-zip for development (#1419)
* Require `ext-zip` for development
* Require `ext-gd` for development
2018-07-14 00:12:34 +02:00
Javier Garcia
c93880b125 clean sample resource 2018-06-13 18:14:13 +02:00
Javier Garcia
2593e9e200 Merge branch 'develop' of github.com:jgpATs2w/PHPWord into develop 2018-06-13 17:57:55 +02:00
Javier Garcia
fe647f6e55 fix when style line-height size comes in decimal number 2018-06-13 17:41:17 +02:00
troosan
4fa945561f
Merge pull request #1352 from troosan/column_width_for_odt
write column width in ODT writer
2018-06-03 23:09:33 +02:00
troosan
5b9719071e remove unused imports 2018-06-03 22:36:30 +02:00
troosan
682b88bd28 Merge commit '4e37afa15da62cdd695a18db2a40d86615086e9d' into
column_width_for_odt

# Conflicts:
#	CHANGELOG.md
2018-06-03 21:24:12 +02:00
troosan
da43a880e3 Address scrutinizer issues 2018-06-03 00:32:21 +02:00
troosan
d9ddc162a3 write column width in ODT writer 2018-06-03 00:32:20 +02:00
troosan
844a7c95ba
Merge pull request #1391 from omarpiani/develop
Added Italian to supported languages
2018-06-01 09:13:40 +02:00
troosan
4e37afa15d
Update CHANGELOG.md 2018-05-31 20:10:49 +02:00
troosan
0bd7c0b301
Add constants for Italian 2018-05-31 19:50:43 +02:00
Omar Piani
aa27109101
Update Language.php 2018-05-31 11:43:20 +02:00
javier
1a06173e1b Add parsing of html image in base64 format (#1382)
* increased test coverage of new lines
* added exception control to file_get_contents error
* update changelog
2018-05-31 01:28:14 +02:00
troosan
e76487172b update changelog 2018-05-31 00:31:41 +02:00
troosan
b2cafffffc Merge remote-tracking branch 'upstream/develop' into develop_upstream 2018-05-31 00:25:31 +02:00
Edvin Hultberg
82f3a2ab44 Update documentation for Style::add*Style methods (#1383)
* Update documentation for Style::add*Style methods
* remove phpDocumentor, simplify dependencies
2018-05-31 00:21:08 +02:00
troosan
c22f7eab5e add check on opened file 2018-05-27 21:27:45 +02:00
troosan
da604a80c4 use annotation instead 2018-05-27 20:53:42 +02:00
troosan
e02c5f74e6 Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into develop_upstream 2018-05-27 20:39:36 +02:00
troosan
0c9626cedd add .gitattributes 2018-05-27 20:38:25 +02:00
Javier Garcia
65a594d271 cs-fixer fixes 2018-05-25 09:29:58 +02:00
Javier Garcia
a89e4c93a7 added exception control to file_get_contents error 2018-05-25 08:01:17 +02: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
Javier Garcia
46b7bea097 increased test coverage of new lines 2018-05-24 07:19:45 +02:00
troosan
c5d0f71963
Merge pull request #1380 from WouterSioen/fix-get-ending-notes-calls
Fix calls to the getEndingNotes method in the samples
2018-05-23 22:52:17 +02:00
Javier Garcia
a228811a61 fixes 2018-05-23 18:48:28 +02:00
Javier Garcia
d54cc6efee fix lint 2018-05-23 18:35:12 +02:00
Javier Garcia
58c6c52ee9 merged with local version 2018-05-23 18:22:54 +02:00
woutersioen
90d4d30dd3 Fix calls to the getEndingNotes method in the samples
This call requires both an array of writes and the filename, which was
missing in both method calls.
2018-05-23 09:18:24 +02:00
troosan
e6501eb9ff
Update coverage badge
[skip ci]
[skip Scrutinizer]
2018-05-20 23:45:03 +02:00
troosan
cdb3633e37
Merge pull request #1360 from adfinis-forks/drop-gh-pages
Drop GitHub pages, switch to coveralls
2018-05-20 22:11:19 +02:00
troosan
0b27bb927d update changelog
[ci skip]
2018-05-20 22:08:53 +02:00
troosan
254064150d disable external code coverage 2018-05-20 20:59:34 +02:00
troosan
2480103b49 run coveralls when running build with code coverage 2018-05-20 17:13:04 +02:00
troosan
7f46d951eb Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into develop_upstream 2018-05-20 14:40:15 +02:00
troosan
453ddf078b Do not try to read document protection if not present 2018-05-20 14:37:59 +02:00
Christian Zosel
e47ce1b4fc Coveralls integration 2018-05-19 12:56:44 +02:00
JAEK-S
65b0f062ad New features when creating charts (#1332)
* add stacked bar and column charts
* add chart colors feature
* adding preliminary chart axis title functionality to XMLwriter
* added percent_stacked to available types array
* Make tick mark and tick label positions configurable
* scrutinizer fixes
* update changelog
2018-05-11 22:50:19 +02:00
Christian Zosel
96a47ec0ae Drop GitHub pages
First step to fix #1355
2018-04-26 08:42:55 +02:00
troosan
94be56b0ec fix parsing of link style 2018-04-25 23:57:07 +02:00
troosan
4d9e9bc81b
Merge branch 'develop' into column_width_for_odt 2018-04-25 22:39:38 +02:00
troosan
84fa44090f
Merge pull request #1343 from meteocontrol/feature-add-table-indent-option
Add support for table indent
2018-04-25 22:37:16 +02:00
troosan
5ec2c8560e
do not push code coverage after build of develop branch
[ci skip]
2018-04-25 22:33:48 +02:00
troosan
b147919a64 write column width in ODT writer 2018-04-18 22:34:53 +02:00
troosan
c52c96d657 add support for STYLEREF field 2018-04-17 07:34:57 +02:00
troosan
85e1e5c280
fix warning 2018-04-14 23:21:02 +02:00
troosan
b394247740
Merge branch 'develop' into feature-add-table-indent-option 2018-04-14 22:46:09 +02:00
troosan
dd27f668e0 add line height test
[ci skip]
2018-04-14 22:42:58 +02:00
troosan
9bc85347ef fix code formatting 2018-04-14 21:15:36 +02:00
troosan
6ba2df474f
Merge pull request #1336 from lalop/addhtpl-bookmark
support internal link in addHtml method
2018-04-13 22:40:09 +02:00
troosan
3380aa8b19
Merge pull request #1339 from meteocontrol/feature-wrong-unit-in-image-doc
Wrong unit in image style documentation
2018-04-13 22:37:19 +02:00
troosan
57ededeabf
Merge pull request #1338 from pcworld/image-security-doc
Improve security-related documentation of addImage and addHtml
2018-04-13 22:36:18 +02:00
troosan
9989e4e387
Merge pull request #1341 from Trainmaster/fix-add-missing-param-annotation
Add missing param annotation
2018-04-13 22:35:25 +02:00
Frank Liepert
833cf07c1a Consistently format "pt" unit 2018-04-12 16:58:48 +02:00
Frank Liepert
853fcec1b6 Fix documented unit for image height/width 2018-04-12 16:58:48 +02:00
Frank Liepert
081c6722f6 Add support for table indent 2018-04-11 10:06:58 +02:00
Frank Liepert
e885b371bc Add missing param annotation 2018-04-10 20:30:04 +02:00
pcworld
6253adaba1 Warn about parsing user-generated HTML 2018-04-09 02:48:49 +02:00
pcworld
a7981717b3 addImage docs: Warn about user-generated strings 2018-04-09 02:45:50 +02:00
Sam
ca82e19bba support internal link in addHtml method 2018-04-07 11:24:52 +02:00
troosan
67b18c32e7
fix
[ci skip]
2018-04-02 14:50:31 +02:00
troosan
ed24140e2f
update samples instructions
[ci skip]
2018-04-02 14:47:18 +02: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
troosan
566e625b85 merge/add test/cleanup 2018-03-25 22:46:50 +02:00
gthomas2
9b722a5b0c Added missing namespaces 2018-03-23 21:29:41 +01:00
gthomas2
34bda10536 Fix images added in word 2011 2018-03-23 21:28:53 +01:00
troosan
400ee57bee fix 2018-03-22 22:47:27 +01:00
troosan
ade497d9d7 update changelog and doc 2018-03-21 22:19:56 +01:00
troosan
c08f2718af check style fixes 2018-03-21 21:58:41 +01:00
troosan
45e2e92af7 fix graph data 2018-03-21 21:50:41 +01:00
troosan
a8d1775eb1 Merge remote-tracking branch 'FrankMeyer/develop' into develop 2018-03-21 06:51:22 +01:00
troosan
2c5970a388 php 5.3 compatibility 2018-03-20 23:42:01 +01:00
Tim Jarrett
d8387c1aba Escape incoming invalid XML characters using htmlspecialchars(). 2018-03-20 22:47:15 +01:00
troosan
d8caa0b572
Merge pull request #1292 from mattbolt/develop
Fix colspan and rowspan for tables in HTML Writer
2018-03-20 22:22:19 +01:00
troosan
d7fc1a5f7b
Merge branch 'develop' into develop 2018-03-20 21:49:36 +01:00
troosan
296706aa03 add unit tests 2018-03-20 21:35:06 +01:00
troosan
992d842552 fix 2018-03-19 23:07:35 +01:00
troosan
f73beaa26a reset static collections at instantiation 2018-03-19 23:06:00 +01:00
troosan
16a9ded2c9 add exact line spacing test 2018-03-19 22:50:55 +01:00
troosan
de01e86d41 parse fixed line space 2018-03-19 22:50:54 +01:00
troosan
97d60dd985 tranlate percentage to rate 2018-03-19 22:50:54 +01:00
troosan
fe3f383621
Merge pull request #1316 from troosan/html_css_parse
add parsing of line-height and text-indent
2018-03-19 07:58:52 +01:00
troosan
de2e05bc11 update changelog
[ci skip]
2018-03-19 06:41:46 +01:00
troosan
997e21433c add parsing of line-height and text-indent 2018-03-18 22:32:55 +01:00
troosan
4c846426ce format & changelog 2018-03-18 20:53:05 +01:00
troosan
fb1e2e41cc Merge branch 'ComputerTinker-AddFieldDateFormats' of
https://github.com/ComputerTinker/PHPWord into
ComputerTinker-ComputerTinker-AddFieldDateFormats

# Conflicts:
#	src/PhpWord/Element/Field.php
2018-03-18 20:44:05 +01:00
troosan
9ffce350f5
Merge pull request #1299 from zobo/word2007_read_tabs
Add support for reading <w:tab/> element in runs.
2018-03-18 17:54:47 +01:00
troosan
bb70eb0b4c fix docx parsing 2018-03-18 12:37:39 +01:00
troosan
17680f7aec
Merge branch 'develop' into word2007_read_tabs 2018-03-11 22:37:05 +01:00
troosan
6b48451ebc
Merge pull request #1310 from troosan/add_image_wrap_distance
add text wrapping distance
2018-03-11 20:42:40 +01:00
troosan
a0111be6ae update changelog and doc 2018-03-11 15:02:24 +01:00
troosan
e29a3e7c10 add text wrapping distance 2018-03-11 13:27:35 +01:00
troosan
8bafe0000f
Merge pull request #1307 from franciscosens/add-suport-pt-br 2018-03-10 08:48:30 +01:00
troosan
77f2b16bc1 update copyright to 2018 2018-03-08 23:52:25 +01:00
Henri MEDOT
f9a05547f7 Added support for Floating Table Positioning (tblpPr) (#639)
Added support for Floating Table Positioning (tblpPr)
2018-03-08 23:46:22 +01:00
Francisco Lucas Sens
eb6900969f Added new constant to Brazilian portuguese language 2018-03-08 16:15:31 -03:00
troosan
9affbf4ecf
Merge pull request #1306 from Trainmaster/feature-make-composer-scripts-compatible-with-windows
Make Composer scripts compatible with Windows
2018-03-07 21:19:56 +01:00
Frank Liepert
d8f4a28b94 Make Composer scripts compatible with Windows
Windows does not like the "./" syntax
2018-03-07 20:05:40 +01:00
Frank Liepert
9ffbd98cc6 Add missing tests 2018-03-07 07:01:54 +01:00
Frank Liepert
edc3aa3cce Improve assertions 2018-03-07 07:01:54 +01:00
Frank Liepert
f41c542ba0 Enforce valid value for on/off type 2018-03-07 07:01:54 +01:00
Frank Liepert
6a6497956d Allow to set "autoHyphenation" setting (#1282)
* Allow to set "autoHyphenation" for document
* Allow to set "consecutiveHyphenLimit" for document
* Allow to set "hyphenationZone" for document
* Allow to set "doNotHyphenateCaps" for document
* Allow to set "suppressAutoHyphens" for paragraph
* randomize the tempDir more
* Word2007 parsing title formatting (#1297)
* Improve Title parsing
- Title should be able to contain TextRun
- Style 'Title' should be treated the same with as Heading
- Add tests for Heading/Title reader
* update the documentation and the changelog
* PHP 7.2 build should not fail anymore
* fix parsing of footnotes and endnotes
* add method to remove an element from a section
* add method to allow sorting of sections
2018-03-06 22:19:39 +01:00
troosan
250fbd49b1
Added support for Vertically Raised or Lowered Text (w:position) (#1294)
* Added support for Vertically Raised or Lowered Text (w:position). Note that only docx writing is implemented for now.
* Add tests + changelog
* add reader + tests + doc
2018-03-06 06:35:43 +01:00
troosan
30b224b3d0
Word2007 parsing title formatting (#1297)
* Improve Title parsing
- Title should be able to contain TextRun
- Style 'Title' should be treated the same with as Heading
- Add tests for Heading/Title reader

* update the documentation and the changelog
* PHP 7.2 build should not fail anymore
* reduce dependencies versions
* fix parsing of footnotes and endnotes
* add method to remove an element from a section
2018-03-06 06:34:55 +01:00
Damjan Cvetko
8a2cba2292 Support multiple elements (w:t, w:delText, w:tab) in w:r. 2018-03-04 17:13:06 +01:00
troosan
740e66acf5
randomize the tempDir more
to make sure directory is unique [ci skip]
2018-03-02 07:17:26 +01:00
Damjan Cvetko
0869bdc8f7 Add support for reading <w:tab/> element in runs. Internaly encoding it as "\t". 2018-03-01 01:40:54 +01:00
Lenz Weber
7fe32e6ac1 Add support for MACROBUTTON Field (#1021)
* add functionality to use MACROBUTTON as Field, use Styles for Field, add noProof to Font Style
* code review
* refactoring + fixes + unit tests
2018-02-27 23:27:18 +01:00
Samuel Laulhau
f3c73f333a Fix HTML parsing when style attribute is empty (#1295) 2018-02-27 23:24:00 +01:00
Matt Bolt
a95c3f83bc Fix colspan and rowspan for tables in HTML Writer. Syntax improved. 2018-02-19 18:02:55 +08:00
Matt Bolt
557af99a6d Fix colspan and rowspan for tables in HTML Writer 2018-02-19 13:08:17 +08:00
troosan
59de019881
Fix listitem parsing (#1290)
* Word 2007 Reader: Added support for ListItemRun
* Add tests + changelog
2018-02-18 01:41:32 +01:00
troosan
def023752d
Merge pull request #1248 from carusogabriel/patch-1
Refactoring
2018-02-18 01:40:24 +01:00
troosan
bded91af9f
Footnote in listitem (#1289)
* Allow footnote to be added in ListItems
2018-02-18 00:39:00 +01:00
dox07
04d0c02e23 Add support for cellSpacing for tables (#1040)
* Add cellSpacing  into table
* add word 2007 reader
* add tests
* add documentation
2018-02-18 00:10:10 +01:00
troosan
ba035185c7
point next dev version to develop branch
[ci skip]
2018-02-18 00:09:14 +01:00
troosan
cc57eb987e
Merge pull request #1286 from meteocontrol/feature-consistent-twip-naming
Use consistent name for twip unit
2018-02-17 08:40:48 +01:00
troosan
7324070c30
Merge pull request #1284 from Trainmaster/feature-remove-zend-stdlib-dependency
Remove zend-stdlib dependency
2018-02-17 08:39:55 +01:00
Frank Liepert
d061c6dc7c Remove zend-stdlib dependency 2018-02-17 00:03:41 +01:00
Frank Liepert
fede4f736e Add missing unit of measurement descriptions 2018-02-16 15:45:20 +01:00
Frank Liepert
ab978356c3 Use same markup for describing unit of measurement 2018-02-16 14:40:31 +01:00
Frank Liepert
e7232a715b Use singular form of twip 2018-02-16 14:34:37 +01:00
troosan
99d8b5256f
Merge pull request #1281 from troosan/add_table_layout
Add support for table layout
2018-02-14 01:21:33 +01:00
troosan
6a926e26f1 refactor attribute name to layout, add doc and tests 2018-02-14 00:39:37 +01:00
troosan
615c1d5576 Merge branch 'stretch-table' of https://github.com/aoloe/php-PHPWord
into tableLayout

Conflicts:
	src/PhpWord/Writer/Word2007/Style/Table.php
2018-02-13 23:29:53 +01:00
ale rimoldi
7ddaed240f table->setStretch() optionally avoids the table to stretch to the page width (only for word output) 2018-02-13 23:24:15 +01:00
troosan
e846602d1e fix null check
[ci skip]
2018-02-11 13:58:26 +01:00
troosan
ee95cf3df0
Merge pull request #1278 from troosan/fix_internal_links_in_html_output
Add HTML writer for Bookmarks + tests
2018-02-11 00:21:12 +01:00
troosan
5ff15e06a2
update testing instructions
[ci skip]
2018-02-11 00:17:19 +01:00
troosan
377fb99fbc Add HTML writer for Bookmarks + tests 2018-02-10 23:43:15 +01:00
troosan
b868c3370c
Merge pull request #1277 from troosan/fix_parsing_of_textbreaks
Fix parsing of textbreaks
2018-02-10 23:05:53 +01:00
troosan
874c6d6fb6 update changelog 2018-02-10 22:19:04 +01:00
troosan
91a8dd3b22 add parsing of p:br and add unit test 2018-02-10 22:16:55 +01:00
troosan
3f40c5e408
Merge pull request #1273 from troosan/various_html_parsing_fixes
Various html parsing fixes, fixes for #1252 and #1254
2018-02-09 22:50:18 +01:00
troosan
5b381bc0c0
Merge branch 'develop' into various_html_parsing_fixes 2018-02-09 21:53:48 +01:00
troosan
604e60cae9
Add support for Track changes (#1262)
* add changed information to HTML writer
* add missing writeFontStyle
* refactor track changes
* set the style
* update documentation and release note
* Update the changelog and doc
* fix scrutinizer issues
2018-02-09 21:49:11 +01:00
troosan
9cd5ab7433 update changelog 2018-02-09 17:17:13 +01:00
troosan
fd127ef9bb
Merge pull request #779 from samsullivan/imagesavealpha
Save PNG alpha information when using remote images.
2018-02-09 17:16:03 +01:00
troosan
24f3463f9a remove output 2018-02-08 07:18:02 +01:00
troosan
c0ed4ab03d Merge remote-tracking branch 'samimussbach/PHPWord/fixNestedLists' into various_html_parsing_fixes 2018-02-08 07:02:38 +01:00
troosan
304173c4d7 fix nested list 2018-02-08 07:02:28 +01:00
troosan
33739ea21c cannot add list on textrun 2018-02-07 21:39:01 +01:00
troosan
46476d7101 update phpdoc 2018-02-07 07:09:27 +01:00
troosan
47c837abef add unit tests 2018-02-06 23:31:56 +01:00
troosan
46a5f96d3b fix parsing of table and p inside table cells 2018-02-06 23:16:32 +01:00
Nicolas Dermine
12ad6fa865 adapt code for php 5.3 2018-02-06 09:30:24 +01:00
Nicolas Dermine
623bd993d8 refactor: use extracted method in original method 2018-02-05 17:49:23 +01:00
Nicolas Dermine
07e97c38cd add getVariableCount method to TemplateProcessor
returns how many times each placeholder is present in the document

almost the same code as `getVariables`

useful when cloning a block a number of times and want to replace
placeholders that are present more than once in the block
(using the `$limit` parameter of `setValue`)
2018-02-05 17:45:24 +01:00
troosan
cf6319d7d4
Merge pull request #1264 from lalop/patch-1
Delete VERSION
2018-02-04 20:29:54 +01:00
troosan
4308ce9eab
Merge pull request #1271 from nicoder/patch-2
fix typo in CONTRIBUTING.md
2018-02-04 20:29:32 +01:00
Nicolas Dermine
edd9617c03
fix typo 2018-02-04 08:42:38 +01:00
troosan
1813e2db38
Merge pull request #1266 from samimussbach/fixTypoInTest
fix typo in test method name
2018-02-02 21:59:37 +01:00
Nicolas Dermine
4105a9aad1 improve cloneBlock regex
it wrongly matched `<w:pPr` when looking for `<w:p`

in that case the cloned block would not be valid XML,
and so the generated docx document could not be opened by Word

adding the `\b` word boundary to the regex fixes this.

the accompanying unit test failed with this message when trying to load
the generated file:

```
ErrorException: DOMDocument::loadXML(): Opening and ending tag mismatch:
p line 2 and body in Entity, line: 2
```

This might solve issues such as #681 and #664.
2018-02-02 17:03:49 +01:00
Sami Mussbach
e0096dba08 fix typo in test method name 2018-02-01 14:12:56 +01:00
Sami Mussbach
8a9a4784d9 add (failing) test and correct documentation sample to valid HTML 2018-02-01 13:58:08 +01:00
Samuel Laulhau
caba7e238f
Delete VERSION
Delete VERSION file since it's outdated so not usefull anymore
2018-01-31 10:17:40 +01:00
troosan
9a91d54e10
Merge pull request #1259 from nicoder/patch-1
fix typo in comment
2018-01-30 20:55:49 +01:00
Nicolas Dermine
30183e2881
fix typo in comment 2018-01-26 18:31:35 +01:00
troosan
4f6fa5079f
Merge pull request #1258 from troosan/parse_html_links
Add parsing of HTML links
2018-01-26 07:59:28 +01:00
troosan
0425a25cdb Add parsing of HTML links 2018-01-25 23:24:21 +01:00
Gabriel Caruso
8ed3cacfe8
Refactoring 2018-01-16 20:19:54 -02:00
samimussbach
4c68ebbe9d Parse formatting inside HTML lists (#1239) 2018-01-13 10:03:53 +01:00
troosan
99b04f0353
fix reading of docx default style (#1238) 2018-01-12 23:42:22 +01:00
troosan
4a530d1d97
Do not show script source when running from CLI 2018-01-03 17:16:19 +01:00
troosan
35aa6d6291 Merge branch 'master' of https://github.com/PHPOffice/PHPWord into upstream_develop 2018-01-03 14:27:34 +01:00
troosan
bdca366d91 remove link to obsolete URL [skip ci] 2018-01-03 14:15:59 +01:00
troosan
7d929fee8c add branch alias for 0.15.0 [skip ci] 2017-12-29 21:48:15 +01:00
troosan
d480aab1b0 add branch alias for 0.15.0 [skip ci] 2017-12-29 21:48:08 +01:00
troosan
23693b403c change impl to avoid compilation issue 2017-12-29 21:47:55 +01:00
troosan
ca29ceb1fa
add branch alias for 0.15.0 [skip ci] 2017-12-29 21:33:29 +01:00
troosan
d1a79b79f1
add branch alias for 0.15.0 [skip ci] 2017-12-29 21:29:31 +01:00
troosan
2d87fd320d fix merge 2017-12-29 20:27:05 +01:00
Maxim
400a8e65d3 rename 'Object' classes to 'ObjectElement' (php 7.2 compatibility) (#1185)
merge develop branch
2017-12-29 20:19:35 +01:00
troosan
526d0ac8de create alias for develop branch 2017-12-29 15:46:31 +01:00
troosan
709ea1e14c update changelog [skip ci] 2017-12-29 15:16:03 +01:00
troosan
46e179d148 add instructions on how to run the samples in a browser 2017-12-29 15:16:03 +01:00
troosan
b20cd4fa9f output the source code of the sample that was run 2017-12-29 15:16:03 +01:00
troosan
1d8e7b8374 split composer scripts, add description (only works with composer 1.6) 2017-12-29 15:16:03 +01:00
troosan
d2b9e88047 add parsing of "align" HTML attribute 2017-12-29 15:16:03 +01:00
troosan
fd7ee76438 create alias for develop branch 2017-12-29 03:01:36 +01:00
troosan
b614497ae6
fix dependencies to have 7.1 compatible build (#1228)
* add assertions in test methods without assertions
* loosen dependencies so 7.0 & 7.1 builds can succeed
* fix some scrutinizer errors
* update release date
2017-12-29 02:30:53 +01:00
troosan
fce1bf28c8 format code 2017-12-25 22:05:46 +01:00
troosan
512cf952ae randomise temp directory name to avoid collisions 2017-12-25 20:42:37 +01:00
troosan
4767703f86 Merge branch 'master' of https://github.com/PHPOffice/PHPWord into upstream_develop 2017-12-25 17:14:27 +01:00
troosan
7250b15e74 Title can be added in Cell 2017-12-25 08:33:02 +01:00
troosan
6daf31be8f
Merge pull request #1226 from PHPOffice/develop
Merge develop branch to master branch
2017-12-25 01:37:54 +01:00
troosan
56720df487 update version 2017-12-25 01:32:34 +01:00
troosan
ed704da5b2 set release date 2017-12-25 01:24:20 +01:00
SRG Group
3e6745f146 HTML image support & TextRun paragraph style (#934)
* Adding setParagraphStyle to Textrun for indentation
* Html Image support added
* fix formatting, add tests & update changelog
2017-12-21 00:03:52 +01:00
troosan
200c2f1eb0
Merge pull request #1019 from jun-i-corn/feature/EnablePasswordProtection
enable password protection (Word)
2017-12-20 22:00:34 +01:00
troosan
7908491ba3 revert mistakenly deleted line 2017-12-19 22:14:52 +01:00
troosan
8929917677
Merge pull request #592 from ComputerTinker/ComputerTinker-FixEmptyDropdownEntry
Pad Empty Dropdown Entry
2017-12-19 21:53:59 +01:00
troosan
0f200d99f4
Merge pull request #1222 from carusogabriel/clean-elses
Clean elses
2017-12-19 21:41:21 +01:00
troosan
46a037ebd0 add composer scripts 2017-12-18 17:02:34 +01:00
troosan
219f3bcee1
Merge pull request #1221 from troosan/fix_parsing_of_on-off
correctly parse on/off values (w:val="true|false|1|0|on|off")
2017-12-18 08:52:35 +01:00
Gabriel Caruso
87acd3764b Clean elses 2017-12-14 12:21:16 -02:00
troosan
5d5362a3fd sort imports 2017-12-14 00:15:23 +01:00
troosan
5a57409df0 fix tests 2017-12-13 23:55:48 +01:00
troosan
ad38d4c20f Merge branch 'feature/EnablePasswordProtection' of https://github.com/jun-i-corn/PHPWord into feature/EnablePasswordProtection 2017-12-13 23:25:32 +01:00
troosan
f7d2ad7201 formatting 2017-12-13 23:24:37 +01:00
troosan
9e029415cc align with pull request submitted in PHPOffice/Commom 2017-12-13 23:17:01 +01:00
troosan
dc7cb1ee75 update changelog & doc 2017-12-13 22:48:58 +01:00
troosan
253b060241 correctly parse on/off values (w:val="true|false|1|0|on|off") 2017-12-13 07:47:49 +01:00
troosan
194e5c47e4 Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into develop 2017-12-05 21:39:35 +01:00
troosan
f6dd78daa6 update doc and changelog 2017-12-05 21:39:28 +01:00
troosan
88bbe49d01
Merge pull request #1217 from troosan/html_br
Added support for linebreaks <br/> in Shared\Html::addHtml()
2017-12-05 21:38:55 +01:00
troosan
d4c6427418
Merge pull request #727 from irond/container_for_checkbox
Add TextRun as container for CheckBox
2017-12-05 21:28:59 +01:00
troosan
0c7593ba10
Merge pull request #582 from SSchwaiger/patch-2
A chart object can also be added to a table cell
2017-12-05 21:04:07 +01:00
troosan
905029a59e
Merge branch 'develop' into html_br 2017-12-05 20:50:33 +01:00
troosan
fd156bf12a
Merge branch 'develop' into html_br 2017-12-05 20:50:13 +01:00
troosan
c079bf7f10 update changelog 2017-12-05 20:47:34 +01:00
troosan
9081ed9868 fix warning 2017-12-05 17:40:23 +01:00
troosan
8f512bf618 Merge branch 'develop-html-br' of https://github.com/anrikun/PHPWord
into develop

Conflicts:
	src/PhpWord/Shared/Html.php
2017-12-05 17:33:51 +01:00
troosan
05e2f1bf63 use non deprecated method 2017-12-05 08:02:23 +01:00
troosan
3b7b894290
Merge branch 'develop' into feature/EnablePasswordProtection 2017-12-05 00:35:29 +01:00
troosan
cfc89b7853
Merge branch 'develop' into feature/EnablePasswordProtection 2017-12-05 00:34:14 +01:00
troosan
86115b9e2d update installation instructions 2017-12-05 00:14:57 +01:00
troosan
3b6f9cea21 Allow use of stdlib 3.x 2017-12-04 22:31:10 +01:00
troosan
274f50ce5a Add unit tests & add array type checks 2017-12-04 22:30:49 +01:00
troosan
ca25eba8aa Scrutinizer fixes 2017-11-26 22:55:37 +01:00
troosan
23bc837666 Scrutinizer fixes 2017-11-26 17:54:47 +01:00
troosan
6a460c292d
Merge pull request #1206 from troosan/odt_page_break
Implement PageBreak for the ODText writer
2017-11-26 00:39:25 +01:00
troosan
def9123575
Merge branch 'develop' into odt_page_break 2017-11-26 00:37:16 +01:00
troosan
911739a0b2
Merge branch 'develop' into odt_page_break 2017-11-26 00:36:37 +01:00
troosan
01008a591b update changelog 2017-11-26 00:35:21 +01:00
troosan
355027d854 PHP-CS fix, improve code coverage 2017-11-26 00:11:09 +01:00
troosan
2ea9ffbdd4 Merge branch 'develop' of https://github.com/cookiekiller/PHPWord into odt_page_break 2017-11-25 23:45:04 +01:00
troosan
72a6b1b19f Add unit test 2017-11-25 23:44:46 +01:00
Michael Spahn
5d928db916 Implement PageBreak for odt writer 2017-11-25 23:44:45 +01:00
troosan
6faddc684a
Merge pull request #1205 from troosan/update_fields
Allow to force an update of all fields on opening a document
2017-11-25 21:56:17 +01:00
troosan
5a5ae48bb6 also add w:bCs 2017-11-25 21:37:11 +01:00
troosan
ab5d4468f9 add the updateFields option on document settings
When set to true, word will ask you to update the fields in the document
when you open the document.
2017-11-25 01:48:30 +01:00
troosan
3429c443ad
Create PULL_REQUEST_TEMPLATE.md 2017-11-25 01:46:20 +01:00
troosan
446d3478e4
Create ISSUE_TEMPLATE.md 2017-11-25 01:45:27 +01:00
troosan
2e562512f4 Add unit tests for PasswordEncoder 2017-11-24 14:45:05 +01:00
troosan
ad83196a05 move password encoding in separate class
fix PHPCS errors
add documentation
add sample
2017-11-23 22:49:21 +01:00
troosan
7b30145270
Merge branch 'develop' into feature/EnablePasswordProtection 2017-11-22 22:59:46 +01:00
troosan
ffa9c156d7 fix formatting 2017-11-22 22:31:59 +01:00
troosan
b4b87cd1dc CS fixer stronger checks 2017-11-22 09:43:35 +01:00
troosan
6a5d2a636d CS fixer warning 2017-11-22 09:02:16 +01:00
troosan
8d82340589 Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into release_0.14 2017-11-22 08:42:13 +01:00
troosan
38ea5ecb5f fix wrong variable 2017-11-22 08:41:42 +01:00
troosan
e07195c512 add test, fix warnings 2017-11-22 08:14:22 +01:00
troosan
0354e4e4a1
Merge pull request #480 from fergusean/patch-1
Skip inquiring PHP for temp directory when it's user defined
2017-11-22 00:24:03 +01:00
troosan
670d46e543 add getter/setter on paragraph for child spacing rule 2017-11-22 00:14:31 +01:00
troosan
ac357d10d5 Various fixes
- parse text inside list items
- add tests
- rename Cell widthType attribute to unit
2017-11-18 15:55:05 +01:00
troosan
b22208f810 format 2017-11-16 23:09:56 +01:00
troosan
bc4750dd7c
Merge pull request #1060 from Mord1n/patch-1
ODT Writer automatic-styles should be closed before opening master-styles.
2017-11-16 23:08:13 +01:00
troosan
ab9a3dbc63 fix warning 2017-11-16 18:03:37 +01:00
troosan
9cd373806c fix build 2017-11-16 17:47:48 +01:00
troosan
5ad68e0ba6 add tests, improve code coverage 2017-11-15 22:58:28 +01:00
troosan
8eb72c976a add HTML table parsing 2017-11-15 22:49:13 +01:00
troosan
c9350d3e80 Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into bring_back_bold_and_italic 2017-11-11 23:52:40 +01:00
troosan
a01d22ed67 improve HTML parser and add tests 2017-11-11 23:49:23 +01:00
troosan
3f8892ed91
Merge pull request #1168 from FBnil/bring_back_bold_and_italic
Html::addHTML should parse <b> <i> <u>
2017-11-11 00:31:52 +01:00
troosan
e72446442b fix format 2017-11-10 23:47:10 +01:00
troosan
ff8234bce4 add tests 2017-11-10 23:37:02 +01:00
troosan
d8dcc770a9 Merge branch 'bring_back_bold_and_italic' of https://github.com/FBnil/PHPWord into bring_back_bold_and_italic 2017-11-10 21:47:57 +01:00
troosan
8bb9a99975 fix warning 2017-11-10 21:47:45 +01:00
troosan
07c9d9fd00 Add unit tests for Html parser 2017-11-10 21:47:44 +01:00
Nilton
379df3cebd Bring back b, i, <span style="font-style: italic;"> and <span style="font-weight: bold;"> 2017-11-10 21:47:43 +01:00
ejuhjav
e4fe0c6673 Update elements.rst
Fixed a typo in the $lineStyle example (defined previously as $linestyle but used as $lineStyle)
2017-11-10 21:47:43 +01:00
troosan
266817ecac
Merge pull request #1188 from gabriel-caruso/phpunit
Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase
2017-11-10 11:21:42 +01:00
troosan
6328b83388 fix warning 2017-11-09 23:07:17 +01:00
Gabriel Caruso
ba6c03e06d Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase 2017-11-09 06:36:47 -02:00
troosan
9e7e07d0bc Add unit tests for Html parser 2017-11-09 00:41:56 +01:00
troosan
c8b55b8e59 Merge branch 'bring_back_bold_and_italic' of https://github.com/FBnil/PHPWord into bring_back_bold_and_italic 2017-11-08 21:46:55 +01:00
Nilton
fcdafeedd4 Bring back b, i, <span style="font-style: italic;"> and <span style="font-weight: bold;"> 2017-11-08 21:46:37 +01:00
ejuhjav
778a77ecff Update elements.rst
Fixed a typo in the $lineStyle example (defined previously as $linestyle but used as $lineStyle)
2017-11-08 21:46:37 +01:00
troosan
7b9e262e44 Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into release_0.14 2017-11-08 00:45:36 +01:00
troosan
ebd4741774 update changelog 2017-11-08 00:45:14 +01:00
troosan
13dc3bb2e4
Merge pull request #874 from bskrtich/develop
Fix incorrect image size between windows and mac.
2017-11-08 00:45:00 +01:00
troosan
5412df29fa update doc 2017-11-08 00:34:22 +01:00
troosan
64a6505f70
Merge pull request #578 from ComputerTinker/develop
#574 Incorrect Constant Names in \Style\Font.php
2017-11-08 00:31:45 +01:00
troosan
610d91e041 call parent constructor in SDT and FormField 2017-11-08 00:27:58 +01:00
troosan
0bd396b5cb
Merge pull request #724 from garethellis36/fix-html-tables
Resolves certain HTML tags rendering no output
2017-11-07 23:14:46 +01:00
troosan
9634352b0f update changelog 2017-11-07 23:13:41 +01:00
troosan
1b9c1d921b format 2017-11-07 23:13:41 +01:00
troosan
75bf84fa48
Merge pull request #887 from taophp/patch-1
Fix division by zero
2017-11-07 22:34:49 +01:00
troosan
ac4180ef7d
Merge pull request #1016 from jun-i-corn/feature/DefaultValueForDropDownSDT
allow setValue() for SDTs
2017-11-07 22:23:53 +01:00
troosan
56a3a53e7b add unit test 2017-11-07 22:11:31 +01:00
troosan
5ddb3f0b77 Merge remote-tracking branch 'origin/develop' into tmp
Conflicts:
	src/PhpWord/Writer/Word2007/Element/SDT.php
2017-11-07 17:43:22 +01:00
troosan
9653619c48
Merge pull request #980 from sergeizelenyi/dev-sdt
Add support for alias and tag on SDT elements
2017-11-06 22:09:55 +01:00
troosan
1e9203adc9 add unit tests 2017-11-06 21:47:02 +01:00
troosan
603bb9b02b Merge branch 'dev-sdt' of https://github.com/sergeizelenyi/PHPWord into dev-sdt 2017-11-06 20:53:29 +01:00
sergeizelenyi
9c1c544954 stylization code 2017-11-06 20:53:08 +01:00
sergeizelenyi
9ac9016f50 added functionality specified alias and tag 2017-11-06 20:53:08 +01:00
troosan
a7a35c688d Allow reading of TargetMode for external images 2017-11-05 22:48:04 +01:00
troosan
200d846f61 implement paragraph textAlignment 2017-11-05 21:39:10 +01:00
troosan
92fc54992a fix end of line space 2017-11-05 08:54:52 +01:00
troosan
ce377b9b58 fix php-cs error 2017-11-05 02:16:04 +01:00
troosan
67ca6ec1fd Merge branch 'develop' of https://github.com/troosan/PHPWord into develop 2017-11-05 02:10:27 +01:00
troosan
8c7ed19d62
Support for Mirrored page setup for docx (#1183) 2017-11-05 02:07:53 +01:00
troosan
64957d9ec8 Support for Mirrored page setup for docx 2017-11-05 01:58:17 +01:00
troosan
de9268ae12
Merge pull request #1150 from kaigoh/patch-2
pad the $args array instead of ignoring errors
2017-11-05 00:54:20 +01:00
troosan
056f81078f Merge branch 'develop' of https://github.com/troosan/PHPWord into
develop

Conflicts:
	composer.json
2017-11-05 00:39:14 +01:00
troosan
aa4c3f8486
HTML writer fixes
* fixed HTML superscript, and added allcaps, smallcaps, and letter-spacing
* make Comment constructor attributes optional
2017-11-05 00:27:14 +01:00
troosan
15eeaa2574
Merge branch 'develop' into fix_php7_issues 2017-11-05 00:23:09 +01:00
troosan
835aa9c5a4
Merge branch 'develop' into fix_php7_issues 2017-11-05 00:22:04 +01:00
troosan
b926eec3bc update changelog 2017-11-05 00:08:15 +01:00
troosan
03d4a36b9b fixed HTML superscript, and added allcaps, smallcaps, and letter-spacing 2017-11-05 00:03:06 +01:00
troosan
601a2b6ec6 make Comment constructor attributes optional 2017-11-04 23:26:04 +01:00
troosan
f4697ab6e1
Merge pull request #1178 from lightbringer1991/489-fix-wrappingStyle-z-index-in-64bit-OS
489: Fix z-index size too big in 64bit OS
2017-11-04 22:44:44 +01:00
troosan
0459670a9c
Enable php-cs-fixer in build & fix resulting warnings (#1099)
* enable php 7.1 build
* upgrade to dompdf/dompdf 0.8.*
* update phpunit & hide output during tests
* run code coverage analysis on 1 build only
* Add php-cs
* Update Copyright
2017-11-04 22:44:12 +01:00
lightbringer
3cbc65bae4 489: Fix z-index size too big in 64bit OS 2017-10-28 18:56:16 +11:00
troosan
0f50b6dc61 update documentation 2017-10-23 23:05:29 +02:00
Nilton
87a355bb82 Bring back b, i, <span style="font-style: italic;"> and <span style="font-weight: bold;"> 2017-10-21 00:07:52 +02:00
Dmitry Lukashin
7792eb2769 Break the references in foreach within TemplateProcessor 2017-10-19 19:02:26 +03:00
Dmitry Lukashin
ba9e8958d7 Replace self:: with static:: calls 2017-10-19 18:51:57 +03:00
Dmitry Lukashin
f7cb73e8a6 Get rid of duplicated code in TemplateProcessor.php 2017-10-19 17:33:46 +03:00
troosan
a4df134a4c Merge remote-tracking branch 'origin/develop' into develop
Conflicts:
	samples/Sample_27_Field.php
	src/PhpWord/Element/AbstractElement.php
	src/PhpWord/Element/Comment.php
	src/PhpWord/Element/TrackChange.php
	src/PhpWord/Writer/Word2007/Element/AbstractElement.php
	tests/PhpWord/Writer/Word2007/Part/StylesTest.php
2017-10-17 20:35:43 +02:00
Kai Gohegan
4084d4f191 Update AbstractContainer.php
Suppressing the PHP warning doesn't seem to work. Padding the $args array does.
2017-10-09 13:19:23 +01:00
troosan
e6f4d0276a Merge branch 'development' into fix_php7_issues 2017-09-27 01:09:23 +02:00
troosan
0beeb275fe Add support for changing the document language (#1108) 2017-09-27 00:40:08 +02:00
troosan
75a3fb8e40 Improve code coverage 2017-09-27 00:27:33 +02:00
troosan
6657f0eec3 fix doc 2017-09-26 22:46:46 +02:00
troosan
7e3d9fb89a replace @link with @see 2017-09-26 22:00:02 +02:00
troosan
cb469b973e more fixes 2017-09-26 17:34:57 +02:00
troosan
e0a2c40fb4 fix failing test 2017-09-26 08:01:28 +02:00
troosan
5364feb6c8 remove cache-file option 2017-09-25 22:48:53 +02:00
troosan
3f3f398524 php-cs fix 2017-09-25 21:30:59 +02:00
troosan
0be9ae3353 Fix php-cs option 2017-09-25 07:00:58 +02:00
troosan
a8ade6d22d general updates
Change "some" code to comply to php-cs rules
Update copyright year to 2010-2017
2017-09-24 22:15:42 +02:00
troosan
743dbff9d4 use php 5.3 array construct 2017-09-18 22:35:27 +02:00
troosan
34a1be0053 Add support for XE and INDEX fields (#922) 2017-09-18 21:45:59 +02:00
troosan
8ce1a19ec4 make FontStyle basedOn paragraph if the paragraph is set on the font (#926)
* make FontStyle based on paragraph if it set
* replace tab with spaces
* basedOn not correctly set if FontStyle is based on other FontStyle
* Fix warnings
2017-09-17 21:38:00 +02:00
troosan
f6aafe48bb Add php-cs 2017-09-14 22:16:35 +02:00
troosan
8b0ce2e936 commit doc based on php 5.6 build 2017-09-14 00:12:29 +02:00
troosan
0115fc3d91 fix formating 2017-09-14 00:00:48 +02:00
troosan
6cd2633b85 fix travis config 2017-09-13 23:38:44 +02:00
troosan
f1aee39700 run code coverage analysis on 1 build only 2017-09-13 23:24:35 +02:00
troosan
9d57693acd update phpunit & hide output during tests 2017-09-13 23:15:46 +02:00
troosan
34ac7170a2 Merge remote-tracking branch 'github_troosan/fix-travis-build' into fix_php7_issues 2017-09-13 22:25:16 +02:00
troosan
d5291629f7 Merge remote-tracking branch 'github_troosan/develop' into fix_php7_issues 2017-09-13 22:19:16 +02:00
troosan
41a048604e upgrade to dompdf/dompdf 0.8.* 2017-09-13 22:10:04 +02:00
troosan
2fc685b4da Merge pull request #1138 from troosan/fix-travis-build
do not force dependency to old ZF version
2017-09-11 22:49:34 +02:00
troosan
15585dd3c7 - fix ZF version
Fix travis build to run on precise
Update the changelog
2017-09-09 01:25:33 +02:00
troosan
c653377b2e Merge pull request #1116 from ctrlaltca/fix_footer_first_page
Fix: different header/footer works only for headers, not for footers
2017-08-13 22:10:15 +02:00
Fabio Bas
c448046b52 Fix: different footer for first page 2017-08-02 10:52:42 +02:00
troosan
cf76b1f217 Simplify SimpleType validation 2017-07-22 00:06:04 +02:00
troosan
7c256b5344 Merge pull request #537 from ejuhjav/patch-1
Update elements.rst
2017-07-11 02:20:05 +02:00
troosan
18cb0b26f7 Add support for comments (#1067)
Just a writer for now, reader to be done
2017-07-11 01:58:54 +02:00
troosan
be6b6008e8 add reader/writer for additional values in settings.xml (#1098)
* add reader/writer for settings.xml
The following values can currently be set/read
- w:trackRevisions
- w:doNotTrackMoves
- w:doNotTrackFormatting
- w:proofState
- w:zoom
- w:decimalSymbol
- w:revisionView
2017-07-11 01:56:20 +02:00
troosan
b72ffbdc98 enable php 7.1 build 2017-07-09 22:21:52 +02:00
troosan
4c7c84b17e fix pclzip compatibility issues 2017-07-09 22:21:34 +02:00
troosan
88cc13dd85 fix 2017-07-07 08:02:31 +02:00
troosan
722c81d89d fix md remarks 2017-07-06 23:03:07 +02:00
troosan
24c440b0ab disable 7.1 and hhvm build as they currently do not work 2017-07-06 22:54:28 +02:00
troosan
b919d58bac add reader for settings 2017-07-06 22:41:04 +02:00
troosan
e9cc289243 refactor Settings to not mix PHPWord settings and document settings 2017-07-05 21:42:38 +02:00
troosan
21303ed4fb prepare release notes 2017-07-05 21:39:22 +02:00
troosan
17849b3514 Merge pull request #1075 from slowprog/develop
Fix names of styles
2017-07-04 15:54:41 +02:00
troosan
a6c6f9faa1 Merge branch 'development' into develop
Conflicts:
	tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
2017-07-04 15:38:01 +02:00
troosan
f3f11cb64b Merge pull request #1092 from troosan/implement_request_#1041
add new NumberFormat values and refactor FootnoteProperties to use same values
2017-07-04 15:30:21 +02:00
troosan
8a5433e5df add new NumberFormat values and refactor other uses 2017-07-04 15:04:30 +02:00
troosan
663a552d29 Merge pull request #1008 from slowprog/develop
Fix name of style definitions
2017-07-03 14:14:43 +02:00
troosan
ef95611203 Fix multiple paragraphs being created 2017-07-03 12:54:18 +02:00
troosan
e7c551a0bf Add possibility to show/hide spelling and grammatical errors (#985)
* Add possibility to show/hide spelling and grammatical errors
2017-07-02 00:37:29 +02:00
troosan
6a3135bff2 Merge pull request #989 from troosan/fix_for_different_even_odd_headers
add possibility to write w:evenAndOddHeaders in settings.xml
2017-07-01 23:36:46 +02:00
troosan
29f7cfb581 Merge pull request #1068 from troosan/footnote_properties
Add possibility to control the footnote number
2017-07-01 23:27:10 +02:00
troosan
ce492133a6 Merge pull request #1088 from troosan/add_support_for_contextual_spacing
Add support for contextual spacing
2017-07-01 23:09:40 +02:00
troosan
0f649f3f37 Add test & update documentation 2017-07-01 22:51:53 +02:00
Maxim Barulin
d5dbfb98b0 add support for contextualSpacing attribute issue #1037 2017-07-01 21:08:05 +02:00
troosan
fd418e0746 Make sample php 5.3 compliant 2017-07-01 17:15:50 +02:00
troosan
ccccb3d679 Merge pull request #988 from troosan/fix_image_loading_over_https
fix image loading over https
2017-07-01 17:07:07 +02:00
troosan
f59b7228bb Merge pull request #977 from troosan/paper_size_computation
fix paper size and add tests for Paper class
2017-07-01 17:03:01 +02:00
troosan
8c3efa4a51 remove unused variable 2017-07-01 16:56:33 +02:00
Andrey Tyshev
2074d35ab0 Fix PreserveText in Section #452 2017-06-19 13:51:41 +03:00
Andrey Tyshev
aae9ad4249 Fix names of styles 2017-06-19 13:47:47 +03:00
Andrey Tyshev
28e3242a1d Merge remote-tracking branch 'upstream/develop' into develop 2017-06-19 13:25:56 +03:00
Hubert Miazek
e22ece8c00 #431 2017-06-19 11:05:59 +02:00
antoine
cbea5aed87 Merge branch 'footer_properties' into develop 2017-06-17 01:02:40 +02:00
antoine
eff532e64f make code php 5.3 -> 5.5 compatible 2017-06-17 01:01:54 +02:00
antoine
2d1b52bc90 Merge branch 'support_for_xe_and_index_field' into develop 2017-06-17 00:35:39 +02:00
antoine
2b4b200e42 fix namespace 2017-06-17 00:34:02 +02:00
antoine
11d816f94d php 5.3 compatibility 2017-06-16 22:39:20 +02:00
antoine
373039cbdc Merge branch 'support_for_xe_and_index_field' into develop 2017-06-16 18:01:23 +02:00
antoine
64f06e1114 use fully qualified name 2017-06-16 17:55:24 +02:00
antoine
f0fa91f63c Merge branch 'support_for_xe_and_index_field' into develop 2017-06-11 12:58:06 +02:00
antoine
8aabf812f8 update XE field to support formatted text + add documentation 2017-06-11 12:56:59 +02:00
antoine
ee2dcddc6e Merge branch 'support_for_xe_and_index_field' into develop 2017-06-07 02:27:55 +02:00
antoine
6a84b8ed26 Add possiblity to add not defined options 2017-06-07 02:26:59 +02:00
antoine
7ce54abac3 Merge remote-tracking branch 'github_troosan/footnote_properties' into develop 2017-05-30 00:37:37 +02:00
antoine
ac89cc39ea Add possibility to control the footnote number 2017-05-30 00:31:32 +02:00
antoine
f21f79761a fix sample 2017-05-25 22:04:23 +02:00
antoine
68dd3fd576 rename attribute to match generated XML node name 2017-05-24 00:18:17 +02:00
Mord1n
a55405e655 Update Styles.php
automatic-styles should be closed before opening master-styles.

This will prevent issue that styles wont work in future if you implement styling for ODT writer....
2017-05-18 16:25:05 +02:00
antoine
11c711b275 Merge branch 'fix_font_style_based_on' into develop 2017-05-16 02:41:52 +02:00
antoine
09e669f9e9 basedOn not correctly set if FontStyle is based on other FontStyle 2017-05-16 02:38:15 +02:00
antoine
6e49e89547 Merge branch 'support_comments' into develop 2017-05-15 23:00:10 +02:00
antoine
1cfb62de0d Add support for comments 2017-05-15 22:49:02 +02:00
antoine
0e0817c972 ignore the build directory 2017-05-12 00:45:31 +02:00
antoine
759794d746 fix twig dependency so build can succeed 2017-05-12 00:45:21 +02:00
Lenz Weber
71574d1fe2 Code Review; minor changes to salt handling, corrected some comments 2017-03-13 16:22:04 +01:00
Progi1984
4decaffd53 PHPWord is looking for a new maintainer 2017-03-13 14:45:57 +01:00
Maria Haubner
76246630ce add test 2017-03-10 17:30:51 +01:00
Maria Haubner
0221414ee0 randomly genereate salt for word password protection 2017-03-10 16:57:42 +01:00
Maria Haubner
703e34137b refactored hash function to word settings 2017-03-10 16:24:52 +01:00
Maria Haubner
483a167500 refactoring of hash function 2017-03-10 15:44:13 +01:00
Maria Haubner
05387fac09 enable password setting in word 2017-03-10 13:28:32 +01:00
Maria Haubner
488b10b73b allow setValue() for SDTs 2017-03-08 13:08:33 +01:00
Andrey Tyshev
f9cab8d02c Fix name of style definitions 2017-02-21 21:42:56 +03:00
antoine
d8c5703e06 Merge remote-tracking branch
'github_troosan/fix_for_different_even_odd_headers' into develop

Conflicts:
	tests/PhpWord/SettingsTest.php
	tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
2017-01-29 14:54:08 +01:00
antoine
aef7a0ba76 add possibility to write w:evenAndOddHeaders in settings.xml 2017-01-29 14:34:19 +01:00
antoine
7c08dd595b Merge remote-tracking branch 'github_troosan/fix_image_loading_over_https' into develop 2017-01-29 13:47:59 +01:00
antoine
217fd6ecf1 fix image loading over https 2017-01-29 13:37:43 +01:00
antoine
517c432ee6 fix image loading over https 2017-01-29 13:16:54 +01:00
antoine
91f79d85cf Merge branch 'show_hide_spelling_grammatical_errors' into develop 2017-01-28 12:04:51 +01:00
antoine
d23409f687 Add possibility to show/hide spelling and grammatical errors 2017-01-28 11:39:43 +01:00
sergeizelenyi
8b960c79d5 stylization code 2017-01-23 16:43:56 +03:00
sergeizelenyi
1ab93e7e8a added functionality specified alias and tag 2017-01-23 16:15:33 +03:00
antoine
8d7775552c Merge remote-tracking branch 'github_troosan/paper_size_computation' into develop 2017-01-22 15:16:16 +01:00
antoine
fc3bc29a02 fix default page size 2017-01-22 11:09:44 +01:00
antoine
da60645be3 Merge remote-tracking branch 'github_troosan/paper_size_computation' into develop 2017-01-21 19:29:14 +01:00
antoine
b6a9f7c9b3 fix paper size and add tests for Paper class 2017-01-21 19:06:49 +01:00
antoine
38a4e79c3c Merge branch 'image_from_string' into develop 2016-12-14 22:41:28 +01:00
Stéphane Mourey
1a1b362f40 Update Paragraph.php 2016-12-13 21:51:44 +01:00
Progi1984
6da9d8a0bf Merge pull request #928 from likeuntomurphy/develop
Fixes PHPOffice/PHPWord#927
2016-12-13 16:56:57 +01:00
Progi1984
c4c35ddb63 Merge pull request #937 from troosan/image_from_string
add support for Image creation from string image data
2016-12-13 09:32:25 +01:00
antoine
204f0c32ec update documentation 2016-12-12 20:39:10 +01:00
antoine
51c6b5fc38 add support for Image creation from string image data 2016-11-08 23:40:10 +01:00
antoine
a070628225 Merge remote-tracking branch 'origin/develop' into develop 2016-11-08 23:33:50 +01:00
antoine
46eebe2136 add support for Image creation from string image data 2016-11-08 23:22:22 +01:00
Progi1984
60e7f53945 Merge pull request #935 from liangtaohy/patch-1
Update MsDoc.php
2016-11-08 13:51:36 +01:00
liangtaohy
3f9ab94812 Update MsDoc.php
fix style\font not found bug
2016-11-08 18:32:22 +08:00
Jonathan Cox
000e36acfe Fixes PHPOffice/PHPWord#927 2016-10-28 20:06:03 -04:00
antoine
1c0444646e Merge branch 'fix_font_style_based_on' into develop 2016-10-28 23:30:11 +02:00
antoine
c50e3c581a replace tab with spaces 2016-10-28 23:28:05 +02:00
antoine
18474c56c4 replace tab with spaces 2016-10-28 23:27:24 +02:00
antoine
2216bc6130 Merge branch 'fix_font_style_based_on' into develop 2016-10-28 23:15:05 +02:00
antoine
8318b412e9 Merge remote-tracking branch 'github_troosan/support_for_xe_and_index_field' into develop 2016-10-28 23:14:34 +02:00
antoine
77ed1565c3 make FontStyle based on paragraph if it set 2016-10-28 22:40:44 +02:00
antoine
e7229fc15c make FontStyle based on paragraph if it set 2016-10-28 22:27:05 +02:00
antoine
0953065b8c improve code coverage 2016-10-28 00:20:47 +02:00
antoine
d52d9b8985 Add support for XE and INDEX fields 2016-10-27 23:12:26 +02:00
Stéphane Mourey
23e19a2d47 Fix division by zero
See #886
2016-09-12 16:43:21 +02:00
Brandon Skrtich
49492b2516 Fix incorrect image size between windows and mac.
See Issue #224
2016-08-26 11:06:19 -06:00
Progi1984
c71069022e Merge pull request #821 from brutto/patch-1
Add info about Invalid image
2016-08-23 10:24:27 +02:00
Michael Spahn
98d2e0df33 Implement PageBreak for odt writer 2016-08-16 17:10:51 +02:00
ale rimoldi
133b727f59 table->setStretch() optionally avoids the table to stretch to the page width (only for word output) 2016-07-25 10:11:52 +02:00
Anton Karakulov
0652302423 add info about Invalid image
if there are many images in document are used and one of them throws `InvalidImageException` it is very difficult to detect which one without any message here...
2016-06-19 15:27:01 +03:00
Phil Betley
b011e6f157 5.3 array syntax 2016-06-16 08:54:24 -04:00
Phil Betley
f51422ad8d add variable indexing for block cloning
Use the same functionality from cloneRow to index variables inside
cloned block sections
2016-06-15 14:46:07 -04:00
Phil Betley
c6fff318f3 Merge remote-tracking branch 'refs/remotes/PHPOffice/develop' into develop 2016-06-15 12:31:38 -04:00
Sam Sullivan
f4ec74a4c5 imagesavealpha() in Element\Image 2016-04-11 12:49:18 -05:00
Sam Sullivan
adfcc62e64 imagesavealpha() in Writer\AbstractWriter 2016-04-11 12:48:43 -05:00
Denis Solovyov
0857f36572 Add TextRun as container for CheckBox 2016-02-12 17:37:44 +02:00
Gareth Ellis
d2daa5a48c Update changelog 2016-02-04 14:14:53 +00:00
Gareth Ellis
17521e7593 PHPCS fixes 2016-02-04 14:06:47 +00:00
Gareth Ellis
3c3eecd4da PHPCS fixes 2016-02-04 14:06:11 +00:00
Gareth Ellis
a68634c3f1 Properly fixing #257 and helps out on #324 2016-02-04 13:40:16 +00: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
Henri MEDOT
f7afdebb03 Added support for linebreaks <br /> in Shared\Html::addHtml() 2015-11-12 18:51:04 +01:00
Russ
d11b2467aa Fix Empty Dropdown Entry
Pad any empty dropdown entries we find so that xmlWriter doesn't
generate an error.
2015-08-06 15:57:18 -05:00
Russ
a9398e32c7 Fix Hour Casing for Intended Formats to Work Correctly
Time formats should either be "h" or "HH".  There were some formats
which were incorrectly specified as "H".
2015-08-06 13:22:01 -05:00
Russ
cb034879b4 Add Date Formats to Field Element
Fix a typo (d-M-yyy H:mm), and expand the list of valid date formats.
2015-08-06 12:50:31 -05:00
Sebastian Schwaiger
13a1c9f24f A chart object can also be added to a table cell 2015-07-29 11:16:04 +02:00
Russ
e929610746 Map Underline Codes to Corrected Constant Values 2015-07-22 09:01:01 -05:00
Russ
304765162e #574 Incorrect Constant Names in \Style\Font.php
Correct constants mapped to "dotDash" and "dotDashHeavy", leaving old spellings for backwards compatibility.
2015-07-22 08:57:15 -05:00
Frank Meyer
a6528471c2 changed if statement due to error in codesniffer 2015-07-21 15:11:34 +02:00
Frank Meyer
3a251770e8 Removed complains of php-codesniffer
removed whitespace
changed inline if statement
2015-07-21 14:56:29 +02:00
Frank Meyer
62d3f97e30 dded the ability to enable gridlines and axislabels on charts
added options 'showAxisLabels', 'showGridX', 'showGridY' to charts style element
2015-07-21 14:07:23 +02:00
ejuhjav
daf7d11144 Update elements.rst
Fixed a typo in the $lineStyle example (defined previously as $linestyle but used as $lineStyle)
2015-05-20 13:17:11 +02:00
fergusean
00adf6de81 Skip inquiring PHP for temp directory when it's user defined 2015-02-13 00:12:13 -05:00
595 changed files with 40160 additions and 19636 deletions

21
.gitattributes vendored Normal file
View File

@ -0,0 +1,21 @@
# build config
/.scrutinizer.yml export-ignore
/.github export-ignore
/php_cs.dist export-ignore
/phpmd.xml.dist export-ignore
/phpstan.neon export-ignore
/composer.lock export-ignore
# git files
/.gitignore export-ignore
/.gitattributes export-ignore
# project directories
/build export-ignore
/docs export-ignore
/samples export-ignore
# tests
/phpunit.xml.dist export-ignore
/tests export-ignore

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).

11
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,11 @@
### Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
Fixes # (issue)
### Checklist:
- [ ] I have run `composer run-script check --timeout=0` and no errors were reported
- [ ] The new code is covered by unit tests (check build/coverage for coverage report)
- [ ] I have updated the documentation to describe the changes

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

9
.gitignore vendored
View File

@ -6,14 +6,19 @@ Thumbs.db
Desktop.ini
.idea
_build
/build
phpunit.xml
composer.lock
composer.phar
vendor
/report
/samples/resources
/build
/samples/results
/.settings
phpword.ini
/.buildpath
/.project
/.scannerwork
/.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,3 +1,14 @@
build:
nodes:
analysis:
tests:
override: [php-scrutinizer-run]
environment:
php:
version: '7.4'
pecl_extensions:
- zip
filter:
excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ]
@ -14,8 +25,8 @@ tools:
config:
ruleset: phpmd.xml.dist
external_code_coverage:
enabled: true
timeout: 900
enabled: false
timeout: 1200
php_cpd: true
# php_sim: # Temporarily disabled to allow focus on things other than duplicates
# min_mass: 40

View File

@ -1,50 +0,0 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
matrix:
allow_failures:
- php: 7.0
- php: hhvm
env:
global:
- secure: "Sq+6bVtnPsu0mWX8DWQ+9bGAjxMcGorksUiHc4YIXEJsuDfVmVlH8tTD547IeCjDAx9MxXerZ2Z4HSjxTB70VEnJPvZMHI/EZn4Ny31YLHEthdZbV5Gd1h0TGp8VOzPKGShvGrtGBX6MvMfgpK4zuieVWbSfdKeecm8ZNLMpUd4="
before_install:
## Packages
- sudo apt-get update -qq
- sudo apt-get install -y graphviz
before_script:
## Composer
- composer self-update
- composer install --prefer-source
## PHPDocumentor
- mkdir -p build/docs
- mkdir -p build/coverage
script:
## PHP_CodeSniffer
- ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
## PHP Mess Detector
- ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
## PHPUnit
- ./vendor/bin/phpunit -c ./ --coverage-text --coverage-html ./build/coverage
## PHPLOC
- ./vendor/bin/phploc src/
## PHPDocumentor
- ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig"
after_script:
## PHPDocumentor
- bash .travis_shell_after_success.sh
## Scrutinizer
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml

View File

@ -1,39 +0,0 @@
#!/bin/bash
echo "--DEBUG--"
echo "TRAVIS_REPO_SLUG: $TRAVIS_REPO_SLUG"
echo "TRAVIS_PHP_VERSION: $TRAVIS_PHP_VERSION"
echo "TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST"
if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_PHP_VERSION" == "5.5" ]; then
echo -e "Publishing PHPDoc...\n"
cp -R build/docs $HOME/docs-latest
cp -R build/coverage $HOME/coverage-latest
cd $HOME
git config --global user.email "travis@travis-ci.org"
git config --global user.name "travis-ci"
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/PHPOffice/PHPWord gh-pages > /dev/null
cd gh-pages
echo "--DEBUG : Suppression"
git rm -rf ./docs/$TRAVIS_BRANCH
echo "--DEBUG : Dossier"
mkdir -p docs/$TRAVIS_BRANCH
mkdir -p coverage/$TRAVIS_BRANCH
echo "--DEBUG : Copie"
cp -Rf $HOME/docs-latest/* ./docs/$TRAVIS_BRANCH/
cp -Rf $HOME/coverage-latest/* ./coverage/$TRAVIS_BRANCH/
echo "--DEBUG : Git"
git add -f .
git commit -m "PHPDocumentor (Travis Build: $TRAVIS_BUILD_NUMBER - Branch: $TRAVIS_BRANCH)"
git push -fq origin gh-pages > /dev/null
echo -e "Published PHPDoc to gh-pages.\n"
fi

View File

@ -1,8 +1,346 @@
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
- Add getVariableCount method in TemplateProcessor. @nicoder #1272
- Add setting Chart Title and Legend visibility @Tom-Magill #1433
- Add ability to pass a Style object in Section constructor @ndench #1416
- Add support for hidden text @Alexmg86 #1527
- Add support for setting images in TemplateProcessor @SailorMax #1170
- Add "Plain Text" type to SDT (Structured Document Tags) @morrisdj #1541
- Added possibility to index variables inside cloned block in TemplateProcessor @JPBetley #817
- Added possibility to replace variables inside cloned block with values in TemplateProcessor @DIDoS #1392
### Fixed
- Fix regex in `cloneBlock` function @nicoder #1269
- HTML Title Writer loses text when Title contains a TextRun instead a string. @begnini #1436
- Fix regex in fixBrokenMacros, make it less greedy @MuriloSo @brainwood @yurii-sio2 #1502 #1345
- 240 twips are being added to line spacing, should not happen when using lineRule fixed @troosan #1509 #1505
- Adding table layout to the generated HTML @aarangara #1441
- Fix loading of Sharepoint document @Garrcomm #1498
- RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals @Patrick64 #1493
- Fix parsing of Office 365 documents @Timanx #1485
- 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
### Miscellaneous
- Get rid of duplicated code in TemplateProcessor @abcdmitry #1161
v0.15.0 (14 Jul 2018)
----------------------
### Added
- Parsing of `align` HTML attribute - @troosan #1231
- Parse formatting inside HTML lists - @troosan @samimussbach #1239 #945 #1215 #508
- Parsing of CSS `direction` instruction, HTML `lang` attribute, formatting inside table cell - @troosan #1273 #1252 #1254
- Add support for Track changes @Cip @troosan #354 #1262
- Add support for fixed Table Layout @aoloe @ekopach @troosan #841 #1276
- Add support for Cell Spacing @dox07 @troosan #1040
- Add parsing of formatting inside lists @atomicalnet @troosan #594
- Added support for Vertically Raised or Lowered Text (w:position) @anrikun @troosan #640
- Add support for MACROBUTTON field @phryneas @troosan #1021
- Add support for Hyphenation @Trainmaster #1282 (Document: `autoHyphenation`, `consecutiveHyphenLimit`, `hyphenationZone`, `doNotHyphenateCaps`, Paragraph: `suppressAutoHyphens`)
- Added support for Floating Table Positioning (tblpPr) @anrikun #639
- Added support for Image text wrapping distance @troosan #1310
- Added parsing of CSS line-height and text-indent in HTML reader @troosan #1316
- Added the ability to enable gridlines and axislabels on charts @FrankMeyer #576
- Add support for table indent (tblInd) @Trainmaster #1343
- Added parsing of internal links in HTML reader @lalop #1336
- Several improvements to charts @JAEK-S #1332
- Add parsing of html image in base64 format @jgpATs2w #1382
- Added Support for Indentation & Tabs on RTF Writer. @smaug1985 #1405
- Allows decimal numbers in HTML line-height style @jgpATs2w #1413
### Fixed
- Fix reading of docx default style - @troosan #1238
- Fix the size unit of when parsing html images - @troosan #1254
- Fixed HTML parsing of nested lists - @troosan #1265
- Save PNG alpha information when using remote images. @samsullivan #779
- Fix parsing of `<w:br/>` tag. @troosan #1274
- Bookmark are not writton as internal link in html writer @troosan #1263
- It should be possible to add a Footnote in a ListItemRun @troosan #1287 #1287
- Fix colspan and rowspan for tables in HTML Writer @mattbolt #1292
- Fix parsing of Heading and Title formating @troosan @gthomas2 #465
- Fix Dateformat typo, fix hours casing, add Month-Day-Year formats @ComputerTinker #591
- Support reading of w:drawing for documents produced by word 2011+ @gthomas2 #464 #1324
- Fix missing column width in ODText writer @potofcoffee #413
- Disable entity loader before parsing XML to avoid XXE injection @Tom4t0 #1427
### Changed
- Remove zend-stdlib dependency @Trainmaster #1284
- The default unit for `\PhpOffice\PhpWord\Style\Image` changed from `px` to `pt`.
### Miscellaneous
- Drop GitHub pages, switch to coveralls for code coverage analysis @czosel #1360
v0.14.0 (29 Dec 2017)
----------------------
This release fixes several bugs and adds some new features.
This version brings compatibility with PHP 7.0 & 7.1
### Added
- Possibility to control the footnote numbering - @troosan #1068
- Image creation from string - @troosan #937
- Introduced the `\PhpOffice\PhpWord\SimpleType\NumberFormat` simple type. - @troosan
- Support for ContextualSpacing - @postHawk #1088
- Possiblity to hide spelling and/or grammatical errors - @troosan #542
- Possiblity to set default document language as well as changing the language for each text element - @troosan #1108
- Support for Comments - @troosan #1067
- Support for paragraph textAlignment - @troosan #1165
- Add support for HTML underline tag <u> in addHtml - @zNightFalLz #1186
- Add support for HTML <br> in addHtml - @anrikun @troosan #659
- Allow to change cell width unit - guillaume-ro-fr #986
- Allow to change the line height rule @troosan
- Implement PageBreak for odt writer @cookiekiller #863 #824
- Allow to force an update of all fields on opening a document - @troosan #951
- Allow adding a CheckBox in a TextRun - @irond #727
- Add support for HTML img tag - @srggroup #934
- Add support for password protection for docx - @mariahaubner #1019
### Fixed
- Loosen dependency to Zend
- Images are not being printed when generating PDF - @hubertinio #1074 #431
- Fixed some PHP 7 warnings - @ likeuntomurphy #927
- Fixed PHP 7.2 compatibility (renamed `Object` class names to `ObjectElement`) - @SailorMax #1185
- Fixed Word 97 reader - @alsofronie @Benpxpx @mario-rivera #912 #920 #892
- Fixed image loading over https - @troosan #988
- Impossibility to set different even and odd page headers - @troosan #981
- Fixed Word2007 reader where unnecessary paragraphs were being created - @donghaobo #1043 #620
- Fixed Word2007 reader where margins were not being read correctly - @slowprog #885 #1008
- Impossible to add element PreserveText in Section - @rvanlaak #452
- Added missing options for numbering format - @troosan #1041
- Fixed impossibility to set a different footer for first page - @ctrlaltca #1116, @aoloe #875
- Fixed styles not being applied by HTML writer, better pdf output - @sarke #1047 #500 #1139
- Fixed read docx error when document contains image from remote url - @FBnil #1173 #1176
- Padded the $args array to remove error - @kaigoh #1150, @reformed #870
- Fix incorrect image size between windows and mac - @bskrtich #874
- Fix adding HTML table to document - @mogilvie @arivanbastos #324
- Fix parsing on/off values (w:val="true|false|1|0|on|off") - @troosan #1221 #1219
- Fix error on Empty Dropdown Entry - @ComputerTinker #592
### Deprecated
- PhpWord->getProtection(), get it from the settings instead PhpWord->getSettings()->getDocumentProtection();
v0.13.0 (31 July 2016)
-------------------
This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).
@ -22,6 +360,7 @@ Manual installation feature has been dropped since the release. Please, use [Com
- Improved error message for the case when `autoload.php` is not found. - @RomanSyroeshko #371
- Renamed the `align` option of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles into `alignment`. - @RomanSyroeshko
- Improved performance of `TemplateProcessor::setValue()`. - @kazitanvirahsan #614, #617
- Fixed some HTML tags not rendering any output (p, header & table) - #257, #324 - @twmobius and @garethellis
### Deprecated
- `getAlign` and `setAlign` methods of `NumberingLevel`, `Frame`, `Table`, and `Paragraph` styles.
@ -399,4 +738,4 @@ This is the first release after a long development hiatus in [CodePlex](https://
- Basic CI with Travis - @Progi1984
- Added PHPWord_Exception and exception when could not copy the template - @Progi1984
- IMPROVED: Moved examples out of Classes directory - @Progi1984
- IMPROVED: Advanced string replace in setValue for Template - @Esmeraldo [#49](http://phpword.codeplex.com/workitem/49)
- IMPROVED: Advanced string replace in setValue for Template - @Esmeraldo [#49](http://phpword.codeplex.com/workitem/49)

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 yours mission to test the changes you made before pull request submission. We use [PHPUnit](https://phpunit.de/) for our testing purposes and recommend you using this tool too. [Here](https://phpunit.de/presentations.html) you can find PHPUnit best practices and additional information on effective unit testing, which helps us making PHPWord better day to day. Do not hesitate to smoke it carefully. It's a great investment in quality of your work, and it saves you years of life.
- **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,16 +1,18 @@
# ![PHPWord](https://rawgit.com/PHPOffice/PHPWord/develop/docs/images/phpword.svg "PHPWord")
[![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)
[![Code Quality](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/quality-score.png?s=b5997ce59ac2816b4514f3a38de9900f6d492c1d)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/)
[![Code Coverage](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/coverage.png?s=742a98745725c562955440edc8d2c39d7ff5ae25)](https://scrutinizer-ci.com/g/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/)
[![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)
PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF), HTML, and PDF.
PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/).
PHPWord is an open source project licensed under the terms of [LGPL version 3](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)
Read more about PHPWord:
@ -20,11 +22,10 @@ Read more about PHPWord:
- [Getting started](#getting-started)
- [Contributing](#contributing)
- [Developers' Documentation](http://phpword.readthedocs.org/)
- [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/)
## 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
@ -52,11 +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
- [Zend\Validator component](http://framework.zend.com/manual/current/en/modules/zend.validator.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)
@ -66,16 +65,15 @@ PHPWord requires the following:
## Installation
PHPWord is installed via [Composer](https://getcomposer.org/).
You just need to [add dependency](https://getcomposer.org/doc/04-schema.md#package-links>) on PHPWord into your package.
To [add a dependency](https://getcomposer.org/doc/04-schema.md#package-links) to PHPWord in your project, either
Example:
```json
{
"require": {
"phpoffice/phpword": "v0.13.*"
}
}
Run the following to use the latest stable version
```sh
composer require phpoffice/phpword
```
or if you want the latest unreleased version
```sh
composer require phpoffice/phpword:dev-master
```
## Getting started
@ -152,13 +150,14 @@ $objWriter->save('helloWorld.html');
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
```
More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail.
More examples are provided in the [samples folder](samples/). For an easy access to those samples launch `php -S localhost:8000` in the samples directory then browse to [http://localhost:8000](http://localhost:8000) to view the samples.
You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) for more detail.
## Contributing
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

@ -1 +0,0 @@
0.13.0

View File

@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 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

@ -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": [
@ -20,7 +20,7 @@
},
{
"name": "Franck Lefevre",
"homepage": "http://blog.rootslabs.net"
"homepage": "https://rootslabs.net/blog/"
},
{
"name": "Ivan Lanin",
@ -29,25 +29,52 @@
{
"name": "Roman Syroeshko",
"homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/"
},
{
"name": "Antoine de Troostembergh"
}
],
"scripts": {
"test": [
"phpunit --color=always"
],
"test-no-coverage": [
"phpunit --color=always --no-coverage"
],
"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",
"phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php",
"@test-no-coverage"
],
"fix": [
"php-cs-fixer fix --ansi"
]
},
"scripts-descriptions": {
"test": "Runs all unit tests",
"test-no-coverage": "Runs all unit tests, without code coverage",
"check": "Runs PHP CheckStyle and PHP Mess detector",
"fix": "Fixes issues found by PHP-CS"
},
"require": {
"php": ">=5.3.3",
"php": "^7.1|^8.0",
"ext-dom": "*",
"ext-json": "*",
"ext-xml": "*",
"zendframework/zend-escaper": "2.4.*",
"zendframework/zend-stdlib": "2.4.*",
"zendframework/zend-validator": "2.4.*",
"phpoffice/common": "0.2.*"
"laminas/laminas-escaper": ">=2.6"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpdocumentor/phpdocumentor":"2.*",
"squizlabs/php_codesniffer": "1.*",
"phpmd/phpmd": "2.*",
"phploc/phploc": "2.*",
"dompdf/dompdf":"0.6.*",
"tecnickcom/tcpdf": "6.*",
"mpdf/mpdf": "5.*"
"ext-zip": "*",
"ext-gd": "*",
"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",
@ -60,5 +87,10 @@
"psr-4": {
"PhpOffice\\PhpWord\\": "src/PhpWord"
}
},
"autoload-dev": {
"psr-4": {
"PhpOffice\\PhpWordTests\\": "tests/PhpWordTests"
}
}
}

View File

@ -41,14 +41,14 @@ master_doc = 'index'
# General information about the project.
project = u'PHPWord'
copyright = u'2014-2015, 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.13.0'
version = '0.18.2'
# The full version, including alpha/beta/rc tags.
release = version
@ -120,7 +120,7 @@ html_theme = 'default'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
#html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.

View File

@ -79,7 +79,7 @@ Below are the properties of the line numbering style.
- ``start`` Line numbering starting value
- ``increment`` Line number increments
- ``distance`` Distance between text and line numbering in twip
- ``distance`` Distance between text and line numbering in *twip*
- ``restart`` Line numbering restart setting
continuous\|newPage\|newSection
@ -98,6 +98,18 @@ that are available for the footer. See "Footer" section for detail.
Additionally, only inside of the header reference you can add watermarks
or background pictures. See "Watermarks" section.
You can pass an optional parameter to specify where the header/footer should be applied, it can be
- ``Footer::AUTO`` default, all pages except if overridden by first or even
- ``Footer::FIRST`` each first page of the section
- ``Footer::EVEN`` each even page of the section. Will only be applied if the evenAndOddHeaders is set to true in phpWord->settings
To change the evenAndOddHeaders use the ``getSettings`` method to return the Settings object, and then call the ``setEvenAndOddHeaders`` method:
.. code-block:: php
$phpWord->getSettings()->setEvenAndOddHeaders(true);
Footers
-------

View File

@ -31,7 +31,7 @@ column shows the containers while the rows lists the elements.
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
| 11 | Watermark | - | v | - | - | - | - |
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
| 12 | Object | v | v | v | v | v | v |
| 12 | OLEObject | v | v | v | v | v | v |
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
| 13 | TOC | v | - | - | - | - | - |
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
@ -39,7 +39,7 @@ column shows the containers while the rows lists the elements.
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
| 15 | Endnote | v | - | - | v\*\* | v\*\* | - |
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
| 16 | CheckBox | v | v | v | v | - | - |
| 16 | CheckBox | v | v | v | v | v | - |
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
| 17 | TextBox | v | v | v | v | - | - |
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
@ -47,6 +47,8 @@ column shows the containers while the rows lists the elements.
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
| 19 | Line | v | v | v | v | v | v |
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
| 20 | Chart | v | | | v | | |
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
Legend:
@ -59,7 +61,7 @@ Legend:
Texts
-----
Text can be added by using ``addText`` and ``addTextRun`` method.
Text can be added by using ``addText`` and ``addTextRun`` methods.
``addText`` is used for creating simple paragraphs that only contain texts with the same style.
``addTextRun`` is used for creating complex paragraphs that contain text with different style (some bold, other
italics, etc) or other elements, e.g. images or links. The syntaxes are as follow:
@ -75,11 +77,19 @@ italics, etc) or other elements, e.g. images or links. The syntaxes are as follo
For available styling options see :ref:`font-style` and :ref:`paragraph-style`.
If you want to enable track changes on added text you can mark it as INSERTED or DELETED by a specific user at a given time:
.. code-block:: php
$text = $section->addText('Hello World!');
$text->setChanged(\PhpOffice\PhpWord\Element\ChangedElement::TYPE_INSERTED, 'Fred', (new \DateTime()));
Titles
~~~~~~
If you want to structure your document or build table of contents, you need titles or headings.
To add a title to the document, use the ``addTitleStyle`` and ``addTitle`` method.
If `depth` is 0, a Title will be inserted, otherwise a Heading1, Heading2, ...
.. code-block:: php
@ -89,7 +99,7 @@ To add a title to the document, use the ``addTitleStyle`` and ``addTitle`` metho
- ``depth``.
- ``$fontStyle``. See :ref:`font-style`.
- ``$paragraphStyle``. See :ref:`paragraph-style`.
- ``$text``. Text to be displayed in the document.
- ``$text``. Text to be displayed in the document. This can be `string` or a `\PhpOffice\PhpWord\Element\TextRun`
It's necessary to add a title style to your document because otherwise the title won't be detected as a real title.
@ -135,23 +145,28 @@ Text breaks are empty new lines. To add text breaks, use the following syntax. A
Page breaks
~~~~~~~~~~~
There are two ways to insert a page breaks, using the ``addPageBreak``
There are two ways to insert a page break, using the ``addPageBreak``
method or using the ``pageBreakBefore`` style of paragraph.
:: code-block:: php
.. code-block:: php
\\$section->addPageBreak();
$section->addPageBreak();
Lists
-----
To add a list item use the function ``addListItem``.
Lists can be added by using ``addListItem`` and ``addListItemRun`` methods.
``addListItem`` is used for creating lists that only contain plain text.
``addListItemRun`` is used for creating complex list items that contains texts
with different style (some bold, other italics, etc) or other elements, e.g.
images or links. The syntaxes are as follow:
Basic usage:
.. code-block:: php
$section->addListItem($text, [$depth], [$fontStyle], [$listStyle], [$paragraphStyle]);
$listItemRun = $section->addListItemRun([$depth], [$listStyle], [$paragraphStyle])
Parameters:
@ -159,9 +174,11 @@ Parameters:
- ``$depth``. Depth of list item.
- ``$fontStyle``. See :ref:`font-style`.
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\_Style\_ListItem.
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\\Style\\ListItem.
- ``$paragraphStyle``. See :ref:`paragraph-style`.
See ``Sample_09_Tables.php`` for more code sample.
Advanced usage:
You can also create your own numbering style by changing the ``$listStyle`` parameter with the name of your numbering style.
@ -232,7 +249,7 @@ To add an image, use the ``addImage`` method to sections, headers, footers, text
$section->addImage($src, [$style]);
- ``$src``. String path to a local image or URL of a remote image.
- ``$src``. String path to a local image, URL of a remote image or the image data, as a string. Warning: Do not pass user-generated strings here, as that would allow an attacker to read arbitrary files or perform server-side request forgery by passing file paths or URLs instead of image data.
- ``$style``. See :ref:`image-style`.
Examples:
@ -254,6 +271,8 @@ Examples:
$footer->addImage('http://example.com/image.php');
$textrun = $section->addTextRun();
$textrun->addImage('http://php.net/logo.jpg');
$source = file_get_contents('/path/to/my/images/earth.jpg');
$textrun->addImage($source);
Watermarks
~~~~~~~~~~
@ -272,11 +291,11 @@ Objects
-------
You can add OLE embeddings, such as Excel spreadsheets or PowerPoint
presentations to the document by using ``addObject`` method.
presentations to the document by using ``addOLEObject`` method.
.. code-block:: php
$section->addObject($src, [$style]);
$section->addOLEObject($src, [$style]);
Table of contents
-----------------
@ -295,9 +314,9 @@ Your TOC can only be generated if you have add at least one title (See "Titles")
Options for ``$tocStyle``:
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\_Style\_TOC.
- ``tabPos``. The position of the tab where the page number appears in twips.
- ``indent``. The indent factor of the titles in twips.
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in ``\PhpOffice\PhpWord\Style\TOC``.
- ``tabPos``. The position of the tab where the page number appears in *twip*.
- ``indent``. The indent factor of the titles in *twip*.
Footnotes & endnotes
--------------------
@ -305,7 +324,7 @@ Footnotes & endnotes
You can create footnotes with ``addFootnote`` and endnotes with
``addEndnote`` in texts or textruns, but it's recommended to use textrun
to have better layout. You can use ``addText``, ``addLink``,
``addTextBreak``, ``addImage``, ``addObject`` on footnotes and endnotes.
``addTextBreak``, ``addImage``, ``addOLEObject`` on footnotes and endnotes.
On textrun:
@ -331,11 +350,27 @@ On text:
$footnote = $section->addFootnote();
$footnote->addText('Footnote text.');
The footnote reference number will be displayed with decimal number
starting from 1. This number use ``FooterReference`` style which you can
redefine by ``addFontStyle`` method. Default value for this style is
By default the footnote reference number will be displayed with decimal number
starting from 1. This number uses the ``FooterReference`` style which you can
redefine with the ``addFontStyle`` method. Default value for this style is
``array('superScript' => true)``;
The footnote numbering can be controlled by setting the FootnoteProperties on the Section.
.. code-block:: php
$fp = new \PhpOffice\PhpWord\ComplexType\FootnoteProperties();
//sets the position of the footnote (pageBottom (default), beneathText, sectEnd, docEnd)
$fp->setPos(\PhpOffice\PhpWord\ComplexType\FootnoteProperties::POSITION_BENEATH_TEXT);
//set the number format to use (decimal (default), upperRoman, upperLetter, ...)
$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(\PhpOffice\PhpWord\ComplexType\FootnoteProperties::RESTART_NUMBER_EACH_PAGE);
//And finaly, set it on the Section
$section->setFootnoteProperties($fp);
Checkboxes
----------
@ -358,25 +393,120 @@ To be completed
Fields
------
To be completed
Currently the following fields are supported:
- PAGE
- NUMPAGES
- DATE
- XE
- INDEX
.. code-block:: php
$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 ``\``.
For instance for the INDEX field, you can do the following (See `Index Field for list of available options <https://support.office.com/en-us/article/Field-codes-Index-field-adafcf4a-cb30-43f6-85c7-743da1635d9e?ui=en-US&rs=en-US&ad=US>`_ ):
.. code-block:: php
//the $fieldText can be either a simple string
$fieldText = 'The index value';
//or a 'TextRun', to be able to format the text you want in the index
$fieldText = new TextRun();
$fieldText->addText('My ');
$fieldText->addText('bold index', ['bold' => true]);
$fieldText->addText(' entry');
$section->addField('XE', array(), array(), $fieldText);
//this actually adds the index
$section->addField('INDEX', array(), array('\\e " " \\h "A" \\c "3"'), 'right click to update index');
Line
------
----
Line elements can be added to sections by using ``addLine``.
.. code-block:: php
$linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552);
$section->addLine($lineStyle)
$lineStyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552);
$section->addLine($lineStyle);
Available line style attributes:
- ``weight``. Line width in twips.
- ``weight``. Line width in *twip*.
- ``color``. Defines the color of stroke.
- ``dash``. Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot.
- ``beginArrow``. Start type of arrow: block, open, classic, diamond, oval.
- ``endArrow``. End type of arrow: block, open, classic, diamond, oval.
- ``width``. Line-object width in pt.
- ``height``. Line-object height in pt.
- ``flip``. Flip the line element: true, false.
- ``width``. Line-object width in *pt*.
- ``height``. Line-object height in *pt*.
- ``flip``. Flip the line element: true, false.
Chart
-----
Charts can be added using
.. code-block:: php
$categories = array('A', 'B', 'C', 'D', 'E');
$series = array(1, 3, 2, 5, 4);
$chart = $section->addChart('line', $categories, $series, $style);
For available styling options see :ref:`chart-style`.
check out the Sample_32_Chart.php for more options and styling.
Comments
--------
Comments can be added to a document by using ``addComment``.
The comment can contain formatted text. Once the comment has been added, it can be linked to any element with ``setCommentStart``.
.. code-block:: php
// first create a comment
$comment= new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
$comment->addText('Test', array('bold' => true));
// add it to the document
$phpWord->addComment($comment);
$textrun = $section->addTextRun();
$textrun->addText('This ');
$text = $textrun->addText('is');
// link the comment to the text you just created
$text->setCommentStart($comment);
If no end is set for a comment using the ``setCommentEnd``, the comment will be ended automatically at the end of the element it is started on.
Track Changes
-------------
Track changes can be set on text elements. There are 2 ways to set the change information on an element.
Either by calling the `setChangeInfo()`, or by setting the `TrackChange` instance on the element with `setTrackChange()`.
.. code-block:: php
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// New portrait section
$section = $phpWord->addSection();
$textRun = $section->addTextRun();
$text = $textRun->addText('Hello World! Time to ');
$text = $textRun->addText('wake ', array('bold' => true));
$text->setChangeInfo(TrackChange::INSERTED, 'Fred', time() - 1800);
$text = $textRun->addText('up');
$text->setTrackChange(new TrackChange(TrackChange::INSERTED, 'Fred'));
$text = $textRun->addText('go to sleep');
$text->setChangeInfo(TrackChange::DELETED, 'Barney', new \DateTime('@' . (time() - 3600)));

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

@ -80,8 +80,8 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
Settings
--------
PHPWord Settings
----------------
The ``PhpOffice\PhpWord\Settings`` class provides some options that will
affect the behavior of PHPWord. Below are the options.
@ -109,8 +109,8 @@ Zip class
By default, PHPWord uses `Zip extension <http://php.net/manual/en/book.zip.php>`__
to deal with ZIP compressed archives and files inside them. If you can't have
Zip extension installed on your server, you can use pure PHP library
alternative, `PclZip <http://www.phpconcept.net/pclzip/>`__, which
included with PHPWord.
alternative, `PclZip <http://www.phpconcept.net/pclzip/>`__, which is
included in PHPWord.
.. code-block:: php
@ -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
~~~~~~~~~~~~
@ -141,6 +151,93 @@ default font by using the following two functions:
$phpWord->setDefaultFontName('Times New Roman');
$phpWord->setDefaultFontSize(12);
Document settings
-----------------
Settings for the generated document can be set using ``$phpWord->getSettings()``
Magnification Setting
~~~~~~~~~~~~~~~~~~~~~
The default zoom value is 100 percent. This can be changed either to another percentage
.. code-block:: php
$phpWord->getSettings()->setZoom(75);
Or to predefined values ``fullPage``, ``bestFit``, ``textFit``
.. code-block:: php
$phpWord->getSettings()->setZoom(Zoom::BEST_FIT);
Mirroring the Page Margins
~~~~~~~~~~~~~~~~~~~~~~~~~~
Use mirror margins to set up facing pages for double-sided documents, such as books or magazines.
.. code-block:: php
$phpWord->getSettings()->setMirrorMargins(true);
Spelling and grammatical checks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
By default spelling and grammatical errors are shown as soon as you open a word document.
For big documents this can slow down the opening of the document. You can hide the spelling and/or grammatical errors with:
.. code-block:: php
$phpWord->getSettings()->setHideGrammaticalErrors(true);
$phpWord->getSettings()->setHideSpellingErrors(true);
You can also specify the status of the spell and grammar checks, marking spelling or grammar as dirty will force a re-check when opening the document.
.. code-block:: php
$proofState = new \PhpOffice\PhpWord\ComplexType\ProofState();
$proofState->setGrammar(\PhpOffice\PhpWord\ComplexType\ProofState::CLEAN);
$proofState->setSpelling(\PhpOffice\PhpWord\ComplexType\ProofState::DIRTY);
$phpWord->getSettings()->setProofState($proofState);
Track Revisions
~~~~~~~~~~~~~~~
Track changes can be activated using ``setTrackRevisions``, you can furture specify
- Not to use move syntax, instead moved items will be seen as deleted in one place and added in another
- Not track formatting revisions
.. code-block:: php
$phpWord->getSettings()->setTrackRevisions(true);
$phpWord->getSettings()->setDoNotTrackMoves(true);
$phpWord->getSettings()->setDoNotTrackFormatting(true);
Decimal Symbol
~~~~~~~~~~~~~~
The default symbol to represent a decimal figure is the ``.`` in english. In french you might want to change it to ``,`` for instance.
.. code-block:: php
$phpWord->getSettings()->setDecimalSymbol(',');
Document Language
~~~~~~~~~~~~~~~~~
The default language of the document can be change with the following.
.. code-block:: php
$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\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.
.. code-block:: php
$lang = new Language();
$lang->setLangId(Language::EN_GB_ID);
$phpWord->getSettings()->setThemeFontLang($lang);
Document information
--------------------
@ -168,7 +265,7 @@ The base length unit in Open Office XML is twip. Twip means "TWentieth
of an Inch Point", i.e. 1 twip = 1/1440 inch.
You can use PHPWord helper functions to convert inches, centimeters, or
points to twips.
points to twip.
.. code-block:: php
@ -183,3 +280,65 @@ points to twips.
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
// 2 cm right margin
$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));
Document protection
-------------------
The document (or parts of it) can be password protected.
.. code-block:: php
$documentProtection = $phpWord->getSettings()->getDocumentProtection();
$documentProtection->setEditing(DocProtect::READ_ONLY);
$documentProtection->setPassword('myPassword');
Automatically Recalculate Fields on Open
----------------------------------------
To force an update of the fields present in the document, set updateFields to true
.. code-block:: php
$phpWord->getSettings()->setUpdateFields(true);
Hyphenation
-----------
Hyphenation describes the process of breaking words with hyphens. There are several options to control hyphenation.
Auto hyphenation
~~~~~~~~~~~~~~~~
To automatically hyphenate text set ``autoHyphenation`` to ``true``.
.. code-block:: php
$phpWord->getSettings()->setAutoHyphenation(true);
Consecutive Hyphen Limit
~~~~~~~~~~~~~~~~~~~~~~~~
The maximum number of consecutive lines of text ending with a hyphen can be controlled by the ``consecutiveHyphenLimit`` option.
There is no limit if the option is not set or the provided value is ``0``.
.. code-block:: php
$phpWord->getSettings()->setConsecutiveHyphenLimit(2);
Hyphenation Zone
~~~~~~~~~~~~~~~~
The hyphenation zone (in *twip*) is the allowed amount of whitespace before hyphenation is applied.
The smaller the hyphenation zone the more words are hyphenated. Or in other words, the wider the hyphenation zone the less words are hyphenated.
.. code-block:: php
$phpWord->getSettings()->setHyphenationZone(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(1));
Hyphenate Caps
~~~~~~~~~~~~~~
To control whether or not words in all capital letters shall be hyphenated use the `doNotHyphenateCaps` option.
.. code-block:: php
$phpWord->getSettings()->setDoNotHyphenateCaps(true);

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,32 +28,21 @@ 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.13.*"
}
}
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
{
"require": {
"phpoffice/phpword": "dev-develop"
}
}
.. code-block:: bash
composer require phpoffice/phpword:dev-master
Using samples
-------------
After installation, you can browse and use the samples that we've
provided, either by command line or using browser. If you can access
your PHPWord library folder using browser, point your browser to the
``samples`` folder, e.g. ``http://localhost/PhpWord/samples/``.
More examples are provided in the ``samples`` directory.
For an easy access to those samples launch ``php -S localhost:8000`` in the samples directory then browse to http://localhost:8000 to view the samples.

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
--------
@ -49,6 +46,7 @@ Features
- Insert drawing shapes (arc, curve, line, polyline, rect, oval)
- Insert charts (pie, doughnut, bar, line, area, scatter, radar)
- Insert form fields (textinput, checkbox, and dropdown)
- Insert comments
- Create document from templates
- Use XSL 1.0 style sheets to transform headers, main document part, and footers of an OOXML template
- ... and many more features on progress
@ -102,6 +100,8 @@ Writers
+---------------------------+----------------------+--------+-------+-------+--------+-------+
| | Endnote | ✓ | | | ✓ | |
+---------------------------+----------------------+--------+-------+-------+--------+-------+
| | Comments | ✓ | | | | |
+---------------------------+----------------------+--------+-------+-------+--------+-------+
| **Graphs** | 2D basic graphs | ✓ | | | | |
+---------------------------+----------------------+--------+-------+-------+--------+-------+
| | 2D advanced graphs | | | | | |
@ -161,6 +161,8 @@ Readers
+---------------------------+----------------------+--------+-------+-------+-------+-------+
| | Endnote | ✓ | | | | |
+---------------------------+----------------------+--------+-------+-------+-------+-------+
| | Comments | | | | | |
+---------------------------+----------------------+--------+-------+-------+-------+-------+
| **Graphs** | 2D basic graphs | | | | | |
+---------------------------+----------------------+--------+-------+-------+-------+-------+
| | 2D advanced graphs | | | | | |
@ -186,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

@ -4,7 +4,7 @@ References
==========
ISO/IEC 29500, Third edition, 2012-09-01
---------------------
----------------------------------------
- `Part 1: Fundamentals and Markup Language Reference
<http://standards.iso.org/ittf/PubliclyAvailableStandards/c061750_ISO_IEC_29500-1_2012.zip>`__

View File

@ -11,26 +11,29 @@ Section
Available Section style options:
- ``borderBottomColor``. Border bottom color.
- ``borderBottomSize``. Border bottom size (in twips).
- ``borderBottomSize``. Border bottom size in *twip*.
- ``borderLeftColor``. Border left color.
- ``borderLeftSize``. Border left size (in twips).
- ``borderLeftSize``. Border left size in *twip*.
- ``borderRightColor``. Border right color.
- ``borderRightSize``. Border right size (in twips).
- ``borderRightSize``. Border right size in *twip*.
- ``borderTopColor``. Border top color.
- ``borderTopSize``. Border top size (in twips).
- ``borderTopSize``. Border top size in *twip*.
- ``breakType``. Section break type (nextPage, nextColumn, continuous, evenPage, oddPage).
- ``colsNum``. Number of columns.
- ``colsSpace``. Spacing between columns.
- ``footerHeight``. Spacing to bottom of footer.
- ``gutter``. Page gutter spacing.
- ``headerHeight``. Spacing to top of header.
- ``marginTop``. Page margin top (in twips).
- ``marginLeft``. Page margin left (in twips).
- ``marginRight``. Page margin right (in twips).
- ``marginBottom``. Page margin bottom (in twips).
- ``marginTop``. Page margin top in *twip*.
- ``marginLeft``. Page margin left in *twip*.
- ``marginRight``. Page margin right in *twip*.
- ``marginBottom``. Page margin bottom in *twip*.
- ``orientation``. Page orientation (``portrait``, which is default, or ``landscape``).
- ``pageSizeH``. Page height (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
- ``pageSizeW``. Page width (in twips). Implicitly defined by ``orientation`` option. Any changes are discouraged.
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:
@ -45,6 +48,7 @@ Available Font style options:
- ``color``. Font color, e.g. *FF0000*.
- ``doubleStrikethrough``. Double strikethrough, *true* or *false*.
- ``fgColor``. Font highlight color, e.g. *yellow*, *green*, *blue*.
See ``\PhpOffice\PhpWord\Style\Font::FGCOLOR_...`` class constants for possible values
- ``hint``. Font content type, *default*, *eastAsia*, or *cs*.
- ``italic``. Italic, *true* or *false*.
- ``name``. Font name, e.g. *Arial*.
@ -54,7 +58,12 @@ Available Font style options:
- ``strikethrough``. Strikethrough, *true* or *false*.
- ``subScript``. Subscript, *true* or *false*.
- ``superScript``. Superscript, *true* or *false*.
- ``underline``. Underline, *dash*, *dotted*, etc.
- ``underline``. Underline, *single*, *dash*, *dotted*, etc.
See ``\PhpOffice\PhpWord\Style\Font::UNDERLINE_...`` class constants for possible values
- ``lang``. Language, either a language code like *en-US*, *fr-BE*, etc. or an object (or as an array) if you need to set eastAsian or bidirectional languages
See ``\PhpOffice\PhpWord\Style\Language`` class for some language codes.
- ``position``. The text position, raised or lowered, in half points
- ``hidden``. Hidden text, *true* or *false*.
.. _paragraph-style:
@ -64,19 +73,30 @@ Paragraph
Available Paragraph style options:
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values.
- ``basedOn``. Parent style.
- ``hanging``. Hanging by how much.
- ``indent``. Indent by how much.
- ``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.
- ``next``. Style for next paragraph.
- ``pageBreakBefore``. Start paragraph on next page, *true* or *false*.
- ``spaceBefore``. Space before paragraph.
- ``spaceAfter``. Space after paragraph.
- ``spaceBefore``. Space before paragraph in *twip*.
- ``spaceAfter``. Space after paragraph in *twip*.
- ``spacing``. Space between lines in *twip*. If spacingLineRule is auto, 240 (height of 1 line) will be added, so if you want a double line height, set this to 240.
- ``spacingLineRule``. Line Spacing Rule. *auto*, *exact*, *atLeast*
See ``\PhpOffice\PhpWord\SimpleType\LineSpacingRule`` class constants for possible values.
- ``suppressAutoHyphens``. Hyphenation for paragraph, *true* or *false*.
- ``tabs``. Set of custom tab stops.
- ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*.
- ``contextualSpacing``. Ignore Spacing Above and Below When Using Identical Styles, *true* or *false*.
- ``bidi``. Right to Left Paragraph Layout, *true* or *false*.
- ``shading``. Paragraph Shading.
- ``textAlignment``. Vertical Character Alignment on Line.
See ``\PhpOffice\PhpWord\SimpleType\TextAlignment`` class constants for possible values.
.. _table-style:
@ -86,12 +106,31 @@ Table
Available Table style options:
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values.
- ``bgColor``. Background color, e.g. '9966CC'.
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
- ``cellMargin(Top|Right|Bottom|Left)``. Cell margin in twips.
- ``width``. Table width in percent.
- ``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 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:
- ``leftFromText`` Distance From Left of Table to Text in *twip*
- ``rightFromText`` Distance From Right of Table to Text in *twip*
- ``topFromText`` Distance From Top of Table to Text in *twip*
- ``bottomFromText`` Distance From Top of Table to Text in *twip*
- ``vertAnchor`` Table Vertical Anchor, one of ``\PhpOffice\PhpWord\Style\TablePosition::VANCHOR_*``
- ``horzAnchor`` Table Horizontal Anchor, one of ``\PhpOffice\PhpWord\Style\TablePosition::HANCHOR_*``
- ``tblpXSpec`` Relative Horizontal Alignment From Anchor, one of ``\PhpOffice\PhpWord\Style\TablePosition::XALIGN_*``
- ``tblpX`` Absolute Horizontal Distance From Anchorin *twip*
- ``tblpYSpec`` Relative Vertical Alignment From Anchor, one of ``\PhpOffice\PhpWord\Style\TablePosition::YALIGN_*``
- ``tblpY`` Absolute Vertical Distance From Anchorin *twip*
Available Row style options:
@ -103,12 +142,14 @@ Available Cell style options:
- ``bgColor``. Background color, e.g. '9966CC'.
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
- ``border(Top|Right|Bottom|Left)Size``. Border size in *twip*.
- ``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``
- ``textDirection(btLr|tbRl)``. Direction of text.
You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
- ``vMerge``. *restart* or *continue*.
- ``width``. Cell width in twips.
- ``width``. Cell width in *twip*.
.. _image-style:
@ -118,11 +159,15 @@ Image
Available Image style options:
- ``alignment``. See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
- ``height``. Height in pixels.
- ``height``. Height in *pt*.
- ``marginLeft``. Left margin in inches, can be negative.
- ``marginTop``. Top margin in inches, can be negative.
- ``width``. Width in pixels.
- ``width``. Width in *pt*.
- ``wrappingStyle``. Wrapping style, *inline*, *square*, *tight*, *behind*, or *infront*.
- ``wrapDistanceTop``. Top text wrapping in pixels.
- ``wrapDistanceBottom``. Bottom text wrapping in pixels.
- ``wrapDistanceLeft``. Left text wrapping in pixels.
- ``wrapDistanceRight``. Right text wrapping in pixels.
.. _numbering-level-style:
@ -132,7 +177,7 @@ Numbering level
Available NumberingLevel style options:
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values.
- ``font``. Font name.
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
- ``hanging``. See paragraph style.
@ -143,3 +188,26 @@ See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
- ``suffix``. Content between numbering symbol and paragraph text tab\|space\|nothing.
- ``tabPos``. See paragraph style.
- ``text``. Numbering level text e.g. %1 for nonbullet or bullet character.
.. _chart-style:
Chart
-----
Available Chart style options:
- ``width``. Width (in EMU).
- ``height``. Height (in EMU).
- ``3d``. Is 3D; applies to pie, bar, line, area, *true* or *false*.
- ``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.
- ``valueAxisTitle``. The title for the values axis.
- ``majorTickMarkPos``. The position for major tick marks, *in*, *out*, *cross*, *none* (default).
- ``showAxisLabels``. Show labels for axis, *true* or *false*.
- ``gridX``. Show Gridlines for X-Axis, *true* or *false*.
- ``gridY``. Show Gridlines for Y-Axis, *true* or *false*.

View File

@ -4,22 +4,300 @@ 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.
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.
To deal with a template file, use ``new TemplateProcessor`` statement. After TemplateProcessor instance creation the document template is copied into the temporary directory. Then you can use ``TemplateProcessor::setValue`` method to change the value of a search pattern. The search-pattern model is: ``${search-pattern}``.
.. code-block:: php
$templateProcessor = new TemplateProcessor('Template.docx');
setValue
""""""""
Given a template containing
.. code-block:: clean
Hello ${firstname} ${lastname}!
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('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
"""""""""""""
The search-pattern model for images can be like:
- ``${search-image-pattern}``
- ``${search-image-pattern:[width]:[height]:[ratio]}``
- ``${search-image-pattern:[width]x[height]}``
- ``${search-image-pattern:size=[width]x[height]}``
- ``${search-image-pattern:width=[width]:height=[height]:ratio=false}``
Where:
- [width] and [height] can be just numbers or numbers with measure, which supported by Word (cm, mm, in, pt, pc, px, %, em, ex)
- [ratio] uses only for ``false``, ``-`` or ``f`` to turn off respect aspect ration of image. By default template image size uses as 'container' size.
Example:
.. code-block:: clean
${CompanyLogo}
${UserLogo:50:50} ${Name} - ${City} - ${Street}
.. code-block:: php
$templateProcessor = new TemplateProcessor('Template.docx');
$templateProcessor->setValue('Name', 'John Doe');
$templateProcessor->setValue(array('City', 'Street'), array('Detroit', '12th Street'));
It is not possible to directly add new OOXML elements to the template file being processed, but it is possible to transform headers, main document part, and footers of the template using XSLT (see ``TemplateProcessor::applyXslStyleSheet``).
$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
See ``Sample_07_TemplateCloneRow.php`` for example on how to create
multirow from a single row in a template by using ``TemplateProcessor::cloneRow``.
return array('path' => SlowFeatureImageGenerator::make(), 'width' => 100, 'height' => 100, 'ratio' => false);
});
See ``Sample_23_TemplateBlock.php`` for example on how to clone a block
of text using ``TemplateProcessor::cloneBlock`` and delete a block of text using
``TemplateProcessor::deleteBlock``.
cloneBlock
""""""""""
Given a template containing
See ``Sample_23_TemplateBlock.php`` for an example.
.. code-block:: clean
${block_name}
Customer: ${customer_name}
Address: ${customer_address}
${/block_name}
The following will duplicate everything between ``${block_name}`` and ``${/block_name}`` 3 times.
.. code-block:: php
$templateProcessor->cloneBlock('block_name', 3, true, true);
The last parameter will rename any macro defined inside the block and add #1, #2, #3 ... to the macro name.
The result will be
.. code-block:: clean
Customer: ${customer_name#1}
Address: ${customer_address#1}
Customer: ${customer_name#2}
Address: ${customer_address#2}
Customer: ${customer_name#3}
Address: ${customer_address#3}
It is also possible to pass an array with the values to replace the marcros with.
If an array with replacements is passed, the ``count`` argument is ignored, it is the size of the array that counts.
.. code-block:: php
$replacements = array(
array('customer_name' => 'Batman', 'customer_address' => 'Gotham City'),
array('customer_name' => 'Superman', 'customer_address' => 'Metropolis'),
);
$templateProcessor->cloneBlock('block_name', 0, true, false, $replacements);
The result will then be
.. code-block:: clean
Customer: Batman
Address: Gotham City
Customer: Superman
Address: Metropolis
replaceBlock
""""""""""""
Given a template containing
.. code-block:: clean
${block_name}
This block content will be replaced
${/block_name}
The following will replace everything between ``${block_name}`` and ``${/block_name}`` with the value passed.
.. code-block:: php
$templateProcessor->replaceBlock('block_name', 'This is the replacement text.');
deleteBlock
"""""""""""
Same as previous, but it deletes the block
.. code-block:: php
$templateProcessor->deleteBlock('block_name');
cloneRow
""""""""
Clones a table row in a template document.
See ``Sample_07_TemplateCloneRow.php`` for an example.
.. code-block:: clean
+-----------+----------------+
| ${userId} | ${userName} |
| |----------------+
| | ${userAddress} |
+-----------+----------------+
.. code-block:: php
$templateProcessor->cloneRow('userId', 2);
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
""""""""""""""""""
Applies the XSL stylesheet passed to header part, footer part and main part
.. code-block:: php
$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>

13
phpstan.neon Normal file
View File

@ -0,0 +1,13 @@
includes:
- vendor/phpstan/phpstan/conf/config.level1.neon
parameters:
memory-limit: 20000000
autoload_directories:
- tests
autoload_files:
- tests/bootstrap.php
excludes_analyse:
- */pclzip.lib.php
- src/PhpWord/Shared/OLERead.php
- src/PhpWord/Reader/MsDoc.php
- src/PhpWord/Writer/PDF/MPDF.php

View File

@ -6,23 +6,18 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
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" charset="UTF-8" highlight="true" />
<log type="coverage-clover" target="./build/logs/clover.xml" />
</logging>
</phpunit>
</phpunit>

View File

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

View File

@ -1,17 +1,24 @@
<?php
use PhpOffice\PhpWord\Style\Font;
include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
$languageEnGb = new \PhpOffice\PhpWord\Style\Language(\PhpOffice\PhpWord\Style\Language::EN_GB);
$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();
@ -20,6 +27,10 @@ $section = $phpWord->addSection();
$section->addTitle('Welcome to PhpWord', 1);
$section->addText('Hello World!');
// $pStyle = new Font();
// $pStyle->setLang()
$section->addText('Ce texte-ci est en français.', ['lang' => \PhpOffice\PhpWord\Style\Language::FR_BE]);
// Two text break
$section->addTextBreak(2);
@ -37,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
@ -71,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,19 +27,22 @@ $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.', ['hidden' => true]);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {

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,8 @@
<?php
use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
use PhpOffice\PhpWord\SimpleType\NumberFormat;
include_once 'Sample_Header.php';
// New Word Document
@ -8,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();
@ -35,18 +39,22 @@ $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.');
$section->addText(
'You can also create the footnote directly from the section making it wrap in a paragraph '
. 'like the footnote below this paragraph. But is is best used from within a textrun.'
. 'like the footnote below this paragraph. But is best used from within a textrun.'
);
$footnote = $section->addFootnote();
$footnote->addText('The reference for this is wrapped in its own line');
$footnoteProperties = new FootnoteProperties();
$footnoteProperties->setNumFmt(NumberFormat::DECIMAL_ENCLOSED_CIRCLE);
$section->setFootnoteProperties($footnoteProperties);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {

View File

@ -1,62 +1,87 @@
<?php
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_07_TemplateCloneRow.docx');
// Variables on different parts of document
$templateProcessor->setValue('weekday', date('l')); // On section/content
$templateProcessor->setValue('time', date('H:i')); // On footer
$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
// Simple table
$templateProcessor->cloneRow('rowValue', 10);
$templateProcessor->setValue('rowValue#1', 'Sun');
$templateProcessor->setValue('rowValue#2', 'Mercury');
$templateProcessor->setValue('rowValue#3', 'Venus');
$templateProcessor->setValue('rowValue#4', 'Earth');
$templateProcessor->setValue('rowValue#5', 'Mars');
$templateProcessor->setValue('rowValue#6', 'Jupiter');
$templateProcessor->setValue('rowValue#7', 'Saturn');
$templateProcessor->setValue('rowValue#8', 'Uranus');
$templateProcessor->setValue('rowValue#9', 'Neptun');
$templateProcessor->setValue('rowValue#10', 'Pluto');
$templateProcessor->setValue('rowNumber#1', '1');
$templateProcessor->setValue('rowNumber#2', '2');
$templateProcessor->setValue('rowNumber#3', '3');
$templateProcessor->setValue('rowNumber#4', '4');
$templateProcessor->setValue('rowNumber#5', '5');
$templateProcessor->setValue('rowNumber#6', '6');
$templateProcessor->setValue('rowNumber#7', '7');
$templateProcessor->setValue('rowNumber#8', '8');
$templateProcessor->setValue('rowNumber#9', '9');
$templateProcessor->setValue('rowNumber#10', '10');
// Table with a spanned cell
$templateProcessor->cloneRow('userId', 3);
$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'));
if (!CLI) {
include_once 'Sample_Footer.php';
}
<?php
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_07_TemplateCloneRow.docx');
// Variables on different parts of document
$templateProcessor->setValue('weekday', date('l')); // On section/content
$templateProcessor->setValue('time', date('H:i')); // On footer
$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
// Simple table
$templateProcessor->cloneRow('rowValue', 10);
$templateProcessor->setValue('rowValue#1', 'Sun');
$templateProcessor->setValue('rowValue#2', 'Mercury');
$templateProcessor->setValue('rowValue#3', 'Venus');
$templateProcessor->setValue('rowValue#4', 'Earth');
$templateProcessor->setValue('rowValue#5', 'Mars');
$templateProcessor->setValue('rowValue#6', 'Jupiter');
$templateProcessor->setValue('rowValue#7', 'Saturn');
$templateProcessor->setValue('rowValue#8', 'Uranus');
$templateProcessor->setValue('rowValue#9', 'Neptun');
$templateProcessor->setValue('rowValue#10', 'Pluto');
$templateProcessor->setValue('rowNumber#1', '1');
$templateProcessor->setValue('rowNumber#2', '2');
$templateProcessor->setValue('rowNumber#3', '3');
$templateProcessor->setValue('rowNumber#4', '4');
$templateProcessor->setValue('rowNumber#5', '5');
$templateProcessor->setValue('rowNumber#6', '6');
$templateProcessor->setValue('rowNumber#7', '7');
$templateProcessor->setValue('rowNumber#8', '8');
$templateProcessor->setValue('rowNumber#9', '9');
$templateProcessor->setValue('rowNumber#10', '10');
// Table with a spanned cell
$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->cloneRowAndSetValues('userId', $values);
//this is equivalent to cloning and settings values with cloneRowAndSetValues
// $templateProcessor->cloneRow('userId', 3);
// $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(['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,11 +1,15 @@
<?php
use PhpOffice\PhpWord\Shared\Converter;
use PhpOffice\PhpWord\Style\TablePosition;
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. Basic table
@ -14,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}");
}
}
@ -27,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);
$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);
@ -40,17 +44,17 @@ $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}");
$table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}");
$text = (0== $i % 2) ? 'X' : '';
$text = (0 == $i % 2) ? 'X' : '';
$table->addCell(500)->addText($text);
}
/**
/*
* 3. colspan (gridSpan) and rowspan (vMerge)
* ---------------------
* | | B | |
@ -62,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);
@ -93,7 +97,7 @@ $table->addCell(2000, $cellVCentered)->addText('C', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered);
$table->addCell(null, $cellRowContinue);
/**
/*
* 4. colspan (gridSpan) and rowspan (vMerge)
* ---------------------
* | | B | 1 |
@ -104,6 +108,7 @@ $table->addCell(null, $cellRowContinue);
* ---------------------
* @see https://github.com/PHPOffice/PHPWord/issues/806
*/
$section->addPageBreak();
$section->addText('Table with colspan and rowspan', $header);
@ -112,32 +117,41 @@ $phpWord->addTableStyle('Colspan Rowspan', $styleTable);
$table = $section->addTable('Colspan Rowspan');
$row = $table->addRow();
$row->addCell(null, ['vMerge' => 'restart'])->addText('A');
$row->addCell(null, ['gridSpan' => 2, 'vMerge' => 'restart',])->addText('B');
$row->addCell()->addText('1');
$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(null, ['vMerge' => 'continue']);
$row->addCell(null, ['vMerge' => 'continue','gridSpan' => 2,]);
$row->addCell()->addText('2');
$row->addCell(1000, ['vMerge' => 'continue']);
$row->addCell(1000, ['vMerge' => 'continue', 'gridSpan' => 2]);
$row->addCell(1000)->addText('2');
$row = $table->addRow();
$row->addCell(null, ['vMerge' => 'continue']);
$row->addCell()->addText('C');
$row->addCell()->addText('D');
$row->addCell()->addText('3');
$row->addCell(1000, ['vMerge' => 'continue']);
$row->addCell(1000)->addText('C');
$row->addCell(1000)->addText('D');
$row->addCell(1000)->addText('3');
// 5. Nested table
$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
$section->addTextBreak(2);
$section->addText('Table with floating positioning.', $header);
$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.');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {

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'));
$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
@ -7,13 +8,8 @@ $source = "resources/{$name}.doc";
echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'MsDoc');
// (Re)write contents
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}
include_once 'Sample_Footer.php';

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,8 @@
<?php
use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Shared\Converter;
include_once 'Sample_Header.php';
// New Word document
@ -9,71 +13,88 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addText('Local image without any styles:');
$section->addImage('resources/_mars.jpg');
$section->addTextBreak(2);
printSeparator($section);
$section->addText('Local image with styles:');
$section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
$section->addTextBreak(2);
$section->addImage('resources/_earth.jpg', ['width' => 210, 'height' => 210, 'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER]);
// Remote image
printSeparator($section);
$source = 'http://php.net/images/logos/php-med-trans-light.gif';
$section->addText("Remote image from: {$source}");
$section->addImage($source);
// Image from string
printSeparator($section);
$source = 'resources/_mars.jpg';
$fileContent = file_get_contents($source);
$section->addText('Image from string');
$section->addImage($fileContent);
//Wrapping style
$text = str_repeat('Hello World! ', 15);
$wrappingStyles = array('inline', 'behind', 'infront', 'square', 'tight');
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 = ['inline', 'behind', 'infront', 'square', 'tight'];
foreach ($wrappingStyles as $wrappingStyle) {
$section->addTextBreak(5);
$section->addText("Wrapping style {$wrappingStyle}");
$section->addImage(
'resources/_earth.jpg',
array(
'positioning' => 'relative',
'marginTop' => -1,
'marginLeft' => 1,
'width' => 80,
'height' => 80,
[
'positioning' => 'relative',
'marginTop' => -1,
'marginLeft' => 1,
'width' => 80,
'height' => 80,
'wrappingStyle' => $wrappingStyle,
)
'wrapDistanceRight' => Converter::cmToPoint(1),
'wrapDistanceBottom' => Converter::cmToPoint(1),
]
);
$section->addText($text);
printSeparator($section);
}
//Absolute positioning
$section->addTextBreak(3);
$section->addText('Absolute positioning: see top right corner of page');
$section->addImage(
'resources/_mars.jpg',
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
$section->addTextBreak(3);
printSeparator($section);
$section->addText('Relative positioning: Horizontal position center relative to column,');
$section->addText('Vertical position top relative to line');
$section->addImage(
'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): void
{
$section->addTextBreak();
$lineStyle = ['weight' => 0.2, 'width' => 150, 'height' => 0, 'align' => 'center'];
$section->addLine($lineStyle);
$section->addTextBreak(2);
}
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {

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,30 +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 = $section->addListItemRun();
$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
@ -9,7 +10,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addText('You can open this OLE object by double clicking on the icon:');
$section->addTextBreak(2);
$section->addObject('resources/_sheet.xls');
$section->addOLEObject('resources/_sheet.xls');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);

View File

@ -1,23 +1,26 @@
<?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->getSettings()->setUpdateFields(true);
// New section
$section = $phpWord->addSection();
// Define styles
$fontStyle12 = array('spaceAfter' => 60, 'size' => 12);
$fontStyle10 = array('size' => 10);
$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->addText('Table of contents 1');
$section->addTitle('Table of contents 1', 0);
$section->addTextBreak(2);
// Add TOC #1

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'));
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,20 +1,99 @@
<?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', ['alignment' => 'center']);
$section = $phpWord->addSection();
$html = '<h1>Adding element via HTML</h1>';
$html .= '<p>Some well formed HTML snippet needs to be used</p>';
$html .= '<p>Some well-formed HTML snippet needs to be used</p>';
$html .= '<p>With for example <strong>some<sup>1</sup> <em>inline</em> formatting</strong><sub>1</sub></p>';
$html .= '<p>Unordered (bulleted) list:</p>';
$html .= '<ul><li>Item 1</li><li>Item 2</li><ul><li>Item 2.1</li><li>Item 2.1</li></ul></ul>';
$html .= '<p>Ordered (numbered) list:</p>';
$html .= '<ol><li>Item 1</li><li>Item 2</li></ol>';
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);
$html .= '<p>A link to <a href="http://phpword.readthedocs.io/" style="text-decoration: underline">Read the docs</a></p>';
$html .= '<p lang="he-IL" style="text-align: right; direction: rtl">היי, זה פסקה מימין לשמאל</p>';
$html .= '<p style="margin-top: 240pt;">Unordered (bulleted) list:</p>';
$html .= '<ul><li>Item 1</li><li>Item 2</li><ul><li>Item 2.1</li><li>Item 2.1</li></ul></ul>';
$html .= '<p style="margin-top: 240pt;">1.5 line height with first line text indent:</p>';
$html .= '<p style="text-align: justify; text-indent: 70.9pt; line-height: 150%;">Lorem ipsum dolor sit amet, <strong>consectetur adipiscing elit</strong>, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>';
$html .= '<h2 style="align: center">centered title</h2>';
$html .= '<p style="margin-top: 240pt;">Ordered (numbered) list:</p>';
$html .= '<ol>
<li><p style="font-weight: bold;">List 1 item 1</p></li>
<li>List 1 item 2</li>
<ol>
<li>sub list 1</li>
<li>sub list 2</li>
</ol>
<li>List 1 item 3</li>
</ol>
<p style="margin-top: 15px;">A second list, numbering should restart</p>
<ol>
<li>List 2 item 1</li>
<li>List 2 item 2</li>
<li>
<ol>
<li>sub list 1</li>
<li>sub list 2</li>
</ol>
</li>
<li>List 2 item 3</li>
<ol>
<li>sub list 1, restarts with a</li>
<li>sub list 2</li>
</ol>
</ol>';
$html .= '<p style="margin-top: 240pt;">List with formatted content:</p>';
$html .= '<ul>
<li>
<span style="font-family: arial,helvetica,sans-serif;">
<span style="font-size: 16px;">big list item1</span>
</span>
</li>
<li>
<span style="font-family: arial,helvetica,sans-serif;">
<span style="font-size: 10px; font-weight: bold;">list item2 in bold</span>
</span>
</li>
</ul>';
$html .= '<p style="margin-top: 240pt;">A table with formatting:</p>';
$html .= '<table align="center" style="width: 50%; border: 6px #0000FF double;">
<thead>
<tr style="background-color: #FF0000; text-align: center; color: #FFFFFF; font-weight: bold; ">
<th style="width: 50pt">header a</th>
<th style="width: 50">header b</th>
<th style="background-color: #FFFF00; border-width: 12px"><span style="background-color: #00FF00;">header c</span></th>
</tr>
</thead>
<tbody>
<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>';
$html .= '<p style="margin-top: 240pt;">Table inside another table:</p>';
$html .= '<table align="center" style="width: 80%; border: 6px #0000FF double;">
<tr><td>
<table style="width: 100%; border: 4px #FF0000 dotted;">
<tr><td>column 1</td><td>column 2</td></tr>
</table>
</td></tr>
<tr><td style="text-align: center;">Cell in parent table</td></tr>
</table>';
$html .= '<p style="margin-top: 240pt;">The text below is not visible, click on show/hide to reveil it:</p>';
$html .= '<p style="display: none">This is hidden text</p>';
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html, false, false);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);

View File

@ -1,28 +1,68 @@
<?php
use PhpOffice\PhpWord\Element\TextRun;
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, ['size' => 14]);
// New section
$section = $phpWord->addSection();
$section->addTitle('This page demos fields');
// Add Field elements
// See Element/Field.php for all options
$section->addText('Date field:');
$section->addField('DATE', array('dateformat' => 'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat'));
$section->addField('DATE', ['dateformat' => 'dddd d MMMM yyyy H:mm:ss'], ['PreserveFormat']);
$section->addText('Style Ref field:');
$section->addField('STYLEREF', ['StyleIdentifier' => 'Heading 1']);
$section->addText('Page field:');
$section->addField('PAGE', array('format' => 'ArabicDash'));
$section->addField('PAGE', ['format' => 'Arabic']);
$section->addText('Number of pages field:');
$section->addField('NUMPAGES', array('format' => 'Arabic', 'numformat' => '0,00'), array('PreserveFormat'));
$section->addField('NUMPAGES', ['numformat' => '0,00', 'format' => 'Arabic'], ['PreserveFormat']);
$section->addTextBreak();
$textrun = $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER));
$textrun = $section->addTextRun();
$textrun->addText('An index field is ');
$textrun->addField('XE', [], ['Italic'], 'My first index');
$textrun->addText('here:');
$indexEntryText = new TextRun();
$indexEntryText->addText('My ');
$indexEntryText->addText('bold index', ['bold' => true]);
$indexEntryText->addText(' entry');
$textrun = $section->addTextRun();
$textrun->addText('A complex index field is ');
$textrun->addField('XE', [], ['Bold'], $indexEntryText);
$textrun->addText('here:');
$section->addText('The actual index:');
$section->addField('INDEX', [], ['\\e " "'], 'right click to update the index');
$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', ['bold' => true]);
$macroText->addText(' to ');
$macroText->addText('zoom to 100%', ['italic' => true]);
$section->addText('A macro button with styled text:');
$section->addField('MACROBUTTON', ['macroname' => 'Zoom100'], [], $macroText);
$section->addTextBreak();
$section->addText('A macro button with simple text:');
$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,26 +9,36 @@ 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');
$twoSeries = array('bar', 'column', 'line', 'area', 'scatter', 'radar');
$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);
$chart = $section->addChart($chartType, $categories, $series1);
$chart->getStyle()->setWidth(Converter::inchToEmu(2.5))->setHeight(Converter::inchToEmu(2));
$chart->getStyle()->setShowGridX($showGridLines);
$chart->getStyle()->setShowGridY($showGridLines);
$chart->getStyle()->setShowAxisLabels($showAxisLabels);
$chart->getStyle()->setShowLegend($showLegend);
$chart->getStyle()->setLegendPosition($legendPosition);
if (in_array($chartType, $twoSeries)) {
$chart->addSeries($categories, $series2);
}
@ -38,13 +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,
];
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,15 +11,21 @@ $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: ');
$textrun->addSDT('date');
$textrun->addTextBreak(1);
$textrun->addText('Date with pre set value: ');
$textrun->addSDT('date')->setValue('03/30/2017');
$textrun->addTextBreak(1);
$textrun->addText('Date with pre set value: ');
$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'));
$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

@ -0,0 +1,63 @@
<?php
include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// A comment
$comment = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
$comment->addText('Test', ['bold' => true]);
$phpWord->addComment($comment);
$section = $phpWord->addSection();
$textrun = $section->addTextRun();
$textrun->addText('This ');
$text = $textrun->addText('is');
$text->setCommentRangeStart($comment);
$textrun->addText(' a test');
$section->addTextBreak(2);
// Let's create a comment that we will link to a start element and an end element
$commentWithStartAndEnd = new \PhpOffice\PhpWord\Element\Comment('Foo Bar', new \DateTime());
$commentWithStartAndEnd->addText('A comment with a start and an end');
$phpWord->addComment($commentWithStartAndEnd);
$textrunWithEnd = $section->addTextRun();
$textrunWithEnd->addText('This ');
$textToStartOn = $textrunWithEnd->addText('is', ['bold' => true]);
$textToStartOn->setCommentRangeStart($commentWithStartAndEnd);
$textrunWithEnd->addText(' another', ['italic' => true]);
$textToEndOn = $textrunWithEnd->addText(' test');
$textToEndOn->setCommentRangeEnd($commentWithStartAndEnd);
$section->addTextBreak(2);
// Let's add a comment on an image
$commentOnImage = new \PhpOffice\PhpWord\Element\Comment('Mr Smart', new \DateTime());
$imageComment = $commentOnImage->addTextRun();
$imageComment->addText('Hey, Mars does look ');
$imageComment->addText('red', ['color' => 'FF0000']);
$phpWord->addComment($commentOnImage);
$image = $section->addImage('resources/_mars.jpg');
$image->setCommentRangeStart($commentOnImage);
$section->addTextBreak(2);
// We can also do things the other way round, link the comment to the element
$anotherText = $section->addText('another text');
$comment1 = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
$comment1->addText('Test', ['bold' => true]);
$comment1->setStartElement($anotherText);
$comment1->setEndElement($anotherText);
$phpWord->addComment($comment1);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}

View File

@ -0,0 +1,22 @@
<?php
use PhpOffice\PhpWord\SimpleType\DocProtect;
include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$documentProtection = $phpWord->getSettings()->getDocumentProtection();
$documentProtection->setEditing(DocProtect::READ_ONLY);
$documentProtection->setPassword('myPassword');
$section = $phpWord->addSection();
$section->addText('this document is password protected');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}

View File

@ -0,0 +1,30 @@
<?php
use PhpOffice\PhpWord\Element\TrackChange;
include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// New portrait section
$section = $phpWord->addSection();
$textRun = $section->addTextRun();
$text = $textRun->addText('Hello World! Time to ');
$text = $textRun->addText('wake ', ['bold' => true]);
$text->setChangeInfo(TrackChange::INSERTED, 'Fred', time() - 1800);
$text = $textRun->addText('up');
$text->setTrackChange(new TrackChange(TrackChange::INSERTED, 'Fred'));
$text = $textRun->addText('go to sleep');
$text->setChangeInfo(TrackChange::DELETED, 'Barney', new \DateTime('@' . (time() - 3600)));
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}

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

@ -12,8 +12,14 @@ define('IS_INDEX', SCRIPT_FILENAME == 'index');
Settings::loadConfig();
$dompdfPath = $vendorDirPath . '/dompdf/dompdf';
if (file_exists($dompdfPath)) {
define('DOMPDF_ENABLE_AUTOLOAD', false);
Settings::setPdfRenderer(Settings::PDF_RENDERER_DOMPDF, $vendorDirPath . '/dompdf/dompdf');
}
// 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()) {
@ -37,17 +43,23 @@ $pageHeading = IS_INDEX ? '' : "<h1>{$pageHeading}</h1>";
// Populate samples
$files = '';
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
$sampleFiles = [];
while (false !== ($sampleFile = readdir($handle))) {
$sampleFiles[] = $sampleFile;
}
sort($sampleFiles);
closedir($handle);
foreach ($sampleFiles as $file) {
if (preg_match('/^Sample_\d+_/', $file)) {
$name = str_replace('_', ' ', preg_replace('/(Sample_|\.php)/', '', $file));
$files .= "<li><a href='{$file}'>{$name}</a></li>";
}
}
closedir($handle);
}
/**
* Write documents
* Write documents.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
* @param string $filename
@ -71,26 +83,27 @@ function write($phpWord, $filename, $writers)
$result .= EOL;
}
$result .= getEndingNotes($writers);
$result .= getEndingNotes($writers, $filename);
return $result;
}
/**
* Get ending notes
* Get ending notes.
*
* @param array $writers
* @param mixed $filename
*
* @return string
*/
function getEndingNotes($writers)
function getEndingNotes($writers, $filename)
{
$result = '';
// Do not show execution time for index
if (!IS_INDEX) {
$result .= date('H:i:s') . " Done writing file(s)" . EOL;
$result .= date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" . EOL;
$result .= date('H:i:s') . ' Done writing file(s)' . EOL;
$result .= date('H:i:s') . ' Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB' . EOL;
}
// Return
@ -102,7 +115,7 @@ function getEndingNotes($writers)
$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> ";
@ -110,6 +123,12 @@ function getEndingNotes($writers)
}
}
$result .= '</p>';
$result .= '<pre>';
if (file_exists($filename . '.php')) {
$result .= highlight_file($filename . '.php', true);
}
$result .= '</pre>';
}
}

View File

@ -3,17 +3,17 @@ 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">
<p>Welcome to PHPWord, a library written in pure PHP that provides a set of classes to write to and read from different document file formats, i.e. Office Open XML (.docx), Open Document Format (.odt), and Rich Text Format (.rtf).</p>
<p>&nbsp;</p>
@ -22,22 +22,22 @@ 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>";
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>";
}
echo "</ul>";
echo '</ul>';
include_once 'Sample_Footer.php';
} 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;

View File

@ -11,5 +11,15 @@
<ul><li>Item 1</li><li>Item 2</li><ul><li>Item 2.1</li><li>Item 2.1</li></ul></ul>
<p>Ordered (numbered) list:</p>
<ol><li>Item 1</li><li>Item 2</li></ol>
<p style="line-height:2">Double height</p>
<h2>Includes images</h2>
<img src="https://phpword.readthedocs.io/en/latest/_images/phpword.png" alt=""/>
<img src="http://php.net/images/logos/php-med-trans-light.gif" name="Imagen 12" align="bottom" width="208" height="183" border="0"/>
<img src="http://php.net/images/logos/php-icon.png" name="Imagen 13" align="bottom" width="143" height="202" border="0"/>
<img src="http://php.net/images/logos/php-med-trans-light.gif" name="Imagen 14" align="bottom" width="194" height="188" border="0"/>
</body>
</html>

Binary file not shown.

0
samples/results/.gitignore vendored Normal file → Executable file
View File

17
sonar-project.properties Normal file
View File

@ -0,0 +1,17 @@
# must be unique in a given SonarQube instance
sonar.projectKey=phpoffice:phpword
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=PHPWord
sonar.projectVersion=0.16
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=src
sonar.tests=tests
sonar.php.coverage.reportPaths=build/logs/clover.xml
sonar.php.tests.reportPath=build/logs/logfile.xml
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
sonar.host.url=http://localhost:9000

View File

@ -10,31 +10,31 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors
* @see https://github.com/PHPOffice/PHPWord
*
* @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 array
* @var \PhpOffice\PhpWord\Element\AbstractContainer[]
*/
private $items = array();
private $items = [];
/**
* Get items
* Get items.
*
* @return array
* @return \PhpOffice\PhpWord\Element\AbstractContainer[]
*/
public function getItems()
{
@ -42,28 +42,28 @@ abstract class AbstractCollection
}
/**
* Get item by index
* Get item by index.
*
* @param int $index
* @return mixed
*
* @return \PhpOffice\PhpWord\Element\AbstractContainer
*/
public function getItem($index)
{
if (array_key_exists($index, $this->items)) {
return $this->items[$index];
} else {
return null;
}
return null;
}
/**
* Set item.
*
* @param int $index
* @param mixed $item
* @return void
* @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;
@ -71,9 +71,10 @@ abstract class AbstractCollection
}
/**
* Add new item
* Add new item.
*
* @param \PhpOffice\PhpWord\Element\AbstractContainer $item
*
* @param mixed $item
* @return int
*/
public function addItem($item)
@ -85,7 +86,7 @@ abstract class AbstractCollection
}
/**
* Get item count
* Get item count.
*
* @return int
*/

View File

@ -10,15 +10,15 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors
* @see https://github.com/PHPOffice/PHPWord
*
* @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

@ -10,15 +10,15 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors
* @see https://github.com/PHPOffice/PHPWord
*
* @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

@ -10,18 +10,18 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors
* @see https://github.com/PHPOffice/PHPWord
*
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord;
namespace PhpOffice\PhpWord\Collection;
/**
* @deprecated 0.12.0 Use `\PhpOffice\PhpWord\TemplateProcessor` instead.
* Comments collection.
*
* @codeCoverageIgnore
* @since 0.12.0
*/
class Template extends TemplateProcessor
class Comments extends AbstractCollection
{
}

View File

@ -10,15 +10,15 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors
* @see https://github.com/PHPOffice/PHPWord
*
* @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

@ -10,15 +10,15 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors
* @see https://github.com/PHPOffice/PHPWord
*
* @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

@ -10,15 +10,15 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors
* @see https://github.com/PHPOffice/PHPWord
*
* @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

@ -0,0 +1,184 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\ComplexType;
use InvalidArgumentException;
use PhpOffice\PhpWord\SimpleType\NumberFormat;
/**
* Footnote properties.
*
* @see http://www.datypic.com/sc/ooxml/e-w_footnotePr-1.html
*/
final class FootnoteProperties
{
const RESTART_NUMBER_CONTINUOUS = 'continuous';
const RESTART_NUMBER_EACH_SECTION = 'eachSect';
const RESTART_NUMBER_EACH_PAGE = 'eachPage';
const POSITION_PAGE_BOTTOM = 'pageBottom';
const POSITION_BENEATH_TEXT = 'beneathText';
const POSITION_SECTION_END = 'sectEnd';
const POSITION_DOC_END = 'docEnd';
/**
* Footnote Positioning Location.
*
* @var string
*/
private $pos;
/**
* Footnote Numbering Format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat.
*
* @var string
*/
private $numFmt;
/**
* Footnote and Endnote Numbering Starting Value.
*
* @var float
*/
private $numStart;
/**
* Footnote and Endnote Numbering Restart Location.
*
* @var string
*/
private $numRestart;
/**
* Get the Footnote Positioning Location.
*
* @return string
*/
public function getPos()
{
return $this->pos;
}
/**
* Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd).
*
* @param string $pos
*
* @return self
*/
public function setPos($pos)
{
$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');
}
return $this;
}
/**
* Get the Footnote Numbering Format.
*
* @return string
*/
public function getNumFmt()
{
return $this->numFmt;
}
/**
* Set the Footnote Numbering Format.
*
* @param string $numFmt One of NumberFormat
*
* @return self
*/
public function setNumFmt($numFmt)
{
NumberFormat::validate($numFmt);
$this->numFmt = $numFmt;
return $this;
}
/**
* Get the Footnote Numbering Format.
*
* @return float
*/
public function getNumStart()
{
return $this->numStart;
}
/**
* Set the Footnote Numbering Format.
*
* @param float $numStart
*
* @return self
*/
public function setNumStart($numStart)
{
$this->numStart = $numStart;
return $this;
}
/**
* Get the Footnote and Endnote Numbering Starting Value.
*
* @return string
*/
public function getNumRestart()
{
return $this->numRestart;
}
/**
* Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage).
*
* @param string $numRestart
*
* @return self
*/
public function setNumRestart($numRestart)
{
$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');
}
return $this;
}
}

View File

@ -0,0 +1,108 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\ComplexType;
use InvalidArgumentException;
/**
* Spelling and Grammatical Checking State.
*
* @see http://www.datypic.com/sc/ooxml/e-w_proofState-1.html
*/
final class ProofState
{
/**
* Check Completed.
*/
const CLEAN = 'clean';
/**
* Check Not Completed.
*/
const DIRTY = 'dirty';
/**
* Spell Checking State.
*
* @var string
*/
private $spelling;
/**
* Grammatical Checking State.
*
* @var string
*/
private $grammar;
/**
* Set the Spell Checking State (dirty or clean).
*
* @param string $spelling
*
* @return self
*/
public function setSpelling($spelling)
{
if ($spelling == self::CLEAN || $spelling == self::DIRTY) {
$this->spelling = $spelling;
} else {
throw new InvalidArgumentException('Invalid value, dirty or clean possible');
}
return $this;
}
/**
* Get the Spell Checking State.
*
* @return string
*/
public function getSpelling()
{
return $this->spelling;
}
/**
* Set the Grammatical Checking State (dirty or clean).
*
* @param string $grammar
*
* @return self
*/
public function setGrammar($grammar)
{
if ($grammar == self::CLEAN || $grammar == self::DIRTY) {
$this->grammar = $grammar;
} else {
throw new InvalidArgumentException('Invalid value, dirty or clean possible');
}
return $this;
}
/**
* Get the Grammatical Checking State.
*
* @return string
*/
public function getGrammar()
{
return $this->grammar;
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\ComplexType;
use PhpOffice\PhpWord\SimpleType\TblWidth as TblWidthSimpleType;
/**
* @see http://www.datypic.com/sc/ooxml/t-w_CT_TblWidth.html
*/
final class TblWidth
{
/** @var string */
private $type;
/** @var int */
private $value;
/**
* @param int $value If omitted, then its value shall be assumed to be 0
* @param string $type If omitted, then its value shall be assumed to be dxa
*/
public function __construct($value = 0, $type = TblWidthSimpleType::TWIP)
{
$this->value = $value;
TblWidthSimpleType::validate($type);
$this->type = $type;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return int
*/
public function getValue()
{
return $this->value;
}
}

View File

@ -0,0 +1,166 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\ComplexType;
/**
* 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.
*
* @var bool
*/
private $markup;
/**
* Display Comments.
*
* @var bool
*/
private $comments;
/**
* Display Content Revisions.
*
* @var bool
*/
private $insDel;
/**
* Display Formatting Revisions.
*
* @var bool
*/
private $formatting;
/**
* Display Ink Annotations.
*
* @var bool
*/
private $inkAnnotations;
/**
* Get Display Visual Indicator Of Markup Area.
*
* @return bool True if markup is shown
*/
public function hasMarkup()
{
return $this->markup;
}
/**
* Set Display Visual Indicator Of Markup Area.
*
* @param bool $markup
* Set to true to show markup
*/
public function setMarkup($markup): void
{
$this->markup = $markup === null ? true : $markup;
}
/**
* Get Display Comments.
*
* @return bool True if comments are shown
*/
public function hasComments()
{
return $this->comments;
}
/**
* Set Display Comments.
*
* @param bool $comments
* Set to true to show comments
*/
public function setComments($comments): void
{
$this->comments = $comments === null ? true : $comments;
}
/**
* Get Display Content Revisions.
*
* @return bool True if content revisions are shown
*/
public function hasInsDel()
{
return $this->insDel;
}
/**
* Set Display Content Revisions.
*
* @param bool $insDel
* Set to true to show content revisions
*/
public function setInsDel($insDel): void
{
$this->insDel = $insDel === null ? true : $insDel;
}
/**
* Get Display Formatting Revisions.
*
* @return bool True if formatting revisions are shown
*/
public function hasFormatting()
{
return $this->formatting;
}
/**
* Set Display Formatting Revisions.
*
* @param null|bool $formatting
* Set to true to show formatting revisions
*/
public function setFormatting($formatting = null): void
{
$this->formatting = $formatting === null ? true : $formatting;
}
/**
* Get Display Ink Annotations.
*
* @return bool True if ink annotations are shown
*/
public function hasInkAnnotations()
{
return $this->inkAnnotations;
}
/**
* Set Display Ink Annotations.
*
* @param bool $inkAnnotations
* Set to true to show ink annotations
*/
public function setInkAnnotations($inkAnnotations): void
{
$this->inkAnnotations = $inkAnnotations === null ? true : $inkAnnotations;
}
}

View File

@ -10,20 +10,23 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors
* @see https://github.com/PHPOffice/PHPWord
*
* @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)
* @method Bookmark addBookmark(string $name)
* @method Link addLink(string $target, string $text = null, mixed $fStyle = null, mixed $pStyle = null)
* @method Link addLink(string $target, string $text = null, mixed $fStyle = null, mixed $pStyle = null, boolean $internal = false)
* @method PreserveText addPreserveText(string $text, mixed $fStyle = null, mixed $pStyle = null)
* @method void addTextBreak(int $count = 1, mixed $fStyle = null, mixed $pStyle = null)
* @method ListItem addListItem(string $txt, int $depth = 0, mixed $font = null, mixed $list = null, mixed $para = null)
@ -31,41 +34,41 @@ 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)
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false)
* @method Object addObject(string $source, mixed $style = null)
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false, $name = null)
* @method OLEObject addOLEObject(string $source, mixed $style = null)
* @method TextBox addTextBox(mixed $style = null)
* @method Field addField(string $type = null, array $properties = array(), array $options = array())
* @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
*/
abstract class AbstractContainer extends AbstractElement
{
/**
* Elements collection
* Elements collection.
*
* @var array
* @var \PhpOffice\PhpWord\Element\AbstractElement[]
*/
protected $elements = array();
protected $elements = [];
/**
* Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun
* 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`.
@ -74,20 +77,21 @@ 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',
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'OLEObject',
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
'Chart', 'FormField', 'SDT'
);
$functions = array();
'Chart', 'FormField', 'SDT', 'Comment',
];
$functions = [];
foreach ($elements as $element) {
$functions['add' . strtolower($element)] = $element;
$functions['add' . strtolower($element)] = $element == 'Object' ? 'OLEObject' : $element;
}
// Run valid `add` command
@ -98,18 +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) = $args; // Suppress error
[$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);
}
// All other elements
} 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,11 +160,9 @@ abstract class AbstractContainer extends AbstractElement
}
/**
* Get all elements
* Get all elements.
*
* @return array
*
* @codeCoverageIgnore
* @return \PhpOffice\PhpWord\Element\AbstractElement[]
*/
public function getElements()
{
@ -167,7 +170,43 @@ abstract class AbstractContainer extends AbstractElement
}
/**
* Count elements
* Returns the element at the requested position.
*
* @param int $index
*
* @return null|\PhpOffice\PhpWord\Element\AbstractElement
*/
public function getElement($index)
{
if (array_key_exists($index, $this->elements)) {
return $this->elements[$index];
}
return null;
}
/**
* Removes the element at requested index.
*
* @param int|\PhpOffice\PhpWord\Element\AbstractElement $toRemove
*/
public function removeElement($toRemove): void
{
if (is_int($toRemove) && array_key_exists($toRemove, $this->elements)) {
unset($this->elements[$toRemove]);
} elseif ($toRemove instanceof \PhpOffice\PhpWord\Element\AbstractElement) {
foreach ($this->elements as $key => $element) {
if ($element->getElementId() === $toRemove->getElementId()) {
unset($this->elements[$key]);
return;
}
}
}
}
/**
* Count elements.
*
* @return int
*/
@ -177,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
*
* @return bool
*
* @throws \BadMethodCallException
*/
private function checkValidity($method)
{
$generalContainers = array(
'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun',
);
$generalContainers = [
'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun', 'TrackChange',
];
$validContainers = array(
'Text' => $generalContainers,
'Bookmark' => $generalContainers,
'Link' => $generalContainers,
'TextBreak' => $generalContainers,
'Image' => $generalContainers,
'Object' => $generalContainers,
'Field' => $generalContainers,
'Line' => $generalContainers,
'Shape' => $generalContainers,
'FormField' => $generalContainers,
'SDT' => $generalContainers,
'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'),
'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'),
'TextBox' => array('Section', 'Header', 'Footer', 'Cell'),
'Footnote' => array('Section', 'TextRun', 'Cell'),
'Endnote' => array('Section', 'TextRun', 'Cell'),
'PreserveText' => array('Header', 'Footer', 'Cell'),
'Title' => array('Section'),
'TOC' => array('Section'),
'PageBreak' => array('Section'),
'Chart' => array('Section'),
);
$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}.");
}
}
@ -240,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

@ -10,39 +10,41 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors
* @see https://github.com/PHPOffice/PHPWord
*
* @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 int
* @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,28 +96,56 @@ abstract class AbstractElement
private $nestedLevel = 0;
/**
* Parent container type
* A reference to the parent.
*
* @var null|AbstractElement
*/
private $parent;
/**
* changed element info.
*
* @var TrackChange
*/
private $trackChange;
/**
* 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, and Chart
* Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment.
*
* @var bool
*/
protected $collectionRelation = false;
/**
* Get PhpWord
* The start position for the linked comment.
*
* @var Comment
*/
protected $commentRangeStart;
/**
* The end position for the linked comment.
*
* @var Comment
*/
protected $commentRangeEnd;
/**
* Get PhpWord.
*
* @return \PhpOffice\PhpWord\PhpWord
*/
@ -128,15 +158,14 @@ abstract class AbstractElement
* Set PhpWord as reference.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return void
*/
public function setPhpWord(PhpWord $phpWord = null)
public function setPhpWord(?PhpWord $phpWord = null): void
{
$this->phpWord = $phpWord;
}
/**
* Get section number
* Get section number.
*
* @return int
*/
@ -150,16 +179,15 @@ abstract class AbstractElement
*
* @param string $docPart
* @param int $docPartId
* @return void
*/
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
*/
@ -169,7 +197,7 @@ abstract class AbstractElement
}
/**
* Get doc part Id
* Get doc part Id.
*
* @return int
*/
@ -179,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
*/
@ -194,7 +222,7 @@ abstract class AbstractElement
}
/**
* Get element index
* Get element index.
*
* @return int
*/
@ -207,15 +235,14 @@ abstract class AbstractElement
* Set element index.
*
* @param int $value
* @return void
*/
public function setElementIndex($value)
public function setElementIndex($value): void
{
$this->elementIndex = $value;
}
/**
* Get element unique ID
* Get element unique ID.
*
* @return string
*/
@ -226,16 +253,14 @@ abstract class AbstractElement
/**
* Set element unique ID from 6 first digit of md5.
*
* @return void
*/
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
*/
@ -248,15 +273,14 @@ abstract class AbstractElement
* Set relation Id.
*
* @param int $value
* @return void
*/
public function setRelationId($value)
public function setRelationId($value): void
{
$this->relationId = $value;
}
/**
* Get nested level
* Get nested level.
*
* @return int
*/
@ -266,21 +290,75 @@ abstract class AbstractElement
}
/**
* Set parent container
* Get comment start.
*
* @return Comment
*/
public function getCommentRangeStart()
{
return $this->commentRangeStart;
}
/**
* Set comment start.
*/
public function setCommentRangeStart(Comment $value): void
{
if ($this instanceof Comment) {
throw new InvalidArgumentException('Cannot set a Comment on a Comment');
}
$this->commentRangeStart = $value;
$this->commentRangeStart->setStartElement($this);
}
/**
* Get comment end.
*
* @return Comment
*/
public function getCommentRangeEnd()
{
return $this->commentRangeEnd;
}
/**
* Set comment end.
*/
public function setCommentRangeEnd(Comment $value): void
{
if ($this instanceof 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.
*
* Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
*
* @param \PhpOffice\PhpWord\Element\AbstractElement $container
* @return void
*/
public function setParentContainer(AbstractElement $container)
public function setParentContainer(self $container): void
{
$this->parentContainer = substr(get_class($container), strrpos(get_class($container), '\\') + 1);
$this->parent = $container;
// Set nested level
$this->nestedLevel = $container->getNestedLevel();
if ($this->parentContainer == 'Cell') {
$this->nestedLevel++;
++$this->nestedLevel;
}
// Set phpword
@ -296,20 +374,21 @@ 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
*
* @return void
*/
private function setMediaRelation()
private function setMediaRelation(): void
{
if (!$this instanceof Link && !$this instanceof Image && !$this instanceof Object) {
if (!$this instanceof Link && !$this instanceof Image && !$this instanceof OLEObject) {
return;
}
$elementName = substr(get_class($this), strrpos(get_class($this), '\\') + 1);
$elementName = substr(static::class, strrpos(static::class, '\\') + 1);
if ($elementName == 'OLEObject') {
$elementName = 'Object';
}
$mediaPart = $this->getMediaPart();
$source = $this->getSource();
$image = null;
@ -319,7 +398,7 @@ abstract class AbstractElement
$rId = Media::addElement($mediaPart, strtolower($elementName), $source, $image);
$this->setRelationId($rId);
if ($this instanceof Object) {
if ($this instanceof OLEObject) {
$icon = $this->getIcon();
$rId = Media::addElement($mediaPart, 'image', $icon, new Image($icon));
$this->setImageRelationId($rId);
@ -328,13 +407,11 @@ abstract class AbstractElement
/**
* Set relation Id for elements that will be registered in the Collection subnamespaces.
*
* @return void
*/
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);
@ -342,26 +419,27 @@ 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
*/
public function isInSection()
{
return ($this->docPart == 'Section');
return $this->docPart == 'Section';
}
/**
* 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 {
@ -372,22 +450,50 @@ abstract class AbstractElement
}
/**
* Set enum value
* Sets the trackChange information.
*/
public function setTrackChange(TrackChange $trackChange): void
{
$this->trackChange = $trackChange;
}
/**
* Gets the trackChange information.
*
* @param mixed $value
* @param array $enum
* @param mixed $default
* @return TrackChange
*/
public function getTrackChange()
{
return $this->trackChange;
}
/**
* Set changed.
*
* @return mixed
* @param string $type INSERTED|DELETED
* @param string $author
* @param null|DateTime|int $date allways in UTC
*/
public function setChangeInfo($type, $author, $date = null): void
{
$this->trackChange = new TrackChange($type, $author, $date);
}
/**
* Set enum value.
*
* @throws \InvalidArgumentException
* @param null|string $value
* @param string[] $enum
* @param null|string $default
*
* @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}");
if ($value !== null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
throw new InvalidArgumentException("Invalid style value: {$value}");
} elseif ($value === null || trim($value) == '') {
$value = $default;
}

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