Merge branch 'master' into allowImageClosure
This commit is contained in:
commit
68118685d0
21
CHANGELOG.md
21
CHANGELOG.md
|
|
@ -3,18 +3,33 @@ 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.17.0 (?? ??? 2019)
|
v0.17.0 (01 oct 2019)
|
||||||
----------------------
|
----------------------
|
||||||
### Added
|
### Added
|
||||||
- Add RightToLeft table presentation. @troosan #1550
|
- Add methods setValuesFromArray and cloneRowFromArray to the TemplateProcessor @geraldb-nicat #670
|
||||||
- Set complex type in template @troosan #1565
|
- 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
|
- 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
|
### Fixed
|
||||||
- Fix HTML border-color parsing. @troosan #1551 #1570
|
- 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
|
### Miscellaneous
|
||||||
- Use embedded http server to test loading of remote images @troosan #
|
- 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)
|
v0.16.0 (30 dec 2018)
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-develop": "0.17-dev"
|
"dev-develop": "0.18-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ copyright = u'2014-2017, PHPWord Contributors'
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '0.16.0'
|
version = '0.17.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = version
|
release = version
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ Example:
|
||||||
|
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"phpoffice/phpword": "v0.14.*"
|
"phpoffice/phpword": "v0.17.*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ abstract class AbstractElement
|
||||||
/**
|
/**
|
||||||
* A reference to the parent
|
* A reference to the parent
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Element\AbstractElement
|
* @var AbstractElement|null
|
||||||
*/
|
*/
|
||||||
private $parent;
|
private $parent;
|
||||||
|
|
||||||
|
|
@ -335,6 +335,11 @@ abstract class AbstractElement
|
||||||
$this->commentRangeEnd->setEndElement($this);
|
$this->commentRangeEnd->setEndElement($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get parent element
|
||||||
|
*
|
||||||
|
* @return AbstractElement|null
|
||||||
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return $this->parent;
|
return $this->parent;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?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 2019 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\RTF\Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field element writer
|
||||||
|
*
|
||||||
|
* Note: for now, only date, page and numpages fields are implemented for RTF.
|
||||||
|
*/
|
||||||
|
class Field extends Text
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write field element.
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$element = $this->element;
|
||||||
|
if (!$element instanceof \PhpOffice\PhpWord\Element\Field) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getStyles();
|
||||||
|
|
||||||
|
$content = '';
|
||||||
|
$content .= $this->writeOpening();
|
||||||
|
$content .= '{';
|
||||||
|
$content .= $this->writeFontStyle();
|
||||||
|
|
||||||
|
$methodName = 'write' . ucfirst(strtolower($element->getType()));
|
||||||
|
if (!method_exists($this, $methodName)) {
|
||||||
|
// Unsupported field
|
||||||
|
$content .= '';
|
||||||
|
} else {
|
||||||
|
$content .= '\\field{\\*\\fldinst ';
|
||||||
|
$content .= $this->$methodName($element);
|
||||||
|
$content .= '}{\\fldrslt}';
|
||||||
|
}
|
||||||
|
$content .= '}';
|
||||||
|
$content .= $this->writeClosing();
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function writePage()
|
||||||
|
{
|
||||||
|
return 'PAGE';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function writeNumpages()
|
||||||
|
{
|
||||||
|
return 'NUMPAGES';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function writeDate(\PhpOffice\PhpWord\Element\Field $element)
|
||||||
|
{
|
||||||
|
$content = '';
|
||||||
|
$content .= 'DATE';
|
||||||
|
$properties = $element->getProperties();
|
||||||
|
if (isset($properties['dateformat'])) {
|
||||||
|
$content .= ' \\\\@ "' . $properties['dateformat'] . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ class ElementTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testUnmatchedElements()
|
public function testUnmatchedElements()
|
||||||
{
|
{
|
||||||
$elements = array('Container', 'Text', 'Title', 'Link', 'Image', 'Table');
|
$elements = array('Container', 'Text', 'Title', 'Link', 'Image', 'Table', 'Field');
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $element;
|
$objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $element;
|
||||||
$parentWriter = new RTF();
|
$parentWriter = new RTF();
|
||||||
|
|
@ -39,4 +39,40 @@ class ElementTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->assertEquals('', $object->write());
|
$this->assertEquals('', $object->write());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPageField()
|
||||||
|
{
|
||||||
|
$parentWriter = new RTF();
|
||||||
|
$element = new \PhpOffice\PhpWord\Element\Field('PAGE');
|
||||||
|
$field = new \PhpOffice\PhpWord\Writer\RTF\Element\Field($parentWriter, $element);
|
||||||
|
|
||||||
|
$this->assertEquals("{\\field{\\*\\fldinst PAGE}{\\fldrslt}}\\par\n", $field->write());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNumpageField()
|
||||||
|
{
|
||||||
|
$parentWriter = new RTF();
|
||||||
|
$element = new \PhpOffice\PhpWord\Element\Field('NUMPAGES');
|
||||||
|
$field = new \PhpOffice\PhpWord\Writer\RTF\Element\Field($parentWriter, $element);
|
||||||
|
|
||||||
|
$this->assertEquals("{\\field{\\*\\fldinst NUMPAGES}{\\fldrslt}}\\par\n", $field->write());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDateField()
|
||||||
|
{
|
||||||
|
$parentWriter = new RTF();
|
||||||
|
$element = new \PhpOffice\PhpWord\Element\Field('DATE', array('dateformat' => 'd MM yyyy H:mm:ss'));
|
||||||
|
$field = new \PhpOffice\PhpWord\Writer\RTF\Element\Field($parentWriter, $element);
|
||||||
|
|
||||||
|
$this->assertEquals("{\\field{\\*\\fldinst DATE \\\\@ \"d MM yyyy H:mm:ss\"}{\\fldrslt}}\\par\n", $field->write());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIndexField()
|
||||||
|
{
|
||||||
|
$parentWriter = new RTF();
|
||||||
|
$element = new \PhpOffice\PhpWord\Element\Field('INDEX');
|
||||||
|
$field = new \PhpOffice\PhpWord\Writer\RTF\Element\Field($parentWriter, $element);
|
||||||
|
|
||||||
|
$this->assertEquals("{}\\par\n", $field->write());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue