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-04-11 21:16:07 +07:00
|
|
|
use PhpOffice\PhpWord\Shared\String;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Background-Color
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $bgColor;
|
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
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new Cell Style
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->valign = null;
|
|
|
|
|
$this->textDirection = null;
|
|
|
|
|
$this->bgColor = 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set style value
|
|
|
|
|
*
|
2014-03-17 07:26:25 +07:00
|
|
|
* @param string $key
|
|
|
|
|
* @param mixed $value
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
|
|
|
|
public function setStyleValue($key, $value)
|
|
|
|
|
{
|
2014-04-11 21:16:07 +07:00
|
|
|
$key = String::removeUnderscorePrefix($key);
|
2014-04-06 18:03:03 +07:00
|
|
|
if ($key == 'borderSize') {
|
2013-12-16 06:40:30 -05:00
|
|
|
$this->setBorderSize($value);
|
2014-04-06 18:03:03 +07:00
|
|
|
} elseif ($key == 'borderColor') {
|
2013-12-16 06:40:30 -05:00
|
|
|
$this->setBorderColor($value);
|
|
|
|
|
} else {
|
|
|
|
|
$this->$key = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
|
* Get background color
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function getBgColor()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->bgColor;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Set background color
|
|
|
|
|
*
|
|
|
|
|
* @param string $pValue
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
public function setBgColor($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->bgColor = $pValue;
|
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-03-11 19:26:56 +07:00
|
|
|
}
|