208 lines
3.5 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/lgpl.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\Style\Shading;
/**
* Table cell style
*/
class Cell extends Border
{
/**
* Text direction constants
*
* @const string
*/
2013-12-16 06:40:30 -05:00
const TEXT_DIR_BTLR = 'btLr';
const TEXT_DIR_TBRL = 'tbRl';
/**
* Default border color
2013-12-16 06:40:30 -05:00
*
* @const string
2013-12-16 06:40:30 -05:00
*/
const DEFAULT_BORDER_COLOR = '000000';
2013-12-16 06:40:30 -05:00
/**
* 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
2013-12-16 06:40:30 -05:00
*
* @var string
*/
private $textDirection;
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
/**
* Shading
*
* @var \PhpOffice\PhpWord\Style\Shading
*/
private $shading;
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 $value
2014-03-17 07:26:25 +07:00
*/
public function setVAlign($value = null)
2013-12-16 06:40:30 -05:00
{
$this->valign = $value;
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 $value
2014-03-17 07:26:25 +07:00
*/
public function setTextDirection($value = null)
2013-12-16 06:40:30 -05:00
{
$this->textDirection = $value;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +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()
{
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
/**
* Set background
2014-03-17 07:26:25 +07:00
*
* @param string $value
* @return self
2014-03-17 07:26:25 +07:00
*/
public function setBgColor($value = null)
2013-12-16 06:40:30 -05:00
{
return $this->setShading(array('fill' => $value));
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Set grid span (colspan)
*
* @param int $value
2014-03-17 07:26:25 +07:00
*/
public function setGridSpan($value = null)
2013-12-16 06:40:30 -05:00
{
$this->gridSpan = $value;
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 $value
2014-03-17 07:26:25 +07:00
*/
public function setVMerge($value = null)
2013-12-16 06:40:30 -05:00
{
$this->vMerge = $value;
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
}
/**
* 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;
}
/**
* Get default border color
*
* @deprecated 0.10.0
* @codeCoverageIgnore
*/
public function getDefaultBorderColor()
{
return self::DEFAULT_BORDER_COLOR;
}
}