Kaydet (Commit) 2207f9c7 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Refactored SfxItemPool for better encapsulation.

Basically everything except pItemInfos is under pImp.  This will
make it easier for future refactoring in the implementation area.
üst ba75626b
......@@ -87,8 +87,6 @@ public:
virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool) = 0;
};
typedef ::std::vector< SfxItemPoolUser* > SfxItemPoolUserVector;
class SVL_DLLPUBLIC SfxItemPool
/* [Beschreibung]
......@@ -105,28 +103,14 @@ class SVL_DLLPUBLIC SfxItemPool
*/
{
SVL_DLLPRIVATE void readTheItems(SvStream & rStream, sal_uInt32 nCount, sal_uInt16 nVersion,
SfxPoolItem * pDefItem, SfxPoolItemArray_Impl ** pArr);
friend struct SfxItemPool_Impl;
UniString aName;
sal_uInt16 nStart, nEnd;
sal_uInt16 _nFileFormatVersion;
#ifdef TF_POOLABLE
const SfxItemInfo* pItemInfos;
#else
#error "TF_POOLABLE should always be set."
#endif
SfxItemPool_Impl* pImp;
SfxPoolItem** ppStaticDefaults;
SfxPoolItem** ppPoolDefaults;
SfxItemPool* pSecondary;
SfxItemPool* pMaster;
sal_uInt16* _pPoolRanges;
bool bPersistentRefCounts;
private:
// ObjectUser section
SfxItemPoolUserVector maSfxItemPoolUsers;
public:
void AddSfxItemPoolUser(SfxItemPoolUser& rNewUser);
......@@ -138,8 +122,8 @@ public:
friend class SfxPoolWhichMap;
private:
inline sal_uInt16 GetIndex_Impl(sal_uInt16 nWhich) const;
inline sal_uInt16 GetSize_Impl() const { return nEnd - nStart + 1; }
sal_uInt16 GetIndex_Impl(sal_uInt16 nWhich) const;
sal_uInt16 GetSize_Impl() const;
SVL_DLLPRIVATE SvStream& Load1_Impl( SvStream &rStream );
SVL_DLLPRIVATE bool IsItemFlag_Impl( sal_uInt16 nWhich, sal_uInt16 nFlag ) const;
......@@ -147,15 +131,16 @@ private:
public:
// fuer dflt. SfxItemSet::CTOR, setze dflt. WhichRanges
void FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const;
const sal_uInt16* GetFrozenIdRanges() const
{ return _pPoolRanges; }
const sal_uInt16* GetFrozenIdRanges() const;
#endif
//---------------------------------------------------------------------
protected:
static inline void SetRefCount( SfxPoolItem& rItem, sal_uLong n );
static inline sal_uLong AddRef( const SfxPoolItem& rItem, sal_uLong n = 1 );
static inline sal_uLong ReleaseRef( const SfxPoolItem& rItem, sal_uLong n = 1);
static inline sal_uLong AddRef( const SfxPoolItem& rItem, sal_uLong n = 1 );
static inline sal_uLong ReleaseRef( const SfxPoolItem& rItem, sal_uLong n = 1);
static inline void SetKind( SfxPoolItem& rItem, sal_uInt16 nRef );
public:
SfxItemPool( const SfxItemPool &rPool,
......@@ -196,7 +181,7 @@ public:
const IntlWrapper * pIntlWrapper
= 0 ) const;
virtual SfxItemPool* Clone() const;
UniString const & GetName() const { return aName; }
const UniString& GetName() const;
virtual const SfxPoolItem& Put( const SfxPoolItem&, sal_uInt16 nWhich = 0 );
virtual void Remove( const SfxPoolItem& );
......@@ -220,23 +205,18 @@ public:
virtual SvStream & Load(SvStream &);
virtual SvStream & Store(SvStream &) const;
int HasPersistentRefCounts() const {
return bPersistentRefCounts; }
bool HasPersistentRefCounts() const;
void LoadCompleted();
sal_uInt16 GetFirstWhich() const { return nStart; }
sal_uInt16 GetLastWhich() const { return nEnd; }
bool IsInRange( sal_uInt16 nWhich ) const {
return nWhich >= nStart &&
nWhich <= nEnd; }
sal_uInt16 GetFirstWhich() const;
sal_uInt16 GetLastWhich() const;
bool IsInRange( sal_uInt16 nWhich ) const;
bool IsInVersionsRange( sal_uInt16 nWhich ) const;
bool IsInStoringRange( sal_uInt16 nWhich ) const;
void SetStoringRange( sal_uInt16 nFrom, sal_uInt16 nTo );
void SetSecondaryPool( SfxItemPool *pPool );
SfxItemPool* GetSecondaryPool() const {
return pSecondary; }
SfxItemPool* GetMasterPool() const {
return pMaster; }
SfxItemPool* GetSecondaryPool() const;
SfxItemPool* GetMasterPool() const;
void FreezeIdRanges();
void Delete();
......@@ -250,18 +230,17 @@ public:
#else
#error "TF_POOLABLE should always be set."
#endif
sal_uInt16 GetWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const;
sal_uInt16 GetSlotId( sal_uInt16 nWhich, sal_Bool bDeep = sal_True ) const;
sal_uInt16 GetTrueWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const;
sal_uInt16 GetTrueSlotId( sal_uInt16 nWhich, sal_Bool bDeep = sal_True ) const;
sal_uInt16 GetWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const;
sal_uInt16 GetSlotId( sal_uInt16 nWhich, sal_Bool bDeep = sal_True ) const;
sal_uInt16 GetTrueWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const;
sal_uInt16 GetTrueSlotId( sal_uInt16 nWhich, sal_Bool bDeep = sal_True ) const;
void SetVersionMap( sal_uInt16 nVer,
sal_uInt16 nOldStart, sal_uInt16 nOldEnd,
sal_uInt16 *pWhichIdTab );
sal_uInt16 GetNewWhich( sal_uInt16 nOldWhich ) const;
sal_uInt16 GetVersion() const;
sal_uInt16 GetFileFormatVersion() const
{ return _nFileFormatVersion; }
sal_uInt16 GetNewWhich( sal_uInt16 nOldWhich ) const;
sal_uInt16 GetVersion() const;
sal_uInt16 GetFileFormatVersion() const;
void SetFileFormatVersion( sal_uInt16 nFileFormatVersion );
bool IsCurrentVersionLoading() const;
......@@ -296,6 +275,11 @@ inline sal_uLong SfxItemPool::ReleaseRef( const SfxPoolItem& rItem, sal_uLong n
return rItem.ReleaseRef(n);
}
inline void SfxItemPool::SetKind( SfxPoolItem& rItem, sal_uInt16 nRef )
{
rItem.SetKind( nRef );
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -28,6 +28,7 @@
#include <svl/brdcst.hxx>
#include <boost/shared_ptr.hpp>
#include <deque>
#include <vector>
#ifndef DELETEZ
#define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
......@@ -74,8 +75,18 @@ class SfxStyleSheetIterator;
struct SfxItemPool_Impl
{
SfxBroadcaster aBC;
SfxPoolItemArray_Impl** ppPoolItems;
std::vector<SfxPoolItemArray_Impl*> maPoolItems;
std::vector<SfxItemPoolUser*> maSfxItemPoolUsers; /// ObjectUser section
UniString aName;
SfxPoolItem** ppPoolDefaults;
SfxPoolItem** ppStaticDefaults;
SfxItemPool* mpMaster;
SfxItemPool* mpSecondary;
sal_uInt16* mpPoolRanges;
SfxPoolVersionArr_Impl aVersions;
sal_uInt16 mnStart;
sal_uInt16 mnEnd;
sal_uInt16 mnFileFormatVersion;
sal_uInt16 nVersion;
sal_uInt16 nLoadingVersion;
sal_uInt16 nInitRefCount; // 1, beim Laden ggf. 2
......@@ -85,9 +96,19 @@ struct SfxItemPool_Impl
SfxMapUnit eDefMetric;
bool bInSetItem;
bool bStreaming; // in Load() bzw. Store()
SfxItemPool_Impl( sal_uInt16 nStart, sal_uInt16 nEnd )
: ppPoolItems (new SfxPoolItemArray_Impl*[ nEnd - nStart + 1])
bool mbPersistentRefCounts;
SfxItemPool_Impl( SfxItemPool* pMaster, const UniString& rName, sal_uInt16 nStart, sal_uInt16 nEnd )
: maPoolItems(nEnd - nStart + 1, NULL)
, aName(rName)
, ppPoolDefaults(new SfxPoolItem* [nEnd - nStart + 1])
, ppStaticDefaults(0)
, mpMaster(pMaster)
, mpSecondary(NULL)
, mpPoolRanges(NULL)
, mnStart(nStart)
, mnEnd(nEnd)
, mnFileFormatVersion(0)
, nLoadingVersion(0)
, nInitRefCount(0)
, nVerStart(0)
......@@ -99,19 +120,30 @@ struct SfxItemPool_Impl
, bInSetItem(false)
, bStreaming(false)
{
memset( ppPoolItems, 0, sizeof( SfxPoolItemArray_Impl* ) * ( nEnd - nStart + 1) );
DBG_ASSERT(mnStart, "Start-Which-Id must be greater 0" );
memset( ppPoolDefaults, 0, sizeof( SfxPoolItem* ) * (nEnd - nStart + 1));
}
~SfxItemPool_Impl()
{
delete[] ppPoolItems;
DeleteItems();
}
void DeleteItems()
{
delete[] ppPoolItems;
ppPoolItems = 0;
std::vector<SfxPoolItemArray_Impl*>::iterator itr = maPoolItems.begin(), itrEnd = maPoolItems.end();
for (; itr != itrEnd; ++itr)
delete *itr;
maPoolItems.clear();
delete[] mpPoolRanges;
mpPoolRanges = NULL;
delete[] ppPoolDefaults;
ppPoolDefaults = NULL;
}
void readTheItems(SvStream & rStream, sal_uInt32 nCount, sal_uInt16 nVersion,
SfxPoolItem * pDefItem, SfxPoolItemArray_Impl ** pArr);
};
// -----------------------------------------------------------------------
......@@ -204,13 +236,4 @@ struct SfxItemPool_Impl
#define SFX_STYLES_REC_HEADER sal_uInt16(0x0010)
#define SFX_STYLES_REC_STYLES sal_uInt16(0x0020)
//========================================================================
inline sal_uInt16 SfxItemPool::GetIndex_Impl(sal_uInt16 nWhich) const
{
DBG_CHKTHIS(SfxItemPool, 0);
DBG_ASSERT(nWhich >= nStart && nWhich <= nEnd, "Which-Id nicht im Pool-Bereich");
return nWhich - nStart;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -43,15 +43,16 @@
void SfxItemPool::AddSfxItemPoolUser(SfxItemPoolUser& rNewUser)
{
maSfxItemPoolUsers.push_back(&rNewUser);
pImp->maSfxItemPoolUsers.push_back(&rNewUser);
}
void SfxItemPool::RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser)
{
const SfxItemPoolUserVector::iterator aFindResult = ::std::find(maSfxItemPoolUsers.begin(), maSfxItemPoolUsers.end(), &rOldUser);
if(aFindResult != maSfxItemPoolUsers.end())
const std::vector<SfxItemPoolUser*>::iterator aFindResult = ::std::find(
pImp->maSfxItemPoolUsers.begin(), pImp->maSfxItemPoolUsers.end(), &rOldUser);
if(aFindResult != pImp->maSfxItemPoolUsers.end())
{
maSfxItemPoolUsers.erase(aFindResult);
pImp->maSfxItemPoolUsers.erase(aFindResult);
}
}
......@@ -60,9 +61,9 @@ const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( sal_uInt16 nWhich ) const
DBG_CHKTHIS(SfxItemPool, 0);
const SfxPoolItem* pRet;
if( IsInRange( nWhich ) )
pRet = *(ppPoolDefaults + GetIndex_Impl( nWhich ));
else if( pSecondary )
pRet = pSecondary->GetPoolDefaultItem( nWhich );
pRet = *(pImp->ppPoolDefaults + GetIndex_Impl( nWhich ));
else if( pImp->mpSecondary )
pRet = pImp->mpSecondary->GetPoolDefaultItem( nWhich );
else
{
SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot get pool default" );
......@@ -73,7 +74,7 @@ const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( sal_uInt16 nWhich ) const
// -----------------------------------------------------------------------
inline bool SfxItemPool::IsItemFlag_Impl( sal_uInt16 nPos, sal_uInt16 nFlag ) const
bool SfxItemPool::IsItemFlag_Impl( sal_uInt16 nPos, sal_uInt16 nFlag ) const
{
sal_uInt16 nItemFlag = pItemInfos[nPos]._nFlags;
return nFlag == (nItemFlag & nFlag);
......@@ -83,7 +84,7 @@ inline bool SfxItemPool::IsItemFlag_Impl( sal_uInt16 nPos, sal_uInt16 nFlag ) co
bool SfxItemPool::IsItemFlag( sal_uInt16 nWhich, sal_uInt16 nFlag ) const
{
for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pSecondary )
for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pImp->mpSecondary )
{
if ( pPool->IsInRange(nWhich) )
return pPool->IsItemFlag_Impl( pPool->GetIndex_Impl(nWhich), nFlag);
......@@ -120,7 +121,7 @@ SfxItemPool::SfxItemPool
#error "TF_POOLABLE should always be set."
#endif
bool bLoadRefCounts /* Ref-Counts mitladen oder auf 1 setzen */
)
) :
/* [Beschreibung]
......@@ -153,38 +154,26 @@ SfxItemPool::SfxItemPool
<SfxItemPool::ReldaseDefaults(sal_Bool)>
*/
: aName(rName),
nStart(nStartWhich),
nEnd(nEndWhich),
#ifdef TF_POOLABLE
pItemInfos(pInfos),
#else
#error "TF_POOLABLE should always be set."
#endif
pImp( new SfxItemPool_Impl( nStart, nEnd ) ),
ppStaticDefaults(0),
ppPoolDefaults(new SfxPoolItem* [ nEndWhich - nStartWhich + 1]),
pSecondary(0),
pMaster(this),
_pPoolRanges( 0 ),
bPersistentRefCounts(bLoadRefCounts),
maSfxItemPoolUsers()
pImp( new SfxItemPool_Impl( this, rName, nStartWhich, nEndWhich ) )
{
DBG_CTOR(SfxItemPool, 0);
DBG_ASSERT(nStart, "Start-Which-Id must be greater 0" );
pImp->eDefMetric = SFX_MAPUNIT_TWIP;
pImp->nVersion = 0;
pImp->bStreaming = sal_False;
pImp->bStreaming = false;
pImp->nLoadingVersion = 0;
pImp->nInitRefCount = 1;
pImp->nVerStart = nStart;
pImp->nVerEnd = nEnd;
pImp->nVerStart = pImp->mnStart;
pImp->nVerEnd = pImp->mnEnd;
pImp->bInSetItem = false;
pImp->nStoringStart = nStartWhich;
pImp->nStoringEnd = nEndWhich;
memset( ppPoolDefaults, 0, sizeof( SfxPoolItem* ) * (nEnd - nStart + 1));
pImp->mbPersistentRefCounts = bLoadRefCounts;
if ( pDefaults )
SetDefaults(pDefaults);
......@@ -202,7 +191,7 @@ SfxItemPool::SfxItemPool
sal_False
statische Defaults
"ubernehehmen */
)
) :
/* [Beschreibung]
......@@ -214,22 +203,12 @@ SfxItemPool::SfxItemPool
<SfxItemPool::Clone()const>
*/
: aName(rPool.aName),
nStart(rPool.nStart),
nEnd(rPool.nEnd),
#ifdef TF_POOLABLE
pItemInfos(rPool.pItemInfos),
#else
#error "TF_POOLABLE should always be set."
#endif
pImp( new SfxItemPool_Impl( nStart, nEnd ) ),
ppStaticDefaults(0),
ppPoolDefaults(new SfxPoolItem* [ nEnd - nStart + 1]),
pSecondary(0),
pMaster(this),
_pPoolRanges( 0 ),
bPersistentRefCounts(rPool.bPersistentRefCounts ),
maSfxItemPoolUsers()
pImp( new SfxItemPool_Impl( this, rPool.pImp->aName, rPool.pImp->mnStart, rPool.pImp->mnEnd ) )
{
DBG_CTOR(SfxItemPool, 0);
pImp->eDefMetric = rPool.pImp->eDefMetric;
......@@ -240,32 +219,31 @@ SfxItemPool::SfxItemPool
pImp->nVerStart = rPool.pImp->nVerStart;
pImp->nVerEnd = rPool.pImp->nVerEnd;
pImp->bInSetItem = false;
pImp->nStoringStart = nStart;
pImp->nStoringEnd = nEnd;
memset( ppPoolDefaults, 0, sizeof( SfxPoolItem* ) * (nEnd - nStart + 1));
pImp->nStoringStart = pImp->mnStart;
pImp->nStoringEnd = pImp->mnEnd;
pImp->mbPersistentRefCounts = rPool.pImp->mbPersistentRefCounts;
// Static Defaults "ubernehmen
if ( bCloneStaticDefaults )
{
SfxPoolItem **ppDefaults = new SfxPoolItem*[nEnd-nStart+1];
for ( sal_uInt16 n = 0; n <= nEnd - nStart; ++n )
SfxPoolItem **ppDefaults = new SfxPoolItem*[pImp->mnEnd-pImp->mnStart+1];
for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n )
{
(*( ppDefaults + n )) = (*( rPool.ppStaticDefaults + n ))->Clone(this);
(*( ppDefaults + n )) = (*( rPool.pImp->ppStaticDefaults + n ))->Clone(this);
(*( ppDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
}
SetDefaults( ppDefaults );
}
else
SetDefaults( rPool.ppStaticDefaults );
SetDefaults( rPool.pImp->ppStaticDefaults );
// Pool Defaults kopieren
for ( sal_uInt16 n = 0; n <= nEnd - nStart; ++n )
if ( (*( rPool.ppPoolDefaults + n )) )
for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n )
if ( (*( rPool.pImp->ppPoolDefaults + n )) )
{
(*( ppPoolDefaults + n )) = (*( rPool.ppPoolDefaults + n ))->Clone(this);
(*( ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT );
(*( pImp->ppPoolDefaults + n )) = (*( rPool.pImp->ppPoolDefaults + n ))->Clone(this);
(*( pImp->ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT );
}
// Copy Version-Map
......@@ -277,8 +255,8 @@ SfxItemPool::SfxItemPool
}
// Verkettung wiederherstellen
if ( rPool.pSecondary )
SetSecondaryPool( rPool.pSecondary->Clone() );
if ( rPool.pImp->mpSecondary )
SetSecondaryPool( rPool.pImp->mpSecondary->Clone() );
}
// -----------------------------------------------------------------------
......@@ -287,21 +265,21 @@ void SfxItemPool::SetDefaults( SfxPoolItem **pDefaults )
{
DBG_CHKTHIS(SfxItemPool, 0);
DBG_ASSERT( pDefaults, "erst wollen, dann nichts geben..." );
DBG_ASSERT( !ppStaticDefaults, "habe schon defaults" );
DBG_ASSERT( !pImp->ppStaticDefaults, "habe schon defaults" );
ppStaticDefaults = pDefaults;
pImp->ppStaticDefaults = pDefaults;
//! if ( (*ppStaticDefaults)->GetKind() != SFX_ITEMS_STATICDEFAULT )
//! geht wohl nicht im Zshg mit SetItems, die hinten stehen
{
DBG_ASSERT( (*ppStaticDefaults)->GetRefCount() == 0 ||
IsDefaultItem( (*ppStaticDefaults) ),
DBG_ASSERT( (*pImp->ppStaticDefaults)->GetRefCount() == 0 ||
IsDefaultItem( (*pImp->ppStaticDefaults) ),
"das sind keine statics" );
for ( sal_uInt16 n = 0; n <= nEnd - nStart; ++n )
for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n )
{
SFX_ASSERT( (*( ppStaticDefaults + n ))->Which() == n + nStart,
n + nStart, "static defaults not sorted" );
(*( ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
DBG_ASSERT( !(pImp->ppPoolItems[n]), "defaults with setitems with items?!" );
SFX_ASSERT( (*( pImp->ppStaticDefaults + n ))->Which() == n + pImp->mnStart,
n + pImp->mnStart, "static defaults not sorted" );
(*( pImp->ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
DBG_ASSERT( !(pImp->maPoolItems[n]), "defaults with setitems with items?!" );
}
}
}
......@@ -329,13 +307,13 @@ void SfxItemPool::ReleaseDefaults
*/
{
DBG_ASSERT( ppStaticDefaults, "keine Arme keine Kekse" );
ReleaseDefaults( ppStaticDefaults, nEnd - nStart + 1, bDelete );
DBG_ASSERT( pImp->ppStaticDefaults, "keine Arme keine Kekse" );
ReleaseDefaults( pImp->ppStaticDefaults, pImp->mnEnd - pImp->mnStart + 1, bDelete );
// KSO (22.10.98): ppStaticDefaults zeigt auf geloeschten Speicher,
// wenn bDelete == sal_True.
if ( bDelete )
ppStaticDefaults = 0;
pImp->ppStaticDefaults = 0;
}
// -----------------------------------------------------------------------
......@@ -386,11 +364,10 @@ void SfxItemPool::ReleaseDefaults
SfxItemPool::~SfxItemPool()
{
DBG_DTOR(SfxItemPool, 0);
DBG_ASSERT( pMaster == this, "destroying active Secondary-Pool" );
DBG_ASSERT( pImp->mpMaster == this, "destroying active Secondary-Pool" );
if ( pImp->ppPoolItems && ppPoolDefaults )
if ( !pImp->maPoolItems.empty() && pImp->ppPoolDefaults )
Delete();
delete[] _pPoolRanges;
delete pImp;
}
......@@ -399,8 +376,8 @@ void SfxItemPool::Free(SfxItemPool* pPool)
if(pPool)
{
// tell all the registered SfxItemPoolUsers that the pool is in destruction
SfxItemPoolUserVector aListCopy(pPool->maSfxItemPoolUsers.begin(), pPool->maSfxItemPoolUsers.end());
for(SfxItemPoolUserVector::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); ++aIterator)
std::vector<SfxItemPoolUser*> aListCopy(pPool->pImp->maSfxItemPoolUsers.begin(), pPool->pImp->maSfxItemPoolUsers.end());
for(std::vector<SfxItemPoolUser*>::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); ++aIterator)
{
SfxItemPoolUser* pSfxItemPoolUser = *aIterator;
DBG_ASSERT(pSfxItemPoolUser, "corrupt SfxItemPoolUser list (!)");
......@@ -409,7 +386,7 @@ void SfxItemPool::Free(SfxItemPool* pPool)
// Clear the vector. This means that user do not need to call RemoveSfxItemPoolUser()
// when they get called from ObjectInDestruction().
pPool->maSfxItemPoolUsers.clear();
pPool->pImp->maSfxItemPoolUsers.clear();
// delete pool
delete pPool;
......@@ -422,36 +399,35 @@ void SfxItemPool::Free(SfxItemPool* pPool)
void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool )
{
// ggf. an abgeh"angten Pools den Master zur"ucksetzen
if ( pSecondary )
if ( pImp->mpSecondary )
{
#ifdef DBG_UTIL
HACK( "fuer Image, dort gibt es derzeit keine Statics - Bug" )
if ( ppStaticDefaults )
if ( pImp->ppStaticDefaults )
{
// Delete() ist noch nicht gelaufen?
if ( pImp->ppPoolItems && pSecondary->pImp->ppPoolItems )
if ( !pImp->maPoolItems.empty() && !pImp->mpSecondary->pImp->maPoolItems.empty() )
{
// hat der master SetItems?
sal_Bool bHasSetItems = sal_False;
for ( sal_uInt16 i = 0; !bHasSetItems && i < nEnd-nStart; ++i )
bHasSetItems = ppStaticDefaults[i]->ISA(SfxSetItem);
for ( sal_uInt16 i = 0; !bHasSetItems && i < pImp->mnEnd - pImp->mnStart; ++i )
bHasSetItems = pImp->ppStaticDefaults[i]->ISA(SfxSetItem);
// abgehaengte Pools muessen leer sein
sal_Bool bOK = bHasSetItems;
bool bOK = bHasSetItems;
for ( sal_uInt16 n = 0;
bOK && n <= pSecondary->nEnd - pSecondary->nStart;
bOK && n <= pImp->mpSecondary->pImp->mnEnd - pImp->mpSecondary->pImp->mnStart;
++n )
{
SfxPoolItemArray_Impl** ppItemArr =
pSecondary->pImp->ppPoolItems + n;
if ( *ppItemArr )
SfxPoolItemArray_Impl* pItemArr = pImp->mpSecondary->pImp->maPoolItems[n];
if ( pItemArr )
{
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin();
for( size_t i = (*ppItemArr)->size(); i; ++ppHtArr, --i )
SfxPoolItemArrayBase_Impl::iterator ppHtArr = pItemArr->begin();
for( size_t i = pItemArr->size(); i; ++ppHtArr, --i )
if ( !(*ppHtArr) )
{
OSL_FAIL( "old secondary pool must be empty" );
bOK = sal_False;
bOK = false;
break;
}
}
......@@ -460,19 +436,19 @@ void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool )
}
#endif
pSecondary->pMaster = pSecondary;
for ( SfxItemPool *p = pSecondary->pSecondary; p; p = p->pSecondary )
p->pMaster = pSecondary;
pImp->mpSecondary->pImp->mpMaster = pImp->mpSecondary;
for ( SfxItemPool *p = pImp->mpSecondary->pImp->mpSecondary; p; p = p->pImp->mpSecondary )
p->pImp->mpMaster = pImp->mpSecondary;
}
// ggf. den Master der neuen Secondary-Pools setzen
DBG_ASSERT( !pPool || pPool->pMaster == pPool, "Secondary tanzt auf zwei Hochzeiten " );
SfxItemPool *pNewMaster = pMaster ? pMaster : this;
for ( SfxItemPool *p = pPool; p; p = p->pSecondary )
p->pMaster = pNewMaster;
DBG_ASSERT( !pPool || pPool->pImp->mpMaster == pPool, "Secondary tanzt auf zwei Hochzeiten " );
SfxItemPool *pNewMaster = pImp->mpMaster ? pImp->mpMaster : this;
for ( SfxItemPool *p = pPool; p; p = p->pImp->mpSecondary )
p->pImp->mpMaster = pNewMaster;
// neuen Secondary-Pool merken
pSecondary = pPool;
pImp->mpSecondary = pPool;
}
// -----------------------------------------------------------------------
......@@ -493,6 +469,11 @@ void SfxItemPool::SetDefaultMetric( SfxMapUnit eNewMetric )
pImp->eDefMetric = eNewMetric;
}
const UniString& SfxItemPool::GetName() const
{
return pImp->aName;
}
// -----------------------------------------------------------------------
SfxItemPresentation SfxItemPool::GetPresentation
......@@ -544,7 +525,7 @@ void SfxItemPool::Delete()
DBG_CHKTHIS(SfxItemPool, 0);
// schon deleted?
if ( !pImp->ppPoolItems || !ppPoolDefaults )
if ( pImp->maPoolItems.empty() || !pImp->ppPoolDefaults )
return;
// z.B. laufenden Requests bescheidsagen
......@@ -553,28 +534,28 @@ void SfxItemPool::Delete()
//MA 16. Apr. 97: Zweimal durchlaufen, in der ersten Runde fuer die SetItems.
//Der Klarheit halber wird das jetzt in zwei besser lesbare Schleifen aufgeteilt.
SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems;
SfxPoolItem** ppDefaultItem = ppPoolDefaults;
SfxPoolItem** ppStaticDefaultItem = ppStaticDefaults;
std::vector<SfxPoolItemArray_Impl*>::iterator itrItemArr = pImp->maPoolItems.begin();
SfxPoolItem** ppDefaultItem = pImp->ppPoolDefaults;
SfxPoolItem** ppStaticDefaultItem = pImp->ppStaticDefaults;
sal_uInt16 nArrCnt;
//Erst die SetItems abraeumen
HACK( "fuer Image, dort gibt es derzeit keine Statics - Bug" )
if ( ppStaticDefaults )
if ( pImp->ppStaticDefaults )
{
for ( nArrCnt = GetSize_Impl();
nArrCnt;
--nArrCnt, ++ppItemArr, ++ppDefaultItem, ++ppStaticDefaultItem )
--nArrCnt, ++itrItemArr, ++ppDefaultItem, ++ppStaticDefaultItem )
{
// KSO (22.10.98): *ppStaticDefaultItem kann im dtor einer
// von SfxItemPool abgeleiteten Klasse bereits geloescht worden
// sein! -> CHAOS Itempool
if ( *ppStaticDefaultItem && (*ppStaticDefaultItem)->ISA(SfxSetItem) )
{
if ( *ppItemArr )
if ( *itrItemArr )
{
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin();
for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr )
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*itrItemArr)->begin();
for ( size_t n = (*itrItemArr)->size(); n; --n, ++ppHtArr )
if (*ppHtArr)
{
#ifdef DBG_UTIL
......@@ -582,7 +563,7 @@ void SfxItemPool::Delete()
#endif
delete *ppHtArr;
}
DELETEZ( *ppItemArr );
DELETEZ( *itrItemArr );
}
if ( *ppDefaultItem )
{
......@@ -595,18 +576,18 @@ void SfxItemPool::Delete()
}
}
ppItemArr = pImp->ppPoolItems;
ppDefaultItem = ppPoolDefaults;
itrItemArr = pImp->maPoolItems.begin();
ppDefaultItem = pImp->ppPoolDefaults;
//Jetzt die 'einfachen' Items
for ( nArrCnt = GetSize_Impl();
nArrCnt;
--nArrCnt, ++ppItemArr, ++ppDefaultItem )
--nArrCnt, ++itrItemArr, ++ppDefaultItem )
{
if ( *ppItemArr )
if ( *itrItemArr )
{
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin();
for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr )
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*itrItemArr)->begin();
for ( size_t n = (*itrItemArr)->size(); n; --n, ++ppHtArr )
if (*ppHtArr)
{
#ifdef DBG_UTIL
......@@ -614,7 +595,7 @@ void SfxItemPool::Delete()
#endif
delete *ppHtArr;
}
delete *ppItemArr;
DELETEZ( *itrItemArr );
}
if ( *ppDefaultItem )
{
......@@ -626,7 +607,6 @@ void SfxItemPool::Delete()
}
pImp->DeleteItems();
delete[] ppPoolDefaults; ppPoolDefaults = 0;
}
// ----------------------------------------------------------------------
......@@ -637,7 +617,7 @@ void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
if ( IsInRange(rItem.Which()) )
{
SfxPoolItem **ppOldDefault =
ppPoolDefaults + GetIndex_Impl(rItem.Which());
pImp->ppPoolDefaults + GetIndex_Impl(rItem.Which());
SfxPoolItem *pNewDefault = rItem.Clone(this);
pNewDefault->SetKind(SFX_ITEMS_POOLDEFAULT);
if ( *ppOldDefault )
......@@ -647,8 +627,8 @@ void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
}
*ppOldDefault = pNewDefault;
}
else if ( pSecondary )
pSecondary->SetPoolDefaultItem(rItem);
else if ( pImp->mpSecondary )
pImp->mpSecondary->SetPoolDefaultItem(rItem);
else
{
SFX_ASSERT( 0, rItem.Which(), "unknown Which-Id - cannot set pool default" );
......@@ -665,15 +645,15 @@ void SfxItemPool::ResetPoolDefaultItem( sal_uInt16 nWhichId )
if ( IsInRange(nWhichId) )
{
SfxPoolItem **ppOldDefault =
ppPoolDefaults + GetIndex_Impl( nWhichId );
pImp->ppPoolDefaults + GetIndex_Impl( nWhichId );
if ( *ppOldDefault )
{
(*ppOldDefault)->SetRefCount(0);
DELETEZ( *ppOldDefault );
}
}
else if ( pSecondary )
pSecondary->ResetPoolDefaultItem(nWhichId);
else if ( pImp->mpSecondary )
pImp->mpSecondary->ResetPoolDefaultItem(nWhichId);
else
{
SFX_ASSERT( 0, nWhichId, "unknown Which-Id - cannot set pool default" );
......@@ -693,11 +673,11 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
nWhich = rItem.Which();
// richtigen Secondary-Pool finden
sal_Bool bSID = nWhich > SFX_WHICH_MAX;
bool bSID = nWhich > SFX_WHICH_MAX;
if ( !bSID && !IsInRange(nWhich) )
{
if ( pSecondary )
return pSecondary->Put( rItem, nWhich );
if ( pImp->mpSecondary )
return pImp->mpSecondary->Put( rItem, nWhich );
OSL_FAIL( "unknown Which-Id - cannot put item" );
}
......@@ -709,7 +689,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
SFX_ASSERT( USHRT_MAX != nIndex || rItem.Which() != nWhich ||
!IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE,
nWhich, "ein nicht Pool-Item ist Default?!" );
SfxPoolItem *pPoolItem = rItem.Clone(pMaster);
SfxPoolItem *pPoolItem = rItem.Clone(pImp->mpMaster);
pPoolItem->SetWhich(nWhich);
AddRef( *pPoolItem );
return *pPoolItem;
......@@ -718,70 +698,72 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
SFX_ASSERT( rItem.IsA(GetDefaultItem(nWhich).Type()), nWhich,
"SFxItemPool: wrong item type in Put" );
SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems + nIndex;
if( !*ppItemArr )
*ppItemArr = new SfxPoolItemArray_Impl;
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex];
if (!pItemArr)
{
pImp->maPoolItems[nIndex] = new SfxPoolItemArray_Impl;
pItemArr = pImp->maPoolItems[nIndex];
}
SfxPoolItemArrayBase_Impl::iterator ppFree;
sal_Bool ppFreeIsSet = sal_False;
SfxPoolItemArrayBase_Impl::iterator ppHtArray = (*ppItemArr)->begin();
bool ppFreeIsSet = false;
if ( IsItemFlag_Impl( nIndex, SFX_ITEM_POOLABLE ) )
{
// wenn es ueberhaupt gepoolt ist, koennte es schon drin sein
if ( IsPooledItem(&rItem) )
{
// 1. Schleife: teste ob der Pointer vorhanden ist.
for( size_t n = (*ppItemArr)->size(); n; ++ppHtArray, --n )
if( &rItem == (*ppHtArray) )
{
AddRef( **ppHtArray );
return **ppHtArray;
}
SfxPoolItemArrayBase_Impl::iterator itr =
std::find(pItemArr->begin(), pItemArr->end(), &rItem);
if (itr != pItemArr->end())
{
AddRef(**itr);
return **itr;
}
}
// 2. Schleife: dann muessen eben die Attribute verglichen werden
size_t n;
for ( n = (*ppItemArr)->size(), ppHtArray = (*ppItemArr)->begin();
n; ++ppHtArray, --n )
SfxPoolItemArrayBase_Impl::iterator itr = pItemArr->begin();
for (; itr != pItemArr->end(); ++itr)
{
if ( *ppHtArray )
if (*itr)
{
if( **ppHtArray == rItem )
if (**itr == rItem)
{
AddRef( **ppHtArray );
return **ppHtArray;
AddRef(**itr);
return **itr;
}
}
else
if ( ppFreeIsSet == sal_False )
{
if (!ppFreeIsSet)
{
ppFree = ppHtArray;
ppFreeIsSet = sal_True;
ppFree = itr;
ppFreeIsSet = true;
}
}
}
}
else
{
// freien Platz suchen
SfxPoolItemArrayBase_Impl::iterator ppHtArr;
size_t n, nCount = (*ppItemArr)->size();
for ( n = (*ppItemArr)->nFirstFree,
ppHtArr = (*ppItemArr)->begin() + n;
n < nCount;
++ppHtArr, ++n )
if ( !*ppHtArr )
SfxPoolItemArrayBase_Impl::iterator itr = pItemArr->begin();
std::advance(itr, pItemArr->nFirstFree);
for (; itr != pItemArr->end(); ++itr)
{
if (!*itr)
{
ppFree = ppHtArr;
ppFreeIsSet = sal_True;
ppFree = itr;
ppFreeIsSet = true;
break;
}
}
// naechstmoeglichen freien Platz merken
(*ppItemArr)->nFirstFree = n;
pItemArr->nFirstFree = std::distance(pItemArr->begin(), itr);
}
// nicht vorhanden, also im PtrArray eintragen
SfxPoolItem* pNewItem = rItem.Clone(pMaster);
SfxPoolItem* pNewItem = rItem.Clone(pImp->mpMaster);
pNewItem->SetWhich(nWhich);
#ifdef DBG_UTIL
SFX_ASSERT( rItem.Type() == pNewItem->Type(), nWhich, "unequal types in Put(): no Clone()?" )
......@@ -800,9 +782,9 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
#endif
#endif
AddRef( *pNewItem, pImp->nInitRefCount );
SfxPoolItem* pTemp = pNewItem;
if ( ppFreeIsSet == sal_False )
(*ppItemArr)->push_back( pTemp );
if ( ppFreeIsSet == false )
pItemArr->push_back( pNewItem );
else
{
DBG_ASSERT( *ppFree == 0, "using surrogate in use" );
......@@ -826,12 +808,12 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
// richtigen Secondary-Pool finden
const sal_uInt16 nWhich = rItem.Which();
sal_Bool bSID = nWhich > SFX_WHICH_MAX;
bool bSID = nWhich > SFX_WHICH_MAX;
if ( !bSID && !IsInRange(nWhich) )
{
if ( pSecondary )
if ( pImp->mpSecondary )
{
pSecondary->Remove( rItem );
pImp->mpSecondary->Remove( rItem );
return;
}
OSL_FAIL( "unknown Which-Id - cannot remove item" );
......@@ -856,35 +838,38 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
// statische Defaults sind eben einfach da
if ( rItem.GetKind() == SFX_ITEMS_STATICDEFAULT &&
&rItem == *( ppStaticDefaults + GetIndex_Impl(nWhich) ) )
&rItem == *( pImp->ppStaticDefaults + GetIndex_Impl(nWhich) ) )
return;
// Item im eigenen Pool suchen
SfxPoolItemArray_Impl** ppItemArr = (pImp->ppPoolItems + nIndex);
SFX_ASSERT( *ppItemArr, rItem.Which(), "removing Item not in Pool" );
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin();
for( size_t n = (*ppItemArr)->size(); n; ++ppHtArr, --n )
if( *ppHtArr == &rItem )
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex];
SFX_ASSERT( pItemArr, rItem.Which(), "removing Item not in Pool" );
SfxPoolItemArrayBase_Impl::iterator ppHtArrBeg = pItemArr->begin(), ppHtArrEnd = pItemArr->end();
for (SfxPoolItemArrayBase_Impl::iterator ppHtArr = ppHtArrBeg; ppHtArr != ppHtArrEnd; ++ppHtArr)
{
SfxPoolItem*& p = *ppHtArr;
if (p == &rItem)
{
if ( (*ppHtArr)->GetRefCount() ) //!
ReleaseRef( **ppHtArr );
if ( p->GetRefCount() ) //!
ReleaseRef( *p );
else
{
SFX_ASSERT( 0, rItem.Which(), "removing Item without ref" );
SFX_TRACE( "to be removed, but not no refs: ", *ppHtArr );
SFX_TRACE( "to be removed, but not no refs: ", p );
}
// ggf. kleinstmoegliche freie Position merken
size_t nPos = (*ppItemArr)->size() - n;
if ( (*ppItemArr)->nFirstFree > nPos )
(*ppItemArr)->nFirstFree = nPos;
size_t nPos = std::distance(ppHtArrBeg, ppHtArr);
if ( pItemArr->nFirstFree > nPos )
pItemArr->nFirstFree = nPos;
//! MI: Hack, solange wir das Problem mit dem Outliner haben
//! siehe anderes MI-REF
if ( 0 == (*ppHtArr)->GetRefCount() && nWhich < 4000 )
DELETEZ(*ppHtArr);
if ( 0 == p->GetRefCount() && nWhich < 4000 )
DELETEZ(p);
return;
}
}
// nicht vorhanden
SFX_ASSERT( 0, rItem.Which(), "removing Item not in Pool" );
......@@ -899,21 +884,28 @@ const SfxPoolItem& SfxItemPool::GetDefaultItem( sal_uInt16 nWhich ) const
if ( !IsInRange(nWhich) )
{
if ( pSecondary )
return pSecondary->GetDefaultItem( nWhich );
if ( pImp->mpSecondary )
return pImp->mpSecondary->GetDefaultItem( nWhich );
SFX_ASSERT( 0, nWhich, "unknown which - dont ask me for defaults" );
}
DBG_ASSERT( ppStaticDefaults, "no defaults known - dont ask me for defaults" );
DBG_ASSERT( pImp->ppStaticDefaults, "no defaults known - dont ask me for defaults" );
sal_uInt16 nPos = GetIndex_Impl(nWhich);
SfxPoolItem *pDefault = *(ppPoolDefaults + nPos);
SfxPoolItem *pDefault = *(pImp->ppPoolDefaults + nPos);
if ( pDefault )
return *pDefault;
return **(ppStaticDefaults + nPos);
return **(pImp->ppStaticDefaults + nPos);
}
// -----------------------------------------------------------------------
SfxItemPool* SfxItemPool::GetSecondaryPool() const
{
return pImp->mpSecondary;
}
SfxItemPool* SfxItemPool::GetMasterPool() const
{
return pImp->mpMaster;
}
void SfxItemPool::FreezeIdRanges()
......@@ -927,7 +919,7 @@ void SfxItemPool::FreezeIdRanges()
*/
{
FillItemIdRanges_Impl( _pPoolRanges );
FillItemIdRanges_Impl( pImp->mpPoolRanges );
}
......@@ -936,25 +928,28 @@ void SfxItemPool::FreezeIdRanges()
void SfxItemPool::FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const
{
DBG_CHKTHIS(SfxItemPool, 0);
DBG_ASSERT( !_pPoolRanges, "GetFrozenRanges() would be faster!" );
DBG_ASSERT( !pImp->mpPoolRanges, "GetFrozenRanges() would be faster!" );
const SfxItemPool *pPool;
sal_uInt16 nLevel = 0;
for( pPool = this; pPool; pPool = pPool->pSecondary )
for( pPool = this; pPool; pPool = pPool->pImp->mpSecondary )
++nLevel;
pWhichRanges = new sal_uInt16[ 2*nLevel + 1 ];
nLevel = 0;
for( pPool = this; pPool; pPool = pPool->pSecondary )
for( pPool = this; pPool; pPool = pPool->pImp->mpSecondary )
{
*(pWhichRanges+(nLevel++)) = pPool->nStart;
*(pWhichRanges+(nLevel++)) = pPool->nEnd;
*(pWhichRanges+(nLevel++)) = pPool->pImp->mnStart;
*(pWhichRanges+(nLevel++)) = pPool->pImp->mnEnd;
*(pWhichRanges+nLevel) = 0;
}
}
// -----------------------------------------------------------------------
const sal_uInt16* SfxItemPool::GetFrozenIdRanges() const
{
return pImp->mpPoolRanges;
}
const SfxPoolItem *SfxItemPool::GetItem2(sal_uInt16 nWhich, sal_uInt32 nOfst) const
{
......@@ -962,17 +957,17 @@ const SfxPoolItem *SfxItemPool::GetItem2(sal_uInt16 nWhich, sal_uInt32 nOfst) co
if ( !IsInRange(nWhich) )
{
if ( pSecondary )
return pSecondary->GetItem2( nWhich, nOfst );
if ( pImp->mpSecondary )
return pImp->mpSecondary->GetItem2( nWhich, nOfst );
SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot resolve surrogate" );
return 0;
}
// dflt-Attribut?
if ( nOfst == SFX_ITEMS_DEFAULT )
return *(ppStaticDefaults + GetIndex_Impl(nWhich));
return *(pImp->ppStaticDefaults + GetIndex_Impl(nWhich));
SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich));
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[GetIndex_Impl(nWhich)];
if( pItemArr && nOfst < pItemArr->size() )
return (*pItemArr)[nOfst];
......@@ -987,13 +982,13 @@ sal_uInt32 SfxItemPool::GetItemCount2(sal_uInt16 nWhich) const
if ( !IsInRange(nWhich) )
{
if ( pSecondary )
return pSecondary->GetItemCount2( nWhich );
if ( pImp->mpSecondary )
return pImp->mpSecondary->GetItemCount2( nWhich );
SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot resolve surrogate" );
return 0;
}
SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich));
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[GetIndex_Impl(nWhich)];
if ( pItemArr )
return pItemArr->size();
return 0;
......@@ -1007,15 +1002,15 @@ sal_uInt16 SfxItemPool::GetWhich( sal_uInt16 nSlotId, sal_Bool bDeep ) const
return nSlotId;
#ifdef TF_POOLABLE
sal_uInt16 nCount = nEnd - nStart + 1;
sal_uInt16 nCount = pImp->mnEnd - pImp->mnStart + 1;
for ( sal_uInt16 nOfs = 0; nOfs < nCount; ++nOfs )
if ( pItemInfos[nOfs]._nSID == nSlotId )
return nOfs + nStart;
return nOfs + pImp->mnStart;
#else
#error "TF_POOLABLE should always be set."
#endif
if ( pSecondary && bDeep )
return pSecondary->GetWhich(nSlotId);
if ( pImp->mpSecondary && bDeep )
return pImp->mpSecondary->GetWhich(nSlotId);
return nSlotId;
}
......@@ -1028,14 +1023,14 @@ sal_uInt16 SfxItemPool::GetSlotId( sal_uInt16 nWhich, sal_Bool bDeep ) const
if ( !IsInRange( nWhich ) )
{
if ( pSecondary && bDeep )
return pSecondary->GetSlotId(nWhich);
if ( pImp->mpSecondary && bDeep )
return pImp->mpSecondary->GetSlotId(nWhich);
SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot get slot-id" );
return 0;
}
#ifdef TF_POOLABLE
sal_uInt16 nSID = pItemInfos[nWhich - nStart]._nSID;
sal_uInt16 nSID = pItemInfos[nWhich - pImp->mnStart]._nSID;
return nSID ? nSID : nWhich;
#else
#error "TF_POOLABLE should always be set."
......@@ -1050,15 +1045,15 @@ sal_uInt16 SfxItemPool::GetTrueWhich( sal_uInt16 nSlotId, sal_Bool bDeep ) const
return 0;
#ifdef TF_POOLABLE
sal_uInt16 nCount = nEnd - nStart + 1;
sal_uInt16 nCount = pImp->mnEnd - pImp->mnStart + 1;
for ( sal_uInt16 nOfs = 0; nOfs < nCount; ++nOfs )
if ( pItemInfos[nOfs]._nSID == nSlotId )
return nOfs + nStart;
return nOfs + pImp->mnStart;
#else
#error "TF_POOLABLE should always be set."
#endif
if ( pSecondary && bDeep )
return pSecondary->GetTrueWhich(nSlotId);
if ( pImp->mpSecondary && bDeep )
return pImp->mpSecondary->GetTrueWhich(nSlotId);
return 0;
}
......@@ -1071,18 +1066,23 @@ sal_uInt16 SfxItemPool::GetTrueSlotId( sal_uInt16 nWhich, sal_Bool bDeep ) const
if ( !IsInRange( nWhich ) )
{
if ( pSecondary && bDeep )
return pSecondary->GetTrueSlotId(nWhich);
if ( pImp->mpSecondary && bDeep )
return pImp->mpSecondary->GetTrueSlotId(nWhich);
SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot get slot-id" );
return 0;
}
#ifdef TF_POOLABLE
return pItemInfos[nWhich - nStart]._nSID;
return pItemInfos[nWhich - pImp->mnStart]._nSID;
#else
#error "TF_POOLABLE should always be set."
#endif
}
// -----------------------------------------------------------------------
sal_uInt16 SfxItemPool::GetFileFormatVersion() const
{
return pImp->mnFileFormatVersion;
}
void SfxItemPool::SetFileFormatVersion( sal_uInt16 nFileFormatVersion )
/* [Description]
......@@ -1094,10 +1094,10 @@ void SfxItemPool::SetFileFormatVersion( sal_uInt16 nFileFormatVersion )
*/
{
DBG_ASSERT( this == pMaster,
DBG_ASSERT( this == pImp->mpMaster,
"SfxItemPool::SetFileFormatVersion() but not a master pool" );
for ( SfxItemPool *pPool = this; pPool; pPool = pPool->pSecondary )
pPool->_nFileFormatVersion = nFileFormatVersion;
for ( SfxItemPool *pPool = this; pPool; pPool = pPool->pImp->mpSecondary )
pPool->pImp->mnFileFormatVersion = nFileFormatVersion;
}
......
......@@ -122,9 +122,9 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
DBG_CHKTHIS(SfxItemPool, 0);
// Store-Master finden
SfxItemPool *pStoreMaster = pMaster != this ? pMaster : 0;
SfxItemPool *pStoreMaster = pImp->mpMaster != this ? pImp->mpMaster : 0;
while ( pStoreMaster && !pStoreMaster->pImp->bStreaming )
pStoreMaster = pStoreMaster->pSecondary;
pStoreMaster = pStoreMaster->pImp->mpSecondary;
// Alter-Header (Version des Pools an sich und Inhalts-Version 0xffff)
pImp->bStreaming = sal_True;
......@@ -149,7 +149,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
{
SfxMiniRecordWriter aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER);
rStream << pImp->nVersion;
SfxPoolItem::writeByteString(rStream, aName);
SfxPoolItem::writeByteString(rStream, pImp->aName);
}
// Version-Maps
......@@ -169,7 +169,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
}
// Workaround gegen Bug in SetVersionMap der 312
if ( SOFFICE_FILEFORMAT_31 == _nFileFormatVersion )
if ( SOFFICE_FILEFORMAT_31 == pImp->mnFileFormatVersion )
rStream << sal_uInt16(nNewWhich+1);
}
}
......@@ -183,13 +183,13 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
{
pImp->bInSetItem = ft != 0;
SfxPoolItemArray_Impl **pArr = pImp->ppPoolItems;
SfxPoolItem **ppDefItem = ppStaticDefaults;
std::vector<SfxPoolItemArray_Impl*>::iterator itrArr = pImp->maPoolItems.begin();
SfxPoolItem **ppDefItem = pImp->ppStaticDefaults;
const sal_uInt16 nSize = GetSize_Impl();
for ( size_t i = 0; i < nSize && !rStream.GetError(); ++i, ++pArr, ++ppDefItem )
for ( size_t i = 0; i < nSize && !rStream.GetError(); ++i, ++itrArr, ++ppDefItem )
{
// Version des Items feststellen
sal_uInt16 nItemVersion = (*ppDefItem)->GetVersion( _nFileFormatVersion );
sal_uInt16 nItemVersion = (*ppDefItem)->GetVersion( pImp->mnFileFormatVersion );
if ( USHRT_MAX == nItemVersion )
// => kam in zu exportierender Version gar nicht vor
continue;
......@@ -197,7 +197,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
// !poolable wird gar nicht im Pool gespeichert
// und itemsets/plain-items je nach Runde
#ifdef TF_POOLABLE
if ( *pArr && IsItemFlag(**ppDefItem, SFX_ITEM_POOLABLE) &&
if ( *itrArr && IsItemFlag(**ppDefItem, SFX_ITEM_POOLABLE) &&
#else
#error "TF_POOLABLE should always be set."
#endif
......@@ -208,7 +208,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
aWhichIdsRec.NewContent(nSlotId, 0);
rStream << (*ppDefItem)->Which();
rStream << nItemVersion;
const sal_uInt32 nCount = ::std::min<size_t>( (*pArr)->size(), SAL_MAX_UINT32 );
const sal_uInt32 nCount = ::std::min<size_t>( (*itrArr)->size(), SAL_MAX_UINT32 );
DBG_ASSERT(nCount, "ItemArr is empty");
rStream << nCount;
......@@ -217,7 +217,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
for ( size_t j = 0; j < nCount; ++j )
{
// Item selbst besorgen
const SfxPoolItem *pItem = (*pArr)->operator[](j);
const SfxPoolItem *pItem = (*itrArr)->operator[](j);
if ( pItem && pItem->GetRefCount() ) //! siehe anderes MI-REF
{
aItemsRec.NewContent((sal_uInt16)j, 'X' );
......@@ -263,11 +263,11 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
sal_uInt16 nCount = GetSize_Impl();
for ( sal_uInt16 n = 0; n < nCount; ++n )
{
const SfxPoolItem* pDefaultItem = ppPoolDefaults[n];
const SfxPoolItem* pDefaultItem = pImp->ppPoolDefaults[n];
if ( pDefaultItem )
{
// Version ermitteln
sal_uInt16 nItemVersion = pDefaultItem->GetVersion( _nFileFormatVersion );
sal_uInt16 nItemVersion = pDefaultItem->GetVersion( pImp->mnFileFormatVersion );
if ( USHRT_MAX == nItemVersion )
// => gab es in der Version noch nicht
continue;
......@@ -287,14 +287,17 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
// weitere Pools rausschreiben
ImpSvlData::GetSvlData().pStoringPool = 0;
aPoolRec.Close();
if ( !rStream.GetError() && pSecondary )
pSecondary->Store( rStream );
if ( !rStream.GetError() && pImp->mpSecondary )
pImp->mpSecondary->Store( rStream );
pImp->bStreaming = sal_False;
return rStream;
}
// -----------------------------------------------------------------------
bool SfxItemPool::HasPersistentRefCounts() const
{
return pImp->mbPersistentRefCounts;
}
void SfxItemPool::LoadCompleted()
......@@ -325,15 +328,15 @@ void SfxItemPool::LoadCompleted()
{
// "uber alle Which-Werte iterieren
SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems;
for( sal_uInt16 nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++ppItemArr )
std::vector<SfxPoolItemArray_Impl*>::iterator itrItemArr = pImp->maPoolItems.begin();
for( sal_uInt16 nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++itrItemArr )
{
// ist "uberhaupt ein Item mit dem Which-Wert da?
if ( *ppItemArr )
if ( *itrItemArr )
{
// "uber alle Items mit dieser Which-Id iterieren
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin();
for( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr )
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*itrItemArr)->begin();
for( size_t n = (*itrItemArr)->size(); n; --n, ++ppHtArr )
if (*ppHtArr)
{
#ifdef DBG_UTIL
......@@ -354,14 +357,29 @@ void SfxItemPool::LoadCompleted()
}
// notify secondary pool
if ( pSecondary )
pSecondary->LoadCompleted();
if ( pImp->mpSecondary )
pImp->mpSecondary->LoadCompleted();
}
sal_uInt16 SfxItemPool::GetFirstWhich() const
{
return pImp->mnStart;
}
sal_uInt16 SfxItemPool::GetLastWhich() const
{
return pImp->mnEnd;
}
bool SfxItemPool::IsInRange( sal_uInt16 nWhich ) const
{
return nWhich >= pImp->mnStart && nWhich <= pImp->mnEnd;
}
//============================================================================
// This had to be moved to a method of its own to keep Solaris GCC happy:
void SfxItemPool::readTheItems (
SvStream & rStream, sal_uInt32 nItemCount, sal_uInt16 nVersion,
void SfxItemPool_Impl::readTheItems (
SvStream & rStream, sal_uInt32 nItemCount, sal_uInt16 nVer,
SfxPoolItem * pDefItem, SfxPoolItemArray_Impl ** ppArr)
{
SfxMultiRecordReader aItemsRec( &rStream, SFX_ITEMPOOL_REC_ITEMS );
......@@ -386,18 +404,18 @@ void SfxItemPool::readTheItems (
sal_uInt16 nRef(0);
rStream >> nRef;
pItem = pDefItem->Create(rStream, nVersion);
pItem = pDefItem->Create(rStream, nVer);
pNewArr->push_back( (SfxPoolItem*) pItem );
if ( !bPersistentRefCounts )
if ( !mbPersistentRefCounts )
// bis <SfxItemPool::LoadCompleted()> festhalten
AddRef(*pItem, 1);
SfxItemPool::AddRef(*pItem, 1);
else
{
if ( nRef > SFX_ITEMS_OLD_MAXREF )
pItem->SetKind( nRef );
SfxItemPool::SetKind(*pItem, nRef);
else
AddRef(*pItem, nRef);
SfxItemPool::AddRef(*pItem, nRef);
}
}
......@@ -438,8 +456,8 @@ void SfxItemPool::readTheItems (
else if ( *rpNewItem == *pOldItem )
{
// wiederverwenden
AddRef( *pOldItem, rpNewItem->GetRefCount() );
SetRefCount( *rpNewItem, 0 );
SfxItemPool::AddRef( *pOldItem, rpNewItem->GetRefCount() );
SfxItemPool::SetRefCount( *rpNewItem, 0 );
delete rpNewItem;
rpNewItem = pOldItem;
bFound = true;
......@@ -466,22 +484,22 @@ void SfxItemPool::readTheItems (
SvStream &SfxItemPool::Load(SvStream &rStream)
{
DBG_CHKTHIS(SfxItemPool, 0);
DBG_ASSERT(ppStaticDefaults, "kein DefaultArray");
DBG_ASSERT(pImp->ppStaticDefaults, "kein DefaultArray");
// protect items by increasing ref count
if ( !bPersistentRefCounts )
if ( !pImp->mbPersistentRefCounts )
{
// "uber alle Which-Werte iterieren
SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems;
for( size_t nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++ppItemArr )
std::vector<SfxPoolItemArray_Impl*>::iterator itrItemArr = pImp->maPoolItems.begin();
for( size_t nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++itrItemArr )
{
// ist "uberhaupt ein Item mit dem Which-Wert da?
if ( *ppItemArr )
if ( *itrItemArr )
{
// "uber alle Items mit dieser Which-Id iterieren
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin();
for( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr )
SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*itrItemArr)->begin();
for( size_t n = (*itrItemArr)->size(); n; --n, ++ppHtArr )
if (*ppHtArr)
{
#ifdef DBG_UTIL
......@@ -502,9 +520,9 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
}
// Load-Master finden
SfxItemPool *pLoadMaster = pMaster != this ? pMaster : 0;
SfxItemPool *pLoadMaster = pImp->mpMaster != this ? pImp->mpMaster : 0;
while ( pLoadMaster && !pLoadMaster->pImp->bStreaming )
pLoadMaster = pLoadMaster->pSecondary;
pLoadMaster = pLoadMaster->pImp->mpSecondary;
// Gesamt Header einlesen
pImp->bStreaming = sal_True;
......@@ -516,8 +534,8 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
rStream >> pImp->nMajorVer >> pImp->nMinorVer;
// Format-Version in Master-Pool "ubertragen
pMaster->pImp->nMajorVer = pImp->nMajorVer;
pMaster->pImp->nMinorVer = pImp->nMinorVer;
pImp->mpMaster->pImp->nMajorVer = pImp->nMajorVer;
pImp->mpMaster->pImp->nMinorVer = pImp->nMinorVer;
// altes Format?
if ( pImp->nMajorVer < 2 )
......@@ -560,7 +578,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
// Header-lesen
rStream >> pImp->nLoadingVersion;
SfxPoolItem::readByteString(rStream, aExternName);
bOwnPool = aExternName == aName;
bOwnPool = aExternName == pImp->aName;
//! solange wir keine fremden Pools laden k"onnen
if ( !bOwnPool )
......@@ -632,19 +650,19 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
//! nWhich, "Slot/Which mismatch" );
sal_uInt16 nIndex = GetIndex_Impl(nWhich);
SfxPoolItemArray_Impl **ppArr = pImp->ppPoolItems + nIndex;
SfxPoolItemArray_Impl **ppArr = &pImp->maPoolItems[0] + nIndex;
// SfxSetItems k"onnten Items aus Sekund"arpools beinhalten
SfxPoolItem *pDefItem = *(ppStaticDefaults + nIndex);
SfxPoolItem *pDefItem = *(pImp->ppStaticDefaults + nIndex);
pImp->bInSetItem = pDefItem->ISA(SfxSetItem);
if ( !bSecondaryLoaded && pSecondary && pImp->bInSetItem )
if ( !bSecondaryLoaded && pImp->mpSecondary && pImp->bInSetItem )
{
// an das Ende des eigenen Pools seeken
sal_uLong nLastPos = rStream.Tell();
aPoolRec.Skip();
// Sekund"arpool einlesen
pSecondary->Load( rStream );
pImp->mpSecondary->Load( rStream );
bSecondaryLoaded = true;
nSecondaryEnd = rStream.Tell();
......@@ -653,9 +671,9 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
}
// Items an sich lesen
readTheItems(rStream, nCount, nVersion, pDefItem, ppArr);
pImp->readTheItems(rStream, nCount, nVersion, pDefItem, ppArr);
pImp->bInSetItem = sal_False;
pImp->bInSetItem = false;
}
}
......@@ -683,32 +701,42 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
// Pool-Default-Item selbst laden
SfxPoolItem *pItem =
( *( ppStaticDefaults + GetIndex_Impl(nWhich) ) )
( *( pImp->ppStaticDefaults + GetIndex_Impl(nWhich) ) )
->Create( rStream, nVersion );
pItem->SetKind( SFX_ITEMS_POOLDEFAULT );
*( ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem;
*( pImp->ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem;
}
}
// ggf. Secondary-Pool laden
aPoolRec.Skip();
if ( pSecondary )
if ( pImp->mpSecondary )
{
if ( !bSecondaryLoaded )
pSecondary->Load( rStream );
pImp->mpSecondary->Load( rStream );
else
rStream.Seek( nSecondaryEnd );
}
// wenn nicht own-Pool, dann kein Name
if ( aExternName != aName )
aName.Erase();
if ( aExternName != pImp->aName )
pImp->aName.Erase();
pImp->bStreaming = sal_False;
return rStream;
};
// -----------------------------------------------------------------------
sal_uInt16 SfxItemPool::GetIndex_Impl(sal_uInt16 nWhich) const
{
DBG_CHKTHIS(SfxItemPool, 0);
DBG_ASSERT(nWhich >= pImp->mnStart && nWhich <= pImp->mnEnd, "Which-Id nicht im Pool-Bereich");
return nWhich - pImp->mnStart;
}
sal_uInt16 SfxItemPool::GetSize_Impl() const
{
return pImp->mnEnd - pImp->mnStart + 1;
}
SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
{
......@@ -725,7 +753,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
if ( pImp->nMajorVer > 1 || pImp->nMinorVer >= 2 )
rStream >> pImp->nLoadingVersion;
SfxPoolItem::readByteString(rStream, aExternName);
bOwnPool = aExternName == aName;
bOwnPool = aExternName == pImp->aName;
pImp->bStreaming = sal_True;
//! solange wir keine fremden laden k"onnen
......@@ -816,7 +844,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
sal_uInt32 nAttrSize(0);
rStream >> nVersion >> nCount;
SfxPoolItemArray_Impl **ppArr = 0;
std::vector<SfxPoolItemArray_Impl*>::iterator ppArr;
SfxPoolItemArray_Impl *pNewArr = 0;
SfxPoolItem *pDefItem = 0;
if ( bKnownItem )
......@@ -830,16 +858,17 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
//! nWhich, "Slot/Which mismatch" );
sal_uInt16 nIndex = GetIndex_Impl(nWhich);
ppArr = pImp->ppPoolItems + nIndex;
ppArr = pImp->maPoolItems.begin();
std::advance(ppArr, nIndex);
pNewArr = new SfxPoolItemArray_Impl();
pDefItem = *(ppStaticDefaults + nIndex);
pDefItem = *(pImp->ppStaticDefaults + nIndex);
}
// Position vor ersten Item merken
sal_uLong nLastPos = rStream.Tell();
// SfxSetItems k"onnten Items aus Sekund"arpools beinhalten
if ( !bSecondaryLoaded && pSecondary && pDefItem->ISA(SfxSetItem) )
if ( !bSecondaryLoaded && pImp->mpSecondary && pDefItem->ISA(SfxSetItem) )
{
// an das Ende des eigenen Pools seeken
rStream.Seek(nEndOfSizes);
......@@ -847,7 +876,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
CHECK_FILEFORMAT_RELEASE( rStream, SFX_ITEMPOOL_TAG_ENDPOOL, pNewArr );
// Sekund"arpool einlesen
pSecondary->Load1_Impl( rStream );
pImp->mpSecondary->Load1_Impl( rStream );
bSecondaryLoaded = true;
nSecondaryEnd = rStream.Tell();
......@@ -868,7 +897,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
{
pItem = pDefItem->Create(rStream, nVersion);
if ( !bPersistentRefCounts )
if ( !pImp->mbPersistentRefCounts )
// bis <SfxItemPool::LoadCompleted()> festhalten
AddRef(*pItem, 1);
else
......@@ -971,10 +1000,10 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
if ( !bOwnPool )
nWhich = nMappedWhich;
SfxPoolItem *pItem =
( *( ppStaticDefaults + GetIndex_Impl(nWhich) ) )
( *( pImp->ppStaticDefaults + GetIndex_Impl(nWhich) ) )
->Create( rStream, nVersion );
pItem->SetKind( SFX_ITEMS_POOLDEFAULT );
*( ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem;
*( pImp->ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem;
}
nLastPos = rStream.Tell();
......@@ -990,16 +1019,16 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_ENDPOOL );
CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_ENDPOOL );
if ( pSecondary )
if ( pImp->mpSecondary )
{
if ( !bSecondaryLoaded )
pSecondary->Load1_Impl( rStream );
pImp->mpSecondary->Load1_Impl( rStream );
else
rStream.Seek( nSecondaryEnd );
}
if ( aExternName != aName )
aName.Erase();
if ( aExternName != pImp->aName )
pImp->aName.Erase();
pImp->bStreaming = sal_False;
return rStream;
......@@ -1089,18 +1118,18 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate
const SfxPoolItem *pItem = 0;
if ( bResolvable )
{
for ( SfxItemPool *pTarget = this; pTarget; pTarget = pTarget->pSecondary )
for ( SfxItemPool *pTarget = this; pTarget; pTarget = pTarget->pImp->mpSecondary )
{
// richtigen (Folge-) Pool gefunden?
if ( pTarget->IsInRange(rWhich) )
{
// dflt-Attribut?
if ( SFX_ITEMS_DEFAULT == nSurrogat )
return *(pTarget->ppStaticDefaults +
return *(pTarget->pImp->ppStaticDefaults +
pTarget->GetIndex_Impl(rWhich));
SfxPoolItemArray_Impl* pItemArr = *(pTarget->pImp->ppPoolItems +
pTarget->GetIndex_Impl(rWhich));
SfxPoolItemArray_Impl* pItemArr =
pTarget->pImp->maPoolItems[pTarget->GetIndex_Impl(rWhich)];
pItem = pItemArr && nSurrogat < pItemArr->size()
? (*pItemArr)[nSurrogat]
: 0;
......@@ -1112,7 +1141,7 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate
}
// Nachladen aus Ref-Pool?
if ( pRefPool != pMaster )
if ( pRefPool != pImp->mpMaster )
return &pTarget->Put( *pItem );
// Referenzen sind NICHT schon mit Pool geladen worden?
......@@ -1184,8 +1213,8 @@ sal_uInt32 SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const
if ( !IsInRange(pItem->Which()) )
{
if ( pSecondary )
return pSecondary->GetSurrogate( pItem );
if ( pImp->mpSecondary )
return pImp->mpSecondary->GetSurrogate( pItem );
SFX_ASSERT( 0, pItem->Which(), "unknown Which-Id - dont ask me for surrogates" );
}
......@@ -1193,7 +1222,7 @@ sal_uInt32 SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const
if( IsStaticDefaultItem(pItem) || IsPoolDefaultItem(pItem) )
return SFX_ITEMS_DEFAULT;
SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(pItem->Which()));
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[GetIndex_Impl(pItem->Which())];
DBG_ASSERT(pItemArr, "ItemArr is not available");
for ( size_t i = 0; i < pItemArr->size(); ++i )
......@@ -1365,8 +1394,8 @@ sal_uInt16 SfxItemPool::GetNewWhich
// (Sekund"ar-) Pool bestimmen
if ( !IsInVersionsRange(nFileWhich) )
{
if ( pSecondary )
return pSecondary->GetNewWhich( nFileWhich );
if ( pImp->mpSecondary )
return pImp->mpSecondary->GetNewWhich( nFileWhich );
SFX_ASSERT( 0, nFileWhich, "unknown which in GetNewWhich()" );
}
......@@ -1451,7 +1480,7 @@ bool SfxItemPool::IsCurrentVersionLoading() const
{
return ( pImp->nVersion == pImp->nLoadingVersion ) &&
( !pSecondary || pSecondary->IsCurrentVersionLoading() );
( !pImp->mpSecondary || pImp->mpSecondary->IsCurrentVersionLoading() );
}
//-------------------------------------------------------------------------
......@@ -1493,14 +1522,14 @@ bool SfxItemPool::StoreItem( SvStream &rStream, const SfxPoolItem &rItem,
return sal_False;
const SfxItemPool *pPool = this;
while ( !pPool->IsInStoringRange(rItem.Which()) )
if ( 0 == ( pPool = pPool->pSecondary ) )
if ( 0 == ( pPool = pPool->pImp->mpSecondary ) )
return sal_False;
DBG_ASSERT( !pImp->bInSetItem || !rItem.ISA(SfxSetItem),
"SetItem contains ItemSet with SetItem" );
sal_uInt16 nSlotId = pPool->GetSlotId( rItem.Which(), sal_True );
sal_uInt16 nItemVersion = rItem.GetVersion(_nFileFormatVersion);
sal_uInt16 nItemVersion = rItem.GetVersion(pImp->mnFileFormatVersion);
if ( USHRT_MAX == nItemVersion )
return sal_False;
......@@ -1539,8 +1568,8 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, bool bDirect,
// richtigen Sekund"ar-Pool finden
while ( !pRefPool->IsInVersionsRange(nWhich) )
{
if ( pRefPool->pSecondary )
pRefPool = pRefPool->pSecondary;
if ( pRefPool->pImp->mpSecondary )
pRefPool = pRefPool->pImp->mpSecondary;
else
{
// WID in der Version nicht vorhanden => ueberspringen
......@@ -1563,7 +1592,7 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, bool bDirect,
nWhich = pRefPool->GetNewWhich( nWhich );
DBG_ASSERT( !nWhich || !pImp->bInSetItem ||
!pRefPool->ppStaticDefaults[pRefPool->GetIndex_Impl(nWhich)]->ISA(SfxSetItem),
!pRefPool->pImp->ppStaticDefaults[pRefPool->GetIndex_Impl(nWhich)]->ISA(SfxSetItem),
"loading SetItem in ItemSet of SetItem" );
// soll "uber Surrogat geladen werden?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment