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\Section;
|
2013-12-11 14:45:44 -05:00
|
|
|
|
2014-03-24 00:26:10 +07:00
|
|
|
/**
|
|
|
|
|
* Object element
|
|
|
|
|
*/
|
2014-03-22 10:06:08 +04:00
|
|
|
class Object
|
|
|
|
|
{
|
2013-12-11 14:45:44 -05:00
|
|
|
/**
|
|
|
|
|
* Ole-Object Src
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
private $_src;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Image Style
|
|
|
|
|
*
|
2014-03-23 10:32:08 +04:00
|
|
|
* @var \PhpOffice\PhpWord\Style\Image
|
2013-12-11 14:45:44 -05:00
|
|
|
*/
|
|
|
|
|
private $_style;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Object Relation ID
|
|
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
|
|
|
|
private $_rId;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Image Relation ID
|
|
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
|
|
|
|
private $_rIdImg;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Object ID
|
|
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
|
|
|
|
private $_objId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new Ole-Object Element
|
|
|
|
|
*
|
|
|
|
|
* @param string $src
|
|
|
|
|
* @param mixed $style
|
|
|
|
|
*/
|
|
|
|
|
public function __construct($src, $style = null)
|
|
|
|
|
{
|
2014-03-28 13:50:53 +07:00
|
|
|
$_supportedObjectTypes = array('xls', 'doc', 'ppt', 'xlsx', 'docx', 'pptx');
|
2013-12-11 14:45:44 -05:00
|
|
|
$inf = pathinfo($src);
|
|
|
|
|
|
2014-03-24 00:26:10 +07:00
|
|
|
if (\file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
|
2013-12-11 14:45:44 -05:00
|
|
|
$this->_src = $src;
|
2014-03-23 17:37:26 +07:00
|
|
|
$this->_style = new \PhpOffice\PhpWord\Style\Image();
|
2013-12-11 14:45:44 -05:00
|
|
|
|
|
|
|
|
if (!is_null($style) && is_array($style)) {
|
|
|
|
|
foreach ($style as $key => $value) {
|
|
|
|
|
if (substr($key, 0, 1) != '_') {
|
|
|
|
|
$key = '_' . $key;
|
|
|
|
|
}
|
|
|
|
|
$this->_style->setStyleValue($key, $value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Image style
|
|
|
|
|
*
|
2014-03-23 10:32:08 +04:00
|
|
|
* @return \PhpOffice\PhpWord\Style\Image
|
2013-12-11 14:45:44 -05:00
|
|
|
*/
|
|
|
|
|
public function getStyle()
|
|
|
|
|
{
|
|
|
|
|
return $this->_style;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Source
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getSource()
|
|
|
|
|
{
|
|
|
|
|
return $this->_src;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Object Relation ID
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getRelationId()
|
|
|
|
|
{
|
|
|
|
|
return $this->_rId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set Object Relation ID
|
|
|
|
|
*
|
|
|
|
|
* @param int $rId
|
|
|
|
|
*/
|
|
|
|
|
public function setRelationId($rId)
|
|
|
|
|
{
|
|
|
|
|
$this->_rId = $rId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Image Relation ID
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getImageRelationId()
|
|
|
|
|
{
|
|
|
|
|
return $this->_rIdImg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set Image Relation ID
|
|
|
|
|
*
|
|
|
|
|
* @param int $rId
|
|
|
|
|
*/
|
|
|
|
|
public function setImageRelationId($rId)
|
|
|
|
|
{
|
|
|
|
|
$this->_rIdImg = $rId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Object ID
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getObjectId()
|
|
|
|
|
{
|
|
|
|
|
return $this->_objId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set Object ID
|
|
|
|
|
*
|
|
|
|
|
* @param int $objId
|
|
|
|
|
*/
|
|
|
|
|
public function setObjectId($objId)
|
|
|
|
|
{
|
|
|
|
|
$this->_objId = $objId;
|
|
|
|
|
}
|
2012-05-06 18:25:40 +02:00
|
|
|
}
|