getDomFromZip($this->docFile, $this->xmlFile); $docSettings = $phpWord->getSettings(); $nodes = $xmlReader->getElements('*'); if ($nodes->length > 0) { foreach ($nodes as $node) { $name = str_replace('w:', '', $node->nodeName); $value = $xmlReader->getAttribute('w:val', $node); $method = 'set' . $name; if (in_array($name, $this::$booleanProperties)) { if ($value == 'false') { $docSettings->$method(false); } else { $docSettings->$method(true); } } else if (method_exists($this, $method)) { $this->$method($xmlReader, $phpWord, $node); } else if (method_exists($docSettings, $method)) { $docSettings->$method($value); } } } } /** * Sets the document protection * * @param XMLReader $xmlReader * @param PhpWord $phpWord * @param \DOMNode $node */ protected function setDocumentProtection(XMLReader $xmlReader, PhpWord $phpWord, \DOMNode $node) { $documentProtection = $phpWord->getSettings()->getDocumentProtection(); $edit = $xmlReader->getAttribute('w:edit', $node); $documentProtection->setEditing($edit); } /** * Sets the proof state * * @param XMLReader $xmlReader * @param PhpWord $phpWord * @param \DOMNode $node */ protected function setProofState(XMLReader $xmlReader, PhpWord $phpWord, \DOMNode $node) { $proofState = $phpWord->getSettings()->getProofState(); $spelling = $xmlReader->getAttribute('w:spelling', $node); $grammar = $xmlReader->getAttribute('w:grammar', $node); if ($spelling != null) { $proofState->setSpelling($spelling); } if ($grammar != null) { $proofState->setGrammar($grammar); } } /** * Sets the proof state * * @param XMLReader $xmlReader * @param PhpWord $phpWord * @param \DOMNode $node */ protected function setZoom(XMLReader $xmlReader, PhpWord $phpWord, \DOMNode $node) { $percent = $xmlReader->getAttribute('w:percent', $node); $val = $xmlReader->getAttribute('w:val', $node); if ($percent != null || $val != null) { $phpWord->getSettings()->setZoom($percent == null ? $val : $percent); } } /** * Set the Revision view * * @param XMLReader $xmlReader * @param PhpWord $phpWord * @param \DOMNode $node */ protected function setRevisionView(XMLReader $xmlReader, PhpWord $phpWord, \DOMNode $node) { $revisionView = new TrackChangesView(); $revisionView->setMarkup($xmlReader->getAttribute('w:markup', $node)); $revisionView->setComments($xmlReader->getAttribute('w:comments', $node)); $revisionView->setInsDel($xmlReader->getAttribute('w:insDel', $node)); $revisionView->setFormatting($xmlReader->getAttribute('w:formatting', $node)); $revisionView->setInkAnnotations($xmlReader->getAttribute('w:inkAnnotations', $node)); $phpWord->getSettings()->setRevisionView($revisionView); } }