when adding image to relationship list check that the generated relationship id is actually unique
This commit is contained in:
parent
ab7d82274e
commit
94b74c27a4
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
|
@ -17,14 +18,14 @@
|
|||
|
||||
namespace PhpOffice\PhpWord;
|
||||
|
||||
use PhpOffice\PhpWord\Escaper\RegExp;
|
||||
use PhpOffice\PhpWord\Escaper\Xml;
|
||||
use PhpOffice\PhpWord\Exception\CopyFileException;
|
||||
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\Shared\Text;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Shared\ZipArchive;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Shared\Text;
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
|
||||
use PhpOffice\PhpWord\Exception\CopyFileException;
|
||||
use PhpOffice\PhpWord\Escaper\Xml;
|
||||
use PhpOffice\PhpWord\Escaper\RegExp;
|
||||
|
||||
class TemplateProcessor
|
||||
{
|
||||
|
|
@ -747,8 +748,10 @@ class TemplateProcessor
|
|||
|
||||
// If tmpXmlRow doesn't contain continue, this row is no longer part of the spanned row.
|
||||
$tmpXmlRow = $this->getSlice($extraRowStart, $extraRowEnd);
|
||||
if (!preg_match('#<w:vMerge/>#', $tmpXmlRow) &&
|
||||
!preg_match('#<w:vMerge w:val="continue"\s*/>#', $tmpXmlRow)) {
|
||||
if (
|
||||
!preg_match('#<w:vMerge/>#', $tmpXmlRow) &&
|
||||
!preg_match('#<w:vMerge w:val="continue"\s*/>#', $tmpXmlRow)
|
||||
) {
|
||||
break;
|
||||
}
|
||||
// This row was a spanned row, update $rowEnd and search for the next row.
|
||||
|
|
@ -1067,7 +1070,11 @@ class TemplateProcessor
|
|||
protected function getNextRelationsIndex($documentPartName)
|
||||
{
|
||||
if (isset($this->tempDocumentRelations[$documentPartName])) {
|
||||
return substr_count($this->tempDocumentRelations[$documentPartName], '<Relationship');
|
||||
$candidate = substr_count($this->tempDocumentRelations[$documentPartName], '<Relationship');
|
||||
while (strpos($this->tempDocumentRelations[$documentPartName], 'Id="rId' . $candidate . '"') !== false) {
|
||||
$candidate++;
|
||||
}
|
||||
return $candidate;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue