summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-09-28 21:02:23 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2020-09-30 14:04:32 +0200
commit30d3ae0268290e6244e58c78b8f45ae7373c47ea (patch)
treef4a0f6afd06790e2199e5af08ec09c760475b4aa /formula
parent831a9b465ac82ec8d27186329d6596ef5e9e4601 (diff)
Resolves: tdf#137091 Use CharClass matching the formula language
This is a combination of 3 commits. 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. I2aa57cdcf530d7a0697c4ffbd5dccb86bb526d8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103588 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit 3c6177be2705303044e3de262689d593f3d0f282) Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Current sytem locale's CharClass for user defined names, tdf#137091 follow-up I5f025a12ca183acb3f80d2a7527677aceb9ffbd5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103593 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit d41c45a522c5e973d7043d36bc6c82e77735ab9b) Determine CharClass difference once, tdf#137091 follow-up As a side note: Clang plugin simplifybool for !(rLT1.getLanguage() == "en" && rLT2.getLanguage() == "en") told "error: logical negation of logical op containing negation, can be simplified" which is nonsense (the message stayed the same while the checks evolved). It actually complained about !(a==b && c==d) to be rewritten as (a!=b || c!=d) whether that makes sense or not.. it may save one boolean operation, yes, but.. Ib478d46d7ff926c1c9f65fec059c7a3f31fa7ce3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103601 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit 1acf517906b7cdc4931dd26319d467dff53ae7d2) Conflicts: sc/source/core/tool/compiler.cxx Change-Id: I2aa57cdcf530d7a0697c4ffbd5dccb86bb526d8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103598 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'formula')
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx19
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);