getBorder() public method

public getBorder ( ) : Box\Spout\Writer\Style\Border
return Box\Spout\Writer\Style\Border
Exemplo n.º 1
0
 /**
  * Returns the contents of the borders definition for the "<style:table-cell-properties>" section
  *
  * @param \Box\Spout\Writer\Style\Style $style
  * @return string
  */
 private function getBorderXMLContent($style)
 {
     $borderProperty = '<style:table-cell-properties %s />';
     $borders = array_map(function (BorderPart $borderPart) {
         return BorderHelper::serializeBorderPart($borderPart);
     }, $style->getBorder()->getParts());
     return sprintf($borderProperty, implode(' ', $borders));
 }
Exemplo n.º 2
0
 /**
  * Returns the contents of the "<style:style>" section, inside "<office:automatic-styles>" section
  *
  * @param \Box\Spout\Writer\Style\Style $style
  * @return string
  */
 protected function getStyleSectionContent($style)
 {
     $defaultStyle = $this->getDefaultStyle();
     $styleIndex = $style->getId() + 1;
     // 1-based
     $content = '<style:style style:data-style-name="N0" style:family="table-cell" style:name="ce' . $styleIndex . '" style:parent-style-name="Default">';
     if ($style->shouldApplyFont()) {
         $content .= '<style:text-properties';
         $fontColor = $style->getFontColor();
         if ($fontColor !== $defaultStyle->getFontColor()) {
             $content .= ' fo:color="#' . $fontColor . '"';
         }
         $fontName = $style->getFontName();
         if ($fontName !== $defaultStyle->getFontName()) {
             $content .= ' style:font-name="' . $fontName . '" style:font-name-asian="' . $fontName . '" style:font-name-complex="' . $fontName . '"';
         }
         $fontSize = $style->getFontSize();
         if ($fontSize !== $defaultStyle->getFontSize()) {
             $content .= ' fo:font-size="' . $fontSize . 'pt" style:font-size-asian="' . $fontSize . 'pt" style:font-size-complex="' . $fontSize . 'pt"';
         }
         if ($style->isFontBold()) {
             $content .= ' fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"';
         }
         if ($style->isFontItalic()) {
             $content .= ' fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"';
         }
         if ($style->isFontUnderline()) {
             $content .= ' style:text-underline-style="solid" style:text-underline-type="single"';
         }
         if ($style->isFontStrikethrough()) {
             $content .= ' style:text-line-through-style="solid"';
         }
         $content .= '/>';
     }
     if ($style->shouldWrapText()) {
         $content .= '<style:table-cell-properties fo:wrap-option="wrap" style:vertical-align="automatic"/>';
     }
     if ($style->shouldApplyBorder()) {
         $borderProperty = '<style:table-cell-properties %s />';
         $borders = array_map(function (BorderPart $borderPart) {
             return BorderHelper::serializeBorderPart($borderPart);
         }, $style->getBorder()->getParts());
         $content .= sprintf($borderProperty, implode(' ', $borders));
     }
     if ($style->shouldApplyBackgroundColor()) {
         $content .= sprintf('
             <style:table-cell-properties fo:background-color="#%s"/>', $style->getBackgroundColor());
     }
     $content .= '</style:style>';
     return $content;
 }
Exemplo n.º 3
0
 /**
  * Register a border definition
  *
  * @param \Box\Spout\Writer\Style\Style $style
  */
 protected function registerBorder($style)
 {
     $styleId = $style->getId();
     if ($style->shouldApplyBorder()) {
         $border = $style->getBorder();
         $serializedBorder = serialize($border);
         $isBorderAlreadyRegistered = isset($this->registeredBorders[$serializedBorder]);
         if ($isBorderAlreadyRegistered) {
             $registeredStyleId = $this->registeredBorders[$serializedBorder];
             $registeredBorderId = $this->styleIdToBorderMappingTable[$registeredStyleId];
             $this->styleIdToBorderMappingTable[$styleId] = $registeredBorderId;
         } else {
             $this->registeredBorders[$serializedBorder] = $styleId;
             $this->styleIdToBorderMappingTable[$styleId] = count($this->registeredBorders);
         }
     } else {
         // If no border should be applied - the mapping is the default border: 0
         $this->styleIdToBorderMappingTable[$styleId] = 0;
     }
 }