/** * * @param XMLReader $document * @param \DOMElement $node * @param string $baseFile */ protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, $baseFile) { // Core $oShape = new MemoryDrawing(); $oShape->getShadow()->setVisible(false); // Variables $fileRels = 'ppt/slides/_rels/' . $baseFile . '.rels'; $oElement = $document->getElement('p:nvPicPr/p:cNvPr', $node); if ($oElement) { $oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : ''); $oShape->setDescription($oElement->hasAttribute('descr') ? $oElement->getAttribute('descr') : ''); } $oElement = $document->getElement('p:blipFill/a:blip', $node); if ($oElement) { if ($oElement->hasAttribute('r:embed') && isset($this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')])) { $pathImage = 'ppt/slides/' . $this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]; $pathImage = explode('/', $pathImage); foreach ($pathImage as $key => $partPath) { if ($partPath == '..') { unset($pathImage[$key - 1]); unset($pathImage[$key]); } } $pathImage = implode('/', $pathImage); $imageFile = $this->oZip->getFromName($pathImage); if (!empty($imageFile)) { $oShape->setImageResource(imagecreatefromstring($imageFile)); } } } $oElement = $document->getElement('p:spPr/a:xfrm', $node); if ($oElement) { if ($oElement->hasAttribute('rot')) { $oShape->setRotation(CommonDrawing::angleToDegrees($oElement->getAttribute('rot'))); } } $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node); if ($oElement) { if ($oElement->hasAttribute('x')) { $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x'))); } if ($oElement->hasAttribute('y')) { $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y'))); } } $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node); if ($oElement) { if ($oElement->hasAttribute('cx')) { $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx'))); } if ($oElement->hasAttribute('cy')) { $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy'))); } } $oElement = $document->getElement('p:spPr/a:effectLst', $node); if ($oElement) { $oShape->getShadow()->setVisible(true); $oSubElement = $document->getElement('a:outerShdw', $oElement); if ($oSubElement) { if ($oSubElement->hasAttribute('blurRad')) { $oShape->getShadow()->setBlurRadius(CommonDrawing::emuToPixels($oSubElement->getAttribute('blurRad'))); } if ($oSubElement->hasAttribute('dist')) { $oShape->getShadow()->setDistance(CommonDrawing::emuToPixels($oSubElement->getAttribute('dist'))); } if ($oSubElement->hasAttribute('dir')) { $oShape->getShadow()->setDirection(CommonDrawing::angleToDegrees($oSubElement->getAttribute('dir'))); } if ($oSubElement->hasAttribute('algn')) { $oShape->getShadow()->setAlignment($oSubElement->getAttribute('algn')); } } $oSubElement = $document->getElement('a:outerShdw/a:srgbClr', $oElement); if ($oSubElement) { if ($oSubElement->hasAttribute('val')) { $oColor = new Color(); $oColor->setRGB($oSubElement->getAttribute('val')); $oShape->getShadow()->setColor($oColor); } } $oSubElement = $document->getElement('a:outerShdw/a:srgbClr/a:alpha', $oElement); if ($oSubElement) { if ($oSubElement->hasAttribute('val')) { $oShape->getShadow()->setAlpha((int) $oSubElement->getAttribute('val') / 1000); } } } $this->oPhpPresentation->getActiveSlide()->addShape($oShape); }