Merge branch 'develop' into feature/EnablePasswordProtection
This commit is contained in:
commit
cfc89b7853
|
|
@ -3,7 +3,7 @@ Change Log
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
v0.14.0 (?? ???? 2017)
|
v0.14.0 (?? Dec 2017)
|
||||||
----------------------
|
----------------------
|
||||||
This release fixes several bugs and adds some new features.
|
This release fixes several bugs and adds some new features.
|
||||||
This is the last version to support PHP 5.3
|
This is the last version to support PHP 5.3
|
||||||
|
|
@ -18,8 +18,10 @@ This is the last version to support PHP 5.3
|
||||||
- Support for Comments - @troosan #1067
|
- Support for Comments - @troosan #1067
|
||||||
- Support for paragraph textAlignment - @troosan #1165
|
- Support for paragraph textAlignment - @troosan #1165
|
||||||
- Add support for HTML underline tag <u> in addHtml - @zNightFalLz #1186
|
- Add support for HTML underline tag <u> in addHtml - @zNightFalLz #1186
|
||||||
- Allow to change cell width unit - guillaume-ro-fr #986
|
- Allow to change cell width unit - @guillaume-ro-fr #986
|
||||||
- Allow to change the line height rule @troosan
|
- 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
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Loosen dependency to Zend
|
- Loosen dependency to Zend
|
||||||
|
|
@ -39,6 +41,9 @@ This is the last version to support PHP 5.3
|
||||||
- Fix incorrect image size between windows and mac - @bskrtich #874
|
- Fix incorrect image size between windows and mac - @bskrtich #874
|
||||||
- Fix adding HTML table to document - @mogilvie @arivanbastos #324
|
- Fix adding HTML table to document - @mogilvie @arivanbastos #324
|
||||||
|
|
||||||
|
###Deprecated
|
||||||
|
- PhpWord->getProtection(), get it from the settings instead PhpWord->getSettings()->getDocumentProtection();
|
||||||
|
|
||||||
v0.13.0 (31 July 2016)
|
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).
|
This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).
|
||||||
|
|
|
||||||
12
README.md
12
README.md
|
|
@ -67,10 +67,18 @@ PHPWord requires the following:
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
PHPWord is installed via [Composer](https://getcomposer.org/).
|
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:
|
Run the following to use the latest stable version
|
||||||
|
```sh
|
||||||
|
composer require phpoffice/phpword
|
||||||
|
```
|
||||||
|
or if you want the latest master version
|
||||||
|
```sh
|
||||||
|
composer require phpoffice/phpword:dev-master
|
||||||
|
```
|
||||||
|
|
||||||
|
You can of course also manually edit your composer.json file
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
"php": ">=5.3.3",
|
"php": ">=5.3.3",
|
||||||
"ext-xml": "*",
|
"ext-xml": "*",
|
||||||
"zendframework/zend-escaper": "^2.2",
|
"zendframework/zend-escaper": "^2.2",
|
||||||
"zendframework/zend-stdlib": "^2.2",
|
"zendframework/zend-stdlib": "^2.2 || ^3.0",
|
||||||
"phpoffice/common": "^0.2"
|
"phpoffice/common": "^0.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
Issue tracker is **ONLY** used for reporting bugs. NO NEW FEATURE ACCEPTED! Use [stackoverflow](https://stackoverflow.com/questions/tagged/phpword) for supporting issues.
|
||||||
|
|
||||||
|
# Expected Behavior
|
||||||
|
|
||||||
|
Please describe the behavior you are expecting.
|
||||||
|
|
||||||
|
# Current Behavior
|
||||||
|
|
||||||
|
What is the current behavior?
|
||||||
|
|
||||||
|
# Failure Information
|
||||||
|
|
||||||
|
Please help provide information about the failure.
|
||||||
|
|
||||||
|
## How to Reproduce
|
||||||
|
|
||||||
|
Please provide a code sample that reproduces the issue.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
$section = $phpWord->addSection();
|
||||||
|
$section->...
|
||||||
|
```
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
* PHP version:
|
||||||
|
* PHPWord version: 0.14
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Description
|
||||||
|
|
||||||
|
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
|
||||||
|
|
||||||
|
Fixes # (issue)
|
||||||
|
|
||||||
|
# Checklist:
|
||||||
|
|
||||||
|
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||||
|
- [ ] I have run phpunit, phpcs, php-cs-fixer, phpmd
|
||||||
|
- [ ] The new code is covered by unit tests
|
||||||
|
- [ ] I have update the documentation to describe the changes
|
||||||
|
|
@ -297,7 +297,7 @@ Your TOC can only be generated if you have add at least one title (See "Titles")
|
||||||
|
|
||||||
Options for ``$tocStyle``:
|
Options for ``$tocStyle``:
|
||||||
|
|
||||||
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\\Style\\TOC.
|
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in ``\PhpOffice\PhpWord\Style\TOC``.
|
||||||
- ``tabPos``. The position of the tab where the page number appears in twips.
|
- ``tabPos``. The position of the tab where the page number appears in twips.
|
||||||
- ``indent``. The indent factor of the titles in twips.
|
- ``indent``. The indent factor of the titles in twips.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -282,3 +282,12 @@ The document (or parts of it) can be password protected.
|
||||||
$documentProtection = $phpWord->getSettings()->getDocumentProtection();
|
$documentProtection = $phpWord->getSettings()->getDocumentProtection();
|
||||||
$documentProtection->setEditing(DocProtect::READ_ONLY);
|
$documentProtection->setEditing(DocProtect::READ_ONLY);
|
||||||
$documentProtection->setPassword('myPassword');
|
$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);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
includes:
|
||||||
|
- vendor/phpstan/phpstan/conf/config.level1.neon
|
||||||
|
parameters:
|
||||||
|
memory-limit: 200000
|
||||||
|
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
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
echo "Running composer update"
|
||||||
|
composer update
|
||||||
|
|
||||||
## PHP_CodeSniffer
|
## PHP_CodeSniffer
|
||||||
|
echo "Running CodeSniffer"
|
||||||
./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
|
./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
|
||||||
|
|
||||||
## PHP-CS-Fixer
|
## PHP-CS-Fixer
|
||||||
|
echo "Running CS Fixer"
|
||||||
./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
|
./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
|
||||||
|
|
||||||
## PHP Mess Detector
|
## PHP Mess Detector
|
||||||
|
echo "Running Mess Detector"
|
||||||
./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
|
./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
|
||||||
|
|
||||||
## PHPUnit
|
## PHPUnit
|
||||||
./vendor/bin/phpunit -c ./ --no-coverage
|
echo "Running PHPUnit"
|
||||||
|
./vendor/bin/phpunit -c ./
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ include_once 'Sample_Header.php';
|
||||||
// New Word document
|
// New Word document
|
||||||
echo date('H:i:s'), ' Create new PhpWord object', EOL;
|
echo date('H:i:s'), ' Create new PhpWord object', EOL;
|
||||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
$phpWord->getSettings()->setUpdateFields(true);
|
||||||
|
|
||||||
// New section
|
// New section
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Endnote element
|
* Endnote element
|
||||||
*
|
*
|
||||||
|
|
@ -38,6 +36,6 @@ class Endnote extends Footnote
|
||||||
*/
|
*/
|
||||||
public function __construct($paragraphStyle = null)
|
public function __construct($paragraphStyle = null)
|
||||||
{
|
{
|
||||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
parent::__construct($paragraphStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ class Field extends AbstractElement
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param array $properties
|
* @param array $properties
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @param TextRun | string $text
|
* @param TextRun|string|null $text
|
||||||
*/
|
*/
|
||||||
public function __construct($type = null, $properties = array(), $options = array(), $text = null)
|
public function __construct($type = null, $properties = array(), $options = array(), $text = null)
|
||||||
{
|
{
|
||||||
|
|
@ -209,7 +209,7 @@ class Field extends AbstractElement
|
||||||
* @param string|TextRun $text
|
* @param string|TextRun $text
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return string|TextRun
|
* @return null|string|TextRun
|
||||||
*/
|
*/
|
||||||
public function setText($text)
|
public function setText($text)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ class Image extends AbstractElement
|
||||||
$this->setIsWatermark($watermark);
|
$this->setIsWatermark($watermark);
|
||||||
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
||||||
|
|
||||||
$this->checkImage($source);
|
$this->checkImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
|
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List item element
|
* List item element
|
||||||
|
|
@ -61,7 +60,7 @@ class ListItemRun extends TextRun
|
||||||
} else {
|
} else {
|
||||||
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
|
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
|
||||||
}
|
}
|
||||||
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
parent::__construct($paragraphStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ class Section extends AbstractContainer
|
||||||
/**
|
/**
|
||||||
* Get the footnote properties
|
* Get the footnote properties
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Element\FooterProperties
|
* @return FootnoteProperties
|
||||||
*/
|
*/
|
||||||
public function getFootnotePropoperties()
|
public function getFootnotePropoperties()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class TrackChange extends AbstractContainer
|
||||||
/**
|
/**
|
||||||
* Date
|
* Date
|
||||||
*
|
*
|
||||||
* @var DateTime
|
* @var \DateTime
|
||||||
*/
|
*/
|
||||||
private $date;
|
private $date;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -410,7 +410,7 @@ class DocInfo
|
||||||
* Get a Custom Property Value
|
* Get a Custom Property Value
|
||||||
*
|
*
|
||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @return string
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getCustomPropertyValue($propertyName)
|
public function getCustomPropertyValue($propertyName)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,13 @@ class Settings
|
||||||
*/
|
*/
|
||||||
private $themeFontLang;
|
private $themeFontLang;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatically Recalculate Fields on Open
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $updateFields = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Radix Point for Field Code Evaluation
|
* Radix Point for Field Code Evaluation
|
||||||
*
|
*
|
||||||
|
|
@ -345,6 +352,22 @@ class Settings
|
||||||
$this->themeFontLang = $themeFontLang;
|
$this->themeFontLang = $themeFontLang;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasUpdateFields()
|
||||||
|
{
|
||||||
|
return $this->updateFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $updateFields
|
||||||
|
*/
|
||||||
|
public function setUpdateFields($updateFields)
|
||||||
|
{
|
||||||
|
$this->updateFields = $updateFields === null ? false : $updateFields;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Radix Point for Field Code Evaluation
|
* Returns the Radix Point for Field Code Evaluation
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -150,11 +150,11 @@ class Settings extends AbstractPart
|
||||||
protected function setRevisionView(XMLReader $xmlReader, PhpWord $phpWord, \DOMElement $node)
|
protected function setRevisionView(XMLReader $xmlReader, PhpWord $phpWord, \DOMElement $node)
|
||||||
{
|
{
|
||||||
$revisionView = new TrackChangesView();
|
$revisionView = new TrackChangesView();
|
||||||
$revisionView->setMarkup($xmlReader->getAttribute('w:markup', $node));
|
$revisionView->setMarkup(filter_var($xmlReader->getAttribute('w:markup', $node), FILTER_VALIDATE_BOOLEAN));
|
||||||
$revisionView->setComments($xmlReader->getAttribute('w:comments', $node));
|
$revisionView->setComments($xmlReader->getAttribute('w:comments', $node));
|
||||||
$revisionView->setInsDel($xmlReader->getAttribute('w:insDel', $node));
|
$revisionView->setInsDel($xmlReader->getAttribute('w:insDel', $node));
|
||||||
$revisionView->setFormatting($xmlReader->getAttribute('w:formatting', $node));
|
$revisionView->setFormatting(filter_var($xmlReader->getAttribute('w:formatting', $node), FILTER_VALIDATE_BOOLEAN));
|
||||||
$revisionView->setInkAnnotations($xmlReader->getAttribute('w:inkAnnotations', $node));
|
$revisionView->setInkAnnotations(filter_var($xmlReader->getAttribute('w:inkAnnotations', $node), FILTER_VALIDATE_BOOLEAN));
|
||||||
$phpWord->getSettings()->setRevisionView($revisionView);
|
$phpWord->getSettings()->setRevisionView($revisionView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ abstract class AbstractEnum
|
||||||
/**
|
/**
|
||||||
* Returns true the value is valid for this enum
|
* Returns true the value is valid for this enum
|
||||||
*
|
*
|
||||||
* @param strign $value
|
* @param string $value
|
||||||
* @return bool true if value is valid
|
* @return bool true if value is valid
|
||||||
*/
|
*/
|
||||||
public static function isValid($value)
|
public static function isValid($value)
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ class Html
|
||||||
{
|
{
|
||||||
if ('li' != $node->nodeName) {
|
if ('li' != $node->nodeName) {
|
||||||
$cNodes = $node->childNodes;
|
$cNodes = $node->childNodes;
|
||||||
if (count($cNodes) > 0) {
|
if (!empty($cNodes)) {
|
||||||
foreach ($cNodes as $cNode) {
|
foreach ($cNodes as $cNode) {
|
||||||
if ($element instanceof AbstractContainer || $element instanceof Table || $element instanceof Row) {
|
if ($element instanceof AbstractContainer || $element instanceof Table || $element instanceof Row) {
|
||||||
self::parseNode($cNode, $element, $styles, $data);
|
self::parseNode($cNode, $element, $styles, $data);
|
||||||
|
|
@ -389,7 +389,7 @@ class Html
|
||||||
private static function parseListItem($node, $element, &$styles, $data)
|
private static function parseListItem($node, $element, &$styles, $data)
|
||||||
{
|
{
|
||||||
$cNodes = $node->childNodes;
|
$cNodes = $node->childNodes;
|
||||||
if (count($cNodes) > 0) {
|
if (!empty($cNodes)) {
|
||||||
$text = '';
|
$text = '';
|
||||||
foreach ($cNodes as $cNode) {
|
foreach ($cNodes as $cNode) {
|
||||||
if ($cNode->nodeName == '#text') {
|
if ($cNode->nodeName == '#text') {
|
||||||
|
|
|
||||||
|
|
@ -3790,7 +3790,7 @@ class PclZip
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- Write gz file format header
|
// ----- Write gz file format header
|
||||||
$v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
|
$v_binary_data = pack('va1a1Va1a1', 0x8b1f, chr($p_entry['compression']), chr(0x00), time(), chr(0x00), chr(3));
|
||||||
@fwrite($v_dest_file, $v_binary_data, 10);
|
@fwrite($v_dest_file, $v_binary_data, 10);
|
||||||
|
|
||||||
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
|
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
|
||||||
|
|
@ -4383,7 +4383,7 @@ class PclZip
|
||||||
//$v_bytes = ($v_bytes << 8) | Ord($v_byte);
|
//$v_bytes = ($v_bytes << 8) | Ord($v_byte);
|
||||||
// Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
|
// Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
|
||||||
// Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
|
// Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
|
||||||
$v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
|
$v_bytes = (($v_bytes & 0xFFFFFF) << 8) | ord($v_byte);
|
||||||
|
|
||||||
// ----- Compare the bytes
|
// ----- Compare the bytes
|
||||||
if ($v_bytes == 0x504b0506) {
|
if ($v_bytes == 0x504b0506) {
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,8 @@ class ZipArchive
|
||||||
} else {
|
} else {
|
||||||
$zip = new \PclZip($this->filename);
|
$zip = new \PclZip($this->filename);
|
||||||
$this->tempDir = Settings::getTempDir();
|
$this->tempDir = Settings::getTempDir();
|
||||||
$this->numFiles = count($zip->listContent());
|
$zipContent = $zip->listContent();
|
||||||
|
$this->numFiles = is_array($zipContent) ? count($zipContent) : 0;
|
||||||
}
|
}
|
||||||
$this->zip = $zip;
|
$this->zip = $zip;
|
||||||
|
|
||||||
|
|
@ -351,7 +352,7 @@ class ZipArchive
|
||||||
* Returns the name of an entry using its index (emulate \ZipArchive)
|
* Returns the name of an entry using its index (emulate \ZipArchive)
|
||||||
*
|
*
|
||||||
* @param int $index
|
* @param int $index
|
||||||
* @return string
|
* @return string|bool
|
||||||
* @since 0.10.0
|
* @since 0.10.0
|
||||||
*/
|
*/
|
||||||
public function pclzipGetNameIndex($index)
|
public function pclzipGetNameIndex($index)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text element writer
|
* Text element writer
|
||||||
*
|
*
|
||||||
|
|
@ -44,11 +42,7 @@ class Link extends AbstractElement
|
||||||
$xmlWriter->startElement('text:a');
|
$xmlWriter->startElement('text:a');
|
||||||
$xmlWriter->writeAttribute('xlink:type', 'simple');
|
$xmlWriter->writeAttribute('xlink:type', 'simple');
|
||||||
$xmlWriter->writeAttribute('xlink:href', $element->getSource());
|
$xmlWriter->writeAttribute('xlink:href', $element->getSource());
|
||||||
if (Settings::isOutputEscapingEnabled()) {
|
$this->writeText($element->getText());
|
||||||
$xmlWriter->text($element->getText());
|
|
||||||
} else {
|
|
||||||
$xmlWriter->writeRaw($element->getText());
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement(); // text:a
|
$xmlWriter->endElement(); // text:a
|
||||||
|
|
||||||
if (!$this->withoutP) {
|
if (!$this->withoutP) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||||
|
* word processing documents.
|
||||||
|
*
|
||||||
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||||
|
* General Public License version 3 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please read the LICENSE
|
||||||
|
* file that was distributed with this source code. For the full list of
|
||||||
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
|
*
|
||||||
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PageBreak element writer
|
||||||
|
*/
|
||||||
|
class PageBreak extends AbstractElement
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write element
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$xmlWriter = $this->getXmlWriter();
|
||||||
|
|
||||||
|
$xmlWriter->startElement('text:p');
|
||||||
|
$xmlWriter->writeAttribute('text:style-name', 'P1');
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
use PhpOffice\PhpWord\Exception\Exception;
|
||||||
use PhpOffice\PhpWord\Settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text element writer
|
* Text element writer
|
||||||
|
|
@ -58,11 +57,7 @@ class Text extends AbstractElement
|
||||||
} elseif (is_string($paragraphStyle)) {
|
} elseif (is_string($paragraphStyle)) {
|
||||||
$xmlWriter->writeAttribute('text:style-name', $paragraphStyle);
|
$xmlWriter->writeAttribute('text:style-name', $paragraphStyle);
|
||||||
}
|
}
|
||||||
if (Settings::isOutputEscapingEnabled()) {
|
$this->writeText($element->getText());
|
||||||
$xmlWriter->text($element->getText());
|
|
||||||
} else {
|
|
||||||
$xmlWriter->writeRaw($element->getText());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (empty($paragraphStyle)) {
|
if (empty($paragraphStyle)) {
|
||||||
$xmlWriter->writeAttribute('text:style-name', 'Standard');
|
$xmlWriter->writeAttribute('text:style-name', 'Standard');
|
||||||
|
|
@ -74,11 +69,7 @@ class Text extends AbstractElement
|
||||||
if (is_string($fontStyle)) {
|
if (is_string($fontStyle)) {
|
||||||
$xmlWriter->writeAttribute('text:style-name', $fontStyle);
|
$xmlWriter->writeAttribute('text:style-name', $fontStyle);
|
||||||
}
|
}
|
||||||
if (Settings::isOutputEscapingEnabled()) {
|
$this->writeText($element->getText());
|
||||||
$xmlWriter->text($element->getText());
|
|
||||||
} else {
|
|
||||||
$xmlWriter->writeRaw($element->getText());
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
if (!$this->withoutP) {
|
if (!$this->withoutP) {
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title element writer
|
* Title element writer
|
||||||
*
|
*
|
||||||
|
|
@ -39,11 +37,7 @@ class Title extends AbstractElement
|
||||||
|
|
||||||
$xmlWriter->startElement('text:h');
|
$xmlWriter->startElement('text:h');
|
||||||
$xmlWriter->writeAttribute('text:outline-level', $element->getDepth());
|
$xmlWriter->writeAttribute('text:outline-level', $element->getDepth());
|
||||||
if (Settings::isOutputEscapingEnabled()) {
|
$this->writeText($element->getText());
|
||||||
$xmlWriter->text($element->getText());
|
|
||||||
} else {
|
|
||||||
$xmlWriter->writeRaw($element->getText());
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement(); // text:h
|
$xmlWriter->endElement(); // text:h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\Common\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ODText meta part writer: meta.xml
|
* ODText meta part writer: meta.xml
|
||||||
|
|
@ -100,11 +99,7 @@ class Meta extends AbstractPart
|
||||||
// if ($type !== null) {
|
// if ($type !== null) {
|
||||||
// $xmlWriter->writeAttribute('meta:value-type', $type);
|
// $xmlWriter->writeAttribute('meta:value-type', $type);
|
||||||
// }
|
// }
|
||||||
if (Settings::isOutputEscapingEnabled()) {
|
$this->writeText($value);
|
||||||
$xmlWriter->text($value);
|
|
||||||
} else {
|
|
||||||
$xmlWriter->writeRaw($value);
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement(); // meta:user-defined
|
$xmlWriter->endElement(); // meta:user-defined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ class TCPDF extends AbstractRenderer implements WriterInterface
|
||||||
* Save PhpWord to file.
|
* Save PhpWord to file.
|
||||||
*
|
*
|
||||||
* @param string $filename Name of the file to save as
|
* @param string $filename Name of the file to save as
|
||||||
* @return vois
|
|
||||||
*/
|
*/
|
||||||
public function save($filename = null)
|
public function save($filename = null)
|
||||||
{
|
{
|
||||||
|
|
@ -55,21 +54,21 @@ class TCPDF extends AbstractRenderer implements WriterInterface
|
||||||
$pdf->setFontSubsetting(false);
|
$pdf->setFontSubsetting(false);
|
||||||
$pdf->setPrintHeader(false);
|
$pdf->setPrintHeader(false);
|
||||||
$pdf->setPrintFooter(false);
|
$pdf->setPrintFooter(false);
|
||||||
$pdf->addPage();
|
$pdf->AddPage();
|
||||||
$pdf->setFont($this->getFont());
|
$pdf->SetFont($this->getFont());
|
||||||
$pdf->writeHTML($this->getContent());
|
$pdf->writeHTML($this->getContent());
|
||||||
|
|
||||||
// Write document properties
|
// Write document properties
|
||||||
$phpWord = $this->getPhpWord();
|
$phpWord = $this->getPhpWord();
|
||||||
$docProps = $phpWord->getDocInfo();
|
$docProps = $phpWord->getDocInfo();
|
||||||
$pdf->setTitle($docProps->getTitle());
|
$pdf->SetTitle($docProps->getTitle());
|
||||||
$pdf->setAuthor($docProps->getCreator());
|
$pdf->SetAuthor($docProps->getCreator());
|
||||||
$pdf->setSubject($docProps->getSubject());
|
$pdf->SetSubject($docProps->getSubject());
|
||||||
$pdf->setKeywords($docProps->getKeywords());
|
$pdf->SetKeywords($docProps->getKeywords());
|
||||||
$pdf->setCreator($docProps->getCreator());
|
$pdf->SetCreator($docProps->getCreator());
|
||||||
|
|
||||||
// Write to file
|
// Write to file
|
||||||
fwrite($fileHandle, $pdf->output($filename, 'S'));
|
fwrite($fileHandle, $pdf->Output($filename, 'S'));
|
||||||
|
|
||||||
parent::restoreStateAfterSave($fileHandle);
|
parent::restoreStateAfterSave($fileHandle);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class Border extends AbstractStyle
|
||||||
$content = '';
|
$content = '';
|
||||||
|
|
||||||
$sides = array('top', 'left', 'right', 'bottom');
|
$sides = array('top', 'left', 'right', 'bottom');
|
||||||
$sizeCount = count($this->sizes) - 1;
|
$sizeCount = count($this->sizes);
|
||||||
|
|
||||||
// Page border measure
|
// Page border measure
|
||||||
// 8 = from text, infront off; 32 = from edge, infront on; 40 = from edge, infront off
|
// 8 = from text, infront off; 32 = from edge, infront on; 40 = from edge, infront off
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class SDT extends Text
|
||||||
*/
|
*/
|
||||||
private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element)
|
private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element)
|
||||||
{
|
{
|
||||||
$this->writecomboBox($xmlWriter, $element);
|
$this->writeComboBox($xmlWriter, $element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ class Settings extends AbstractPart
|
||||||
{
|
{
|
||||||
if ($settingValue == '') {
|
if ($settingValue == '') {
|
||||||
$xmlWriter->writeElement($settingKey);
|
$xmlWriter->writeElement($settingKey);
|
||||||
} else {
|
} elseif (is_array($settingValue) && !empty($settingValue)) {
|
||||||
$xmlWriter->startElement($settingKey);
|
$xmlWriter->startElement($settingKey);
|
||||||
|
|
||||||
/** @var array $settingValue Type hint */
|
/** @var array $settingValue Type hint */
|
||||||
|
|
@ -148,13 +148,14 @@ class Settings extends AbstractPart
|
||||||
$this->setOnOffValue('w:doNotTrackMoves', $documentSettings->hasDoNotTrackMoves());
|
$this->setOnOffValue('w:doNotTrackMoves', $documentSettings->hasDoNotTrackMoves());
|
||||||
$this->setOnOffValue('w:doNotTrackFormatting', $documentSettings->hasDoNotTrackFormatting());
|
$this->setOnOffValue('w:doNotTrackFormatting', $documentSettings->hasDoNotTrackFormatting());
|
||||||
$this->setOnOffValue('w:evenAndOddHeaders', $documentSettings->hasEvenAndOddHeaders());
|
$this->setOnOffValue('w:evenAndOddHeaders', $documentSettings->hasEvenAndOddHeaders());
|
||||||
|
$this->setOnOffValue('w:updateFields', $documentSettings->hasUpdateFields());
|
||||||
|
|
||||||
$this->setThemeFontLang($documentSettings->getThemeFontLang());
|
$this->setThemeFontLang($documentSettings->getThemeFontLang());
|
||||||
$this->setRevisionView($documentSettings->getRevisionView());
|
$this->setRevisionView($documentSettings->getRevisionView());
|
||||||
$this->setDocumentProtection($documentSettings->getDocumentProtection());
|
$this->setDocumentProtection($documentSettings->getDocumentProtection());
|
||||||
$this->setProofState($documentSettings->getProofState());
|
$this->setProofState($documentSettings->getProofState());
|
||||||
$this->setZoom($documentSettings->getZoom());
|
$this->setZoom($documentSettings->getZoom());
|
||||||
$this->getCompatibility();
|
$this->setCompatibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -236,6 +237,7 @@ class Settings extends AbstractPart
|
||||||
private function setRevisionView(TrackChangesView $trackChangesView = null)
|
private function setRevisionView(TrackChangesView $trackChangesView = null)
|
||||||
{
|
{
|
||||||
if ($trackChangesView != null) {
|
if ($trackChangesView != null) {
|
||||||
|
$revisionView = array();
|
||||||
$revisionView['w:markup'] = $trackChangesView->hasMarkup() ? 'true' : 'false';
|
$revisionView['w:markup'] = $trackChangesView->hasMarkup() ? 'true' : 'false';
|
||||||
$revisionView['w:comments'] = $trackChangesView->hasComments() ? 'true' : 'false';
|
$revisionView['w:comments'] = $trackChangesView->hasComments() ? 'true' : 'false';
|
||||||
$revisionView['w:insDel'] = $trackChangesView->hasInsDel() ? 'true' : 'false';
|
$revisionView['w:insDel'] = $trackChangesView->hasInsDel() ? 'true' : 'false';
|
||||||
|
|
@ -279,7 +281,7 @@ class Settings extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Get compatibility setting.
|
* Get compatibility setting.
|
||||||
*/
|
*/
|
||||||
private function getCompatibility()
|
private function setCompatibility()
|
||||||
{
|
{
|
||||||
$compatibility = $this->getParentWriter()->getPhpWord()->getCompatibility();
|
$compatibility = $this->getParentWriter()->getPhpWord()->getCompatibility();
|
||||||
if ($compatibility->getOoxmlVersion() !== null) {
|
if ($compatibility->getOoxmlVersion() !== null) {
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ class Font extends AbstractStyle
|
||||||
|
|
||||||
// Bold, italic
|
// Bold, italic
|
||||||
$xmlWriter->writeElementIf($style->isBold(), 'w:b');
|
$xmlWriter->writeElementIf($style->isBold(), 'w:b');
|
||||||
|
$xmlWriter->writeElementIf($style->isBold(), 'w:bCs');
|
||||||
$xmlWriter->writeElementIf($style->isItalic(), 'w:i');
|
$xmlWriter->writeElementIf($style->isItalic(), 'w:i');
|
||||||
$xmlWriter->writeElementIf($style->isItalic(), 'w:iCs');
|
$xmlWriter->writeElementIf($style->isItalic(), 'w:iCs');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,4 +162,14 @@ class SettingsTest extends \PHPUnit\Framework\TestCase
|
||||||
$oSettings->setZoom(Zoom::FULL_PAGE);
|
$oSettings->setZoom(Zoom::FULL_PAGE);
|
||||||
$this->assertEquals('fullPage', $oSettings->getZoom());
|
$this->assertEquals('fullPage', $oSettings->getZoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Update Fields on update
|
||||||
|
*/
|
||||||
|
public function testUpdateFields()
|
||||||
|
{
|
||||||
|
$oSettings = new Settings();
|
||||||
|
$oSettings->setUpdateFields(true);
|
||||||
|
$this->assertTrue($oSettings->hasUpdateFields());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase
|
||||||
$result = Converter::pixelToPoint($value);
|
$result = Converter::pixelToPoint($value);
|
||||||
$this->assertEquals($value / 96 * 72, $result);
|
$this->assertEquals($value / 96 * 72, $result);
|
||||||
|
|
||||||
$result = Converter::pixelToEMU($value);
|
$result = Converter::pixelToEmu($value);
|
||||||
$this->assertEquals(round($value * 9525), $result);
|
$this->assertEquals(round($value * 9525), $result);
|
||||||
|
|
||||||
$result = Converter::pointToTwip($value);
|
$result = Converter::pointToTwip($value);
|
||||||
|
|
@ -82,7 +82,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase
|
||||||
$result = Converter::pointToPixel($value);
|
$result = Converter::pointToPixel($value);
|
||||||
$this->assertEquals($value / 72 * 96, $result);
|
$this->assertEquals($value / 72 * 96, $result);
|
||||||
|
|
||||||
$result = Converter::pointToEMU($value);
|
$result = Converter::pointToEmu($value);
|
||||||
$this->assertEquals(round($value / 72 * 96 * 9525), $result);
|
$this->assertEquals(round($value / 72 * 96 * 9525), $result);
|
||||||
|
|
||||||
$result = Converter::emuToPixel($value);
|
$result = Converter::emuToPixel($value);
|
||||||
|
|
@ -111,7 +111,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase
|
||||||
$values[] = array('0F9D', false); // 4 characters
|
$values[] = array('0F9D', false); // 4 characters
|
||||||
// Conduct test
|
// Conduct test
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
$result = Converter::htmlToRGB($value[0]);
|
$result = Converter::htmlToRgb($value[0]);
|
||||||
$this->assertEquals($value[1], $result);
|
$this->assertEquals($value[1], $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,21 +29,21 @@ class NumberingTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testGetSetProperties()
|
public function testGetSetProperties()
|
||||||
{
|
{
|
||||||
$this->object = new Numbering();
|
$object = new Numbering();
|
||||||
$this->properties = array(
|
$properties = array(
|
||||||
'numId' => array(null, 1),
|
'numId' => array(null, 1),
|
||||||
'type' => array(null, 'singleLevel'),
|
'type' => array(null, 'singleLevel'),
|
||||||
);
|
);
|
||||||
foreach ($this->properties as $property => $value) {
|
foreach ($properties as $property => $value) {
|
||||||
list($default, $expected) = $value;
|
list($default, $expected) = $value;
|
||||||
$get = "get{$property}";
|
$get = "get{$property}";
|
||||||
$set = "set{$property}";
|
$set = "set{$property}";
|
||||||
|
|
||||||
$this->assertEquals($default, $this->object->$get()); // Default value
|
$this->assertEquals($default, $object->$get()); // Default value
|
||||||
|
|
||||||
$this->object->$set($expected);
|
$object->$set($expected);
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->object->$get()); // New value
|
$this->assertEquals($expected, $object->$get()); // New value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,8 +52,8 @@ class NumberingTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testGetLevels()
|
public function testGetLevels()
|
||||||
{
|
{
|
||||||
$this->object = new Numbering();
|
$object = new Numbering();
|
||||||
|
|
||||||
$this->assertEmpty($this->object->getLevels());
|
$this->assertEmpty($object->getLevels());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ class TableTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$value = 'FF0000';
|
$value = 'FF0000';
|
||||||
$object->setBorderColor($value);
|
$object->setBorderColor($value);
|
||||||
|
$values = array();
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
$get = "getBorder{$part}Color";
|
$get = "getBorder{$part}Color";
|
||||||
$values[] = $value;
|
$values[] = $value;
|
||||||
|
|
@ -121,6 +122,7 @@ class TableTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$value = 4;
|
$value = 4;
|
||||||
$object->setBorderSize($value);
|
$object->setBorderSize($value);
|
||||||
|
$values = array();
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
$get = "getBorder{$part}Size";
|
$get = "getBorder{$part}Size";
|
||||||
$values[] = $value;
|
$values[] = $value;
|
||||||
|
|
@ -143,6 +145,7 @@ class TableTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$value = 240;
|
$value = 240;
|
||||||
$object->setCellMargin($value);
|
$object->setCellMargin($value);
|
||||||
|
$values = array();
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
$get = "getCellMargin{$part}";
|
$get = "getCellMargin{$part}";
|
||||||
$values[] = $value;
|
$values[] = $value;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText;
|
namespace PhpOffice\PhpWord\Writer\ODText;
|
||||||
|
|
||||||
use PhpOffice\Common\XMLWriter;
|
use PhpOffice\Common\XMLWriter;
|
||||||
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\TestHelperDOCX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for PhpOffice\PhpWord\Writer\ODText\Element subnamespace
|
* Test class for PhpOffice\PhpWord\Writer\ODText\Element subnamespace
|
||||||
|
|
@ -40,4 +42,21 @@ class ElementTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->assertEquals('', $xmlWriter->getData());
|
$this->assertEquals('', $xmlWriter->getData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test PageBreak
|
||||||
|
*/
|
||||||
|
public function testPageBreak()
|
||||||
|
{
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$section = $phpWord->addSection();
|
||||||
|
$section->addText('test');
|
||||||
|
$section->addPageBreak();
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
|
||||||
|
|
||||||
|
$element = '/office:document-content/office:body/office:text/text:section/text:p[2]';
|
||||||
|
$this->assertTrue($doc->elementExists($element, 'content.xml'));
|
||||||
|
$this->assertEquals('P1', $doc->getElementAttribute($element, 'text:style-name', 'content.xml'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\RTF;
|
namespace PhpOffice\PhpWord\Writer\RTF;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Writer\RTF\Style\Border;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for PhpOffice\PhpWord\Writer\RTF\Style subnamespace
|
* Test class for PhpOffice\PhpWord\Writer\RTF\Style subnamespace
|
||||||
*/
|
*/
|
||||||
|
|
@ -35,4 +37,22 @@ class StyleTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->assertEquals('', $object->write());
|
$this->assertEquals('', $object->write());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBorderWithNonRegisteredColors()
|
||||||
|
{
|
||||||
|
$border = new Border();
|
||||||
|
$border->setSizes(array(1, 2, 3, 4));
|
||||||
|
$border->setColors(array('#FF0000', '#FF0000', '#FF0000', '#FF0000'));
|
||||||
|
$border->setSizes(array(20, 20, 20, 20));
|
||||||
|
|
||||||
|
$content = $border->write();
|
||||||
|
|
||||||
|
$expected = '\pgbrdropt32';
|
||||||
|
$expected .= '\pgbrdrt\brdrs\brdrw20\brdrcf0\brsp480 ';
|
||||||
|
$expected .= '\pgbrdrl\brdrs\brdrw20\brdrcf0\brsp480 ';
|
||||||
|
$expected .= '\pgbrdrr\brdrs\brdrw20\brdrcf0\brsp480 ';
|
||||||
|
$expected .= '\pgbrdrb\brdrs\brdrw20\brdrcf0\brsp480 ';
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue