summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-10 19:36:04 +0100
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-10 22:36:17 +0100
commit554a0ca639504a2fc6ac99555df161ad3fe636bc (patch)
treee250ef9068880f47cd4adb4e6bab2c2f9c9416ed /sw
parentc483e0eeb896b0719f27156e922c102312d98753 (diff)
ooxml: export combo box controls
Export combo box controls as <sdt> elements. Added unit test. Change-Id: I9eda25101240ec61f78ede0f0462d3ab8e77b09b
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/combobox-control.docxbin0 -> 21561 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx21
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx36
3 files changed, 57 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/combobox-control.docx b/sw/qa/extras/ooxmlexport/data/combobox-control.docx
new file mode 100644
index 000000000000..180aacab9e90
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/combobox-control.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 6175b87df0bb..632a73ddae63 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2975,6 +2975,27 @@ DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(2014), sal_Int32(aDate.Year));
}
+DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx")
+{
+ // check XML
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[1]", "value", "manolo");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[2]", "value", "pepito");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "Manolo");
+
+ // check imported control
+ uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), getProperty<OUString>(xControl->getControl(), "Text"));
+
+ uno::Sequence<OUString> aItems = getProperty<uno::Sequence<OUString>>(xControl->getControl(), "StringItemList");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), sal_Int32(aItems.getLength()));
+ CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]);
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 65f3676713f1..7b34920620cb 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3685,6 +3685,42 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject)
m_pSerializer->endElementNS(XML_w, XML_sdt);
}
+ else if (xInfo->supportsService("com.sun.star.form.component.ComboBox"))
+ {
+ // gather component properties
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY);
+ OUString sText = xPropertySet->getPropertyValue("Text").get<OUString>();
+ uno::Sequence<OUString> aItems = xPropertySet->getPropertyValue("StringItemList").get<uno::Sequence<OUString>>();
+
+ // output component
+
+ m_pSerializer->startElementNS(XML_w, XML_sdt, FSEND);
+ m_pSerializer->startElementNS(XML_w, XML_sdtPr, FSEND);
+
+ m_pSerializer->startElementNS(XML_w, XML_dropDownList, FSEND);
+
+ for (sal_Int32 i=0; i < aItems.getLength(); ++i)
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_listItem,
+ FSNS(XML_w, XML_displayText),
+ rtl::OUStringToOString( aItems[i], RTL_TEXTENCODING_UTF8 ).getStr(),
+ FSNS(XML_w, XML_value),
+ rtl::OUStringToOString( aItems[i], RTL_TEXTENCODING_UTF8 ).getStr(),
+ FSEND);
+ }
+
+ m_pSerializer->endElementNS(XML_w, XML_dropDownList);
+ m_pSerializer->endElementNS(XML_w, XML_sdtPr);
+
+ m_pSerializer->startElementNS(XML_w, XML_sdtContent, FSEND);
+ m_pSerializer->startElementNS(XML_w, XML_r, FSEND);
+ RunText(sText);
+ m_pSerializer->endElementNS(XML_w, XML_r);
+ m_pSerializer->endElementNS(XML_w, XML_sdtContent);
+
+ m_pSerializer->endElementNS(XML_w, XML_sdt);
+ }
}
}
}