diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 521c8a7f..4b7f6e0a 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -223,7 +223,7 @@ abstract class AbstractPart // $rIdIcon = $xmlReader->getAttribute('r:id', $domNode, 'w:object/v:shape/v:imagedata'); $target = $this->getMediaTarget($docPart, $rId); if (!is_null($target)) { - $textContent = ""; + $textContent = "<Object: {$target}>"; $parent->addText($textContent, $fontStyle, $paragraphStyle); } } else { @@ -477,9 +477,9 @@ abstract class AbstractPart if (self::READ_SIZE == $method) { $style = $attributeValue / 2; } elseif (self::READ_TRUE == $method) { - $style = true; + $style = $this->isOn($attributeValue); } elseif (self::READ_FALSE == $method) { - $style = false; + $style = !$this->isOn($attributeValue); } elseif (self::READ_EQUAL == $method) { $style = $attributeValue == $expected; } @@ -487,6 +487,18 @@ abstract class AbstractPart return $style; } + /** + * Parses the value of the on/off value, null is considered true as it means the w:val attribute was not present + * + * @see http://www.datypic.com/sc/ooxml/t-w_ST_OnOff.html + * @param string $value + * @return bool + */ + private function isOn($value = null) + { + return $value == null || $value == '1' || $value == 'true' || $value == 'on'; + } + /** * Returns the target of image, object, or link as stored in ::readMainRels * diff --git a/tests/PhpWord/Reader/Word2007Test.php b/tests/PhpWord/Reader/Word2007Test.php index 8b787247..9a555672 100644 --- a/tests/PhpWord/Reader/Word2007Test.php +++ b/tests/PhpWord/Reader/Word2007Test.php @@ -18,6 +18,7 @@ namespace PhpOffice\PhpWord\Reader; use PhpOffice\PhpWord\IOFactory; +use PhpOffice\PhpWord\TestHelperDOCX; /** * Test class for PhpOffice\PhpWord\Reader\Word2007 @@ -54,6 +55,13 @@ class Word2007Test extends \PHPUnit\Framework\TestCase { $filename = __DIR__ . '/../_files/documents/reader.docx'; $phpWord = IOFactory::load($filename); + $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $phpWord); + $this->assertTrue($phpWord->getSettings()->hasDoNotTrackMoves()); + $this->assertFalse($phpWord->getSettings()->hasDoNotTrackFormatting()); + $this->assertEquals(100, $phpWord->getSettings()->getZoom()); + + $doc = TestHelperDOCX::getDocument($phpWord); + $this->assertFalse($doc->elementExists('/w:document/w:body/w:p/w:r[w:t/node()="italics"]/w:rPr/w:b')); } } diff --git a/tests/PhpWord/_files/documents/reader.docx b/tests/PhpWord/_files/documents/reader.docx index ef6b6615..65c761e0 100644 Binary files a/tests/PhpWord/_files/documents/reader.docx and b/tests/PhpWord/_files/documents/reader.docx differ diff --git a/tests/PhpWord/_includes/XmlDocument.php b/tests/PhpWord/_includes/XmlDocument.php index c82c5a8e..21a12105 100644 --- a/tests/PhpWord/_includes/XmlDocument.php +++ b/tests/PhpWord/_includes/XmlDocument.php @@ -97,6 +97,7 @@ class XmlDocument if (null === $this->xpath) { $this->xpath = new \DOMXpath($this->dom); + $this->xpath->registerNamespace('w14', 'http://schemas.microsoft.com/office/word/2010/wordml'); } return $this->xpath->query($path);