コード例 #1
0
ファイル: Slide.php プロジェクト: presclark/PHPPowerPoint
 /**
  * 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();
 }
コード例 #2
0
ファイル: Content.php プロジェクト: nandadotexe/PHPPowerPoint
 /**
  * Write table Chart
  * @param XMLWriter $objWriter
  * @param Chart $shape
  */
 public function writeShapeChart(XMLWriter $objWriter, Chart $shape)
 {
     $parentWriter = $this->getParentWriter();
     if (!$parentWriter instanceof ODPresentation) {
         throw new \Exception('The $parentWriter is not an instance of \\PhpOffice\\PhpPowerpoint\\Writer\\ODPresentation');
     }
     $parentWriter->chartArray[$this->shapeId] = $shape;
     // draw:frame
     $objWriter->startElement('draw:frame');
     $objWriter->writeAttribute('draw:name', $shape->getTitle()->getText());
     $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('svg:height', String::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm');
     $objWriter->writeAttribute('svg:width', String::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm');
     // draw:object
     $objWriter->startElement('draw:object');
     $objWriter->writeAttribute('xlink:href', './Object ' . $this->shapeId);
     $objWriter->writeAttribute('xlink:type', 'simple');
     $objWriter->writeAttribute('xlink:show', 'embed');
     // > draw:object
     $objWriter->endElement();
     // > draw:frame
     $objWriter->endElement();
 }
コード例 #3
0
ファイル: Content.php プロジェクト: presclark/PHPPowerPoint
 /**
  * Write table Chart
  * @param XMLWriter $objWriter
  * @param Chart $shape
  * @param integer $shapeId
  */
 public function writeShapeChart(XMLWriter $objWriter, Chart $shape, $shapeId)
 {
     $this->getParentWriter()->chartArray[$shapeId] = $shape;
     // draw:frame
     $objWriter->startElement('draw:frame');
     $objWriter->writeAttribute('draw:name', $shape->getTitle()->getText());
     $objWriter->writeAttribute('svg:x', String::numberFormat(SharedDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm');
     $objWriter->writeAttribute('svg:y', String::numberFormat(SharedDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm');
     $objWriter->writeAttribute('svg:height', String::numberFormat(SharedDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm');
     $objWriter->writeAttribute('svg:width', String::numberFormat(SharedDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm');
     // draw:object
     $objWriter->startElement('draw:object');
     $objWriter->writeAttribute('xlink:href', './Object ' . $shapeId);
     $objWriter->writeAttribute('xlink:type', 'simple');
     $objWriter->writeAttribute('xlink:show', 'embed');
     // > draw:object
     $objWriter->endElement();
     // > draw:frame
     $objWriter->endElement();
 }