2012-05-06 18:25:40 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
2014-03-26 16:33:20 +07:00
|
|
|
* PHPWord
|
2012-05-06 18:25:40 +02:00
|
|
|
*
|
2014-03-27 23:55:06 +07:00
|
|
|
* @link https://github.com/PHPOffice/PHPWord
|
2014-05-05 12:38:31 +04:00
|
|
|
* @copyright 2010-2014 PHPWord contributors
|
2014-05-04 21:03:28 +04:00
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
2012-05-06 18:25:40 +02:00
|
|
|
*/
|
|
|
|
|
|
2014-03-31 01:13:02 +07:00
|
|
|
namespace PhpOffice\PhpWord\Element;
|
2014-03-22 10:06:08 +04:00
|
|
|
|
|
|
|
|
use PhpOffice\PhpWord\Style\Font;
|
|
|
|
|
use PhpOffice\PhpWord\Style\Paragraph;
|
|
|
|
|
|
2014-03-24 00:26:10 +07:00
|
|
|
/**
|
|
|
|
|
* Text break element
|
|
|
|
|
*/
|
2014-04-08 00:23:49 +07:00
|
|
|
class TextBreak extends AbstractElement
|
2013-12-11 14:45:44 -05:00
|
|
|
{
|
2014-03-14 22:03:19 +07:00
|
|
|
/**
|
|
|
|
|
* Paragraph style
|
|
|
|
|
*
|
2014-04-16 17:22:30 +04:00
|
|
|
* @var string|\PhpOffice\PhpWord\Style\Paragraph
|
2014-03-14 22:03:19 +07:00
|
|
|
*/
|
|
|
|
|
private $paragraphStyle = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Text style
|
|
|
|
|
*
|
2014-04-16 17:22:30 +04:00
|
|
|
* @var string|\PhpOffice\PhpWord\Style\Font
|
2014-03-14 22:03:19 +07:00
|
|
|
*/
|
|
|
|
|
private $fontStyle = null;
|
2013-12-11 14:45:44 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new TextBreak Element
|
2014-03-24 00:26:10 +07:00
|
|
|
*
|
|
|
|
|
* @param mixed $fontStyle
|
|
|
|
|
* @param mixed $paragraphStyle
|
2013-12-11 14:45:44 -05:00
|
|
|
*/
|
2014-03-14 22:03:19 +07:00
|
|
|
public function __construct($fontStyle = null, $paragraphStyle = null)
|
|
|
|
|
{
|
|
|
|
|
if (!is_null($paragraphStyle)) {
|
|
|
|
|
$paragraphStyle = $this->setParagraphStyle($paragraphStyle);
|
|
|
|
|
}
|
|
|
|
|
if (!is_null($fontStyle)) {
|
|
|
|
|
$this->setFontStyle($fontStyle, $paragraphStyle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set Text style
|
|
|
|
|
*
|
2014-03-30 18:51:25 +07:00
|
|
|
* @param mixed $style
|
|
|
|
|
* @param mixed $paragraphStyle
|
2014-04-16 17:22:30 +04:00
|
|
|
* @return string|\PhpOffice\PhpWord\Style\Font
|
2014-03-14 22:03:19 +07:00
|
|
|
*/
|
|
|
|
|
public function setFontStyle($style = null, $paragraphStyle = null)
|
|
|
|
|
{
|
2014-03-22 10:06:08 +04:00
|
|
|
if ($style instanceof Font) {
|
2014-03-14 22:03:19 +07:00
|
|
|
$this->fontStyle = $style;
|
|
|
|
|
$this->setParagraphStyle($paragraphStyle);
|
|
|
|
|
} elseif (is_array($style)) {
|
2014-03-22 10:06:08 +04:00
|
|
|
$this->fontStyle = new Font('text', $paragraphStyle);
|
2014-03-14 22:03:19 +07:00
|
|
|
$this->fontStyle->setArrayStyle($style);
|
|
|
|
|
} else {
|
|
|
|
|
$this->fontStyle = $style;
|
|
|
|
|
$this->setParagraphStyle($paragraphStyle);
|
|
|
|
|
}
|
|
|
|
|
return $this->fontStyle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Text style
|
|
|
|
|
*
|
2014-04-16 17:22:30 +04:00
|
|
|
* @return string|\PhpOffice\PhpWord\Style\Font
|
2014-03-14 22:03:19 +07:00
|
|
|
*/
|
|
|
|
|
public function getFontStyle()
|
|
|
|
|
{
|
|
|
|
|
return $this->fontStyle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set Paragraph style
|
|
|
|
|
*
|
2014-04-16 17:22:30 +04:00
|
|
|
* @param string|array|\PhpOffice\PhpWord\Style\Paragraph $style
|
|
|
|
|
* @return string|\PhpOffice\PhpWord\Style\Paragraph
|
2014-03-14 22:03:19 +07:00
|
|
|
*/
|
|
|
|
|
public function setParagraphStyle($style = null)
|
|
|
|
|
{
|
|
|
|
|
if (is_array($style)) {
|
2014-03-22 10:06:08 +04:00
|
|
|
$this->paragraphStyle = new Paragraph;
|
2014-03-14 22:03:19 +07:00
|
|
|
$this->paragraphStyle->setArrayStyle($style);
|
2014-03-22 10:06:08 +04:00
|
|
|
} elseif ($style instanceof Paragraph) {
|
2014-03-14 22:03:19 +07:00
|
|
|
$this->paragraphStyle = $style;
|
|
|
|
|
} else {
|
|
|
|
|
$this->paragraphStyle = $style;
|
|
|
|
|
}
|
|
|
|
|
return $this->paragraphStyle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Paragraph style
|
|
|
|
|
*
|
2014-04-16 17:22:30 +04:00
|
|
|
* @return string|\PhpOffice\PhpWord\Style\Paragraph
|
2014-03-14 22:03:19 +07:00
|
|
|
*/
|
|
|
|
|
public function getParagraphStyle()
|
2013-12-11 14:45:44 -05:00
|
|
|
{
|
2014-03-14 22:03:19 +07:00
|
|
|
return $this->paragraphStyle;
|
2013-12-11 14:45:44 -05:00
|
|
|
}
|
2012-05-06 18:25:40 +02:00
|
|
|
}
|