Skip to content

Commit 3a7dd77

Browse files
committed
Add support for mc:AlternateContent
1 parent ec1b3d3 commit 3a7dd77

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ phpword.ini
2121
/.project
2222
/nbproject
2323
/.php_cs.cache
24+
docker-compose.yml
25+
/phpdocker
26+
/public

src/PhpWord/Reader/Word2007/AbstractPart.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,19 @@ protected function readRunChild(XMLReader $xmlReader, \DOMElement $node, Abstrac
292292
$parent->addTextBreak();
293293
} elseif ($node->nodeName == 'w:tab') {
294294
$parent->addText("\t");
295+
} elseif ($node->nodeName == 'mc:AlternateContent') {
296+
$hasChildren = $node->childNodes->length > 0;
297+
298+
if ($hasChildren) {
299+
$origin = $node->childNodes->item($node->childNodes->length - 1);
300+
301+
if ($origin->nodeValue) {
302+
// TextRun
303+
$textContent = htmlspecialchars($origin->nodeValue, ENT_QUOTES, 'UTF-8');
304+
305+
$parent->addText($textContent, $fontStyle, $paragraphStyle);
306+
}
307+
}
295308
} elseif ($node->nodeName == 'w:t' || $node->nodeName == 'w:delText') {
296309
// TextRun
297310
$textContent = htmlspecialchars($xmlReader->getValue('.', $node), ENT_QUOTES, 'UTF-8');

0 commit comments

Comments
 (0)