diff options
author | Eike Rathke <erack@redhat.com> | 2017-03-09 22:09:55 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-03-09 22:10:22 +0100 |
commit | 646a1d20974ff13b908a85cdff37c2701d582d8f (patch) | |
tree | 2dd1f03b1da6b3560f63b3c79383a19eb7e515f4 | |
parent | b3354ad2482737b49bd8d7593d355671197c4551 (diff) |
add/use ScCaptionPtr::removeFromDrawPage()
Change-Id: Ibe073f071b120b61738b7e813a14824248f1fcfc
-rw-r--r-- | sc/inc/postit.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/postit.cxx | 18 |
2 files changed, 21 insertions, 2 deletions
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx index dfb88c1428a8..c61df47be866 100644 --- a/sc/inc/postit.hxx +++ b/sc/inc/postit.hxx @@ -63,6 +63,11 @@ public: */ void insertToDrawPage( SdrPage& rDrawPage ); + /** Remove from draw page. The caption object is not owned anymore by the + draw page then. + */ + void removeFromDrawPage( SdrPage& rDrawPage ); + /** Release all management of the SdrCaptionObj* in all instances of this list and dissolve. The SdrCaptionObj pointer returned is ready to be managed elsewhere. diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 8ed2e9f0d7ff..c01b6d772cc5 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -710,6 +710,20 @@ void ScCaptionPtr::insertToDrawPage( SdrPage& rDrawPage ) mpHead->mbInDrawPage = true; } +void ScCaptionPtr::removeFromDrawPage( SdrPage& rDrawPage ) +{ + assert(mpHead && mpCaption); + SAL_WARN_IF(!mpHead->mbInDrawPage,"sc.core","ScCaptionPtr::removeFromDrawPage - not in draw page"); + /* FIXME: that should assert, but currently fails in + * Test::testCopyToDocument() probably due to CopyStaticToDocument() + * lacking something. */ + //assert(mpHead->mbInDrawPage); // did we lose track anywhere? + + SdrObject* pObj = rDrawPage.RemoveObject( mpCaption->GetOrdNum() ); + assert(pObj == mpCaption); (void)pObj; + mpHead->mbInDrawPage = false; +} + SdrCaptionObj* ScCaptionPtr::release() { SdrCaptionObj* pTmp = mpCaption; @@ -1081,10 +1095,10 @@ void ScPostIt::RemoveCaption() if( bRecording ) pDrawLayer->AddCalcUndo( new SdrUndoDelObj( *maNoteData.mxCaption.get() ) ); // remove the object from the drawing page, delete if undo is disabled - SdrObject* pObj = pDrawPage->RemoveObject( maNoteData.mxCaption->GetOrdNum() ); + maNoteData.mxCaption.removeFromDrawPage( *pDrawPage ); if( !bRecording ) { - maNoteData.mxCaption.release(); + SdrObject* pObj = maNoteData.mxCaption.release(); SdrObject::Free( pObj ); } } |