Get fallback value instead of taking the last element
This commit is contained in:
parent
63d1ffceb8
commit
58e0200fbd
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue