Element inheritance refinements

This commit is contained in:
Ivan Lanin 2014-04-08 03:27:19 +07:00
parent 3ef0f41c25
commit cd2dba0848
8 changed files with 9 additions and 98 deletions

View File

@ -9,7 +9,6 @@
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Exception\InvalidImageException;
use PhpOffice\PhpWord\Exception\InvalidObjectException; use PhpOffice\PhpWord\Exception\InvalidObjectException;
use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
@ -482,7 +481,6 @@ abstract class AbstractElement
'table' => array('section', 'header', 'footer'), 'table' => array('section', 'header', 'footer'),
'footnote' => array('section', 'textrun', 'cell'), 'footnote' => array('section', 'textrun', 'cell'),
'preservetext' => array('header', 'footer', 'cell'), 'preservetext' => array('header', 'footer', 'cell'),
'relationid' => array('header', 'footer', 'footnote'),
'title' => array('section'), 'title' => array('section'),
); );
// Special condition, e.g. preservetext can only exists in cell when // Special condition, e.g. preservetext can only exists in cell when

View File

@ -32,13 +32,6 @@ class Image extends AbstractElement
*/ */
private $style; private $style;
/**
* Image relation ID specific only for DOCX
*
* @var string
*/
private $rId;
/** /**
* Is watermark * Is watermark
* *
@ -155,26 +148,6 @@ class Image extends AbstractElement
return $this->style; return $this->style;
} }
/**
* Get image relation ID
*
* @return int
*/
public function getRelationId()
{
return $this->rId;
}
/**
* Set image relation ID
*
* @param int $rId
*/
public function setRelationId($rId)
{
$this->rId = $rId;
}
/** /**
* Get image source * Get image source
* *

View File

@ -31,13 +31,6 @@ class Link extends AbstractElement
*/ */
private $name; private $name;
/**
* Link Relation ID
*
* @var string
*/
private $relationId;
/** /**
* Font style * Font style
* *
@ -71,26 +64,6 @@ class Link extends AbstractElement
return $this; return $this;
} }
/**
* Get Link Relation ID
*
* @return int
*/
public function getRelationId()
{
return $this->relationId;
}
/**
* Set Link Relation ID
*
* @param int $rId
*/
public function setRelationId($rId)
{
$this->relationId = $rId;
}
/** /**
* Get Link source * Get Link source
* *

View File

@ -30,13 +30,6 @@ class Object extends AbstractElement
*/ */
private $style; private $style;
/**
* Object Relation ID
*
* @var int
*/
private $relationId;
/** /**
* Image Relation ID * Image Relation ID
* *
@ -84,26 +77,6 @@ class Object extends AbstractElement
return $this->source; return $this->source;
} }
/**
* Get Object Relation ID
*
* @return int
*/
public function getRelationId()
{
return $this->relationId;
}
/**
* Set Object Relation ID
*
* @param int $rId
*/
public function setRelationId($rId)
{
$this->relationId = $rId;
}
/** /**
* Get Image Relation ID * Get Image Relation ID
* *

View File

@ -90,7 +90,10 @@ abstract class AbstractReader implements ReaderInterface
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
} }
if (is_resource($this->fileHandle)) {
fclose($this->fileHandle); fclose($this->fileHandle);
}
return true; return true;
} }
} }

View File

@ -222,7 +222,7 @@ class Template
* @param string $blockname * @param string $blockname
* @param integer $clones * @param integer $clones
* @param boolean $replace * @param boolean $replace
* @return null * @return string|null
*/ */
public function cloneBlock($blockname, $clones = 1, $replace = true) public function cloneBlock($blockname, $clones = 1, $replace = true)
{ {
@ -263,7 +263,6 @@ class Template
* Delete a block of text * Delete a block of text
* *
* @param string $blockname * @param string $blockname
* @param string $replacement
*/ */
public function deleteBlock($blockname) public function deleteBlock($blockname)
{ {
@ -317,7 +316,7 @@ class Template
* *
* @param string $documentPartXML * @param string $documentPartXML
* @param string $search * @param string $search
* @param mixed $replace * @param string $replace
* @param integer $limit * @param integer $limit
* @return string * @return string
*/ */
@ -335,16 +334,10 @@ class Template
$search = '${' . $search . '}'; $search = '${' . $search . '}';
} }
if (!is_array($replace)) {
if (!String::isUTF8($replace)) { if (!String::isUTF8($replace)) {
$replace = utf8_encode($replace); $replace = utf8_encode($replace);
} }
$replace = htmlspecialchars($replace); $replace = htmlspecialchars($replace);
} else {
foreach ($replace as $key => $value) {
$replace[$key] = htmlspecialchars($value);
}
}
$regExpDelim = '/'; $regExpDelim = '/';
$escapedSearch = preg_quote($search, $regExpDelim); $escapedSearch = preg_quote($search, $regExpDelim);

View File

@ -11,7 +11,6 @@ namespace PhpOffice\PhpWord\Writer;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Writer\ODText\Content; use PhpOffice\PhpWord\Writer\ODText\Content;
use PhpOffice\PhpWord\Writer\ODText\Manifest; use PhpOffice\PhpWord\Writer\ODText\Manifest;
use PhpOffice\PhpWord\Writer\ODText\Meta; use PhpOffice\PhpWord\Writer\ODText\Meta;

View File

@ -9,7 +9,6 @@
namespace PhpOffice\PhpWord\Writer\ODText; namespace PhpOffice\PhpWord\Writer\ODText;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
/** /**