示例#1
0
 /**
  * Write chart
  *
  * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer
  * @param \PhpOffice\PhpPresentation\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', CommonDrawing::degreesToAngle($shape->getRotation()));
     // a:off
     $objWriter->startElement('a:off');
     $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX()));
     $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY()));
     $objWriter->endElement();
     // a:ext
     $objWriter->startElement('a:ext');
     $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($shape->getWidth()));
     $objWriter->writeAttribute('cy', CommonDrawing::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();
 }