summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2020-06-16 17:11:12 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-06-17 17:00:46 +0200
commit33ad3ee258587904afaa03550858beac25b883f7 (patch)
treeb9da475b6226ce31132917efe2360bd8a52ee568 /sw
parent5568d92c5c705b4d728af859dc44afdd64e72195 (diff)
tdf#134043 DOCX import: DropDown text field instead of ComboBox form control
Change-Id: Ide9cedefde3b00fa0eeb37a6540e8d4a420b70c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96471 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx26
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx29
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport4.cxx35
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport8.cxx33
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx4
5 files changed, 99 insertions, 28 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 5ff581743ccd..133c2add7822 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -264,12 +264,26 @@ DECLARE_OOXMLEXPORT_TEST(testDropdownInCell, "dropdown-in-cell.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
// Second problem: dropdown shape wasn't anchored inside the B1 cell.
- uno::Reference<text::XTextContent> xShape(getShape(1), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xAnchor = xShape->getAnchor();
- uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
- uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
- uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xCell, uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextRangeCompare->compareRegionStarts(xAnchor, xCell));
+ if (getShapes() > 0)
+ {
+ uno::Reference<text::XTextContent> xShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xAnchor = xShape->getAnchor();
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
+ uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xCell, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextRangeCompare->compareRegionStarts(xAnchor, xCell));
+ }
+ else
+ {
+ // ComboBox was imported as DropDown text field
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+ CPPUNIT_ASSERT(xFields->hasMoreElements());
+ uno::Any aField = xFields->nextElement();
+ uno::Reference<lang::XServiceInfo> xServiceInfo(aField, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.textfield.DropDown"));
+ }
}
DECLARE_OOXMLEXPORT_TEST(testTableAlignment, "table-alignment.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 272daae72c78..430749768862 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -560,7 +560,7 @@ DECLARE_OOXMLEXPORT_TEST(testParaAdjustDistribute, "para-adjust-distribute.docx"
DECLARE_OOXMLEXPORT_TEST(testInputListExport, "tdf122186_input_list.odt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
- if (!mbExported) // importing the ODT, an input field
+ if (!mbExported || getShapes() == 0) // importing the ODT, an input field
{
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
@@ -1032,11 +1032,28 @@ DECLARE_OOXMLEXPORT_TEST(tdf127085, "tdf127085.docx")
DECLARE_OOXMLEXPORT_TEST(tdf119809, "tdf119809.docx")
{
// Combobox without an item list lost during import
- uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
- uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.ComboBox")));
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty< uno::Sequence<OUString> >(xPropertySet, "StringItemList").getLength());
+ if (getShapes() > 0)
+ {
+ uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
+ uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.ComboBox")));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty< uno::Sequence<OUString> >(xPropertySet, "StringItemList").getLength());
+ }
+ else
+ {
+ // ComboBox was imported as DropDown text field
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+ CPPUNIT_ASSERT(xFields->hasMoreElements());
+ uno::Any aField = xFields->nextElement();
+ uno::Reference<lang::XServiceInfo> xServiceInfo(aField, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.textfield.DropDown"));
+
+ uno::Sequence<OUString> aItems = getProperty< uno::Sequence<OUString> >(aField, "Items");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aItems.getLength());
+ }
}
DECLARE_OOXMLEXPORT_TEST(tdf118169, "tdf118169.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index c1890a33c2cd..7356de7be9fe 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -714,17 +714,38 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testComboBoxControl, "combobox-control.docx"
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
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");
+ 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);
+ if (getShapes() > 0)
+ {
+ uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), getProperty<OUString>(xControl->getControl(), "Text"));
+ 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), aItems.getLength());
- CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]);
- CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]);
+ uno::Sequence<OUString> aItems = getProperty< uno::Sequence<OUString> >(xControl->getControl(), "StringItemList");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aItems.getLength());
+ CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]);
+ }
+ else
+ {
+ // ComboBox was imported as DropDown text field
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+ CPPUNIT_ASSERT(xFields->hasMoreElements());
+ uno::Any aField = xFields->nextElement();
+ uno::Reference<lang::XServiceInfo> xServiceInfo(aField, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.textfield.DropDown"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("manolo"), getProperty<OUString>(aField, "SelectedItem"));
+
+ uno::Sequence<OUString> aItems = getProperty< uno::Sequence<OUString> >(aField, "Items");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aItems.getLength());
+ CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]);
+ }
}
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testCheckBoxControl, "checkbox-control.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index 56e6e6b1079f..5f401b266bfc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -926,13 +926,32 @@ DECLARE_OOXMLEXPORT_TEST(testN592908_Picture, "n592908-picture.docx")
DECLARE_OOXMLEXPORT_TEST(testN779630, "n779630.docx")
{
// A combo box is imported
- uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
- uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.ComboBox")));
- CPPUNIT_ASSERT_EQUAL(OUString("dropdown default text"), getProperty<OUString>(xPropertySet, "DefaultText"));
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty< uno::Sequence<OUString> >(xPropertySet, "StringItemList").getLength());
- CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPropertySet, "Dropdown"));
+ if (getShapes() > 0)
+ {
+ uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
+ uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.ComboBox")));
+ CPPUNIT_ASSERT_EQUAL(OUString("dropdown default text"), getProperty<OUString>(xPropertySet, "DefaultText"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty< uno::Sequence<OUString> >(xPropertySet, "StringItemList").getLength());
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPropertySet, "Dropdown"));
+ }
+ else
+ {
+ // ComboBox was imported as DropDown text field
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+ CPPUNIT_ASSERT(xFields->hasMoreElements());
+ uno::Any aField = xFields->nextElement();
+ uno::Reference<lang::XServiceInfo> xServiceInfo(aField, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.textfield.DropDown"));
+
+ uno::Sequence<OUString> aItems = getProperty< uno::Sequence<OUString> >(aField, "Items");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aItems.getLength());
+ CPPUNIT_ASSERT_EQUAL(OUString("Yes"), aItems[0]);
+ CPPUNIT_ASSERT_EQUAL(OUString("No"), aItems[1]);
+ }
}
DECLARE_OOXMLEXPORT_TEST(testIndentation, "indentation.docx")
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index ecd4c588fbbd..b2e67a1d3769 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1367,8 +1367,8 @@ DECLARE_OOXMLIMPORT_TEST(testTdf133448, "tdf133448.docx")
CPPUNIT_ASSERT(xGraphicDescriptor->getPropertyValue("SizePixel") >>= aSizePixel);
//Without the fix in place, the graphic's size is 0x0
- CPPUNIT_ASSERT_EQUAL(sal_Int32(837), aSizePixel.Width);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(598), aSizePixel.Height);
+ CPPUNIT_ASSERT_GREATER(sal_Int32(0), aSizePixel.Width);
+ CPPUNIT_ASSERT_GREATER(sal_Int32(0), aSizePixel.Height);
}
DECLARE_OOXMLIMPORT_TEST(testTdf100072, "tdf100072.docx")