diff options
author | Eike Rathke <erack@redhat.com> | 2017-04-10 20:00:52 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-04-10 23:31:59 +0200 |
commit | adcf24117d939f0f2bb0a00d89da3105db134ebf (patch) | |
tree | 7fd56e76d0d238e8a7d10cc73671fefb1ca38695 /sc/source/core | |
parent | b076e8f673d1714ee8b6f991eb2ca299b6fa8949 (diff) |
move implementation from RemoveCaption() to removeFromDrawPageAndFree()
Change-Id: I4f98112c13dfcd5c6c2fdb5b682cca494d63a954
Diffstat (limited to 'sc/source/core')
-rw-r--r-- | sc/source/core/data/postit.cxx | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 2acc07a09939..36d1f82f47fb 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -717,6 +717,30 @@ void ScCaptionPtr::removeFromDrawPage( SdrPage& rDrawPage ) assert(pObj == mpCaption); (void)pObj; } +void ScCaptionPtr::removeFromDrawPageAndFree() +{ + assert(mpHead && mpCaption); + SdrPage* pDrawPage = mpCaption->GetPage(); + SAL_WARN_IF( !pDrawPage, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing page"); + if (pDrawPage) + { + pDrawPage->RecalcObjOrdNums(); + ScDrawLayer* pDrawLayer = dynamic_cast<ScDrawLayer*>(mpCaption->GetModel()); + SAL_WARN_IF( !pDrawLayer, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing layer"); + // create drawing undo action (before removing the object to have valid draw page in undo action) + const bool bRecording = (pDrawLayer && pDrawLayer->IsRecording()); + if (bRecording) + pDrawLayer->AddCalcUndo( new SdrUndoDelObj( *mpCaption )); + // remove the object from the drawing page, delete if undo is disabled + removeFromDrawPage( *pDrawPage ); + if (!bRecording) + { + SdrObject* pObj = release(); + SdrObject::Free( pObj ); + } + } +} + SdrCaptionObj* ScCaptionPtr::release() { SdrCaptionObj* pTmp = mpCaption; @@ -1074,27 +1098,8 @@ void ScPostIt::RemoveCaption() undo documents refer to captions in original document, do not remove them from drawing layer here). */ ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer(); - if( maNoteData.mxCaption && (pDrawLayer == maNoteData.mxCaption->GetModel()) ) - { - OSL_ENSURE( pDrawLayer, "ScPostIt::RemoveCaption - object without drawing layer" ); - SdrPage* pDrawPage = maNoteData.mxCaption->GetPage(); - OSL_ENSURE( pDrawPage, "ScPostIt::RemoveCaption - object without drawing page" ); - if( pDrawPage ) - { - pDrawPage->RecalcObjOrdNums(); - // create drawing undo action (before removing the object to have valid draw page in undo action) - const bool bRecording = (pDrawLayer && pDrawLayer->IsRecording()); - if( bRecording ) - pDrawLayer->AddCalcUndo( new SdrUndoDelObj( *maNoteData.mxCaption.get() ) ); - // remove the object from the drawing page, delete if undo is disabled - maNoteData.mxCaption.removeFromDrawPage( *pDrawPage ); - if( !bRecording ) - { - SdrObject* pObj = maNoteData.mxCaption.release(); - SdrObject::Free( pObj ); - } - } - } + if (maNoteData.mxCaption && (pDrawLayer == maNoteData.mxCaption->GetModel())) + maNoteData.mxCaption.removeFromDrawPageAndFree(); // Either the caption object is gone or, because of Undo or clipboard is // held in at least two instances, or only one instance in Undo because the // original sheet in this document is just deleted, or the Undo document is |