/**
  * Create a new Title Element
  *
  * @param string $text
  * @param int $depth
  */
 public function __construct($text, $depth = 1)
 {
     $this->text = CommonText::toUTF8($text);
     $this->depth = $depth;
     if (array_key_exists("Heading_{$this->depth}", Style::getStyles())) {
         $this->style = "Heading{$this->depth}";
     }
     return $this;
 }
 /**
  * Create a new Link Element
  *
  * @param string $source
  * @param string $text
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  */
 public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
 {
     $this->source = CommonText::toUTF8($source);
     $this->text = is_null($text) ? $this->source : CommonText::toUTF8($text);
     $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
     $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
     $this->internal = $internal;
     return $this;
 }
 /**
  * Create a new Preserve Text Element
  *
  * @param string $text
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  * @return self
  */
 public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
 {
     $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
     $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
     $this->text = CommonText::toUTF8($text);
     $matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     if (isset($matches[0])) {
         $this->text = $matches;
     }
     return $this;
 }
 /**
  * Create a new ListItem
  *
  * @param string $text
  * @param int $depth
  * @param mixed $fontStyle
  * @param array|string|null $listStyle
  * @param mixed $paragraphStyle
  */
 public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
 {
     $this->textObject = new Text(CommonText::toUTF8($text), $fontStyle, $paragraphStyle);
     $this->depth = $depth;
     // Version >= 0.10.0 will pass numbering style name. Older version will use old method
     if (!is_null($listStyle) && is_string($listStyle)) {
         $this->style = new ListItemStyle($listStyle);
     } else {
         $this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
     }
 }
 /**
  * Set text content
  *
  * @param string $text
  * @return self
  */
 public function setText($text)
 {
     $this->text = CommonText::toUTF8($text);
     return $this;
 }
 /**
  * Create a new Bookmark Element
  *
  * @param string $name
  */
 public function __construct($name)
 {
     $this->name = CommonText::toUTF8($name);
     return $this;
 }
 /**
  * Set name content
  *
  * @param string $name
  * @return self
  */
 public function setName($name)
 {
     $this->name = CommonText::toUTF8($name);
     return $this;
 }