2012-05-06 18:25:40 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
2014-03-26 16:33:20 +07:00
|
|
|
* PHPWord
|
2012-05-06 18:25:40 +02:00
|
|
|
*
|
2014-03-27 23:55:06 +07:00
|
|
|
* @link https://github.com/PHPOffice/PHPWord
|
|
|
|
|
* @copyright 2014 PHPWord
|
|
|
|
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
2012-05-06 18:25:40 +02:00
|
|
|
*/
|
|
|
|
|
|
2014-03-22 10:06:08 +04:00
|
|
|
namespace PhpOffice\PhpWord\Style;
|
2013-12-16 06:40:30 -05:00
|
|
|
|
2014-05-02 09:45:16 +07:00
|
|
|
use PhpOffice\PhpWord\Style\Shading;
|
2014-04-11 21:16:07 +07:00
|
|
|
|
2014-03-24 00:26:10 +07:00
|
|
|
/**
|
|
|
|
|
* Table cell style
|
|
|
|
|
*/
|
2014-04-28 23:33:26 +07:00
|
|
|
class Cell extends Border
|
2014-03-22 10:06:08 +04:00
|
|
|
{
|
2013-12-16 06:40:30 -05:00
|
|
|
const TEXT_DIR_BTLR = 'btLr';
|
|
|
|
|
const TEXT_DIR_TBRL = 'tbRl';
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-10 21:06:15 +07:00
|
|
|
* Vertical align (top, center, both, bottom)
|
2013-12-16 06:40:30 -05:00
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $valign;
|
2013-12-16 06:40:30 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Text Direction
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $textDirection;
|
2013-12-16 06:40:30 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Border Default Color
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $defaultBorderColor;
|
2013-12-16 06:40:30 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* colspan
|
|
|
|
|
*
|
|
|
|
|
* @var integer
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $gridSpan = null;
|
2013-12-16 06:40:30 -05:00
|
|
|
|
|
|
|
|
/**
|
2014-03-10 21:06:15 +07:00
|
|
|
* rowspan (restart, continue)
|
2013-12-16 06:40:30 -05:00
|
|
|
*
|
2014-03-10 21:06:15 +07:00
|
|
|
* - restart: Start/restart merged region
|
|
|
|
|
* - continue: Continue merged region
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $vMerge = null;
|
2013-12-16 06:40:30 -05:00
|
|
|
|
2014-05-02 09:45:16 +07:00
|
|
|
/**
|
|
|
|
|
* Shading
|
|
|
|
|
*
|
|
|
|
|
* @var \PhpOffice\PhpWord\Style\Shading
|
|
|
|
|
*/
|
|
|
|
|
private $shading;
|
|
|
|
|
|
2013-12-16 06:40:30 -05:00
|
|
|
/**
|
|
|
|
|
* Create a new Cell Style
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->valign = null;
|
|
|
|
|
$this->textDirection = null;
|
|
|
|
|
$this->borderTopSize = null;
|
|
|
|
|
$this->borderTopColor = null;
|
|
|
|
|
$this->borderLeftSize = null;
|
|
|
|
|
$this->borderLeftColor = null;
|
|
|
|
|
$this->borderRightSize = null;
|
|
|
|
|
$this->borderRightColor = null;
|
|
|
|
|
$this->borderBottomSize = null;
|
|
|
|
|
$this->borderBottomColor = null;
|
|
|
|
|
$this->defaultBorderColor = '000000';
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Get vertical align
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function getVAlign()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->valign;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Set vertical align
|
|
|
|
|
*
|
|
|
|
|
* @param string $pValue
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function setVAlign($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->valign = $pValue;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Get text direction
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function getTextDirection()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->textDirection;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Set text direction
|
|
|
|
|
*
|
|
|
|
|
* @param string $pValue
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function setTextDirection($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->textDirection = $pValue;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
2014-05-02 09:45:16 +07:00
|
|
|
* Get background
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
2014-03-17 07:26:25 +07:00
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function getBgColor()
|
|
|
|
|
{
|
2014-05-02 09:45:16 +07:00
|
|
|
if (!is_null($this->shading)) {
|
|
|
|
|
return $this->shading->getFill();
|
|
|
|
|
}
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
2014-05-02 09:45:16 +07:00
|
|
|
* Set background
|
2014-03-17 07:26:25 +07:00
|
|
|
*
|
2014-05-02 09:45:16 +07:00
|
|
|
* @param string $value
|
|
|
|
|
* @return \PhpOffice\PhpWord\Style\Table
|
2014-03-17 07:26:25 +07:00
|
|
|
*/
|
2014-05-02 09:45:16 +07:00
|
|
|
public function setBgColor($value = null)
|
2013-12-16 06:40:30 -05:00
|
|
|
{
|
2014-05-02 09:45:16 +07:00
|
|
|
$this->setShading(array('fill' => $value));
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Get default border color
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function getDefaultBorderColor()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->defaultBorderColor;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Set grid span (colspan)
|
|
|
|
|
*
|
|
|
|
|
* @param int $pValue
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function setGridSpan($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->gridSpan = $pValue;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Get grid span (colspan)
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function getGridSpan()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->gridSpan;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Set vertical merge (rowspan)
|
|
|
|
|
*
|
|
|
|
|
* @param string $pValue
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function setVMerge($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->vMerge = $pValue;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Get vertical merge (rowspan)
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function getVMerge()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->vMerge;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
2014-05-02 09:45:16 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
2014-03-11 19:26:56 +07:00
|
|
|
}
|