getBackgroundColor() public method

public getBackgroundColor ( ) : string
return string
示例#1
0
 /**
  * Register a fill definition
  *
  * @param \Box\Spout\Writer\Style\Style $style
  */
 protected function registerFill($style)
 {
     $styleId = $style->getId();
     // Currently - only solid backgrounds are supported
     // so $backgroundColor is a scalar value (RGB Color)
     $backgroundColor = $style->getBackgroundColor();
     if ($backgroundColor) {
         $isBackgroundColorRegistered = isset($this->registeredFills[$backgroundColor]);
         // We need to track the already registered background definitions
         if ($isBackgroundColorRegistered) {
             $registeredStyleId = $this->registeredFills[$backgroundColor];
             $registeredFillId = $this->styleIdToFillMappingTable[$registeredStyleId];
             $this->styleIdToFillMappingTable[$styleId] = $registeredFillId;
         } else {
             $this->registeredFills[$backgroundColor] = $styleId;
             $this->styleIdToFillMappingTable[$styleId] = $this->fillIndex++;
         }
     } else {
         // The fillId maps a style to a fill declaration
         // When there is no background color definition - we default to 0
         $this->styleIdToFillMappingTable[$styleId] = 0;
     }
 }
示例#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;
 }
示例#3
0
文件: StyleHelper.php 项目: box/spout
 /**
  * Returns the contents of the background color definition for the "<style:table-cell-properties>" section
  *
  * @param \Box\Spout\Writer\Style\Style $style
  * @return string
  */
 private function getBackgroundColorXMLContent($style)
 {
     return sprintf('<style:table-cell-properties fo:background-color="#%s"/>', $style->getBackgroundColor());
 }