can't keep track of drawlayer insertion

Draw Undo independently can reinsert a caption to the drawlayer, which
is beyond our knowledge. To track that cumbersome manual tracking (or
callbacks or whatever) would be needed, which actually this tries to get
rid of instead of increasing..

Change-Id: I373843ad61d0b6e19b9d3f98fd8f9e01a448296d
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index fde974b..4c0c10b 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -89,7 +89,6 @@ private:
    {
        ScCaptionPtr*       mpFirst;        ///< first in list
        oslInterlockedCount mnRefs;         ///< use count
        bool                mbInDrawPage;   ///< caption object is owned by draw page

        Head() = delete;
        explicit Head( ScCaptionPtr* );
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 9568148..9bd602b 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -535,7 +535,7 @@ ScCaptionPtr& ScCaptionPtr::operator=( const ScCaptionPtr& r )
}

ScCaptionPtr::Head::Head( ScCaptionPtr* p ) :
    mpFirst(p), mnRefs(1), mbInDrawPage(false)
    mpFirst(p), mnRefs(1)
{
}

@@ -686,7 +686,8 @@ void ScCaptionPtr::decRefAndDestroy()
        assert(mpHead->mpFirst == this);    // this must be one and only one
        assert(!mpNext);                    // this must be one and only one
        assert(mpCaption);
        if (mpHead->mbInDrawPage)
#if 0
        if (what?)
        {
            /* FIXME: this should eventually remove the caption from drawing layer
             * foo and call SdrObject::Free(), likely with mpCaption, see
@@ -695,6 +696,7 @@ void ScCaptionPtr::decRefAndDestroy()
        }
        /* FIXME: once we got ownership right */
        //SdrObject::Free( mpCaption );
#endif
        mpCaption = nullptr;
        delete mpHead;
        mpHead = nullptr;
@@ -704,24 +706,15 @@ void ScCaptionPtr::decRefAndDestroy()
void ScCaptionPtr::insertToDrawPage( SdrPage& rDrawPage )
{
    assert(mpHead && mpCaption);
    assert(!mpHead->mbInDrawPage);  // multiple assignments not possible

    rDrawPage.InsertObject( mpCaption );
    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()