예제 #1
0
 /**
  * tests setBorders
  */
 public function testSetBorders()
 {
     $borderFormat = new PHPRtfLite_Border_Format(1.5, '#ff0', PHPRtfLite_Border_Format::TYPE_SINGLE);
     $this->_border->setBorders($borderFormat);
     $this->assertType('PHPRtfLite_Border_Format', $this->_border->getBorderTop());
     $this->assertType('PHPRtfLite_Border_Format', $this->_border->getBorderBottom());
     $this->assertType('PHPRtfLite_Border_Format', $this->_border->getBorderRight());
     $this->assertType('PHPRtfLite_Border_Format', $this->_border->getBorderLeft());
 }
예제 #2
0
 /**
  * Sets border to a cell
  *
  * @param PHPRtfLite_Border $border
  */
 public function setBorder(PHPRtfLite_Border $border)
 {
     $borderFormatTop = $border->getBorderTop();
     $borderFormatBottom = $border->getBorderBottom();
     $borderFormatLeft = $border->getBorderLeft();
     $borderFormatRight = $border->getBorderRight();
     if (!$this->_border) {
         $this->_border = new PHPRtfLite_Border();
     }
     if ($borderFormatLeft) {
         $this->_border->setBorderLeft($borderFormatLeft);
     }
     if ($borderFormatRight) {
         $this->_border->setBorderRight($borderFormatRight);
     }
     if ($borderFormatTop) {
         $this->_border->setBorderTop($borderFormatTop);
     }
     if ($borderFormatBottom) {
         $this->_border->setBorderBottom($borderFormatBottom);
     }
     if ($borderFormatTop && $this->_table->checkIfCellExists($this->_rowIndex - 1, $this->_columnIndex)) {
         $cell = $this->_table->getCell($this->_rowIndex - 1, $this->_columnIndex);
         $borderBottom = $cell->getBorder();
         if ($borderBottom == null) {
             $borderBottom = new PHPRtfLite_Border();
         }
         $borderBottom->setBorderBottom($borderFormatTop);
         $cell->setCellBorder($borderBottom);
     }
     if ($borderFormatBottom && $this->_table->checkIfCellExists($this->_rowIndex + 1, $this->_columnIndex)) {
         $cell = $this->_table->getCell($this->_rowIndex + 1, $this->_columnIndex);
         $borderTop = $cell->getBorder();
         if ($borderTop == null) {
             $borderTop = new PHPRtfLite_Border();
         }
         $borderTop->setBorderTop($borderFormatBottom);
         $cell->setCellBorder($borderTop);
     }
     if ($borderFormatLeft && $this->_table->checkIfCellExists($this->_rowIndex, $this->_columnIndex - 1)) {
         $cell = $this->_table->getCell($this->_rowIndex, $this->_columnIndex - 1);
         $borderRight = $cell->getBorder();
         if ($borderRight == null) {
             $borderRight = new PHPRtfLite_Border();
         }
         $borderRight->setBorderRight($borderFormatLeft);
         $cell->setCellBorder($borderRight);
     }
     if ($borderFormatRight && $this->_table->checkIfCellExists($this->_rowIndex, $this->_columnIndex + 1)) {
         $cell = $this->_table->getCell($this->_rowIndex, $this->_columnIndex + 1);
         $borderLeft = $cell->getBorder();
         if ($borderLeft == null) {
             $borderLeft = new PHPRtfLite_Border();
         }
         $borderLeft->setBorderLeft($borderFormatRight);
         $cell->setCellBorder($borderLeft);
     }
 }