Add plain text SDT type

This commit is contained in:
Daniel Morris 2018-12-26 21:45:32 +02:00
parent 56ca30ab95
commit a5ec49d99d
3 changed files with 15 additions and 3 deletions

View File

@ -90,7 +90,7 @@ class SDT extends Text
*/
public function setType($value)
{
$enum = array('comboBox', 'dropDownList', 'date');
$enum = array('plainText', 'comboBox', 'dropDownList', 'date');
$this->type = $this->setEnumVal($value, $enum, 'comboBox');
return $this;

View File

@ -73,6 +73,18 @@ class SDT extends Text
$this->endElementP(); // w:p
}
/**
* Write text.
*
* @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtText.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\SDT $element
*/
private function writePlainText(XMLWriter $xmlWriter, SDTElement $element)
{
$xmlWriter->startElement("w:text");
$xmlWriter->endElement(); // w:{$type}
}
/**
* Write combo box.
*

View File

@ -29,8 +29,8 @@ class SDTTest extends \PHPUnit\Framework\TestCase
*/
public function testConstruct()
{
$types = array('comboBox', 'dropDownList', 'date');
$type = $types[rand(0, 2)];
$types = array('plainText', 'comboBox', 'dropDownList', 'date');
$type = $types[rand(0, 3)];
$value = rand(0, 100);
$alias = 'alias';
$tag = 'my_tag';