Get fallback value instead of taking the last element

This commit is contained in:
Sven Ahrens 2020-09-02 12:12:48 +02:00
parent 63d1ffceb8
commit 58e0200fbd
1 changed files with 6 additions and 6 deletions

View File

@ -293,14 +293,14 @@ abstract class AbstractPart
} elseif ($node->nodeName == 'w:tab') { } elseif ($node->nodeName == 'w:tab') {
$parent->addText("\t"); $parent->addText("\t");
} elseif ($node->nodeName == 'mc:AlternateContent') { } elseif ($node->nodeName == 'mc:AlternateContent') {
$hasChildren = $node->childNodes->length > 0; if ($node->hasChildNodes()) {
// Get fallback instead of mc:Choice to make sure it is compatible
if ($hasChildren) { $fallbackElements = $node->getElementsByTagName('Fallback');
$origin = $node->childNodes->item($node->childNodes->length - 1);
if ($origin->nodeValue) { if ($fallbackElements->length) {
$fallback = $fallbackElements->item(0);
// TextRun // TextRun
$textContent = htmlspecialchars($origin->nodeValue, ENT_QUOTES, 'UTF-8'); $textContent = htmlspecialchars($fallback->nodeValue, ENT_QUOTES, 'UTF-8');
$parent->addText($textContent, $fontStyle, $paragraphStyle); $parent->addText($textContent, $fontStyle, $paragraphStyle);
} }