summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-03-09 09:47:35 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-03-09 09:46:53 +0000
commitc8a93253e43e81e5dbc89937f2a21ca75e0582bc (patch)
treec5ebf27b0f2a5ece4846bf2e0cd0a09815f105e0 /svl
parent9885a4f10f6b900a2a870e5fe691c4a465522b75 (diff)
remove unused NOT_POOLABLE enum value
and simplify the resulting SfxItemInfo field down to a single bool Change-Id: I73e24e83d39afc7660ac85872ba96bc790713cb2 Reviewed-on: https://gerrit.libreoffice.org/23058 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/README2
-rw-r--r--svl/qa/unit/items/test_itempool.cxx19
-rw-r--r--svl/source/items/itempool.cxx25
-rw-r--r--svl/source/items/itemset.cxx8
-rw-r--r--svl/source/items/poolio.cxx6
-rw-r--r--svl/source/items/stylepool.cxx4
6 files changed, 26 insertions, 38 deletions
diff --git a/svl/README b/svl/README
index 57cb60ce8d19..ce257747987b 100644
--- a/svl/README
+++ b/svl/README
@@ -19,7 +19,7 @@ A small reference counted piece of data. Many subclasses, each with a
unique integer to identify its type (WhichId). Can be compared for equality
(operator==), Clone()d, and converted to/from uno::Any (QueryValue/PutValue).
-A pool item may have value semantics (SfxItemPoolFlags::POOLABLE), meaning that
+A pool item may have value semantics ("poolable"), meaning that
there will generally be only one instance that compares equal per item pool,
or not, in which case the item will be Clone()d quite a bit.
diff --git a/svl/qa/unit/items/test_itempool.cxx b/svl/qa/unit/items/test_itempool.cxx
index 0c817ec804be..cc43694493e4 100644
--- a/svl/qa/unit/items/test_itempool.cxx
+++ b/svl/qa/unit/items/test_itempool.cxx
@@ -35,10 +35,10 @@ class PoolItemTest : public CppUnit::TestFixture
void PoolItemTest::testPool()
{
SfxItemInfo aItems[] =
- { { 0, SfxItemPoolFlags::POOLABLE },
- { 1, SfxItemPoolFlags::NONE /* not poolable */ },
- { 2, SfxItemPoolFlags::NOT_POOLABLE },
- { 3, SfxItemPoolFlags::NONE /* not poolable */}
+ { { 0, true },
+ { 1, false /* not poolable */ },
+ { 2, false },
+ { 3, false /* not poolable */}
};
SfxItemPool *pPool = new SfxItemPool("testpool", 0, 3, aItems);
@@ -80,17 +80,6 @@ void PoolItemTest::testPool()
CPPUNIT_ASSERT(&rVal2 != &rVal);
}
- // not-poolable
- SfxVoidItem aItemTwo( 2 );
- SfxVoidItem aNotherTwo( 2 );
- {
- CPPUNIT_ASSERT(pImpl->maPoolItems[2] == nullptr);
- const SfxPoolItem &rVal = pPool->Put(aItemTwo);
- // those guys just don't go in ...
- CPPUNIT_ASSERT(pImpl->maPoolItems[2] == nullptr);
- CPPUNIT_ASSERT(rVal == aItemOne);
- }
-
// Test rehash
for (size_t i = 0; i < pImpl->maPoolItems.size(); ++i)
{
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 40fd54cb9bd6..34153c729311 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -115,18 +115,18 @@ const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( sal_uInt16 nWhich ) const
}
-bool SfxItemPool::IsItemFlag_Impl( sal_uInt16 nPos, SfxItemPoolFlags nFlag ) const
+bool SfxItemPool::IsItemPoolable_Impl( sal_uInt16 nPos ) const
{
- return bool(pItemInfos[nPos]._nFlags & nFlag);
+ return pItemInfos[nPos]._bPoolable;
}
-bool SfxItemPool::IsItemFlag( sal_uInt16 nWhich, SfxItemPoolFlags nFlag ) const
+bool SfxItemPool::IsItemPoolable( sal_uInt16 nWhich ) const
{
for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pImp->mpSecondary )
{
if ( pPool->IsInRange(nWhich) )
- return pPool->IsItemFlag_Impl( pPool->GetIndex_Impl(nWhich), nFlag);
+ return pPool->IsItemPoolable_Impl( pPool->GetIndex_Impl(nWhich));
}
DBG_ASSERT( !IsWhich(nWhich), "unknown which-id" );
return false;
@@ -151,7 +151,7 @@ SfxBroadcaster& SfxItemPool::BC()
* 'pItemInfos' is a USHORT array arranged in the same way, which holds
* SlotIds and Flags. These SlotIds can be 0, if the affected Items are
* exclusively used in the Core.
- * The flags allow for e.g. enabling value sharing (SfxItemPoolFlags::POOLABLE).
+ * The flags allow for e.g. enabling value sharing (poolable).
*
* If the Pool is supposed to hold SfxSetItems, the ctor cannot yet contain
* static Defaults. This needs to be done afterwards, using
@@ -632,10 +632,9 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
OSL_FAIL( "unknown WhichId - cannot put item" );
}
- // SID or not poolable (new definition)?
+ // SID ?
sal_uInt16 nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich);
- if ( USHRT_MAX == nIndex ||
- IsItemFlag_Impl( nIndex, SfxItemPoolFlags::NOT_POOLABLE ) )
+ if ( USHRT_MAX == nIndex )
{
assert((USHRT_MAX != nIndex || rItem.Which() != nWhich ||
!IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE)
@@ -661,7 +660,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
// Is this a 'poolable' item - ie. should we re-use and return
// the same underlying item for equivalent (==) SfxPoolItems?
- if ( IsItemFlag_Impl( nIndex, SfxItemPoolFlags::POOLABLE ) )
+ if ( IsItemPoolable_Impl( nIndex ) )
{
// if is already in a pool, then it is worth checking if it is in this one.
if ( IsPooledItem(&rItem) )
@@ -721,9 +720,9 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
assert(typeid(rItem) == typeid(*pNewItem) && "SfxItemPool::Put(): unequal types, no Clone() override?");
if (dynamic_cast<const SfxSetItem*>(&rItem) == nullptr)
{
- assert((!IsItemFlag(nWhich, SfxItemPoolFlags::POOLABLE) || rItem == *pNewItem)
+ assert((!IsItemPoolable(nWhich) || rItem == *pNewItem)
&& "SfxItemPool::Put(): unequal items: no operator== override?");
- assert((!IsItemFlag(*pNewItem, SfxItemPoolFlags::POOLABLE) || *pNewItem == rItem)
+ assert((!IsItemPoolable(*pNewItem) || *pNewItem == rItem)
&& "SfxItemPool::Put(): unequal items: no operator== override?");
}
AddRef( *pNewItem, pImp->nInitRefCount );
@@ -782,9 +781,9 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
OSL_FAIL( "unknown WhichId - cannot remove item" );
}
- // SID or not poolable (new definition)?
+ // SID ?
sal_uInt16 nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich);
- if ( bSID || IsItemFlag_Impl( nIndex, SfxItemPoolFlags::NOT_POOLABLE ) )
+ if ( bSID )
{
assert((USHRT_MAX != nIndex || !IsDefaultItem(&rItem)) &&
"a non Pool Item is Default?!");
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 6a28a9fcd03b..2772226bf20c 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -181,7 +181,7 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet )
IsStaticDefaultItem(*ppSrc) ) // Defaults that are not to be pooled?
// Just copy the pointer
*ppDst = *ppSrc;
- else if (m_pPool->IsItemFlag( **ppSrc, SfxItemPoolFlags::POOLABLE ))
+ else if (m_pPool->IsItemPoolable( **ppSrc ))
{
// Just copy the pointer and increase RefCount
*ppDst = *ppSrc;
@@ -475,7 +475,7 @@ const SfxPoolItem* SfxItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
}
}
}
- SFX_ASSERT( !m_pPool->IsItemFlag(nWhich, SfxItemPoolFlags::POOLABLE) ||
+ SFX_ASSERT( !m_pPool->IsItemPoolable(nWhich) ||
dynamic_cast<const SfxSetItem*>( &rItem ) != nullptr || **ppFnd == rItem,
nWhich, "putted Item unequal" );
return *ppFnd;
@@ -1401,7 +1401,7 @@ bool SfxItemSet::operator==(const SfxItemSet &rCmp) const
rCmp.GetItemState( nWh, false, &pItem2 ) ||
( pItem1 != pItem2 &&
( !pItem1 || IsInvalidItem(pItem1) ||
- (m_pPool->IsItemFlag(*pItem1, SfxItemPoolFlags::POOLABLE) &&
+ (m_pPool->IsItemPoolable(*pItem1) &&
*pItem1 != *pItem2 ) ) ) )
return false;
}
@@ -1424,7 +1424,7 @@ bool SfxItemSet::operator==(const SfxItemSet &rCmp) const
if ( *ppItem1 != *ppItem2 &&
( ( !*ppItem1 || !*ppItem2 ) ||
( IsInvalidItem(*ppItem1) || IsInvalidItem(*ppItem2) ) ||
- (m_pPool->IsItemFlag(**ppItem1, SfxItemPoolFlags::POOLABLE)) ||
+ (m_pPool->IsItemPoolable(**ppItem1)) ||
**ppItem1 != **ppItem2 ) )
return false;
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index e588a6a8ce2d..9e1b969036d9 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -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 && IsItemFlag(**ppDefItem, SfxItemPoolFlags::POOLABLE) &&
+ if ( *itrArr && IsItemPoolable(**ppDefItem) &&
pImp->bInSetItem == (dynamic_cast< const SfxSetItem* >(*ppDefItem) != nullptr) )
{
// Own signature, global WhichId and ItemVersion
@@ -737,7 +737,7 @@ sal_uInt16 SfxItemPool::GetSize_Impl() const
* Loads surrogate from 'rStream' and returns the corresponding SfxPoolItem
* from the rRefPool.
* If the surrogate contained within the stream == SFX_ITEMS_DIRECT
- * (!SfxItemPoolFlags::POOLABLE), we return 0 and the Item is to be loaded directly
+ * (!poolable), we return 0 and the Item is to be loaded directly
* from the stream.
* We also return 0 for 0xfffffff0 (SFX_ITEMS_NULL) and rWhich is set to 0,
* making the Items unavailable.
@@ -869,7 +869,7 @@ bool SfxItemPool::StoreSurrogate ( SvStream& rStream, const SfxPoolItem* pItem)
{
if ( pItem )
{
- bool bRealSurrogate = IsItemFlag(*pItem, SfxItemPoolFlags::POOLABLE);
+ bool bRealSurrogate = IsItemPoolable(*pItem);
rStream.WriteUInt32( bRealSurrogate
? GetSurrogate( pItem )
: SFX_ITEMS_DIRECT );
diff --git a/svl/source/items/stylepool.cxx b/svl/source/items/stylepool.cxx
index 9eaf86cef689..9734bd152928 100644
--- a/svl/source/items/stylepool.cxx
+++ b/svl/source/items/stylepool.cxx
@@ -391,7 +391,7 @@ StylePool::SfxItemSet_Pointer_t StylePoolImpl::insertItemSet( const SfxItemSet&
}
while( pItem )
{
- if( !rSet.GetPool()->IsItemFlag(pItem->Which(), SfxItemPoolFlags::POOLABLE ) )
+ if( !rSet.GetPool()->IsItemPoolable(pItem->Which() ) )
bNonPoolable = true;
if ( !xFoundIgnorableItems.get() ||
(xFoundIgnorableItems->Put( *pItem ) == nullptr ) )
@@ -407,7 +407,7 @@ StylePool::SfxItemSet_Pointer_t StylePoolImpl::insertItemSet( const SfxItemSet&
pItem = aIgnorableItemsIter.GetCurItem();
while( pItem )
{
- if( !rSet.GetPool()->IsItemFlag(pItem->Which(), SfxItemPoolFlags::POOLABLE ) )
+ if( !rSet.GetPool()->IsItemPoolable(pItem->Which() ) )
bNonPoolable = true;
pCurNode = pCurNode->findChildNode( *pItem, true );
pItem = aIgnorableItemsIter.NextItem();