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 42 of file postit.hxx.

Constructor & Destructor Documentation

ScCaptionPtr::ScCaptionPtr ( )

Definition at line 455 of file postit.cxx.

References false, and mpNext.

ScCaptionPtr::ScCaptionPtr ( SdrCaptionObj p)
explicit

Definition at line 460 of file postit.cxx.

References false, mpNext, and newHead().

ScCaptionPtr::ScCaptionPtr ( const ScCaptionPtr r)

Definition at line 469 of file postit.cxx.

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

ScCaptionPtr::ScCaptionPtr ( ScCaptionPtr &&  r)
noexcept

Definition at line 487 of file postit.cxx.

ScCaptionPtr::~ScCaptionPtr ( )

Definition at line 678 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 814 of file postit.cxx.

References mbNotOwner, mpCaption, mpHead, and mpNext.

bool ScCaptionPtr::decRef ( ) const
private

Definition at line 695 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 798 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 790 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 55 of file postit.hxx.

References mpCaption.

oslInterlockedCount ScCaptionPtr::getRefs ( ) const

Definition at line 684 of file postit.cxx.

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

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

void ScCaptionPtr::incRef ( ) const
private

Definition at line 689 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 739 of file postit.cxx.

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

void ScCaptionPtr::newHead ( )
private

Definition at line 559 of file postit.cxx.

References mpHead.

Referenced by reset(), and ScCaptionPtr().

ScCaptionPtr::operator bool ( ) const
inlineexplicit

Definition at line 53 of file postit.hxx.

References mpCaption.

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

Definition at line 58 of file postit.hxx.

References mpCaption.

SdrCaptionObj& ScCaptionPtr::operator* ( )
inline

Definition at line 59 of file postit.hxx.

References mpCaption.

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

Definition at line 56 of file postit.hxx.

References mpCaption.

SdrCaptionObj* ScCaptionPtr::operator-> ( )
inline

Definition at line 57 of file postit.hxx.

References mpCaption.

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

Definition at line 511 of file postit.cxx.

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

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

Definition at line 495 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 783 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 746 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 591 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 565 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 549 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 108 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 106 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: