示例#1
0
 /**
  * Write picture
  *
  * @param \PhpOffice\Common\XMLWriter $objWriter
  * @param \PhpOffice\PhpPowerpoint\Shape\AbstractDrawing $shape
  */
 public function writeShapePic(XMLWriter $objWriter, AbstractDrawing $shape)
 {
     // draw:frame
     $objWriter->startElement('draw:frame');
     $objWriter->writeAttribute('draw:name', $shape->getName());
     $objWriter->writeAttribute('svg:width', String::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm');
     $objWriter->writeAttribute('svg:height', String::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm');
     $objWriter->writeAttribute('svg:x', String::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm');
     $objWriter->writeAttribute('svg:y', String::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm');
     $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId);
     // draw:image
     $objWriter->startElement('draw:image');
     if ($shape instanceof ShapeDrawing) {
         $objWriter->writeAttribute('xlink:href', 'Pictures/' . md5($shape->getPath()) . '.' . $shape->getExtension());
     } elseif ($shape instanceof MemoryDrawing) {
         $objWriter->writeAttribute('xlink:href', 'Pictures/' . $shape->getIndexedFilename());
     }
     $objWriter->writeAttribute('xlink:type', 'simple');
     $objWriter->writeAttribute('xlink:show', 'embed');
     $objWriter->writeAttribute('xlink:actuate', 'onLoad');
     $objWriter->writeElement('text:p');
     $objWriter->endElement();
     if ($shape->hasHyperlink()) {
         // office:event-listeners
         $objWriter->startElement('office:event-listeners');
         // presentation:event-listener
         $objWriter->startElement('presentation:event-listener');
         $objWriter->writeAttribute('script:event-name', 'dom:click');
         $objWriter->writeAttribute('presentation:action', 'show');
         $objWriter->writeAttribute('xlink:href', $shape->getHyperlink()->getUrl());
         $objWriter->writeAttribute('xlink:type', 'simple');
         $objWriter->writeAttribute('xlink:show', 'embed');
         $objWriter->writeAttribute('xlink:actuate', 'onRequest');
         // > presentation:event-listener
         $objWriter->endElement();
         // > office:event-listeners
         $objWriter->endElement();
     }
     $objWriter->endElement();
 }