add Font Content Type

w:hint attribute added
This commit is contained in:
jhfangying 2014-03-13 13:09:44 +08:00
parent bb38d6c135
commit a7663476f6
3 changed files with 102 additions and 106 deletions

View File

@ -43,7 +43,11 @@ class PHPWord
* Default font name (Arial) * Default font name (Arial)
*/ */
const DEFAULT_FONT_NAME = 'Arial'; const DEFAULT_FONT_NAME = 'Arial';
/**
* Default Font Content Type(default)
* default|eastAsia|cs
*/
const DEFAULT_FONT_CONTENT_TYPE='default';
/** /**
* Default font size in points (10pt) * Default font size in points (10pt)
* *

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPWord * PHPWord
* *
@ -24,14 +25,13 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 0.7.0 * @version 0.7.0
*/ */
use PhpOffice\PhpWord\Exceptions\InvalidStyleException; use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
/** /**
* Class PHPWord_Style_Font * Class PHPWord_Style_Font
*/ */
class PHPWord_Style_Font class PHPWord_Style_Font {
{
const UNDERLINE_NONE = 'none'; const UNDERLINE_NONE = 'none';
const UNDERLINE_DASH = 'dash'; const UNDERLINE_DASH = 'dash';
const UNDERLINE_DASHHEAVY = 'dashHeavy'; const UNDERLINE_DASHHEAVY = 'dashHeavy';
@ -50,7 +50,6 @@ class PHPWord_Style_Font
const UNDERLINE_WAVYDOUBLE = 'wavyDbl'; const UNDERLINE_WAVYDOUBLE = 'wavyDbl';
const UNDERLINE_WAVYHEAVY = 'wavyHeavy'; const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
const UNDERLINE_WORDS = 'words'; const UNDERLINE_WORDS = 'words';
const FGCOLOR_YELLOW = 'yellow'; const FGCOLOR_YELLOW = 'yellow';
const FGCOLOR_LIGHTGREEN = 'green'; const FGCOLOR_LIGHTGREEN = 'green';
const FGCOLOR_CYAN = 'cyan'; const FGCOLOR_CYAN = 'cyan';
@ -158,14 +157,20 @@ class PHPWord_Style_Font
*/ */
private $lineHeight = 1.0; private $lineHeight = 1.0;
/**
* Font Content Type
*
* @var string
*/
private $_hint = PHPWord::DEFAULT_FONT_CONTENT_TYPE;
/** /**
* New font style * New font style
* *
* @param string $type Type of font * @param string $type Type of font
* @param array $paragraphStyle Paragraph styles definition * @param array $paragraphStyle Paragraph styles definition
*/ */
public function __construct($type = 'text', $paragraphStyle = null) public function __construct($type = 'text', $paragraphStyle = null) {
{
$this->_type = $type; $this->_type = $type;
if ($paragraphStyle instanceof PHPWord_Style_Paragraph) { if ($paragraphStyle instanceof PHPWord_Style_Paragraph) {
@ -184,8 +189,7 @@ class PHPWord_Style_Font
* @param array $style * @param array $style
* @return $this * @return $this
*/ */
public function setArrayStyle(array $style = array()) public function setArrayStyle(array $style = array()) {
{
foreach ($style as $key => $value) { foreach ($style as $key => $value) {
if ($key === 'line-height') { if ($key === 'line-height') {
$this->setLineHeight($value); $this->setLineHeight($value);
@ -205,8 +209,7 @@ class PHPWord_Style_Font
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*/ */
public function setStyleValue($key, $value) public function setStyleValue($key, $value) {
{
$method = 'set' . substr($key, 1); $method = 'set' . substr($key, 1);
if (method_exists($this, $method)) { if (method_exists($this, $method)) {
$this->$method($value); $this->$method($value);
@ -218,8 +221,7 @@ class PHPWord_Style_Font
* *
* @return bool * @return bool
*/ */
public function getName() public function getName() {
{
return $this->_name; return $this->_name;
} }
@ -229,22 +231,21 @@ class PHPWord_Style_Font
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setName($pValue = PHPWord::DEFAULT_FONT_NAME) public function setName($pValue = PHPWord::DEFAULT_FONT_NAME) {
{
if (is_null($pValue) || $pValue == '') { if (is_null($pValue) || $pValue == '') {
$pValue = PHPWord::DEFAULT_FONT_NAME; $pValue = PHPWord::DEFAULT_FONT_NAME;
} }
$this->_name = $pValue; $this->_name = $pValue;
return $this; return $this;
} }
/** /**
* Get font size * Get font size
* *
* @return int|float * @return int|float
*/ */
public function getSize() public function getSize() {
{
return $this->_size; return $this->_size;
} }
@ -254,8 +255,7 @@ class PHPWord_Style_Font
* @param int|float $pValue * @param int|float $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE) public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE) {
{
if (!is_numeric($pValue)) { if (!is_numeric($pValue)) {
$pValue = PHPWord::DEFAULT_FONT_SIZE; $pValue = PHPWord::DEFAULT_FONT_SIZE;
} }
@ -268,8 +268,7 @@ class PHPWord_Style_Font
* *
* @return bool * @return bool
*/ */
public function getBold() public function getBold() {
{
return $this->_bold; return $this->_bold;
} }
@ -279,8 +278,7 @@ class PHPWord_Style_Font
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setBold($pValue = false) public function setBold($pValue = false) {
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -293,8 +291,7 @@ class PHPWord_Style_Font
* *
* @return bool * @return bool
*/ */
public function getItalic() public function getItalic() {
{
return $this->_italic; return $this->_italic;
} }
@ -304,8 +301,7 @@ class PHPWord_Style_Font
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setItalic($pValue = false) public function setItalic($pValue = false) {
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -318,8 +314,7 @@ class PHPWord_Style_Font
* *
* @return bool * @return bool
*/ */
public function getSuperScript() public function getSuperScript() {
{
return $this->_superScript; return $this->_superScript;
} }
@ -329,8 +324,7 @@ class PHPWord_Style_Font
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setSuperScript($pValue = false) public function setSuperScript($pValue = false) {
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -344,8 +338,7 @@ class PHPWord_Style_Font
* *
* @return bool * @return bool
*/ */
public function getSubScript() public function getSubScript() {
{
return $this->_subScript; return $this->_subScript;
} }
@ -355,8 +348,7 @@ class PHPWord_Style_Font
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setSubScript($pValue = false) public function setSubScript($pValue = false) {
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -370,8 +362,7 @@ class PHPWord_Style_Font
* *
* @return string * @return string
*/ */
public function getUnderline() public function getUnderline() {
{
return $this->_underline; return $this->_underline;
} }
@ -381,8 +372,7 @@ class PHPWord_Style_Font
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) {
{
if ($pValue == '') { if ($pValue == '') {
$pValue = PHPWord_Style_Font::UNDERLINE_NONE; $pValue = PHPWord_Style_Font::UNDERLINE_NONE;
} }
@ -395,8 +385,7 @@ class PHPWord_Style_Font
* *
* @return bool * @return bool
*/ */
public function getStrikethrough() public function getStrikethrough() {
{
return $this->_strikethrough; return $this->_strikethrough;
} }
@ -406,8 +395,7 @@ class PHPWord_Style_Font
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setStrikethrough($pValue = false) public function setStrikethrough($pValue = false) {
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -420,8 +408,7 @@ class PHPWord_Style_Font
* *
* @return string * @return string
*/ */
public function getColor() public function getColor() {
{
return $this->_color; return $this->_color;
} }
@ -431,8 +418,7 @@ class PHPWord_Style_Font
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR) public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR) {
{
if (is_null($pValue) || $pValue == '') { if (is_null($pValue) || $pValue == '') {
$pValue = PHPWord::DEFAULT_FONT_COLOR; $pValue = PHPWord::DEFAULT_FONT_COLOR;
} }
@ -445,8 +431,7 @@ class PHPWord_Style_Font
* *
* @return bool * @return bool
*/ */
public function getFgColor() public function getFgColor() {
{
return $this->_fgColor; return $this->_fgColor;
} }
@ -456,8 +441,7 @@ class PHPWord_Style_Font
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setFgColor($pValue = null) public function setFgColor($pValue = null) {
{
$this->_fgColor = $pValue; $this->_fgColor = $pValue;
return $this; return $this;
} }
@ -467,8 +451,7 @@ class PHPWord_Style_Font
* *
* @return string * @return string
*/ */
public function getStyleType() public function getStyleType() {
{
return $this->_type; return $this->_type;
} }
@ -477,12 +460,10 @@ class PHPWord_Style_Font
* *
* @return PHPWord_Style_Paragraph * @return PHPWord_Style_Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle() {
{
return $this->_paragraphStyle; return $this->_paragraphStyle;
} }
/** /**
* Set the line height * Set the line height
* *
@ -490,8 +471,7 @@ class PHPWord_Style_Font
* @return $this * @return $this
* @throws InvalidStyleException * @throws InvalidStyleException
*/ */
public function setLineHeight($lineHeight) public function setLineHeight($lineHeight) {
{
if (is_string($lineHeight)) { if (is_string($lineHeight)) {
$lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight));
} }
@ -508,8 +488,28 @@ class PHPWord_Style_Font
/** /**
* @return int|float * @return int|float
*/ */
public function getLineHeight() public function getLineHeight() {
{
return $this->lineHeight; return $this->lineHeight;
} }
/**
* Get Font Content Type
*
* @return bool
*/
public function getHint() {
return $this->_hint;
}
/**
* Set Font Content Type
*
* @param string $pValue
* @return PHPWord_Style_Font
*/
public function setHint($pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE) {
if (is_null($pValue) || $pValue == '') {
$pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE;
}
$this->_hint = $pValue;
return $this;
}
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPWord * PHPWord
* *
@ -28,11 +29,9 @@
/** /**
* Class PHPWord_Writer_Word2007_Base * Class PHPWord_Writer_Word2007_Base
*/ */
class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
{
protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) {
{
$styleFont = $text->getFontStyle(); $styleFont = $text->getFontStyle();
$SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
@ -81,8 +80,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
} }
} }
protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) {
{
$elements = $textrun->getElements(); $elements = $textrun->getElements();
$styleParagraph = $textrun->getParagraphStyle(); $styleParagraph = $textrun->getParagraphStyle();
@ -108,7 +106,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$this->_writeLink($objWriter, $element, true); $this->_writeLink($objWriter, $element, true);
} elseif ($element instanceof PHPWord_Section_Image) { } elseif ($element instanceof PHPWord_Section_Image) {
$this->_writeImage($objWriter, $element, true); $this->_writeImage($objWriter, $element, true);
} elseif($element instanceof PHPWord_Section_Footnote) { } elseif ($element instanceof PHPWord_Section_Footnote) {
$this->_writeFootnoteReference($objWriter, $element, true); $this->_writeFootnoteReference($objWriter, $element, true);
} }
} }
@ -126,10 +124,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
* @return void * @return void
*/ */
protected function _writeParagraphStyle( protected function _writeParagraphStyle(
PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Paragraph $style, $withoutPPR = false) {
PHPWord_Style_Paragraph $style,
$withoutPPR = false)
{
$align = $style->getAlign(); $align = $style->getAlign();
$spacing = $style->getSpacing(); $spacing = $style->getSpacing();
$spaceBefore = $style->getSpaceBefore(); $spaceBefore = $style->getSpaceBefore();
@ -143,9 +138,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$pageBreakBefore = $style->getPageBreakBefore(); $pageBreakBefore = $style->getPageBreakBefore();
if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) ||
!is_null($spaceAfter) || !is_null($indent) || !is_null($hanging) || !is_null($spaceAfter) || !is_null($indent) || !is_null($hanging) ||
!is_null($tabs) || !is_null($widowControl) || !is_null($keepNext) || !is_null($tabs) || !is_null($widowControl) || !is_null($keepNext) ||
!is_null($keepLines) || !is_null($pageBreakBefore)) { !is_null($keepLines) || !is_null($pageBreakBefore)) {
if (!$withoutPPR) { if (!$withoutPPR) {
$objWriter->startElement('w:pPr'); $objWriter->startElement('w:pPr');
} }
@ -172,7 +167,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
// Spacing // Spacing
if (!is_null($spaceBefore) || !is_null($spaceAfter) || if (!is_null($spaceBefore) || !is_null($spaceAfter) ||
!is_null($spacing)) { !is_null($spacing)) {
$objWriter->startElement('w:spacing'); $objWriter->startElement('w:spacing');
if (!is_null($spaceBefore)) { if (!is_null($spaceBefore)) {
$objWriter->writeAttribute('w:before', $spaceBefore); $objWriter->writeAttribute('w:before', $spaceBefore);
@ -220,8 +215,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
} }
} }
protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) {
{
$rID = $link->getRelationId(); $rID = $link->getRelationId();
$linkName = $link->getLinkName(); $linkName = $link->getLinkName();
if (is_null($linkName)) { if (is_null($linkName)) {
@ -276,8 +270,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
} }
} }
protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) {
{
$styleFont = $textrun->getFontStyle(); $styleFont = $textrun->getFontStyle();
$styleParagraph = $textrun->getParagraphStyle(); $styleParagraph = $textrun->getParagraphStyle();
@ -368,8 +361,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$objWriter->endElement(); // p $objWriter->endElement(); // p
} }
protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) {
{
$font = $style->getName(); $font = $style->getName();
$bold = $style->getBold(); $bold = $style->getBold();
$italic = $style->getItalic(); $italic = $style->getItalic();
@ -380,6 +372,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$underline = $style->getUnderline(); $underline = $style->getUnderline();
$superscript = $style->getSuperScript(); $superscript = $style->getSuperScript();
$subscript = $style->getSubScript(); $subscript = $style->getSubScript();
$hint = $style->getHint();
$objWriter->startElement('w:rPr'); $objWriter->startElement('w:rPr');
@ -390,9 +383,14 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$objWriter->writeAttribute('w:hAnsi', $font); $objWriter->writeAttribute('w:hAnsi', $font);
$objWriter->writeAttribute('w:eastAsia', $font); $objWriter->writeAttribute('w:eastAsia', $font);
$objWriter->writeAttribute('w:cs', $font); $objWriter->writeAttribute('w:cs', $font);
//Font Content Type
if ($hint != PHPWord::DEFAULT_FONT_CONTENT_TYPE) {
$objWriter->writeAttribute('w:hint', $hint);
}
$objWriter->endElement(); $objWriter->endElement();
} }
// Color // Color
if ($color != PHPWord::DEFAULT_FONT_COLOR) { if ($color != PHPWord::DEFAULT_FONT_COLOR) {
$objWriter->startElement('w:color'); $objWriter->startElement('w:color');
@ -450,13 +448,11 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$objWriter->endElement(); $objWriter->endElement();
} }
protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) {
{
$objWriter->writeElement('w:p', null); $objWriter->writeElement('w:p', null);
} }
protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) {
{
$_rows = $table->getRows(); $_rows = $table->getRows();
$_cRows = count($_rows); $_cRows = count($_rows);
@ -543,7 +539,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
} elseif ($element instanceof PHPWord_Section_ListItem) { } elseif ($element instanceof PHPWord_Section_ListItem) {
$this->_writeListItem($objWriter, $element); $this->_writeListItem($objWriter, $element);
} elseif ($element instanceof PHPWord_Section_Image || } elseif ($element instanceof PHPWord_Section_Image ||
$element instanceof PHPWord_Section_MemoryImage $element instanceof PHPWord_Section_MemoryImage
) { ) {
$this->_writeImage($objWriter, $element); $this->_writeImage($objWriter, $element);
} elseif ($element instanceof PHPWord_Section_Object) { } elseif ($element instanceof PHPWord_Section_Object) {
@ -564,8 +560,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
} }
} }
protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) {
{
$margins = $style->getCellMargin(); $margins = $style->getCellMargin();
$mTop = (!is_null($margins[0])) ? true : false; $mTop = (!is_null($margins[0])) ? true : false;
$mLeft = (!is_null($margins[1])) ? true : false; $mLeft = (!is_null($margins[1])) ? true : false;
@ -609,8 +604,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
} }
} }
protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Cell $style = null) protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Cell $style = null) {
{
$bgColor = $style->getBgColor(); $bgColor = $style->getBgColor();
$valign = $style->getVAlign(); $valign = $style->getVAlign();
$textDir = $style->getTextDirection(); $textDir = $style->getTextDirection();
@ -716,8 +710,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
* @param \PHPWord_Shared_XMLWriter $objWriter * @param \PHPWord_Shared_XMLWriter $objWriter
* @param \PHPWord_Section_Image $image * @param \PHPWord_Section_Image $image
*/ */
protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Image $image, $withoutP = false) protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Image $image, $withoutP = false) {
{
$rId = $image->getRelationId(); $rId = $image->getRelationId();
$style = $image->getStyle(); $style = $image->getStyle();
@ -793,8 +786,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
} }
} }
protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) {
{
$rId = $image->getRelationId(); $rId = $image->getRelationId();
$style = $image->getStyle(); $style = $image->getStyle();
@ -837,8 +829,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$objWriter->endElement(); $objWriter->endElement();
} }
protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) {
{
$text = htmlspecialchars($title->getText()); $text = htmlspecialchars($title->getText());
$text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text); $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text);
$anchor = $title->getAnchor(); $anchor = $title->getAnchor();
@ -888,22 +879,22 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$objWriter->startElement('w:p'); $objWriter->startElement('w:p');
if($SpIsObject) { if ($SpIsObject) {
$this->_writeParagraphStyle($objWriter, $styleParagraph); $this->_writeParagraphStyle($objWriter, $styleParagraph);
} elseif(!$SpIsObject && !is_null($styleParagraph)) { } elseif (!$SpIsObject && !is_null($styleParagraph)) {
$objWriter->startElement('w:pPr'); $objWriter->startElement('w:pPr');
$objWriter->startElement('w:pStyle'); $objWriter->startElement('w:pStyle');
$objWriter->writeAttribute('w:val', $styleParagraph); $objWriter->writeAttribute('w:val', $styleParagraph);
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
$elements = $footnote->getElements(); $elements = $footnote->getElements();
if(count($elements) > 0) { if (count($elements) > 0) {
foreach($elements as $element) { foreach ($elements as $element) {
if($element instanceof PHPWord_Section_Text) { if ($element instanceof PHPWord_Section_Text) {
$this->_writeText($objWriter, $element, true); $this->_writeText($objWriter, $element, true);
} elseif($element instanceof PHPWord_Section_Link) { } elseif ($element instanceof PHPWord_Section_Link) {
$this->_writeLink($objWriter, $element, true); $this->_writeLink($objWriter, $element, true);
} }
} }
@ -930,4 +921,5 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$objWriter->endElement(); // w:p $objWriter->endElement(); // w:p
} }
} }
}
}