Skip to content

Commit 57f330c

Browse files
committed
Handle the cases were there's no whitespace after <w:tr.
1 parent 590f08c commit 57f330c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Classes/PHPWord/Template.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,15 @@ public function getVariables()
128128
* @param mixed $offset
129129
*/
130130
private function _findRowStart($offset) {
131-
return strrpos($this->_documentXML, "<w:tr ", ((strlen($this->_documentXML) - $offset) * -1));
131+
$rowStart = strrpos($this->_documentXML, "<w:tr ", ((strlen($this->_documentXML) - $offset) * -1));
132+
if (!$rowStart) {
133+
$rowStart = strrpos($this->_documentXML, "<w:tr>", ((strlen($this->_documentXML) - $offset) * -1));
134+
}
135+
if (!$rowStart) {
136+
trigger_error("Can not find the start position of the row to clone.");
137+
return false;
138+
}
139+
return $rowStart;
132140
}
133141

134142
/**
@@ -137,7 +145,8 @@ private function _findRowStart($offset) {
137145
* @param mixed $offset
138146
*/
139147
private function _findRowEnd($offset) {
140-
return strpos($this->_documentXML, "</w:tr>", $offset) + 7;
148+
$rowEnd = strpos($this->_documentXML, "</w:tr>", $offset) + 7;
149+
return $rowEnd;
141150
}
142151

143152
/**

0 commit comments

Comments
 (0)