LibreOffice Module svl (master) 1
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
SfxItemPool Class Reference

Base class for providers of defaults of SfxPoolItems. More...

#include <itempool.hxx>

Inheritance diagram for SfxItemPool:
[legend]
Collaboration diagram for SfxItemPool:
[legend]

Classes

struct  Item2Range
 

Public Member Functions

void FillItemIdRanges_Impl (WhichRangesContainer &pWhichRanges) const
 
const WhichRangesContainerGetFrozenIdRanges () const
 
 SfxItemPool (const SfxItemPool &rPool, bool bCloneStaticDefaults=false)
 Copy ctor. More...
 
 SfxItemPool (const OUString &rName, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxItemInfo *pItemInfos, std::vector< SfxPoolItem * > *pDefaults=nullptr)
 This is the regular ctor to be used for this class. More...
 
virtual ~SfxItemPool ()
 
SfxBroadcasterBC ()
 
void SetPoolDefaultItem (const SfxPoolItem &)
 
const SfxPoolItemGetPoolDefaultItem (sal_uInt16 nWhich) const
 
template<class T >
const T * GetPoolDefaultItem (TypedWhichId< T > nWhich) const
 
void ResetPoolDefaultItem (sal_uInt16 nWhich)
 Resets the default of the given WhichId back to the static Default. More...
 
void SetDefaults (std::vector< SfxPoolItem * > *pDefaults)
 
void ClearDefaults ()
 
void ReleaseDefaults (bool bDelete=false)
 Frees the static Defaults of the corresponding SfxItemPool instance and deletes them if specified. More...
 
virtual MapUnit GetMetric (sal_uInt16 nWhich) const
 
void SetDefaultMetric (MapUnit eNewMetric)
 
MapUnit GetDefaultMetric () const
 
virtual bool GetPresentation (const SfxPoolItem &rItem, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
 Request string representation of pool items. More...
 
virtual rtl::Reference< SfxItemPoolClone () const
 
const OUString & GetName () const
 
template<class T >
const T & Put (std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
 
template<class T >
const T & Put (const T &rItem, sal_uInt16 nWhich=0)
 
void Remove (const SfxPoolItem &)
 
const SfxPoolItemGetDefaultItem (sal_uInt16 nWhich) const
 
template<class T >
const T & GetDefaultItem (TypedWhichId< T > nWhich) const
 
bool CheckItemInPool (const SfxPoolItem *) const
 
const SfxPoolItemGetItem2Default (sal_uInt16 nWhich) const
 
template<class T >
const T * GetItem2Default (TypedWhichId< T > nWhich) const
 
sal_uInt32 GetItemCount2 (sal_uInt16 nWhich) const
 
Item2Range GetItemSurrogates (sal_uInt16 nWhich) const
 
std::vector< const SfxPoolItem * > FindItemSurrogate (sal_uInt16 nWhich, SfxPoolItem const &rNeedle) const
 
sal_uInt16 GetFirstWhich () const
 
sal_uInt16 GetLastWhich () const
 
bool IsInRange (sal_uInt16 nWhich) const
 
void SetSecondaryPool (SfxItemPool *pPool)
 
SfxItemPoolGetSecondaryPool () const
 
SfxItemPoolGetLastPoolInChain ()
 
SfxItemPoolGetMasterPool () const
 
void FreezeIdRanges ()
 This method should be called at the master pool, when all secondary pools are appended to it. More...
 
void Delete ()
 
bool IsItemPoolable (sal_uInt16 nWhich) const
 
bool IsItemPoolable (const SfxPoolItem &rItem) const
 
void SetItemInfos (const SfxItemInfo *pInfos)
 
sal_uInt16 GetWhich (sal_uInt16 nSlot, bool bDeep=true) const
 
template<class T >
TypedWhichId< T > GetWhich (TypedWhichId< T > nSlot, bool bDeep=true) const
 
sal_uInt16 GetSlotId (sal_uInt16 nWhich) const
 
sal_uInt16 GetTrueWhich (sal_uInt16 nSlot, bool bDeep=true) const
 
sal_uInt16 GetTrueSlotId (sal_uInt16 nWhich) const
 
void dumpAsXml (xmlTextWriterPtr pWriter) const
 
- Public Member Functions inherited from salhelper::SimpleReferenceObject
 SimpleReferenceObject ()
 
void acquire ()
 
void release ()
 

Static Public Member Functions

static void ReleaseDefaults (std::vector< SfxPoolItem * > *pDefaults, bool bDelete=false)
 Frees the specified static Defaults and also deletes them, if so specified. More...
 
static bool IsWhich (sal_uInt16 nId)
 
static bool IsSlot (sal_uInt16 nId)
 
- Static Public Member Functions inherited from salhelper::SimpleReferenceObject
static void * operator new (std::size_t nSize)
 
static void * operator new (std::size_t nSize, std::nothrow_t const &rNothrow)
 
static void operator delete (void *pPtr)
 
static void operator delete (void *pPtr, std::nothrow_t const &rNothrow)
 

Protected Member Functions

virtual const SfxPoolItemPutImpl (const SfxPoolItem &, sal_uInt16 nWhich=0, bool bPassingOwnership=false)
 
- Protected Member Functions inherited from salhelper::SimpleReferenceObject
virtual ~SimpleReferenceObject () COVERITY_NOEXCEPT_FALSE
 

Static Protected Member Functions

static void ClearRefCount (SfxPoolItem &rItem)
 
static void AddRef (const SfxPoolItem &rItem)
 
static sal_uInt32 ReleaseRef (const SfxPoolItem &rItem, sal_uInt32 n=1)
 

Private Member Functions

sal_uInt16 GetIndex_Impl (sal_uInt16 nWhich) const
 
sal_uInt16 GetSize_Impl () const
 
SVL_DLLPRIVATE bool IsItemPoolable_Impl (sal_uInt16 nWhich) const
 
const SfxItemPooloperator= (const SfxItemPool &)=delete
 

Private Attributes

const SfxItemInfopItemInfos
 
std::unique_ptr< SfxItemPool_ImplpImpl
 

Static Private Attributes

static const sal_uInt16 SFX_WHICH_MAX = 4999
 

Friends

struct SfxItemPool_Impl
 
class SfxItemSet
 
class SfxAllItemSet
 

Additional Inherited Members

- Protected Attributes inherited from salhelper::SimpleReferenceObject
oslInterlockedCount m_nCount
 

Detailed Description

Base class for providers of defaults of SfxPoolItems.

The derived classes hold the concrete (const) instances which are referenced in several places (usually within a single document). This helps to lower the amount of calls to lifecycle methods, speeds up comparisons within a document and facilitates loading and saving of attributes.

Definition at line 50 of file itempool.hxx.

Constructor & Destructor Documentation

◆ SfxItemPool() [1/2]

SfxItemPool::SfxItemPool ( const SfxItemPool rPool,
bool  bCloneStaticDefaults = false 
)

Copy ctor.

See also
SfxItemPool::Clone() const

Definition at line 262 of file itempool.cxx.

References aName, Clone(), mnEnd, mnStart, n, pImpl, PoolDefault, SetDefaults(), SetSecondaryPool(), and StaticDefault.

Referenced by Clone().

◆ SfxItemPool() [2/2]

SfxItemPool::SfxItemPool ( const OUString &  rName,
sal_uInt16  nStartWhich,
sal_uInt16  nEndWhich,
const SfxItemInfo pInfo,
std::vector< SfxPoolItem * > *  pDefaults = nullptr 
)

This is the regular ctor to be used for this class.

An SfxItemPool instance is initialized, which can manage Items in the range from 'nStartWhich' to 'nEndWhich'.

For every one of these WhichIds a static Default must be present in the 'pDefaults' array. They start with an SfxPoolItem (with the WhichId 'nStartWhich'), are sorted by WhichId and consecutively stored.

'pItemInfos' is a USHORT array arranged in the same way, which holds SlotIds and Flags. These SlotIds can be 0, if the affected Items are exclusively used in the Core. The flags allow for e.g. enabling value sharing (poolable).

If the Pool is supposed to hold SfxSetItems, the ctor cannot yet contain static Defaults. This needs to be done afterwards, using

See also
SfxItemPool::SetDefaults(std::vector<SfxPoolItem*>*).
SfxItemPool::SetDefaults(std::vector<SfxPoolItem*>*)
SfxItemPool::ReleaseDefaults(std::vector<SfxPoolItem*>*,bool)
SfxItemPool::ReleaseDefaults(bool)

Definition at line 218 of file itempool.cxx.

References p, pImpl, pItemInfos, SAL_WARN, and SetDefaults().

◆ ~SfxItemPool()

SfxItemPool::~SfxItemPool ( )
virtual

Definition at line 401 of file itempool.cxx.

References DBG_ASSERT, Delete(), and pImpl.

Member Function Documentation

◆ AddRef()

void SfxItemPool::AddRef ( const SfxPoolItem rItem)
inlinestaticprotected

Definition at line 217 of file itempool.hxx.

References SfxPoolItem::AddRef().

Referenced by PutImpl().

◆ BC()

SfxBroadcaster & SfxItemPool::BC ( )

Definition at line 190 of file itempool.cxx.

References pImpl.

◆ CheckItemInPool()

bool SfxItemPool::CheckItemInPool ( const SfxPoolItem pItem) const

◆ ClearDefaults()

void SfxItemPool::ClearDefaults ( )

Definition at line 327 of file itempool.cxx.

References pImpl.

◆ ClearRefCount()

void SfxItemPool::ClearRefCount ( SfxPoolItem rItem)
inlinestaticprotected

Definition at line 211 of file itempool.hxx.

References SfxPoolItem::SetRefCount().

Referenced by Delete().

◆ Clone()

rtl::Reference< SfxItemPool > SfxItemPool::Clone ( ) const
virtual

Definition at line 509 of file itempool.cxx.

References SfxItemPool().

Referenced by SfxItemPool().

◆ Delete()

void SfxItemPool::Delete ( )

Definition at line 515 of file itempool.cxx.

References ClearRefCount(), Dying, GetSize_Impl(), n, pImpl, and ReleaseRef().

Referenced by ~SfxItemPool().

◆ dumpAsXml()

void SfxItemPool::dumpAsXml ( xmlTextWriterPtr  pWriter) const

Definition at line 1003 of file itempool.cxx.

References pImpl.

◆ FillItemIdRanges_Impl()

void SfxItemPool::FillItemIdRanges_Impl ( WhichRangesContainer pWhichRanges) const

◆ FindItemSurrogate()

std::vector< const SfxPoolItem * > SfxItemPool::FindItemSurrogate ( sal_uInt16  nWhich,
SfxPoolItem const &  rNeedle 
) const

◆ FreezeIdRanges()

void SfxItemPool::FreezeIdRanges ( )

This method should be called at the master pool, when all secondary pools are appended to it.

It calculates the ranges of 'which-ids' for fast construction of item-sets, which contains all 'which-ids'.

Definition at line 859 of file itempool.cxx.

References FillItemIdRanges_Impl(), and pImpl.

◆ GetDefaultItem() [1/2]

const SfxPoolItem & SfxItemPool::GetDefaultItem ( sal_uInt16  nWhich) const

◆ GetDefaultItem() [2/2]

template<class T >
const T & SfxItemPool::GetDefaultItem ( TypedWhichId< T >  nWhich) const
inline

Definition at line 145 of file itempool.hxx.

◆ GetDefaultMetric()

MapUnit SfxItemPool::GetDefaultMetric ( ) const

Definition at line 485 of file itempool.cxx.

References pImpl.

◆ GetFirstWhich()

sal_uInt16 SfxItemPool::GetFirstWhich ( ) const

Definition at line 97 of file itempool.cxx.

References pImpl.

Referenced by lcl_CheckSlots2().

◆ GetFrozenIdRanges()

const WhichRangesContainer & SfxItemPool::GetFrozenIdRanges ( ) const

Definition at line 877 of file itempool.cxx.

References pImpl.

◆ GetIndex_Impl()

sal_uInt16 SfxItemPool::GetIndex_Impl ( sal_uInt16  nWhich) const
private

◆ GetItem2Default() [1/2]

const SfxPoolItem * SfxItemPool::GetItem2Default ( sal_uInt16  nWhich) const

Definition at line 882 of file itempool.cxx.

References GetIndex_Impl(), IsInRange(), and pImpl.

◆ GetItem2Default() [2/2]

template<class T >
const T * SfxItemPool::GetItem2Default ( TypedWhichId< T >  nWhich) const
inline

Definition at line 158 of file itempool.hxx.

◆ GetItemCount2()

sal_uInt32 SfxItemPool::GetItemCount2 ( sal_uInt16  nWhich) const

Definition at line 925 of file itempool.cxx.

References GetIndex_Impl(), IsInRange(), pImpl, and SfxPoolItemArray_Impl::size().

◆ GetItemSurrogates()

SfxItemPool::Item2Range SfxItemPool::GetItemSurrogates ( sal_uInt16  nWhich) const

◆ GetLastPoolInChain()

SfxItemPool * SfxItemPool::GetLastPoolInChain ( )

Definition at line 839 of file itempool.cxx.

References GetSecondaryPool().

◆ GetLastWhich()

sal_uInt16 SfxItemPool::GetLastWhich ( ) const

Definition at line 102 of file itempool.cxx.

References pImpl.

Referenced by lcl_CheckSlots2().

◆ GetMasterPool()

SfxItemPool * SfxItemPool::GetMasterPool ( ) const

Definition at line 847 of file itempool.cxx.

References pImpl.

Referenced by SetSecondaryPool().

◆ GetMetric()

MapUnit SfxItemPool::GetMetric ( sal_uInt16  nWhich) const
virtual

Definition at line 473 of file itempool.cxx.

References pImpl.

Referenced by GetPresentation().

◆ GetName()

const OUString & SfxItemPool::GetName ( ) const

Definition at line 490 of file itempool.cxx.

References pImpl.

Referenced by lcl_CheckSlots2().

◆ GetPoolDefaultItem() [1/2]

const SfxPoolItem * SfxItemPool::GetPoolDefaultItem ( sal_uInt16  nWhich) const

Definition at line 156 of file itempool.cxx.

References GetIndex_Impl(), IsInRange(), and pImpl.

◆ GetPoolDefaultItem() [2/2]

template<class T >
const T * SfxItemPool::GetPoolDefaultItem ( TypedWhichId< T >  nWhich) const
inline

Definition at line 91 of file itempool.hxx.

◆ GetPresentation()

bool SfxItemPool::GetPresentation ( const SfxPoolItem rItem,
MapUnit  ePresentationMetric,
OUString &  rText,
const IntlWrapper rIntlWrapper 
) const
virtual

Request string representation of pool items.

This virtual function produces a string representation from the respective SfxItemPool subclass' known SfxPoolItems.

Subclasses, please override this method, and handle SfxPoolItems that don't return useful/complete information on SfxPoolItem::GetPresentation()

This baseclass yields the unmodified string representation of rItem.

Parameters
[in]rItemSfxPoolItem to query the string representation of
[in]ePresentrequested kind of representation - see SfxItemPresentation
[in]eMetricrequested unit of measure of the representation
[out]rTextstring representation of 'rItem'
Returns
true if it has a valid string representation

Definition at line 496 of file itempool.cxx.

References Complete, GetMetric(), SfxPoolItem::GetPresentation(), and SfxPoolItem::Which().

Referenced by SfxStyleSheetBase::GetDescription().

◆ GetSecondaryPool()

SfxItemPool * SfxItemPool::GetSecondaryPool ( ) const

Definition at line 833 of file itempool.cxx.

References pImpl.

Referenced by GetLastPoolInChain().

◆ GetSize_Impl()

sal_uInt16 SfxItemPool::GetSize_Impl ( ) const
private

Definition at line 122 of file itempool.cxx.

References pImpl.

Referenced by Delete().

◆ GetSlotId()

sal_uInt16 SfxItemPool::GetSlotId ( sal_uInt16  nWhich) const

Definition at line 955 of file itempool.cxx.

References SfxItemInfo::_nSID, IsInRange(), IsWhich(), pImpl, and pItemInfos.

◆ GetTrueSlotId()

sal_uInt16 SfxItemPool::GetTrueSlotId ( sal_uInt16  nWhich) const

Definition at line 988 of file itempool.cxx.

References SfxItemInfo::_nSID, IsInRange(), IsWhich(), pImpl, and pItemInfos.

◆ GetTrueWhich()

sal_uInt16 SfxItemPool::GetTrueWhich ( sal_uInt16  nSlot,
bool  bDeep = true 
) const

Definition at line 973 of file itempool.cxx.

References IsSlot(), nCount, pImpl, and pItemInfos.

◆ GetWhich() [1/2]

sal_uInt16 SfxItemPool::GetWhich ( sal_uInt16  nSlot,
bool  bDeep = true 
) const

Definition at line 940 of file itempool.cxx.

References IsSlot(), nCount, pImpl, and pItemInfos.

Referenced by SfxItemSet::GetItem().

◆ GetWhich() [2/2]

template<class T >
TypedWhichId< T > SfxItemPool::GetWhich ( TypedWhichId< T >  nSlot,
bool  bDeep = true 
) const
inline

Definition at line 188 of file itempool.hxx.

References GetWhich.

◆ IsInRange()

bool SfxItemPool::IsInRange ( sal_uInt16  nWhich) const

◆ IsItemPoolable() [1/2]

bool SfxItemPool::IsItemPoolable ( const SfxPoolItem rItem) const
inline

Definition at line 183 of file itempool.hxx.

References SfxPoolItem::Which().

◆ IsItemPoolable() [2/2]

bool SfxItemPool::IsItemPoolable ( sal_uInt16  nWhich) const

◆ IsItemPoolable_Impl()

bool SfxItemPool::IsItemPoolable_Impl ( sal_uInt16  nWhich) const
private

Definition at line 172 of file itempool.cxx.

References SfxItemInfo::_bPoolable, nPos, and pItemInfos.

Referenced by PutImpl().

◆ IsSlot()

static bool SfxItemPool::IsSlot ( sal_uInt16  nId)
inlinestatic

Definition at line 196 of file itempool.hxx.

References nId.

Referenced by GetTrueWhich(), GetWhich(), PutImpl(), and Remove().

◆ IsWhich()

static bool SfxItemPool::IsWhich ( sal_uInt16  nId)
inlinestatic

◆ operator=()

const SfxItemPool & SfxItemPool::operator= ( const SfxItemPool )
privatedelete

◆ Put() [1/2]

template<class T >
const T & SfxItemPool::Put ( const T &  rItem,
sal_uInt16  nWhich = 0 
)
inline

Definition at line 140 of file itempool.hxx.

References SfxAllItemSet::PutImpl().

◆ Put() [2/2]

template<class T >
const T & SfxItemPool::Put ( std::unique_ptr< T >  xItem,
sal_uInt16  nWhich = 0 
)
inline

◆ PutImpl()

const SfxPoolItem & SfxItemPool::PutImpl ( const SfxPoolItem rItem,
sal_uInt16  nWhich = 0,
bool  bPassingOwnership = false 
)
protectedvirtual

◆ ReleaseDefaults() [1/2]

void SfxItemPool::ReleaseDefaults ( bool  bDelete = false)

Frees the static Defaults of the corresponding SfxItemPool instance and deletes them if specified.

The SfxItemPool instance MUST NOT BE USED after this function has been called; only the dtor must be called.

Definition at line 339 of file itempool.cxx.

References DBG_ASSERT, pImpl, and ReleaseDefaults().

Referenced by ReleaseDefaults().

◆ ReleaseDefaults() [2/2]

void SfxItemPool::ReleaseDefaults ( std::vector< SfxPoolItem * > *  pDefaults,
bool  bDelete = false 
)
static

Frees the specified static Defaults and also deletes them, if so specified.

This method MUST be called AFTER all SfxItemPool instances (which use the specified static Defaults 'pDefault') have been destroyed.

Definition at line 366 of file itempool.cxx.

References DBG_ASSERT, and IsStaticDefaultItem().

◆ ReleaseRef()

sal_uInt32 SfxItemPool::ReleaseRef ( const SfxPoolItem rItem,
sal_uInt32  n = 1 
)
inlinestaticprotected

Definition at line 223 of file itempool.hxx.

References n, and SfxPoolItem::ReleaseRef().

Referenced by Delete(), and Remove().

◆ Remove()

void SfxItemPool::Remove ( const SfxPoolItem rItem)

◆ ResetPoolDefaultItem()

void SfxItemPool::ResetPoolDefaultItem ( sal_uInt16  nWhichId)

Resets the default of the given WhichId back to the static Default.

If a pool default exists, it is removed.

Definition at line 613 of file itempool.cxx.

References GetIndex_Impl(), IsInRange(), and pImpl.

◆ SetDefaultMetric()

void SfxItemPool::SetDefaultMetric ( MapUnit  eNewMetric)

Definition at line 479 of file itempool.cxx.

References pImpl.

◆ SetDefaults()

void SfxItemPool::SetDefaults ( std::vector< SfxPoolItem * > *  pDefaults)

if ((*mpStaticDefaults)->GetKind() != SfxItemKind::StaticDefault) FIXME: Probably doesn't work with SetItems at the end

Definition at line 305 of file itempool.cxx.

References DBG_ASSERT, IsDefaultItem(), n, pImpl, and StaticDefault.

Referenced by SfxItemPool().

◆ SetItemInfos()

void SfxItemPool::SetItemInfos ( const SfxItemInfo pInfos)

Definition at line 466 of file itempool.cxx.

References CHECK_SLOTS, and pItemInfos.

◆ SetPoolDefaultItem()

void SfxItemPool::SetPoolDefaultItem ( const SfxPoolItem rItem)

◆ SetSecondaryPool()

void SfxItemPool::SetSecondaryPool ( SfxItemPool pPool)

Definition at line 418 of file itempool.cxx.

References CHECK_SLOTS, DBG_ASSERT, GetMasterPool(), i, p, pImpl, and SAL_WARN.

Referenced by SfxItemPool().

Friends And Related Function Documentation

◆ SfxAllItemSet

friend class SfxAllItemSet
friend

Definition at line 54 of file itempool.hxx.

◆ SfxItemPool_Impl

friend struct SfxItemPool_Impl
friend

Definition at line 52 of file itempool.hxx.

◆ SfxItemSet

friend class SfxItemSet
friend

Definition at line 53 of file itempool.hxx.

Member Data Documentation

◆ pImpl

std::unique_ptr<SfxItemPool_Impl> SfxItemPool::pImpl
private

◆ pItemInfos

const SfxItemInfo* SfxItemPool::pItemInfos
private

◆ SFX_WHICH_MAX

const sal_uInt16 SfxItemPool::SFX_WHICH_MAX = 4999
staticprivate

Definition at line 207 of file itempool.hxx.


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