Merge branch 'develop' of https://github.com/PHPOffice/PHPWord into tmp

Conflicts:
	tests/PhpWord/Shared/HtmlTest.php
This commit is contained in:
troosan 2021-02-10 21:04:16 +01:00
commit d4f08a3f8a
11 changed files with 260 additions and 53 deletions

View File

@ -3,6 +3,50 @@ Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
v0.18.0 (08 feb 2021)
----------------------
### Added
- allow to use customized pdf library [\#1983](https://github.com/PHPOffice/PHPWord/pull/1983) ([SailorMax](https://github.com/SailorMax))
- 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))
- 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))
- Add support for several features for the RTF writer [\#1775](https://github.com/PHPOffice/PHPWord/pull/1775) ([oleibman](https://github.com/oleibman))
- Improvements in RTF writer [\#1755](https://github.com/PHPOffice/PHPWord/pull/1755) ([oleibman](https://github.com/oleibman))
- Add font style for Field elements [\#1774](https://github.com/PHPOffice/PHPWord/pull/1774) ([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 ListItemRun in HTML writer [\#1766](https://github.com/PHPOffice/PHPWord/pull/1766) ([stefan-91](https://github.com/stefan-91))
- Allow a closure to be passed with image replacement tags [\#1716](https://github.com/PHPOffice/PHPWord/pull/1716) ([mbardelmeijer](https://github.com/mbardelmeijer))
- Add support for charts in template processor [\#2012](https://github.com/PHPOffice/PHPWord/pull/2012) ([dbarzin](https://github.com/dbarzin))
- Update addHtml to handle style inheritance [\#1965](https://github.com/PHPOffice/PHPWord/pull/1965) ([Julien1138](https://github.com/Julien1138))
- Add parsing of HTML checkbox input field [\#1832](https://github.com/PHPOffice/PHPWord/pull/1832) ([Matze2010](https://github.com/Matze2010))
- Add Option for Dynamic Chart Legend Position [\#1922](https://github.com/PHPOffice/PHPWord/pull/1922) ([csk83](https://github.com/csk83))
### Fixed
- Add null check when setComplexValue is not found [\#1936](https://github.com/PHPOffice/PHPWord/pull/1936) ([YannikFirre](https://github.com/YannikFirre))
- 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 typo in docs. Update templates-processing.rst [\#1952](https://github.com/PHPOffice/PHPWord/pull/1952) ([mnvx](https://github.com/mnvx))
- Fixes PHPDoc @param and @return types for several Converter methods [\#1818](https://github.com/PHPOffice/PHPWord/pull/1818) ([caugner](https://github.com/caugner))
- Fix documentation and method name for FootnoteProperties [\#1776](https://github.com/PHPOffice/PHPWord/pull/1776) ([mdupont](https://github.com/mdupont))
- Fix PHPUnit tests on develop branch [\#1771](https://github.com/PHPOffice/PHPWord/pull/1771) ([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))
- Update templates processing docs [\#1729](https://github.com/PHPOffice/PHPWord/pull/1729) ([hcdias](https://github.com/hcdias))
- Fix limit not taken into account when adding image in template [\#1967](https://github.com/PHPOffice/PHPWord/pull/1967) ([jsochor](https://github.com/jsochor))
- Fix cloneBlock issue [\#2006](https://github.com/PHPOffice/PHPWord/pull/2006) ([lexdewilligen](https://github.com/lexdewilligen))
- TemplateProcessor cloneBlock wrongly clones images [\#1763](https://github.com/PHPOffice/PHPWord/pull/1763) ([alarai](https://github.com/alarai))
- Some document have non-standard locale code [\#1824](https://github.com/PHPOffice/PHPWord/pull/1824) ([ErnestStaug](https://github.com/ErnestStaug))
- Update the regexp to avoid catastrophic backtracking [\#1809](https://github.com/PHPOffice/PHPWord/pull/1809) ([juzser](https://github.com/juzser))
### 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))
- 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))
v0.17.0 (01 oct 2019)
----------------------
### Added

View File

@ -201,6 +201,7 @@ Available Chart style options:
- ``colors``. A list of colors to use in the chart.
- ``title``. The title for the chart.
- ``showLegend``. Show legend, *true* or *false*.
- ``LegendPosition``. Legend position, *r* (default), *b*, *t*, *l* or *tr*.
- ``categoryLabelPosition``. Label position for categories, *nextTo* (default), *low* or *high*.
- ``valueLabelPosition``. Label position for values, *nextTo* (default), *low* or *high*.
- ``categoryAxisTitle``. The title for the category axis.

View File

@ -25,6 +25,9 @@ $series2 = array(3, 1, 7, 2, 6);
$series3 = array(8, 3, 2, 5, 4);
$showGridLines = false;
$showAxisLabels = false;
$showLegend = true;
$legendPosition = 't';
// r = right, l = left, t = top, b = bottom, tr = top right
foreach ($chartTypes as $chartType) {
$section->addTitle(ucfirst($chartType), 2);
@ -33,6 +36,8 @@ foreach ($chartTypes as $chartType) {
$chart->getStyle()->setShowGridX($showGridLines);
$chart->getStyle()->setShowGridY($showGridLines);
$chart->getStyle()->setShowAxisLabels($showAxisLabels);
$chart->getStyle()->setShowLegend($showLegend);
$chart->getStyle()->setLegendPosition($legendPosition);
if (in_array($chartType, $twoSeries)) {
$chart->addSeries($categories, $series2);
}

View File

@ -115,7 +115,7 @@ class Html
// tables, cells
if (false !== strpos($val, '%')) {
// e.g. <table width="100%"> or <td width="50%">
$styles['width'] = intval($val) * 50;
$styles['width'] = (int) $val * 50;
$styles['unit'] = \PhpOffice\PhpWord\SimpleType\TblWidth::PERCENT;
} else {
// e.g. <table width="250> where "250" = 250px (always pixels)
@ -125,7 +125,7 @@ class Html
break;
case 'cellspacing':
// tables e.g. <table cellspacing="2">, where "2" = 2px (always pixels)
$val = intval($val).'px';
$val = (int) $val . 'px';
$styles['cellSpacing'] = Converter::cssToTwip($val);
break;
case 'bgcolor':
@ -426,7 +426,7 @@ class Html
$cell = $element->addCell($width, $cellStyles);
if (self::shouldAddTextRun($node)) {
return $cell->addTextRun(self::parseInlineStyle($node, $styles['paragraph']));
return $cell->addTextRun(self::filterOutNonInheritedStyles(self::parseInlineStyle($node, $styles['paragraph'])));
}
return $cell;
@ -457,15 +457,51 @@ class Html
*/
protected static function recursiveParseStylesInHierarchy(\DOMNode $node, array $style)
{
$parentStyle = self::parseInlineStyle($node, array());
$style = array_merge($parentStyle, $style);
$parentStyle = array();
if ($node->parentNode != null && XML_ELEMENT_NODE == $node->parentNode->nodeType) {
$style = self::recursiveParseStylesInHierarchy($node->parentNode, $style);
$parentStyle = self::recursiveParseStylesInHierarchy($node->parentNode, array());
}
if ($node->nodeName === '#text') {
$parentStyle = array_merge($parentStyle, $style);
} else {
$parentStyle = self::filterOutNonInheritedStyles($parentStyle);
}
$style = self::parseInlineStyle($node, $parentStyle);
return $style;
}
/**
* Removes non-inherited styles from array
*
* @param array &$styles
*/
protected static function filterOutNonInheritedStyles(array $styles)
{
$nonInheritedStyles = array(
'borderSize',
'borderTopSize',
'borderRightSize',
'borderBottomSize',
'borderLeftSize',
'borderColor',
'borderTopColor',
'borderRightColor',
'borderBottomColor',
'borderLeftColor',
'borderStyle',
'spaceAfter',
'spaceBefore',
'underline',
'strikethrough',
'hidden',
);
$styles = array_diff_key($styles, array_flip($nonInheritedStyles));
return $styles;
}
/**
* Parse list node
*
@ -706,7 +742,8 @@ class Html
// Word does not accept shortened hex colors e.g. #CCC, only full e.g. #CCCCCC
if (preg_match('/([0-9]+[^0-9]*)\s+(\#[a-fA-F0-9]+|[a-zA-Z]+)\s+([a-z]+)/', $cValue, $matches)) {
if (false !== strpos($cKey, '-')) {
$which = explode('-', $cKey)[1];
$tmp = explode('-', $cKey);
$which = $tmp[1];
$which = ucfirst($which); // e.g. bottom -> Bottom
} else {
$which = '';
@ -718,7 +755,7 @@ class Html
// This may be adjusted, if better ratio or formula found.
// BC change: up to ver. 0.17.0 was $size converted to points - Converter::cssToPoint($size)
$size = Converter::cssToTwip($matches[1]);
$size = intval($size / 2);
$size = (int) ($size / 2);
// valid variants may be e.g. borderSize, borderTopSize, borderLeftColor, etc ..
$styles["border{$which}Size"] = $size; // twips
$styles["border{$which}Color"] = trim($matches[2], '#');
@ -896,9 +933,9 @@ class Html
}
/**
* Transforms a HTML/CSS alignment into a \PhpOffice\PhpWord\SimpleType\Jc
* Transforms a HTML/CSS vertical alignment
*
* @param string $cssAlignment
* @param string $alignment
* @return string|null
*/
protected static function mapAlignVertical($alignment)
@ -926,10 +963,10 @@ class Html
}
/**
* Map list style for ordered list
*
* @param string $cssListType
*/
* Map list style for ordered list
*
* @param string $cssListType
*/
protected static function mapListType($cssListType)
{
switch ($cssListType) {
@ -984,12 +1021,12 @@ class Html
}
/**
* Render horizontal rule
* Note: Word rule is not the same as HTML's <hr> since it does not support width and thus neither alignment
*
* @param \DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
*/
* Render horizontal rule
* Note: Word rule is not the same as HTML's <hr> since it does not support width and thus neither alignment
*
* @param \DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
*/
protected static function parseHorizRule($node, $element)
{
$styles = self::parseInlineStyle($node);
@ -997,19 +1034,19 @@ class Html
// <hr> is implemented as an empty paragraph - extending 100% inside the section
// Some properties may be controlled, e.g. <hr style="border-bottom: 3px #DDDDDD solid; margin-bottom: 0;">
$fontStyle = $styles + ['size' => 3];
$fontStyle = $styles + array('size' => 3);
$paragraphStyle = $styles + [
'lineHeight' => 0.25, // multiply default line height - e.g. 1, 1.5 etc
'spacing' => 0, // twip
'spaceBefore' => 120, // twip, 240/2 (default line height)
'spaceAfter' => 120, // twip
'borderBottomSize' => empty($styles['line-height']) ? 1 : $styles['line-height'],
$paragraphStyle = $styles + array(
'lineHeight' => 0.25, // multiply default line height - e.g. 1, 1.5 etc
'spacing' => 0, // twip
'spaceBefore' => 120, // twip, 240/2 (default line height)
'spaceAfter' => 120, // twip
'borderBottomSize' => empty($styles['line-height']) ? 1 : $styles['line-height'],
'borderBottomColor' => empty($styles['color']) ? '000000' : $styles['color'],
'borderBottomStyle' => 'single', // same as "solid"
];
);
$element->addText("", $fontStyle, $paragraphStyle);
$element->addText('', $fontStyle, $paragraphStyle);
// Notes: <hr/> cannot be:
// - table - throws error "cannot be inside textruns", e.g. lists

View File

@ -0,0 +1,58 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
* @copyright 2010-2018 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\SimpleType;
use PhpOffice\PhpWord\Shared\AbstractEnum;
/**
* Border Styles.
*
* @since 0.18.0
*
* @see http://www.datypic.com/sc/ooxml/t-w_ST_Border.html
*/
final class Border extends AbstractEnum
{
const SINGLE = 'single'; //A single line
const DASH_DOT_STROKED = 'dashDotStroked'; //A line with a series of alternating thin and thick strokes
const DASHED = 'dashed'; //A dashed line
const DASH_SMALL_GAP = 'dashSmallGap'; //A dashed line with small gaps
const DOT_DASH = 'dotDash'; //A line with alternating dots and dashes
const DOT_DOT_DASH = 'dotDotDash'; //A line with a repeating dot - dot - dash sequence
const DOTTED = 'dotted'; //A dotted line
const DOUBLE = 'double'; //A double line
const DOUBLE_WAVE = 'doubleWave'; //A double wavy line
const INSET = 'inset'; //An inset set of lines
const NIL = 'nil'; //No border
const NONE = 'none'; //No border
const OUTSET = 'outset'; //An outset set of lines
const THICK = 'thick'; //A single line
const THICK_THIN_LARGE_GAP = 'thickThinLargeGap'; //A thick line contained within a thin line with a large-sized intermediate gap
const THICK_THIN_MEDIUM_GAP = 'thickThinMediumGap'; //A thick line contained within a thin line with a medium-sized intermediate gap
const THICK_THIN_SMALL_GAP = 'thickThinSmallGap'; //A thick line contained within a thin line with a small intermediate gap
const THIN_THICK_LARGE_GAP = 'thinThickLargeGap'; //A thin line contained within a thick line with a large-sized intermediate gap
const THIN_THICK_MEDIUM_GAP = 'thinThickMediumGap'; //A thick line contained within a thin line with a medium-sized intermediate gap
const THIN_THICK_SMALL_GAP = 'thinThickSmallGap'; //A thick line contained within a thin line with a small intermediate gap
const THIN_THICK_THINLARGE_GAP = 'thinThickThinLargeGap'; //A thin-thick-thin line with a large gap
const THIN_THICK_THIN_MEDIUM_GAP = 'thinThickThinMediumGap'; //A thin-thick-thin line with a medium gap
const THIN_THICK_THIN_SMALL_GAP = 'thinThickThinSmallGap'; //A thin-thick-thin line with a small gap
const THREE_D_EMBOSS = 'threeDEmboss'; //A three-staged gradient line, getting darker towards the paragraph
const THREE_D_ENGRAVE = 'threeDEngrave'; //A three-staged gradient like, getting darker away from the paragraph
const TRIPLE = 'triple'; //A triple line
const WAVE = 'wave'; //A wavy line
}

View File

@ -66,6 +66,14 @@ class Chart extends AbstractStyle
*/
private $showLegend = false;
/**
* Chart legend Position.
* Possible values are 'r', 't', 'b', 'l', 'tr'
*
* @var string
*/
private $legendPosition = 'r';
/**
* A list of display options for data labels
*
@ -233,6 +241,7 @@ class Chart extends AbstractStyle
* Set the colors to use in a chart.
*
* @param array $value a list of colors to use in the chart
* @return self
*/
public function setColors($value = array())
{
@ -255,6 +264,7 @@ class Chart extends AbstractStyle
* Set the chart title
*
* @param string $value
* @return self
*/
public function setTitle($value = null)
{
@ -277,6 +287,7 @@ class Chart extends AbstractStyle
* Set chart legend visibility
*
* @param bool $value
* @return self
*/
public function setShowLegend($value = false)
{
@ -285,6 +296,37 @@ class Chart extends AbstractStyle
return $this;
}
/**
* Get chart legend position
*
* @return string
*/
public function getLegendPosition()
{
return $this->legendPosition;
}
/**
* Set chart legend position. choices:
* "r" - right of chart
* "b" - bottom of chart
* "t" - top of chart
* "l" - left of chart
* "tr" - top right of chart
*
* default: right
*
* @param string $legendPosition
* @return self
*/
public function setLegendPosition($legendPosition = 'r')
{
$enum = array('r', 'b', 't', 'l', 'tr');
$this->legendPosition = $this->setEnumVal($legendPosition, $enum, $this->legendPosition);
return $this;
}
/*
* Show labels for axis
*
@ -328,7 +370,10 @@ class Chart extends AbstractStyle
{
foreach (array_keys($this->dataLabelOptions) as $option) {
if (isset($values[$option])) {
$this->dataLabelOptions[$option] = $this->setBoolVal($values[$option], $this->dataLabelOptions[$option]);
$this->dataLabelOptions[$option] = $this->setBoolVal(
$values[$option],
$this->dataLabelOptions[$option]
);
}
}
}

View File

@ -228,6 +228,10 @@ final class Language extends AbstractStyle
*/
private function validateLocale($locale)
{
if ($locale !== null) {
$locale = str_replace('_', '-', $locale);
}
if (strlen($locale) === 2) {
return strtolower($locale) . '-' . strtoupper($locale);
}

View File

@ -798,7 +798,7 @@ class TemplateProcessor
$xmlBlock = null;
$matches = array();
preg_match(
'/(<\?xml.*)(<w:p\b.*>\${' . $blockname . '}<\/w:.*?p>)(.*)(<w:p\b.*\${\/' . $blockname . '}<\/w:.*?p>)/is',
'/(.*((?s)<w:p\b(?:(?!<w:p\b).)*?\${' . $blockname . '}<\/w:.*?p>))(.*)((?s)<w:p\b(?:(?!<w:p\b).)[^$]*?\${\/' . $blockname . '}<\/w:.*?p>)/is',
$this->tempDocumentMainPart,
$matches
);
@ -1182,7 +1182,7 @@ class TemplateProcessor
* @param string $blockType XML tag type of block
* @return \PhpOffice\PhpWord\TemplateProcessor Fluent interface
*/
protected function replaceXmlBlock($macro, $block, $blockType = 'w:p')
public function replaceXmlBlock($macro, $block, $blockType = 'w:p')
{
$where = $this->findContainingXmlBlockForMacro($macro, $blockType);
if (is_array($where)) {

View File

@ -131,6 +131,7 @@ class Chart extends AbstractPart
$title = $style->getTitle();
$showLegend = $style->isShowLegend();
$legendPosition = $style->getLegendPosition();
//Chart title
if ($title) {
@ -154,7 +155,7 @@ class Chart extends AbstractPart
//Chart legend
if ($showLegend) {
$xmlWriter->writeRaw('<c:legend><c:legendPos val="r"/></c:legend>');
$xmlWriter->writeRaw('<c:legend><c:legendPos val="' . $legendPosition . '"/></c:legend>');
}
$xmlWriter->startElement('c:plotArea');

View File

@ -132,6 +132,7 @@ class Paragraph extends AbstractStyle
$styleWriter = new MarginBorder($xmlWriter);
$styleWriter->setSizes($style->getBorderSize());
$styleWriter->setStyles($style->getBorderStyle());
$styleWriter->setColors($style->getBorderColor());
$styleWriter->write();

View File

@ -293,11 +293,11 @@ class HtmlTest extends AbstractWebServerEmbeddedTest
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$html = '<table align="left" style="width: 50%; border: 6px #0000FF solid;">
$html = '<table align="left" style="width: 50%; border: 12px #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; border-color: #00EE00">header b</th>
<tr style="background-color: #FF0000; text-align: center; color: #FFFFFF; font-weight: bold">
<th style="width: 50pt"><p>header a</p></th>
<th style="width: 50; border-color: #00EE00; border-width: 3px"><span>header b</span></th>
<th style="border-color: #00AA00 #00BB00 #00CC00 #00DD00; border-width: 3px">header c</th>
</tr>
</thead>
@ -324,6 +324,12 @@ class HtmlTest extends AbstractWebServerEmbeddedTest
$this->assertEquals('00BB00', $doc->getElementAttribute('/w:document/w:body/w:tbl/w:tr[1]/w:tc[3]/w:tcPr/w:tcBorders/w:right', 'w:color'));
$this->assertEquals('00CC00', $doc->getElementAttribute('/w:document/w:body/w:tbl/w:tr[1]/w:tc[3]/w:tcPr/w:tcBorders/w:bottom', 'w:color'));
$this->assertEquals('00DD00', $doc->getElementAttribute('/w:document/w:body/w:tbl/w:tr[1]/w:tc[3]/w:tcPr/w:tcBorders/w:left', 'w:color'));
//check borders are not propagated inside cells
$this->assertTrue($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p'));
$this->assertFalse($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:pBdr'));
$this->assertTrue($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p'));
$this->assertFalse($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:pBdr'));
}
/**
@ -634,6 +640,7 @@ class HtmlTest extends AbstractWebServerEmbeddedTest
}
/**
<<<<<<< HEAD
* Tests checkbox input field
*/
public function testInputCheckbox()
@ -655,12 +662,16 @@ class HtmlTest extends AbstractWebServerEmbeddedTest
/**
* Parse widths in tables and cells, which also allows for controlling column width
*/
=======
* Parse widths in tables and cells, which also allows for controlling column width
*/
>>>>>>> branch 'develop' of https://github.com/PHPOffice/PHPWord
public function testParseTableAndCellWidth()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection([
$section = $phpWord->addSection(array(
'orientation' => \PhpOffice\PhpWord\Style\Section::ORIENTATION_LANDSCAPE,
]);
));
// borders & backgrounds are here just for better visual comparison
$html = <<<HTML
@ -722,14 +733,14 @@ HTML;
}
/**
* Test parsing background color for table rows and table cellspacing
*/
* Test parsing background color for table rows and table cellspacing
*/
public function testParseCellspacingRowBgColor()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection([
$section = $phpWord->addSection(array(
'orientation' => \PhpOffice\PhpWord\Style\Section::ORIENTATION_LANDSCAPE,
]);
));
// borders & backgrounds are here just for better visual comparison
$html = <<<HTML
@ -763,8 +774,8 @@ HTML;
}
/**
* Parse horizontal rule
*/
* Parse horizontal rule
*/
public function testParseHorizRule()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
@ -793,7 +804,7 @@ HTML;
$xpath = '/w:document/w:body/w:p[4]/w:pPr/w:pBdr/w:bottom';
$this->assertTrue($doc->elementExists($xpath));
$this->assertEquals('single', $doc->getElement($xpath)->getAttribute('w:val'));
$this->assertEquals(intval(5 * 15 / 2), $doc->getElement($xpath)->getAttribute('w:sz'));
$this->assertEquals((int) (5 * 15 / 2), $doc->getElement($xpath)->getAttribute('w:sz'));
$this->assertEquals('lightblue', $doc->getElement($xpath)->getAttribute('w:color'));
$xpath = '/w:document/w:body/w:p[4]/w:pPr/w:spacing';
@ -804,8 +815,8 @@ HTML;
}
/**
* Parse ordered list start & numbering style
*/
* Parse ordered list start & numbering style
*/
public function testParseOrderedList()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
@ -865,8 +876,8 @@ HTML;
}
/**
* Parse ordered list start & numbering style
*/
* Parse ordered list start & numbering style
*/
public function testParseVerticalAlign()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
@ -905,8 +916,8 @@ HTML;
}
/**
* Fix bug - don't decode double quotes inside double quoted string
*/
* Fix bug - don't decode double quotes inside double quoted string
*/
public function testDontDecodeAlreadyEncodedDoubleQuotes()
{
$phpWord = new \PhpOffice\PhpWord\PhpWord();
@ -919,6 +930,6 @@ HTML;
Html::addHtml($section, $html);
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
$this->assertTrue(is_object($doc));
$this->assertInternalType('object', $doc);
}
}