diff options
author | László Németh <nemeth@numbertext.org> | 2022-11-09 13:35:11 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-11-09 16:34:48 +0100 |
commit | 94bf4908a6661101c270ef647e33dde09f16ac08 (patch) | |
tree | 64e7f67b7e732ec126ed2a8a3e1aed8723d94049 /writerfilter | |
parent | aa8a8b36b73304431bacd7ed0f8803de8dfffe3e (diff) |
tdf#148799 DOCX import: fix invalid formulas with comma
Writer formulas must contain decimal points instead of commas,
otherwise automatic update of the formulas, e.g. moving text
cursor in the table, results ** Expression is faulty ** instead
of the recalculated value. The only way to get standard
Writer formulas is to replace the commas with points in numbers
in writerfilter.
Note: only formula cells support comma localization,
but not formula fields yet, so the recalculated values show
decimal point instead of decimal comma.
Follow-up to commit 1abf4e6d07ca0ac31bc54f812df84efc82d2af1b
"DOCX import: don't throw away cached value of SwHiddenTextField ...",
see also tdf#136106.
Change-Id: Id5e6dc2b87afc4e8fda0d5c4347ba7942a8989b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142488
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index b5afddc7a494..0e436fe165b9 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -5552,6 +5552,13 @@ OUString DomainMapper_Impl::convertFieldFormula(const OUString& input) { icu::RegexMatcher rmatch6("\\b(ABOVE|BELOW|LEFT|RIGHT)\\b", usInput, rMatcherFlags, status); usInput = rmatch6.replaceAll(icu::UnicodeString(" $1 "), status); + /* fix decimal separator */ + if ( m_pSettingsTable->GetDecimalSymbol() == "," ) + { + icu::RegexMatcher rmatch7("\\b([0-9]+),([0-9]+([eE][-]?[0-9]+)?)\\b", usInput, rMatcherFlags, status); + usInput = rmatch7.replaceAll(icu::UnicodeString("$1.$2"), status); + } + return OUString(usInput.getTerminatedBuffer()); } |