formula/source/core/api/FormulaCompiler.cxx | 17 ++++++++++++----- include/formula/FormulaCompiler.hxx | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-)
New commits: commit 8648ca116ccfa47211b711905ec13809431a7985 Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Jul 25 17:40:11 2024 +0200 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Fri Jul 26 15:39:45 2024 +0200 Resolves: tdf#162087 FormulaCompiler::OpCodeMap::maHashMap must be uppercase which is the case for all English function names, but not the TableRef item specifiers like #All, #Data, ... Change-Id: I7f675e05b0d52eac9596b96b4d2cf299351fb82a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171022 Tested-by: Jenkins Reviewed-by: Eike Rathke <er...@redhat.com> (cherry picked from commit dc9486f2443fa52588b625c0a2a288bff56a7a45) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171031 Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 8f0dd62d6ace..93886a061b25 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -1282,17 +1282,21 @@ bool FormulaCompiler::IsMatrixFunction( OpCode eOpCode ) } -void FormulaCompiler::OpCodeMap::putCopyOpCode( const OUString& rSymbol, OpCode eOp ) +void FormulaCompiler::OpCodeMap::putCopyOpCode( const OUString& rSymbol, OpCode eOp, const CharClass* pCharClass ) { SAL_WARN_IF( !mpTable[eOp].isEmpty() && rSymbol.isEmpty(), "formula.core", "OpCodeMap::putCopyOpCode: NOT replacing OpCode " << static_cast<sal_uInt16>(eOp) << " '" << mpTable[eOp] << "' with empty name!"); if (!mpTable[eOp].isEmpty() && rSymbol.isEmpty()) - maHashMap.emplace(mpTable[eOp], eOp); + { + OUString aUpper( pCharClass ? pCharClass->uppercase( mpTable[eOp]) : mpTable[eOp].toAsciiUpperCase()); + maHashMap.emplace(aUpper, eOp); + } else { + OUString aUpper( pCharClass ? pCharClass->uppercase( rSymbol) : rSymbol.toAsciiUpperCase()); mpTable[eOp] = rSymbol; - maHashMap.emplace(rSymbol, eOp); + maHashMap.emplace(aUpper, eOp); } } @@ -1311,6 +1315,9 @@ void FormulaCompiler::OpCodeMap::copyFrom( const OpCodeMap& r ) "OpCodeMap::copyFrom: OpCode 0 assigned, this: '" << mpTable[0] << "' that: '" << r.mpTable[0] << "'"); + std::unique_ptr<CharClass> xCharClass( r.mbEnglish ? nullptr : createCharClassIfNonEnglishUI()); + const CharClass* pCharClass = xCharClass.get(); + // For bOverrideKnownBad when copying from the English core map (ODF 1.1 // and API) to the native map (UI "use English function names") replace the // known bad legacy function names with correct ones. @@ -1333,7 +1340,7 @@ void FormulaCompiler::OpCodeMap::copyFrom( const OpCodeMap& r ) default: aSymbol = r.mpTable[i]; } - putCopyOpCode( aSymbol, eOp); + putCopyOpCode( aSymbol, eOp, pCharClass); } } else @@ -1342,7 +1349,7 @@ void FormulaCompiler::OpCodeMap::copyFrom( const OpCodeMap& r ) { OpCode eOp = OpCode(i); const OUString& rSymbol = r.mpTable[i]; - putCopyOpCode( rSymbol, eOp); + putCopyOpCode( rSymbol, eOp, pCharClass); } } diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx index 11a49f4680a0..f3488408fbb8 100644 --- a/include/formula/FormulaCompiler.hxx +++ b/include/formula/FormulaCompiler.hxx @@ -195,7 +195,7 @@ public: Does NOT check eOp range! */ - void putCopyOpCode( const OUString& rSymbol, OpCode eOp ); + void putCopyOpCode( const OUString& rSymbol, OpCode eOp, const CharClass* pCharClass ); }; public: