LibreOffice Module sc (master)  1
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ScCaptionPtr Class Reference

Some desperate attempt to fight against the caption object ownership mess, to which none of shared/weak/plain pointer is a cure. More...

#include <postit.hxx>

Collaboration diagram for ScCaptionPtr:
[legend]

Classes

struct  Head
 

Public Member Functions

 ScCaptionPtr ()
 
 ScCaptionPtr (SdrCaptionObj *p)
 
 ScCaptionPtr (const ScCaptionPtr &r)
 
 ScCaptionPtr (ScCaptionPtr &&r) noexcept
 
 ~ScCaptionPtr ()
 
ScCaptionPtroperator= (const ScCaptionPtr &r)
 
ScCaptionPtroperator= (ScCaptionPtr &&r) noexcept
 
 operator bool () const
 
const SdrCaptionObjget () const
 
SdrCaptionObjget ()
 
const SdrCaptionObjoperator-> () const
 
SdrCaptionObjoperator-> ()
 
const SdrCaptionObjoperator* () const
 
SdrCaptionObjoperator* ()
 
void reset (SdrCaptionObj *p)
 
void insertToDrawPage (SdrPage &rDrawPage)
 Insert to draw page. More...
 
void removeFromDrawPage (SdrPage &rDrawPage)
 Remove from draw page. More...
 
void removeFromDrawPageAndFree (bool bIgnoreUndo=false)
 Remove from draw page and free caption object if no Undo recording. More...
 
SdrCaptionObjrelease ()
 Release all management of the SdrCaptionObj* in all instances of this list and dissolve. More...
 
void forget ()
 Forget the SdrCaptionObj pointer in this one instance. More...
 
void setNotOwner ()
 Flag that this instance is in Undo, so drawing layer owns it. More...
 
oslInterlockedCount getRefs () const
 

Private Member Functions

void newHead ()
 
void incRef () const
 
bool decRef () const
 
void decRefAndDestroy ()
 
void removeFromList ()
 Remove from current list and close gap. More...
 
void replaceInList (ScCaptionPtr *pNew) noexcept
 Replace this instance with pNew in a list, if any. More...
 
void dissolve ()
 Dissolve list when the caption object is released or gone. More...
 
void clear ()
 Just clear everything, while dissolving the list. More...
 

Private Attributes

HeadmpHead
 points to the "master" entry More...
 
ScCaptionPtrmpNext
 next in list More...
 
SdrCaptionObjmpCaption
 the caption object, managed by head master More...
 
bool mbNotOwner
 whether this caption object is owned by something else, e.g. held in Undo More...
 

Detailed Description

Some desperate attempt to fight against the caption object ownership mess, to which none of shared/weak/plain pointer is a cure.

Definition at line 41 of file postit.hxx.

Constructor & Destructor Documentation

ScCaptionPtr::ScCaptionPtr ( )

Definition at line 454 of file postit.cxx.

References mpNext.

ScCaptionPtr::ScCaptionPtr ( SdrCaptionObj p)
explicit

Definition at line 459 of file postit.cxx.

References mpNext, and newHead().

ScCaptionPtr::ScCaptionPtr ( const ScCaptionPtr r)

Definition at line 468 of file postit.cxx.

References incRef(), mpCaption, mpHead, and mpNext.

ScCaptionPtr::ScCaptionPtr ( ScCaptionPtr &&  r)
noexcept

Definition at line 486 of file postit.cxx.

ScCaptionPtr::~ScCaptionPtr ( )

Definition at line 677 of file postit.cxx.

References decRefAndDestroy(), and removeFromList().

Member Function Documentation

void ScCaptionPtr::clear ( )
private

Just clear everything, while dissolving the list.

Definition at line 813 of file postit.cxx.

References mbNotOwner, mpCaption, mpHead, and mpNext.

bool ScCaptionPtr::decRef ( ) const
private

Definition at line 694 of file postit.cxx.

References ScCaptionPtr::Head::mnRefs, and mpHead.

Referenced by decRefAndDestroy(), and forget().

void ScCaptionPtr::decRefAndDestroy ( )
private
void ScCaptionPtr::dissolve ( )
private

Dissolve list when the caption object is released or gone.

Definition at line 797 of file postit.cxx.

References mpCaption, ScCaptionPtr::Head::mpFirst, mpHead, mpNext, and p.

Referenced by release().

void ScCaptionPtr::forget ( )

Forget the SdrCaptionObj pointer in this one instance.

Decrements a use count but does not destroy the object, it's up to the caller to manage this mess...

Definition at line 789 of file postit.cxx.

References decRef(), mbNotOwner, mpCaption, and removeFromList().

Referenced by ScPostIt::ForgetCaption(), and ScPostIt::RemoveCaption().

const SdrCaptionObj* ScCaptionPtr::get ( ) const
inline
SdrCaptionObj* ScCaptionPtr::get ( )
inline

Definition at line 54 of file postit.hxx.

References mpCaption.

oslInterlockedCount ScCaptionPtr::getRefs ( ) const

Definition at line 683 of file postit.cxx.

References ScCaptionPtr::Head::mnRefs, and mpHead.

Referenced by ScPostIt::RemoveCaption(), and removeFromDrawPageAndFree().

void ScCaptionPtr::incRef ( ) const
private

Definition at line 688 of file postit.cxx.

References ScCaptionPtr::Head::mnRefs, and mpHead.

Referenced by operator=(), and ScCaptionPtr().

void ScCaptionPtr::insertToDrawPage ( SdrPage rDrawPage)

Insert to draw page.

The caption object is owned by the draw page then.

Definition at line 738 of file postit.cxx.

References SdrObjList::InsertObject(), mpCaption, and mpHead.

void ScCaptionPtr::newHead ( )
private

Definition at line 558 of file postit.cxx.

References mpHead.

Referenced by reset(), and ScCaptionPtr().

ScCaptionPtr::operator bool ( ) const
inlineexplicit

Definition at line 52 of file postit.hxx.

References mpCaption.

const SdrCaptionObj& ScCaptionPtr::operator* ( ) const
inline

Definition at line 57 of file postit.hxx.

References mpCaption.

SdrCaptionObj& ScCaptionPtr::operator* ( )
inline

Definition at line 58 of file postit.hxx.

References mpCaption.

const SdrCaptionObj* ScCaptionPtr::operator-> ( ) const
inline

Definition at line 55 of file postit.hxx.

References mpCaption.

SdrCaptionObj* ScCaptionPtr::operator-> ( )
inline

Definition at line 56 of file postit.hxx.

References mpCaption.

ScCaptionPtr & ScCaptionPtr::operator= ( const ScCaptionPtr r)

Definition at line 510 of file postit.cxx.

References decRefAndDestroy(), incRef(), mbNotOwner, mpCaption, mpHead, mpNext, and removeFromList().

ScCaptionPtr & ScCaptionPtr::operator= ( ScCaptionPtr &&  r)
noexcept

Definition at line 494 of file postit.cxx.

References mbNotOwner, mpCaption, mpHead, and mpNext.

SdrCaptionObj * ScCaptionPtr::release ( )

Release all management of the SdrCaptionObj* in all instances of this list and dissolve.

The SdrCaptionObj pointer returned is ready to be managed elsewhere.

Definition at line 782 of file postit.cxx.

References dissolve(), and mpCaption.

Referenced by decRefAndDestroy(), removeFromDrawPageAndFree(), and ScNoteMarker::~ScNoteMarker().

void ScCaptionPtr::removeFromDrawPage ( SdrPage rDrawPage)

Remove from draw page.

The caption object is not owned anymore by the draw page then.

Definition at line 745 of file postit.cxx.

References SdrObject::GetOrdNum(), mpCaption, mpHead, SdrObjList::RemoveObject(), and void().

Referenced by removeFromDrawPageAndFree().

void ScCaptionPtr::removeFromDrawPageAndFree ( bool  bIgnoreUndo = false)
void ScCaptionPtr::removeFromList ( )
private

Remove from current list and close gap.

Usually there are only very few instances, so maintaining a doubly linked list isn't worth memory/performance wise and a simple walk does it.

Definition at line 590 of file postit.cxx.

References ScCaptionPtr::Head::mnRefs, mpCaption, ScCaptionPtr::Head::mpFirst, mpHead, mpNext, and nCount.

Referenced by forget(), operator=(), reset(), and ~ScCaptionPtr().

void ScCaptionPtr::replaceInList ( ScCaptionPtr pNew)
privatenoexcept

Replace this instance with pNew in a list, if any.

Used by move-ctor and move assignment operator.

Definition at line 564 of file postit.cxx.

References mpCaption, ScCaptionPtr::Head::mpFirst, mpHead, and mpNext.

void ScCaptionPtr::reset ( SdrCaptionObj p)
void ScCaptionPtr::setNotOwner ( )

Flag that this instance is in Undo, so drawing layer owns it.

Definition at line 548 of file postit.cxx.

References mbNotOwner.

Referenced by ScUndoReplaceNote::ScUndoReplaceNote().

Member Data Documentation

bool ScCaptionPtr::mbNotOwner
private

whether this caption object is owned by something else, e.g. held in Undo

Definition at line 107 of file postit.hxx.

Referenced by clear(), decRefAndDestroy(), forget(), operator=(), reset(), and setNotOwner().

SdrCaptionObj* ScCaptionPtr::mpCaption
private
Head* ScCaptionPtr::mpHead
private
ScCaptionPtr* ScCaptionPtr::mpNext
mutableprivate

next in list

Definition at line 105 of file postit.hxx.

Referenced by clear(), decRefAndDestroy(), dissolve(), operator=(), removeFromList(), replaceInList(), and ScCaptionPtr().


The documentation for this class was generated from the following files: