123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- <?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.
- *
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2014 PHPWord contributors
- * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
- */
-
- namespace PhpOffice\PhpWord\Style;
-
- /**
- * Frame defines the size and position of an object
- *
- * Width, height, left/hpos, top/vpos, hrel, vrel, wrap, zindex
- *
- * @since 0.12.0
- * @todo Make existing style (image, textbox, etc) use this style
- */
- class Frame extends AbstractStyle
- {
- /**
- * Length unit
- *
- * @const string
- */
- const UNIT_PT = 'pt'; // Mostly for shapes
- const UNIT_PX = 'px'; // Mostly for images
-
- /**
- * General positioning options.
- *
- * @const string
- */
- const POS_ABSOLUTE = 'absolute';
- const POS_RELATIVE = 'relative';
-
- /**
- * Horizontal/vertical value
- *
- * @const string
- */
- const POS_CENTER = 'center';
- const POS_LEFT = 'left';
- const POS_RIGHT = 'right';
- const POS_TOP = 'top';
- const POS_BOTTOM = 'bottom';
- const POS_INSIDE = 'inside';
- const POS_OUTSIDE = 'outside';
-
- /**
- * Position relative to
- *
- * @const string
- */
- const POS_RELTO_MARGIN = 'margin';
- const POS_RELTO_PAGE = 'page';
- const POS_RELTO_COLUMN = 'column'; // horizontal only
- const POS_RELTO_CHAR = 'char'; // horizontal only
- const POS_RELTO_TEXT = 'text'; // vertical only
- const POS_RELTO_LINE = 'line'; // vertical only
- const POS_RELTO_LMARGIN = 'left-margin-area'; // horizontal only
- const POS_RELTO_RMARGIN = 'right-margin-area'; // horizontal only
- const POS_RELTO_TMARGIN = 'top-margin-area'; // vertical only
- const POS_RELTO_BMARGIN = 'bottom-margin-area'; // vertical only
- const POS_RELTO_IMARGIN = 'inner-margin-area';
- const POS_RELTO_OMARGIN = 'outer-margin-area';
-
- /**
- * Wrap type
- *
- * @const string
- */
- const WRAP_INLINE = 'inline';
- const WRAP_SQUARE = 'square';
- const WRAP_TIGHT = 'tight';
- const WRAP_THROUGH = 'through';
- const WRAP_TOPBOTTOM = 'topAndBottom';
- const WRAP_BEHIND = 'behind';
- const WRAP_INFRONT = 'infront';
-
- /**
- * Alignment
- *
- * @var \PhpOffice\PhpWord\Style\Alignment
- */
- private $alignment;
-
- /**
- * Unit
- *
- * @var string
- */
- private $unit = 'pt';
-
- /**
- * Width
- *
- * @var int|float
- */
- private $width;
-
- /**
- * Height
- *
- * @var int|float
- */
- private $height;
-
- /**
- * Leftmost (horizontal) position
- *
- * @var int|float
- */
- private $left = 0;
-
- /**
- * Topmost (vertical) position
- *
- * @var int|float
- */
- private $top = 0;
-
- /**
- * Position type: absolute|relative
- *
- * @var string
- */
- private $pos;
-
- /**
- * Horizontal position
- *
- * @var string
- */
- private $hPos;
-
- /**
- * Horizontal position relative to
- *
- * @var string
- */
- private $hPosRelTo;
-
- /**
- * Vertical position
- *
- * @var string
- */
- private $vPos;
-
- /**
- * Vertical position relative to
- *
- * @var string
- */
- private $vPosRelTo;
-
- /**
- * Wrap type
- *
- * @var string
- */
- private $wrap;
-
- /**
- * Create a new instance
- *
- * @param array $style
- */
- public function __construct($style = array())
- {
- $this->alignment = new Alignment();
- $this->setStyleByArray($style);
- }
-
- /**
- * Get alignment
- *
- * @return string
- */
- public function getAlign()
- {
- return $this->alignment->getValue();
- }
-
- /**
- * Set alignment
- *
- * @param string $value
- * @return self
- */
- public function setAlign($value = null)
- {
- $this->alignment->setValue($value);
-
- return $this;
- }
-
- /**
- * Get unit
- *
- * @return string
- */
- public function getUnit()
- {
- return $this->unit;
- }
-
- /**
- * Set unit
- *
- * @param string $value
- * @return self
- */
- public function setUnit($value)
- {
- $this->unit = $value;
-
- return $this;
- }
-
- /**
- * Get width
- *
- * @return int|float
- */
- public function getWidth()
- {
- return $this->width;
- }
-
- /**
- * Set width
- *
- * @param int|float $value
- * @return self
- */
- public function setWidth($value = null)
- {
- $this->width = $this->setNumericVal($value, null);
-
- return $this;
- }
-
- /**
- * Get height
- *
- * @return int|float
- */
- public function getHeight()
- {
- return $this->height;
- }
-
- /**
- * Set height
- *
- * @param int|float $value
- * @return self
- */
- public function setHeight($value = null)
- {
- $this->height = $this->setNumericVal($value, null);
-
- return $this;
- }
-
- /**
- * Get left
- *
- * @return int|float
- */
- public function getLeft()
- {
- return $this->left;
- }
-
- /**
- * Set left
- *
- * @param int|float $value
- * @return self
- */
- public function setLeft($value = 0)
- {
- $this->left = $this->setNumericVal($value, 0);
-
- return $this;
- }
-
- /**
- * Get topmost position
- *
- * @return int|float
- */
- public function getTop()
- {
- return $this->top;
- }
-
- /**
- * Set topmost position
- *
- * @param int|float $value
- * @return self
- */
- public function setTop($value = 0)
- {
- $this->top = $this->setNumericVal($value, 0);
-
- return $this;
- }
-
- /**
- * Get position type
- *
- * @return string
- */
- public function getPos()
- {
- return $this->pos;
- }
-
- /**
- * Set position type
- *
- * @param string $value
- * @return self
- */
- public function setPos($value)
- {
- $enum = array(
- self::POS_ABSOLUTE,
- self::POS_RELATIVE,
- );
- $this->pos = $this->setEnumVal($value, $enum, $this->pos);
-
- return $this;
- }
-
- /**
- * Get horizontal position
- *
- * @return string
- */
- public function getHPos()
- {
- return $this->hPos;
- }
-
- /**
- * Set horizontal position
- *
- * @since 0.12.0 "absolute" option is available.
- *
- * @param string $value
- * @return self
- */
- public function setHPos($value)
- {
- $enum = array(
- self::POS_ABSOLUTE,
- self::POS_LEFT,
- self::POS_CENTER,
- self::POS_RIGHT,
- self::POS_INSIDE,
- self::POS_OUTSIDE,
- );
- $this->hPos = $this->setEnumVal($value, $enum, $this->hPos);
-
- return $this;
- }
-
- /**
- * Get vertical position
- *
- * @return string
- */
- public function getVPos()
- {
- return $this->vPos;
- }
-
- /**
- * Set vertical position
- *
- * @since 0.12.0 "absolute" option is available.
- *
- * @param string $value
- * @return self
- */
- public function setVPos($value)
- {
- $enum = array(
- self::POS_ABSOLUTE,
- self::POS_TOP,
- self::POS_CENTER,
- self::POS_BOTTOM,
- self::POS_INSIDE,
- self::POS_OUTSIDE,
- );
- $this->vPos = $this->setEnumVal($value, $enum, $this->vPos);
-
- return $this;
- }
-
- /**
- * Get horizontal position relative to
- *
- * @return string
- */
- public function getHPosRelTo()
- {
- return $this->hPosRelTo;
- }
-
- /**
- * Set horizontal position relative to
- *
- * @param string $value
- * @return self
- */
- public function setHPosRelTo($value)
- {
- $enum = array(
- self::POS_RELTO_MARGIN,
- self::POS_RELTO_PAGE,
- self::POS_RELTO_COLUMN,
- self::POS_RELTO_CHAR,
- self::POS_RELTO_LMARGIN,
- self::POS_RELTO_RMARGIN,
- self::POS_RELTO_IMARGIN,
- self::POS_RELTO_OMARGIN,
- );
- $this->hPosRelTo = $this->setEnumVal($value, $enum, $this->hPosRelTo);
-
- return $this;
- }
-
- /**
- * Get vertical position relative to
- *
- * @return string
- */
- public function getVPosRelTo()
- {
- return $this->vPosRelTo;
- }
-
- /**
- * Set vertical position relative to
- *
- * @param string $value
- * @return self
- */
- public function setVPosRelTo($value)
- {
- $enum = array(
- self::POS_RELTO_MARGIN,
- self::POS_RELTO_PAGE,
- self::POS_RELTO_TEXT,
- self::POS_RELTO_LINE,
- self::POS_RELTO_TMARGIN,
- self::POS_RELTO_BMARGIN,
- self::POS_RELTO_IMARGIN,
- self::POS_RELTO_OMARGIN,
- );
- $this->vPosRelTo = $this->setEnumVal($value, $enum, $this->vPosRelTo);
-
- return $this;
- }
-
- /**
- * Get wrap type
- *
- * @return string
- */
- public function getWrap()
- {
- return $this->wrap;
- }
-
- /**
- * Set wrap type
- *
- * @param string $value
- * @return self
- */
- public function setWrap($value)
- {
- $enum = array(
- self::WRAP_INLINE,
- self::WRAP_SQUARE,
- self::WRAP_TIGHT,
- self::WRAP_THROUGH,
- self::WRAP_TOPBOTTOM,
- self::WRAP_BEHIND,
- self::WRAP_INFRONT,
- );
- $this->wrap = $this->setEnumVal($value, $enum, $this->wrap);
-
- return $this;
- }
- }
|