sc/inc/documentimport.hxx | 2 ++ sc/source/core/data/documentimport.cxx | 14 ++++++++++++++ sc/source/filter/oox/sheetdatabuffer.cxx | 16 ++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-)
New commits: commit 0f62288b989f78e3e757aa7f3811c9fad03c1c0d Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Feb 16 11:14:48 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Mar 1 22:25:32 2022 +0100 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. Change-Id: Ic2814ecbeafdeb99632d2a255ed6c1dedf7376b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130151 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit fea55f5ef8dba16706033c9efdd33c45477eb333) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130309 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Eike Rathke <er...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx index cefe2949dcc7..0e49e073fd62 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 2dbc61c03938..d2350c1cdb6b 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -96,6 +96,15 @@ struct ScDocumentImportImpl return rTab.getBlockPosition(nCol); } + void invalidateBlockPositionSet(SCTAB nTab) + { + if (o3tl::make_unsigned(nTab) >= maBlockPosSet.size()) + return; + + sc::TableColumnBlockPositionSet& rTab = maBlockPosSet[nTab]; + rTab.invalidate(); + } + void initForSheets() { size_t n = mrDoc.GetTableCount(); @@ -183,6 +192,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 e497ee44f8d8..29de63bdb9f4 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -443,9 +443,22 @@ void SheetDataBuffer::addColXfStyleProcessRowRanges() 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 ) @@ -458,7 +471,6 @@ void SheetDataBuffer::finalizeImport() addColXfStyleProcessRowRanges(); - ScDocumentImport& rDocImport = getDocImport(); ScDocument& rDoc = rDocImport.getDoc(); StylesBuffer& rStyles = getStyles(); for ( const auto& [rCol, rRowStyles] : maStylesPerColumn )