/** * Test get/set color */ public function testSetGetColor() { $object = new Border(); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setColor()); $this->assertNull($object->getColor()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setColor(new Color(COLOR::COLOR_BLUE))); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor()); $this->assertEquals('FF0000FF', $object->getColor()->getARGB()); }
/** * Write Border * * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpPresentation\Style\Border $pBorder Border * @param string $pElementName Element name * @throws \Exception */ protected function writeBorder(XMLWriter $objWriter, $pBorder, $pElementName = 'L') { if (!$pBorder instanceof Border) { return; } if ($pBorder->getLineStyle() == Border::LINE_NONE && $pElementName == '') { return; } // Line style $lineStyle = $pBorder->getLineStyle(); if ($lineStyle == Border::LINE_NONE) { $lineStyle = Border::LINE_SINGLE; } // Line width $lineWidth = 12700 * $pBorder->getLineWidth(); // a:ln $pElementName $objWriter->startElement('a:ln' . $pElementName); $objWriter->writeAttribute('w', $lineWidth); $objWriter->writeAttribute('cap', 'flat'); $objWriter->writeAttribute('cmpd', $lineStyle); $objWriter->writeAttribute('algn', 'ctr'); // Fill? if ($pBorder->getLineStyle() == Border::LINE_NONE) { // a:noFill $objWriter->writeElement('a:noFill', null); } else { // a:solidFill $objWriter->startElement('a:solidFill'); $this->writeColor($objWriter, $pBorder->getColor()); $objWriter->endElement(); } // Dash $objWriter->startElement('a:prstDash'); $objWriter->writeAttribute('val', $pBorder->getDashStyle()); $objWriter->endElement(); // a:round $objWriter->writeElement('a:round', null); // a:headEnd $objWriter->startElement('a:headEnd'); $objWriter->writeAttribute('type', 'none'); $objWriter->writeAttribute('w', 'med'); $objWriter->writeAttribute('len', 'med'); $objWriter->endElement(); // a:tailEnd $objWriter->startElement('a:tailEnd'); $objWriter->writeAttribute('type', 'none'); $objWriter->writeAttribute('w', 'med'); $objWriter->writeAttribute('len', 'med'); $objWriter->endElement(); $objWriter->endElement(); }