Ejemplo n.º 1
0
 /**
  * Read Shape Drawing
  *
  * @param \DOMElement $oNodeFrame
  */
 protected function loadShapeDrawing(\DOMElement $oNodeFrame)
 {
     // Core
     $oShape = new Gd();
     $oShape->getShadow()->setVisible(false);
     $oNodeImage = $this->oXMLReader->getElement('draw:image', $oNodeFrame);
     if ($oNodeImage) {
         if ($oNodeImage->hasAttribute('xlink:href')) {
             $sFilename = $oNodeImage->getAttribute('xlink:href');
             // svm = StarView Metafile
             if (pathinfo($sFilename, PATHINFO_EXTENSION) == 'svm') {
                 return;
             }
             $imageFile = $this->oZip->getFromName($sFilename);
             if (!empty($imageFile)) {
                 $oShape->setImageResource(imagecreatefromstring($imageFile));
             }
         }
     }
     $oShape->setName($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
     $oShape->setDescription($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
     $oShape->setResizeProportional(false);
     $oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:width'), 0, -2))) : '');
     $oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:height'), 0, -2))) : '');
     $oShape->setResizeProportional(true);
     $oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:x'), 0, -2))) : '');
     $oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:y'), 0, -2))) : '');
     if ($oNodeFrame->hasAttribute('draw:style-name')) {
         $keyStyle = $oNodeFrame->getAttribute('draw:style-name');
         if (isset($this->arrayStyles[$keyStyle])) {
             $oShape->setShadow($this->arrayStyles[$keyStyle]['shadow']);
         }
     }
     $this->oPhpPresentation->getActiveSlide()->addShape($oShape);
 }
Ejemplo n.º 2
0
 /**
  *
  * @param XMLReader $document
  * @param \DOMElement $node
  * @param AbstractSlide $oSlide
  */
 protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide)
 {
     // Core
     $oShape = new Gd();
     $oShape->getShadow()->setVisible(false);
     // Variables
     $fileRels = $oSlide->getRelsIndex();
     $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')]['Target'])) {
             $pathImage = 'ppt/slides/' . $this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target'];
             $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);
             }
         }
     }
     $oSlide->addShape($oShape);
 }