/** * gets rtf code * * @return string rtf code */ public function getContent() { $content = $this->getTypeAsRtfCode() . '\\brdrw' . $this->_size . '\\brsp' . $this->_space; if ($this->_color && $this->_colorTable) { $colorIndex = $this->_colorTable->getColorIndex($this->_color); if ($colorIndex !== false) { $content .= '\\brdrcf' . $colorIndex; } } return $content . ' '; }
/** * gets rtf code of paragraph * * @return string rtf code */ public function getContent() { $content = ''; switch ($this->_alignment) { case self::TEXT_ALIGN_RIGHT: $content .= '\\qr '; break; case self::TEXT_ALIGN_CENTER: $content .= '\\qc '; break; case self::TEXT_ALIGN_JUSTIFY: $content .= '\\qj '; break; default: $content .= '\\ql '; break; } if ($this->_indentFirstLine != 0) { $content .= '\\fi' . PHPRtfLite_Unit::getUnitInTwips($this->_indentFirstLine) . ' '; } if ($this->_indentLeft > 0) { $content .= '\\li' . PHPRtfLite_Unit::getUnitInTwips($this->_indentLeft) . ' '; } if ($this->_indentRight > 0) { $content .= '\\ri' . PHPRtfLite_Unit::getUnitInTwips($this->_indentRight) . ' '; } if ($this->_spaceBefore > 0) { $content .= '\\sb' . $this->_spaceBefore . ' '; } if ($this->_spaceAfter > 0) { $content .= '\\sa' . $this->_spaceAfter . ' '; } if ($this->_spaceBetweenLines > 0) { $content .= '\\sl' . $this->_spaceBetweenLines . ' '; } if ($this->_border) { $content .= $this->_border->getContent('\\'); } if ($this->_shading > 0) { $content .= '\\shading' . $this->_shading . ' '; } if ($this->_backgroundColor && $this->_colorTable) { $colorIndex = $this->_colorTable->getColorIndex($this->_backgroundColor); if ($colorIndex !== false) { $content .= '\\cbpat' . $colorIndex . ' '; } } return $content; }
/** * gets rtf code of font * * @return string rtf code */ public function getContent() { $content = ''; if ($this->_size > 0) { $content .= '\\fs' . $this->_size * 2 . ' '; } if ($this->_fontFamily && $this->_fontTable) { $fontIndex = $this->_fontTable->getFontIndex($this->_fontFamily); if ($fontIndex !== false) { $content .= '\\f' . $fontIndex . ' '; } } if ($this->_color && $this->_colorTable) { $colorIndex = $this->_colorTable->getColorIndex($this->_color); if ($colorIndex !== false) { $content .= '\\cf' . $colorIndex . ' '; } } if ($this->_backgroundColor && $this->_colorTable) { $colorIndex = $this->_colorTable->getColorIndex($this->_backgroundColor); if ($colorIndex !== false) { $content .= '\\chcbpat' . $colorIndex . ' '; } } if ($this->_isBold) { $content .= '\\b '; } if ($this->_isItalic) { $content .= '\\i '; } if ($this->_isUnderlined) { $content .= '\\ul '; } if ($this->_animation) { $content .= '\\animtext' . $this->_animation; } if ($this->_isStriked) { $content .= '\\strike ' . $this->_animation; } elseif ($this->_isDoubleStriked) { $content .= '\\striked1 ' . $this->_animation; } return $content; }
/** * @dataProvider provideGetColorIndex * @param PHPRtfLite_DocHead_ColorTable $colorTable * @param string $color * @param integer $colorIndex */ public function testGetColorIndex(PHPRtfLite_DocHead_ColorTable $colorTable, $color, $colorIndex) { $colorTable->add($color); $this->assertEquals($colorIndex, $colorTable->getColorIndex($color)); }