PHPWord/src/PhpWord/Style/Image.php

224 lines
3.9 KiB
PHP
Raw Normal View History

2012-05-06 18:25:40 +02:00
<?php
/**
* 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
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2012-05-06 18:25:40 +02:00
*/
namespace PhpOffice\PhpWord\Style;
/**
* Image and memory image style
*/
class Image
{
2013-12-11 14:51:35 -05:00
const WRAPPING_STYLE_INLINE = 'inline';
const WRAPPING_STYLE_SQUARE = 'square';
const WRAPPING_STYLE_TIGHT = 'tight';
const WRAPPING_STYLE_BEHIND = 'behind';
const WRAPPING_STYLE_INFRONT = 'infront';
2014-03-17 07:26:25 +07:00
/**
* Image width
*
* @var int
*/
private $width;
2014-03-17 07:26:25 +07:00
/**
* Image width
*
* @var int
*/
private $height;
2014-03-17 07:26:25 +07:00
/**
* Alignment
*
* @var string
*/
private $align;
2014-03-17 07:26:25 +07:00
/**
* Wrapping style
*
* @var string
*/
2013-12-11 14:51:35 -05:00
private $wrappingStyle;
/**
* Margin Top
*
* @var int
*/
private $marginTop;
/**
* Margin Left
*
* @var int
*/
private $marginLeft;
2014-03-17 07:26:25 +07:00
/**
* Create new image style
2014-03-17 07:26:25 +07:00
*/
public function __construct()
{
$this->width = null;
$this->height = null;
$this->align = null;
$this->marginTop = null;
$this->marginLeft = null;
2013-12-11 14:51:35 -05:00
$this->setWrappingStyle(self::WRAPPING_STYLE_INLINE);
}
2014-03-17 07:26:25 +07:00
/**
* Set style value
*
* @param string $key
* @param mixed $value
*/
public function setStyleValue($key, $value)
{
if (substr($key, 0, 1) == '_') {
$key = substr($key, 1);
}
$this->$key = $value;
}
2014-03-17 07:26:25 +07:00
/**
* Get width
*/
public function getWidth()
{
return $this->width;
}
2014-03-17 07:26:25 +07:00
/**
* Set width
*
* @param int $pValue
*/
public function setWidth($pValue = null)
{
$this->width = $pValue;
}
2014-03-17 07:26:25 +07:00
/**
* Get height
*/
public function getHeight()
{
return $this->height;
}
2014-03-17 07:26:25 +07:00
/**
* Set height
*
* @param int $pValue
*/
public function setHeight($pValue = null)
{
$this->height = $pValue;
}
2014-03-17 07:26:25 +07:00
/**
* Get alignment
*/
public function getAlign()
{
return $this->align;
}
2014-03-17 07:26:25 +07:00
/**
* Set alignment
*
* @param string $pValue
*/
public function setAlign($pValue = null)
{
$this->align = $pValue;
}
/**
* Get Margin Top
*
* @return int
*/
public function getMarginTop()
{
return $this->marginTop;
}
/**
* Set Margin Top
*
* @param int $pValue
2013-12-11 14:51:35 -05:00
* @return $this
*/
public function setMarginTop($pValue = null)
{
$this->marginTop = $pValue;
return $this;
}
/**
* Get Margin Left
*
* @return int
*/
public function getMarginLeft()
{
return $this->marginLeft;
}
/**
* Set Margin Left
*
* @param int $pValue
2013-12-11 14:51:35 -05:00
* @return $this
*/
public function setMarginLeft($pValue = null)
{
$this->marginLeft = $pValue;
return $this;
}
2013-12-11 14:51:35 -05:00
/**
2014-03-17 07:26:25 +07:00
* Set wrapping style
*
2013-12-11 14:51:35 -05:00
* @param string $wrappingStyle
* @throws \InvalidArgumentException
2013-12-11 14:51:35 -05:00
* @return $this
*/
public function setWrappingStyle($wrappingStyle)
{
switch ($wrappingStyle) {
case self::WRAPPING_STYLE_BEHIND:
case self::WRAPPING_STYLE_INFRONT:
case self::WRAPPING_STYLE_INLINE:
case self::WRAPPING_STYLE_SQUARE:
case self::WRAPPING_STYLE_TIGHT:
$this->wrappingStyle = $wrappingStyle;
break;
default:
throw new \InvalidArgumentException('Wrapping style does not exists');
2013-12-11 14:51:35 -05:00
break;
}
return $this;
}
/**
2014-03-17 07:26:25 +07:00
* Get wrapping style
*
2013-12-11 14:51:35 -05:00
* @return string
*/
public function getWrappingStyle()
{
return $this->wrappingStyle;
}
}