Style: Remove `bgColor` from `Font`, `Table`, and `Cell` and put it into the new `Shading` style
This commit is contained in:
parent
9afa46105e
commit
999a9c5037
|
|
@ -42,6 +42,7 @@ This release marked heavy refactorings on internal code structure with the creat
|
||||||
- Section: Ability to define gutter and line numbering - @ivanlanin
|
- Section: Ability to define gutter and line numbering - @ivanlanin
|
||||||
- Font: Small caps, all caps, and double strikethrough - @ivanlanin GH-151
|
- Font: Small caps, all caps, and double strikethrough - @ivanlanin GH-151
|
||||||
- Settings: Ability to use measurement unit other than twips with `setMeasurementUnit` - @ivanlanin GH-199
|
- Settings: Ability to use measurement unit other than twips with `setMeasurementUnit` - @ivanlanin GH-199
|
||||||
|
- Style: Remove `bgColor` from `Font`, `Table`, and `Cell` and put it into the new `Shading` style - @ivanlanin
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
// Ads styles
|
// Ads styles
|
||||||
$phpWord->addParagraphStyle('pStyle', array('spacing'=>100));
|
$phpWord->addParagraphStyle('pStyle', array('spacing'=>100));
|
||||||
$phpWord->addFontStyle('BoldText', array('bold'=>true));
|
$phpWord->addFontStyle('BoldText', array('bold'=>true));
|
||||||
$phpWord->addFontStyle('ColoredText', array('color'=>'FF8080'));
|
$phpWord->addFontStyle('ColoredText', array('color'=>'FF8080', 'bgColor' => 'FFFFCC'));
|
||||||
$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
|
$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
|
||||||
|
|
||||||
// New portrait section
|
// New portrait section
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ $section->addTextBreak(1);
|
||||||
$section->addText("Table with colspan and rowspan", $header);
|
$section->addText("Table with colspan and rowspan", $header);
|
||||||
|
|
||||||
$styleTable = array('borderSize' => 6, 'borderColor' => '999999');
|
$styleTable = array('borderSize' => 6, 'borderColor' => '999999');
|
||||||
$cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center');
|
$cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center', 'bgColor' => 'FFFF00');
|
||||||
$cellRowContinue = array('vMerge' => 'continue');
|
$cellRowContinue = array('vMerge' => 'continue');
|
||||||
$cellColSpan = array('gridSpan' => 2, 'valign' => 'center');
|
$cellColSpan = array('gridSpan' => 2, 'valign' => 'center');
|
||||||
$cellHCentered = array('align' => 'center');
|
$cellHCentered = array('align' => 'center');
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Style;
|
namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Shared\String;
|
use PhpOffice\PhpWord\Style\Shading;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table cell style
|
* Table cell style
|
||||||
|
|
@ -33,13 +33,6 @@ class Cell extends Border
|
||||||
*/
|
*/
|
||||||
private $textDirection;
|
private $textDirection;
|
||||||
|
|
||||||
/**
|
|
||||||
* Background-Color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $bgColor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Border Default Color
|
* Border Default Color
|
||||||
*
|
*
|
||||||
|
|
@ -64,6 +57,13 @@ class Cell extends Border
|
||||||
*/
|
*/
|
||||||
private $vMerge = null;
|
private $vMerge = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shading
|
||||||
|
*
|
||||||
|
* @var \PhpOffice\PhpWord\Style\Shading
|
||||||
|
*/
|
||||||
|
private $shading;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Cell Style
|
* Create a new Cell Style
|
||||||
*/
|
*/
|
||||||
|
|
@ -71,7 +71,6 @@ class Cell extends Border
|
||||||
{
|
{
|
||||||
$this->valign = null;
|
$this->valign = null;
|
||||||
$this->textDirection = null;
|
$this->textDirection = null;
|
||||||
$this->bgColor = null;
|
|
||||||
$this->borderTopSize = null;
|
$this->borderTopSize = null;
|
||||||
$this->borderTopColor = null;
|
$this->borderTopColor = null;
|
||||||
$this->borderLeftSize = null;
|
$this->borderLeftSize = null;
|
||||||
|
|
@ -83,24 +82,6 @@ class Cell extends Border
|
||||||
$this->defaultBorderColor = '000000';
|
$this->defaultBorderColor = '000000';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set style value
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $value
|
|
||||||
*/
|
|
||||||
public function setStyleValue($key, $value)
|
|
||||||
{
|
|
||||||
$key = String::removeUnderscorePrefix($key);
|
|
||||||
if ($key == 'borderSize') {
|
|
||||||
$this->setBorderSize($value);
|
|
||||||
} elseif ($key == 'borderColor') {
|
|
||||||
$this->setBorderColor($value);
|
|
||||||
} else {
|
|
||||||
$this->$key = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get vertical align
|
* Get vertical align
|
||||||
*/
|
*/
|
||||||
|
|
@ -138,21 +119,26 @@ class Cell extends Border
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get background color
|
* Get background
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getBgColor()
|
public function getBgColor()
|
||||||
{
|
{
|
||||||
return $this->bgColor;
|
if (!is_null($this->shading)) {
|
||||||
|
return $this->shading->getFill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set background color
|
* Set background
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $value
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Table
|
||||||
*/
|
*/
|
||||||
public function setBgColor($pValue = null)
|
public function setBgColor($value = null)
|
||||||
{
|
{
|
||||||
$this->bgColor = $pValue;
|
$this->setShading(array('fill' => $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -198,4 +184,34 @@ class Cell extends Border
|
||||||
{
|
{
|
||||||
return $this->vMerge;
|
return $this->vMerge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get shading
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Shading
|
||||||
|
*/
|
||||||
|
public function getShading()
|
||||||
|
{
|
||||||
|
return $this->shading;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set shading
|
||||||
|
*
|
||||||
|
* @param array $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setShading($value = null)
|
||||||
|
{
|
||||||
|
if (is_array($value)) {
|
||||||
|
if (!$this->shading instanceof Shading) {
|
||||||
|
$this->shading = new Shading();
|
||||||
|
}
|
||||||
|
$this->shading->setStyleByArray($value);
|
||||||
|
} else {
|
||||||
|
$this->shading = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
use PhpOffice\PhpWord\Exception\InvalidStyleException;
|
use PhpOffice\PhpWord\Exception\InvalidStyleException;
|
||||||
|
use PhpOffice\PhpWord\Style\Shading;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Font style
|
* Font style
|
||||||
|
|
@ -153,12 +154,6 @@ class Font extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
private $fgColor = null;
|
private $fgColor = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Background color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $bgColor = null;
|
|
||||||
/**
|
/**
|
||||||
* Text line height
|
* Text line height
|
||||||
*
|
*
|
||||||
|
|
@ -195,6 +190,13 @@ class Font extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
private $allCaps = false;
|
private $allCaps = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shading
|
||||||
|
*
|
||||||
|
* @var \PhpOffice\PhpWord\Style\Shading
|
||||||
|
*/
|
||||||
|
private $shading;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new font style
|
* Create new font style
|
||||||
*
|
*
|
||||||
|
|
@ -501,26 +503,26 @@ class Font extends AbstractStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get background color
|
* Get background
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getBgColor()
|
public function getBgColor()
|
||||||
{
|
{
|
||||||
return $this->bgColor;
|
if (!is_null($this->shading)) {
|
||||||
|
return $this->shading->getFill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set background color
|
* Set background
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return $this
|
* @return \PhpOffice\PhpWord\Style\Table
|
||||||
*/
|
*/
|
||||||
public function setBgColor($value = null)
|
public function setBgColor($value = null)
|
||||||
{
|
{
|
||||||
$this->bgColor = $value;
|
$this->setShading(array('fill' => $value));
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -649,4 +651,34 @@ class Font extends AbstractStyle
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get shading
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Shading
|
||||||
|
*/
|
||||||
|
public function getShading()
|
||||||
|
{
|
||||||
|
return $this->shading;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set shading
|
||||||
|
*
|
||||||
|
* @param array $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setShading($value = null)
|
||||||
|
{
|
||||||
|
if (is_array($value)) {
|
||||||
|
if (!$this->shading instanceof Shading) {
|
||||||
|
$this->shading = new Shading();
|
||||||
|
}
|
||||||
|
$this->shading->setStyleByArray($value);
|
||||||
|
} else {
|
||||||
|
$this->shading = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ class LineNumbering extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set distance
|
* Set distance
|
||||||
*
|
*
|
||||||
* @param int|float $value
|
* @param string $value
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setRestart($value = null)
|
public function setRestart($value = null)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Style;
|
namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Style\LineNumbering;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section settings
|
* Section settings
|
||||||
*/
|
*/
|
||||||
|
|
@ -146,7 +148,7 @@ class Section extends Border
|
||||||
/**
|
/**
|
||||||
* Line numbering
|
* Line numbering
|
||||||
*
|
*
|
||||||
* @var array
|
* @var \PhpOffice\PhpWord\Style\LineNumbering
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/e-w_lnNumType-1.html
|
* @link http://www.schemacentral.com/sc/ooxml/e-w_lnNumType-1.html
|
||||||
*/
|
*/
|
||||||
private $lineNumbering;
|
private $lineNumbering;
|
||||||
|
|
@ -491,7 +493,7 @@ class Section extends Border
|
||||||
/**
|
/**
|
||||||
* Get line numbering
|
* Get line numbering
|
||||||
*
|
*
|
||||||
* @return self
|
* @return \PhpOffice\PhpWord\Style\LineNumbering
|
||||||
*/
|
*/
|
||||||
public function getLineNumbering()
|
public function getLineNumbering()
|
||||||
{
|
{
|
||||||
|
|
@ -506,20 +508,15 @@ class Section extends Border
|
||||||
*/
|
*/
|
||||||
public function setLineNumbering($value = null)
|
public function setLineNumbering($value = null)
|
||||||
{
|
{
|
||||||
if ($this->lineNumbering instanceof LineNumbering) {
|
if (is_array($value)) {
|
||||||
|
if (!$this->lineNumbering instanceof LineNumbering) {
|
||||||
|
$this->lineNumbering = new LineNumbering($value);
|
||||||
|
}
|
||||||
$this->lineNumbering->setStyleByArray($value);
|
$this->lineNumbering->setStyleByArray($value);
|
||||||
} else {
|
} else {
|
||||||
$this->lineNumbering = new LineNumbering($value);
|
$this->lineNumbering = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove line numbering
|
|
||||||
*/
|
|
||||||
public function removeLineNumbering()
|
|
||||||
{
|
|
||||||
$this->lineNumbering = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPWord
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2014 PHPWord
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shading style
|
||||||
|
*
|
||||||
|
* @link http://www.schemacentral.com/sc/ooxml/t-w_CT_Shd.html
|
||||||
|
* @since 0.10.0
|
||||||
|
*/
|
||||||
|
class Shading extends AbstractStyle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Shading pattern
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @link http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html
|
||||||
|
*/
|
||||||
|
private $pattern = 'clear';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shading pattern color
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $color = 'auto';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shading background color
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $fill;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance
|
||||||
|
*
|
||||||
|
* @param array $style
|
||||||
|
*/
|
||||||
|
public function __construct($style = array())
|
||||||
|
{
|
||||||
|
$this->setStyleByArray($style);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get pattern
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPattern()
|
||||||
|
{
|
||||||
|
return $this->pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set pattern
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setPattern($value = null)
|
||||||
|
{
|
||||||
|
$this->pattern = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get color
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getColor()
|
||||||
|
{
|
||||||
|
return $this->color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set pattern
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setColor($value = null)
|
||||||
|
{
|
||||||
|
$this->color = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get fill
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFill()
|
||||||
|
{
|
||||||
|
return $this->fill;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fill
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setFill($value = null)
|
||||||
|
{
|
||||||
|
$this->fill = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Style;
|
namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Shared\String;
|
use PhpOffice\PhpWord\Style\Shading;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table style
|
* Table style
|
||||||
|
|
@ -51,13 +51,6 @@ class Table extends Border
|
||||||
*/
|
*/
|
||||||
private $cellMarginBottom = null;
|
private $cellMarginBottom = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Background color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $bgColor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Border size inside horizontal
|
* Border size inside horizontal
|
||||||
*
|
*
|
||||||
|
|
@ -86,6 +79,13 @@ class Table extends Border
|
||||||
*/
|
*/
|
||||||
private $borderInsideVColor;
|
private $borderInsideVColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shading
|
||||||
|
*
|
||||||
|
* @var \PhpOffice\PhpWord\Style\Shading
|
||||||
|
*/
|
||||||
|
private $shading;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new table style
|
* Create new table style
|
||||||
*
|
*
|
||||||
|
|
@ -118,26 +118,6 @@ class Table extends Border
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set style value
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $value
|
|
||||||
*/
|
|
||||||
public function setStyleValue($key, $value)
|
|
||||||
{
|
|
||||||
$key = String::removeUnderscorePrefix($key);
|
|
||||||
if ($key == 'borderSize') {
|
|
||||||
$this->setBorderSize($value);
|
|
||||||
} elseif ($key == 'borderColor') {
|
|
||||||
$this->setBorderColor($value);
|
|
||||||
} elseif ($key == 'cellMargin') {
|
|
||||||
$this->setCellMargin($value);
|
|
||||||
} else {
|
|
||||||
$this->$key = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get First Row Style
|
* Get First Row Style
|
||||||
*
|
*
|
||||||
|
|
@ -155,131 +135,100 @@ class Table extends Border
|
||||||
*/
|
*/
|
||||||
public function getBgColor()
|
public function getBgColor()
|
||||||
{
|
{
|
||||||
return $this->bgColor;
|
if (!is_null($this->shading)) {
|
||||||
|
return $this->shading->getFill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set background
|
* Set background
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $value
|
||||||
* @return \PhpOffice\PhpWord\Style\Table
|
* @return \PhpOffice\PhpWord\Style\Table
|
||||||
*/
|
*/
|
||||||
public function setBgColor($pValue = null)
|
public function setBgColor($value = null)
|
||||||
{
|
{
|
||||||
$this->bgColor = $pValue;
|
$this->setShading(array('fill' => $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set TLRBVH Border Size
|
* Set TLRBHV Border Size
|
||||||
*
|
*
|
||||||
* @param int $pValue Border size in eighths of a point (1/8 point)
|
* @param int $value Border size in eighths of a point (1/8 point)
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderSize($pValue = null)
|
public function setBorderSize($value = null)
|
||||||
{
|
{
|
||||||
$this->borderTopSize = $pValue;
|
$this->setBorderTopSize($value);
|
||||||
$this->borderLeftSize = $pValue;
|
$this->setBorderLeftSize($value);
|
||||||
$this->borderRightSize = $pValue;
|
$this->setBorderRightSize($value);
|
||||||
$this->borderBottomSize = $pValue;
|
$this->setBorderBottomSize($value);
|
||||||
$this->borderInsideHSize = $pValue;
|
$this->setBorderInsideHSize($value);
|
||||||
$this->borderInsideVSize = $pValue;
|
$this->setBorderInsideVSize($value);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get TLRBVH Border Size
|
* Get TLRBHV Border Size
|
||||||
*
|
*
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
public function getBorderSize()
|
public function getBorderSize()
|
||||||
{
|
{
|
||||||
$top = $this->getBorderTopSize();
|
return array(
|
||||||
$left = $this->getBorderLeftSize();
|
$this->getBorderTopSize(),
|
||||||
$right = $this->getBorderRightSize();
|
$this->getBorderLeftSize(),
|
||||||
$bottom = $this->getBorderBottomSize();
|
$this->getBorderRightSize(),
|
||||||
$insideH = $this->getBorderInsideHSize();
|
$this->getBorderBottomSize(),
|
||||||
$insideV = $this->getBorderInsideVSize();
|
$this->getBorderInsideHSize(),
|
||||||
|
$this->getBorderInsideVSize(),
|
||||||
return array($top, $left, $right, $bottom, $insideH, $insideV);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set TLRBVH Border Color
|
* Set TLRBHV Border Color
|
||||||
* @param string $pValue
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderColor($pValue = null)
|
public function setBorderColor($value = null)
|
||||||
{
|
{
|
||||||
$this->borderTopColor = $pValue;
|
$this->setBorderTopColor($value);
|
||||||
$this->borderLeftColor = $pValue;
|
$this->setBorderLeftColor($value);
|
||||||
$this->borderRightColor = $pValue;
|
$this->setBorderRightColor($value);
|
||||||
$this->borderBottomColor = $pValue;
|
$this->setBorderBottomColor($value);
|
||||||
$this->borderInsideHColor = $pValue;
|
$this->setBorderInsideHColor($value);
|
||||||
$this->borderInsideVColor = $pValue;
|
$this->setBorderInsideVColor($value);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get TLRB Border Color
|
* Get TLRBHV Border Color
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getBorderColor()
|
public function getBorderColor()
|
||||||
{
|
{
|
||||||
$top = $this->getBorderTopColor();
|
return array(
|
||||||
$left = $this->getBorderLeftColor();
|
$this->getBorderTopColor(),
|
||||||
$right = $this->getBorderRightColor();
|
$this->getBorderLeftColor(),
|
||||||
$bottom = $this->getBorderBottomColor();
|
$this->getBorderRightColor(),
|
||||||
$insideH = $this->getBorderInsideHColor();
|
$this->getBorderBottomColor(),
|
||||||
$insideV = $this->getBorderInsideVColor();
|
$this->getBorderInsideHColor(),
|
||||||
|
$this->getBorderInsideVColor(),
|
||||||
return array($top, $left, $right, $bottom, $insideH, $insideV);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border color inside horizontal
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderInsideHColor($pValue = null)
|
|
||||||
{
|
|
||||||
$this->borderInsideHColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border color inside horizontal
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderInsideHColor()
|
|
||||||
{
|
|
||||||
return (isset($this->borderInsideHColor)) ? $this->borderInsideHColor : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border color inside vertical
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderInsideVColor($pValue = null)
|
|
||||||
{
|
|
||||||
$this->borderInsideVColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border color inside vertical
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderInsideVColor()
|
|
||||||
{
|
|
||||||
return (isset($this->borderInsideVColor)) ? $this->borderInsideVColor : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set border size inside horizontal
|
* Set border size inside horizontal
|
||||||
*
|
*
|
||||||
* @param $pValue
|
* @param $value
|
||||||
*/
|
*/
|
||||||
public function setBorderInsideHSize($pValue = null)
|
public function setBorderInsideHSize($value = null)
|
||||||
{
|
{
|
||||||
$this->borderInsideHSize = $pValue;
|
$this->borderInsideHSize = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -295,11 +244,11 @@ class Table extends Border
|
||||||
/**
|
/**
|
||||||
* Set border size inside vertical
|
* Set border size inside vertical
|
||||||
*
|
*
|
||||||
* @param $pValue
|
* @param $value
|
||||||
*/
|
*/
|
||||||
public function setBorderInsideVSize($pValue = null)
|
public function setBorderInsideVSize($value = null)
|
||||||
{
|
{
|
||||||
$this->borderInsideVSize = $pValue;
|
$this->borderInsideVSize = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -312,14 +261,54 @@ class Table extends Border
|
||||||
return (isset($this->borderInsideVSize)) ? $this->borderInsideVSize : null;
|
return (isset($this->borderInsideVSize)) ? $this->borderInsideVSize : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border color inside horizontal
|
||||||
|
*
|
||||||
|
* @param $value
|
||||||
|
*/
|
||||||
|
public function setBorderInsideHColor($value = null)
|
||||||
|
{
|
||||||
|
$this->borderInsideHColor = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border color inside horizontal
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderInsideHColor()
|
||||||
|
{
|
||||||
|
return (isset($this->borderInsideHColor)) ? $this->borderInsideHColor : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border color inside vertical
|
||||||
|
*
|
||||||
|
* @param $value
|
||||||
|
*/
|
||||||
|
public function setBorderInsideVColor($value = null)
|
||||||
|
{
|
||||||
|
$this->borderInsideVColor = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border color inside vertical
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderInsideVColor()
|
||||||
|
{
|
||||||
|
return (isset($this->borderInsideVColor)) ? $this->borderInsideVColor : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set cell margin top
|
* Set cell margin top
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $value
|
||||||
*/
|
*/
|
||||||
public function setCellMarginTop($pValue = null)
|
public function setCellMarginTop($value = null)
|
||||||
{
|
{
|
||||||
$this->cellMarginTop = $pValue;
|
$this->cellMarginTop = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -335,11 +324,11 @@ class Table extends Border
|
||||||
/**
|
/**
|
||||||
* Set cell margin left
|
* Set cell margin left
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $value
|
||||||
*/
|
*/
|
||||||
public function setCellMarginLeft($pValue = null)
|
public function setCellMarginLeft($value = null)
|
||||||
{
|
{
|
||||||
$this->cellMarginLeft = $pValue;
|
$this->cellMarginLeft = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -355,11 +344,11 @@ class Table extends Border
|
||||||
/**
|
/**
|
||||||
* Set cell margin right
|
* Set cell margin right
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $value
|
||||||
*/
|
*/
|
||||||
public function setCellMarginRight($pValue = null)
|
public function setCellMarginRight($value = null)
|
||||||
{
|
{
|
||||||
$this->cellMarginRight = $pValue;
|
$this->cellMarginRight = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -375,11 +364,11 @@ class Table extends Border
|
||||||
/**
|
/**
|
||||||
* Set cell margin bottom
|
* Set cell margin bottom
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $value
|
||||||
*/
|
*/
|
||||||
public function setCellMarginBottom($pValue = null)
|
public function setCellMarginBottom($value = null)
|
||||||
{
|
{
|
||||||
$this->cellMarginBottom = $pValue;
|
$this->cellMarginBottom = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -395,14 +384,14 @@ class Table extends Border
|
||||||
/**
|
/**
|
||||||
* Set TLRB cell margin
|
* Set TLRB cell margin
|
||||||
*
|
*
|
||||||
* @param int $pValue Margin in twips
|
* @param int $value Margin in twips
|
||||||
*/
|
*/
|
||||||
public function setCellMargin($pValue = null)
|
public function setCellMargin($value = null)
|
||||||
{
|
{
|
||||||
$this->cellMarginTop = $pValue;
|
$this->setCellMarginTop($value);
|
||||||
$this->cellMarginLeft = $pValue;
|
$this->setCellMarginLeft($value);
|
||||||
$this->cellMarginRight = $pValue;
|
$this->setCellMarginRight($value);
|
||||||
$this->cellMarginBottom = $pValue;
|
$this->setCellMarginBottom($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -414,4 +403,34 @@ class Table extends Border
|
||||||
{
|
{
|
||||||
return array($this->cellMarginTop, $this->cellMarginLeft, $this->cellMarginRight, $this->cellMarginBottom);
|
return array($this->cellMarginTop, $this->cellMarginLeft, $this->cellMarginRight, $this->cellMarginBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get shading
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Shading
|
||||||
|
*/
|
||||||
|
public function getShading()
|
||||||
|
{
|
||||||
|
return $this->shading;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set shading
|
||||||
|
*
|
||||||
|
* @param array $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setShading($value = null)
|
||||||
|
{
|
||||||
|
if (is_array($value)) {
|
||||||
|
if (!$this->shading instanceof Shading) {
|
||||||
|
$this->shading = new Shading();
|
||||||
|
}
|
||||||
|
$this->shading->setStyleByArray($value);
|
||||||
|
} else {
|
||||||
|
$this->shading = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Shading;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cell style writer
|
* Cell style writer
|
||||||
*
|
*
|
||||||
|
|
@ -48,11 +50,8 @@ class Cell extends AbstractStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($bgColor)) {
|
if (!is_null($bgColor)) {
|
||||||
$this->xmlWriter->startElement('w:shd');
|
$styleWriter = new Shading($this->xmlWriter, $this->style->getShading());
|
||||||
$this->xmlWriter->writeAttribute('w:val', 'clear');
|
$styleWriter->write();
|
||||||
$this->xmlWriter->writeAttribute('w:color', 'auto');
|
|
||||||
$this->xmlWriter->writeAttribute('w:fill', $bgColor);
|
|
||||||
$this->xmlWriter->endElement();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($valign)) {
|
if (!is_null($valign)) {
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ class Font extends AbstractStyle
|
||||||
$font = $this->style->getName();
|
$font = $this->style->getName();
|
||||||
$color = $this->style->getColor();
|
$color = $this->style->getColor();
|
||||||
$size = $this->style->getSize();
|
$size = $this->style->getSize();
|
||||||
$bgColor = $this->style->getBgColor();
|
|
||||||
|
|
||||||
$this->xmlWriter->startElement('w:rPr');
|
$this->xmlWriter->startElement('w:rPr');
|
||||||
|
|
||||||
|
|
@ -125,12 +124,9 @@ class Font extends AbstractStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
// Background-Color
|
// Background-Color
|
||||||
if (!is_null($bgColor)) {
|
if (!is_null($this->style->getShading())) {
|
||||||
$this->xmlWriter->startElement('w:shd');
|
$styleWriter = new Shading($this->xmlWriter, $this->style->getShading());
|
||||||
$this->xmlWriter->writeAttribute('w:val', "clear");
|
$styleWriter->write();
|
||||||
$this->xmlWriter->writeAttribute('w:color', "auto");
|
|
||||||
$this->xmlWriter->writeAttribute('w:fill', $bgColor);
|
|
||||||
$this->xmlWriter->endElement();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Superscript/subscript
|
// Superscript/subscript
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPWord
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2014 PHPWord
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shading style writer
|
||||||
|
*
|
||||||
|
* @since 0.10.0
|
||||||
|
*/
|
||||||
|
class Shading extends AbstractStyle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write style
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
if (!($this->style instanceof \PhpOffice\PhpWord\Style\Shading)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->xmlWriter->startElement('w:shd');
|
||||||
|
$this->xmlWriter->writeAttribute('w:val', $this->style->getPattern());
|
||||||
|
$this->xmlWriter->writeAttribute('w:color', $this->style->getColor());
|
||||||
|
$this->xmlWriter->writeAttribute('w:fill', $this->style->getFill());
|
||||||
|
$this->xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Shading;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table style writer
|
* Table style writer
|
||||||
*
|
*
|
||||||
|
|
@ -32,7 +34,6 @@ class Table extends AbstractStyle
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$bgColor = $this->style->getBgColor();
|
|
||||||
$brdCol = $this->style->getBorderColor();
|
$brdCol = $this->style->getBorderColor();
|
||||||
$brdSz = $this->style->getBorderSize();
|
$brdSz = $this->style->getBorderSize();
|
||||||
$cellMargin = $this->style->getCellMargin();
|
$cellMargin = $this->style->getCellMargin();
|
||||||
|
|
@ -76,13 +77,10 @@ class Table extends AbstractStyle
|
||||||
// Only write background color and first row for full style
|
// Only write background color and first row for full style
|
||||||
if ($this->isFullStyle) {
|
if ($this->isFullStyle) {
|
||||||
// Background color
|
// Background color
|
||||||
if (!is_null($bgColor)) {
|
if (!is_null($this->style->getShading())) {
|
||||||
$this->xmlWriter->startElement('w:tcPr');
|
$this->xmlWriter->startElement('w:tcPr');
|
||||||
$this->xmlWriter->startElement('w:shd');
|
$styleWriter = new Shading($this->xmlWriter, $this->style->getShading());
|
||||||
$this->xmlWriter->writeAttribute('w:val', 'clear');
|
$styleWriter->write();
|
||||||
$this->xmlWriter->writeAttribute('w:color', 'auto');
|
|
||||||
$this->xmlWriter->writeAttribute('w:fill', $bgColor);
|
|
||||||
$this->xmlWriter->endElement();
|
|
||||||
$this->xmlWriter->endElement();
|
$this->xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
// First Row
|
// First Row
|
||||||
|
|
@ -110,17 +108,12 @@ class Table extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
private function writeFirstRow(\PhpOffice\PhpWord\Style\Table $style, $type)
|
private function writeFirstRow(\PhpOffice\PhpWord\Style\Table $style, $type)
|
||||||
{
|
{
|
||||||
$bgColor = $style->getBgColor();
|
|
||||||
|
|
||||||
$this->xmlWriter->startElement('w:tblStylePr');
|
$this->xmlWriter->startElement('w:tblStylePr');
|
||||||
$this->xmlWriter->writeAttribute('w:type', $type);
|
$this->xmlWriter->writeAttribute('w:type', $type);
|
||||||
$this->xmlWriter->startElement('w:tcPr');
|
$this->xmlWriter->startElement('w:tcPr');
|
||||||
if (!is_null($bgColor)) {
|
if (!is_null($style->getShading())) {
|
||||||
$this->xmlWriter->startElement('w:shd');
|
$styleWriter = new Shading($this->xmlWriter, $style->getShading());
|
||||||
$this->xmlWriter->writeAttribute('w:val', 'clear');
|
$styleWriter->write();
|
||||||
$this->xmlWriter->writeAttribute('w:color', 'auto');
|
|
||||||
$this->xmlWriter->writeAttribute('w:fill', $bgColor);
|
|
||||||
$this->xmlWriter->endElement(); // w:shd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Borders
|
// Borders
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
||||||
$oSettings->setSettingValue('lineNumbering', array('start' => 1, 'increment' => 1, 'distance' => 240, 'restart' => 'newPage'));
|
$oSettings->setSettingValue('lineNumbering', array('start' => 1, 'increment' => 1, 'distance' => 240, 'restart' => 'newPage'));
|
||||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\LineNumbering', $oSettings->getLineNumbering());
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\LineNumbering', $oSettings->getLineNumbering());
|
||||||
|
|
||||||
$oSettings->removeLineNumbering();
|
$oSettings->setSettingValue('lineNumbering', null);
|
||||||
$this->assertNull($oSettings->getLineNumbering());
|
$this->assertNull($oSettings->getLineNumbering());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue