diff options
author | László Németh <nemeth@numbertext.org> | 2020-08-22 17:22:04 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-08-23 13:07:03 +0200 |
commit | f1f27b2487ccfb7a03190ff68eadbfb611dd9749 (patch) | |
tree | dc6bffe8fa118ee797d5f14f51ea26ad1555836c /sw | |
parent | 886c2e35fadc7813498da041fc4ea8a8ba2fb358 (diff) |
tdf#123356 DOCX import: fix COUNT formula
Convert COUNT(x) to the equivalent, but
portable Writer formula SUM(x)/MEAN(x).
Note: this is a temporary conversion, which
supports only 1-level nesting of function calls.
Adding COUNT to Writer core, it will be possible
to remove portable conversion later.
Change-Id: I4b4019aadad52e6d1cf3b2d18d80b1d2c7485c6a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101185
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf123356.docx | bin | 0 -> 41063 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 20 |
2 files changed, 20 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123356.docx b/sw/qa/extras/ooxmlexport/data/tdf123356.docx Binary files differnew file mode 100644 index 000000000000..9432ca2dbb06 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf123356.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index ad96c19673c3..638a43761c76 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -113,6 +113,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123390, "tdf123390.docx") CPPUNIT_ASSERT_EQUAL(OUString("1"), xEnumerationAccess2->getPresentation(false).trim()); } +DECLARE_OOXMLEXPORT_TEST(testTdf123356, "tdf123356.docx") +{ + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + + uno::Reference<text::XTextField> xEnumerationAccess1(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("-11"), xEnumerationAccess1->getPresentation(true).trim()); + CPPUNIT_ASSERT_EQUAL(OUString("-11"), xEnumerationAccess1->getPresentation(false).trim()); + + // Tests cell formula COUNT(x) to SUM(x)/MEAN(x) conversion + uno::Reference<text::XTextField> xEnumerationAccess4(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("(SUM(<A1:C1>|<A2:B2>)/MEAN(<A1:C1>|<A2:B2>))"), xEnumerationAccess4->getPresentation(true).trim()); + CPPUNIT_ASSERT_EQUAL(OUString("5"), xEnumerationAccess4->getPresentation(false).trim()); + + uno::Reference<text::XTextField> xEnumerationAccess3(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("(SUM(<A1:C1>)/MEAN(<A1:C1>))"), xEnumerationAccess3->getPresentation(true).trim()); + CPPUNIT_ASSERT_EQUAL(OUString("3"), xEnumerationAccess3->getPresentation(false).trim()); +} + DECLARE_OOXMLEXPORT_TEST(testTdf98000_changePageStyle, "tdf98000_changePageStyle.odt") { uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); |