From cd2dba084891b3525db82a0663517cb942d4577e Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 8 Apr 2014 03:27:19 +0700 Subject: [PATCH] Element inheritance refinements --- src/PhpWord/Element/AbstractElement.php | 2 -- src/PhpWord/Element/Image.php | 27 ------------------------- src/PhpWord/Element/Link.php | 27 ------------------------- src/PhpWord/Element/Object.php | 27 ------------------------- src/PhpWord/Reader/AbstractReader.php | 5 ++++- src/PhpWord/Template.php | 17 +++++----------- src/PhpWord/Writer/ODText.php | 1 - src/PhpWord/Writer/ODText/Manifest.php | 1 - 8 files changed, 9 insertions(+), 98 deletions(-) diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index eabb1963..d9f9984d 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -9,7 +9,6 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Exception\InvalidImageException; use PhpOffice\PhpWord\Exception\InvalidObjectException; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Style; @@ -482,7 +481,6 @@ abstract class AbstractElement 'table' => array('section', 'header', 'footer'), 'footnote' => array('section', 'textrun', 'cell'), 'preservetext' => array('header', 'footer', 'cell'), - 'relationid' => array('header', 'footer', 'footnote'), 'title' => array('section'), ); // Special condition, e.g. preservetext can only exists in cell when diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index bf29220b..d49972d2 100755 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -32,13 +32,6 @@ class Image extends AbstractElement */ private $style; - /** - * Image relation ID specific only for DOCX - * - * @var string - */ - private $rId; - /** * Is watermark * @@ -155,26 +148,6 @@ class Image extends AbstractElement 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 * diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index 96c66339..1cf35624 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -31,13 +31,6 @@ class Link extends AbstractElement */ private $name; - /** - * Link Relation ID - * - * @var string - */ - private $relationId; - /** * Font style * @@ -71,26 +64,6 @@ class Link extends AbstractElement 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 * diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index f6b4161b..058117c9 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -30,13 +30,6 @@ class Object extends AbstractElement */ private $style; - /** - * Object Relation ID - * - * @var int - */ - private $relationId; - /** * Image Relation ID * @@ -84,26 +77,6 @@ class Object extends AbstractElement 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 * diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php index 10c864f3..cf43a858 100644 --- a/src/PhpWord/Reader/AbstractReader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -90,7 +90,10 @@ abstract class AbstractReader implements ReaderInterface } catch (Exception $e) { return false; } - fclose($this->fileHandle); + if (is_resource($this->fileHandle)) { + fclose($this->fileHandle); + } + return true; } } diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index 30c2ee08..b0be592d 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -222,7 +222,7 @@ class Template * @param string $blockname * @param integer $clones * @param boolean $replace - * @return null + * @return string|null */ public function cloneBlock($blockname, $clones = 1, $replace = true) { @@ -263,7 +263,6 @@ class Template * Delete a block of text * * @param string $blockname - * @param string $replacement */ public function deleteBlock($blockname) { @@ -317,7 +316,7 @@ class Template * * @param string $documentPartXML * @param string $search - * @param mixed $replace + * @param string $replace * @param integer $limit * @return string */ @@ -335,16 +334,10 @@ class Template $search = '${' . $search . '}'; } - if (!is_array($replace)) { - if (!String::isUTF8($replace)) { - $replace = utf8_encode($replace); - } - $replace = htmlspecialchars($replace); - } else { - foreach ($replace as $key => $value) { - $replace[$key] = htmlspecialchars($value); - } + if (!String::isUTF8($replace)) { + $replace = utf8_encode($replace); } + $replace = htmlspecialchars($replace); $regExpDelim = '/'; $escapedSearch = preg_quote($search, $regExpDelim); diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php index e3b82f4d..4a4b1cbb 100755 --- a/src/PhpWord/Writer/ODText.php +++ b/src/PhpWord/Writer/ODText.php @@ -11,7 +11,6 @@ namespace PhpOffice\PhpWord\Writer; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Writer\ODText\Content; use PhpOffice\PhpWord\Writer\ODText\Manifest; use PhpOffice\PhpWord\Writer\ODText\Meta; diff --git a/src/PhpWord/Writer/ODText/Manifest.php b/src/PhpWord/Writer/ODText/Manifest.php index 106ddfc5..b82a6041 100755 --- a/src/PhpWord/Writer/ODText/Manifest.php +++ b/src/PhpWord/Writer/ODText/Manifest.php @@ -9,7 +9,6 @@ namespace PhpOffice\PhpWord\Writer\ODText; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; /**