summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-09-29 11:23:41 +0200
committerEike Rathke <erack@redhat.com>2020-09-29 21:44:38 +0200
commit1acf517906b7cdc4931dd26319d467dff53ae7d2 (patch)
tree01bb319954fcba0cd6ad6a7066e04c16b1a04798
parentd2dc5b389ccf1c51975960660cb8f6ad4a6f928c (diff)
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 <erack@redhat.com>
-rw-r--r--sc/inc/compiler.hxx1
-rw-r--r--sc/source/core/tool/compiler.cxx16
2 files changed, 16 insertions, 1 deletions
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