202 lines
3.6 KiB
PHP
Raw Normal View History

2012-05-06 18:25:40 +02:00
<?php
/**
* 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
*/
namespace PhpOffice\PhpWord\Style;
2013-12-16 06:40:30 -05:00
use PhpOffice\PhpWord\Shared\String;
/**
* Table cell style
*/
class Cell extends Border
{
2013-12-16 06:40:30 -05:00
const TEXT_DIR_BTLR = 'btLr';
const TEXT_DIR_TBRL = 'tbRl';
/**
* Vertical align (top, center, both, bottom)
2013-12-16 06:40:30 -05:00
*
* @var string
*/
private $valign;
2013-12-16 06:40:30 -05:00
/**
* Text Direction
*
* @var string
*/
private $textDirection;
2013-12-16 06:40:30 -05:00
/**
* Background-Color
*
* @var string
*/
private $bgColor;
2013-12-16 06:40:30 -05:00
/**
* Border Default Color
*
* @var string
*/
private $defaultBorderColor;
2013-12-16 06:40:30 -05:00
/**
* colspan
*
* @var integer
*/
private $gridSpan = null;
2013-12-16 06:40:30 -05:00
/**
* rowspan (restart, continue)
2013-12-16 06:40:30 -05:00
*
* - restart: Start/restart merged region
* - continue: Continue merged region
*
* @var string
2013-12-16 06:40:30 -05:00
*/
private $vMerge = null;
2013-12-16 06:40:30 -05:00
/**
* Create a new Cell Style
*/
public function __construct()
{
$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)
{
$key = String::removeUnderscorePrefix($key);
if ($key == 'borderSize') {
2013-12-16 06:40:30 -05:00
$this->setBorderSize($value);
} 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()
{
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)
{
$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()
{
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)
{
$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()
{
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)
{
$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()
{
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)
{
$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()
{
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)
{
$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()
{
return $this->vMerge;
2013-12-16 06:40:30 -05:00
}
}