tdf#89329: use unique_ptr for pImpl in itempool

Change-Id: Ie0a5e5a16cf4b724ff55b0a89ee0ec803df6eb41
Reviewed-on: https://gerrit.libreoffice.org/25635
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Xisco Fauli
2016-05-29 21:15:01 +02:00
committed by Noel Grandin
parent c150ac0787
commit c8ff6e35d6
4 changed files with 259 additions and 260 deletions

View File

@@ -24,6 +24,7 @@
#include <svl/poolitem.hxx> #include <svl/poolitem.hxx>
#include <svl/svldllapi.h> #include <svl/svldllapi.h>
#include <tools/solar.h> #include <tools/solar.h>
#include <memory>
class SvStream; class SvStream;
class SfxBroadcaster; class SfxBroadcaster;
@@ -62,7 +63,7 @@ class SVL_DLLPUBLIC SfxItemPool
friend struct SfxItemPool_Impl; friend struct SfxItemPool_Impl;
const SfxItemInfo* pItemInfos; const SfxItemInfo* pItemInfos;
SfxItemPool_Impl* pImp; std::unique_ptr<SfxItemPool_Impl> pImpl;
public: public:
void AddSfxItemPoolUser(SfxItemPoolUser& rNewUser); void AddSfxItemPoolUser(SfxItemPoolUser& rNewUser);

View File

@@ -163,7 +163,7 @@ struct SfxItemPool_Impl
// unit testing // unit testing
friend class PoolItemTest; friend class PoolItemTest;
static SfxItemPool_Impl *GetImpl(SfxItemPool *pPool) { return pPool->pImp; } static SfxItemPool_Impl *GetImpl(SfxItemPool *pPool) { return pPool->pImpl.get(); }
}; };

View File

@@ -73,7 +73,7 @@ lcl_CheckSlots2(std::map<sal_uInt16, sal_uInt16> & rSlotMap,
#define CHECK_SLOTS() \ #define CHECK_SLOTS() \
do { \ do { \
std::map<sal_uInt16, sal_uInt16> slotmap; \ std::map<sal_uInt16, sal_uInt16> slotmap; \
for (SfxItemPool * p = pImp->mpMaster; p; p = p->pImp->mpSecondary) \ for (SfxItemPool * p = pImpl->mpMaster; p; p = p->pImpl->mpSecondary) \
{ \ { \
lcl_CheckSlots2(slotmap, *p, p->pItemInfos); \ lcl_CheckSlots2(slotmap, *p, p->pItemInfos); \
} \ } \
@@ -86,16 +86,16 @@ do { \
void SfxItemPool::AddSfxItemPoolUser(SfxItemPoolUser& rNewUser) void SfxItemPool::AddSfxItemPoolUser(SfxItemPoolUser& rNewUser)
{ {
pImp->maSfxItemPoolUsers.push_back(&rNewUser); pImpl->maSfxItemPoolUsers.push_back(&rNewUser);
} }
void SfxItemPool::RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser) void SfxItemPool::RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser)
{ {
const std::vector<SfxItemPoolUser*>::iterator aFindResult = ::std::find( const std::vector<SfxItemPoolUser*>::iterator aFindResult = ::std::find(
pImp->maSfxItemPoolUsers.begin(), pImp->maSfxItemPoolUsers.end(), &rOldUser); pImpl->maSfxItemPoolUsers.begin(), pImpl->maSfxItemPoolUsers.end(), &rOldUser);
if(aFindResult != pImp->maSfxItemPoolUsers.end()) if(aFindResult != pImpl->maSfxItemPoolUsers.end())
{ {
pImp->maSfxItemPoolUsers.erase(aFindResult); pImpl->maSfxItemPoolUsers.erase(aFindResult);
} }
} }
@@ -103,9 +103,9 @@ const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( sal_uInt16 nWhich ) const
{ {
const SfxPoolItem* pRet; const SfxPoolItem* pRet;
if( IsInRange( nWhich ) ) if( IsInRange( nWhich ) )
pRet = *(pImp->ppPoolDefaults + GetIndex_Impl( nWhich )); pRet = *(pImpl->ppPoolDefaults + GetIndex_Impl( nWhich ));
else if( pImp->mpSecondary ) else if( pImpl->mpSecondary )
pRet = pImp->mpSecondary->GetPoolDefaultItem( nWhich ); pRet = pImpl->mpSecondary->GetPoolDefaultItem( nWhich );
else else
{ {
assert(false && "unknown WhichId - cannot get pool default"); assert(false && "unknown WhichId - cannot get pool default");
@@ -123,7 +123,7 @@ bool SfxItemPool::IsItemPoolable_Impl( sal_uInt16 nPos ) const
bool SfxItemPool::IsItemPoolable( sal_uInt16 nWhich ) const bool SfxItemPool::IsItemPoolable( sal_uInt16 nWhich ) const
{ {
for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pImp->mpSecondary ) for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pImpl->mpSecondary )
{ {
if ( pPool->IsInRange(nWhich) ) if ( pPool->IsInRange(nWhich) )
return pPool->IsItemPoolable_Impl( pPool->GetIndex_Impl(nWhich)); return pPool->IsItemPoolable_Impl( pPool->GetIndex_Impl(nWhich));
@@ -135,7 +135,7 @@ bool SfxItemPool::IsItemPoolable( sal_uInt16 nWhich ) const
SfxBroadcaster& SfxItemPool::BC() SfxBroadcaster& SfxItemPool::BC()
{ {
return pImp->aBC; return pImpl->aBC;
} }
@@ -173,19 +173,19 @@ SfxItemPool::SfxItemPool
bool bLoadRefCounts /* Load RefCounts or set to 1? */ bool bLoadRefCounts /* Load RefCounts or set to 1? */
) : ) :
pItemInfos(pInfo), pItemInfos(pInfo),
pImp( new SfxItemPool_Impl( this, rName, nStartWhich, nEndWhich ) ) pImpl( new SfxItemPool_Impl( this, rName, nStartWhich, nEndWhich ) )
{ {
pImp->eDefMetric = SFX_MAPUNIT_TWIP; pImpl->eDefMetric = SFX_MAPUNIT_TWIP;
pImp->nVersion = 0; pImpl->nVersion = 0;
pImp->bStreaming = false; pImpl->bStreaming = false;
pImp->nLoadingVersion = 0; pImpl->nLoadingVersion = 0;
pImp->nInitRefCount = 1; pImpl->nInitRefCount = 1;
pImp->nVerStart = pImp->mnStart; pImpl->nVerStart = pImpl->mnStart;
pImp->nVerEnd = pImp->mnEnd; pImpl->nVerEnd = pImpl->mnEnd;
pImp->bInSetItem = false; pImpl->bInSetItem = false;
pImp->nStoringStart = nStartWhich; pImpl->nStoringStart = nStartWhich;
pImp->nStoringEnd = nEndWhich; pImpl->nStoringEnd = nEndWhich;
pImp->mbPersistentRefCounts = bLoadRefCounts; pImpl->mbPersistentRefCounts = bLoadRefCounts;
if ( pDefaults ) if ( pDefaults )
SetDefaults(pDefaults); SetDefaults(pDefaults);
@@ -207,74 +207,74 @@ SfxItemPool::SfxItemPool
Take over static Defaults */ Take over static Defaults */
) : ) :
pItemInfos(rPool.pItemInfos), pItemInfos(rPool.pItemInfos),
pImp( new SfxItemPool_Impl( this, rPool.pImp->aName, rPool.pImp->mnStart, rPool.pImp->mnEnd ) ) pImpl( new SfxItemPool_Impl( this, rPool.pImpl->aName, rPool.pImpl->mnStart, rPool.pImpl->mnEnd ) )
{ {
pImp->eDefMetric = rPool.pImp->eDefMetric; pImpl->eDefMetric = rPool.pImpl->eDefMetric;
pImp->nVersion = rPool.pImp->nVersion; pImpl->nVersion = rPool.pImpl->nVersion;
pImp->bStreaming = false; pImpl->bStreaming = false;
pImp->nLoadingVersion = 0; pImpl->nLoadingVersion = 0;
pImp->nInitRefCount = 1; pImpl->nInitRefCount = 1;
pImp->nVerStart = rPool.pImp->nVerStart; pImpl->nVerStart = rPool.pImpl->nVerStart;
pImp->nVerEnd = rPool.pImp->nVerEnd; pImpl->nVerEnd = rPool.pImpl->nVerEnd;
pImp->bInSetItem = false; pImpl->bInSetItem = false;
pImp->nStoringStart = pImp->mnStart; pImpl->nStoringStart = pImpl->mnStart;
pImp->nStoringEnd = pImp->mnEnd; pImpl->nStoringEnd = pImpl->mnEnd;
pImp->mbPersistentRefCounts = rPool.pImp->mbPersistentRefCounts; pImpl->mbPersistentRefCounts = rPool.pImpl->mbPersistentRefCounts;
// Take over static Defaults // Take over static Defaults
if ( bCloneStaticDefaults ) if ( bCloneStaticDefaults )
{ {
SfxPoolItem **ppDefaults = new SfxPoolItem*[pImp->mnEnd-pImp->mnStart+1]; SfxPoolItem **ppDefaults = new SfxPoolItem*[pImpl->mnEnd-pImpl->mnStart+1];
for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n ) for ( sal_uInt16 n = 0; n <= pImpl->mnEnd - pImpl->mnStart; ++n )
{ {
(*( ppDefaults + n )) = (*( rPool.pImp->ppStaticDefaults + n ))->Clone(this); (*( ppDefaults + n )) = (*( rPool.pImpl->ppStaticDefaults + n ))->Clone(this);
(*( ppDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT ); (*( ppDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
} }
SetDefaults( ppDefaults ); SetDefaults( ppDefaults );
} }
else else
SetDefaults( rPool.pImp->ppStaticDefaults ); SetDefaults( rPool.pImpl->ppStaticDefaults );
// Copy Pool Defaults // Copy Pool Defaults
for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n ) for ( sal_uInt16 n = 0; n <= pImpl->mnEnd - pImpl->mnStart; ++n )
if ( (*( rPool.pImp->ppPoolDefaults + n )) ) if ( (*( rPool.pImpl->ppPoolDefaults + n )) )
{ {
(*( pImp->ppPoolDefaults + n )) = (*( rPool.pImp->ppPoolDefaults + n ))->Clone(this); (*( pImpl->ppPoolDefaults + n )) = (*( rPool.pImpl->ppPoolDefaults + n ))->Clone(this);
(*( pImp->ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT ); (*( pImpl->ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT );
} }
// Copy Version map // Copy Version map
for (std::shared_ptr<SfxPoolVersion_Impl>& pOld : rPool.pImp->aVersions) for (std::shared_ptr<SfxPoolVersion_Impl>& pOld : rPool.pImpl->aVersions)
{ {
SfxPoolVersion_ImplPtr pNew = std::make_shared<SfxPoolVersion_Impl>( *pOld ); SfxPoolVersion_ImplPtr pNew = std::make_shared<SfxPoolVersion_Impl>( *pOld );
pImp->aVersions.push_back( pNew ); pImpl->aVersions.push_back( pNew );
} }
// Repair linkage // Repair linkage
if ( rPool.pImp->mpSecondary ) if ( rPool.pImpl->mpSecondary )
SetSecondaryPool( rPool.pImp->mpSecondary->Clone() ); SetSecondaryPool( rPool.pImpl->mpSecondary->Clone() );
} }
void SfxItemPool::SetDefaults( SfxPoolItem **pDefaults ) void SfxItemPool::SetDefaults( SfxPoolItem **pDefaults )
{ {
DBG_ASSERT( pDefaults, "first we ask for it, and then we don't give back..." ); DBG_ASSERT( pDefaults, "first we ask for it, and then we don't give back..." );
DBG_ASSERT( !pImp->ppStaticDefaults, "already have Defaults" ); DBG_ASSERT( !pImpl->ppStaticDefaults, "already have Defaults" );
pImp->ppStaticDefaults = pDefaults; pImpl->ppStaticDefaults = pDefaults;
//! if ( (*ppStaticDefaults)->GetKind() != SFX_ITEMS_STATICDEFAULT ) //! if ( (*ppStaticDefaults)->GetKind() != SFX_ITEMS_STATICDEFAULT )
//! FIXME: Probably doesn't work with SetItems at the end //! FIXME: Probably doesn't work with SetItems at the end
{ {
DBG_ASSERT( (*pImp->ppStaticDefaults)->GetRefCount() == 0 || DBG_ASSERT( (*pImpl->ppStaticDefaults)->GetRefCount() == 0 ||
IsDefaultItem( (*pImp->ppStaticDefaults) ), IsDefaultItem( (*pImpl->ppStaticDefaults) ),
"these are not static" ); "these are not static" );
for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n ) for ( sal_uInt16 n = 0; n <= pImpl->mnEnd - pImpl->mnStart; ++n )
{ {
assert(((*(pImp->ppStaticDefaults + n))->Which() == n + pImp->mnStart) assert(((*(pImpl->ppStaticDefaults + n))->Which() == n + pImpl->mnStart)
&& "static defaults not sorted" ); && "static defaults not sorted" );
(*( pImp->ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT ); (*( pImpl->ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
DBG_ASSERT( !(pImp->maPoolItems[n]), "defaults with setitems with items?!" ); DBG_ASSERT( !(pImpl->maPoolItems[n]), "defaults with setitems with items?!" );
} }
} }
} }
@@ -298,12 +298,12 @@ void SfxItemPool::ReleaseDefaults
{ {
DBG_ASSERT( pImp->ppStaticDefaults, "requirements not met" ); DBG_ASSERT( pImpl->ppStaticDefaults, "requirements not met" );
ReleaseDefaults( pImp->ppStaticDefaults, pImp->mnEnd - pImp->mnStart + 1, bDelete ); ReleaseDefaults( pImpl->ppStaticDefaults, pImpl->mnEnd - pImpl->mnStart + 1, bDelete );
// ppStaticDefaults points to deleted memory if bDelete == true. // ppStaticDefaults points to deleted memory if bDelete == true.
if ( bDelete ) if ( bDelete )
pImp->ppStaticDefaults = nullptr; pImpl->ppStaticDefaults = nullptr;
} }
@@ -346,21 +346,19 @@ void SfxItemPool::ReleaseDefaults
SfxItemPool::~SfxItemPool() SfxItemPool::~SfxItemPool()
{ {
if ( !pImp->maPoolItems.empty() && pImp->ppPoolDefaults ) if ( !pImpl->maPoolItems.empty() && pImpl->ppPoolDefaults )
Delete(); Delete();
if (pImp->mpMaster != nullptr && pImp->mpMaster != this) if (pImpl->mpMaster != nullptr && pImpl->mpMaster != this)
{ {
// This condition indicates an error. // This condition indicates an error.
// A pImp->mpMaster->SetSecondaryPool(...) call should have been made // A pImpl->mpMaster->SetSecondaryPool(...) call should have been made
// earlier to prevent this. At this point we can only try to // earlier to prevent this. At this point we can only try to
// prevent a crash later on. // prevent a crash later on.
DBG_ASSERT( pImp->mpMaster == this, "destroying active Secondary-Pool" ); DBG_ASSERT( pImpl->mpMaster == this, "destroying active Secondary-Pool" );
if (pImp->mpMaster->pImp->mpSecondary == this) if (pImpl->mpMaster->pImpl->mpSecondary == this)
pImp->mpMaster->pImp->mpSecondary = nullptr; pImpl->mpMaster->pImpl->mpSecondary = nullptr;
} }
delete pImp;
} }
void SfxItemPool::Free(SfxItemPool* pPool) void SfxItemPool::Free(SfxItemPool* pPool)
@@ -368,7 +366,7 @@ 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
std::vector<SfxItemPoolUser*> aListCopy(pPool->pImp->maSfxItemPoolUsers.begin(), pPool->pImp->maSfxItemPoolUsers.end()); std::vector<SfxItemPoolUser*> aListCopy(pPool->pImpl->maSfxItemPoolUsers.begin(), pPool->pImpl->maSfxItemPoolUsers.end());
for(std::vector<SfxItemPoolUser*>::const_iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); ++aIterator) for(std::vector<SfxItemPoolUser*>::const_iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); ++aIterator)
{ {
SfxItemPoolUser* pSfxItemPoolUser = *aIterator; SfxItemPoolUser* pSfxItemPoolUser = *aIterator;
@@ -378,7 +376,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->pImp->maSfxItemPoolUsers.clear(); pPool->pImpl->maSfxItemPoolUsers.clear();
// delete pool // delete pool
delete pPool; delete pPool;
@@ -389,25 +387,25 @@ void SfxItemPool::Free(SfxItemPool* pPool)
void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool ) void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool )
{ {
// Reset Master in attached Pools // Reset Master in attached Pools
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
{ {
#ifdef DBG_UTIL #ifdef DBG_UTIL
if (pImp->ppStaticDefaults != nullptr && !pImp->maPoolItems.empty() if (pImpl->ppStaticDefaults != nullptr && !pImpl->maPoolItems.empty()
&& !pImp->mpSecondary->pImp->maPoolItems.empty()) && !pImpl->mpSecondary->pImpl->maPoolItems.empty())
// Delete() did not yet run? // Delete() did not yet run?
{ {
// Does the Master have SetItems? // Does the Master have SetItems?
bool bHasSetItems = false; bool bHasSetItems = false;
for ( sal_uInt16 i = 0; !bHasSetItems && i < pImp->mnEnd - pImp->mnStart; ++i ) for ( sal_uInt16 i = 0; !bHasSetItems && i < pImpl->mnEnd - pImpl->mnStart; ++i )
bHasSetItems = dynamic_cast<const SfxSetItem *>(pImp->ppStaticDefaults[i]) != nullptr; bHasSetItems = dynamic_cast<const SfxSetItem *>(pImpl->ppStaticDefaults[i]) != nullptr;
// Detached Pools must be empty // Detached Pools must be empty
bool bOK = bHasSetItems; bool bOK = bHasSetItems;
for ( sal_uInt16 n = 0; for ( sal_uInt16 n = 0;
bOK && n <= pImp->mpSecondary->pImp->mnEnd - pImp->mpSecondary->pImp->mnStart; bOK && n <= pImpl->mpSecondary->pImpl->mnEnd - pImpl->mpSecondary->pImpl->mnStart;
++n ) ++n )
{ {
SfxPoolItemArray_Impl* pItemArr = pImp->mpSecondary->pImp->maPoolItems[n]; SfxPoolItemArray_Impl* pItemArr = pImpl->mpSecondary->pImpl->maPoolItems[n];
if ( pItemArr ) if ( pItemArr )
{ {
SfxPoolItemArrayBase_Impl::const_iterator ppHtArr = pItemArr->begin(); SfxPoolItemArrayBase_Impl::const_iterator ppHtArr = pItemArr->begin();
@@ -423,19 +421,19 @@ void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool )
} }
#endif #endif
pImp->mpSecondary->pImp->mpMaster = pImp->mpSecondary; pImpl->mpSecondary->pImpl->mpMaster = pImpl->mpSecondary;
for ( SfxItemPool *p = pImp->mpSecondary->pImp->mpSecondary; p; p = p->pImp->mpSecondary ) for ( SfxItemPool *p = pImpl->mpSecondary->pImpl->mpSecondary; p; p = p->pImpl->mpSecondary )
p->pImp->mpMaster = pImp->mpSecondary; p->pImpl->mpMaster = pImpl->mpSecondary;
} }
// Set Master of new Secondary Pools // Set Master of new Secondary Pools
DBG_ASSERT( !pPool || pPool->pImp->mpMaster == pPool, "Secondary is present in two Pools" ); DBG_ASSERT( !pPool || pPool->pImpl->mpMaster == pPool, "Secondary is present in two Pools" );
SfxItemPool *pNewMaster = GetMasterPool() ? pImp->mpMaster : this; SfxItemPool *pNewMaster = GetMasterPool() ? pImpl->mpMaster : this;
for ( SfxItemPool *p = pPool; p; p = p->pImp->mpSecondary ) for ( SfxItemPool *p = pPool; p; p = p->pImpl->mpSecondary )
p->pImp->mpMaster = pNewMaster; p->pImpl->mpMaster = pNewMaster;
// Remember new Secondary Pool // Remember new Secondary Pool
pImp->mpSecondary = pPool; pImpl->mpSecondary = pPool;
CHECK_SLOTS(); CHECK_SLOTS();
} }
@@ -449,18 +447,18 @@ void SfxItemPool::SetItemInfos(SfxItemInfo const*const pInfo)
SfxMapUnit SfxItemPool::GetMetric( sal_uInt16 ) const SfxMapUnit SfxItemPool::GetMetric( sal_uInt16 ) const
{ {
return pImp->eDefMetric; return pImpl->eDefMetric;
} }
void SfxItemPool::SetDefaultMetric( SfxMapUnit eNewMetric ) void SfxItemPool::SetDefaultMetric( SfxMapUnit eNewMetric )
{ {
pImp->eDefMetric = eNewMetric; pImpl->eDefMetric = eNewMetric;
} }
const OUString& SfxItemPool::GetName() const const OUString& SfxItemPool::GetName() const
{ {
return pImp->aName; return pImpl->aName;
} }
@@ -487,21 +485,21 @@ SfxItemPool* SfxItemPool::Clone() const
void SfxItemPool::Delete() void SfxItemPool::Delete()
{ {
// Already deleted? // Already deleted?
if ( pImp->maPoolItems.empty() || !pImp->ppPoolDefaults ) if ( pImpl->maPoolItems.empty() || !pImpl->ppPoolDefaults )
return; return;
// Inform e.g. running Requests // Inform e.g. running Requests
pImp->aBC.Broadcast( SfxSimpleHint( SFX_HINT_DYING ) ); pImpl->aBC.Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
// Iterate through twice: first for the SetItems. // Iterate through twice: first for the SetItems.
// We separate this into two loops (for clarity's sake) // We separate this into two loops (for clarity's sake)
std::vector<SfxPoolItemArray_Impl*>::iterator itrItemArr = pImp->maPoolItems.begin(); std::vector<SfxPoolItemArray_Impl*>::iterator itrItemArr = pImpl->maPoolItems.begin();
SfxPoolItem** ppDefaultItem = pImp->ppPoolDefaults; SfxPoolItem** ppDefaultItem = pImpl->ppPoolDefaults;
SfxPoolItem** ppStaticDefaultItem = pImp->ppStaticDefaults; SfxPoolItem** ppStaticDefaultItem = pImpl->ppStaticDefaults;
sal_uInt16 nArrCnt; sal_uInt16 nArrCnt;
// Collect the SetItems first // Collect the SetItems first
if (pImp->ppStaticDefaults != nullptr) { if (pImpl->ppStaticDefaults != nullptr) {
for ( nArrCnt = GetSize_Impl(); for ( nArrCnt = GetSize_Impl();
nArrCnt; nArrCnt;
--nArrCnt, ++itrItemArr, ++ppDefaultItem, ++ppStaticDefaultItem ) --nArrCnt, ++itrItemArr, ++ppDefaultItem, ++ppStaticDefaultItem )
@@ -535,8 +533,8 @@ void SfxItemPool::Delete()
} }
} }
itrItemArr = pImp->maPoolItems.begin(); itrItemArr = pImpl->maPoolItems.begin();
ppDefaultItem = pImp->ppPoolDefaults; ppDefaultItem = pImpl->ppPoolDefaults;
// Now for the easy Items // Now for the easy Items
for ( nArrCnt = GetSize_Impl(); for ( nArrCnt = GetSize_Impl();
@@ -565,7 +563,7 @@ void SfxItemPool::Delete()
} }
} }
pImp->DeleteItems(); pImpl->DeleteItems();
} }
@@ -574,7 +572,7 @@ void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
if ( IsInRange(rItem.Which()) ) if ( IsInRange(rItem.Which()) )
{ {
SfxPoolItem **ppOldDefault = SfxPoolItem **ppOldDefault =
pImp->ppPoolDefaults + GetIndex_Impl(rItem.Which()); pImpl->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 )
@@ -584,8 +582,8 @@ void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
} }
*ppOldDefault = pNewDefault; *ppOldDefault = pNewDefault;
} }
else if ( pImp->mpSecondary ) else if ( pImpl->mpSecondary )
pImp->mpSecondary->SetPoolDefaultItem(rItem); pImpl->mpSecondary->SetPoolDefaultItem(rItem);
else else
{ {
assert(false && "unknown WhichId - cannot set pool default"); assert(false && "unknown WhichId - cannot set pool default");
@@ -601,15 +599,15 @@ void SfxItemPool::ResetPoolDefaultItem( sal_uInt16 nWhichId )
if ( IsInRange(nWhichId) ) if ( IsInRange(nWhichId) )
{ {
SfxPoolItem **ppOldDefault = SfxPoolItem **ppOldDefault =
pImp->ppPoolDefaults + GetIndex_Impl( nWhichId ); pImpl->ppPoolDefaults + GetIndex_Impl( nWhichId );
if ( *ppOldDefault ) if ( *ppOldDefault )
{ {
(*ppOldDefault)->SetRefCount(0); (*ppOldDefault)->SetRefCount(0);
DELETEZ( *ppOldDefault ); DELETEZ( *ppOldDefault );
} }
} }
else if ( pImp->mpSecondary ) else if ( pImpl->mpSecondary )
pImp->mpSecondary->ResetPoolDefaultItem(nWhichId); pImpl->mpSecondary->ResetPoolDefaultItem(nWhichId);
else else
{ {
assert(false && "unknown WhichId - cannot reset pool default"); assert(false && "unknown WhichId - cannot reset pool default");
@@ -626,8 +624,8 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
bool bSID = nWhich > SFX_WHICH_MAX; bool bSID = nWhich > SFX_WHICH_MAX;
if ( !bSID && !IsInRange(nWhich) ) if ( !bSID && !IsInRange(nWhich) )
{ {
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
return pImp->mpSecondary->Put( rItem, nWhich ); return pImpl->mpSecondary->Put( rItem, nWhich );
OSL_FAIL( "unknown WhichId - cannot put item" ); OSL_FAIL( "unknown WhichId - cannot put item" );
} }
@@ -638,20 +636,20 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
assert((USHRT_MAX != nIndex || rItem.Which() != nWhich || assert((USHRT_MAX != nIndex || rItem.Which() != nWhich ||
!IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE) !IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE)
&& "a non Pool Item is Default?!"); && "a non Pool Item is Default?!");
SfxPoolItem *pPoolItem = rItem.Clone(pImp->mpMaster); SfxPoolItem *pPoolItem = rItem.Clone(pImpl->mpMaster);
pPoolItem->SetWhich(nWhich); pPoolItem->SetWhich(nWhich);
AddRef( *pPoolItem ); AddRef( *pPoolItem );
return *pPoolItem; return *pPoolItem;
} }
assert(!pImp->ppStaticDefaults || assert(!pImpl->ppStaticDefaults ||
typeid(rItem) == typeid(GetDefaultItem(nWhich))); typeid(rItem) == typeid(GetDefaultItem(nWhich)));
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex]; SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[nIndex];
if (!pItemArr) if (!pItemArr)
{ {
pImp->maPoolItems[nIndex] = new SfxPoolItemArray_Impl; pImpl->maPoolItems[nIndex] = new SfxPoolItemArray_Impl;
pItemArr = pImp->maPoolItems[nIndex]; pItemArr = pImpl->maPoolItems[nIndex];
} }
SfxPoolItemArrayBase_Impl::iterator ppFree; SfxPoolItemArrayBase_Impl::iterator ppFree;
@@ -714,7 +712,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
} }
// 3. not found, so clone to insert into the pointer array. // 3. not found, so clone to insert into the pointer array.
SfxPoolItem* pNewItem = rItem.Clone(pImp->mpMaster); SfxPoolItem* pNewItem = rItem.Clone(pImpl->mpMaster);
pNewItem->SetWhich(nWhich); pNewItem->SetWhich(nWhich);
assert(typeid(rItem) == typeid(*pNewItem) && "SfxItemPool::Put(): unequal types, no Clone() override?"); assert(typeid(rItem) == typeid(*pNewItem) && "SfxItemPool::Put(): unequal types, no Clone() override?");
if (dynamic_cast<const SfxSetItem*>(&rItem) == nullptr) if (dynamic_cast<const SfxSetItem*>(&rItem) == nullptr)
@@ -724,7 +722,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
assert((!IsItemPoolable(*pNewItem) || *pNewItem == rItem) assert((!IsItemPoolable(*pNewItem) || *pNewItem == rItem)
&& "SfxItemPool::Put(): unequal items: no operator== override?"); && "SfxItemPool::Put(): unequal items: no operator== override?");
} }
AddRef( *pNewItem, pImp->nInitRefCount ); AddRef( *pNewItem, pImpl->nInitRefCount );
// 4. finally insert into the pointer array // 4. finally insert into the pointer array
assert( pItemArr->maPtrToIndex.find(pNewItem) == pItemArr->maPtrToIndex.end() ); assert( pItemArr->maPtrToIndex.find(pNewItem) == pItemArr->maPtrToIndex.end() );
@@ -772,9 +770,9 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
bool bSID = nWhich > SFX_WHICH_MAX; bool bSID = nWhich > SFX_WHICH_MAX;
if ( !bSID && !IsInRange(nWhich) ) if ( !bSID && !IsInRange(nWhich) )
{ {
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
{ {
pImp->mpSecondary->Remove( rItem ); pImpl->mpSecondary->Remove( rItem );
return; return;
} }
OSL_FAIL( "unknown WhichId - cannot remove item" ); OSL_FAIL( "unknown WhichId - cannot remove item" );
@@ -798,11 +796,11 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
// Static Defaults are just there // Static Defaults are just there
if ( rItem.GetKind() == SFX_ITEMS_STATICDEFAULT && if ( rItem.GetKind() == SFX_ITEMS_STATICDEFAULT &&
&rItem == *( pImp->ppStaticDefaults + GetIndex_Impl(nWhich) ) ) &rItem == *( pImpl->ppStaticDefaults + GetIndex_Impl(nWhich) ) )
return; return;
// Find Item in own Pool // Find Item in own Pool
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex]; SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[nIndex];
assert(pItemArr && "removing Item not in Pool"); assert(pItemArr && "removing Item not in Pool");
SfxPoolItemArray_Impl::PoolItemPtrToIndexMap::const_iterator it; SfxPoolItemArray_Impl::PoolItemPtrToIndexMap::const_iterator it;
@@ -846,27 +844,27 @@ const SfxPoolItem& SfxItemPool::GetDefaultItem( sal_uInt16 nWhich ) const
{ {
if ( !IsInRange(nWhich) ) if ( !IsInRange(nWhich) )
{ {
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
return pImp->mpSecondary->GetDefaultItem( nWhich ); return pImpl->mpSecondary->GetDefaultItem( nWhich );
assert(!"unknown which - don't ask me for defaults"); assert(!"unknown which - don't ask me for defaults");
} }
DBG_ASSERT( pImp->ppStaticDefaults, "no defaults known - don't ask me for defaults" ); DBG_ASSERT( pImpl->ppStaticDefaults, "no defaults known - don't ask me for defaults" );
sal_uInt16 nPos = GetIndex_Impl(nWhich); sal_uInt16 nPos = GetIndex_Impl(nWhich);
SfxPoolItem *pDefault = *(pImp->ppPoolDefaults + nPos); SfxPoolItem *pDefault = *(pImpl->ppPoolDefaults + nPos);
if ( pDefault ) if ( pDefault )
return *pDefault; return *pDefault;
return **(pImp->ppStaticDefaults + nPos); return **(pImpl->ppStaticDefaults + nPos);
} }
SfxItemPool* SfxItemPool::GetSecondaryPool() const SfxItemPool* SfxItemPool::GetSecondaryPool() const
{ {
return pImp->mpSecondary; return pImpl->mpSecondary;
} }
SfxItemPool* SfxItemPool::GetMasterPool() const SfxItemPool* SfxItemPool::GetMasterPool() const
{ {
return pImp->mpMaster; return pImpl->mpMaster;
} }
/** /**
@@ -878,33 +876,33 @@ SfxItemPool* SfxItemPool::GetMasterPool() const
*/ */
void SfxItemPool::FreezeIdRanges() void SfxItemPool::FreezeIdRanges()
{ {
FillItemIdRanges_Impl( pImp->mpPoolRanges ); FillItemIdRanges_Impl( pImpl->mpPoolRanges );
} }
void SfxItemPool::FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const void SfxItemPool::FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const
{ {
DBG_ASSERT( !pImp->mpPoolRanges, "GetFrozenRanges() would be faster!" ); DBG_ASSERT( !pImpl->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->pImp->mpSecondary ) for( pPool = this; pPool; pPool = pPool->pImpl->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->pImp->mpSecondary ) for( pPool = this; pPool; pPool = pPool->pImpl->mpSecondary )
{ {
*(pWhichRanges+(nLevel++)) = pPool->pImp->mnStart; *(pWhichRanges+(nLevel++)) = pPool->pImpl->mnStart;
*(pWhichRanges+(nLevel++)) = pPool->pImp->mnEnd; *(pWhichRanges+(nLevel++)) = pPool->pImpl->mnEnd;
*(pWhichRanges+nLevel) = 0; *(pWhichRanges+nLevel) = 0;
} }
} }
const sal_uInt16* SfxItemPool::GetFrozenIdRanges() const const sal_uInt16* SfxItemPool::GetFrozenIdRanges() const
{ {
return pImp->mpPoolRanges; return pImpl->mpPoolRanges;
} }
const SfxPoolItem *SfxItemPool::GetItem2Default(sal_uInt16 nWhich) const const SfxPoolItem *SfxItemPool::GetItem2Default(sal_uInt16 nWhich) const
@@ -916,17 +914,17 @@ const SfxPoolItem *SfxItemPool::GetItem2(sal_uInt16 nWhich, sal_uInt32 nOfst) co
{ {
if ( !IsInRange(nWhich) ) if ( !IsInRange(nWhich) )
{ {
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
return pImp->mpSecondary->GetItem2( nWhich, nOfst ); return pImpl->mpSecondary->GetItem2( nWhich, nOfst );
assert(false && "unknown WhichId - cannot resolve surrogate"); assert(false && "unknown WhichId - cannot resolve surrogate");
return nullptr; return nullptr;
} }
// default attribute? // default attribute?
if ( nOfst == SFX_ITEMS_DEFAULT ) if ( nOfst == SFX_ITEMS_DEFAULT )
return *(pImp->ppStaticDefaults + GetIndex_Impl(nWhich)); return *(pImpl->ppStaticDefaults + GetIndex_Impl(nWhich));
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[GetIndex_Impl(nWhich)]; SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[GetIndex_Impl(nWhich)];
if( pItemArr && nOfst < pItemArr->size() ) if( pItemArr && nOfst < pItemArr->size() )
return (*pItemArr)[nOfst]; return (*pItemArr)[nOfst];
@@ -937,13 +935,13 @@ sal_uInt32 SfxItemPool::GetItemCount2(sal_uInt16 nWhich) const
{ {
if ( !IsInRange(nWhich) ) if ( !IsInRange(nWhich) )
{ {
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
return pImp->mpSecondary->GetItemCount2( nWhich ); return pImpl->mpSecondary->GetItemCount2( nWhich );
assert(false && "unknown WhichId - cannot resolve surrogate"); assert(false && "unknown WhichId - cannot resolve surrogate");
return 0; return 0;
} }
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[GetIndex_Impl(nWhich)]; SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[GetIndex_Impl(nWhich)];
if ( pItemArr ) if ( pItemArr )
return pItemArr->size(); return pItemArr->size();
return 0; return 0;
@@ -955,12 +953,12 @@ sal_uInt16 SfxItemPool::GetWhich( sal_uInt16 nSlotId, bool bDeep ) const
if ( !IsSlot(nSlotId) ) if ( !IsSlot(nSlotId) )
return nSlotId; return nSlotId;
sal_uInt16 nCount = pImp->mnEnd - pImp->mnStart + 1; sal_uInt16 nCount = pImpl->mnEnd - pImpl->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 + pImp->mnStart; return nOfs + pImpl->mnStart;
if ( pImp->mpSecondary && bDeep ) if ( pImpl->mpSecondary && bDeep )
return pImp->mpSecondary->GetWhich(nSlotId); return pImpl->mpSecondary->GetWhich(nSlotId);
return nSlotId; return nSlotId;
} }
@@ -972,13 +970,13 @@ sal_uInt16 SfxItemPool::GetSlotId( sal_uInt16 nWhich, bool bDeep ) const
if ( !IsInRange( nWhich ) ) if ( !IsInRange( nWhich ) )
{ {
if ( pImp->mpSecondary && bDeep ) if ( pImpl->mpSecondary && bDeep )
return pImp->mpSecondary->GetSlotId(nWhich); return pImpl->mpSecondary->GetSlotId(nWhich);
assert(false && "unknown WhichId - cannot get slot-id"); assert(false && "unknown WhichId - cannot get slot-id");
return 0; return 0;
} }
sal_uInt16 nSID = pItemInfos[nWhich - pImp->mnStart]._nSID; sal_uInt16 nSID = pItemInfos[nWhich - pImpl->mnStart]._nSID;
return nSID ? nSID : nWhich; return nSID ? nSID : nWhich;
} }
@@ -988,12 +986,12 @@ sal_uInt16 SfxItemPool::GetTrueWhich( sal_uInt16 nSlotId, bool bDeep ) const
if ( !IsSlot(nSlotId) ) if ( !IsSlot(nSlotId) )
return 0; return 0;
sal_uInt16 nCount = pImp->mnEnd - pImp->mnStart + 1; sal_uInt16 nCount = pImpl->mnEnd - pImpl->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 + pImp->mnStart; return nOfs + pImpl->mnStart;
if ( pImp->mpSecondary && bDeep ) if ( pImpl->mpSecondary && bDeep )
return pImp->mpSecondary->GetTrueWhich(nSlotId); return pImpl->mpSecondary->GetTrueWhich(nSlotId);
return 0; return 0;
} }
@@ -1005,12 +1003,12 @@ sal_uInt16 SfxItemPool::GetTrueSlotId( sal_uInt16 nWhich ) const
if ( !IsInRange( nWhich ) ) if ( !IsInRange( nWhich ) )
{ {
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
return pImp->mpSecondary->GetTrueSlotId(nWhich); return pImpl->mpSecondary->GetTrueSlotId(nWhich);
assert(false && "unknown WhichId - cannot get slot-id"); assert(false && "unknown WhichId - cannot get slot-id");
return 0; return 0;
} }
return pItemInfos[nWhich - pImp->mnStart]._nSID; return pItemInfos[nWhich - pImpl->mnStart]._nSID;
} }
/** /**
@@ -1021,10 +1019,10 @@ sal_uInt16 SfxItemPool::GetTrueSlotId( sal_uInt16 nWhich ) const
*/ */
void SfxItemPool::SetFileFormatVersion( sal_uInt16 nFileFormatVersion ) void SfxItemPool::SetFileFormatVersion( sal_uInt16 nFileFormatVersion )
{ {
DBG_ASSERT( this == pImp->mpMaster, DBG_ASSERT( this == pImpl->mpMaster,
"SfxItemPool::SetFileFormatVersion() but not a master pool" ); "SfxItemPool::SetFileFormatVersion() but not a master pool" );
for ( SfxItemPool *pPool = this; pPool; pPool = pPool->pImp->mpSecondary ) for ( SfxItemPool *pPool = this; pPool; pPool = pPool->pImpl->mpSecondary )
pPool->pImp->mnFileFormatVersion = nFileFormatVersion; pPool->pImpl->mnFileFormatVersion = nFileFormatVersion;
} }
const SfxItemPool* SfxItemPool::pStoringPool_ = nullptr; const SfxItemPool* SfxItemPool::pStoringPool_ = nullptr;

View File

@@ -122,12 +122,12 @@ static SfxItemKind convertUInt16ToSfxItemKind(sal_uInt16 x)
SvStream &SfxItemPool::Store(SvStream &rStream) const SvStream &SfxItemPool::Store(SvStream &rStream) const
{ {
// Find StoreMaster // Find StoreMaster
SfxItemPool *pStoreMaster = pImp->mpMaster != this ? pImp->mpMaster : nullptr; SfxItemPool *pStoreMaster = pImpl->mpMaster != this ? pImpl->mpMaster : nullptr;
while ( pStoreMaster && !pStoreMaster->pImp->bStreaming ) while ( pStoreMaster && !pStoreMaster->pImpl->bStreaming )
pStoreMaster = pStoreMaster->pImp->mpSecondary; pStoreMaster = pStoreMaster->pImpl->mpSecondary;
// Old header (version of the Pool and content version is 0xffff by default) // Old header (version of the Pool and content version is 0xffff by default)
pImp->bStreaming = true; pImpl->bStreaming = true;
if ( !pStoreMaster ) if ( !pStoreMaster )
{ {
rStream.WriteUInt16( rStream.GetVersion() >= SOFFICE_FILEFORMAT_50 rStream.WriteUInt16( rStream.GetVersion() >= SOFFICE_FILEFORMAT_50
@@ -148,14 +148,14 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
// Single header (content version and name) // Single header (content version and name)
{ {
SfxMiniRecordWriter aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER); SfxMiniRecordWriter aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER);
rStream.WriteUInt16( pImp->nVersion ); rStream.WriteUInt16( pImpl->nVersion );
writeByteString(rStream, pImp->aName); writeByteString(rStream, pImpl->aName);
} }
// VersionMaps // VersionMaps
{ {
SfxMultiVarRecordWriter aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP ); SfxMultiVarRecordWriter aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP );
for (std::shared_ptr<SfxPoolVersion_Impl>& pVer : pImp->aVersions) for (std::shared_ptr<SfxPoolVersion_Impl>& pVer : pImpl->aVersions)
{ {
aVerRec.NewContent(); aVerRec.NewContent();
rStream.WriteUInt16( pVer->_nVer ).WriteUInt16( pVer->_nStart ).WriteUInt16( pVer->_nEnd ); rStream.WriteUInt16( pVer->_nVer ).WriteUInt16( pVer->_nStart ).WriteUInt16( pVer->_nEnd );
@@ -168,7 +168,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
} }
// Workaround for bug in SetVersionMap 312 // Workaround for bug in SetVersionMap 312
if ( SOFFICE_FILEFORMAT_31 == pImp->mnFileFormatVersion ) if ( SOFFICE_FILEFORMAT_31 == pImpl->mnFileFormatVersion )
rStream.WriteUInt16( nNewWhich+1 ); rStream.WriteUInt16( nNewWhich+1 );
} }
} }
@@ -180,15 +180,15 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
// First write the atomic Items and then write the Sets (important when loading) // First write the atomic Items and then write the Sets (important when loading)
for (int ft = 0 ; ft < 2 && !rStream.GetError(); ft++) for (int ft = 0 ; ft < 2 && !rStream.GetError(); ft++)
{ {
pImp->bInSetItem = ft != 0; pImpl->bInSetItem = ft != 0;
std::vector<SfxPoolItemArray_Impl*>::const_iterator itrArr = pImp->maPoolItems.begin(); std::vector<SfxPoolItemArray_Impl*>::const_iterator itrArr = pImpl->maPoolItems.begin();
SfxPoolItem **ppDefItem = pImp->ppStaticDefaults; SfxPoolItem **ppDefItem = pImpl->ppStaticDefaults;
const sal_uInt16 nSize = GetSize_Impl(); const sal_uInt16 nSize = GetSize_Impl();
for ( size_t i = 0; i < nSize && !rStream.GetError(); ++i, ++itrArr, ++ppDefItem ) for ( size_t i = 0; i < nSize && !rStream.GetError(); ++i, ++itrArr, ++ppDefItem )
{ {
// Get version of the Item // Get version of the Item
sal_uInt16 nItemVersion = (*ppDefItem)->GetVersion( pImp->mnFileFormatVersion ); sal_uInt16 nItemVersion = (*ppDefItem)->GetVersion( pImpl->mnFileFormatVersion );
if ( USHRT_MAX == nItemVersion ) if ( USHRT_MAX == nItemVersion )
// => Was not present in the version that was supposed to be exported // => Was not present in the version that was supposed to be exported
continue; continue;
@@ -196,7 +196,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
// ! Poolable is not even saved in the Pool // ! Poolable is not even saved in the Pool
// And itemsets/plain-items depending on the round // And itemsets/plain-items depending on the round
if ( *itrArr && IsItemPoolable(**ppDefItem) && if ( *itrArr && IsItemPoolable(**ppDefItem) &&
pImp->bInSetItem == (dynamic_cast< const SfxSetItem* >(*ppDefItem) != nullptr) ) pImpl->bInSetItem == (dynamic_cast< const SfxSetItem* >(*ppDefItem) != nullptr) )
{ {
// Own signature, global WhichId and ItemVersion // Own signature, global WhichId and ItemVersion
sal_uInt16 nSlotId = GetSlotId( (*ppDefItem)->Which(), false ); sal_uInt16 nSlotId = GetSlotId( (*ppDefItem)->Which(), false );
@@ -247,7 +247,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
} }
} }
pImp->bInSetItem = false; pImpl->bInSetItem = false;
} }
// Save the set Defaults (PoolDefaults) // Save the set Defaults (PoolDefaults)
@@ -257,11 +257,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 = pImp->ppPoolDefaults[n]; const SfxPoolItem* pDefaultItem = pImpl->ppPoolDefaults[n];
if ( pDefaultItem ) if ( pDefaultItem )
{ {
// Get version // Get version
sal_uInt16 nItemVersion = pDefaultItem->GetVersion( pImp->mnFileFormatVersion ); sal_uInt16 nItemVersion = pDefaultItem->GetVersion( pImpl->mnFileFormatVersion );
if ( USHRT_MAX == nItemVersion ) if ( USHRT_MAX == nItemVersion )
// => Was not present in the version yet // => Was not present in the version yet
continue; continue;
@@ -281,16 +281,16 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
// Write out additional Pools // Write out additional Pools
pStoringPool_ = nullptr; pStoringPool_ = nullptr;
aPoolRec.Close(); aPoolRec.Close();
if ( !rStream.GetError() && pImp->mpSecondary ) if ( !rStream.GetError() && pImpl->mpSecondary )
pImp->mpSecondary->Store( rStream ); pImpl->mpSecondary->Store( rStream );
pImp->bStreaming = false; pImpl->bStreaming = false;
return rStream; return rStream;
} }
bool SfxItemPool::HasPersistentRefCounts() const bool SfxItemPool::HasPersistentRefCounts() const
{ {
return pImp->mbPersistentRefCounts; return pImpl->mbPersistentRefCounts;
} }
/** /**
@@ -308,10 +308,10 @@ bool SfxItemPool::HasPersistentRefCounts() const
void SfxItemPool::LoadCompleted() void SfxItemPool::LoadCompleted()
{ {
// Did we load without RefCounts? // Did we load without RefCounts?
if ( pImp->nInitRefCount > 1 ) if ( pImpl->nInitRefCount > 1 )
{ {
// Iterate over all Which values // Iterate over all Which values
std::vector<SfxPoolItemArray_Impl*>::const_iterator itrItemArr = pImp->maPoolItems.begin(); std::vector<SfxPoolItemArray_Impl*>::const_iterator itrItemArr = pImpl->maPoolItems.begin();
for( sal_uInt16 nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++itrItemArr ) for( sal_uInt16 nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++itrItemArr )
{ {
// Is there an item with the Which value present at all? // Is there an item with the Which value present at all?
@@ -332,27 +332,27 @@ void SfxItemPool::LoadCompleted()
} }
// from now on normal initial ref count // from now on normal initial ref count
pImp->nInitRefCount = 1; pImpl->nInitRefCount = 1;
} }
// notify secondary pool // notify secondary pool
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
pImp->mpSecondary->LoadCompleted(); pImpl->mpSecondary->LoadCompleted();
} }
sal_uInt16 SfxItemPool::GetFirstWhich() const sal_uInt16 SfxItemPool::GetFirstWhich() const
{ {
return pImp->mnStart; return pImpl->mnStart;
} }
sal_uInt16 SfxItemPool::GetLastWhich() const sal_uInt16 SfxItemPool::GetLastWhich() const
{ {
return pImp->mnEnd; return pImpl->mnEnd;
} }
bool SfxItemPool::IsInRange( sal_uInt16 nWhich ) const bool SfxItemPool::IsInRange( sal_uInt16 nWhich ) const
{ {
return nWhich >= pImp->mnStart && nWhich <= pImp->mnEnd; return nWhich >= pImpl->mnStart && nWhich <= pImpl->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:
@@ -462,14 +462,14 @@ void SfxItemPool_Impl::readTheItems (
SvStream &SfxItemPool::Load(SvStream &rStream) SvStream &SfxItemPool::Load(SvStream &rStream)
{ {
DBG_ASSERT(pImp->ppStaticDefaults, "No DefaultArray"); DBG_ASSERT(pImpl->ppStaticDefaults, "No DefaultArray");
// Protect items by increasing ref count // Protect items by increasing ref count
if ( !pImp->mbPersistentRefCounts ) if ( !pImpl->mbPersistentRefCounts )
{ {
// Iterate over all Which values // Iterate over all Which values
std::vector<SfxPoolItemArray_Impl*>::const_iterator itrItemArr = pImp->maPoolItems.begin(); std::vector<SfxPoolItemArray_Impl*>::const_iterator itrItemArr = pImpl->maPoolItems.begin();
for( size_t nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++itrItemArr ) for( size_t nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++itrItemArr )
{ {
// Is there an Item with that Which value present at all? // Is there an Item with that Which value present at all?
@@ -487,16 +487,16 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
} }
// During loading (until LoadCompleted()) protect all items // During loading (until LoadCompleted()) protect all items
pImp->nInitRefCount = 2; pImpl->nInitRefCount = 2;
} }
// Find LoadMaster // Find LoadMaster
SfxItemPool *pLoadMaster = pImp->mpMaster != this ? pImp->mpMaster : nullptr; SfxItemPool *pLoadMaster = pImpl->mpMaster != this ? pImpl->mpMaster : nullptr;
while ( pLoadMaster && !pLoadMaster->pImp->bStreaming ) while ( pLoadMaster && !pLoadMaster->pImpl->bStreaming )
pLoadMaster = pLoadMaster->pImp->mpSecondary; pLoadMaster = pLoadMaster->pImpl->mpSecondary;
// Read whole Header // Read whole Header
pImp->bStreaming = true; pImpl->bStreaming = true;
if ( !pLoadMaster ) if ( !pLoadMaster )
{ {
// Load format version // Load format version
@@ -507,21 +507,21 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
OSL_FAIL( "SFX_ITEMPOOL_TAG_STARTPOOL_5" ); /*! s.u. */ OSL_FAIL( "SFX_ITEMPOOL_TAG_STARTPOOL_5" ); /*! s.u. */
/*! Set error code and evaluate! */ /*! Set error code and evaluate! */
(rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR);
pImp->bStreaming = false; pImpl->bStreaming = false;
return rStream; return rStream;
} }
rStream.ReadUChar( pImp->nMajorVer ).ReadUChar( pImp->nMinorVer ); rStream.ReadUChar( pImpl->nMajorVer ).ReadUChar( pImpl->nMinorVer );
// Take over format version to MasterPool // Take over format version to MasterPool
pImp->mpMaster->pImp->nMajorVer = pImp->nMajorVer; pImpl->mpMaster->pImpl->nMajorVer = pImpl->nMajorVer;
pImp->mpMaster->pImp->nMinorVer = pImp->nMinorVer; pImpl->mpMaster->pImpl->nMinorVer = pImpl->nMinorVer;
// Unknown Format // Unknown Format
if (pImp->nMajorVer < 2 || pImp->nMajorVer > SFX_ITEMPOOL_VER_MAJOR) if (pImpl->nMajorVer < 2 || pImpl->nMajorVer > SFX_ITEMPOOL_VER_MAJOR)
{ {
rStream.SetError(SVSTREAM_FILEFORMAT_ERROR); rStream.SetError(SVSTREAM_FILEFORMAT_ERROR);
pImp->bStreaming = false; pImpl->bStreaming = false;
return rStream; return rStream;
} }
@@ -533,7 +533,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
OSL_FAIL( "SFX_ITEMPOOL_TAG_TRICK4OLD" ); /*! s.u. */ OSL_FAIL( "SFX_ITEMPOOL_TAG_TRICK4OLD" ); /*! s.u. */
/*! Set error code and evaluate! */ /*! Set error code and evaluate! */
(rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR);
pImp->bStreaming = false; pImpl->bStreaming = false;
return rStream; return rStream;
} }
@@ -544,7 +544,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
SfxMiniRecordReader aPoolRec( &rStream, SFX_ITEMPOOL_REC ); SfxMiniRecordReader aPoolRec( &rStream, SFX_ITEMPOOL_REC );
if ( rStream.GetError() ) if ( rStream.GetError() )
{ {
pImp->bStreaming = false; pImpl->bStreaming = false;
return rStream; return rStream;
} }
@@ -555,21 +555,21 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
SfxMiniRecordReader aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER ); SfxMiniRecordReader aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER );
if ( rStream.GetError() ) if ( rStream.GetError() )
{ {
pImp->bStreaming = false; pImpl->bStreaming = false;
return rStream; return rStream;
} }
// Read Header // Read Header
rStream.ReadUInt16( pImp->nLoadingVersion ); rStream.ReadUInt16( pImpl->nLoadingVersion );
aExternName = readByteString(rStream); aExternName = readByteString(rStream);
bool bOwnPool = aExternName == pImp->aName; bool bOwnPool = aExternName == pImpl->aName;
//! As long as we cannot read foreign Pools //! As long as we cannot read foreign Pools
if ( !bOwnPool ) if ( !bOwnPool )
{ {
rStream.SetError(SVSTREAM_FILEFORMAT_ERROR); rStream.SetError(SVSTREAM_FILEFORMAT_ERROR);
aPoolRec.Skip(); aPoolRec.Skip();
pImp->bStreaming = false; pImpl->bStreaming = false;
return rStream; return rStream;
} }
} }
@@ -579,12 +579,12 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
SfxMultiRecordReader aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP ); SfxMultiRecordReader aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP );
if ( rStream.GetError() ) if ( rStream.GetError() )
{ {
pImp->bStreaming = false; pImpl->bStreaming = false;
return rStream; return rStream;
} }
// Version maps einlesen // Version maps einlesen
sal_uInt16 nOwnVersion = pImp->nVersion; sal_uInt16 nOwnVersion = pImpl->nVersion;
for ( sal_uInt16 nVerNo = 0; aVerRec.GetContent(); ++nVerNo ) for ( sal_uInt16 nVerNo = 0; aVerRec.GetContent(); ++nVerNo )
{ {
// Read header for single versions // Read header for single versions
@@ -593,7 +593,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
sal_uInt16 nCount = nHEnd - nHStart + 1; sal_uInt16 nCount = nHEnd - nHStart + 1;
// Is new version is known? // Is new version is known?
if ( nVerNo >= pImp->aVersions.size() ) if ( nVerNo >= pImpl->aVersions.size() )
{ {
// Add new Version // Add new Version
const size_t nMaxRecords = rStream.remainingSize() / sizeof(sal_uInt16); const size_t nMaxRecords = rStream.remainingSize() / sizeof(sal_uInt16);
@@ -610,7 +610,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
SetVersionMap( nVersion, nHStart, nHEnd, pMap ); SetVersionMap( nVersion, nHStart, nHEnd, pMap );
} }
} }
pImp->nVersion = nOwnVersion; pImpl->nVersion = nOwnVersion;
} }
// Load Items // Load Items
@@ -625,7 +625,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
sal_uInt16 nVersion(0), nWhich(0); sal_uInt16 nVersion(0), nWhich(0);
//!sal_uInt16 nSlotId = aWhichIdsRec.GetContentTag(); //!sal_uInt16 nSlotId = aWhichIdsRec.GetContentTag();
rStream.ReadUInt16( nWhich ); rStream.ReadUInt16( nWhich );
if ( pImp->nLoadingVersion != pImp->nVersion ) if ( pImpl->nLoadingVersion != pImpl->nVersion )
// Move WhichId from file version to Pool version // Move WhichId from file version to Pool version
nWhich = GetNewWhich( nWhich ); nWhich = GetNewWhich( nWhich );
@@ -641,19 +641,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->maPoolItems[0] + nIndex; SfxPoolItemArray_Impl **ppArr = &pImpl->maPoolItems[0] + nIndex;
// SfxSetItems could contain Items from secondary Pools // SfxSetItems could contain Items from secondary Pools
SfxPoolItem *pDefItem = *(pImp->ppStaticDefaults + nIndex); SfxPoolItem *pDefItem = *(pImpl->ppStaticDefaults + nIndex);
pImp->bInSetItem = dynamic_cast<const SfxSetItem*>( pDefItem ) != nullptr; pImpl->bInSetItem = dynamic_cast<const SfxSetItem*>( pDefItem ) != nullptr;
if ( !bSecondaryLoaded && pImp->mpSecondary && pImp->bInSetItem ) if ( !bSecondaryLoaded && pImpl->mpSecondary && pImpl->bInSetItem )
{ {
// Seek to end of own Pool // Seek to end of own Pool
sal_uLong nLastPos = rStream.Tell(); sal_uLong nLastPos = rStream.Tell();
aPoolRec.Skip(); aPoolRec.Skip();
// Read secondary Pool // Read secondary Pool
pImp->mpSecondary->Load( rStream ); pImpl->mpSecondary->Load( rStream );
bSecondaryLoaded = true; bSecondaryLoaded = true;
nSecondaryEnd = rStream.Tell(); nSecondaryEnd = rStream.Tell();
@@ -662,9 +662,9 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
} }
// Read Items // Read Items
pImp->readTheItems(rStream, nCount, nVersion, pDefItem, ppArr); pImpl->readTheItems(rStream, nCount, nVersion, pDefItem, ppArr);
pImp->bInSetItem = false; pImpl->bInSetItem = false;
} }
} }
@@ -678,7 +678,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
sal_uInt16 nVersion(0), nWhich(0); sal_uInt16 nVersion(0), nWhich(0);
//!sal_uInt16 nSlotId = aDefsRec.GetContentTag(); //!sal_uInt16 nSlotId = aDefsRec.GetContentTag();
rStream.ReadUInt16( nWhich ); rStream.ReadUInt16( nWhich );
if ( pImp->nLoadingVersion != pImp->nVersion ) if ( pImpl->nLoadingVersion != pImpl->nVersion )
// Move WhichId from file version to Pool version // Move WhichId from file version to Pool version
nWhich = GetNewWhich( nWhich ); nWhich = GetNewWhich( nWhich );
@@ -692,44 +692,44 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
// Load PoolDefaultItem // Load PoolDefaultItem
SfxPoolItem *pItem = SfxPoolItem *pItem =
( *( pImp->ppStaticDefaults + GetIndex_Impl(nWhich) ) ) ( *( pImpl->ppStaticDefaults + GetIndex_Impl(nWhich) ) )
->Create( rStream, nVersion ); ->Create( rStream, nVersion );
pItem->SetKind( SFX_ITEMS_POOLDEFAULT ); pItem->SetKind( SFX_ITEMS_POOLDEFAULT );
*( pImp->ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem; *( pImpl->ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem;
} }
} }
// Load secondary Pool if needed // Load secondary Pool if needed
aPoolRec.Skip(); aPoolRec.Skip();
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
{ {
if ( !bSecondaryLoaded ) if ( !bSecondaryLoaded )
pImp->mpSecondary->Load( rStream ); pImpl->mpSecondary->Load( rStream );
else else
rStream.Seek( nSecondaryEnd ); rStream.Seek( nSecondaryEnd );
} }
// If not own Pool, then no name // If not own Pool, then no name
if ( aExternName != pImp->aName ) if ( aExternName != pImpl->aName )
(pImp->aName).clear(); (pImpl->aName).clear();
pImp->bStreaming = false; pImpl->bStreaming = false;
return rStream; return rStream;
}; };
sal_uInt16 SfxItemPool::GetIndex_Impl(sal_uInt16 nWhich) const sal_uInt16 SfxItemPool::GetIndex_Impl(sal_uInt16 nWhich) const
{ {
if (nWhich < pImp->mnStart || nWhich > pImp->mnEnd) if (nWhich < pImpl->mnStart || nWhich > pImpl->mnEnd)
{ {
assert(false && "missing bounds check before use"); assert(false && "missing bounds check before use");
return 0; return 0;
} }
return nWhich - pImp->mnStart; return nWhich - pImpl->mnStart;
} }
sal_uInt16 SfxItemPool::GetSize_Impl() const sal_uInt16 SfxItemPool::GetSize_Impl() const
{ {
return pImp->mnEnd - pImp->mnStart + 1; return pImpl->mnEnd - pImpl->mnStart + 1;
} }
/** /**
@@ -810,18 +810,18 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate
if ( bResolvable ) if ( bResolvable )
{ {
const SfxPoolItem *pItem = nullptr; const SfxPoolItem *pItem = nullptr;
for ( SfxItemPool *pTarget = this; pTarget; pTarget = pTarget->pImp->mpSecondary ) for ( SfxItemPool *pTarget = this; pTarget; pTarget = pTarget->pImpl->mpSecondary )
{ {
// Found the right (Range-)Pool? // Found the right (Range-)Pool?
if ( pTarget->IsInRange(rWhich) ) if ( pTarget->IsInRange(rWhich) )
{ {
// Default attribute? // Default attribute?
if ( SFX_ITEMS_DEFAULT == nSurrogat ) if ( SFX_ITEMS_DEFAULT == nSurrogat )
return *(pTarget->pImp->ppStaticDefaults + return *(pTarget->pImpl->ppStaticDefaults +
pTarget->GetIndex_Impl(rWhich)); pTarget->GetIndex_Impl(rWhich));
SfxPoolItemArray_Impl* pItemArr = SfxPoolItemArray_Impl* pItemArr =
pTarget->pImp->maPoolItems[pTarget->GetIndex_Impl(rWhich)]; pTarget->pImpl->maPoolItems[pTarget->GetIndex_Impl(rWhich)];
pItem = pItemArr && nSurrogat < pItemArr->size() pItem = pItemArr && nSurrogat < pItemArr->size()
? (*pItemArr)[nSurrogat] ? (*pItemArr)[nSurrogat]
: nullptr; : nullptr;
@@ -833,7 +833,7 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate
} }
// Reload from RefPool? // Reload from RefPool?
if ( pRefPool != pImp->mpMaster ) if ( pRefPool != pImpl->mpMaster )
return &pTarget->Put( *pItem ); return &pTarget->Put( *pItem );
// References have NOT been loaded together with the pool? // References have NOT been loaded together with the pool?
@@ -888,8 +888,8 @@ sal_uInt32 SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const
if ( !IsInRange(pItem->Which()) ) if ( !IsInRange(pItem->Which()) )
{ {
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
return pImp->mpSecondary->GetSurrogate( pItem ); return pImpl->mpSecondary->GetSurrogate( pItem );
SFX_ASSERT( false, pItem->Which(), "unknown Which-Id - don't ask me for surrogates" ); SFX_ASSERT( false, pItem->Which(), "unknown Which-Id - don't ask me for surrogates" );
} }
@@ -897,7 +897,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->maPoolItems[GetIndex_Impl(pItem->Which())]; SfxPoolItemArray_Impl* pItemArr = pImpl->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 )
@@ -913,8 +913,8 @@ sal_uInt32 SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const
bool SfxItemPool::IsInStoringRange( sal_uInt16 nWhich ) const bool SfxItemPool::IsInStoringRange( sal_uInt16 nWhich ) const
{ {
return nWhich >= pImp->nStoringStart && return nWhich >= pImpl->nStoringStart &&
nWhich <= pImp->nStoringEnd; nWhich <= pImpl->nStoringEnd;
} }
/** /**
@@ -932,8 +932,8 @@ bool SfxItemPool::IsInStoringRange( sal_uInt16 nWhich ) const
*/ */
void SfxItemPool::SetStoringRange( sal_uInt16 nFrom, sal_uInt16 nTo ) void SfxItemPool::SetStoringRange( sal_uInt16 nFrom, sal_uInt16 nTo )
{ {
pImp->nStoringStart = nFrom; pImpl->nStoringStart = nFrom;
pImp->nStoringEnd = nTo; pImpl->nStoringEnd = nTo;
} }
@@ -990,23 +990,23 @@ void SfxItemPool::SetVersionMap
// Create new map entry to insert // Create new map entry to insert
const SfxPoolVersion_ImplPtr pVerMap = std::make_shared<SfxPoolVersion_Impl>( const SfxPoolVersion_ImplPtr pVerMap = std::make_shared<SfxPoolVersion_Impl>(
nVer, nOldStart, nOldEnd, pOldWhichIdTab ); nVer, nOldStart, nOldEnd, pOldWhichIdTab );
pImp->aVersions.push_back( pVerMap ); pImpl->aVersions.push_back( pVerMap );
DBG_ASSERT( nVer > pImp->nVersion, "Versions not sorted" ); DBG_ASSERT( nVer > pImpl->nVersion, "Versions not sorted" );
pImp->nVersion = nVer; pImpl->nVersion = nVer;
// Adapt version range // Adapt version range
for ( sal_uInt16 n = 0; n < nOldEnd-nOldStart+1; ++n ) for ( sal_uInt16 n = 0; n < nOldEnd-nOldStart+1; ++n )
{ {
sal_uInt16 nWhich = pOldWhichIdTab[n]; sal_uInt16 nWhich = pOldWhichIdTab[n];
if ( nWhich < pImp->nVerStart ) if ( nWhich < pImpl->nVerStart )
{ {
if ( !nWhich ) if ( !nWhich )
nWhich = 0; nWhich = 0;
pImp->nVerStart = nWhich; pImpl->nVerStart = nWhich;
} }
else if ( nWhich > pImp->nVerEnd ) else if ( nWhich > pImpl->nVerEnd )
pImp->nVerEnd = nWhich; pImpl->nVerEnd = nWhich;
} }
} }
@@ -1039,22 +1039,22 @@ sal_uInt16 SfxItemPool::GetNewWhich
// Determine (secondary) Pool // Determine (secondary) Pool
if ( !IsInVersionsRange(nFileWhich) ) if ( !IsInVersionsRange(nFileWhich) )
{ {
if ( pImp->mpSecondary ) if ( pImpl->mpSecondary )
return pImp->mpSecondary->GetNewWhich( nFileWhich ); return pImpl->mpSecondary->GetNewWhich( nFileWhich );
SFX_ASSERT( false, nFileWhich, "unknown which in GetNewWhich()" ); SFX_ASSERT( false, nFileWhich, "unknown which in GetNewWhich()" );
} }
// Newer/the same/older version? // Newer/the same/older version?
short nDiff = (short)pImp->nLoadingVersion - (short)pImp->nVersion; short nDiff = (short)pImpl->nLoadingVersion - (short)pImpl->nVersion;
// WhichId of a newer version? // WhichId of a newer version?
if ( nDiff > 0 ) if ( nDiff > 0 )
{ {
// Map step by step from the top version down to the file version // Map step by step from the top version down to the file version
for ( size_t nMap = pImp->aVersions.size(); nMap > 0; --nMap ) for ( size_t nMap = pImpl->aVersions.size(); nMap > 0; --nMap )
{ {
SfxPoolVersion_ImplPtr pVerInfo = pImp->aVersions[nMap-1]; SfxPoolVersion_ImplPtr pVerInfo = pImpl->aVersions[nMap-1];
if ( pVerInfo->_nVer > pImp->nVersion ) if ( pVerInfo->_nVer > pImpl->nVersion )
{ sal_uInt16 nOfs; { sal_uInt16 nOfs;
sal_uInt16 nCount = pVerInfo->_nEnd - pVerInfo->_nStart + 1; sal_uInt16 nCount = pVerInfo->_nEnd - pVerInfo->_nStart + 1;
for ( nOfs = 0; for ( nOfs = 0;
@@ -1077,9 +1077,9 @@ sal_uInt16 SfxItemPool::GetNewWhich
else if ( nDiff < 0 ) else if ( nDiff < 0 )
{ {
// Map step by step from the top version down to the file version // Map step by step from the top version down to the file version
for (std::shared_ptr<SfxPoolVersion_Impl>& pVerInfo : pImp->aVersions) for (std::shared_ptr<SfxPoolVersion_Impl>& pVerInfo : pImpl->aVersions)
{ {
if ( pVerInfo->_nVer > pImp->nLoadingVersion ) if ( pVerInfo->_nVer > pImpl->nLoadingVersion )
{ {
if (nFileWhich >= pVerInfo->_nStart && if (nFileWhich >= pVerInfo->_nStart &&
nFileWhich <= pVerInfo->_nEnd) nFileWhich <= pVerInfo->_nEnd)
@@ -1101,7 +1101,7 @@ sal_uInt16 SfxItemPool::GetNewWhich
bool SfxItemPool::IsInVersionsRange( sal_uInt16 nWhich ) const bool SfxItemPool::IsInVersionsRange( sal_uInt16 nWhich ) const
{ {
return nWhich >= pImp->nVerStart && nWhich <= pImp->nVerEnd; return nWhich >= pImpl->nVerStart && nWhich <= pImpl->nVerEnd;
} }
@@ -1119,8 +1119,8 @@ bool SfxItemPool::IsInVersionsRange( sal_uInt16 nWhich ) const
*/ */
bool SfxItemPool::IsCurrentVersionLoading() const bool SfxItemPool::IsCurrentVersionLoading() const
{ {
return ( pImp->nVersion == pImp->nLoadingVersion ) && return ( pImpl->nVersion == pImpl->nLoadingVersion ) &&
( !pImp->mpSecondary || pImp->mpSecondary->IsCurrentVersionLoading() ); ( !pImpl->mpSecondary || pImpl->mpSecondary->IsCurrentVersionLoading() );
} }
@@ -1154,14 +1154,14 @@ bool SfxItemPool::StoreItem( SvStream &rStream, const SfxPoolItem &rItem,
const SfxItemPool *pPool = this; const SfxItemPool *pPool = this;
while ( !pPool->IsInStoringRange(rItem.Which()) ) while ( !pPool->IsInStoringRange(rItem.Which()) )
if ( nullptr == ( pPool = pPool->pImp->mpSecondary ) ) if ( nullptr == ( pPool = pPool->pImpl->mpSecondary ) )
return false; return false;
DBG_ASSERT( !pImp->bInSetItem || dynamic_cast<const SfxSetItem*>( &rItem ) == nullptr, DBG_ASSERT( !pImpl->bInSetItem || dynamic_cast<const SfxSetItem*>( &rItem ) == nullptr,
"SetItem contains ItemSet with SetItem" ); "SetItem contains ItemSet with SetItem" );
sal_uInt16 nSlotId = pPool->GetSlotId( rItem.Which() ); sal_uInt16 nSlotId = pPool->GetSlotId( rItem.Which() );
sal_uInt16 nItemVersion = rItem.GetVersion(pImp->mnFileFormatVersion); sal_uInt16 nItemVersion = rItem.GetVersion(pImpl->mnFileFormatVersion);
if ( USHRT_MAX == nItemVersion ) if ( USHRT_MAX == nItemVersion )
return false; return false;
@@ -1198,8 +1198,8 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream,
// Find right secondary Pool // Find right secondary Pool
while ( !pRefPool->IsInVersionsRange(nWhich) ) while ( !pRefPool->IsInVersionsRange(nWhich) )
{ {
if ( pRefPool->pImp->mpSecondary ) if ( pRefPool->pImpl->mpSecondary )
pRefPool = pRefPool->pImp->mpSecondary; pRefPool = pRefPool->pImpl->mpSecondary;
else else
{ {
// WID not present in this version => skip // WID not present in this version => skip
@@ -1220,8 +1220,8 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream,
if ( !bCurVersion ) if ( !bCurVersion )
nWhich = pRefPool->GetNewWhich( nWhich ); // Map WhichId to new version nWhich = pRefPool->GetNewWhich( nWhich ); // Map WhichId to new version
DBG_ASSERT( !nWhich || !pImp->bInSetItem || DBG_ASSERT( !nWhich || !pImpl->bInSetItem ||
dynamic_cast<const SfxSetItem*>( pRefPool->pImp->ppStaticDefaults[pRefPool->GetIndex_Impl(nWhich)] ) == nullptr, dynamic_cast<const SfxSetItem*>( pRefPool->pImpl->ppStaticDefaults[pRefPool->GetIndex_Impl(nWhich)] ) == nullptr,
"loading SetItem in ItemSet of SetItem" ); "loading SetItem in ItemSet of SetItem" );
// Are we loading via surrogate? // Are we loading via surrogate?