/** * Create a new Style * * @param boolean $isSupervisor */ public function __construct($isSupervisor = false) { // Supervisor? $this->_isSupervisor = $isSupervisor; // Initialise values $this->_conditionalStyles = array(); $this->_font = new Style_Font($isSupervisor); $this->_fill = new Style_Fill($isSupervisor); $this->_borders = new Style_Borders($isSupervisor); $this->_alignment = new Style_Alignment($isSupervisor); $this->_numberFormat = new Style_NumberFormat($isSupervisor); $this->_protection = new Style_Protection($isSupervisor); // bind parent if we are a supervisor if ($isSupervisor) { $this->_font->bindParent($this); $this->_fill->bindParent($this); $this->_borders->bindParent($this); $this->_alignment->bindParent($this); $this->_numberFormat->bindParent($this); $this->_protection->bindParent($this); } }
/** * Build style array from subcomponents * * @param array $array * @return array */ public function getStyleArray($array) { switch ($this->_parentPropertyName) { case '_allBorders': $key = 'allborders'; break; case '_bottom': $key = 'bottom'; break; case '_diagonal': $key = 'diagonal'; break; case '_horizontal': $key = 'horizontal'; break; case '_inside': $key = 'inside'; break; case '_left': $key = 'left'; break; case '_outline': $key = 'outline'; break; case '_right': $key = 'right'; break; case '_top': $key = 'top'; break; case '_vertical': $key = 'vertical'; break; } return $this->_parent->getStyleArray(array($key => $array)); }
/** * Write Border * * @param Shared_XMLWriter $objWriter XML Writer * @param Style_Borders $pBorders Borders style * @throws Exception */ private function _writeBorder(Shared_XMLWriter $objWriter = null, Style_Borders $pBorders = null) { // Write border $objWriter->startElement('border'); // Diagonal? switch ($pBorders->getDiagonalDirection()) { case Style_Borders::DIAGONAL_UP: $objWriter->writeAttribute('diagonalUp', 'true'); $objWriter->writeAttribute('diagonalDown', 'false'); break; case Style_Borders::DIAGONAL_DOWN: $objWriter->writeAttribute('diagonalUp', 'false'); $objWriter->writeAttribute('diagonalDown', 'true'); break; case Style_Borders::DIAGONAL_BOTH: $objWriter->writeAttribute('diagonalUp', 'true'); $objWriter->writeAttribute('diagonalDown', 'true'); break; } // BorderPr $this->_writeBorderPr($objWriter, 'left', $pBorders->getLeft()); $this->_writeBorderPr($objWriter, 'right', $pBorders->getRight()); $this->_writeBorderPr($objWriter, 'top', $pBorders->getTop()); $this->_writeBorderPr($objWriter, 'bottom', $pBorders->getBottom()); $this->_writeBorderPr($objWriter, 'diagonal', $pBorders->getDiagonal()); $objWriter->endElement(); }
/** * Create CSS style (Style_Borders) * * @param Style_Borders $pStyle Style_Borders * @return array */ private function _createCSSStyleBorders(Style_Borders $pStyle) { // Construct CSS $css = array(); // Create CSS $css['border-bottom'] = $this->_createCSSStyleBorder($pStyle->getBottom()); $css['border-top'] = $this->_createCSSStyleBorder($pStyle->getTop()); $css['border-left'] = $this->_createCSSStyleBorder($pStyle->getLeft()); $css['border-right'] = $this->_createCSSStyleBorder($pStyle->getRight()); // Return return $css; }