public function testCommentsAuthors() { $oAuthor = new Comment\Author(); $oComment = new Comment(); $oComment->setAuthor($oAuthor); $oPhpPresentation = new PhpPresentation(); $oPhpPresentation->getActiveSlide()->addShape($oComment); $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007'); $this->assertTrue($pres->elementExists('/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"]', 'ppt/_rels/presentation.xml.rels')); }
public function testComments() { $expectedElement = '/p:cmLst/p:cm'; $oAuthor = new Comment\Author(); $oComment = new Comment(); $oComment->setAuthor($oAuthor); $this->oPresentation->getActiveSlide()->addShape($oComment); $pres = TestHelperDOCX::getDocument($this->oPresentation, 'PowerPoint2007'); $this->assertTrue($pres->fileExists('ppt/comments/comment1.xml')); $this->assertTrue($pres->elementExists($expectedElement, 'ppt/comments/comment1.xml')); $this->assertEquals(0, $pres->getElementAttribute($expectedElement, 'authorId', 'ppt/comments/comment1.xml')); }
public function testWithSameAuthor() { $expectedElement = '/p:cmAuthorLst/p:cmAuthor'; $oAuthor = new Comment\Author(); $oComment1 = new Comment(); $oComment1->setAuthor($oAuthor); $this->oPresentation->getActiveSlide()->addShape($oComment1); $oComment2 = new Comment(); $oComment2->setAuthor($oAuthor); $this->oPresentation->getActiveSlide()->addShape($oComment2); $pres = TestHelperDOCX::getDocument($this->oPresentation, 'PowerPoint2007'); $this->assertTrue($pres->fileExists('ppt/commentAuthors.xml')); $this->assertTrue($pres->fileExists('ppt/commentAuthors.xml')); $this->assertTrue($pres->elementExists($expectedElement, 'ppt/commentAuthors.xml')); $this->assertEquals(1, $pres->elementCount($expectedElement, 'ppt/commentAuthors.xml')); }
public function testGetSetHeightAndWidtg() { $object = new Comment(); $this->assertNull($object->getHeight()); $this->assertNull($object->getWidth()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment', $object->setHeight(1)); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment', $object->setWidth(1)); $this->assertNull($object->getHeight()); $this->assertNull($object->getWidth()); }
public function testComment() { $expectedName = 'Name'; $expectedText = 'Text'; $oAuthor = new Comment\Author(); $oAuthor->setName($expectedName); $oComment = new Comment(); $oComment->setAuthor($oAuthor); $oComment->setText($expectedText); $this->oPresentation->getActiveSlide()->addShape($oComment); $pres = TestHelperDOCX::getDocument($this->oPresentation, 'ODPresentation'); $element = '/office:document-content'; $this->assertTrue($pres->elementExists($element, 'content.xml')); $this->assertTrue($pres->attributeElementExists($element, 'xmlns:officeooo', 'content.xml')); $element = '/office:document-content/office:body/office:presentation/draw:page/officeooo:annotation'; $this->assertTrue($pres->elementExists($element, 'content.xml')); $element = '/office:document-content/office:body/office:presentation/draw:page/officeooo:annotation/dc:creator'; $this->assertTrue($pres->elementExists($element, 'content.xml')); $this->assertEquals($expectedName, $pres->getElement($element, 'content.xml')->nodeValue); $element = '/office:document-content/office:body/office:presentation/draw:page/officeooo:annotation/text:p'; $this->assertTrue($pres->elementExists($element, 'content.xml')); $this->assertEquals($expectedText, $pres->getElement($element, 'content.xml')->nodeValue); }
/** * Write Comment * @param XMLWriter $objWriter * @param Comment $oShape */ public function writeShapeComment(XMLWriter $objWriter, Comment $oShape) { // officeooo:annotation $objWriter->startElement('officeooo:annotation'); $objWriter->writeAttribute('svg:x', number_format(CommonDrawing::pixelsToCentimeters($oShape->getOffsetX()), 2, '.', '') . 'cm'); $objWriter->writeAttribute('svg:y', number_format(CommonDrawing::pixelsToCentimeters($oShape->getOffsetY()), 2, '.', '') . 'cm'); if ($oShape->getAuthor() instanceof Comment\Author) { $objWriter->writeElement('dc:creator', $oShape->getAuthor()->getName()); } $objWriter->writeElement('dc:date', date('Y-m-d\\TH:i:s', $oShape->getDate())); $objWriter->writeElement('text:p', $oShape->getText()); // ## officeooo:annotation $objWriter->endElement(); }