summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-03-09 22:09:55 +0100
committerHenry Castro <hcastro@collabora.com>2017-05-02 18:59:07 -0400
commitd18f568cea0f3e9235ac842a891e597fbe689bf0 (patch)
tree2f825e36271bcdd44b7cb2695ee5e2ad611c64f9
parenta1b940dd78c36345452188b1cfcb0ba06511100e (diff)
add/use ScCaptionPtr::removeFromDrawPage()
Change-Id: Ibe073f071b120b61738b7e813a14824248f1fcfc
-rw-r--r--sc/inc/postit.hxx5
-rw-r--r--sc/source/core/data/postit.cxx18
2 files changed, 21 insertions, 2 deletions
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index b69acbfddb4e..9159476723dc 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 ee9b89e78ef7..66e91517338e 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 );
}
}