summaryrefslogtreecommitdiff
path: root/svl/source/items
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2024-01-27 15:04:06 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2024-01-27 19:02:54 +0100
commit4790ef5cb574650c418591566eeb0babc69db59e (patch)
treebdca4156b1da8bb3efc06cebcee77fa541866ca7 /svl/source/items
parentd2d8f8bf82558d9aa548fb9f13bed410e0baf79b (diff)
ITEM: Cleanup some Pool stuff with Defaults
Sorted out some methods at ItemPool which process Defaults to make more clear what is going on and what which method is doing. Change-Id: I2568d3e03d0a56a14b6fe4e04521e1a8e22c000b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162643 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'svl/source/items')
-rw-r--r--svl/source/items/itempool.cxx108
-rw-r--r--svl/source/items/itemprop.cxx4
-rw-r--r--svl/source/items/itemset.cxx20
-rw-r--r--svl/source/items/poolitem.cxx3
4 files changed, 68 insertions, 67 deletions
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index cb70ecd95c0b..0b5fd21b2fe8 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -332,13 +332,13 @@ sal_uInt16 SfxItemPool::GetSize_Impl() const
return mnEnd - mnStart + 1;
}
-const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( sal_uInt16 nWhich ) const
+const SfxPoolItem* SfxItemPool::GetUserDefaultItem( sal_uInt16 nWhich ) const
{
const SfxPoolItem* pRet;
if( IsInRange( nWhich ) )
- pRet = maPoolDefaults[GetIndex_Impl(nWhich)];
+ pRet = maUserDefaults[GetIndex_Impl(nWhich)];
else if( mpSecondary )
- pRet = mpSecondary->GetPoolDefaultItem( nWhich );
+ pRet = mpSecondary->GetUserDefaultItem( nWhich );
else
{
assert(false && "unknown WhichId - cannot get pool default");
@@ -383,11 +383,11 @@ SfxBroadcaster& SfxItemPool::BC()
*
* If the Pool is supposed to hold SfxSetItems, the ctor cannot yet contain
* static Defaults. This needs to be done afterwards, using
- * @see SfxItemPool::SetDefaults(std::vector<SfxPoolItem*>*).
+ * @see SfxItemPool::SetPoolDefaults(std::vector<SfxPoolItem*>*).
*
- * @see SfxItemPool::SetDefaults(std::vector<SfxPoolItem*>*)
- * @see SfxItemPool::ReleaseDefaults(std::vector<SfxPoolItem*>*,bool)
- * @see SfxItemPool::ReleaseDefaults(bool)
+ * @see SfxItemPool::SetPoolDefaults(std::vector<SfxPoolItem*>*)
+ * @see SfxItemPool::ReleasePoolDefaults(std::vector<SfxPoolItem*>*,bool)
+ * @see SfxItemPool::ReleasePoolDefaults(bool)
*/
SfxItemPool::SfxItemPool
(
@@ -403,8 +403,8 @@ SfxItemPool::SfxItemPool
: salhelper::SimpleReferenceObject()
,pItemInfos(pInfo)
, aName(rName)
-, maPoolDefaults(nEndWhich - nStartWhich + 1)
-, mpStaticDefaults(nullptr)
+, maUserDefaults(nEndWhich - nStartWhich + 1)
+, mpPoolDefaults(nullptr)
, mpMaster(this)
, mnStart(nStartWhich)
, mnEnd(nEndWhich)
@@ -416,7 +416,7 @@ SfxItemPool::SfxItemPool
eDefMetric = MapUnit::MapTwip;
if ( pDefaults )
- SetDefaults(pDefaults);
+ SetPoolDefaults(pDefaults);
#ifdef DBG_UTIL
if (pItemInfos)
@@ -455,8 +455,8 @@ SfxItemPool::SfxItemPool
: salhelper::SimpleReferenceObject()
, pItemInfos(rPool.pItemInfos)
, aName(rPool.aName)
-, maPoolDefaults(rPool.mnEnd - rPool.mnStart + 1)
-, mpStaticDefaults(nullptr)
+, maUserDefaults(rPool.mnEnd - rPool.mnStart + 1)
+, mpPoolDefaults(nullptr)
, mpMaster(this)
, mnStart(rPool.mnStart)
, mnEnd(rPool.mnEnd)
@@ -473,21 +473,21 @@ SfxItemPool::SfxItemPool
std::vector<SfxPoolItem *>* ppDefaults = new std::vector<SfxPoolItem*>(mnEnd-mnStart+1);
for ( sal_uInt16 n = 0; n <= mnEnd - mnStart; ++n )
{
- (*ppDefaults)[n] = (*rPool.mpStaticDefaults)[n]->Clone(this);
+ (*ppDefaults)[n] = (*rPool.mpPoolDefaults)[n]->Clone(this);
(*ppDefaults)[n]->setStaticDefault();
}
- SetDefaults( ppDefaults );
+ SetPoolDefaults( ppDefaults );
}
else
- SetDefaults( rPool.mpStaticDefaults );
+ SetPoolDefaults( rPool.mpPoolDefaults );
// Copy Pool Defaults
- for (size_t n = 0; n < maPoolDefaults.size(); ++n )
- if (rPool.maPoolDefaults[n])
+ for (size_t n = 0; n < maUserDefaults.size(); ++n )
+ if (rPool.maUserDefaults[n])
{
- maPoolDefaults[n] = rPool.maPoolDefaults[n]->Clone(this); //resets kind
- maPoolDefaults[n]->setPoolDefault();
+ maUserDefaults[n] = rPool.maUserDefaults[n]->Clone(this); //resets kind
+ maUserDefaults[n]->setUserDefault();
}
// Repair linkage
@@ -495,30 +495,30 @@ SfxItemPool::SfxItemPool
SetSecondaryPool( rPool.mpSecondary->Clone().get() );
}
-void SfxItemPool::SetDefaults( std::vector<SfxPoolItem*>* pDefaults )
+void SfxItemPool::SetPoolDefaults( std::vector<SfxPoolItem*>* pDefaults )
{
DBG_ASSERT( pDefaults, "first we ask for it, and then we don't give back..." );
- DBG_ASSERT( !mpStaticDefaults, "already have Defaults" );
+ DBG_ASSERT( !mpPoolDefaults, "already have Defaults" );
- mpStaticDefaults = pDefaults;
- //! if ((*mpStaticDefaults)->GetKind() != SfxItemKind::StaticDefault)
+ mpPoolDefaults = pDefaults;
+ //! if ((*mpPoolDefaults)->GetKind() != SfxItemKind::StaticDefault)
//! FIXME: Probably doesn't work with SetItems at the end
{
- DBG_ASSERT( (*mpStaticDefaults)[0]->GetRefCount() == 0 ||
- IsDefaultItem( (*mpStaticDefaults)[0] ),
+ DBG_ASSERT( (*mpPoolDefaults)[0]->GetRefCount() == 0 ||
+ IsDefaultItem( (*mpPoolDefaults)[0] ),
"these are not static" );
for ( sal_uInt16 n = 0; n <= mnEnd - mnStart; ++n )
{
- assert( ((*mpStaticDefaults)[n]->Which() == n + mnStart)
+ assert( ((*mpPoolDefaults)[n]->Which() == n + mnStart)
&& "items ids in pool-ranges and in static-defaults do not match" );
- (*mpStaticDefaults)[n]->setStaticDefault();
+ (*mpPoolDefaults)[n]->setStaticDefault();
}
}
}
-void SfxItemPool::ClearDefaults()
+void SfxItemPool::ClearPoolDefaults()
{
- mpStaticDefaults = nullptr;
+ mpPoolDefaults = nullptr;
}
/**
@@ -528,7 +528,7 @@ void SfxItemPool::ClearDefaults()
* The SfxItemPool instance MUST NOT BE USED after this function has
* been called; only the dtor must be called.
*/
-void SfxItemPool::ReleaseDefaults
+void SfxItemPool::ReleasePoolDefaults
(
bool bDelete /* true
Deletes the array as well as the single static Defaults
@@ -539,12 +539,12 @@ void SfxItemPool::ReleaseDefaults
{
- DBG_ASSERT( mpStaticDefaults, "requirements not met" );
- ReleaseDefaults( mpStaticDefaults, bDelete );
+ DBG_ASSERT( mpPoolDefaults, "requirements not met" );
+ ReleasePoolDefaults( mpPoolDefaults, bDelete );
- // mpStaticDefaults points to deleted memory if bDelete == true.
+ // mpPoolDefaults points to deleted memory if bDelete == true.
if ( bDelete )
- mpStaticDefaults = nullptr;
+ mpPoolDefaults = nullptr;
}
@@ -555,7 +555,7 @@ void SfxItemPool::ReleaseDefaults
* This method MUST be called AFTER all SfxItemPool instances (which
* use the specified static Defaults 'pDefault') have been destroyed.
*/
-void SfxItemPool::ReleaseDefaults
+void SfxItemPool::ReleasePoolDefaults
(
std::vector<SfxPoolItem*>*
pDefaults, /* Static Defaults that are to be freed */
@@ -593,7 +593,7 @@ void SfxItemPool::ReleaseDefaults
SfxItemPool::~SfxItemPool()
{
// Need to be deleted?
- if (!mbPreDeleteDone)//maPoolDefaults.empty())
+ if (!mbPreDeleteDone)//maUserDefaults.empty())
Delete();
if (mpMaster != nullptr && mpMaster != this)
@@ -682,7 +682,7 @@ rtl::Reference<SfxItemPool> SfxItemPool::Clone() const
void SfxItemPool::Delete()
{
// Already deleted?
- if (mbPreDeleteDone)//maPoolDefaults.empty())
+ if (mbPreDeleteDone)//maUserDefaults.empty())
return;
mbPreDeleteDone = true;
@@ -690,7 +690,7 @@ void SfxItemPool::Delete()
aBC.Broadcast( SfxHint( SfxHintId::Dying ) );
// default items
- for (auto rItemPtr : maPoolDefaults)
+ for (auto rItemPtr : maUserDefaults)
{
if (rItemPtr)
{
@@ -702,19 +702,19 @@ void SfxItemPool::Delete()
}
}
- maPoolDefaults.clear();
+ maUserDefaults.clear();
mpPoolRanges.reset();
}
-void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
+void SfxItemPool::SetUserDefaultItem(const SfxPoolItem &rItem)
{
if ( IsInRange(rItem.Which()) )
{
auto& rOldDefault =
- maPoolDefaults[GetIndex_Impl(rItem.Which())];
+ maUserDefaults[GetIndex_Impl(rItem.Which())];
SfxPoolItem *pNewDefault = rItem.Clone(this);
- pNewDefault->setPoolDefault();
+ pNewDefault->setUserDefault();
if (rOldDefault)
{
rOldDefault->SetRefCount(0);
@@ -724,7 +724,7 @@ void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
rOldDefault = pNewDefault;
}
else if ( mpSecondary )
- mpSecondary->SetPoolDefaultItem(rItem);
+ mpSecondary->SetUserDefaultItem(rItem);
else
{
assert(false && "unknown WhichId - cannot set pool default");
@@ -735,12 +735,12 @@ void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
* Resets the default of the given WhichId back to the static Default.
* If a pool default exists, it is removed.
*/
-void SfxItemPool::ResetPoolDefaultItem( sal_uInt16 nWhichId )
+void SfxItemPool::ResetUserDefaultItem( sal_uInt16 nWhichId )
{
if ( IsInRange(nWhichId) )
{
auto& rOldDefault =
- maPoolDefaults[GetIndex_Impl(nWhichId)];
+ maUserDefaults[GetIndex_Impl(nWhichId)];
if (rOldDefault)
{
rOldDefault->SetRefCount(0);
@@ -749,28 +749,28 @@ void SfxItemPool::ResetPoolDefaultItem( sal_uInt16 nWhichId )
}
}
else if ( mpSecondary )
- mpSecondary->ResetPoolDefaultItem(nWhichId);
+ mpSecondary->ResetUserDefaultItem(nWhichId);
else
{
assert(false && "unknown WhichId - cannot reset pool default");
}
}
-const SfxPoolItem& SfxItemPool::GetDefaultItem( sal_uInt16 nWhich ) const
+const SfxPoolItem& SfxItemPool::GetUserOrPoolDefaultItem( sal_uInt16 nWhich ) const
{
if ( !IsInRange(nWhich) )
{
if ( mpSecondary )
- return mpSecondary->GetDefaultItem( nWhich );
+ return mpSecondary->GetUserOrPoolDefaultItem( nWhich );
assert(!"unknown which - don't ask me for defaults");
}
- DBG_ASSERT( mpStaticDefaults, "no defaults known - don't ask me for defaults" );
+ DBG_ASSERT( mpPoolDefaults, "no defaults known - don't ask me for defaults" );
sal_uInt16 nPos = GetIndex_Impl(nWhich);
- SfxPoolItem* pDefault = maPoolDefaults[nPos];
+ SfxPoolItem* pDefault = maUserDefaults[nPos];
if ( pDefault )
return *pDefault;
- return *(*mpStaticDefaults)[nPos];
+ return *(*mpPoolDefaults)[nPos];
}
SfxItemPool* SfxItemPool::GetSecondaryPool() const
@@ -822,16 +822,16 @@ const WhichRangesContainer& SfxItemPool::GetFrozenIdRanges() const
return mpPoolRanges;
}
-const SfxPoolItem *SfxItemPool::GetItem2Default(sal_uInt16 nWhich) const
+const SfxPoolItem *SfxItemPool::GetPoolDefaultItem(sal_uInt16 nWhich) const
{
if ( !IsInRange(nWhich) )
{
if ( mpSecondary )
- return mpSecondary->GetItem2Default( nWhich );
+ return mpSecondary->GetPoolDefaultItem( nWhich );
assert(false && "unknown WhichId - cannot resolve surrogate");
return nullptr;
}
- return (*mpStaticDefaults)[ GetIndex_Impl(nWhich) ];
+ return (*mpPoolDefaults)[ GetIndex_Impl(nWhich) ];
}
namespace
diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx
index 3885542f89b8..8478eaadc98a 100644
--- a/svl/source/items/itemprop.cxx
+++ b/svl/source/items/itemprop.cxx
@@ -120,7 +120,7 @@ void SfxItemPropertySet::getPropertyValue( const SfxItemPropertyMapEntry& rEntry
const SfxPoolItem* pItem = nullptr;
SfxItemState eState = rSet.GetItemState( rEntry.nWID, true, &pItem );
if (SfxItemState::SET != eState && SfxItemPool::IsWhich(rEntry.nWID) )
- pItem = &rSet.GetPool()->GetDefaultItem(rEntry.nWID);
+ pItem = &rSet.GetPool()->GetUserOrPoolDefaultItem(rEntry.nWID);
// return item values as uno::Any
if(eState >= SfxItemState::DEFAULT && pItem)
{
@@ -168,7 +168,7 @@ void SfxItemPropertySet::setPropertyValue( const SfxItemPropertyMapEntry& rEntry
std::unique_ptr<SfxPoolItem> pNewItem;
SfxItemState eState = rSet.GetItemState( rEntry.nWID, true, &pItem );
if (SfxItemState::SET != eState && SfxItemPool::IsWhich(rEntry.nWID))
- pItem = &rSet.GetPool()->GetDefaultItem(rEntry.nWID);
+ pItem = &rSet.GetPool()->GetUserOrPoolDefaultItem(rEntry.nWID);
if (pItem)
{
pNewItem.reset(pItem->Clone());
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 1c591f73c60e..9271ab13f3c1 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -560,7 +560,7 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS
// if (IsStaticDefaultItem(pSource))
// {
// assert(!bPassingOwnership && "ITEM: PassingOwnership not possible combined with StaticDefault (!)");
- // const SfxPoolItem* pStatic(pTargetPool->GetItem2Default(pSource->Which()));
+ // const SfxPoolItem* pStatic(pTargetPool->GetPoolDefaultItem(pSource->Which()));
// if (nullptr != pStatic)
// {
// if (SfxPoolItem::areSame(pSource, pStatic))
@@ -575,7 +575,7 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS
// else if (IsDefaultItem(pSource))
// {
// assert(!bPassingOwnership && "ITEM: PassingOwnership not possible combined with DynamicDefault (!)");
- // const SfxPoolItem* pDynamic(pTargetPool->GetPoolDefaultItem(pSource->Which()));
+ // const SfxPoolItem* pDynamic(pTargetPool->GetUserDefaultItem(pSource->Which()));
// if (nullptr != pDynamic)
// {
// if (SfxPoolItem::areSame(pSource, pDynamic))
@@ -1254,7 +1254,7 @@ void SfxItemSet::PutExtended
switch (eDontCareAs)
{
case SfxItemState::SET:
- PutImpl(rSource.GetPool()->GetDefaultItem(nWhich), false);
+ PutImpl(rSource.GetPool()->GetUserOrPoolDefaultItem(nWhich), false);
break;
case SfxItemState::DEFAULT:
@@ -1281,7 +1281,7 @@ void SfxItemSet::PutExtended
switch (eDefaultAs)
{
case SfxItemState::SET:
- PutImpl(rSource.GetPool()->GetDefaultItem(nWhich), false);
+ PutImpl(rSource.GetPool()->GetUserOrPoolDefaultItem(nWhich), false);
break;
case SfxItemState::DEFAULT:
@@ -1506,7 +1506,7 @@ const SfxPoolItem* SfxItemSet::GetItem(sal_uInt16 nId, bool bSearchInParent) con
if (bSearchInParent && SfxItemState::DEFAULT == eState && SfxItemPool::IsWhich(nWhich))
{
- pItem = &GetPool()->GetDefaultItem(nWhich);
+ pItem = &GetPool()->GetUserOrPoolDefaultItem(nWhich);
}
return pItem;
@@ -1525,7 +1525,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const
{
if (IsInvalidItem(*aFoundOne))
{
- return GetPool()->GetDefaultItem(nWhich);
+ return GetPool()->GetUserOrPoolDefaultItem(nWhich);
}
#ifdef DBG_UTIL
if (IsDisabledItem(*aFoundOne))
@@ -1542,7 +1542,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const
// Get the Default from the Pool and return
assert(m_pPool);
- return GetPool()->GetDefaultItem(nWhich);
+ return GetPool()->GetUserOrPoolDefaultItem(nWhich);
}
/**
@@ -1753,7 +1753,7 @@ void SfxItemSet::MergeItem_Impl(const SfxPoolItem **ppFnd1, const SfxPoolItem *p
*ppFnd1 = INVALID_POOL_ITEM;
else if ( pFnd2 && !bIgnoreDefaults &&
- GetPool()->GetDefaultItem(pFnd2->Which()) != *pFnd2 )
+ GetPool()->GetUserOrPoolDefaultItem(pFnd2->Which()) != *pFnd2 )
// Decision table: default, set, !=, sal_False
*ppFnd1 = INVALID_POOL_ITEM;
@@ -1776,7 +1776,7 @@ void SfxItemSet::MergeItem_Impl(const SfxPoolItem **ppFnd1, const SfxPoolItem *p
{
// 2nd Item is Default
if ( !bIgnoreDefaults &&
- **ppFnd1 != GetPool()->GetDefaultItem((*ppFnd1)->Which()) )
+ **ppFnd1 != GetPool()->GetUserOrPoolDefaultItem((*ppFnd1)->Which()) )
{
// Decision table: set, default, !=, sal_False
checkRemovePoolRegistration(*ppFnd1);
@@ -1789,7 +1789,7 @@ void SfxItemSet::MergeItem_Impl(const SfxPoolItem **ppFnd1, const SfxPoolItem *p
{
// 2nd Item is dontcare
if ( !bIgnoreDefaults ||
- **ppFnd1 != GetPool()->GetDefaultItem( (*ppFnd1)->Which()) )
+ **ppFnd1 != GetPool()->GetUserOrPoolDefaultItem( (*ppFnd1)->Which()) )
{
// Decision table: set, dontcare, doesn't matter, sal_False
// or: set, dontcare, !=, sal_True
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index 10fda040f5cb..31f6cd27990d 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -510,7 +510,8 @@ SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
, m_nSerialNumber(nUsedSfxPoolItemCount)
#endif
, m_bStaticDefault(false)
- , m_bPoolDefault(false)
+ , m_bDynamicDefault(false)
+ , m_bUserDefault(false)
, m_bIsSetItem(false)
, m_bShareable(true)
#ifdef DBG_UTIL