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()); }
/** * The OfficeArtSpgrContainer record specifies a container for groups of shapes. * @param string $stream * @param integer $pos * @param boolean $bInGroup * @link : https://msdn.microsoft.com/en-us/library/dd910416(v=office.12).aspx */ private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = false) { $arrayReturn = array('length' => 0); $data = $this->loadRecordHeader($stream, $pos); if ($data['recVer'] == 0xf && $data['recInstance'] == 0x0 && $data['recType'] == 0xf003) { $arrayReturn['length'] += 8; do { $rhFileBlock = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']); if (!($rhFileBlock['recVer'] == 0xf && $rhFileBlock['recInstance'] == 0x0 && ($rhFileBlock['recType'] == 0xf003 || $rhFileBlock['recType'] == 0xf004))) { throw new \Exception('PowerPoint97 Reader : readRecordOfficeArtSpgrContainer.'); } switch ($rhFileBlock['recType']) { case 0xf003: // Core $this->oCurrentGroup = $this->oPhpPresentation->getActiveSlide()->createGroup(); $this->bFirstShapeGroup = false; // OfficeArtSpgrContainer $fileBlock = $this->readRecordOfficeArtSpgrContainer($stream, $pos + $arrayReturn['length'], true); $arrayReturn['length'] += $fileBlock['length']; $data['recLen'] -= $fileBlock['length']; break; case 0xf004: // Core if (!$bInGroup) { $this->oCurrentGroup = null; } // OfficeArtSpContainer $fileBlock = $this->readRecordOfficeArtSpContainer($stream, $pos + $arrayReturn['length']); $arrayReturn['length'] += $fileBlock['length']; $data['recLen'] -= $fileBlock['length']; // Core //@todo if (!is_null($fileBlock['shape'])) { if ($bInGroup) { $this->oCurrentGroup->addShape($fileBlock['shape']); } else { $this->oPhpPresentation->getActiveSlide()->addShape($fileBlock['shape']); } } break; } } while ($data['recLen'] > 0); } return $arrayReturn; }
public function testCommentInGroupRelationship() { $oPhpPresentation = new PhpPresentation(); $oSlide = $oPhpPresentation->getActiveSlide(); $oGroup = new Group(); $oGroup->addShape(new Comment()); $oSlide->addShape($oGroup); $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007'); $this->assertTrue($pres->elementExists('/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"]', 'ppt/slides/_rels/slide1.xml.rels')); }