diff options
author | Eike Rathke <erack@redhat.com> | 2020-09-28 21:02:23 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2020-09-29 00:54:12 +0200 |
commit | 3c6177be2705303044e3de262689d593f3d0f282 (patch) | |
tree | 0bef6428be1e46c48f5d58e5ccaefcfb500f5e9f /formula | |
parent | 6e51adec109ab179f093181856959a6d8dc3d3b2 (diff) |
Resolves: tdf#137091 Use CharClass matching the formula language
... not the current locale. Specifically important for
uppercase/lowercase conversions that may yield different results
for example in Turkish i with/without dot.
Change-Id: I2aa57cdcf530d7a0697c4ffbd5dccb86bb526d8e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103588
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'formula')
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index e6a224fa93a7..e969ecba4344 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -29,6 +29,9 @@ #include <svl/zforlist.hxx> #include <unotools/charclass.hxx> +#include <vcl/svapp.hxx> +#include <vcl/settings.hxx> +#include <comphelper/processfactory.hxx> #include <com/sun/star/sheet/FormulaOpCodeMapEntry.hpp> #include <com/sun/star/sheet/FormulaMapGroup.hpp> #include <com/sun/star/sheet/FormulaMapGroupSpecialOffset.hpp> @@ -140,6 +143,14 @@ void lclPushOpCodeMapEntries( ::std::vector< sheet::FormulaOpCodeMapEntry >& rVe lclPushOpCodeMapEntry( rVec, pTable, *pnOpCodes ); } +CharClass* createCharClassIfNonEnglishUI() +{ + const LanguageTag& rLanguageTag( Application::GetSettings().GetUILanguageTag()); + if (rLanguageTag.getLanguage() == "en") + return nullptr; + return new CharClass( ::comphelper::getProcessComponentContext(), rLanguageTag); +} + class OpCodeList { public: @@ -163,8 +174,8 @@ OpCodeList::OpCodeList(bool bLocalized, const std::pair<const char*, int>* pSymb , mpSymbols(pSymbols) , mbLocalized(bLocalized) { - SvtSysLocale aSysLocale; - const CharClass* pCharClass = (xMap->isEnglish() ? nullptr : aSysLocale.GetCharClassPtr()); + std::unique_ptr<CharClass> xCharClass( xMap->isEnglish() ? nullptr : createCharClassIfNonEnglishUI()); + const CharClass* pCharClass = xCharClass.get(); if (meSepType == FormulaCompiler::SeparatorType::RESOURCE_BASE) { for (sal_uInt16 i = 0; i <= SC_OPCODE_LAST_OPCODE_ID; ++i) @@ -809,8 +820,8 @@ FormulaCompiler::OpCodeMapPtr FormulaCompiler::CreateOpCodeMap( NonConstOpCodeMapPtr xMap = std::make_shared<OpCodeMap>( SC_OPCODE_LAST_OPCODE_ID + 1, false, FormulaGrammar::mergeToGrammar( FormulaGrammar::setEnglishBit( FormulaGrammar::GRAM_EXTERNAL, bEnglish), FormulaGrammar::CONV_UNSPECIFIED)); - SvtSysLocale aSysLocale; - const CharClass* pCharClass = (xMap->isEnglish() ? nullptr : aSysLocale.GetCharClassPtr()); + std::unique_ptr<CharClass> xCharClass( xMap->isEnglish() ? nullptr : createCharClassIfNonEnglishUI()); + const CharClass* pCharClass = xCharClass.get(); for (auto const& rMapEntry : rMapping) { OpCode eOp = OpCode(rMapEntry.Token.OpCode); |