summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2016-09-22 16:02:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-09-22 19:05:09 +0000
commita49748caf2bc3d236862eef5d26383212d35e648 (patch)
tree8f6b2ae02ccc0ee8a72dae8a652493f8e087cadd /svl
parent450a2fd5e2dafd1a0c08e73ef85db978f6b1a927 (diff)
convert SfxItemKind to scoped enum
reduced size because it is stored in widely used SfxPoolItem. converted 'if' chains to 'switch case' Change-Id: Id9b5e375b681c88e8c91c561abd1a50610aa4815 Reviewed-on: https://gerrit.libreoffice.org/29186 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/itempool.cxx12
-rw-r--r--svl/source/items/poolio.cxx50
-rw-r--r--svl/source/items/poolitem.cxx4
3 files changed, 37 insertions, 29 deletions
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 330d2f77b113..6f4a6f210ad7 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -228,7 +228,7 @@ SfxItemPool::SfxItemPool
for ( sal_uInt16 n = 0; n <= pImpl->mnEnd - pImpl->mnStart; ++n )
{
(*( ppDefaults + n )) = (*( rPool.pImpl->ppStaticDefaults + n ))->Clone(this);
- (*( ppDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
+ (*( ppDefaults + n ))->SetKind(SfxItemKind::StaticDefault);
}
SetDefaults( ppDefaults );
@@ -241,7 +241,7 @@ SfxItemPool::SfxItemPool
if (rPool.pImpl->maPoolDefaults[n])
{
pImpl->maPoolDefaults[n] = rPool.pImpl->maPoolDefaults[n]->Clone(this); //resets kind
- pImpl->maPoolDefaults[n]->SetKind(SFX_ITEMS_POOLDEFAULT);
+ pImpl->maPoolDefaults[n]->SetKind(SfxItemKind::PoolDefault);
}
// Copy Version map
@@ -263,7 +263,7 @@ void SfxItemPool::SetDefaults( SfxPoolItem **pDefaults )
DBG_ASSERT( !pImpl->ppStaticDefaults, "already have Defaults" );
pImpl->ppStaticDefaults = pDefaults;
- //! if ( (*ppStaticDefaults)->GetKind() != SFX_ITEMS_STATICDEFAULT )
+ //! if ((*ppStaticDefaults)->GetKind() != SfxItemKind::StaticDefault)
//! FIXME: Probably doesn't work with SetItems at the end
{
DBG_ASSERT( (*pImpl->ppStaticDefaults)->GetRefCount() == 0 ||
@@ -273,7 +273,7 @@ void SfxItemPool::SetDefaults( SfxPoolItem **pDefaults )
{
assert(((*(pImpl->ppStaticDefaults + n))->Which() == n + pImpl->mnStart)
&& "static defaults not sorted" );
- (*( pImpl->ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
+ (*( pImpl->ppStaticDefaults + n ))->SetKind(SfxItemKind::StaticDefault);
DBG_ASSERT( !(pImpl->maPoolItems[n]), "defaults with setitems with items?!" );
}
}
@@ -568,7 +568,7 @@ void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
auto& rOldDefault =
pImpl->maPoolDefaults[GetIndex_Impl(rItem.Which())];
SfxPoolItem *pNewDefault = rItem.Clone(this);
- pNewDefault->SetKind(SFX_ITEMS_POOLDEFAULT);
+ pNewDefault->SetKind(SfxItemKind::PoolDefault);
if (rOldDefault)
{
rOldDefault->SetRefCount(0);
@@ -627,7 +627,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
if (bSID)
{
assert((rItem.Which() != nWhich ||
- !IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE)
+ !IsDefaultItem(&rItem) || rItem.GetKind() == SfxItemKind::DeleteOnIdle)
&& "a non Pool Item is Default?!");
SfxPoolItem *pPoolItem = rItem.Clone(pImpl->mpMaster);
pPoolItem->SetWhich(nWhich);
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index 0fa426399d4e..ec236900a532 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -41,32 +41,40 @@ const SfxItemPool* SfxItemPool::GetStoringPool()
return pStoringPool_;
}
-static sal_uInt16 convertSfxItemKindToUInt16(SfxItemKind x)
+static sal_uInt16 convertSfxItemKindToUInt16(SfxItemKind eKind)
{
- if ( x == SFX_ITEMS_NONE )
+ switch (eKind)
+ {
+ case SfxItemKind::NONE:
return 0;
- if ( x == SFX_ITEMS_DELETEONIDLE )
+ case SfxItemKind::DeleteOnIdle:
return 0xfffd;
- if ( x == SFX_ITEMS_STATICDEFAULT )
+ case SfxItemKind::StaticDefault:
return 0xfffe;
- if ( x == SFX_ITEMS_POOLDEFAULT )
+ case SfxItemKind::PoolDefault:
return 0xffff;
- assert(false);
- abort();
+ default:
+ assert("unknown SfxItemKind");
+ return 0;
+ }
}
-static SfxItemKind convertUInt16ToSfxItemKind(sal_uInt16 x)
+static SfxItemKind convertUInt16ToSfxItemKind(sal_uInt16 nRefCnt)
{
- if ( x == 0 )
- return SFX_ITEMS_NONE;
- if ( x == 0xfffd )
- return SFX_ITEMS_DELETEONIDLE;
- if ( x == 0xfffe )
- return SFX_ITEMS_STATICDEFAULT;
- if ( x == 0xffff )
- return SFX_ITEMS_POOLDEFAULT;
- assert(false);
- abort();
+ switch (nRefCnt)
+ {
+ case 0:
+ return SfxItemKind::NONE;
+ case 0xfffd:
+ return SfxItemKind::DeleteOnIdle;
+ case 0xfffe:
+ return SfxItemKind::StaticDefault;
+ case 0xffff:
+ return SfxItemKind::PoolDefault;
+ default:
+ assert(false);
+ abort();
+ }
}
@@ -688,7 +696,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
SfxPoolItem *pItem =
( *( pImpl->ppStaticDefaults + GetIndex_Impl(nWhich) ) )
->Create( rStream, nVersion );
- pItem->SetKind( SFX_ITEMS_POOLDEFAULT );
+ pItem->SetKind( SfxItemKind::PoolDefault );
pImpl->maPoolDefaults[GetIndex_Impl(nWhich)] = pItem;
}
}
@@ -851,8 +859,8 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate
* Saves a surrogate for '*pItem' in 'rStream'
*
* @returns sal_True: a real surrogates has been saved
- * SFX_ITEMS_NULL for 'pItem==0', SFX_ITEMS_STATICDEFAULT
- * and SFX_ITEMS_POOLDEFAULT are 'real' surrogates
+ * SFX_ITEMS_NULL for 'pItem==0', SfxItemKind::StaticDefault
+ * and SfxItemKind::PoolDefault are 'real' surrogates
*
* @returns sal_False: a dummy surrogate (SFX_ITEMS_DIRECT) has been saved;
* the actual Item needs to be saved right after it on
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index f11a2904672a..d6bfea432055 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -38,7 +38,7 @@ const char* pw5 = "Wow! 10.000.000 items!";
SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
: m_nRefCount(0)
, m_nWhich(nWhich)
- , m_nKind(SFX_ITEMS_NONE)
+ , m_nKind(SfxItemKind::NONE)
{
DBG_ASSERT(nWhich <= SHRT_MAX, "invalid WhichId");
#if OSL_DEBUG_LEVEL > 0
@@ -75,7 +75,7 @@ SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
SfxPoolItem::SfxPoolItem( const SfxPoolItem& rCpy )
: m_nRefCount(0) // don't copy that
, m_nWhich(rCpy.m_nWhich)
- , m_nKind( SFX_ITEMS_NONE )
+ , m_nKind(SfxItemKind::NONE)
{
#if OSL_DEBUG_LEVEL > 0
++nItemCount;