Add support for mc:AlternateContent

This commit is contained in:
Sven Ahrens 2020-09-01 18:13:25 +02:00
parent ec1b3d35ee
commit 3a7dd774a2
2 changed files with 16 additions and 0 deletions

3
.gitignore vendored
View File

@ -21,3 +21,6 @@ phpword.ini
/.project
/nbproject
/.php_cs.cache
docker-compose.yml
/phpdocker
/public

View File

@ -292,6 +292,19 @@ abstract class AbstractPart
$parent->addTextBreak();
} elseif ($node->nodeName == 'w:tab') {
$parent->addText("\t");
} elseif ($node->nodeName == 'mc:AlternateContent') {
$hasChildren = $node->childNodes->length > 0;
if ($hasChildren) {
$origin = $node->childNodes->item($node->childNodes->length - 1);
if ($origin->nodeValue) {
// TextRun
$textContent = htmlspecialchars($origin->nodeValue, ENT_QUOTES, 'UTF-8');
$parent->addText($textContent, $fontStyle, $paragraphStyle);
}
}
} elseif ($node->nodeName == 'w:t' || $node->nodeName == 'w:delText') {
// TextRun
$textContent = htmlspecialchars($xmlReader->getValue('.', $node), ENT_QUOTES, 'UTF-8');