PHPWord/src/PhpWord/Element/TextRun.php

63 lines
1.5 KiB
PHP
Raw Normal View History

2012-05-06 18:25:40 +02:00
<?php
/**
* PHPWord
2012-05-06 18:25:40 +02:00
*
2014-03-27 23:55:06 +07:00
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2012-05-06 18:25:40 +02:00
*/
namespace PhpOffice\PhpWord\Element;
2013-12-16 06:40:30 -05:00
use PhpOffice\PhpWord\Container\Container;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Textrun/paragraph element
*/
class TextRun extends Container
{
2013-12-16 06:40:30 -05:00
/**
* Paragraph style
*
* @var string|Paragraph
2013-12-16 06:40:30 -05:00
*/
private $paragraphStyle;
2013-12-16 06:40:30 -05:00
/**
* Create new instance
2013-12-16 06:40:30 -05:00
*
* @param string|array|Paragraph $paragraphStyle
* @param string $docPartType section|header|footer
* @param int $docPartId
2013-12-16 06:40:30 -05:00
*/
public function __construct($paragraphStyle = null, $docPartType = 'section', $docPartId = 1)
2013-12-16 06:40:30 -05:00
{
$this->containerType = 'textrun';
$this->docPartType = $docPartType;
$this->docPartId = $docPartId;
2013-12-16 06:40:30 -05:00
// Set paragraph style
if (is_array($paragraphStyle)) {
$this->paragraphStyle = new Paragraph();
foreach ($paragraphStyle as $key => $value) {
2013-12-16 06:40:30 -05:00
if (substr($key, 0, 1) != '_') {
$key = '_' . $key;
}
$this->paragraphStyle->setStyleValue($key, $value);
2013-12-16 06:40:30 -05:00
}
} else {
$this->paragraphStyle = $paragraphStyle;
2014-03-11 16:44:22 -06:00
}
}
2013-12-16 06:40:30 -05:00
/**
* Get Paragraph style
*
2014-03-30 18:51:25 +07:00
* @return string|Paragraph
2013-12-16 06:40:30 -05:00
*/
public function getParagraphStyle()
{
return $this->paragraphStyle;
}
}