Merge Table and TableFull style
This commit is contained in:
parent
db57346c47
commit
b24550d060
|
|
@ -21,6 +21,7 @@ None yet.
|
||||||
- Use `PhpOffice\PhpWord` namespace for PSR compliance - @RomanSyroeshko @gabrielbull GH-159 GH-58
|
- Use `PhpOffice\PhpWord` namespace for PSR compliance - @RomanSyroeshko @gabrielbull GH-159 GH-58
|
||||||
- Restructure folders and change folder name `Classes` to `src` and `Tests` to `test` for PSR compliance - @RomanSyroeshko @gabrielbull
|
- Restructure folders and change folder name `Classes` to `src` and `Tests` to `test` for PSR compliance - @RomanSyroeshko @gabrielbull
|
||||||
- Compliance to phpDocumentor - @ivanlanin
|
- Compliance to phpDocumentor - @ivanlanin
|
||||||
|
- Merge Style\TableFull into Style\Table - @ivanlanin GH-160
|
||||||
|
|
||||||
## 0.8.1 - 17 Mar 2014
|
## 0.8.1 - 17 Mar 2014
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace PhpOffice\PhpWord;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
use PhpOffice\PhpWord\Style\TableFull;
|
use PhpOffice\PhpWord\Style\Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style
|
* Style
|
||||||
|
|
@ -114,7 +114,7 @@ class Style
|
||||||
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
|
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
|
||||||
{
|
{
|
||||||
if (!array_key_exists($styleName, self::$_styleElements)) {
|
if (!array_key_exists($styleName, self::$_styleElements)) {
|
||||||
$style = new TableFull($styleTable, $styleFirstRow);
|
$style = new Table($styleTable, $styleFirstRow);
|
||||||
|
|
||||||
self::$_styleElements[$styleName] = $style;
|
self::$_styleElements[$styleName] = $style;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,13 @@ namespace PhpOffice\PhpWord\Style;
|
||||||
*/
|
*/
|
||||||
class Table
|
class Table
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Style for first row
|
||||||
|
*
|
||||||
|
* @var \PhpOffice\PhpWord\Style\Table
|
||||||
|
*/
|
||||||
|
private $_firstRow = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cell margin top
|
* Cell margin top
|
||||||
*
|
*
|
||||||
|
|
@ -59,14 +66,133 @@ class Table
|
||||||
private $_cellMarginBottom = null;
|
private $_cellMarginBottom = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new table style
|
* Background color
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
private $_bgColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border size top
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_borderTopSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border color
|
||||||
|
*
|
||||||
|
* @var string top
|
||||||
|
*/
|
||||||
|
private $_borderTopColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border size left
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_borderLeftSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border color left
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_borderLeftColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border size right
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_borderRightSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border color right
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_borderRightColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border size bottom
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_borderBottomSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border color bottom
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_borderBottomColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border size inside horizontal
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_borderInsideHSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border color inside horizontal
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_borderInsideHColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border size inside vertical
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_borderInsideVSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border color inside vertical
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_borderInsideVColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new table style
|
||||||
|
*
|
||||||
|
* @param mixed $styleTable
|
||||||
|
* @param mixed $styleFirstRow
|
||||||
|
*/
|
||||||
|
public function __construct($styleTable = null, $styleFirstRow = null)
|
||||||
{
|
{
|
||||||
$this->_cellMarginTop = null;
|
if (!is_null($styleFirstRow) && is_array($styleFirstRow)) {
|
||||||
$this->_cellMarginLeft = null;
|
$this->_firstRow = clone $this;
|
||||||
$this->_cellMarginRight = null;
|
|
||||||
$this->_cellMarginBottom = null;
|
unset($this->_firstRow->_firstRow);
|
||||||
|
unset($this->_firstRow->_cellMarginBottom);
|
||||||
|
unset($this->_firstRow->_cellMarginTop);
|
||||||
|
unset($this->_firstRow->_cellMarginLeft);
|
||||||
|
unset($this->_firstRow->_cellMarginRight);
|
||||||
|
unset($this->_firstRow->_borderInsideVColor);
|
||||||
|
unset($this->_firstRow->_borderInsideVSize);
|
||||||
|
unset($this->_firstRow->_borderInsideHColor);
|
||||||
|
unset($this->_firstRow->_borderInsideHSize);
|
||||||
|
foreach ($styleFirstRow as $key => $value) {
|
||||||
|
if (substr($key, 0, 1) != '_') {
|
||||||
|
$key = '_' . $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_firstRow->setStyleValue($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($styleTable) && is_array($styleTable)) {
|
||||||
|
foreach ($styleTable as $key => $value) {
|
||||||
|
if (substr($key, 0, 1) != '_') {
|
||||||
|
$key = '_' . $key;
|
||||||
|
}
|
||||||
|
$this->setStyleValue($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,7 +203,359 @@ class Table
|
||||||
*/
|
*/
|
||||||
public function setStyleValue($key, $value)
|
public function setStyleValue($key, $value)
|
||||||
{
|
{
|
||||||
$this->$key = $value;
|
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
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Table
|
||||||
|
*/
|
||||||
|
public function getFirstRow()
|
||||||
|
{
|
||||||
|
return $this->_firstRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Last Row Style
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Table
|
||||||
|
*/
|
||||||
|
public function getLastRow()
|
||||||
|
{
|
||||||
|
return $this->_lastRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get background
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Table
|
||||||
|
*/
|
||||||
|
public function getBgColor()
|
||||||
|
{
|
||||||
|
return $this->_bgColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set background
|
||||||
|
*
|
||||||
|
* @param string $pValue
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Table
|
||||||
|
*/
|
||||||
|
public function setBgColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_bgColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set TLRBVH Border Size
|
||||||
|
*
|
||||||
|
* @param int $pValue Border size in eighths of a point (1/8 point)
|
||||||
|
*/
|
||||||
|
public function setBorderSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderTopSize = $pValue;
|
||||||
|
$this->_borderLeftSize = $pValue;
|
||||||
|
$this->_borderRightSize = $pValue;
|
||||||
|
$this->_borderBottomSize = $pValue;
|
||||||
|
$this->_borderInsideHSize = $pValue;
|
||||||
|
$this->_borderInsideVSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get TLRBVH Border Size
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getBorderSize()
|
||||||
|
{
|
||||||
|
$t = $this->getBorderTopSize();
|
||||||
|
$l = $this->getBorderLeftSize();
|
||||||
|
$r = $this->getBorderRightSize();
|
||||||
|
$b = $this->getBorderBottomSize();
|
||||||
|
$h = $this->getBorderInsideHSize();
|
||||||
|
$v = $this->getBorderInsideVSize();
|
||||||
|
|
||||||
|
return array($t, $l, $r, $b, $h, $v);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set TLRBVH Border Color
|
||||||
|
* @param string $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderTopColor = $pValue;
|
||||||
|
$this->_borderLeftColor = $pValue;
|
||||||
|
$this->_borderRightColor = $pValue;
|
||||||
|
$this->_borderBottomColor = $pValue;
|
||||||
|
$this->_borderInsideHColor = $pValue;
|
||||||
|
$this->_borderInsideVColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get TLRB Border Color
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getBorderColor()
|
||||||
|
{
|
||||||
|
$t = $this->getBorderTopColor();
|
||||||
|
$l = $this->getBorderLeftColor();
|
||||||
|
$r = $this->getBorderRightColor();
|
||||||
|
$b = $this->getBorderBottomColor();
|
||||||
|
$h = $this->getBorderInsideHColor();
|
||||||
|
$v = $this->getBorderInsideVColor();
|
||||||
|
|
||||||
|
return array($t, $l, $r, $b, $h, $v);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border size top
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderTopSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderTopSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border size top
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderTopSize()
|
||||||
|
{
|
||||||
|
return $this->_borderTopSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border color top
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderTopColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderTopColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border color top
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderTopColor()
|
||||||
|
{
|
||||||
|
return $this->_borderTopColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border size left
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderLeftSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderLeftSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border size left
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderLeftSize()
|
||||||
|
{
|
||||||
|
return $this->_borderLeftSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border color left
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderLeftColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderLeftColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border color left
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderLeftColor()
|
||||||
|
{
|
||||||
|
return $this->_borderLeftColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border size right
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderRightSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderRightSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border size right
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderRightSize()
|
||||||
|
{
|
||||||
|
return $this->_borderRightSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border color right
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderRightColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderRightColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border color right
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderRightColor()
|
||||||
|
{
|
||||||
|
return $this->_borderRightColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border size bottom
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderBottomSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderBottomSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border size bottom
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderBottomSize()
|
||||||
|
{
|
||||||
|
return $this->_borderBottomSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border color bottom
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderBottomColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderBottomColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border color bottom
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderBottomColor()
|
||||||
|
{
|
||||||
|
return $this->_borderBottomColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderInsideHSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderInsideHSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border size inside horizontal
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderInsideHSize()
|
||||||
|
{
|
||||||
|
return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border size inside vertical
|
||||||
|
*
|
||||||
|
* @param $pValue
|
||||||
|
*/
|
||||||
|
public function setBorderInsideVSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderInsideVSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get border size inside vertical
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getBorderInsideVSize()
|
||||||
|
{
|
||||||
|
return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,663 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* PhpWord
|
|
||||||
*
|
|
||||||
* Copyright (c) 2014 PhpWord
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2014 PhpWord
|
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
|
||||||
* @version 0.8.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Style;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Table (full) style
|
|
||||||
*/
|
|
||||||
class TableFull
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Style for first row
|
|
||||||
*
|
|
||||||
* @var \PhpOffice\PhpWord\Style\TableFull
|
|
||||||
*/
|
|
||||||
private $_firstRow = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cell margin top
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_cellMarginTop = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cell margin left
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_cellMarginLeft = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cell margin right
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_cellMarginRight = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cell margin bottom
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_cellMarginBottom = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Background color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_bgColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border size top
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderTopSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border color
|
|
||||||
*
|
|
||||||
* @var string top
|
|
||||||
*/
|
|
||||||
private $_borderTopColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border size left
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderLeftSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border color left
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_borderLeftColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border size right
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderRightSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border color right
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_borderRightColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border size bottom
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderBottomSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border color bottom
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_borderBottomColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border size inside horizontal
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderInsideHSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border color inside horizontal
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_borderInsideHColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border size inside vertical
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderInsideVSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border color inside vertical
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_borderInsideVColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new table style
|
|
||||||
*
|
|
||||||
* @param mixed $styleTable
|
|
||||||
* @param mixed $styleFirstRow
|
|
||||||
*/
|
|
||||||
public function __construct($styleTable = null, $styleFirstRow = null)
|
|
||||||
{
|
|
||||||
if (!is_null($styleFirstRow) && is_array($styleFirstRow)) {
|
|
||||||
$this->_firstRow = clone $this;
|
|
||||||
|
|
||||||
unset($this->_firstRow->_firstRow);
|
|
||||||
unset($this->_firstRow->_cellMarginBottom);
|
|
||||||
unset($this->_firstRow->_cellMarginTop);
|
|
||||||
unset($this->_firstRow->_cellMarginLeft);
|
|
||||||
unset($this->_firstRow->_cellMarginRight);
|
|
||||||
unset($this->_firstRow->_borderInsideVColor);
|
|
||||||
unset($this->_firstRow->_borderInsideVSize);
|
|
||||||
unset($this->_firstRow->_borderInsideHColor);
|
|
||||||
unset($this->_firstRow->_borderInsideHSize);
|
|
||||||
foreach ($styleFirstRow as $key => $value) {
|
|
||||||
if (substr($key, 0, 1) != '_') {
|
|
||||||
$key = '_' . $key;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_firstRow->setStyleValue($key, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_null($styleTable) && is_array($styleTable)) {
|
|
||||||
foreach ($styleTable as $key => $value) {
|
|
||||||
if (substr($key, 0, 1) != '_') {
|
|
||||||
$key = '_' . $key;
|
|
||||||
}
|
|
||||||
$this->setStyleValue($key, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set style value
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $value
|
|
||||||
*/
|
|
||||||
public function setStyleValue($key, $value)
|
|
||||||
{
|
|
||||||
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
|
|
||||||
*
|
|
||||||
* @return \PhpOffice\PhpWord\Style\TableFull
|
|
||||||
*/
|
|
||||||
public function getFirstRow()
|
|
||||||
{
|
|
||||||
return $this->_firstRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Last Row Style
|
|
||||||
*
|
|
||||||
* @return \PhpOffice\PhpWord\Style\TableFull
|
|
||||||
*/
|
|
||||||
public function getLastRow()
|
|
||||||
{
|
|
||||||
return $this->_lastRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get background
|
|
||||||
*
|
|
||||||
* @return \PhpOffice\PhpWord\Style\TableFull
|
|
||||||
*/
|
|
||||||
public function getBgColor()
|
|
||||||
{
|
|
||||||
return $this->_bgColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set background
|
|
||||||
*
|
|
||||||
* @param string $pValue
|
|
||||||
* @return \PhpOffice\PhpWord\Style\TableFull
|
|
||||||
*/
|
|
||||||
public function setBgColor($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_bgColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set TLRBVH Border Size
|
|
||||||
*
|
|
||||||
* @param int $pValue Border size in eighths of a point (1/8 point)
|
|
||||||
*/
|
|
||||||
public function setBorderSize($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderTopSize = $pValue;
|
|
||||||
$this->_borderLeftSize = $pValue;
|
|
||||||
$this->_borderRightSize = $pValue;
|
|
||||||
$this->_borderBottomSize = $pValue;
|
|
||||||
$this->_borderInsideHSize = $pValue;
|
|
||||||
$this->_borderInsideVSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get TLRBVH Border Size
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getBorderSize()
|
|
||||||
{
|
|
||||||
$t = $this->getBorderTopSize();
|
|
||||||
$l = $this->getBorderLeftSize();
|
|
||||||
$r = $this->getBorderRightSize();
|
|
||||||
$b = $this->getBorderBottomSize();
|
|
||||||
$h = $this->getBorderInsideHSize();
|
|
||||||
$v = $this->getBorderInsideVSize();
|
|
||||||
|
|
||||||
return array($t, $l, $r, $b, $h, $v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set TLRBVH Border Color
|
|
||||||
* @param string $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderColor($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderTopColor = $pValue;
|
|
||||||
$this->_borderLeftColor = $pValue;
|
|
||||||
$this->_borderRightColor = $pValue;
|
|
||||||
$this->_borderBottomColor = $pValue;
|
|
||||||
$this->_borderInsideHColor = $pValue;
|
|
||||||
$this->_borderInsideVColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get TLRB Border Color
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getBorderColor()
|
|
||||||
{
|
|
||||||
$t = $this->getBorderTopColor();
|
|
||||||
$l = $this->getBorderLeftColor();
|
|
||||||
$r = $this->getBorderRightColor();
|
|
||||||
$b = $this->getBorderBottomColor();
|
|
||||||
$h = $this->getBorderInsideHColor();
|
|
||||||
$v = $this->getBorderInsideVColor();
|
|
||||||
|
|
||||||
return array($t, $l, $r, $b, $h, $v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border size top
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderTopSize($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderTopSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border size top
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderTopSize()
|
|
||||||
{
|
|
||||||
return $this->_borderTopSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border color top
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderTopColor($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderTopColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border color top
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderTopColor()
|
|
||||||
{
|
|
||||||
return $this->_borderTopColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border size left
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderLeftSize($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderLeftSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border size left
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderLeftSize()
|
|
||||||
{
|
|
||||||
return $this->_borderLeftSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border color left
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderLeftColor($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderLeftColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border color left
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderLeftColor()
|
|
||||||
{
|
|
||||||
return $this->_borderLeftColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border size right
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderRightSize($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderRightSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border size right
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderRightSize()
|
|
||||||
{
|
|
||||||
return $this->_borderRightSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border color right
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderRightColor($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderRightColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border color right
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderRightColor()
|
|
||||||
{
|
|
||||||
return $this->_borderRightColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border size bottom
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderBottomSize($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderBottomSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border size bottom
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderBottomSize()
|
|
||||||
{
|
|
||||||
return $this->_borderBottomSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border color bottom
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderBottomColor($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderBottomColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border color bottom
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderBottomColor()
|
|
||||||
{
|
|
||||||
return $this->_borderBottomColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderInsideHSize($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderInsideHSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border size inside horizontal
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderInsideHSize()
|
|
||||||
{
|
|
||||||
return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set border size inside vertical
|
|
||||||
*
|
|
||||||
* @param $pValue
|
|
||||||
*/
|
|
||||||
public function setBorderInsideVSize($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_borderInsideVSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get border size inside vertical
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public function getBorderInsideVSize()
|
|
||||||
{
|
|
||||||
return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set cell margin top
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setCellMarginTop($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_cellMarginTop = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get cell margin top
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getCellMarginTop()
|
|
||||||
{
|
|
||||||
return $this->_cellMarginTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set cell margin left
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setCellMarginLeft($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_cellMarginLeft = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get cell margin left
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getCellMarginLeft()
|
|
||||||
{
|
|
||||||
return $this->_cellMarginLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set cell margin right
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setCellMarginRight($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_cellMarginRight = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get cell margin right
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getCellMarginRight()
|
|
||||||
{
|
|
||||||
return $this->_cellMarginRight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set cell margin bottom
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setCellMarginBottom($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_cellMarginBottom = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get cell margin bottom
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getCellMarginBottom()
|
|
||||||
{
|
|
||||||
return $this->_cellMarginBottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set TLRB cell margin
|
|
||||||
*
|
|
||||||
* @param int $pValue Margin in twips
|
|
||||||
*/
|
|
||||||
public function setCellMargin($pValue = null)
|
|
||||||
{
|
|
||||||
$this->_cellMarginTop = $pValue;
|
|
||||||
$this->_cellMarginLeft = $pValue;
|
|
||||||
$this->_cellMarginRight = $pValue;
|
|
||||||
$this->_cellMarginBottom = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get cell margin
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getCellMargin()
|
|
||||||
{
|
|
||||||
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -30,7 +30,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
use PhpOffice\PhpWord\Style\TableFull;
|
use PhpOffice\PhpWord\Style\Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ODText styloes part writer
|
* ODText styloes part writer
|
||||||
|
|
@ -203,8 +203,8 @@ class Styles extends WriterPart
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
} elseif ($style instanceof TableFull) {
|
} elseif ($style instanceof Table) {
|
||||||
// PhpOffice\PhpWord\Style\TableFull
|
// PhpOffice\PhpWord\Style\Table
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -575,7 +575,7 @@ class Base extends WriterPart
|
||||||
$tblStyle = $table->getStyle();
|
$tblStyle = $table->getStyle();
|
||||||
$tblWidth = $table->getWidth();
|
$tblWidth = $table->getWidth();
|
||||||
if ($tblStyle instanceof PhpOffice\PhpWord\Style\Table) {
|
if ($tblStyle instanceof PhpOffice\PhpWord\Style\Table) {
|
||||||
$this->_writeTableStyle($xmlWriter, $tblStyle);
|
$this->_writeTableStyle($xmlWriter, $tblStyle, false);
|
||||||
} else {
|
} else {
|
||||||
if (!empty($tblStyle)) {
|
if (!empty($tblStyle)) {
|
||||||
$xmlWriter->startElement('w:tblPr');
|
$xmlWriter->startElement('w:tblPr');
|
||||||
|
|
@ -679,52 +679,199 @@ class Base extends WriterPart
|
||||||
*
|
*
|
||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param PhpOffice\PhpWord\Style\Table $style
|
* @param PhpOffice\PhpWord\Style\Table $style
|
||||||
|
* @param boolean $isFullStyle
|
||||||
*/
|
*/
|
||||||
protected function _writeTableStyle(
|
protected function _writeTableStyle(
|
||||||
XMLWriter $xmlWriter,
|
XMLWriter $xmlWriter,
|
||||||
\PhpOffice\PhpWord\Style\Table $style = null
|
\PhpOffice\PhpWord\Style\Table $style,
|
||||||
|
$isFullStyle = true
|
||||||
) {
|
) {
|
||||||
$margins = $style->getCellMargin();
|
$bgColor = $style->getBgColor();
|
||||||
$mTop = (!is_null($margins[0])) ? true : false;
|
$brdCol = $style->getBorderColor();
|
||||||
$mLeft = (!is_null($margins[1])) ? true : false;
|
|
||||||
$mRight = (!is_null($margins[2])) ? true : false;
|
|
||||||
$mBottom = (!is_null($margins[3])) ? true : false;
|
|
||||||
|
|
||||||
if ($mTop || $mLeft || $mRight || $mBottom) {
|
$brdSz = $style->getBorderSize();
|
||||||
|
$bTop = (!is_null($brdSz[0])) ? true : false;
|
||||||
|
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
||||||
|
$bRight = (!is_null($brdSz[2])) ? true : false;
|
||||||
|
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
||||||
|
$bInsH = (!is_null($brdSz[4])) ? true : false;
|
||||||
|
$bInsV = (!is_null($brdSz[5])) ? true : false;
|
||||||
|
$borders = ($bTop || $bLeft || $bRight || $bBottom || $bInsH || $bInsV) ? true : false;
|
||||||
|
|
||||||
|
$cellMargin = $style->getCellMargin();
|
||||||
|
$mTop = (!is_null($cellMargin[0])) ? true : false;
|
||||||
|
$mLeft = (!is_null($cellMargin[1])) ? true : false;
|
||||||
|
$mRight = (!is_null($cellMargin[2])) ? true : false;
|
||||||
|
$mBottom = (!is_null($cellMargin[3])) ? true : false;
|
||||||
|
$margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false;
|
||||||
|
|
||||||
|
if ($margins || $borders) {
|
||||||
$xmlWriter->startElement('w:tblPr');
|
$xmlWriter->startElement('w:tblPr');
|
||||||
$xmlWriter->startElement('w:tblCellMar');
|
if ($margins) {
|
||||||
|
$xmlWriter->startElement('w:tblCellMar');
|
||||||
if ($mTop) {
|
if ($mTop) {
|
||||||
$xmlWriter->startElement('w:top');
|
echo $margins[0];
|
||||||
$xmlWriter->writeAttribute('w:w', $margins[0]);
|
$xmlWriter->startElement('w:top');
|
||||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
$xmlWriter->writeAttribute('w:w', $cellMargin[0]);
|
||||||
|
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($mLeft) {
|
||||||
|
$xmlWriter->startElement('w:left');
|
||||||
|
$xmlWriter->writeAttribute('w:w', $cellMargin[1]);
|
||||||
|
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($mRight) {
|
||||||
|
$xmlWriter->startElement('w:right');
|
||||||
|
$xmlWriter->writeAttribute('w:w', $cellMargin[2]);
|
||||||
|
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($mBottom) {
|
||||||
|
$xmlWriter->startElement('w:bottom');
|
||||||
|
$xmlWriter->writeAttribute('w:w', $cellMargin[3]);
|
||||||
|
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
if ($borders) {
|
||||||
if ($mLeft) {
|
$xmlWriter->startElement('w:tblBorders');
|
||||||
$xmlWriter->startElement('w:left');
|
if ($bTop) {
|
||||||
$xmlWriter->writeAttribute('w:w', $margins[1]);
|
$xmlWriter->startElement('w:top');
|
||||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[0]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($bLeft) {
|
||||||
|
$xmlWriter->startElement('w:left');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[1]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($bRight) {
|
||||||
|
$xmlWriter->startElement('w:right');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[2]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($bBottom) {
|
||||||
|
$xmlWriter->startElement('w:bottom');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[3]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($bInsH) {
|
||||||
|
$xmlWriter->startElement('w:insideH');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[4]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[4]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($bInsV) {
|
||||||
|
$xmlWriter->startElement('w:insideV');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[5]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[5]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
$xmlWriter->endElement(); // w:tblPr
|
||||||
if ($mRight) {
|
}
|
||||||
$xmlWriter->startElement('w:right');
|
// Only write background color and first row for full style
|
||||||
$xmlWriter->writeAttribute('w:w', $margins[2]);
|
if ($isFullStyle) {
|
||||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
// Background color
|
||||||
|
if (!is_null($bgColor)) {
|
||||||
|
$xmlWriter->startElement('w:tcPr');
|
||||||
|
$xmlWriter->startElement('w:shd');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'clear');
|
||||||
|
$xmlWriter->writeAttribute('w:color', 'auto');
|
||||||
|
$xmlWriter->writeAttribute('w:fill', $bgColor);
|
||||||
|
$xmlWriter->endElement();
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
// First Row
|
||||||
if ($mBottom) {
|
$firstRow = $style->getFirstRow();
|
||||||
$xmlWriter->startElement('w:bottom');
|
if (!is_null($firstRow)) {
|
||||||
$xmlWriter->writeAttribute('w:w', $margins[3]);
|
$this->_writeRowStyle($xmlWriter, 'firstRow', $firstRow);
|
||||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
/**
|
||||||
|
* Write row style
|
||||||
|
*
|
||||||
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
|
* @param string $type
|
||||||
|
* @param PhpOffice\PhpWord\Style\Table $style
|
||||||
|
*/
|
||||||
|
protected function _writeRowStyle(
|
||||||
|
XMLWriter $xmlWriter,
|
||||||
|
$type,
|
||||||
|
\PhpOffice\PhpWord\Style\Table $style
|
||||||
|
) {
|
||||||
|
$brdSz = $style->getBorderSize();
|
||||||
|
$brdCol = $style->getBorderColor();
|
||||||
|
$bgColor = $style->getBgColor();
|
||||||
|
|
||||||
|
$bTop = (!is_null($brdSz[0])) ? true : false;
|
||||||
|
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
||||||
|
$bRight = (!is_null($brdSz[2])) ? true : false;
|
||||||
|
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
||||||
|
$borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false;
|
||||||
|
|
||||||
|
$xmlWriter->startElement('w:tblStylePr');
|
||||||
|
$xmlWriter->writeAttribute('w:type', $type);
|
||||||
|
|
||||||
|
$xmlWriter->startElement('w:tcPr');
|
||||||
|
if (!is_null($bgColor)) {
|
||||||
|
$xmlWriter->startElement('w:shd');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'clear');
|
||||||
|
$xmlWriter->writeAttribute('w:color', 'auto');
|
||||||
|
$xmlWriter->writeAttribute('w:fill', $bgColor);
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$xmlWriter->startElement('w:tcBorders');
|
||||||
|
if ($bTop) {
|
||||||
|
$xmlWriter->startElement('w:top');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[0]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($bLeft) {
|
||||||
|
$xmlWriter->startElement('w:left');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[1]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($bRight) {
|
||||||
|
$xmlWriter->startElement('w:right');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[2]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
if ($bBottom) {
|
||||||
|
$xmlWriter->startElement('w:bottom');
|
||||||
|
$xmlWriter->writeAttribute('w:val', 'single');
|
||||||
|
$xmlWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||||
|
$xmlWriter->writeAttribute('w:color', $brdCol[3]);
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
use PhpOffice\PhpWord\Style\TableFull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Word2007 styles part writer
|
* Word2007 styles part writer
|
||||||
|
|
@ -72,7 +71,6 @@ class Styles extends Base
|
||||||
// Write DocDefaults
|
// Write DocDefaults
|
||||||
$this->_writeDocDefaults($xmlWriter);
|
$this->_writeDocDefaults($xmlWriter);
|
||||||
|
|
||||||
|
|
||||||
// Write Style Definitions
|
// Write Style Definitions
|
||||||
$styles = Style::getStyles();
|
$styles = Style::getStyles();
|
||||||
|
|
||||||
|
|
@ -170,7 +168,7 @@ class Styles extends Base
|
||||||
$this->_writeParagraphStyle($xmlWriter, $style);
|
$this->_writeParagraphStyle($xmlWriter, $style);
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
} elseif ($style instanceof TableFull) {
|
} elseif ($style instanceof \PhpOffice\PhpWord\Style\Table) {
|
||||||
$xmlWriter->startElement('w:style');
|
$xmlWriter->startElement('w:style');
|
||||||
$xmlWriter->writeAttribute('w:type', 'table');
|
$xmlWriter->writeAttribute('w:type', 'table');
|
||||||
$xmlWriter->writeAttribute('w:customStyle', '1');
|
$xmlWriter->writeAttribute('w:customStyle', '1');
|
||||||
|
|
@ -184,9 +182,9 @@ class Styles extends Base
|
||||||
$xmlWriter->writeAttribute('w:val', '99');
|
$xmlWriter->writeAttribute('w:val', '99');
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
$this->_writeFullTableStyle($xmlWriter, $style);
|
$this->_writeTableStyle($xmlWriter, $style);
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement(); // w:style
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -197,200 +195,6 @@ class Styles extends Base
|
||||||
return $xmlWriter->getData();
|
return $xmlWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Write table style
|
|
||||||
*
|
|
||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
|
||||||
* @param PhpOffice\PhpWord\Style\TableFull $style
|
|
||||||
*/
|
|
||||||
private function _writeFullTableStyle(XMLWriter $xmlWriter, TableFull $style)
|
|
||||||
{
|
|
||||||
|
|
||||||
$brdSz = $style->getBorderSize();
|
|
||||||
$brdCol = $style->getBorderColor();
|
|
||||||
$bgColor = $style->getBgColor();
|
|
||||||
$cellMargin = $style->getCellMargin();
|
|
||||||
|
|
||||||
$bTop = (!is_null($brdSz[0])) ? true : false;
|
|
||||||
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
|
||||||
$bRight = (!is_null($brdSz[2])) ? true : false;
|
|
||||||
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
|
||||||
$bInsH = (!is_null($brdSz[4])) ? true : false;
|
|
||||||
$bInsV = (!is_null($brdSz[5])) ? true : false;
|
|
||||||
$borders = ($bTop || $bLeft || $bRight || $bBottom || $bInsH || $bInsV) ? true : false;
|
|
||||||
|
|
||||||
$mTop = (!is_null($cellMargin[0])) ? true : false;
|
|
||||||
$mLeft = (!is_null($cellMargin[1])) ? true : false;
|
|
||||||
$mRight = (!is_null($cellMargin[2])) ? true : false;
|
|
||||||
$mBottom = (!is_null($cellMargin[3])) ? true : false;
|
|
||||||
$margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false;
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:tblPr');
|
|
||||||
|
|
||||||
if ($margins) {
|
|
||||||
$xmlWriter->startElement('w:tblCellMar');
|
|
||||||
if ($mTop) {
|
|
||||||
echo $margins[0];
|
|
||||||
$xmlWriter->startElement('w:top');
|
|
||||||
$xmlWriter->writeAttribute('w:w', $cellMargin[0]);
|
|
||||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($mLeft) {
|
|
||||||
$xmlWriter->startElement('w:left');
|
|
||||||
$xmlWriter->writeAttribute('w:w', $cellMargin[1]);
|
|
||||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($mRight) {
|
|
||||||
$xmlWriter->startElement('w:right');
|
|
||||||
$xmlWriter->writeAttribute('w:w', $cellMargin[2]);
|
|
||||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($mBottom) {
|
|
||||||
$xmlWriter->startElement('w:bottom');
|
|
||||||
$xmlWriter->writeAttribute('w:w', $cellMargin[3]);
|
|
||||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($borders) {
|
|
||||||
$xmlWriter->startElement('w:tblBorders');
|
|
||||||
if ($bTop) {
|
|
||||||
$xmlWriter->startElement('w:top');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[0]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[0]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($bLeft) {
|
|
||||||
$xmlWriter->startElement('w:left');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[1]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[1]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($bRight) {
|
|
||||||
$xmlWriter->startElement('w:right');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[2]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[2]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($bBottom) {
|
|
||||||
$xmlWriter->startElement('w:bottom');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[3]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[3]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($bInsH) {
|
|
||||||
$xmlWriter->startElement('w:insideH');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[4]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[4]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($bInsV) {
|
|
||||||
$xmlWriter->startElement('w:insideV');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[5]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[5]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
if (!is_null($bgColor)) {
|
|
||||||
$xmlWriter->startElement('w:tcPr');
|
|
||||||
$xmlWriter->startElement('w:shd');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'clear');
|
|
||||||
$xmlWriter->writeAttribute('w:color', 'auto');
|
|
||||||
$xmlWriter->writeAttribute('w:fill', $bgColor);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
// First Row
|
|
||||||
$firstRow = $style->getFirstRow();
|
|
||||||
if (!is_null($firstRow)) {
|
|
||||||
$this->_writeRowStyle($xmlWriter, 'firstRow', $firstRow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write first row style
|
|
||||||
*
|
|
||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
|
||||||
* @param string $type
|
|
||||||
* @param PhpOffice\PhpWord\Style\TableFull $style
|
|
||||||
*/
|
|
||||||
private function _writeRowStyle(XMLWriter $xmlWriter, $type, TableFull $style)
|
|
||||||
{
|
|
||||||
$brdSz = $style->getBorderSize();
|
|
||||||
$brdCol = $style->getBorderColor();
|
|
||||||
$bgColor = $style->getBgColor();
|
|
||||||
|
|
||||||
$bTop = (!is_null($brdSz[0])) ? true : false;
|
|
||||||
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
|
||||||
$bRight = (!is_null($brdSz[2])) ? true : false;
|
|
||||||
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
|
||||||
$borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false;
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:tblStylePr');
|
|
||||||
$xmlWriter->writeAttribute('w:type', $type);
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:tcPr');
|
|
||||||
if (!is_null($bgColor)) {
|
|
||||||
$xmlWriter->startElement('w:shd');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'clear');
|
|
||||||
$xmlWriter->writeAttribute('w:color', 'auto');
|
|
||||||
$xmlWriter->writeAttribute('w:fill', $bgColor);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:tcBorders');
|
|
||||||
if ($bTop) {
|
|
||||||
$xmlWriter->startElement('w:top');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[0]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[0]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($bLeft) {
|
|
||||||
$xmlWriter->startElement('w:left');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[1]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[1]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($bRight) {
|
|
||||||
$xmlWriter->startElement('w:right');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[2]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[2]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
if ($bBottom) {
|
|
||||||
$xmlWriter->startElement('w:bottom');
|
|
||||||
$xmlWriter->writeAttribute('w:val', 'single');
|
|
||||||
$xmlWriter->writeAttribute('w:sz', $brdSz[3]);
|
|
||||||
$xmlWriter->writeAttribute('w:color', $brdCol[3]);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write document defaults
|
* Write document defaults
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
||||||
$styles = array(
|
$styles = array(
|
||||||
'Paragraph' => 'Paragraph',
|
'Paragraph' => 'Paragraph',
|
||||||
'Font' => 'Font',
|
'Font' => 'Font',
|
||||||
'Table' => 'TableFull',
|
'Table' => 'Table',
|
||||||
'Link' => 'Font',
|
'Link' => 'Font',
|
||||||
);
|
);
|
||||||
foreach ($styles as $key => $value) {
|
foreach ($styles as $key => $value) {
|
||||||
|
|
|
||||||
|
|
@ -1,130 +0,0 @@
|
||||||
<?php
|
|
||||||
namespace PhpOffice\PhpWord\Tests\Style;
|
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Style\TableFull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @runTestsInSeparateProcesses
|
|
||||||
*/
|
|
||||||
class TableFullTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Test class construction
|
|
||||||
*
|
|
||||||
* There are 3 variables for class constructor:
|
|
||||||
* - $styleTable: Define table styles
|
|
||||||
* - $styleFirstRow: Define style for the first row
|
|
||||||
* - $styleLastRow: Define style for the last row (reserved)
|
|
||||||
*/
|
|
||||||
public function testConstruct()
|
|
||||||
{
|
|
||||||
$styleTable = array('bgColor' => 'FF0000');
|
|
||||||
$styleFirstRow = array('borderBottomSize' => 3);
|
|
||||||
|
|
||||||
$object = new TableFull($styleTable, $styleFirstRow);
|
|
||||||
$this->assertEquals('FF0000', $object->getBgColor());
|
|
||||||
|
|
||||||
$firstRow = $object->getFirstRow();
|
|
||||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TableFull', $firstRow);
|
|
||||||
$this->assertEquals(3, $firstRow->getBorderBottomSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test setting style with normal value
|
|
||||||
*/
|
|
||||||
public function testSetGetNormal()
|
|
||||||
{
|
|
||||||
$object = new TableFull();
|
|
||||||
|
|
||||||
$attributes = array(
|
|
||||||
'bgColor' => 'FF0000',
|
|
||||||
'borderTopSize' => 4,
|
|
||||||
'borderTopColor' => 'FF0000',
|
|
||||||
'borderLeftSize' => 4,
|
|
||||||
'borderLeftColor' => 'FF0000',
|
|
||||||
'borderRightSize' => 4,
|
|
||||||
'borderRightColor' => 'FF0000',
|
|
||||||
'borderBottomSize' => 4,
|
|
||||||
'borderBottomColor' => 'FF0000',
|
|
||||||
'borderInsideHSize' => 4,
|
|
||||||
'borderInsideHColor' => 'FF0000',
|
|
||||||
'borderInsideVSize' => 4,
|
|
||||||
'borderInsideVColor' => 'FF0000',
|
|
||||||
'cellMarginTop' => 240,
|
|
||||||
'cellMarginLeft' => 240,
|
|
||||||
'cellMarginRight' => 240,
|
|
||||||
'cellMarginBottom' => 240,
|
|
||||||
);
|
|
||||||
foreach ($attributes as $key => $value) {
|
|
||||||
$set = "set{$key}";
|
|
||||||
$get = "get{$key}";
|
|
||||||
$object->$set($value);
|
|
||||||
$this->assertEquals($value, $object->$get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test border color
|
|
||||||
*
|
|
||||||
* Set border color and test if each part has the same color
|
|
||||||
* While looping, push values array to be asserted with getBorderColor
|
|
||||||
*/
|
|
||||||
public function testBorderColor()
|
|
||||||
{
|
|
||||||
$object = new TableFull();
|
|
||||||
$parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV');
|
|
||||||
|
|
||||||
$value = 'FF0000';
|
|
||||||
$object->setBorderColor($value);
|
|
||||||
foreach ($parts as $part) {
|
|
||||||
$get = "getBorder{$part}Color";
|
|
||||||
$values[] = $value;
|
|
||||||
$this->assertEquals($value, $object->$get());
|
|
||||||
}
|
|
||||||
$this->assertEquals($values, $object->getBorderColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test border size
|
|
||||||
*
|
|
||||||
* Set border size and test if each part has the same size
|
|
||||||
* While looping, push values array to be asserted with getBorderSize
|
|
||||||
* Value is in eights of a point, i.e. 4 / 8 = .5pt
|
|
||||||
*/
|
|
||||||
public function testBorderSize()
|
|
||||||
{
|
|
||||||
$object = new TableFull();
|
|
||||||
$parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV');
|
|
||||||
|
|
||||||
$value = 4;
|
|
||||||
$object->setBorderSize($value);
|
|
||||||
foreach ($parts as $part) {
|
|
||||||
$get = "getBorder{$part}Size";
|
|
||||||
$values[] = $value;
|
|
||||||
$this->assertEquals($value, $object->$get());
|
|
||||||
}
|
|
||||||
$this->assertEquals($values, $object->getBorderSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test cell margin
|
|
||||||
*
|
|
||||||
* Set cell margin and test if each part has the same margin
|
|
||||||
* While looping, push values array to be asserted with getCellMargin
|
|
||||||
* Value is in twips
|
|
||||||
*/
|
|
||||||
public function testCellMargin()
|
|
||||||
{
|
|
||||||
$object = new TableFull();
|
|
||||||
$parts = array('Top', 'Left', 'Right', 'Bottom');
|
|
||||||
|
|
||||||
$value = 240;
|
|
||||||
$object->setCellMargin($value);
|
|
||||||
foreach ($parts as $part) {
|
|
||||||
$get = "getCellMargin{$part}";
|
|
||||||
$values[] = $value;
|
|
||||||
$this->assertEquals($value, $object->$get());
|
|
||||||
}
|
|
||||||
$this->assertEquals($values, $object->getCellMargin());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,38 +9,120 @@ use PhpOffice\PhpWord\Style\Table;
|
||||||
class TableTest extends \PHPUnit_Framework_TestCase
|
class TableTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test set style value
|
* Test class construction
|
||||||
|
*
|
||||||
|
* There are 3 variables for class constructor:
|
||||||
|
* - $styleTable: Define table styles
|
||||||
|
* - $styleFirstRow: Define style for the first row
|
||||||
|
* - $styleLastRow: Define style for the last row (reserved)
|
||||||
*/
|
*/
|
||||||
public function testSetStyleValue()
|
public function testConstruct()
|
||||||
|
{
|
||||||
|
$styleTable = array('bgColor' => 'FF0000');
|
||||||
|
$styleFirstRow = array('borderBottomSize' => 3);
|
||||||
|
|
||||||
|
$object = new Table($styleTable, $styleFirstRow);
|
||||||
|
$this->assertEquals('FF0000', $object->getBgColor());
|
||||||
|
|
||||||
|
$firstRow = $object->getFirstRow();
|
||||||
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Table', $firstRow);
|
||||||
|
$this->assertEquals(3, $firstRow->getBorderBottomSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test setting style with normal value
|
||||||
|
*/
|
||||||
|
public function testSetGetNormal()
|
||||||
{
|
{
|
||||||
$object = new Table();
|
$object = new Table();
|
||||||
$parts = array('Top', 'Left', 'Right', 'Bottom');
|
|
||||||
|
|
||||||
$value = 240; // In twips
|
$attributes = array(
|
||||||
foreach ($parts as $part) {
|
'bgColor' => 'FF0000',
|
||||||
$property = "_cellMargin{$part}";
|
'borderTopSize' => 4,
|
||||||
$get = "getCellMargin{$part}";
|
'borderTopColor' => 'FF0000',
|
||||||
$object->setStyleValue($property, $value);
|
'borderLeftSize' => 4,
|
||||||
|
'borderLeftColor' => 'FF0000',
|
||||||
|
'borderRightSize' => 4,
|
||||||
|
'borderRightColor' => 'FF0000',
|
||||||
|
'borderBottomSize' => 4,
|
||||||
|
'borderBottomColor' => 'FF0000',
|
||||||
|
'borderInsideHSize' => 4,
|
||||||
|
'borderInsideHColor' => 'FF0000',
|
||||||
|
'borderInsideVSize' => 4,
|
||||||
|
'borderInsideVColor' => 'FF0000',
|
||||||
|
'cellMarginTop' => 240,
|
||||||
|
'cellMarginLeft' => 240,
|
||||||
|
'cellMarginRight' => 240,
|
||||||
|
'cellMarginBottom' => 240,
|
||||||
|
);
|
||||||
|
foreach ($attributes as $key => $value) {
|
||||||
|
$set = "set{$key}";
|
||||||
|
$get = "get{$key}";
|
||||||
|
$object->$set($value);
|
||||||
$this->assertEquals($value, $object->$get());
|
$this->assertEquals($value, $object->$get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test border color
|
||||||
|
*
|
||||||
|
* Set border color and test if each part has the same color
|
||||||
|
* While looping, push values array to be asserted with getBorderColor
|
||||||
|
*/
|
||||||
|
public function testBorderColor()
|
||||||
|
{
|
||||||
|
$object = new Table();
|
||||||
|
$parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV');
|
||||||
|
|
||||||
|
$value = 'FF0000';
|
||||||
|
$object->setBorderColor($value);
|
||||||
|
foreach ($parts as $part) {
|
||||||
|
$get = "getBorder{$part}Color";
|
||||||
|
$values[] = $value;
|
||||||
|
$this->assertEquals($value, $object->$get());
|
||||||
|
}
|
||||||
|
$this->assertEquals($values, $object->getBorderColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test border size
|
||||||
|
*
|
||||||
|
* Set border size and test if each part has the same size
|
||||||
|
* While looping, push values array to be asserted with getBorderSize
|
||||||
|
* Value is in eights of a point, i.e. 4 / 8 = .5pt
|
||||||
|
*/
|
||||||
|
public function testBorderSize()
|
||||||
|
{
|
||||||
|
$object = new Table();
|
||||||
|
$parts = array('Top', 'Left', 'Right', 'Bottom', 'InsideH', 'InsideV');
|
||||||
|
|
||||||
|
$value = 4;
|
||||||
|
$object->setBorderSize($value);
|
||||||
|
foreach ($parts as $part) {
|
||||||
|
$get = "getBorder{$part}Size";
|
||||||
|
$values[] = $value;
|
||||||
|
$this->assertEquals($value, $object->$get());
|
||||||
|
}
|
||||||
|
$this->assertEquals($values, $object->getBorderSize());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cell margin
|
* Test cell margin
|
||||||
|
*
|
||||||
|
* Set cell margin and test if each part has the same margin
|
||||||
|
* While looping, push values array to be asserted with getCellMargin
|
||||||
|
* Value is in twips
|
||||||
*/
|
*/
|
||||||
public function testCellMargin()
|
public function testCellMargin()
|
||||||
{
|
{
|
||||||
$object = new Table();
|
$object = new Table();
|
||||||
$parts = array('Top', 'Left', 'Right', 'Bottom');
|
$parts = array('Top', 'Left', 'Right', 'Bottom');
|
||||||
|
|
||||||
// Set cell margin and test if each part has the same margin
|
$value = 240;
|
||||||
// While looping, push values array to be asserted with getCellMargin
|
$object->setCellMargin($value);
|
||||||
$value = 240; // In twips
|
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
$set = "setCellMargin{$part}";
|
|
||||||
$get = "getCellMargin{$part}";
|
$get = "getCellMargin{$part}";
|
||||||
$values[] = $value;
|
$values[] = $value;
|
||||||
$object->$set($value);
|
|
||||||
$this->assertEquals($value, $object->$get());
|
$this->assertEquals($value, $object->$get());
|
||||||
}
|
}
|
||||||
$this->assertEquals($values, $object->getCellMargin());
|
$this->assertEquals($values, $object->getCellMargin());
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase
|
||||||
$font = array('italic' => true);
|
$font = array('italic' => true);
|
||||||
$table = array('bgColor' => 'CCCCCC');
|
$table = array('bgColor' => 'CCCCCC');
|
||||||
$styles = array('Paragraph' => 'Paragraph', 'Font' => 'Font',
|
$styles = array('Paragraph' => 'Paragraph', 'Font' => 'Font',
|
||||||
'Link' => 'Font', 'Table' => 'TableFull',
|
'Link' => 'Font', 'Table' => 'Table',
|
||||||
'Heading_1' => 'Font', 'Normal' => 'Paragraph');
|
'Heading_1' => 'Font', 'Normal' => 'Paragraph');
|
||||||
$elementCount = 6;
|
$elementCount = 6;
|
||||||
Style::addParagraphStyle('Paragraph', $paragraph);
|
Style::addParagraphStyle('Paragraph', $paragraph);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue