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
|
2014-05-04 21:03:28 +04:00
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
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-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
|
|
|
{
|
2014-05-02 13:39:56 +07:00
|
|
|
/**
|
|
|
|
|
* Text direction constants
|
|
|
|
|
*
|
|
|
|
|
* @const string
|
|
|
|
|
*/
|
2013-12-16 06:40:30 -05:00
|
|
|
const TEXT_DIR_BTLR = 'btLr';
|
|
|
|
|
const TEXT_DIR_TBRL = 'tbRl';
|
|
|
|
|
|
|
|
|
|
/**
|
2014-05-02 13:39:56 +07:00
|
|
|
* Default border color
|
2013-12-16 06:40:30 -05:00
|
|
|
*
|
2014-05-02 13:39:56 +07:00
|
|
|
* @const string
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
2014-05-02 13:39:56 +07:00
|
|
|
const DEFAULT_BORDER_COLOR = '000000';
|
2013-12-16 06:40:30 -05:00
|
|
|
|
|
|
|
|
/**
|
2014-05-02 13:39:56 +07:00
|
|
|
* Vertical align (top, center, both, bottom)
|
2013-12-16 06:40:30 -05:00
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2014-05-02 13:39:56 +07:00
|
|
|
private $valign;
|
2013-12-16 06:40:30 -05:00
|
|
|
|
|
|
|
|
/**
|
2014-05-02 13:39:56 +07:00
|
|
|
* Text Direction
|
2013-12-16 06:40:30 -05:00
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2014-05-02 13:39:56 +07:00
|
|
|
private $textDirection;
|
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;
|
|
|
|
|
|
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
|
|
|
|
|
*
|
2014-05-02 13:39:56 +07:00
|
|
|
* @param string $value
|
2014-03-17 07:26:25 +07:00
|
|
|
*/
|
2014-05-02 13:39:56 +07:00
|
|
|
public function setVAlign($value = null)
|
2013-12-16 06:40:30 -05:00
|
|
|
{
|
2014-05-02 13:39:56 +07: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()
|
|
|
|
|
{
|
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
|
|
|
|
|
*
|
2014-05-02 13:39:56 +07:00
|
|
|
* @param string $value
|
2014-03-17 07:26:25 +07:00
|
|
|
*/
|
2014-05-02 13:39:56 +07:00
|
|
|
public function setTextDirection($value = null)
|
2013-12-16 06:40:30 -05:00
|
|
|
{
|
2014-05-02 13:39:56 +07:00
|
|
|
$this->textDirection = $value;
|
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
|
2014-05-02 13:39:56 +07:00
|
|
|
* @return self
|
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 13:39:56 +07: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)
|
|
|
|
|
*
|
2014-05-02 13:39:56 +07:00
|
|
|
* @param int $value
|
2014-03-17 07:26:25 +07:00
|
|
|
*/
|
2014-05-02 13:39:56 +07:00
|
|
|
public function setGridSpan($value = null)
|
2013-12-16 06:40:30 -05:00
|
|
|
{
|
2014-05-02 13:39:56 +07: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()
|
|
|
|
|
{
|
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)
|
|
|
|
|
*
|
2014-05-02 13:39:56 +07:00
|
|
|
* @param string $value
|
2014-03-17 07:26:25 +07:00
|
|
|
*/
|
2014-05-02 13:39:56 +07:00
|
|
|
public function setVMerge($value = null)
|
2013-12-16 06:40:30 -05:00
|
|
|
{
|
2014-05-02 13:39:56 +07: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()
|
|
|
|
|
{
|
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-05-02 13:39:56 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get default border color
|
|
|
|
|
*
|
|
|
|
|
* @deprecated 0.10.0
|
|
|
|
|
* @codeCoverageIgnore
|
|
|
|
|
*/
|
|
|
|
|
public function getDefaultBorderColor()
|
|
|
|
|
{
|
|
|
|
|
return self::DEFAULT_BORDER_COLOR;
|
|
|
|
|
}
|
2014-03-11 19:26:56 +07:00
|
|
|
}
|