formula/source/core/api/FormulaCompiler.cxx | 17 ++++++++++++----- include/formula/FormulaCompiler.hxx | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-)
New commits: commit 85d800ccc30b28c4c5a310aee0ae6b189427ac03 Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Jul 25 17:40:11 2024 +0200 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Sat Jul 27 03:19: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/+/171030 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 90366e0bcedb..c784116c0e47 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -1240,17 +1240,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); } } @@ -1269,6 +1273,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. @@ -1291,7 +1298,7 @@ void FormulaCompiler::OpCodeMap::copyFrom( const OpCodeMap& r ) default: aSymbol = r.mpTable[i]; } - putCopyOpCode( aSymbol, eOp); + putCopyOpCode( aSymbol, eOp, pCharClass); } } else @@ -1300,7 +1307,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 08710f561b5a..b55e828d3c1d 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: