diff options
Diffstat (limited to 'sc/source/core/data/document.cxx')
-rw-r--r-- | sc/source/core/data/document.cxx | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index a5138984ee3a..4fb535d0df00 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1218,11 +1218,22 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab, SCTAB nTabRangeStart = nStartTab; SCTAB nTabRangeEnd = nEndTab; lcl_GetFirstTabRange( nTabRangeStart, nTabRangeEnd, pTabMark, static_cast<SCTAB>(maTabs.size()) ); + ScRange aShiftedRange(nStartCol, nStartRow, nTabRangeStart, nEndCol, MAXROW, nTabRangeEnd); + sc::EndListeningContext aEndListenCxt(*this); + + std::vector<ScAddress> aGroupPos; do { - UpdateBroadcastAreas( URM_INSDEL, ScRange( - ScAddress( nStartCol, nStartRow, nTabRangeStart ), - ScAddress( nEndCol, MAXROW, nTabRangeEnd )), 0, static_cast<SCsROW>(nSize), 0 ); + aShiftedRange.aStart.SetTab(nTabRangeStart); + aShiftedRange.aEnd.SetTab(nTabRangeEnd); + + // Collect all formula groups that will get split by the shifting, + // and end all their listening. Record the position of the top + // cell of the topmost group, and the postion of the bottom cell + // of the bottommost group. + EndListeningIntersectedGroups(aEndListenCxt, aShiftedRange, &aGroupPos); + + UpdateBroadcastAreas(URM_INSDEL, aShiftedRange, 0, static_cast<SCsROW>(nSize), 0); } while ( lcl_GetNextTabRange( nTabRangeStart, nTabRangeEnd, pTabMark, static_cast<SCTAB>(maTabs.size()) ) ); @@ -1230,14 +1241,21 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab, sc::RefUpdateContext aCxt(*this); aCxt.meMode = URM_INSDEL; - aCxt.maRange = ScRange(nStartCol, nStartRow, nTabRangeStart, nEndCol, MAXROW, nTabRangeEnd); + aCxt.maRange = aShiftedRange; aCxt.mnRowDelta = nSize; do { + aCxt.maRange.aStart.SetTab(nTabRangeStart); + aCxt.maRange.aEnd.SetTab(nTabRangeEnd); UpdateReference(aCxt, pRefUndoDoc, false); // without drawing objects } while ( lcl_GetNextTabRange( nTabRangeStart, nTabRangeEnd, pTabMark, static_cast<SCTAB>(maTabs.size()) ) ); + // UpdateReference should have set "needs listening" flags to those + // whose references have been modified. We also need to set this flag + // to those that were in the groups that got split by shifting. + SetNeedsListeningGroups(aGroupPos); + for (i=nStartTab; i<=nEndTab && i < static_cast<SCTAB>(maTabs.size()); i++) if (maTabs[i] && (!pTabMark || pTabMark->GetTableSelect(i))) maTabs[i]->InsertRow( nStartCol, nEndCol, nStartRow, nSize ); |