sc/inc/compiler.hxx              |    1 +
 sc/source/core/tool/compiler.cxx |   16 +++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 1acf517906b7cdc4931dd26319d467dff53ae7d2
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Tue Sep 29 11:23:41 2020 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Tue Sep 29 21:44:38 2020 +0200

    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..
    
    Change-Id: Ib478d46d7ff926c1c9f65fec059c7a3f31fa7ce3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103601
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index c4550a2ae3f6..a8ea757922b1 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -287,6 +287,7 @@ private:
     std::queue<OpCode> maPendingOpCodes; // additional opcodes generated from 
a single symbol
 
     const CharClass* pCharClass; // which character classification is used for 
parseAnyToken and upper/lower
+    bool        mbCharClassesDiffer;    // whether pCharClass and current 
system locale's CharClass differ
     sal_uInt16      mnPredetectedReference;     // reference when reading ODF, 
0 (none), 1 (single) or 2 (double)
     sal_Int32   mnRangeOpPosInSymbol;       // if and where a range operator 
is in symbol
     const Convention *pConv;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index f4967ec2381f..98ff152e30a9 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -294,6 +294,16 @@ void ScCompiler::SetFormulaLanguage( const 
ScCompiler::OpCodeMapPtr & xMap )
         pCharClass = GetCharClassEnglish();
     else
         pCharClass = GetCharClassLocalized();
+
+    // The difference is needed for an uppercase() call that usually does not
+    // result in different strings but for a few languages like Turkish;
+    // though even de-DE and de-CH may differ in ß/SS handling..
+    // At least don't care if both are English.
+    // The current locale is more likely to not be "en" so check first.
+    const LanguageTag& rLT1 = ScGlobal::getCharClassPtr()->getLanguageTag();
+    const LanguageTag& rLT2 = pCharClass->getLanguageTag();
+    mbCharClassesDiffer = (rLT1 != rLT2 && (rLT1.getLanguage() != "en" || 
rLT2.getLanguage() != "en"));
+
     SetGrammarAndRefConvention( mxSymbols->getGrammar(), GetGrammar());
 }
 
@@ -1832,6 +1842,7 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, 
const ScAddress& rPos,
     mnCurrentSheetTab(-1),
     mnCurrentSheetEndPos(0),
     pCharClass(ScGlobal::getCharClassPtr()),
+    mbCharClassesDiffer(false),
     mnPredetectedReference(0),
     mnRangeOpPosInSymbol(-1),
     pConv(GetRefConvention(FormulaGrammar::CONV_OOO)),
@@ -1855,6 +1866,7 @@ ScCompiler::ScCompiler( ScDocument& rDocument, const 
ScAddress& rPos, ScTokenArr
         mnCurrentSheetEndPos(0),
         nSrcPos(0),
         pCharClass( ScGlobal::getCharClassPtr() ),
+        mbCharClassesDiffer(false),
         mnPredetectedReference(0),
         mnRangeOpPosInSymbol(-1),
         pConv( GetRefConvention( FormulaGrammar::CONV_OOO ) ),
@@ -1877,6 +1889,7 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, 
const ScAddress& rPos,
     mnCurrentSheetTab(-1),
     mnCurrentSheetEndPos(0),
     pCharClass(ScGlobal::getCharClassPtr()),
+    mbCharClassesDiffer(false),
     mnPredetectedReference(0),
     mnRangeOpPosInSymbol(-1),
     pConv(GetRefConvention(FormulaGrammar::CONV_OOO)),
@@ -1900,6 +1913,7 @@ ScCompiler::ScCompiler( ScDocument& rDocument, const 
ScAddress& rPos,
         mnCurrentSheetEndPos(0),
         nSrcPos(0),
         pCharClass( ScGlobal::getCharClassPtr() ),
+        mbCharClassesDiffer(false),
         mnPredetectedReference(0),
         mnRangeOpPosInSymbol(-1),
         pConv( GetRefConvention( FormulaGrammar::CONV_OOO ) ),
@@ -4411,7 +4425,7 @@ bool ScCompiler::NextNewToken( bool bInArray )
             return true;
 
         // User defined names and such do need i18n upper also in ODF.
-        if (bAsciiUpper || pCharClass->getLanguageTag() != 
ScGlobal::getCharClassPtr()->getLanguageTag())
+        if (bAsciiUpper || mbCharClassesDiffer)
         {
             // Use current system locale here because user defined symbols are
             // more likely in that localized language than in the formula
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to