summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-09-16 13:06:32 +0200
committerLászló Németh <nemeth@numbertext.org>2020-09-18 11:40:19 +0200
commitd676d2c22f1d092c9978ffc1595b8356d8db1f7a (patch)
tree94679ff81736620f7ac80307a0ec9700ba0a0bc0 /sw
parent4b94023c5caf2b5cbffca2ff2f3abf7597d0cbb0 (diff)
tdf#123382 DOCX import: fix range IDs in column A
Range IDs ABOVE, BELOW, LEFT and RIGHT weren't recognized in the first table column. Also the original formula was not grab-bagged in the first table cell (A1), according to the limitation of isInTable(). Follow-up of commit 436cf6d31deb7f9594a5da52ec7883d7e3d34344 (tdf#123355 DOCX import: fix cell range ABOVE, BELOW) and commit 82189fdc93ac337e1de3379d678eca6b7654e6fc (tdf133647 tdf123386 tdf123389 fix DOCX table formula export). Change-Id: Ic7d9c63a5ca989328f7ed33e25e1eda45296b3a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102849 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf123382.docxbin0 -> 17952 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport15.cxx52
2 files changed, 52 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123382.docx b/sw/qa/extras/ooxmlexport/data/tdf123382.docx
new file mode 100644
index 000000000000..cac27ef51832
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123382.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 39a9b103308a..d83e670dab58 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -302,6 +302,58 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123355, "tdf123355.docx")
assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc[4]/w:p/w:r[2]/w:instrText", " =SUM(LEFT)");
}
+DECLARE_OOXMLEXPORT_TEST(testTdf123382, "tdf123382.docx")
+{
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+
+ // Tests conversion of range IDs ABOVE, BELOW, LEFT and RIGHT
+ uno::Reference<text::XTextField> xEnumerationAccess1(xFields->nextElement(), uno::UNO_QUERY);
+ // Note: range ends at B4 here, which is a cell with text content
+ CPPUNIT_ASSERT_EQUAL(OUString("MAX(<B1:D1>)"), xEnumerationAccess1->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("12"), xEnumerationAccess1->getPresentation(false).trim());
+
+ // range ends at the end of the empty cells
+ uno::Reference<text::XTextField> xEnumerationAccess6(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("MAX(<C4:D4>)"), xEnumerationAccess6->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("9"), xEnumerationAccess6->getPresentation(false).trim());
+
+ // range starts at the first cell above D5
+ uno::Reference<text::XTextField> xEnumerationAccess2(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("SUM(<B3:D3>)"), xEnumerationAccess2->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("30"), xEnumerationAccess2->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess3(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("MAX(<C2:A2>)"), xEnumerationAccess3->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("7"), xEnumerationAccess3->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess4(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("MAX(<B2:D2>)"), xEnumerationAccess4->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("7"), xEnumerationAccess4->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess5(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("MAX(<D2:D4>)"), xEnumerationAccess5->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("12"), xEnumerationAccess5->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess7(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("MAX(<B2:B4>)"), xEnumerationAccess7->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("10"), xEnumerationAccess7->getPresentation(false).trim());
+
+ xmlDocUniquePtr pXmlDoc = parseExport();
+ if (!pXmlDoc)
+ return;
+
+ // keep original formula IDs
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:r[2]/w:instrText", " =MAX(RIGHT)");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p/w:r[2]/w:instrText", " =MAX(RIGHT)");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc[1]/w:p/w:r[2]/w:instrText", " =SUM(RIGHT)");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:r[2]/w:instrText", " =MAX(BELOW)");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc[2]/w:p/w:r[2]/w:instrText", " =MAX(RIGHT)");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[4]/w:p/w:r[2]/w:instrText", " =MAX(BELOW)");
+ 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(testTdf98000_changePageStyle, "tdf98000_changePageStyle.odt")
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);