diff --git a/Classes/PHPWord/Template.php b/Classes/PHPWord/Template.php index 28608348..4d0b3b79 100755 --- a/Classes/PHPWord/Template.php +++ b/Classes/PHPWord/Template.php @@ -128,7 +128,15 @@ class PHPWord_Template * @param mixed $offset */ private function _findRowStart($offset) { - return strrpos($this->_documentXML, "_documentXML) - $offset) * -1)); + $rowStart = strrpos($this->_documentXML, "_documentXML) - $offset) * -1)); + if (!$rowStart) { + $rowStart = strrpos($this->_documentXML, "", ((strlen($this->_documentXML) - $offset) * -1)); + } + if (!$rowStart) { + trigger_error("Can not find the start position of the row to clone."); + return false; + } + return $rowStart; } /** @@ -137,7 +145,8 @@ class PHPWord_Template * @param mixed $offset */ private function _findRowEnd($offset) { - return strpos($this->_documentXML, "", $offset) + 7; + $rowEnd = strpos($this->_documentXML, "", $offset) + 7; + return $rowEnd; } /**