Exemple #1
0
 /**
  * Write chart
  *
  * @param \PhpOffice\PhpPowerpoint\Shared\XMLWriter $objWriter XML Writer
  * @param \PhpOffice\PhpPowerpoint\Shape\Chart $shape
  * @param  int $shapeId
  */
 private function writeShapeChart(XMLWriter $objWriter, ShapeChart $shape, $shapeId)
 {
     // p:graphicFrame
     $objWriter->startElement('p:graphicFrame');
     // p:nvGraphicFramePr
     $objWriter->startElement('p:nvGraphicFramePr');
     // p:cNvPr
     $objWriter->startElement('p:cNvPr');
     $objWriter->writeAttribute('id', $shapeId);
     $objWriter->writeAttribute('name', $shape->getName());
     $objWriter->writeAttribute('descr', $shape->getDescription());
     $objWriter->endElement();
     // p:cNvGraphicFramePr
     $objWriter->writeElement('p:cNvGraphicFramePr', null);
     // p:nvPr
     $objWriter->writeElement('p:nvPr', null);
     $objWriter->endElement();
     // p:xfrm
     $objWriter->startElement('p:xfrm');
     $objWriter->writeAttribute('rot', SharedDrawing::degreesToAngle($shape->getRotation()));
     // a:off
     $objWriter->startElement('a:off');
     $objWriter->writeAttribute('x', SharedDrawing::pixelsToEmu($shape->getOffsetX()));
     $objWriter->writeAttribute('y', SharedDrawing::pixelsToEmu($shape->getOffsetY()));
     $objWriter->endElement();
     // a:ext
     $objWriter->startElement('a:ext');
     $objWriter->writeAttribute('cx', SharedDrawing::pixelsToEmu($shape->getWidth()));
     $objWriter->writeAttribute('cy', SharedDrawing::pixelsToEmu($shape->getHeight()));
     $objWriter->endElement();
     $objWriter->endElement();
     // a:graphic
     $objWriter->startElement('a:graphic');
     // a:graphicData
     $objWriter->startElement('a:graphicData');
     $objWriter->writeAttribute('uri', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
     // c:chart
     $objWriter->startElement('c:chart');
     $objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
     $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
     $objWriter->writeAttribute('r:id', $shape->relationId);
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
 }