Exemplo n.º 1
0
 /**
  * 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();
 }
Exemplo n.º 2
0
 public function testGetSetVertical()
 {
     $object = new RichText();
     $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setVertical());
     $this->assertFalse($object->isVertical());
     $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setVertical(true));
     $this->assertTrue($object->isVertical());
     $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setVertical(false));
     $this->assertFalse($object->isVertical());
 }