From c8ff6e35d6350dace92c8184a03e0524704327d0 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Sun, 29 May 2016 21:15:01 +0200 Subject: tdf#89329: use unique_ptr for pImpl in itempool Change-Id: Ie0a5e5a16cf4b724ff55b0a89ee0ec803df6eb41 Reviewed-on: https://gerrit.libreoffice.org/25635 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/svl/itempool.hxx | 3 +- svl/source/inc/poolio.hxx | 2 +- svl/source/items/itempool.cxx | 300 +++++++++++++++++++++--------------------- svl/source/items/poolio.cxx | 214 +++++++++++++++--------------- 4 files changed, 259 insertions(+), 260 deletions(-) diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx index f3ef335d3aa2..d7b5b73df3e2 100644 --- a/include/svl/itempool.hxx +++ b/include/svl/itempool.hxx @@ -24,6 +24,7 @@ #include #include #include +#include class SvStream; class SfxBroadcaster; @@ -62,7 +63,7 @@ class SVL_DLLPUBLIC SfxItemPool friend struct SfxItemPool_Impl; const SfxItemInfo* pItemInfos; - SfxItemPool_Impl* pImp; + std::unique_ptr pImpl; public: void AddSfxItemPoolUser(SfxItemPoolUser& rNewUser); diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx index 61947fac8bc0..fc62eb2f2006 100644 --- a/svl/source/inc/poolio.hxx +++ b/svl/source/inc/poolio.hxx @@ -163,7 +163,7 @@ struct SfxItemPool_Impl // unit testing friend class PoolItemTest; - static SfxItemPool_Impl *GetImpl(SfxItemPool *pPool) { return pPool->pImp; } + static SfxItemPool_Impl *GetImpl(SfxItemPool *pPool) { return pPool->pImpl.get(); } }; diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index be8a3e92762e..fbbfcea51db3 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -73,7 +73,7 @@ lcl_CheckSlots2(std::map & rSlotMap, #define CHECK_SLOTS() \ do { \ std::map 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); \ } \ @@ -86,16 +86,16 @@ do { \ void SfxItemPool::AddSfxItemPoolUser(SfxItemPoolUser& rNewUser) { - pImp->maSfxItemPoolUsers.push_back(&rNewUser); + pImpl->maSfxItemPoolUsers.push_back(&rNewUser); } void SfxItemPool::RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser) { const std::vector::iterator aFindResult = ::std::find( - pImp->maSfxItemPoolUsers.begin(), pImp->maSfxItemPoolUsers.end(), &rOldUser); - if(aFindResult != pImp->maSfxItemPoolUsers.end()) + pImpl->maSfxItemPoolUsers.begin(), pImpl->maSfxItemPoolUsers.end(), &rOldUser); + 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; if( IsInRange( nWhich ) ) - pRet = *(pImp->ppPoolDefaults + GetIndex_Impl( nWhich )); - else if( pImp->mpSecondary ) - pRet = pImp->mpSecondary->GetPoolDefaultItem( nWhich ); + pRet = *(pImpl->ppPoolDefaults + GetIndex_Impl( nWhich )); + else if( pImpl->mpSecondary ) + pRet = pImpl->mpSecondary->GetPoolDefaultItem( nWhich ); else { 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 { - for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pImp->mpSecondary ) + for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pImpl->mpSecondary ) { if ( pPool->IsInRange(nWhich) ) return pPool->IsItemPoolable_Impl( pPool->GetIndex_Impl(nWhich)); @@ -135,7 +135,7 @@ bool SfxItemPool::IsItemPoolable( sal_uInt16 nWhich ) const SfxBroadcaster& SfxItemPool::BC() { - return pImp->aBC; + return pImpl->aBC; } @@ -173,19 +173,19 @@ SfxItemPool::SfxItemPool bool bLoadRefCounts /* Load RefCounts or set to 1? */ ) : pItemInfos(pInfo), - pImp( new SfxItemPool_Impl( this, rName, nStartWhich, nEndWhich ) ) + pImpl( new SfxItemPool_Impl( this, rName, nStartWhich, nEndWhich ) ) { - pImp->eDefMetric = SFX_MAPUNIT_TWIP; - pImp->nVersion = 0; - pImp->bStreaming = false; - pImp->nLoadingVersion = 0; - pImp->nInitRefCount = 1; - pImp->nVerStart = pImp->mnStart; - pImp->nVerEnd = pImp->mnEnd; - pImp->bInSetItem = false; - pImp->nStoringStart = nStartWhich; - pImp->nStoringEnd = nEndWhich; - pImp->mbPersistentRefCounts = bLoadRefCounts; + pImpl->eDefMetric = SFX_MAPUNIT_TWIP; + pImpl->nVersion = 0; + pImpl->bStreaming = false; + pImpl->nLoadingVersion = 0; + pImpl->nInitRefCount = 1; + pImpl->nVerStart = pImpl->mnStart; + pImpl->nVerEnd = pImpl->mnEnd; + pImpl->bInSetItem = false; + pImpl->nStoringStart = nStartWhich; + pImpl->nStoringEnd = nEndWhich; + pImpl->mbPersistentRefCounts = bLoadRefCounts; if ( pDefaults ) SetDefaults(pDefaults); @@ -207,74 +207,74 @@ SfxItemPool::SfxItemPool Take over static Defaults */ ) : 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; - pImp->nVersion = rPool.pImp->nVersion; - pImp->bStreaming = false; - pImp->nLoadingVersion = 0; - pImp->nInitRefCount = 1; - pImp->nVerStart = rPool.pImp->nVerStart; - pImp->nVerEnd = rPool.pImp->nVerEnd; - pImp->bInSetItem = false; - pImp->nStoringStart = pImp->mnStart; - pImp->nStoringEnd = pImp->mnEnd; - pImp->mbPersistentRefCounts = rPool.pImp->mbPersistentRefCounts; + pImpl->eDefMetric = rPool.pImpl->eDefMetric; + pImpl->nVersion = rPool.pImpl->nVersion; + pImpl->bStreaming = false; + pImpl->nLoadingVersion = 0; + pImpl->nInitRefCount = 1; + pImpl->nVerStart = rPool.pImpl->nVerStart; + pImpl->nVerEnd = rPool.pImpl->nVerEnd; + pImpl->bInSetItem = false; + pImpl->nStoringStart = pImpl->mnStart; + pImpl->nStoringEnd = pImpl->mnEnd; + pImpl->mbPersistentRefCounts = rPool.pImpl->mbPersistentRefCounts; // Take over static Defaults if ( bCloneStaticDefaults ) { - SfxPoolItem **ppDefaults = new SfxPoolItem*[pImp->mnEnd-pImp->mnStart+1]; - for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n ) + SfxPoolItem **ppDefaults = new SfxPoolItem*[pImpl->mnEnd-pImpl->mnStart+1]; + 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 ); } SetDefaults( ppDefaults ); } else - SetDefaults( rPool.pImp->ppStaticDefaults ); + SetDefaults( rPool.pImpl->ppStaticDefaults ); // Copy Pool Defaults - for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n ) - if ( (*( rPool.pImp->ppPoolDefaults + n )) ) + for ( sal_uInt16 n = 0; n <= pImpl->mnEnd - pImpl->mnStart; ++n ) + if ( (*( rPool.pImpl->ppPoolDefaults + n )) ) { - (*( pImp->ppPoolDefaults + n )) = (*( rPool.pImp->ppPoolDefaults + n ))->Clone(this); - (*( pImp->ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT ); + (*( pImpl->ppPoolDefaults + n )) = (*( rPool.pImpl->ppPoolDefaults + n ))->Clone(this); + (*( pImpl->ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT ); } // Copy Version map - for (std::shared_ptr& pOld : rPool.pImp->aVersions) + for (std::shared_ptr& pOld : rPool.pImpl->aVersions) { SfxPoolVersion_ImplPtr pNew = std::make_shared( *pOld ); - pImp->aVersions.push_back( pNew ); + pImpl->aVersions.push_back( pNew ); } // Repair linkage - if ( rPool.pImp->mpSecondary ) - SetSecondaryPool( rPool.pImp->mpSecondary->Clone() ); + if ( rPool.pImpl->mpSecondary ) + SetSecondaryPool( rPool.pImpl->mpSecondary->Clone() ); } void SfxItemPool::SetDefaults( SfxPoolItem **pDefaults ) { 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 ) //! FIXME: Probably doesn't work with SetItems at the end { - DBG_ASSERT( (*pImp->ppStaticDefaults)->GetRefCount() == 0 || - IsDefaultItem( (*pImp->ppStaticDefaults) ), + DBG_ASSERT( (*pImpl->ppStaticDefaults)->GetRefCount() == 0 || + IsDefaultItem( (*pImpl->ppStaticDefaults) ), "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" ); - (*( pImp->ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT ); - DBG_ASSERT( !(pImp->maPoolItems[n]), "defaults with setitems with items?!" ); + (*( pImpl->ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT ); + DBG_ASSERT( !(pImpl->maPoolItems[n]), "defaults with setitems with items?!" ); } } } @@ -298,12 +298,12 @@ void SfxItemPool::ReleaseDefaults { - DBG_ASSERT( pImp->ppStaticDefaults, "requirements not met" ); - ReleaseDefaults( pImp->ppStaticDefaults, pImp->mnEnd - pImp->mnStart + 1, bDelete ); + DBG_ASSERT( pImpl->ppStaticDefaults, "requirements not met" ); + ReleaseDefaults( pImpl->ppStaticDefaults, pImpl->mnEnd - pImpl->mnStart + 1, bDelete ); // ppStaticDefaults points to deleted memory if bDelete == true. if ( bDelete ) - pImp->ppStaticDefaults = nullptr; + pImpl->ppStaticDefaults = nullptr; } @@ -346,21 +346,19 @@ void SfxItemPool::ReleaseDefaults SfxItemPool::~SfxItemPool() { - if ( !pImp->maPoolItems.empty() && pImp->ppPoolDefaults ) + if ( !pImpl->maPoolItems.empty() && pImpl->ppPoolDefaults ) Delete(); - if (pImp->mpMaster != nullptr && pImp->mpMaster != this) + if (pImpl->mpMaster != nullptr && pImpl->mpMaster != this) { // 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 // prevent a crash later on. - DBG_ASSERT( pImp->mpMaster == this, "destroying active Secondary-Pool" ); - if (pImp->mpMaster->pImp->mpSecondary == this) - pImp->mpMaster->pImp->mpSecondary = nullptr; + DBG_ASSERT( pImpl->mpMaster == this, "destroying active Secondary-Pool" ); + if (pImpl->mpMaster->pImpl->mpSecondary == this) + pImpl->mpMaster->pImpl->mpSecondary = nullptr; } - - delete pImp; } void SfxItemPool::Free(SfxItemPool* pPool) @@ -368,7 +366,7 @@ void SfxItemPool::Free(SfxItemPool* pPool) if(pPool) { // tell all the registered SfxItemPoolUsers that the pool is in destruction - std::vector aListCopy(pPool->pImp->maSfxItemPoolUsers.begin(), pPool->pImp->maSfxItemPoolUsers.end()); + std::vector aListCopy(pPool->pImpl->maSfxItemPoolUsers.begin(), pPool->pImpl->maSfxItemPoolUsers.end()); for(std::vector::const_iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); ++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() // when they get called from ObjectInDestruction(). - pPool->pImp->maSfxItemPoolUsers.clear(); + pPool->pImpl->maSfxItemPoolUsers.clear(); // delete pool delete pPool; @@ -389,25 +387,25 @@ void SfxItemPool::Free(SfxItemPool* pPool) void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool ) { // Reset Master in attached Pools - if ( pImp->mpSecondary ) + if ( pImpl->mpSecondary ) { #ifdef DBG_UTIL - if (pImp->ppStaticDefaults != nullptr && !pImp->maPoolItems.empty() - && !pImp->mpSecondary->pImp->maPoolItems.empty()) + if (pImpl->ppStaticDefaults != nullptr && !pImpl->maPoolItems.empty() + && !pImpl->mpSecondary->pImpl->maPoolItems.empty()) // Delete() did not yet run? { // Does the Master have SetItems? bool bHasSetItems = false; - for ( sal_uInt16 i = 0; !bHasSetItems && i < pImp->mnEnd - pImp->mnStart; ++i ) - bHasSetItems = dynamic_cast(pImp->ppStaticDefaults[i]) != nullptr; + for ( sal_uInt16 i = 0; !bHasSetItems && i < pImpl->mnEnd - pImpl->mnStart; ++i ) + bHasSetItems = dynamic_cast(pImpl->ppStaticDefaults[i]) != nullptr; // Detached Pools must be empty bool bOK = bHasSetItems; 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 ) { - SfxPoolItemArray_Impl* pItemArr = pImp->mpSecondary->pImp->maPoolItems[n]; + SfxPoolItemArray_Impl* pItemArr = pImpl->mpSecondary->pImpl->maPoolItems[n]; if ( pItemArr ) { SfxPoolItemArrayBase_Impl::const_iterator ppHtArr = pItemArr->begin(); @@ -423,19 +421,19 @@ void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool ) } #endif - pImp->mpSecondary->pImp->mpMaster = pImp->mpSecondary; - for ( SfxItemPool *p = pImp->mpSecondary->pImp->mpSecondary; p; p = p->pImp->mpSecondary ) - p->pImp->mpMaster = pImp->mpSecondary; + pImpl->mpSecondary->pImpl->mpMaster = pImpl->mpSecondary; + for ( SfxItemPool *p = pImpl->mpSecondary->pImpl->mpSecondary; p; p = p->pImpl->mpSecondary ) + p->pImpl->mpMaster = pImpl->mpSecondary; } // Set Master of new Secondary Pools - DBG_ASSERT( !pPool || pPool->pImp->mpMaster == pPool, "Secondary is present in two Pools" ); - SfxItemPool *pNewMaster = GetMasterPool() ? pImp->mpMaster : this; - for ( SfxItemPool *p = pPool; p; p = p->pImp->mpSecondary ) - p->pImp->mpMaster = pNewMaster; + DBG_ASSERT( !pPool || pPool->pImpl->mpMaster == pPool, "Secondary is present in two Pools" ); + SfxItemPool *pNewMaster = GetMasterPool() ? pImpl->mpMaster : this; + for ( SfxItemPool *p = pPool; p; p = p->pImpl->mpSecondary ) + p->pImpl->mpMaster = pNewMaster; // Remember new Secondary Pool - pImp->mpSecondary = pPool; + pImpl->mpSecondary = pPool; CHECK_SLOTS(); } @@ -449,18 +447,18 @@ void SfxItemPool::SetItemInfos(SfxItemInfo const*const pInfo) SfxMapUnit SfxItemPool::GetMetric( sal_uInt16 ) const { - return pImp->eDefMetric; + return pImpl->eDefMetric; } void SfxItemPool::SetDefaultMetric( SfxMapUnit eNewMetric ) { - pImp->eDefMetric = eNewMetric; + pImpl->eDefMetric = eNewMetric; } const OUString& SfxItemPool::GetName() const { - return pImp->aName; + return pImpl->aName; } @@ -487,21 +485,21 @@ SfxItemPool* SfxItemPool::Clone() const void SfxItemPool::Delete() { // Already deleted? - if ( pImp->maPoolItems.empty() || !pImp->ppPoolDefaults ) + if ( pImpl->maPoolItems.empty() || !pImpl->ppPoolDefaults ) return; // 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. // We separate this into two loops (for clarity's sake) - std::vector::iterator itrItemArr = pImp->maPoolItems.begin(); - SfxPoolItem** ppDefaultItem = pImp->ppPoolDefaults; - SfxPoolItem** ppStaticDefaultItem = pImp->ppStaticDefaults; + std::vector::iterator itrItemArr = pImpl->maPoolItems.begin(); + SfxPoolItem** ppDefaultItem = pImpl->ppPoolDefaults; + SfxPoolItem** ppStaticDefaultItem = pImpl->ppStaticDefaults; sal_uInt16 nArrCnt; // Collect the SetItems first - if (pImp->ppStaticDefaults != nullptr) { + if (pImpl->ppStaticDefaults != nullptr) { for ( nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++itrItemArr, ++ppDefaultItem, ++ppStaticDefaultItem ) @@ -535,8 +533,8 @@ void SfxItemPool::Delete() } } - itrItemArr = pImp->maPoolItems.begin(); - ppDefaultItem = pImp->ppPoolDefaults; + itrItemArr = pImpl->maPoolItems.begin(); + ppDefaultItem = pImpl->ppPoolDefaults; // Now for the easy Items 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()) ) { SfxPoolItem **ppOldDefault = - pImp->ppPoolDefaults + GetIndex_Impl(rItem.Which()); + pImpl->ppPoolDefaults + GetIndex_Impl(rItem.Which()); SfxPoolItem *pNewDefault = rItem.Clone(this); pNewDefault->SetKind(SFX_ITEMS_POOLDEFAULT); if ( *ppOldDefault ) @@ -584,8 +582,8 @@ void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem) } *ppOldDefault = pNewDefault; } - else if ( pImp->mpSecondary ) - pImp->mpSecondary->SetPoolDefaultItem(rItem); + else if ( pImpl->mpSecondary ) + pImpl->mpSecondary->SetPoolDefaultItem(rItem); else { assert(false && "unknown WhichId - cannot set pool default"); @@ -601,15 +599,15 @@ void SfxItemPool::ResetPoolDefaultItem( sal_uInt16 nWhichId ) if ( IsInRange(nWhichId) ) { SfxPoolItem **ppOldDefault = - pImp->ppPoolDefaults + GetIndex_Impl( nWhichId ); + pImpl->ppPoolDefaults + GetIndex_Impl( nWhichId ); if ( *ppOldDefault ) { (*ppOldDefault)->SetRefCount(0); DELETEZ( *ppOldDefault ); } } - else if ( pImp->mpSecondary ) - pImp->mpSecondary->ResetPoolDefaultItem(nWhichId); + else if ( pImpl->mpSecondary ) + pImpl->mpSecondary->ResetPoolDefaultItem(nWhichId); else { 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; if ( !bSID && !IsInRange(nWhich) ) { - if ( pImp->mpSecondary ) - return pImp->mpSecondary->Put( rItem, nWhich ); + if ( pImpl->mpSecondary ) + return pImpl->mpSecondary->Put( rItem, nWhich ); 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 || !IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE) && "a non Pool Item is Default?!"); - SfxPoolItem *pPoolItem = rItem.Clone(pImp->mpMaster); + SfxPoolItem *pPoolItem = rItem.Clone(pImpl->mpMaster); pPoolItem->SetWhich(nWhich); AddRef( *pPoolItem ); return *pPoolItem; } - assert(!pImp->ppStaticDefaults || + assert(!pImpl->ppStaticDefaults || typeid(rItem) == typeid(GetDefaultItem(nWhich))); - SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex]; + SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[nIndex]; if (!pItemArr) { - pImp->maPoolItems[nIndex] = new SfxPoolItemArray_Impl; - pItemArr = pImp->maPoolItems[nIndex]; + pImpl->maPoolItems[nIndex] = new SfxPoolItemArray_Impl; + pItemArr = pImpl->maPoolItems[nIndex]; } 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. - SfxPoolItem* pNewItem = rItem.Clone(pImp->mpMaster); + SfxPoolItem* pNewItem = rItem.Clone(pImpl->mpMaster); pNewItem->SetWhich(nWhich); assert(typeid(rItem) == typeid(*pNewItem) && "SfxItemPool::Put(): unequal types, no Clone() override?"); if (dynamic_cast(&rItem) == nullptr) @@ -724,7 +722,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich assert((!IsItemPoolable(*pNewItem) || *pNewItem == rItem) && "SfxItemPool::Put(): unequal items: no operator== override?"); } - AddRef( *pNewItem, pImp->nInitRefCount ); + AddRef( *pNewItem, pImpl->nInitRefCount ); // 4. finally insert into the pointer array assert( pItemArr->maPtrToIndex.find(pNewItem) == pItemArr->maPtrToIndex.end() ); @@ -772,9 +770,9 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem ) bool bSID = nWhich > SFX_WHICH_MAX; if ( !bSID && !IsInRange(nWhich) ) { - if ( pImp->mpSecondary ) + if ( pImpl->mpSecondary ) { - pImp->mpSecondary->Remove( rItem ); + pImpl->mpSecondary->Remove( rItem ); return; } OSL_FAIL( "unknown WhichId - cannot remove item" ); @@ -798,11 +796,11 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem ) // Static Defaults are just there if ( rItem.GetKind() == SFX_ITEMS_STATICDEFAULT && - &rItem == *( pImp->ppStaticDefaults + GetIndex_Impl(nWhich) ) ) + &rItem == *( pImpl->ppStaticDefaults + GetIndex_Impl(nWhich) ) ) return; // Find Item in own Pool - SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex]; + SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[nIndex]; assert(pItemArr && "removing Item not in Pool"); SfxPoolItemArray_Impl::PoolItemPtrToIndexMap::const_iterator it; @@ -846,27 +844,27 @@ const SfxPoolItem& SfxItemPool::GetDefaultItem( sal_uInt16 nWhich ) const { if ( !IsInRange(nWhich) ) { - if ( pImp->mpSecondary ) - return pImp->mpSecondary->GetDefaultItem( nWhich ); + if ( pImpl->mpSecondary ) + return pImpl->mpSecondary->GetDefaultItem( nWhich ); 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); - SfxPoolItem *pDefault = *(pImp->ppPoolDefaults + nPos); + SfxPoolItem *pDefault = *(pImpl->ppPoolDefaults + nPos); if ( pDefault ) return *pDefault; - return **(pImp->ppStaticDefaults + nPos); + return **(pImpl->ppStaticDefaults + nPos); } SfxItemPool* SfxItemPool::GetSecondaryPool() const { - return pImp->mpSecondary; + return pImpl->mpSecondary; } SfxItemPool* SfxItemPool::GetMasterPool() const { - return pImp->mpMaster; + return pImpl->mpMaster; } /** @@ -878,33 +876,33 @@ SfxItemPool* SfxItemPool::GetMasterPool() const */ void SfxItemPool::FreezeIdRanges() { - FillItemIdRanges_Impl( pImp->mpPoolRanges ); + FillItemIdRanges_Impl( pImpl->mpPoolRanges ); } 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; sal_uInt16 nLevel = 0; - for( pPool = this; pPool; pPool = pPool->pImp->mpSecondary ) + for( pPool = this; pPool; pPool = pPool->pImpl->mpSecondary ) ++nLevel; pWhichRanges = new sal_uInt16[ 2*nLevel + 1 ]; 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->pImp->mnEnd; + *(pWhichRanges+(nLevel++)) = pPool->pImpl->mnStart; + *(pWhichRanges+(nLevel++)) = pPool->pImpl->mnEnd; *(pWhichRanges+nLevel) = 0; } } const sal_uInt16* SfxItemPool::GetFrozenIdRanges() const { - return pImp->mpPoolRanges; + return pImpl->mpPoolRanges; } 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 ( pImp->mpSecondary ) - return pImp->mpSecondary->GetItem2( nWhich, nOfst ); + if ( pImpl->mpSecondary ) + return pImpl->mpSecondary->GetItem2( nWhich, nOfst ); assert(false && "unknown WhichId - cannot resolve surrogate"); return nullptr; } // default attribute? 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() ) return (*pItemArr)[nOfst]; @@ -937,13 +935,13 @@ sal_uInt32 SfxItemPool::GetItemCount2(sal_uInt16 nWhich) const { if ( !IsInRange(nWhich) ) { - if ( pImp->mpSecondary ) - return pImp->mpSecondary->GetItemCount2( nWhich ); + if ( pImpl->mpSecondary ) + return pImpl->mpSecondary->GetItemCount2( nWhich ); assert(false && "unknown WhichId - cannot resolve surrogate"); return 0; } - SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[GetIndex_Impl(nWhich)]; + SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[GetIndex_Impl(nWhich)]; if ( pItemArr ) return pItemArr->size(); return 0; @@ -955,12 +953,12 @@ sal_uInt16 SfxItemPool::GetWhich( sal_uInt16 nSlotId, bool bDeep ) const if ( !IsSlot(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 ) if ( pItemInfos[nOfs]._nSID == nSlotId ) - return nOfs + pImp->mnStart; - if ( pImp->mpSecondary && bDeep ) - return pImp->mpSecondary->GetWhich(nSlotId); + return nOfs + pImpl->mnStart; + if ( pImpl->mpSecondary && bDeep ) + return pImpl->mpSecondary->GetWhich(nSlotId); return nSlotId; } @@ -972,13 +970,13 @@ sal_uInt16 SfxItemPool::GetSlotId( sal_uInt16 nWhich, bool bDeep ) const if ( !IsInRange( nWhich ) ) { - if ( pImp->mpSecondary && bDeep ) - return pImp->mpSecondary->GetSlotId(nWhich); + if ( pImpl->mpSecondary && bDeep ) + return pImpl->mpSecondary->GetSlotId(nWhich); assert(false && "unknown WhichId - cannot get slot-id"); return 0; } - sal_uInt16 nSID = pItemInfos[nWhich - pImp->mnStart]._nSID; + sal_uInt16 nSID = pItemInfos[nWhich - pImpl->mnStart]._nSID; return nSID ? nSID : nWhich; } @@ -988,12 +986,12 @@ sal_uInt16 SfxItemPool::GetTrueWhich( sal_uInt16 nSlotId, bool bDeep ) const if ( !IsSlot(nSlotId) ) 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 ) if ( pItemInfos[nOfs]._nSID == nSlotId ) - return nOfs + pImp->mnStart; - if ( pImp->mpSecondary && bDeep ) - return pImp->mpSecondary->GetTrueWhich(nSlotId); + return nOfs + pImpl->mnStart; + if ( pImpl->mpSecondary && bDeep ) + return pImpl->mpSecondary->GetTrueWhich(nSlotId); return 0; } @@ -1005,12 +1003,12 @@ sal_uInt16 SfxItemPool::GetTrueSlotId( sal_uInt16 nWhich ) const if ( !IsInRange( nWhich ) ) { - if ( pImp->mpSecondary ) - return pImp->mpSecondary->GetTrueSlotId(nWhich); + if ( pImpl->mpSecondary ) + return pImpl->mpSecondary->GetTrueSlotId(nWhich); assert(false && "unknown WhichId - cannot get slot-id"); 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 ) { - DBG_ASSERT( this == pImp->mpMaster, + DBG_ASSERT( this == pImpl->mpMaster, "SfxItemPool::SetFileFormatVersion() but not a master pool" ); - for ( SfxItemPool *pPool = this; pPool; pPool = pPool->pImp->mpSecondary ) - pPool->pImp->mnFileFormatVersion = nFileFormatVersion; + for ( SfxItemPool *pPool = this; pPool; pPool = pPool->pImpl->mpSecondary ) + pPool->pImpl->mnFileFormatVersion = nFileFormatVersion; } const SfxItemPool* SfxItemPool::pStoringPool_ = nullptr; diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx index d380e9b8a112..ae7eb18c2ab8 100644 --- a/svl/source/items/poolio.cxx +++ b/svl/source/items/poolio.cxx @@ -122,12 +122,12 @@ static SfxItemKind convertUInt16ToSfxItemKind(sal_uInt16 x) SvStream &SfxItemPool::Store(SvStream &rStream) const { // Find StoreMaster - SfxItemPool *pStoreMaster = pImp->mpMaster != this ? pImp->mpMaster : nullptr; - while ( pStoreMaster && !pStoreMaster->pImp->bStreaming ) - pStoreMaster = pStoreMaster->pImp->mpSecondary; + SfxItemPool *pStoreMaster = pImpl->mpMaster != this ? pImpl->mpMaster : nullptr; + while ( pStoreMaster && !pStoreMaster->pImpl->bStreaming ) + pStoreMaster = pStoreMaster->pImpl->mpSecondary; // Old header (version of the Pool and content version is 0xffff by default) - pImp->bStreaming = true; + pImpl->bStreaming = true; if ( !pStoreMaster ) { rStream.WriteUInt16( rStream.GetVersion() >= SOFFICE_FILEFORMAT_50 @@ -148,14 +148,14 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const // Single header (content version and name) { SfxMiniRecordWriter aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER); - rStream.WriteUInt16( pImp->nVersion ); - writeByteString(rStream, pImp->aName); + rStream.WriteUInt16( pImpl->nVersion ); + writeByteString(rStream, pImpl->aName); } // VersionMaps { SfxMultiVarRecordWriter aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP ); - for (std::shared_ptr& pVer : pImp->aVersions) + for (std::shared_ptr& pVer : pImpl->aVersions) { aVerRec.NewContent(); 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 - if ( SOFFICE_FILEFORMAT_31 == pImp->mnFileFormatVersion ) + if ( SOFFICE_FILEFORMAT_31 == pImpl->mnFileFormatVersion ) 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) for (int ft = 0 ; ft < 2 && !rStream.GetError(); ft++) { - pImp->bInSetItem = ft != 0; + pImpl->bInSetItem = ft != 0; - std::vector::const_iterator itrArr = pImp->maPoolItems.begin(); - SfxPoolItem **ppDefItem = pImp->ppStaticDefaults; + std::vector::const_iterator itrArr = pImpl->maPoolItems.begin(); + SfxPoolItem **ppDefItem = pImpl->ppStaticDefaults; const sal_uInt16 nSize = GetSize_Impl(); for ( size_t i = 0; i < nSize && !rStream.GetError(); ++i, ++itrArr, ++ppDefItem ) { // Get version of the Item - sal_uInt16 nItemVersion = (*ppDefItem)->GetVersion( pImp->mnFileFormatVersion ); + sal_uInt16 nItemVersion = (*ppDefItem)->GetVersion( pImpl->mnFileFormatVersion ); if ( USHRT_MAX == nItemVersion ) // => Was not present in the version that was supposed to be exported continue; @@ -196,7 +196,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const // ! Poolable is not even saved in the Pool // And itemsets/plain-items depending on the round 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 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) @@ -257,11 +257,11 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const sal_uInt16 nCount = GetSize_Impl(); for ( sal_uInt16 n = 0; n < nCount; ++n ) { - const SfxPoolItem* pDefaultItem = pImp->ppPoolDefaults[n]; + const SfxPoolItem* pDefaultItem = pImpl->ppPoolDefaults[n]; if ( pDefaultItem ) { // Get version - sal_uInt16 nItemVersion = pDefaultItem->GetVersion( pImp->mnFileFormatVersion ); + sal_uInt16 nItemVersion = pDefaultItem->GetVersion( pImpl->mnFileFormatVersion ); if ( USHRT_MAX == nItemVersion ) // => Was not present in the version yet continue; @@ -281,16 +281,16 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const // Write out additional Pools pStoringPool_ = nullptr; aPoolRec.Close(); - if ( !rStream.GetError() && pImp->mpSecondary ) - pImp->mpSecondary->Store( rStream ); + if ( !rStream.GetError() && pImpl->mpSecondary ) + pImpl->mpSecondary->Store( rStream ); - pImp->bStreaming = false; + pImpl->bStreaming = false; return rStream; } bool SfxItemPool::HasPersistentRefCounts() const { - return pImp->mbPersistentRefCounts; + return pImpl->mbPersistentRefCounts; } /** @@ -308,10 +308,10 @@ bool SfxItemPool::HasPersistentRefCounts() const void SfxItemPool::LoadCompleted() { // Did we load without RefCounts? - if ( pImp->nInitRefCount > 1 ) + if ( pImpl->nInitRefCount > 1 ) { // Iterate over all Which values - std::vector::const_iterator itrItemArr = pImp->maPoolItems.begin(); + std::vector::const_iterator itrItemArr = pImpl->maPoolItems.begin(); for( sal_uInt16 nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++itrItemArr ) { // 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 - pImp->nInitRefCount = 1; + pImpl->nInitRefCount = 1; } // notify secondary pool - if ( pImp->mpSecondary ) - pImp->mpSecondary->LoadCompleted(); + if ( pImpl->mpSecondary ) + pImpl->mpSecondary->LoadCompleted(); } sal_uInt16 SfxItemPool::GetFirstWhich() const { - return pImp->mnStart; + return pImpl->mnStart; } sal_uInt16 SfxItemPool::GetLastWhich() const { - return pImp->mnEnd; + return pImpl->mnEnd; } 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: @@ -462,14 +462,14 @@ void SfxItemPool_Impl::readTheItems ( SvStream &SfxItemPool::Load(SvStream &rStream) { - DBG_ASSERT(pImp->ppStaticDefaults, "No DefaultArray"); + DBG_ASSERT(pImpl->ppStaticDefaults, "No DefaultArray"); // Protect items by increasing ref count - if ( !pImp->mbPersistentRefCounts ) + if ( !pImpl->mbPersistentRefCounts ) { // Iterate over all Which values - std::vector::const_iterator itrItemArr = pImp->maPoolItems.begin(); + std::vector::const_iterator itrItemArr = pImpl->maPoolItems.begin(); for( size_t nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++itrItemArr ) { // 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 - pImp->nInitRefCount = 2; + pImpl->nInitRefCount = 2; } // Find LoadMaster - SfxItemPool *pLoadMaster = pImp->mpMaster != this ? pImp->mpMaster : nullptr; - while ( pLoadMaster && !pLoadMaster->pImp->bStreaming ) - pLoadMaster = pLoadMaster->pImp->mpSecondary; + SfxItemPool *pLoadMaster = pImpl->mpMaster != this ? pImpl->mpMaster : nullptr; + while ( pLoadMaster && !pLoadMaster->pImpl->bStreaming ) + pLoadMaster = pLoadMaster->pImpl->mpSecondary; // Read whole Header - pImp->bStreaming = true; + pImpl->bStreaming = true; if ( !pLoadMaster ) { // Load format version @@ -507,21 +507,21 @@ SvStream &SfxItemPool::Load(SvStream &rStream) OSL_FAIL( "SFX_ITEMPOOL_TAG_STARTPOOL_5" ); /*! s.u. */ /*! Set error code and evaluate! */ (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); - pImp->bStreaming = false; + pImpl->bStreaming = false; return rStream; } - rStream.ReadUChar( pImp->nMajorVer ).ReadUChar( pImp->nMinorVer ); + rStream.ReadUChar( pImpl->nMajorVer ).ReadUChar( pImpl->nMinorVer ); // Take over format version to MasterPool - pImp->mpMaster->pImp->nMajorVer = pImp->nMajorVer; - pImp->mpMaster->pImp->nMinorVer = pImp->nMinorVer; + pImpl->mpMaster->pImpl->nMajorVer = pImpl->nMajorVer; + pImpl->mpMaster->pImpl->nMinorVer = pImpl->nMinorVer; // 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); - pImp->bStreaming = false; + pImpl->bStreaming = false; return rStream; } @@ -533,7 +533,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream) OSL_FAIL( "SFX_ITEMPOOL_TAG_TRICK4OLD" ); /*! s.u. */ /*! Set error code and evaluate! */ (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); - pImp->bStreaming = false; + pImpl->bStreaming = false; return rStream; } @@ -544,7 +544,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream) SfxMiniRecordReader aPoolRec( &rStream, SFX_ITEMPOOL_REC ); if ( rStream.GetError() ) { - pImp->bStreaming = false; + pImpl->bStreaming = false; return rStream; } @@ -555,21 +555,21 @@ SvStream &SfxItemPool::Load(SvStream &rStream) SfxMiniRecordReader aPoolHeaderRec( &rStream, SFX_ITEMPOOL_REC_HEADER ); if ( rStream.GetError() ) { - pImp->bStreaming = false; + pImpl->bStreaming = false; return rStream; } // Read Header - rStream.ReadUInt16( pImp->nLoadingVersion ); + rStream.ReadUInt16( pImpl->nLoadingVersion ); aExternName = readByteString(rStream); - bool bOwnPool = aExternName == pImp->aName; + bool bOwnPool = aExternName == pImpl->aName; //! As long as we cannot read foreign Pools if ( !bOwnPool ) { rStream.SetError(SVSTREAM_FILEFORMAT_ERROR); aPoolRec.Skip(); - pImp->bStreaming = false; + pImpl->bStreaming = false; return rStream; } } @@ -579,12 +579,12 @@ SvStream &SfxItemPool::Load(SvStream &rStream) SfxMultiRecordReader aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP ); if ( rStream.GetError() ) { - pImp->bStreaming = false; + pImpl->bStreaming = false; return rStream; } // Version maps einlesen - sal_uInt16 nOwnVersion = pImp->nVersion; + sal_uInt16 nOwnVersion = pImpl->nVersion; for ( sal_uInt16 nVerNo = 0; aVerRec.GetContent(); ++nVerNo ) { // Read header for single versions @@ -593,7 +593,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream) sal_uInt16 nCount = nHEnd - nHStart + 1; // Is new version is known? - if ( nVerNo >= pImp->aVersions.size() ) + if ( nVerNo >= pImpl->aVersions.size() ) { // Add new Version const size_t nMaxRecords = rStream.remainingSize() / sizeof(sal_uInt16); @@ -610,7 +610,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream) SetVersionMap( nVersion, nHStart, nHEnd, pMap ); } } - pImp->nVersion = nOwnVersion; + pImpl->nVersion = nOwnVersion; } // Load Items @@ -625,7 +625,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream) sal_uInt16 nVersion(0), nWhich(0); //!sal_uInt16 nSlotId = aWhichIdsRec.GetContentTag(); rStream.ReadUInt16( nWhich ); - if ( pImp->nLoadingVersion != pImp->nVersion ) + if ( pImpl->nLoadingVersion != pImpl->nVersion ) // Move WhichId from file version to Pool version nWhich = GetNewWhich( nWhich ); @@ -641,19 +641,19 @@ SvStream &SfxItemPool::Load(SvStream &rStream) //! nWhich, "Slot/Which mismatch" ); 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 - SfxPoolItem *pDefItem = *(pImp->ppStaticDefaults + nIndex); - pImp->bInSetItem = dynamic_cast( pDefItem ) != nullptr; - if ( !bSecondaryLoaded && pImp->mpSecondary && pImp->bInSetItem ) + SfxPoolItem *pDefItem = *(pImpl->ppStaticDefaults + nIndex); + pImpl->bInSetItem = dynamic_cast( pDefItem ) != nullptr; + if ( !bSecondaryLoaded && pImpl->mpSecondary && pImpl->bInSetItem ) { // Seek to end of own Pool sal_uLong nLastPos = rStream.Tell(); aPoolRec.Skip(); // Read secondary Pool - pImp->mpSecondary->Load( rStream ); + pImpl->mpSecondary->Load( rStream ); bSecondaryLoaded = true; nSecondaryEnd = rStream.Tell(); @@ -662,9 +662,9 @@ SvStream &SfxItemPool::Load(SvStream &rStream) } // 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 nSlotId = aDefsRec.GetContentTag(); rStream.ReadUInt16( nWhich ); - if ( pImp->nLoadingVersion != pImp->nVersion ) + if ( pImpl->nLoadingVersion != pImpl->nVersion ) // Move WhichId from file version to Pool version nWhich = GetNewWhich( nWhich ); @@ -692,44 +692,44 @@ SvStream &SfxItemPool::Load(SvStream &rStream) // Load PoolDefaultItem SfxPoolItem *pItem = - ( *( pImp->ppStaticDefaults + GetIndex_Impl(nWhich) ) ) + ( *( pImpl->ppStaticDefaults + GetIndex_Impl(nWhich) ) ) ->Create( rStream, nVersion ); pItem->SetKind( SFX_ITEMS_POOLDEFAULT ); - *( pImp->ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem; + *( pImpl->ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem; } } // Load secondary Pool if needed aPoolRec.Skip(); - if ( pImp->mpSecondary ) + if ( pImpl->mpSecondary ) { if ( !bSecondaryLoaded ) - pImp->mpSecondary->Load( rStream ); + pImpl->mpSecondary->Load( rStream ); else rStream.Seek( nSecondaryEnd ); } // If not own Pool, then no name - if ( aExternName != pImp->aName ) - (pImp->aName).clear(); + if ( aExternName != pImpl->aName ) + (pImpl->aName).clear(); - pImp->bStreaming = false; + pImpl->bStreaming = false; return rStream; }; 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"); return 0; } - return nWhich - pImp->mnStart; + return nWhich - pImpl->mnStart; } 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 ) { 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? if ( pTarget->IsInRange(rWhich) ) { // Default attribute? if ( SFX_ITEMS_DEFAULT == nSurrogat ) - return *(pTarget->pImp->ppStaticDefaults + + return *(pTarget->pImpl->ppStaticDefaults + pTarget->GetIndex_Impl(rWhich)); SfxPoolItemArray_Impl* pItemArr = - pTarget->pImp->maPoolItems[pTarget->GetIndex_Impl(rWhich)]; + pTarget->pImpl->maPoolItems[pTarget->GetIndex_Impl(rWhich)]; pItem = pItemArr && nSurrogat < pItemArr->size() ? (*pItemArr)[nSurrogat] : nullptr; @@ -833,7 +833,7 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate } // Reload from RefPool? - if ( pRefPool != pImp->mpMaster ) + if ( pRefPool != pImpl->mpMaster ) return &pTarget->Put( *pItem ); // 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 ( pImp->mpSecondary ) - return pImp->mpSecondary->GetSurrogate( pItem ); + if ( pImpl->mpSecondary ) + return pImpl->mpSecondary->GetSurrogate( pItem ); 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) ) 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"); 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 { - return nWhich >= pImp->nStoringStart && - nWhich <= pImp->nStoringEnd; + return nWhich >= pImpl->nStoringStart && + nWhich <= pImpl->nStoringEnd; } /** @@ -932,8 +932,8 @@ bool SfxItemPool::IsInStoringRange( sal_uInt16 nWhich ) const */ void SfxItemPool::SetStoringRange( sal_uInt16 nFrom, sal_uInt16 nTo ) { - pImp->nStoringStart = nFrom; - pImp->nStoringEnd = nTo; + pImpl->nStoringStart = nFrom; + pImpl->nStoringEnd = nTo; } @@ -990,23 +990,23 @@ void SfxItemPool::SetVersionMap // Create new map entry to insert const SfxPoolVersion_ImplPtr pVerMap = std::make_shared( nVer, nOldStart, nOldEnd, pOldWhichIdTab ); - pImp->aVersions.push_back( pVerMap ); + pImpl->aVersions.push_back( pVerMap ); - DBG_ASSERT( nVer > pImp->nVersion, "Versions not sorted" ); - pImp->nVersion = nVer; + DBG_ASSERT( nVer > pImpl->nVersion, "Versions not sorted" ); + pImpl->nVersion = nVer; // Adapt version range for ( sal_uInt16 n = 0; n < nOldEnd-nOldStart+1; ++n ) { sal_uInt16 nWhich = pOldWhichIdTab[n]; - if ( nWhich < pImp->nVerStart ) + if ( nWhich < pImpl->nVerStart ) { if ( !nWhich ) nWhich = 0; - pImp->nVerStart = nWhich; + pImpl->nVerStart = nWhich; } - else if ( nWhich > pImp->nVerEnd ) - pImp->nVerEnd = nWhich; + else if ( nWhich > pImpl->nVerEnd ) + pImpl->nVerEnd = nWhich; } } @@ -1039,22 +1039,22 @@ sal_uInt16 SfxItemPool::GetNewWhich // Determine (secondary) Pool if ( !IsInVersionsRange(nFileWhich) ) { - if ( pImp->mpSecondary ) - return pImp->mpSecondary->GetNewWhich( nFileWhich ); + if ( pImpl->mpSecondary ) + return pImpl->mpSecondary->GetNewWhich( nFileWhich ); SFX_ASSERT( false, nFileWhich, "unknown which in GetNewWhich()" ); } // 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? if ( nDiff > 0 ) { // 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]; - if ( pVerInfo->_nVer > pImp->nVersion ) + SfxPoolVersion_ImplPtr pVerInfo = pImpl->aVersions[nMap-1]; + if ( pVerInfo->_nVer > pImpl->nVersion ) { sal_uInt16 nOfs; sal_uInt16 nCount = pVerInfo->_nEnd - pVerInfo->_nStart + 1; for ( nOfs = 0; @@ -1077,9 +1077,9 @@ sal_uInt16 SfxItemPool::GetNewWhich else if ( nDiff < 0 ) { // Map step by step from the top version down to the file version - for (std::shared_ptr& pVerInfo : pImp->aVersions) + for (std::shared_ptr& pVerInfo : pImpl->aVersions) { - if ( pVerInfo->_nVer > pImp->nLoadingVersion ) + if ( pVerInfo->_nVer > pImpl->nLoadingVersion ) { if (nFileWhich >= pVerInfo->_nStart && nFileWhich <= pVerInfo->_nEnd) @@ -1101,7 +1101,7 @@ sal_uInt16 SfxItemPool::GetNewWhich 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 { - return ( pImp->nVersion == pImp->nLoadingVersion ) && - ( !pImp->mpSecondary || pImp->mpSecondary->IsCurrentVersionLoading() ); + return ( pImpl->nVersion == pImpl->nLoadingVersion ) && + ( !pImpl->mpSecondary || pImpl->mpSecondary->IsCurrentVersionLoading() ); } @@ -1154,14 +1154,14 @@ bool SfxItemPool::StoreItem( SvStream &rStream, const SfxPoolItem &rItem, const SfxItemPool *pPool = this; while ( !pPool->IsInStoringRange(rItem.Which()) ) - if ( nullptr == ( pPool = pPool->pImp->mpSecondary ) ) + if ( nullptr == ( pPool = pPool->pImpl->mpSecondary ) ) return false; - DBG_ASSERT( !pImp->bInSetItem || dynamic_cast( &rItem ) == nullptr, + DBG_ASSERT( !pImpl->bInSetItem || dynamic_cast( &rItem ) == nullptr, "SetItem contains ItemSet with SetItem" ); 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 ) return false; @@ -1198,8 +1198,8 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, // Find right secondary Pool while ( !pRefPool->IsInVersionsRange(nWhich) ) { - if ( pRefPool->pImp->mpSecondary ) - pRefPool = pRefPool->pImp->mpSecondary; + if ( pRefPool->pImpl->mpSecondary ) + pRefPool = pRefPool->pImpl->mpSecondary; else { // WID not present in this version => skip @@ -1220,8 +1220,8 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, if ( !bCurVersion ) nWhich = pRefPool->GetNewWhich( nWhich ); // Map WhichId to new version - DBG_ASSERT( !nWhich || !pImp->bInSetItem || - dynamic_cast( pRefPool->pImp->ppStaticDefaults[pRefPool->GetIndex_Impl(nWhich)] ) == nullptr, + DBG_ASSERT( !nWhich || !pImpl->bInSetItem || + dynamic_cast( pRefPool->pImpl->ppStaticDefaults[pRefPool->GetIndex_Impl(nWhich)] ) == nullptr, "loading SetItem in ItemSet of SetItem" ); // Are we loading via surrogate? -- cgit