From a5ec49d99dd3783571b9e477ecc24583cd194bf9 Mon Sep 17 00:00:00 2001 From: Daniel Morris Date: Wed, 26 Dec 2018 21:45:32 +0200 Subject: [PATCH] Add plain text SDT type --- src/PhpWord/Element/SDT.php | 2 +- src/PhpWord/Writer/Word2007/Element/SDT.php | 12 ++++++++++++ tests/PhpWord/Element/SDTTest.php | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/Element/SDT.php b/src/PhpWord/Element/SDT.php index a866d1bd..5548f768 100644 --- a/src/PhpWord/Element/SDT.php +++ b/src/PhpWord/Element/SDT.php @@ -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; diff --git a/src/PhpWord/Writer/Word2007/Element/SDT.php b/src/PhpWord/Writer/Word2007/Element/SDT.php index 21020a0f..fc1540b9 100644 --- a/src/PhpWord/Writer/Word2007/Element/SDT.php +++ b/src/PhpWord/Writer/Word2007/Element/SDT.php @@ -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. * diff --git a/tests/PhpWord/Element/SDTTest.php b/tests/PhpWord/Element/SDTTest.php index 6e40bae0..2328dd76 100644 --- a/tests/PhpWord/Element/SDTTest.php +++ b/tests/PhpWord/Element/SDTTest.php @@ -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';