summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-03-09 15:22:57 +0100
committerJan Holesovsky <kendy@collabora.com>2017-05-15 21:58:57 +0200
commit58f894c86505c95f3924fa5e6d0c9523e062430e (patch)
treee5573f1a54668bb19fcdd04d764d63a863e1ee92 /sc
parent4c004a4bb09afbb69a1345d218ae79b6fa011034 (diff)
add ScCaptionPtr::insertToDrawPage()
Change-Id: I1266b55c2558d306b20b0f2d9fba07b0bc46544e
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/postit.hxx13
-rw-r--r--sc/source/core/data/postit.cxx18
2 files changed, 26 insertions, 5 deletions
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index e198870479f6..7266109200c0 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -31,6 +31,7 @@ class EditTextObject;
class OutlinerParaObject;
class SdrCaptionObj;
class SdrPage;
+
class SfxItemSet;
class ScDocument;
class Rectangle;
@@ -58,6 +59,10 @@ public:
// Does not default to nullptr to make it visually obvious where such is used.
void reset( SdrCaptionObj* p );
+ /** Insert to draw page. The caption object is owned by the draw page then.
+ */
+ void insertToDrawPage( 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.
@@ -77,8 +82,12 @@ private:
struct Head
{
- ScCaptionPtr* mpFirst; ///< first in list
- oslInterlockedCount mnRefs; ///< use count
+ ScCaptionPtr* mpFirst; ///< first in list
+ oslInterlockedCount mnRefs; ///< use count
+ bool mbInDrawPage; ///< caption object is owned by draw page
+
+ Head() = delete;
+ explicit Head( ScCaptionPtr* );
};
Head* mpHead; ///< points to the "master" entry
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 2ae4a75d7750..638dfa643204 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -534,12 +534,15 @@ ScCaptionPtr& ScCaptionPtr::operator=( const ScCaptionPtr& r )
return *this;
}
+ScCaptionPtr::Head::Head( ScCaptionPtr* p ) :
+ mpFirst(p), mnRefs(1), mbInDrawPage(false)
+{
+}
+
void ScCaptionPtr::newHead()
{
assert(!mpHead);
- mpHead = new Head;
- mpHead->mpFirst = this;
- mpHead->mnRefs = 1;
+ mpHead = new Head(this);
}
void ScCaptionPtr::replaceInList( ScCaptionPtr* pNew )
@@ -692,6 +695,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;
+}
+
SdrCaptionObj* ScCaptionPtr::release()
{
SdrCaptionObj* pTmp = mpCaption;