summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/document.hxx4
-rw-r--r--sc/source/core/data/column2.cxx2
-rw-r--r--sc/source/core/data/document.cxx4
-rw-r--r--sc/source/core/data/grouptokenconverter.cxx18
-rw-r--r--sc/source/core/inc/grouptokenconverter.hxx1
5 files changed, 24 insertions, 5 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index e0237ac301f8..f860dbc574ed 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -299,7 +299,7 @@ private:
rtl::Reference<ScPoolHelper> xPoolHelper;
std::shared_ptr<svl::SharedStringPool> mpCellStringPool;
- std::unique_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt;
+ std::shared_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt;
mutable std::unique_ptr<sc::DocumentLinkManager> mpDocLinkMgr;
ScCalcConfig maCalcConfig;
@@ -1050,7 +1050,7 @@ public:
svl::SharedString GetSharedString( const ScAddress& rPos ) const;
- sc::FormulaGroupContext& GetFormulaGroupContext();
+ std::shared_ptr<sc::FormulaGroupContext>& GetFormulaGroupContext();
SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString );
sal_uInt16 GetStringForFormula( const ScAddress& rPos, OUString& rString );
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 19a7aede99f5..a32b2f77fc04 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2560,7 +2560,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
return formula::VectorRefArray(formula::VectorRefArray::Invalid);
// See if the requested range is already cached.
- sc::FormulaGroupContext& rCxt = pDocument->GetFormulaGroupContext();
+ sc::FormulaGroupContext& rCxt = *(pDocument->GetFormulaGroupContext());
sc::FormulaGroupContext::ColArray* pColArray = rCxt.getCachedColArray(nTab, nCol, nRow2+1);
if (pColArray)
{
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f9f3933dbf6c..2fcce0776df6 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3443,12 +3443,12 @@ svl::SharedString ScDocument::GetSharedString( const ScAddress& rPos ) const
return maTabs[rPos.Tab()]->GetSharedString(rPos.Col(), rPos.Row());
}
-sc::FormulaGroupContext& ScDocument::GetFormulaGroupContext()
+std::shared_ptr<sc::FormulaGroupContext>& ScDocument::GetFormulaGroupContext()
{
if (!mpFormulaGroupCxt)
mpFormulaGroupCxt.reset(new sc::FormulaGroupContext);
- return *mpFormulaGroupCxt;
+ return mpFormulaGroupCxt;
}
void ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString )
diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx
index da3964cf9864..22b89a6cb510 100644
--- a/sc/source/core/data/grouptokenconverter.cxx
+++ b/sc/source/core/data/grouptokenconverter.cxx
@@ -135,6 +135,15 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode)
formula::SingleVectorRefToken aTok(aArray, nLen, nTrimLen);
mrGroupTokens.AddToken(aTok);
+
+ if (nTrimLen && !mxFormulaGroupContext)
+ {
+ //tdf#98880 if the SingleVectorRefToken relies on the
+ //underlying storage provided by the Document
+ //FormulaGroupContext, take a reference to it here to
+ //ensure that backing storage exists for our lifetime
+ mxFormulaGroupContext = mrDoc.GetFormulaGroupContext();
+ }
}
else
{
@@ -210,6 +219,15 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode)
formula::DoubleVectorRefToken aTok(aArrays, nRequestedLength, nArrayLength, nRefRowSize, bAbsFirst, bAbsLast);
mrGroupTokens.AddToken(aTok);
+
+ if (nArrayLength && !aArrays.empty() && !mxFormulaGroupContext)
+ {
+ //tdf#98880 if the DoubleVectorRefToken relies on the
+ //underlying storage provided by the Document
+ //FormulaGroupContext, take a reference to it here to
+ //ensure that backing storage exists for our lifetime
+ mxFormulaGroupContext = mrDoc.GetFormulaGroupContext();
+ }
}
break;
case svIndex:
diff --git a/sc/source/core/inc/grouptokenconverter.hxx b/sc/source/core/inc/grouptokenconverter.hxx
index 9685681886e0..7b88004e9d5c 100644
--- a/sc/source/core/inc/grouptokenconverter.hxx
+++ b/sc/source/core/inc/grouptokenconverter.hxx
@@ -20,6 +20,7 @@ class SC_DLLPUBLIC ScGroupTokenConverter
{
ScTokenArray& mrGroupTokens;
ScDocument& mrDoc;
+ std::shared_ptr<sc::FormulaGroupContext> mxFormulaGroupContext;
ScFormulaCell& mrCell;
const ScAddress& mrPos;