summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-09-18 09:28:06 +0200
committerLászló Németh <nemeth@numbertext.org>2020-09-18 20:20:46 +0200
commit782700c6940341d489eabf00a531cb184941484e (patch)
tree1d27be87bc715426119565458249b71b28b688ce /sw/qa/extras
parent10bb02efd8afd42e633e370480104e2575546d8e (diff)
tdf#122648 DOCX import: fix table formula in all tables
Table formula import worked only in the first table, because of using bad fallback table for cell references without table names during formula conversion to internal formula. Set table of the text field as the correct fallback table. Follow-up of commit 68e74bdf63e992666016c790e8e4cfd5b28d6abe (tdf133647 tdf123386 tdf123389 Improved .docx table formula import). Change-Id: Ib080f12426c57c8c74fe919eb45637a655875d1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102989 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf122648.docxbin0 -> 4767 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport15.cxx35
2 files changed, 35 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf122648.docx b/sw/qa/extras/ooxmlexport/data/tdf122648.docx
new file mode 100644
index 000000000000..900a9f30b23b
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf122648.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index d83e670dab58..6606befccaf1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -354,6 +354,41 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123382, "tdf123382.docx")
assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[4]/w:p/w:r[2]/w:instrText", " =MAX(LEFT)");
}
+DECLARE_OOXMLEXPORT_TEST(testTdf122648, "tdf122648.docx")
+{
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+
+ // table formula conversion worked only in the first table
+ uno::Reference<text::XTextField> xEnumerationAccess1(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("<A1>"), xEnumerationAccess1->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), xEnumerationAccess1->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess2(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("SUM(<A1:B1>)"), xEnumerationAccess2->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("2"), xEnumerationAccess2->getPresentation(false).trim());
+
+ // These were <?> and SUM(<?:?>) with zero values
+ uno::Reference<text::XTextField> xEnumerationAccess3(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("<A1>"), xEnumerationAccess3->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), xEnumerationAccess3->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess4(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("SUM(<A1:B1>)"), xEnumerationAccess4->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("2"), xEnumerationAccess4->getPresentation(false).trim());
+
+ xmlDocUniquePtr pXmlDoc = parseExport();
+ if (!pXmlDoc)
+ return;
+
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", " =A1");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[2]/w:tc[2]/w:p/w:r[2]/w:instrText", " =SUM(A1:B1)");
+ // These were =<?> and =SUM(<?:?>)
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl[2]/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", " =A1");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl[2]/w:tr[2]/w:tc[2]/w:p/w:r[2]/w:instrText", " =SUM(A1:B1)");
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf98000_changePageStyle, "tdf98000_changePageStyle.odt")
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);