Example #1
0
 private function _getDataContent_writeText(PHPWord_Section_Text $text)
 {
     $sRTFText = '';
     $styleFont = $text->getFontStyle();
     $SfIsObject = $styleFont instanceof PHPWord_Style_Font ? true : false;
     if (!$SfIsObject) {
         $styleFont = PHPWord_Style::getStyle($styleFont);
     }
     $styleParagraph = $text->getParagraphStyle();
     $SpIsObject = $styleParagraph instanceof PHPWord_Style_Paragraph ? true : false;
     if (!$SpIsObject) {
         $styleParagraph = PHPWord_Style::getStyle($styleParagraph);
     }
     if ($styleParagraph) {
         if ($this->_lastParagraphStyle != $text->getParagraphStyle()) {
             $sRTFText .= '\\pard\\nowidctlpar';
             if ($styleParagraph->getSpaceAfter() != null) {
                 $sRTFText .= '\\sa' . $styleParagraph->getSpaceAfter();
             }
             if ($styleParagraph->getAlign() != null) {
                 if ($styleParagraph->getAlign() == 'center') {
                     $sRTFText .= '\\qc';
                 }
             }
             $this->_lastParagraphStyle = $text->getParagraphStyle();
         } else {
             $this->_lastParagraphStyle = '';
         }
     } else {
         $this->_lastParagraphStyle = '';
     }
     if ($styleFont) {
         if ($styleFont->getColor() != null) {
             $idxColor = array_search($styleFont->getColor(), $this->_colorTable);
             if ($idxColor !== FALSE) {
                 $sRTFText .= '\\cf' . ($idxColor + 1);
             }
         } else {
             $sRTFText .= '\\cf0';
         }
         if ($styleFont->getName() != null) {
             $idxFont = array_search($styleFont->getName(), $this->_fontTable);
             if ($idxFont !== FALSE) {
                 $sRTFText .= '\\f' . $idxFont;
             }
         } else {
             $sRTFText .= '\\f0';
         }
         if ($styleFont->getBold()) {
             $sRTFText .= '\\b';
         }
         if ($styleFont->getBold()) {
             $sRTFText .= '\\i';
         }
         if ($styleFont->getSize()) {
             $sRTFText .= '\\fs' . $styleFont->getSize();
         }
     }
     if ($this->_lastParagraphStyle != '' || $styleFont) {
         $sRTFText .= ' ';
     }
     $sRTFText .= $text->getText();
     if ($styleFont) {
         $sRTFText .= '\\cf0';
         $sRTFText .= '\\f0';
         if ($styleFont->getBold()) {
             $sRTFText .= '\\b0';
         }
         if ($styleFont->getItalic()) {
             $sRTFText .= '\\i0';
         }
         if ($styleFont->getSize()) {
             $sRTFText .= '\\fs20';
         }
     }
     $sRTFText .= '\\par' . PHP_EOL;
     return $sRTFText;
 }