summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-08-05 12:43:36 +0200
committerEike Rathke <erack@redhat.com>2022-08-06 11:19:01 +0200
commit28c4c72a4e81821d9e567757725937f74a6d114f (patch)
treed88af81c9928bad45b4b2b47a0e71d23b8dd9092 /sc/source/core
parent7fba323df141be9eddbce39bec0c0f7ee412a7f7 (diff)
Related: tdf#135993 Destroy temporary OpCodeMap when reading config
Initialized at FormulaCompiler base class instance it lacks AddIn mapping and a still existing OpCodeMap prevents necessary reinitialization from derived ScCompiler instance later. Change-Id: I0c2db41dd45829abfb8460730264f097ab76ab2e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137881 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/tool/calcconfig.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index f1673e0ebe68..27836704dab9 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -187,7 +187,11 @@ bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes)
{
OUStringBuffer result(256);
+ // If GetOpCodeMap() initializes the map at base class
+ // formula::FormulaCompiler before any ScCompiler did, all AddIn mapping
+ // would be missing also in future. So if it didn't exist destroy it again.
formula::FormulaCompiler aCompiler;
+ const bool bTemporary = !aCompiler.HasOpCodeMap(css::sheet::FormulaLanguage::ENGLISH);
formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH));
for (auto i = rOpCodes->begin(); i != rOpCodes->end(); ++i)
@@ -197,13 +201,18 @@ OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes)
result.append(pOpCodeMap->getSymbol(*i));
}
+ if (bTemporary)
+ aCompiler.DestroyOpCodeMap(css::sheet::FormulaLanguage::ENGLISH);
+
return result.makeStringAndClear();
}
ScCalcConfig::OpCodeSet ScStringToOpCodeSet(std::u16string_view rOpCodes)
{
ScCalcConfig::OpCodeSet result = std::make_shared<o3tl::sorted_vector< OpCode >>();
+ // Same as above.
formula::FormulaCompiler aCompiler;
+ const bool bTemporary = !aCompiler.HasOpCodeMap(css::sheet::FormulaLanguage::ENGLISH);
formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH));
const formula::OpCodeHashMap& rHashMap(pOpCodeMap->getHashMap());
@@ -234,6 +243,10 @@ ScCalcConfig::OpCodeSet ScStringToOpCodeSet(std::u16string_view rOpCodes)
// HACK: Both unary and binary minus have the same string but different opcodes.
if( result->find( ocSub ) != result->end())
result->insert( ocNegSub );
+
+ if (bTemporary)
+ aCompiler.DestroyOpCodeMap(css::sheet::FormulaLanguage::ENGLISH);
+
return result;
}