PHPWord/src/PhpWord/Style/TextBox.php

258 lines
4.7 KiB
PHP
Raw Normal View History

2014-05-07 21:27:51 +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.
*
* @see https://github.com/PHPOffice/PHPWord
2022-09-16 11:45:45 +02:00
*
2014-05-07 21:27:51 +02:00
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
2022-09-16 11:45:45 +02:00
* TextBox style.
2014-05-08 12:58:44 +07:00
*
* @since 0.11.0
2014-05-07 21:27:51 +02:00
*/
class TextBox extends Image
2014-05-07 21:27:51 +02:00
{
/**
2022-09-16 11:45:45 +02:00
* margin top.
2014-05-07 21:27:51 +02:00
*
* @var int
*/
2022-09-16 11:45:45 +02:00
private $innerMarginTop;
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* margin left.
2014-05-07 21:27:51 +02:00
*
* @var int
*/
2022-09-16 11:45:45 +02:00
private $innerMarginLeft;
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* margin right.
2014-05-07 21:27:51 +02:00
*
* @var int
*/
2022-09-16 11:45:45 +02:00
private $innerMarginRight;
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* Cell margin bottom.
2014-05-07 21:27:51 +02:00
*
* @var int
*/
2022-09-16 11:45:45 +02:00
private $innerMarginBottom;
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* border size.
*
2014-05-07 21:27:51 +02:00
* @var int
*/
2022-09-16 11:45:45 +02:00
private $borderSize;
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* border color.
2014-05-07 21:27:51 +02:00
*
* @var string
*/
private $borderColor;
2022-12-30 21:50:28 +01:00
/**
* background color.
*
* @var string
*/
private $bgColor;
/**
* Set background color.
*
* @param string $value
*/
2022-12-30 21:50:28 +01:00
public function setBgColor($value = null): void
{
$this->bgColor = $value;
}
/**
* Get background color.
*
* @return string
*/
public function getBgColor()
{
return $this->bgColor;
}
2014-05-07 21:27:51 +02:00
/**
* Set margin top.
2014-05-07 21:27:51 +02:00
*
* @param int $value
*/
2022-09-16 11:45:45 +02:00
public function setInnerMarginTop($value = null): void
2014-05-07 21:27:51 +02:00
{
$this->innerMarginTop = $value;
}
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* Get margin top.
2014-05-07 21:27:51 +02:00
*
* @return int
*/
public function getInnerMarginTop()
{
return $this->innerMarginTop;
}
2014-05-07 21:27:51 +02:00
/**
* Set margin left.
2014-05-07 21:27:51 +02:00
*
* @param int $value
*/
2022-09-16 11:45:45 +02:00
public function setInnerMarginLeft($value = null): void
2014-05-07 21:27:51 +02:00
{
$this->innerMarginLeft = $value;
}
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* Get margin left.
2014-05-07 21:27:51 +02:00
*
* @return int
*/
public function getInnerMarginLeft()
{
return $this->innerMarginLeft;
}
2014-05-07 21:27:51 +02:00
/**
* Set margin right.
2014-05-07 21:27:51 +02:00
*
* @param int $value
*/
2022-09-16 11:45:45 +02:00
public function setInnerMarginRight($value = null): void
2014-05-07 21:27:51 +02:00
{
$this->innerMarginRight = $value;
}
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* Get margin right.
2014-05-07 21:27:51 +02:00
*
* @return int
*/
public function getInnerMarginRight()
{
return $this->innerMarginRight;
}
2014-05-07 21:27:51 +02:00
/**
* Set margin bottom.
2014-05-07 21:27:51 +02:00
*
* @param int $value
*/
2022-09-16 11:45:45 +02:00
public function setInnerMarginBottom($value = null): void
2014-05-07 21:27:51 +02:00
{
$this->innerMarginBottom = $value;
}
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* Get margin bottom.
2014-05-07 21:27:51 +02:00
*
* @return int
*/
public function getInnerMarginBottom()
{
return $this->innerMarginBottom;
}
2014-05-07 21:27:51 +02:00
/**
* Set TLRB cell margin.
2014-05-07 21:27:51 +02:00
*
* @param int $value Margin in twips
*/
2022-09-16 11:45:45 +02:00
public function setInnerMargin($value = null): void
2014-05-07 21:27:51 +02:00
{
$this->setInnerMarginTop($value);
$this->setInnerMarginLeft($value);
$this->setInnerMarginRight($value);
$this->setInnerMarginBottom($value);
}
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* Get cell margin.
2014-05-07 21:27:51 +02:00
*
* @return int[]
2014-05-07 21:27:51 +02:00
*/
public function getInnerMargin()
{
2022-09-16 11:45:45 +02:00
return [$this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom];
2014-05-07 21:27:51 +02:00
}
2014-05-08 22:42:56 +07:00
/**
* Has inner margin?
*
* @return bool
*/
public function hasInnerMargins()
{
$hasInnerMargins = false;
$margins = $this->getInnerMargin();
$numMargins = count($margins);
2022-09-16 11:45:45 +02:00
for ($i = 0; $i < $numMargins; ++$i) {
if ($margins[$i] !== null) {
2014-05-08 22:42:56 +07:00
$hasInnerMargins = true;
}
}
return $hasInnerMargins;
}
2014-05-07 21:27:51 +02:00
/**
* Set border size.
*
2014-05-07 21:27:51 +02:00
* @param int $value Size in points
*/
2022-09-16 11:45:45 +02:00
public function setBorderSize($value = null): void
2014-05-07 21:27:51 +02:00
{
$this->borderSize = $value;
}
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* Get border size.
*
2014-05-07 21:27:51 +02:00
* @return int
*/
public function getBorderSize()
{
return $this->borderSize;
}
/**
* Set border color.
*
2014-05-07 21:27:51 +02:00
* @param string $value
*/
2022-09-16 11:45:45 +02:00
public function setBorderColor($value = null): void
2014-05-07 21:27:51 +02:00
{
$this->borderColor = $value;
}
2014-05-07 21:27:51 +02:00
/**
2022-09-16 11:45:45 +02:00
* Get border color.
*
2014-05-07 21:27:51 +02:00
* @return string
*/
public function getBorderColor()
{
return $this->borderColor;
}
}