diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/combobox-control.docx | bin | 0 -> 21561 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 21 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 36 |
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 Binary files differnew file mode 100644 index 000000000000..180aacab9e90 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/combobox-control.docx 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); + } } } } |