From d55b26a093bdbced08985dbc7113190b52a8bc66 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 26 Feb 2020 13:00:23 +0100 Subject: sw: DOCX export: for SwDropDownField, don't write FORMDROPDOWN ... because Word's funny limitation to 25 listEntry children causes data loss, as seen in commit d9634e3c9bfaf826b3d4d39e9a57d6c2d8d9a3dc "sw: DOCX export: limit FORMDROPDOWN listEntry to Word's abilities". Instead write SDT dropDownList, which appears to be able to store at least 26 listItem children without complaint from Word, so it's an improvement. Funnily domainmapper converts it to a form control on DOCX import. Change-Id: Ic0f24144cb2b5233f82c7b3bc67946a6e56448a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89541 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'sw/qa') diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index c3a8c4948397..9c1f362b8a70 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -452,13 +452,31 @@ DECLARE_OOXMLEXPORT_TEST(testParaAdjustDistribute, "para-adjust-distribute.docx" getProperty(getParagraph(2), "ParaLastLineAdjust"))); } -DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testInputListExport, "tdf122186_input_list.odt") +DECLARE_OOXMLEXPORT_TEST(testInputListExport, "tdf122186_input_list.odt") { - // We need to make sure we don't export the text itself next to the input list field - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r", 5); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[4]/w:t", 0); + if (!mbExported) // importing the ODT, an input field + { + uno::Reference xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference xFields(xFieldsAccess->createEnumeration()); + CPPUNIT_ASSERT(xFields->hasMoreElements()); + uno::Any aField = xFields->nextElement(); + uno::Reference xServiceInfo(aField, uno::UNO_QUERY); + CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.textfield.DropDown")); + } + else // importing the DOCX, a form control + { + uno::Reference xControlShape(getShape(1), uno::UNO_QUERY); + uno::Reference xPropertySet(xControlShape->getControl(), uno::UNO_QUERY); + uno::Reference xServiceInfo(xPropertySet, uno::UNO_QUERY); + CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.form.component.ComboBox")); + CPPUNIT_ASSERT(getProperty(xPropertySet, "Dropdown")); + auto const items(getProperty>(xPropertySet, "StringItemList")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), items.getLength()); + CPPUNIT_ASSERT_EQUAL(OUString("1"), items[0]); + CPPUNIT_ASSERT_EQUAL(OUString("2"), items[1]); + CPPUNIT_ASSERT_EQUAL(OUString("3"), items[2]); + } } DECLARE_OOXMLEXPORT_TEST(testTdf116371, "tdf116371.odt") -- cgit