diff options
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/column2.cxx | 21 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/column4.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 9 |
4 files changed, 33 insertions, 4 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 967c35e481ab..534708289918 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1816,8 +1816,27 @@ void ScColumn::SetCellNote(SCROW nRow, ScPostIt* pNote) maCellNotes.set(nRow, pNote); } -void ScColumn::DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 ) +namespace { +class ForgetCellNoteCaptionsHandler +{ + +public: + ForgetCellNoteCaptionsHandler() {} + + void operator() ( size_t /*nRow*/, ScPostIt* p ) + { + p->ForgetCaption(); + } +}; +} + +void ScColumn::DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership ) { + if (bForgetCaptionOwnership) + { + ForgetCellNoteCaptionsHandler aFunc; + sc::ParseNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc); + } rBlockPos.miCellNotePos = maCellNotes.set_empty(rBlockPos.miCellNotePos, nRow1, nRow2); } diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index d5558e5087d6..0bcc2066f91d 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -684,7 +684,10 @@ void ScColumn::DeleteArea( } if (nDelFlag & IDF_NOTE) - DeleteCellNotes(aBlockPos, nStartRow, nEndRow); + { + bool bForgetCaptionOwnership = ((nDelFlag & IDF_FORGETCAPTIONS) != IDF_NONE); + DeleteCellNotes(aBlockPos, nStartRow, nEndRow, bForgetCaptionOwnership); + } if ( nDelFlag & IDF_EDITATTR ) { diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 46b59c04b6a0..ac09eac472ce 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -114,7 +114,7 @@ void ScColumn::DeleteBeforeCopyFromClip( } if (nDelFlag & IDF_NOTE) - DeleteCellNotes(aBlockPos, nRow1, nRow2); + DeleteCellNotes(aBlockPos, nRow1, nRow2, false); if (nDelFlag & IDF_EDITATTR) RemoveEditAttribs(nRow1, nRow2); diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index 1430a12df683..8748a7b473c5 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1243,7 +1243,14 @@ void ScUndoDragDrop::DoUndo( ScRange aRange ) // do not undo objects and note captions, they are handled via drawing undo InsertDeleteFlags nUndoFlags = (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS; - rDoc.DeleteAreaTab( aRange, nUndoFlags ); + // Additionally discard/forget caption ownership during deletion, as + // Drag&Drop is a special case in that the Undo holds captions of the + // transfered target range, which would get deleted and + // SdrGroupUndo::Undo() would attempt to access invalidated captions and + // crash, tdf#92995 + InsertDeleteFlags nDelFlags = nUndoFlags | IDF_FORGETCAPTIONS; + + rDoc.DeleteAreaTab( aRange, nDelFlags ); pRefUndoDoc->CopyToDocument( aRange, nUndoFlags, false, &rDoc ); if ( rDoc.HasAttrib( aRange, HASATTR_MERGED ) ) rDoc.ExtendMerge( aRange, true ); |