diff options
-rw-r--r-- | sc/inc/formulagroup.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 14 | ||||
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 7 |
3 files changed, 23 insertions, 0 deletions
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx index f0dcb4888a72..db37426df05f 100644 --- a/sc/inc/formulagroup.hxx +++ b/sc/inc/formulagroup.hxx @@ -94,6 +94,8 @@ struct FormulaGroupContext ColArray* setCachedColArray( SCTAB nTab, SCCOL nCol, NumArrayType* pNumArray, StrArrayType* pStrArray ); + void discardCachedColArray(SCTAB nTab, SCCOL nCol); + void ensureStrArray( ColArray& rColArray, size_t nArrayLen ); void ensureNumArray( ColArray& rColArray, size_t nArrayLen ); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 21f38f54711d..183a219f1f4a 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2711,7 +2711,10 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 size_t nPos = itBlk->size; ++itBlk; if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) + { + rCxt.discardCachedColArray(nTab, nCol); return formula::VectorRefArray(formula::VectorRefArray::Invalid); + } rtl_uString** pStr = nullptr; if (pColArray->mpStrArray && hasNonEmpty(*pColArray->mpStrArray, nRow1, nRow2)) @@ -2744,7 +2747,10 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 size_t nPos = itBlk->size; ++itBlk; if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) + { + rCxt.discardCachedColArray(nTab, nCol); return formula::VectorRefArray(formula::VectorRefArray::Invalid); + } assert(pColArray->mpStrArray); @@ -2781,13 +2787,18 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 pColArray = copyFirstFormulaBlock(rCxt, itBlk, nRow2+1, nTab, nCol); if (!pColArray) + { // Failed to insert a new cached column array. return formula::VectorRefArray(formula::VectorRefArray::Invalid); + } size_t nPos = itBlk->size; ++itBlk; if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) + { + rCxt.discardCachedColArray(nTab, nCol); return formula::VectorRefArray(formula::VectorRefArray::Invalid); + } const double* pNum = nullptr; rtl_uString** pStr = nullptr; @@ -2817,7 +2828,10 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2 size_t nPos = itBlk->size; ++itBlk; if (!appendToBlock(pDocument, rCxt, *pColArray, nPos, nRow2+1, itBlk, maCells.end())) + { + rCxt.discardCachedColArray(nTab, nCol); return formula::VectorRefArray(formula::VectorRefArray::Invalid); + } if (pColArray->mpStrArray && hasNonEmpty(*pColArray->mpStrArray, nRow1, nRow2)) return formula::VectorRefArray(&(*pColArray->mpNumArray)[nRow1], &(*pColArray->mpStrArray)[nRow1]); diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index cd4a4ccecaf3..4304e1b08e04 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -104,6 +104,13 @@ FormulaGroupContext::ColArray* FormulaGroupContext::setCachedColArray( return &rArray; } +void FormulaGroupContext::discardCachedColArray( SCTAB nTab, SCCOL nCol ) +{ + ColArraysType::iterator itColArray = maColArrays.find(ColKey(nTab, nCol)); + if (itColArray != maColArrays.end()) + maColArrays.erase(itColArray); +} + void FormulaGroupContext::ensureStrArray( ColArray& rColArray, size_t nArrayLen ) { if (rColArray.mpStrArray) |