getOffsetY() public method

Get Y Offset
public getOffsetY ( ) : integer
return integer
Example #1
0
 /**
  * Write group
  *
  * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer
  * @param \PhpOffice\PhpPresentation\Shape\Group $group
  * @param  int $shapeId
  */
 private function writeShapeGroup(XMLWriter $objWriter, Group $group, &$shapeId)
 {
     // p:grpSp
     $objWriter->startElement('p:grpSp');
     // p:nvGrpSpPr
     $objWriter->startElement('p:nvGrpSpPr');
     // p:cNvPr
     $objWriter->startElement('p:cNvPr');
     $objWriter->writeAttribute('name', 'Group ' . $shapeId++);
     $objWriter->writeAttribute('id', $shapeId);
     $objWriter->endElement();
     // p:cNvPr
     // NOTE: Re: $shapeId This seems to be how PowerPoint 2010 does business.
     // p:cNvGrpSpPr
     $objWriter->writeElement('p:cNvGrpSpPr', null);
     // p:nvPr
     $objWriter->writeElement('p:nvPr', null);
     $objWriter->endElement();
     // p:nvGrpSpPr
     // p:grpSpPr
     $objWriter->startElement('p:grpSpPr');
     // a:xfrm
     $objWriter->startElement('a:xfrm');
     // a:off
     $objWriter->startElement('a:off');
     $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($group->getOffsetX()));
     $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($group->getOffsetY()));
     $objWriter->endElement();
     // a:off
     // a:ext
     $objWriter->startElement('a:ext');
     $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($group->getExtentX()));
     $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($group->getExtentY()));
     $objWriter->endElement();
     // a:ext
     // a:chOff
     $objWriter->startElement('a:chOff');
     $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($group->getOffsetX()));
     $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($group->getOffsetY()));
     $objWriter->endElement();
     // a:chOff
     // a:chExt
     $objWriter->startElement('a:chExt');
     $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($group->getExtentX()));
     $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($group->getExtentY()));
     $objWriter->endElement();
     // a:chExt
     $objWriter->endElement();
     // a:xfrm
     $objWriter->endElement();
     // p:grpSpPr
     $shapes = $group->getShapeCollection();
     foreach ($shapes as $shape) {
         // Increment $shapeId
         ++$shapeId;
         // Check type
         if ($shape instanceof RichText) {
             $this->writeShapeText($objWriter, $shape, $shapeId);
         } elseif ($shape instanceof ShapeTable) {
             $this->writeShapeTable($objWriter, $shape, $shapeId);
         } elseif ($shape instanceof Line) {
             $this->writeShapeLine($objWriter, $shape, $shapeId);
         } elseif ($shape instanceof ShapeChart) {
             $this->writeShapeChart($objWriter, $shape, $shapeId);
         } elseif ($shape instanceof AbstractDrawing) {
             $this->writeShapePic($objWriter, $shape, $shapeId);
         } elseif ($shape instanceof Group) {
             $this->writeShapeGroup($objWriter, $shape, $shapeId);
         }
     }
     $objWriter->endElement();
     // p:grpSp
 }
Example #2
0
 public function testExtentsAndOffsetsForTwoShapes()
 {
     // Since Groups and Slides cache offsets and extents on first
     // calculation, this test is separate from the above.
     // Should the calculation be performed every GET, this test can be
     // combined with the above.
     $offsetX = 100;
     $offsetY = 100;
     $extentX = 1000;
     $extentY = 450;
     $increase = 50;
     $line1 = new Line($offsetX, $offsetY, $extentX, $extentY);
     $line2 = new Line($offsetX + $increase, $offsetY + $increase, $extentX + $increase, $extentY + $increase);
     $object = new Group();
     $object->addShape($line1);
     $object->addShape($line2);
     $this->assertEquals($offsetX, $object->getOffsetX());
     $this->assertEquals($offsetY, $object->getOffsetY());
     $this->assertEquals($extentX + $increase, $object->getExtentX());
     $this->assertEquals($extentY + $increase, $object->getExtentY());
 }
 /**
  * Write group
  *
  * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer
  * @param \PhpOffice\PhpPresentation\Shape\Group $group
  * @param  int $shapeId
  */
 protected function writeShapeGroup(XMLWriter $objWriter, Group $group, &$shapeId)
 {
     // p:grpSp
     $objWriter->startElement('p:grpSp');
     // p:nvGrpSpPr
     $objWriter->startElement('p:nvGrpSpPr');
     // p:cNvPr
     $objWriter->startElement('p:cNvPr');
     $objWriter->writeAttribute('name', 'Group ' . $shapeId++);
     $objWriter->writeAttribute('id', $shapeId);
     $objWriter->endElement();
     // p:cNvPr
     // NOTE: Re: $shapeId This seems to be how PowerPoint 2010 does business.
     // p:cNvGrpSpPr
     $objWriter->writeElement('p:cNvGrpSpPr', null);
     // p:nvPr
     $objWriter->writeElement('p:nvPr', null);
     $objWriter->endElement();
     // p:nvGrpSpPr
     // p:grpSpPr
     $objWriter->startElement('p:grpSpPr');
     // a:xfrm
     $objWriter->startElement('a:xfrm');
     // a:off
     $objWriter->startElement('a:off');
     $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($group->getOffsetX()));
     $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($group->getOffsetY()));
     $objWriter->endElement();
     // a:off
     // a:ext
     $objWriter->startElement('a:ext');
     $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($group->getExtentX()));
     $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($group->getExtentY()));
     $objWriter->endElement();
     // a:ext
     // a:chOff
     $objWriter->startElement('a:chOff');
     $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($group->getOffsetX()));
     $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($group->getOffsetY()));
     $objWriter->endElement();
     // a:chOff
     // a:chExt
     $objWriter->startElement('a:chExt');
     $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($group->getExtentX()));
     $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($group->getExtentY()));
     $objWriter->endElement();
     // a:chExt
     $objWriter->endElement();
     // a:xfrm
     $objWriter->endElement();
     // p:grpSpPr
     $this->writeShapeCollection($objWriter, $group->getShapeCollection(), $shapeId);
     $objWriter->endElement();
     // p:grpSp
 }