123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- <?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
- * @copyright 2010-2018 PHPWord contributors
- * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
- */
- namespace PhpOffice\PhpWord\Style;
- /**
- * TablePosition style
- *
- * @see http://www.datypic.com/sc/ooxml/e-w_tblpPr-1.html
- */
- class TablePosition extends AbstractStyle
- {
- /**
- * Vertical anchor constants
- *
- * @const string
- * @see http://www.datypic.com/sc/ooxml/t-w_ST_VAnchor.html
- */
- const VANCHOR_TEXT = 'text'; // Relative to vertical text extents
- const VANCHOR_MARGIN = 'margin'; // Relative to margin
- const VANCHOR_PAGE = 'page'; // Relative to page
- /**
- * Horizontal anchor constants
- *
- * @const string
- * @see http://www.datypic.com/sc/ooxml/t-w_ST_HAnchor.html
- */
- const HANCHOR_TEXT = 'text'; // Relative to text extents
- const HANCHOR_MARGIN = 'margin'; // Relative to margin
- const HANCHOR_PAGE = 'page'; // Relative to page
- /**
- * Horizontal alignment constants
- *
- * @const string
- * @see http://www.datypic.com/sc/ooxml/t-w_ST_XAlign.html
- */
- const XALIGN_LEFT = 'left'; // Left aligned horizontally
- const XALIGN_CENTER = 'center'; // Centered horizontally
- const XALIGN_RIGHT = 'right'; // Right aligned horizontally
- const XALIGN_INSIDE = 'inside'; // Inside
- const XALIGN_OUTSIDE = 'outside'; // Outside
- /**
- * Vertical alignment constants
- *
- * @const string
- * @see http://www.datypic.com/sc/ooxml/t-w_ST_YAlign.html
- */
- const YALIGN_INLINE = 'inline'; // In line with text
- const YALIGN_TOP = 'top'; // Top
- const YALIGN_CENTER = 'center'; // Centered vertically
- const YALIGN_BOTTOM = 'bottom'; // Bottom
- const YALIGN_INSIDE = 'inside'; // Inside Anchor Extents
- const YALIGN_OUTSIDE = 'outside'; // Centered vertically
- /**
- * Distance from left of table to text
- *
- * @var int
- */
- private $leftFromText;
- /**
- * Distance from right of table to text
- *
- * @var int
- */
- private $rightFromText;
- /**
- * Distance from top of table to text
- *
- * @var int
- */
- private $topFromText;
- /**
- * Distance from bottom of table to text
- *
- * @var int
- */
- private $bottomFromText;
- /**
- * Table vertical anchor
- *
- * @var string
- * @see http://www.datypic.com/sc/ooxml/t-w_ST_VAnchor.html
- */
- private $vertAnchor;
- /**
- * Table horizontal anchor
- *
- * @var string
- * @see http://www.datypic.com/sc/ooxml/t-w_ST_HAnchor.html
- */
- private $horzAnchor;
- /**
- * Relative horizontal alignment from anchor
- *
- * @var string
- * @see http://www.datypic.com/sc/ooxml/t-w_ST_XAlign.html
- */
- private $tblpXSpec;
- /**
- * Absolute horizontal distance from anchor
- *
- * @var int
- */
- private $tblpX;
- /**
- * Relative vertical alignment from anchor
- *
- * @var string
- * @see http://www.datypic.com/sc/ooxml/t-w_ST_YAlign.html
- */
- private $tblpYSpec;
- /**
- * Absolute vertical distance from anchor
- *
- * @var int
- */
- private $tblpY;
- /**
- * Create a new instance
- *
- * @param array $style
- */
- public function __construct($style = array())
- {
- $this->setStyleByArray($style);
- }
- /**
- * Get distance from left of table to text
- *
- * @return int
- */
- public function getLeftFromText()
- {
- return $this->leftFromText;
- }
- /**
- * Set distance from left of table to text
- *
- * @param int $value
- * @return self
- */
- public function setLeftFromText($value = null)
- {
- $this->leftFromText = $this->setNumericVal($value, $this->leftFromText);
- return $this;
- }
- /**
- * Get distance from right of table to text
- *
- * @return int
- */
- public function getRightFromText()
- {
- return $this->rightFromText;
- }
- /**
- * Set distance from right of table to text
- *
- * @param int $value
- * @return self
- */
- public function setRightFromText($value = null)
- {
- $this->rightFromText = $this->setNumericVal($value, $this->rightFromText);
- return $this;
- }
- /**
- * Get distance from top of table to text
- *
- * @return int
- */
- public function getTopFromText()
- {
- return $this->topFromText;
- }
- /**
- * Set distance from top of table to text
- *
- * @param int $value
- * @return self
- */
- public function setTopFromText($value = null)
- {
- $this->topFromText = $this->setNumericVal($value, $this->topFromText);
- return $this;
- }
- /**
- * Get distance from bottom of table to text
- *
- * @return int
- */
- public function getBottomFromText()
- {
- return $this->bottomFromText;
- }
- /**
- * Set distance from bottom of table to text
- *
- * @param int $value
- * @return self
- */
- public function setBottomFromText($value = null)
- {
- $this->bottomFromText = $this->setNumericVal($value, $this->bottomFromText);
- return $this;
- }
- /**
- * Get table vertical anchor
- *
- * @return string
- */
- public function getVertAnchor()
- {
- return $this->vertAnchor;
- }
- /**
- * Set table vertical anchor
- *
- * @param string $value
- * @return self
- */
- public function setVertAnchor($value = null)
- {
- $enum = array(
- self::VANCHOR_TEXT,
- self::VANCHOR_MARGIN,
- self::VANCHOR_PAGE,
- );
- $this->vertAnchor = $this->setEnumVal($value, $enum, $this->vertAnchor);
- return $this;
- }
- /**
- * Get table horizontal anchor
- *
- * @return string
- */
- public function getHorzAnchor()
- {
- return $this->horzAnchor;
- }
- /**
- * Set table horizontal anchor
- *
- * @param string $value
- * @return self
- */
- public function setHorzAnchor($value = null)
- {
- $enum = array(
- self::HANCHOR_TEXT,
- self::HANCHOR_MARGIN,
- self::HANCHOR_PAGE,
- );
- $this->horzAnchor = $this->setEnumVal($value, $enum, $this->horzAnchor);
- return $this;
- }
- /**
- * Get relative horizontal alignment from anchor
- *
- * @return string
- */
- public function getTblpXSpec()
- {
- return $this->tblpXSpec;
- }
- /**
- * Set relative horizontal alignment from anchor
- *
- * @param string $value
- * @return self
- */
- public function setTblpXSpec($value = null)
- {
- $enum = array(
- self::XALIGN_LEFT,
- self::XALIGN_CENTER,
- self::XALIGN_RIGHT,
- self::XALIGN_INSIDE,
- self::XALIGN_OUTSIDE,
- );
- $this->tblpXSpec = $this->setEnumVal($value, $enum, $this->tblpXSpec);
- return $this;
- }
- /**
- * Get absolute horizontal distance from anchor
- *
- * @return int
- */
- public function getTblpX()
- {
- return $this->tblpX;
- }
- /**
- * Set absolute horizontal distance from anchor
- *
- * @param int $value
- * @return self
- */
- public function setTblpX($value = null)
- {
- $this->tblpX = $this->setNumericVal($value, $this->tblpX);
- return $this;
- }
- /**
- * Get relative vertical alignment from anchor
- *
- * @return string
- */
- public function getTblpYSpec()
- {
- return $this->tblpYSpec;
- }
- /**
- * Set relative vertical alignment from anchor
- *
- * @param string $value
- * @return self
- */
- public function setTblpYSpec($value = null)
- {
- $enum = array(
- self::YALIGN_INLINE,
- self::YALIGN_TOP,
- self::YALIGN_CENTER,
- self::YALIGN_BOTTOM,
- self::YALIGN_INSIDE,
- self::YALIGN_OUTSIDE,
- );
- $this->tblpYSpec = $this->setEnumVal($value, $enum, $this->tblpYSpec);
- return $this;
- }
- /**
- * Get absolute vertical distance from anchor
- *
- * @return int
- */
- public function getTblpY()
- {
- return $this->tblpY;
- }
- /**
- * Set absolute vertical distance from anchor
- *
- * @param int $value
- * @return self
- */
- public function setTblpY($value = null)
- {
- $this->tblpY = $this->setNumericVal($value, $this->tblpY);
- return $this;
- }
- }
|