diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-02-16 11:14:48 +0000 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-02-22 13:19:01 +0100 |
commit | 21653331a609100a4e005b922730a564b0c020b7 (patch) | |
tree | 0fc7c12357c1218a101d439e07692b82bb46d4c0 /sc | |
parent | 441b43b300673eeb024140b45696180f2542f752 (diff) |
clear ScDocumentImport position cache if iterators are invalid
SheetDataBuffer::finalizeArrayFormula calls
ScCellRangeObj::setArrayTokens
ScDocFunc::EnterMatrix
ScDocument::InsertMatrixFormula
and InsertMatrixFormula calls the variant of ScColumn::SetFormulaCell
which doesn't take a sc::ColumnBlockPosition& param when SetFormulaCell
adds a cell to the column so any iterators belonging to ScDocumentImport
are invalid.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130151
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit fea55f5ef8dba16706033c9efdd33c45477eb333)
Change-Id: Ic2814ecbeafdeb99632d2a255ed6c1dedf7376b1
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/documentimport.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/documentimport.cxx | 14 | ||||
-rw-r--r-- | sc/source/filter/oox/sheetdatabuffer.cxx | 16 |
3 files changed, 30 insertions, 2 deletions
diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx index 758469f258a6..ed77561a5153 100644 --- a/sc/inc/documentimport.hxx +++ b/sc/inc/documentimport.hxx @@ -125,6 +125,8 @@ public: void setMergedCells(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + void invalidateBlockPositionSet(SCTAB nTab); + void finalize(); /** Broadcast all formula cells that are marked with diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index e5c0cfbef37e..739a62d553ca 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -92,6 +92,15 @@ struct ScDocumentImportImpl return rTab.getBlockPosition(nCol); } + void invalidateBlockPositionSet(SCTAB nTab) + { + if (sal_uInt16(nTab) >= maBlockPosSet.size()) + return; + + sc::TableColumnBlockPositionSet& rTab = maBlockPosSet[nTab]; + rTab.invalidate(); + } + void initForSheets() { size_t n = mrDoc.GetTableCount(); @@ -179,6 +188,11 @@ void ScDocumentImport::setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uI mpImpl->mrDoc.pDocOptions->SetDate(nDay, nMonth, nYear); } +void ScDocumentImport::invalidateBlockPositionSet(SCTAB nTab) +{ + mpImpl->invalidateBlockPositionSet(nTab); +} + void ScDocumentImport::setAutoInput(const ScAddress& rPos, const OUString& rStr, const ScSetStringParam* pStringParam) { ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab()); diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index 03b35ef76e35..61539c8f90af 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -401,9 +401,22 @@ void SheetDataBuffer::addColXfStyle( sal_Int32 nXfId, sal_Int32 nFormatId, const void SheetDataBuffer::finalizeImport() { + ScDocumentImport& rDocImport = getDocImport(); + + SCTAB nStartTabInvalidatedIters(SCTAB_MAX); + SCTAB nEndTabInvalidatedIters(0); + // create all array formulas for( const auto& [rRange, rTokens] : maArrayFormulas ) - finalizeArrayFormula( rRange, rTokens ); + { + finalizeArrayFormula(rRange, rTokens); + + nStartTabInvalidatedIters = std::min(rRange.aStart.Tab(), nStartTabInvalidatedIters); + nEndTabInvalidatedIters = std::max(rRange.aEnd.Tab(), nEndTabInvalidatedIters); + } + + for (SCTAB nTab = nStartTabInvalidatedIters; nTab <= nEndTabInvalidatedIters; ++nTab) + rDocImport.invalidateBlockPositionSet(nTab); // create all table operations for( const auto& [rRange, rModel] : maTableOperations ) @@ -439,7 +452,6 @@ void SheetDataBuffer::finalizeImport() } } - ScDocumentImport& rDocImport = getDocImport(); ScDocument& rDoc = rDocImport.getDoc(); StylesBuffer& rStyles = getStyles(); for ( const auto& [rCol, rRowStyles] : maStylesPerColumn ) |