454 lines
8.1 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
/**
* Table cell style
*/
class Cell extends AbstractStyle
{
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 Top Size
*
* @var int
*/
private $borderTopSize;
2013-12-16 06:40:30 -05:00
/**
* Border Top Color
*
* @var string
*/
private $borderTopColor;
2013-12-16 06:40:30 -05:00
/**
* Border Left Size
*
* @var int
*/
private $borderLeftSize;
2013-12-16 06:40:30 -05:00
/**
* Border Left Color
*
* @var string
*/
private $borderLeftColor;
2013-12-16 06:40:30 -05:00
/**
* Border Right Size
*
* @var int
*/
private $borderRightSize;
2013-12-16 06:40:30 -05:00
/**
* Border Right Color
*
* @var string
*/
private $borderRightColor;
2013-12-16 06:40:30 -05:00
/**
* Border Bottom Size
*
* @var int
*/
private $borderBottomSize;
2013-12-16 06:40:30 -05:00
/**
* Border Bottom Color
*
* @var string
*/
private $borderBottomColor;
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)
{
if (substr($key, 0, 1) == '_') {
$key = substr($key, 1);
}
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
/**
* Set border size
*
* @param int $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderSize($pValue = null)
{
$this->borderTopSize = $pValue;
$this->borderLeftSize = $pValue;
$this->borderRightSize = $pValue;
$this->borderBottomSize = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border size
*/
2013-12-16 06:40:30 -05:00
public function getBorderSize()
{
$t = $this->getBorderTopSize();
$l = $this->getBorderLeftSize();
$r = $this->getBorderRightSize();
$b = $this->getBorderBottomSize();
return array($t, $l, $r, $b);
}
2014-03-17 07:26:25 +07:00
/**
* Set border color
*
* @param string $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderColor($pValue = null)
{
$this->borderTopColor = $pValue;
$this->borderLeftColor = $pValue;
$this->borderRightColor = $pValue;
$this->borderBottomColor = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border color
*/
2013-12-16 06:40:30 -05:00
public function getBorderColor()
{
$t = $this->getBorderTopColor();
$l = $this->getBorderLeftColor();
$r = $this->getBorderRightColor();
$b = $this->getBorderBottomColor();
return array($t, $l, $r, $b);
}
2014-03-17 07:26:25 +07:00
/**
* Set border top size
*
* @param int $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderTopSize($pValue = null)
{
$this->borderTopSize = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border top size
*/
2013-12-16 06:40:30 -05:00
public function getBorderTopSize()
{
return $this->borderTopSize;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Set border top color
*
* @param string $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderTopColor($pValue = null)
{
$this->borderTopColor = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border top color
*/
2013-12-16 06:40:30 -05:00
public function getBorderTopColor()
{
return $this->borderTopColor;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Set border left size
*
* @param int $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderLeftSize($pValue = null)
{
$this->borderLeftSize = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border left size
*/
2013-12-16 06:40:30 -05:00
public function getBorderLeftSize()
{
return $this->borderLeftSize;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Set border left color
*
* @param string $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderLeftColor($pValue = null)
{
$this->borderLeftColor = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border left color
*/
2013-12-16 06:40:30 -05:00
public function getBorderLeftColor()
{
return $this->borderLeftColor;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Set border right size
*
* @param int $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderRightSize($pValue = null)
{
$this->borderRightSize = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border right size
*/
2013-12-16 06:40:30 -05:00
public function getBorderRightSize()
{
return $this->borderRightSize;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Set border right color
*
* @param string $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderRightColor($pValue = null)
{
$this->borderRightColor = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border right color
*/
2013-12-16 06:40:30 -05:00
public function getBorderRightColor()
{
return $this->borderRightColor;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Set border bottom size
*
* @param int $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderBottomSize($pValue = null)
{
$this->borderBottomSize = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border bottom size
*/
2013-12-16 06:40:30 -05:00
public function getBorderBottomSize()
{
return $this->borderBottomSize;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Set border bottom color
*
* @param string $pValue
*/
2013-12-16 06:40:30 -05:00
public function setBorderBottomColor($pValue = null)
{
$this->borderBottomColor = $pValue;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Get border bottom color
*/
2013-12-16 06:40:30 -05:00
public function getBorderBottomColor()
{
return $this->borderBottomColor;
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
}
}