/**
  * Create a new Preserve Text Element
  *
  * @var string $text
  * @var mixed $style
  */
 public function __construct($text = null, $styleFont = null, $styleParagraph = null)
 {
     // Set font style
     if (is_array($styleFont)) {
         $this->_styleFont = new PHPWord_Style_Font('text');
         foreach ($styleFont as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleFont->setStyleValue($key, $value);
         }
     } else {
         $this->_styleFont = $styleFont;
     }
     // Set paragraph style
     if (is_array($styleParagraph)) {
         $this->_styleParagraph = new PHPWord_Style_Paragraph();
         foreach ($styleParagraph as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleParagraph->setStyleValue($key, $value);
         }
     } else {
         $this->_styleParagraph = $styleParagraph;
     }
     $pattern = '/({.*?})/';
     $this->_text = preg_split($pattern, $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     return $this;
 }
Esempio n. 2
0
 /**
  * Create a new Text Element
  * 
  * @var string $text
  * @var mixed $style
  */
 public function __construct($text = null, $styleFont = null, $styleParagraph = null)
 {
     // Set font style
     if (is_array($styleFont)) {
         $this->_styleFont = new PHPWord_Style_Font('text');
         foreach ($styleFont as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleFont->setStyleValue($key, $value);
         }
     } else {
         $this->_styleFont = $styleFont;
     }
     // Set paragraph style
     if (is_array($styleParagraph)) {
         $this->_styleParagraph = new PHPWord_Style_Paragraph();
         foreach ($styleParagraph as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleParagraph->setStyleValue($key, $value);
         }
     } else {
         $this->_styleParagraph = $styleParagraph;
     }
     if (is_array($text)) {
         throw new Exception('muss schon ein String sein.');
     }
     $this->_text = $text;
     return $this;
 }
Esempio n. 3
0
File: Text.php Progetto: roojs/pear
 /**
  * Create a new Text Element
  * 
  * @var string $text
  * @var mixed $style
  */
 public function __construct($text = null, $styleFont = null, $styleParagraph = null)
 {
     // Set font style
     if (is_array($styleFont)) {
         require_once __DIR__ . '/../Style/Font.php';
         $this->_styleFont = new Document_Word_Writer_Style_Font('text');
         foreach ($styleFont as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleFont->setStyleValue($key, $value);
         }
     } else {
         $this->_styleFont = $styleFont;
     }
     // Set paragraph style
     if (is_array($styleParagraph)) {
         require_once __DIR__ . '/../Style/Paragraph.php';
         $this->_styleParagraph = new Document_Word_Writer_Style_Paragraph();
         foreach ($styleParagraph as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleParagraph->setStyleValue($key, $value);
         }
     } else {
         $this->_styleParagraph = $styleParagraph;
     }
     $this->_text = $text;
     return $this;
 }
Esempio n. 4
0
 /**
  * Create a new TextRun Element
  */
 public function __construct($styleParagraph = null)
 {
     $this->_elementCollection = array();
     // Set paragraph style
     if (is_array($styleParagraph)) {
         $this->_styleParagraph = new PHPWord_Style_Paragraph();
         foreach ($styleParagraph as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleParagraph->setStyleValue($key, $value);
         }
     } else {
         $this->_styleParagraph = $styleParagraph;
     }
 }
Esempio n. 5
0
 /**
  * Create a new Link Element
  * 
  * @var string $linkSrc
  * @var string $linkName
  * @var mixed $styleFont
  * @var mixed $styleParagraph
  */
 public function __construct($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null)
 {
     $this->_linkSrc = $linkSrc;
     $this->_linkName = $linkName;
     // Set font style
     if (is_array($styleFont)) {
         $this->_styleFont = new PHPWord_Style_Font('text');
         foreach ($styleFont as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleFont->setStyleValue($key, $value);
         }
     } else {
         $this->_styleFont = $styleFont;
     }
     // Set paragraph style
     if (is_array($styleParagraph)) {
         $this->_styleParagraph = new PHPWord_Style_Paragraph();
         foreach ($styleParagraph as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleParagraph->setStyleValue($key, $value);
         }
     } else {
         $this->_styleParagraph = $styleParagraph;
     }
     return $this;
 }
Esempio n. 6
0
 /**
  * Create a new TextRun Element
  */
 public function __construct($styleParagraph = null)
 {
     require_once __DIR__ . '/../Style/Paragraph.php';
     $this->_elementCollection = array();
     // Set paragraph style
     if (is_array($styleParagraph)) {
         $this->_styleParagraph = new Document_Word_Writer_Style_Paragraph();
         foreach ($styleParagraph as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleParagraph->setStyleValue($key, $value);
         }
     } else {
         $this->_styleParagraph = $styleParagraph;
     }
 }
Esempio n. 7
0
 /**
  * Set Paragraph style
  *
  * @return PHPWord_Style_Paragraph
  */
 public function setParagraphStyle($styleParagraph)
 {
     if (is_array($styleParagraph)) {
         $this->_styleParagraph = new PHPWord_Style_Paragraph();
         foreach ($styleParagraph as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $this->_styleParagraph->setStyleValue($key, $value);
         }
     } else {
         $this->_styleParagraph = $styleParagraph;
     }
 }
Esempio n. 8
0
 /**
  * Add a title style
  *
  * @param string $styleName
  * @param array $styleFont
  * @param array $styleParagraph
  */
 public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
 {
     $styleName = 'Heading_' . $titleCount;
     if (!array_key_exists($styleName, self::$_styleElements)) {
         $font = new PHPWord_Style_Font('title', $styleParagraph);
         foreach ($styleFont as $key => $value) {
             if (substr($key, 0, 1) != '_') {
                 $key = '_' . $key;
             }
             $font->setStyleValue($key, $value);
         }
         self::$_styleElements[$styleName] = $font;
     }
 }