Exemplo n.º 1
0
 /**
  * Create a new Link Element
  *
  * @param string $target
  * @param string $text
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  */
 public function __construct($target, $text = null, $fontStyle = null, $paragraphStyle = null)
 {
     $this->target = String::toUTF8($target);
     $this->text = is_null($text) ? $this->target : String::toUTF8($text);
     $this->fontStyle = $this->setStyle(new Font('text'), $fontStyle);
     $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Create a new Title Element
  *
  * @param string $text
  * @param int $depth
  */
 public function __construct($text, $depth = 1)
 {
     $this->text = String::toUTF8($text);
     $this->depth = $depth;
     if (array_key_exists("Heading_{$this->depth}", Style::getStyles())) {
         $this->style = "Heading{$this->depth}";
     }
     return $this;
 }
Exemplo n.º 3
0
 /**
  * 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 = String::toUTF8($source);
     $this->text = is_null($text) ? $this->source : String::toUTF8($text);
     $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
     $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
     $this->internal = $internal;
     return $this;
 }
Exemplo n.º 4
0
 /**
  * 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->setStyle(new Font('text'), $fontStyle);
     $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle);
     $this->text = String::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;
 }
Exemplo n.º 5
0
 /**
  * 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(String::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);
     }
 }
Exemplo n.º 6
0
 /**
  * Set text content
  *
  * @param string $text
  * @return self
  */
 public function setText($text)
 {
     $this->text = String::toUTF8($text);
     return $this;
 }
Exemplo n.º 7
0
 /**
  * Set name content
  *
  * @param string $name
  * @return self
  */
 public function setName($name)
 {
     $this->name = String::toUTF8($name);
     return $this;
 }
Exemplo n.º 8
0
 /**
  * Create a new Bookmark Element
  *
  * @param string $name
  */
 public function __construct($name)
 {
     $this->name = String::toUTF8($name);
     return $this;
 }
Exemplo n.º 9
0
 /**
  * Set text content
  * 修复phpword的bug,详见https://github.com/PHPOffice/PHPWord/issues/401
  * @param string $text
  * @return self
  */
 public function setText($text)
 {
     $this->text = String::toUTF8(htmlspecialchars($text));
     return $this;
 }
Exemplo n.º 10
0
 /**
  * Add a CheckBox Element
  *
  * @param string $name
  * @param string $text
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  * @return CheckBox
  */
 public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = null)
 {
     $this->checkValidity('checkbox');
     $checkBox = new CheckBox(String::toUTF8($name), String::toUTF8($text), $fontStyle, $paragraphStyle);
     $checkBox->setDocPart($this->getDocPart(), $this->getDocPartId());
     $this->addElement($checkBox);
     return $checkBox;
 }