diff options
author | László Németh <nemeth@numbertext.org> | 2020-08-20 19:41:00 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-08-20 22:05:28 +0200 |
commit | 4d9b72d1c3929eca04c7a2e363ab6214676b0f64 (patch) | |
tree | 7665089d6ac8bdaf9079d091093ed868117a2a41 /writerfilter | |
parent | 64e19525eebd0974f1609300d95a74c1e083e8e3 (diff) |
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@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
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()); } |