Example #1
0
 /**
  * Write margin.
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param \PhpOffice\PhpWord\Style\Table $style
  * @return void
  */
 private function writeMargin(XMLWriter $xmlWriter, TableStyle $style)
 {
     if ($style->hasMargin()) {
         $xmlWriter->startElement('w:tblCellMar');
         $styleWriter = new MarginBorder($xmlWriter);
         $styleWriter->setSizes($style->getCellMargin());
         $styleWriter->write();
         $xmlWriter->endElement();
         // w:tblCellMar
     }
 }
Example #2
0
 /**
  * Test cell margin
  *
  * Set cell margin and test if each part has the same margin
  * While looping, push values array to be asserted with getCellMargin
  * Value is in twips
  */
 public function testCellMargin()
 {
     $object = new Table();
     $parts = array('Top', 'Left', 'Right', 'Bottom');
     $value = 240;
     $object->setCellMargin($value);
     foreach ($parts as $part) {
         $get = "getCellMargin{$part}";
         $values[] = $value;
         $this->assertEquals($value, $object->{$get}());
     }
     $this->assertEquals($values, $object->getCellMargin());
     $this->assertTrue($object->hasMargin());
 }