242 lines
4.7 KiB
PHP
Raw Normal View History

2012-05-06 18:25:40 +02:00
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
2012-05-06 18:25:40 +02:00
*
2014-03-27 23:55:06 +07:00
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2014 PHPWord contributors
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
*/
namespace PhpOffice\PhpWord\Style;
2013-12-16 06:40:30 -05:00
/**
* Table cell style
*/
class Cell extends Border
{
2014-05-08 19:25:29 +07:00
/**
* Vertical alignment constants
*
* @const string
*/
const VALIGN_TOP = 'top';
const VALIGN_CENTER = 'center';
const VALIGN_BOTTOM = 'bottom';
const VALIGN_BOTH = 'both';
/**
* 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-08 19:25:29 +07:00
/**
* Vertical merge (rowspan) constants
*
* @const string
*/
const VMERGE_RESTART = 'restart';
const VMERGE_CONTINUE = 'continue';
2013-12-16 06:40:30 -05:00
/**
* 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
*/
2014-05-07 09:47:02 +07:00
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
*/
2014-05-08 19:25:29 +07:00
private $gridSpan;
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
*/
2014-05-08 19:25:29 +07:00
private $vMerge;
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()
{
2014-05-07 09:47:02 +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 $value
2014-05-08 19:25:29 +07:00
* @return self
2014-03-17 07:26:25 +07:00
*/
public function setVAlign($value = null)
2013-12-16 06:40:30 -05:00
{
2014-05-08 19:25:29 +07:00
$enum = array(self::VALIGN_TOP, self::VALIGN_CENTER, self::VALIGN_BOTTOM, self::VALIGN_BOTH);
$this->vAlign = $this->setEnumVal($value, $enum, $this->vAlign);
return $this;
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-05-08 19:25:29 +07:00
* @return self
2014-03-17 07:26:25 +07:00
*/
public function setTextDirection($value = null)
2013-12-16 06:40:30 -05:00
{
2014-05-08 19:25:29 +07:00
$enum = array(self::TEXT_DIR_BTLR, self::TEXT_DIR_TBRL);
$this->textDirection = $this->setEnumVal($value, $enum, $this->textDirection);
return $this;
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 ($this->shading !== null) {
return $this->shading->getFill();
} else {
return null;
}
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-05-08 19:25:29 +07:00
/**
* Get grid span (colspan)
*/
public function getGridSpan()
{
return $this->gridSpan;
}
2014-03-17 07:26:25 +07:00
/**
* Set grid span (colspan)
*
* @param int $value
2014-05-08 19:25:29 +07:00
* @return self
2014-03-17 07:26:25 +07:00
*/
public function setGridSpan($value = null)
2013-12-16 06:40:30 -05:00
{
2014-05-08 19:25:29 +07:00
$this->gridSpan = $this->setIntVal($value, $this->gridSpan);
return $this;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
2014-05-08 19:25:29 +07:00
* Get vertical merge (rowspan)
2014-03-17 07:26:25 +07:00
*/
2014-05-08 19:25:29 +07:00
public function getVMerge()
2013-12-16 06:40:30 -05:00
{
2014-05-08 19:25:29 +07:00
return $this->vMerge;
2013-12-16 06:40:30 -05:00
}
2014-03-17 07:26:25 +07:00
/**
* Set vertical merge (rowspan)
*
* @param string $value
2014-05-08 19:25:29 +07:00
* @return self
2014-03-17 07:26:25 +07:00
*/
public function setVMerge($value = null)
2013-12-16 06:40:30 -05:00
{
2014-05-08 19:25:29 +07:00
$enum = array(self::VMERGE_RESTART, self::VMERGE_CONTINUE);
$this->vMerge = $this->setEnumVal($value, $enum, $this->vMerge);
2013-12-16 06:40:30 -05:00
2014-05-08 19:25:29 +07:00
return $this;
2013-12-16 06:40:30 -05:00
}
/**
* Get shading
*
* @return \PhpOffice\PhpWord\Style\Shading
*/
public function getShading()
{
return $this->shading;
}
/**
* Set shading
*
2014-05-07 09:47:02 +07:00
* @param mixed $value
* @return self
*/
public function setShading($value = null)
{
2014-05-07 09:47:02 +07:00
$this->setObjectVal($value, 'Shading', $this->shading);
return $this;
}
/**
* Get default border color
*
* @deprecated 0.10.0
* @codeCoverageIgnore
*/
public function getDefaultBorderColor()
{
return self::DEFAULT_BORDER_COLOR;
}
}