2012-05-06 18:25:40 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
2014-03-26 16:33:20 +07:00
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
2014-03-22 10:06:08 +04:00
|
|
|
namespace PhpOffice\PhpWord\Style;
|
|
|
|
|
|
2014-03-24 00:26:10 +07:00
|
|
|
/**
|
|
|
|
|
* Image and memory image style
|
|
|
|
|
*/
|
2014-04-08 03:03:14 +07:00
|
|
|
class Image extends AbstractStyle
|
2013-12-11 14:45:44 -05:00
|
|
|
{
|
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';
|
2013-12-11 14:45:44 -05:00
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Image width
|
|
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $width;
|
2014-03-17 07:26:25 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Image width
|
|
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $height;
|
2014-03-17 07:26:25 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Alignment
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $align;
|
2014-03-17 07:26:25 +07:00
|
|
|
|
2013-12-11 14:45:44 -05:00
|
|
|
/**
|
|
|
|
|
* Margin Top
|
|
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $marginTop;
|
2013-12-11 14:45:44 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Margin Left
|
|
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
2014-04-06 18:03:03 +07:00
|
|
|
private $marginLeft;
|
2013-12-11 14:45:44 -05:00
|
|
|
|
2014-04-08 03:03:14 +07:00
|
|
|
/**
|
|
|
|
|
* Wrapping style
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
private $wrappingStyle;
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
2014-03-24 00:26:10 +07:00
|
|
|
* Create new image style
|
2014-03-17 07:26:25 +07:00
|
|
|
*/
|
2013-12-11 14:45:44 -05:00
|
|
|
public function __construct()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$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);
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Get width
|
|
|
|
|
*/
|
2013-12-11 14:45:44 -05:00
|
|
|
public function getWidth()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->width;
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Set width
|
|
|
|
|
*
|
|
|
|
|
* @param int $pValue
|
|
|
|
|
*/
|
2013-12-11 14:45:44 -05:00
|
|
|
public function setWidth($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->width = $pValue;
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Get height
|
|
|
|
|
*/
|
2013-12-11 14:45:44 -05:00
|
|
|
public function getHeight()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->height;
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Set height
|
|
|
|
|
*
|
|
|
|
|
* @param int $pValue
|
|
|
|
|
*/
|
2013-12-11 14:45:44 -05:00
|
|
|
public function setHeight($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->height = $pValue;
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Get alignment
|
|
|
|
|
*/
|
2013-12-11 14:45:44 -05:00
|
|
|
public function getAlign()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->align;
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:26:25 +07:00
|
|
|
/**
|
|
|
|
|
* Set alignment
|
|
|
|
|
*
|
|
|
|
|
* @param string $pValue
|
|
|
|
|
*/
|
2013-12-11 14:45:44 -05:00
|
|
|
public function setAlign($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->align = $pValue;
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Margin Top
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getMarginTop()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->marginTop;
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set Margin Top
|
|
|
|
|
*
|
|
|
|
|
* @param int $pValue
|
2013-12-11 14:51:35 -05:00
|
|
|
* @return $this
|
2013-12-11 14:45:44 -05:00
|
|
|
*/
|
|
|
|
|
public function setMarginTop($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->marginTop = $pValue;
|
2013-12-11 14:45:44 -05:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Margin Left
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getMarginLeft()
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
return $this->marginLeft;
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set Margin Left
|
|
|
|
|
*
|
|
|
|
|
* @param int $pValue
|
2013-12-11 14:51:35 -05:00
|
|
|
* @return $this
|
2013-12-11 14:45:44 -05:00
|
|
|
*/
|
|
|
|
|
public function setMarginLeft($pValue = null)
|
|
|
|
|
{
|
2014-04-06 18:03:03 +07:00
|
|
|
$this->marginLeft = $pValue;
|
2013-12-11 14:45:44 -05:00
|
|
|
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
|
2014-03-23 10:32:08 +04:00
|
|
|
* @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:
|
2014-03-23 10:32:08 +04:00
|
|
|
throw new \InvalidArgumentException('Wrapping style does not exists');
|
2013-12-11 14:51:35 -05:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
2014-03-11 19:26:56 +07:00
|
|
|
}
|