[Libreoffice-commits] core.git: sw/qa writerfilter/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 20 20:06:07 UTC 2020
sw/qa/extras/ooxmlexport/data/tdf123390.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 24 ++++++++++++++++++++++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 ++++-
3 files changed, 29 insertions(+), 1 deletion(-)
New commits:
commit 4d9b72d1c3929eca04c7a2e363ab6214676b0f64
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Thu Aug 20 19:41:00 2020 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Thu Aug 20 22:05:28 2020 +0200
tdf#123390 DOCX import: fix SIGN formula
Convert SIGN(x) to the equivalent, but
portable Writer formula (0 < x) - (x < 0).
Note: this is a temporary conversion, which
supports only 1-level nesting of function calls.
Adding SIGN to Writer core, it will be possible
to remove portable conversion later.
Change-Id: I88853fe865808427c966b8570a052b101fecdac0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101085
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123390.docx b/sw/qa/extras/ooxmlexport/data/tdf123390.docx
new file mode 100644
index 000000000000..c3591dbfd2e6
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf123390.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index cd3dc8021f2a..c9cc9bd617c3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -91,6 +91,30 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123354, "tdf123354.docx")
CPPUNIT_ASSERT_EQUAL(OUString("233423"), xEnumerationAccess3->getPresentation(false).trim());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf123390, "tdf123390.docx")
+{
+ // Tests cell formula SIGN(x) to (0 < x) - (x < 0) conversion
+ 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("((0 L (-11)) - ((-11) L 0))"), xEnumerationAccess1->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("-1"), xEnumerationAccess1->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess4(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("((0 L (<B2>)) - ((<B2>) L 0))"), xEnumerationAccess4->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("0"), xEnumerationAccess4->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess3(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("((0 L (0)) - ((0) L 0))"), xEnumerationAccess3->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("0"), xEnumerationAccess3->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess2(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("((0 L (<B1>)) - ((<B1>) L 0))"), xEnumerationAccess2->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), xEnumerationAccess2->getPresentation(false).trim());
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf98000_changePageStyle, "tdf98000_changePageStyle.odt")
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d720e53a2a53..b5a8f124c142 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4264,10 +4264,14 @@ OUString DomainMapper_Impl::convertFieldFormula(const OUString& input) {
icu::RegexMatcher rmatch5("\\bDEFINED\\s*\\(<([A-Z]+[0-9]+)>\\)", usInput, rMatcherFlags, status);
usInput = rmatch5.replaceAll(icu::UnicodeString("DEFINED($1)"), status);
- /* Fix up ABS(x) using SQRT(x POW 2) - it supports only 1-level nesting */
+ /* Fix up ABS(x) using SQRT(x POW 2) (it supports only 1-level nesting) */
icu::RegexMatcher rmatch6("\\bABS\\s*(\\(([^()]*|([^()])*\\([^()]*\\)[^()]*)*\\))", usInput, rMatcherFlags, status);
usInput = rmatch6.replaceAll(icu::UnicodeString("SQRT($1 POW 2)"), status);
+ /* Fix up SIGN(x) using (0 < x) - (x < 0) (it supports only 1-level nesting) */
+ icu::RegexMatcher rmatch7("\\bSIGN\\s*(\\(([^()]*|([^()])*\\([^()]*\\)[^()]*)*\\))", usInput, rMatcherFlags, status);
+ usInput = rmatch7.replaceAll(icu::UnicodeString("((0 L $1) - ($1 L 0))"), status);
+
return OUString(usInput.getTerminatedBuffer());
}
More information about the Libreoffice-commits
mailing list