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