/** * Write txt * * @param \PhpOffice\PhpPowerpoint\Shared\XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpPowerpoint\Shape\RichText $shape * @param int $shapeId * @throws \Exception */ private function writeShapeText(XMLWriter $objWriter, RichText $shape, $shapeId) { // p:sp $objWriter->startElement('p:sp'); // p:nvSpPr $objWriter->startElement('p:nvSpPr'); // p:cNvPr $objWriter->startElement('p:cNvPr'); $objWriter->writeAttribute('id', $shapeId); $objWriter->writeAttribute('name', ''); $objWriter->endElement(); // p:cNvSpPr $objWriter->startElement('p:cNvSpPr'); $objWriter->writeAttribute('txBox', '1'); $objWriter->endElement(); // p:nvPr $objWriter->writeElement('p:nvPr', null); $objWriter->endElement(); // p:spPr $objWriter->startElement('p:spPr'); // a:xfrm $objWriter->startElement('a: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:prstGeom $objWriter->startElement('a:prstGeom'); $objWriter->writeAttribute('prst', 'rect'); $objWriter->endElement(); $objWriter->endElement(); // p:txBody $objWriter->startElement('p:txBody'); // a:bodyPr $objWriter->startElement('a:bodyPr'); $objWriter->writeAttribute('anchor', $shape->getActiveParagraph()->getAlignment()->getVertical()); $objWriter->writeAttribute('wrap', $shape->getWrap()); $objWriter->writeAttribute('rtlCol', '0'); $objWriter->writeAttribute('horzOverflow', $shape->getHorizontalOverflow()); $objWriter->writeAttribute('vertOverflow', $shape->getVerticalOverflow()); if ($shape->isUpright()) { $objWriter->writeAttribute('upright', '1'); } if ($shape->isVertical()) { $objWriter->writeAttribute('vert', 'vert'); } $objWriter->writeAttribute('bIns', SharedDrawing::pixelsToEmu($shape->getInsetBottom())); $objWriter->writeAttribute('lIns', SharedDrawing::pixelsToEmu($shape->getInsetLeft())); $objWriter->writeAttribute('rIns', SharedDrawing::pixelsToEmu($shape->getInsetRight())); $objWriter->writeAttribute('tIns', SharedDrawing::pixelsToEmu($shape->getInsetTop())); $objWriter->writeAttribute('numCol', $shape->getColumns()); // a:spAutoFit $objWriter->writeElement('a:' . $shape->getAutoFit(), null); $objWriter->endElement(); // a:lstStyle $objWriter->writeElement('a:lstStyle', null); // Write paragraphs $this->writeParagraphs($objWriter, $shape->getParagraphs()); $objWriter->endElement(); $objWriter->endElement(); }
public function testGetSetInset() { $object = new RichText(); // Default $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setInsetBottom()); $this->assertEquals(4.8, $object->getInsetBottom()); $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setInsetLeft()); $this->assertEquals(9.6, $object->getInsetLeft()); $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setInsetRight()); $this->assertEquals(9.6, $object->getInsetRight()); $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setInsetTop()); $this->assertEquals(4.8, $object->getInsetTop()); // Value $value = rand(1, 100); $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setInsetBottom($value)); $this->assertEquals($value, $object->getInsetBottom()); $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setInsetLeft($value)); $this->assertEquals($value, $object->getInsetLeft()); $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setInsetRight($value)); $this->assertEquals($value, $object->getInsetRight()); $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setInsetTop($value)); $this->assertEquals($value, $object->getInsetTop()); }