Font-style addition: bgColor

Signed-off-by: Julien Carignan <julien.carignan@hotmail.com>
This commit is contained in:
Julien Carignan 2014-03-24 13:43:20 -04:00
parent 47fa1f0c3b
commit 27840ab710
2 changed files with 44 additions and 0 deletions

View File

@ -149,6 +149,18 @@ class PHPWord_Style_Font
* @var string
*/
private $_fgColor = null;
/**
* Background color
*
* @var string
*/
private $_bgColor = null;
/**
* Text line height
*
* @var int
*/
/**
* Text line height
@ -468,6 +480,28 @@ class PHPWord_Style_Font
$this->_fgColor = $pValue;
return $this;
}
/**
* Get background color
*
* @return string
*/
public function getBgColor()
{
return $this->_bgColor;
}
/**
* Set background color
*
* @param string $pValue
* @return PHPWord_Style_Font
*/
public function setBgColor($pValue = null)
{
$this->_bgColor = $pValue;
return $this;
}
/**
* Get style type

View File

@ -398,6 +398,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$color = $style->getColor();
$size = $style->getSize();
$fgColor = $style->getFgColor();
$bgColor = $style->getBgColor();
$strikethrough = $style->getStrikethrough();
$underline = $style->getUnderline();
$superscript = $style->getSuperScript();
@ -467,6 +468,15 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$objWriter->writeAttribute('w:val', $fgColor);
$objWriter->endElement();
}
// Background-Color
if (!is_null($bgColor)) {
$objWriter->startElement('w:shd');
$objWriter->writeAttribute('w:val', "clear");
$objWriter->writeAttribute('w:color', "auto");
$objWriter->writeAttribute('w:fill', $bgColor);
$objWriter->endElement();
}
// Superscript/subscript
if ($superscript || $subscript) {