|
1 | 1 | <?php
|
| 2 | + |
2 | 3 | /**
|
3 | 4 | * This file is part of PHPWord - A pure PHP library for reading and writing
|
4 | 5 | * word processing documents.
|
|
17 | 18 |
|
18 | 19 | namespace PhpOffice\PhpWord;
|
19 | 20 |
|
20 |
| -use PhpOffice\PhpWord\Escaper\RegExp; |
21 |
| -use PhpOffice\PhpWord\Escaper\Xml; |
22 |
| -use PhpOffice\PhpWord\Exception\CopyFileException; |
23 |
| -use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; |
24 |
| -use PhpOffice\PhpWord\Exception\Exception; |
25 |
| -use PhpOffice\PhpWord\Shared\Text; |
26 |
| -use PhpOffice\PhpWord\Shared\XMLWriter; |
27 | 21 | use PhpOffice\PhpWord\Shared\ZipArchive;
|
| 22 | +use PhpOffice\PhpWord\Shared\XMLWriter; |
| 23 | +use PhpOffice\PhpWord\Shared\Text; |
| 24 | +use PhpOffice\PhpWord\Exception\Exception; |
| 25 | +use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; |
| 26 | +use PhpOffice\PhpWord\Exception\CopyFileException; |
| 27 | +use PhpOffice\PhpWord\Escaper\Xml; |
| 28 | +use PhpOffice\PhpWord\Escaper\RegExp; |
28 | 29 |
|
29 | 30 | class TemplateProcessor
|
30 | 31 | {
|
@@ -620,8 +621,8 @@ public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEM
|
620 | 621 |
|
621 | 622 | // collect document parts
|
622 | 623 | $searchParts = array(
|
623 |
| - $this->getMainPartName() => &$this->tempDocumentMainPart, |
624 |
| - ); |
| 624 | + $this->getMainPartName() => &$this->tempDocumentMainPart, |
| 625 | + ); |
625 | 626 | foreach (array_keys($this->tempDocumentHeaders) as $headerIndex) {
|
626 | 627 | $searchParts[$this->getHeaderName($headerIndex)] = &$this->tempDocumentHeaders[$headerIndex];
|
627 | 628 | }
|
@@ -661,7 +662,7 @@ public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEM
|
661 | 662 | if (preg_match('/(<[^<]+>)([^<]*)(' . preg_quote($varNameWithArgsFixed) . ')([^>]*)(<[^>]+>)/Uu', $partContent, $matches)) {
|
662 | 663 | $wholeTag = $matches[0];
|
663 | 664 | array_shift($matches);
|
664 |
| - list($openTag, $prefix, , $postfix, $closeTag) = $matches; |
| 665 | + list($openTag, $prefix,, $postfix, $closeTag) = $matches; |
665 | 666 | $replaceXml = $openTag . $prefix . $closeTag . $xmlImage . $openTag . $postfix . $closeTag;
|
666 | 667 | // replace on each iteration, because in one tag we can have 2+ inline variables => before proceed next variable we need to change $partContent
|
667 | 668 | $partContent = $this->setValueForPart($wholeTag, $replaceXml, $partContent, $limit);
|
@@ -747,8 +748,10 @@ public function cloneRow($search, $numberOfClones)
|
747 | 748 |
|
748 | 749 | // If tmpXmlRow doesn't contain continue, this row is no longer part of the spanned row.
|
749 | 750 | $tmpXmlRow = $this->getSlice($extraRowStart, $extraRowEnd);
|
750 |
| - if (!preg_match('#<w:vMerge/>#', $tmpXmlRow) && |
751 |
| - !preg_match('#<w:vMerge w:val="continue"\s*/>#', $tmpXmlRow)) { |
| 751 | + if ( |
| 752 | + !preg_match('#<w:vMerge/>#', $tmpXmlRow) && |
| 753 | + !preg_match('#<w:vMerge w:val="continue"\s*/>#', $tmpXmlRow) |
| 754 | + ) { |
752 | 755 | break;
|
753 | 756 | }
|
754 | 757 | // This row was a spanned row, update $rowEnd and search for the next row.
|
@@ -1067,7 +1070,11 @@ protected function getRelationsName($documentPartName)
|
1067 | 1070 | protected function getNextRelationsIndex($documentPartName)
|
1068 | 1071 | {
|
1069 | 1072 | if (isset($this->tempDocumentRelations[$documentPartName])) {
|
1070 |
| - return substr_count($this->tempDocumentRelations[$documentPartName], '<Relationship'); |
| 1073 | + $candidate = substr_count($this->tempDocumentRelations[$documentPartName], '<Relationship'); |
| 1074 | + while (strpos($this->tempDocumentRelations[$documentPartName], 'Id="rId' . $candidate . '"') !== false) { |
| 1075 | + $candidate++; |
| 1076 | + } |
| 1077 | + return $candidate; |
1071 | 1078 | }
|
1072 | 1079 |
|
1073 | 1080 | return 1;
|
|
0 commit comments