summaryrefslogtreecommitdiff
path: root/svl/source/items
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-07-22 13:09:24 +0200
committerNoel Grandin <noel@peralex.com>2014-07-23 13:26:18 +0200
commit8497efb425d901257464a03e7c5faa3f1bbea9fe (patch)
tree5cc2e57b1a15e55a11fc933e33b96d81547fd91a /svl/source/items
parentb78d881520f2eb658180e2c90ffee3d30a80f0ae (diff)
convert SfxPoolItem kind constants to an enum
Change-Id: I57de8c0cebfd60fdf70c23c72ecf1e47c69d7ecd
Diffstat (limited to 'svl/source/items')
-rw-r--r--svl/source/items/poolio.cxx35
-rw-r--r--svl/source/items/poolitem.cxx4
2 files changed, 34 insertions, 5 deletions
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index bbc73f56055f..4a3c67d26a99 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -42,6 +42,34 @@ const SfxItemPool* SfxItemPool::GetStoringPool()
return pStoringPool_;
}
+static sal_uInt16 convertSfxItemKindToUInt16(SfxItemKind x)
+{
+ if ( x == SFX_ITEMS_NONE )
+ return 0;
+ if ( x == SFX_ITEMS_DELETEONIDLE )
+ return 0xfffd;
+ if ( x == SFX_ITEMS_STATICDEFAULT )
+ return 0xfffe;
+ if ( x == SFX_ITEMS_POOLDEFAULT )
+ return 0xffff;
+ assert(false);
+}
+
+static SfxItemKind convertUInt16ToSfxItemKind(sal_uInt16 x)
+{
+ 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);
+}
+
+
+
/**
* The SfxItemPool is saved to the specified Stream (together with all its
* secondary Pools) using its Pool Defaults and pooled Items.
@@ -191,7 +219,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
aItemsRec.NewContent((sal_uInt16)j, 'X' );
if ( pItem->GetRefCount() == SFX_ITEMS_SPECIAL )
- rStream.WriteUInt16( (sal_uInt16) pItem->GetKind() );
+ rStream.WriteUInt16( convertSfxItemKindToUInt16(pItem->GetKind()) );
else
{
rStream.WriteUInt16( (sal_uInt16) pItem->GetRefCount() );
@@ -371,7 +399,7 @@ void SfxItemPool_Impl::readTheItems (
else
{
if ( nRef > SFX_ITEMS_OLD_MAXREF )
- SfxItemPool::SetKind(*pItem, nRef);
+ SfxItemPool::SetKind(*pItem, convertUInt16ToSfxItemKind(nRef));
else
SfxItemPool::AddRef(*pItem, nRef);
}
@@ -692,6 +720,7 @@ sal_uInt16 SfxItemPool::GetSize_Impl() const
return pImp->mnEnd - pImp->mnStart + 1;
}
+
SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
{
// For the Master the Header has already been loaded in Load()
@@ -843,7 +872,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
else
{
if ( nRef > SFX_ITEMS_OLD_MAXREF )
- pItem->SetKind( nRef );
+ pItem->SetKind( convertUInt16ToSfxItemKind(nRef) );
else
AddRef(*pItem, nRef);
}
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index 38c74375565c..ef327d69b2ff 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -44,7 +44,7 @@ IMPL_PTRHINT(SfxPoolItemHint,SfxPoolItem)
SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
: m_nRefCount(0)
, m_nWhich(nWhich)
- , m_nKind(0)
+ , m_nKind(SFX_ITEMS_NONE)
{
DBG_ASSERT(nWhich <= SHRT_MAX, "invalid WhichId");
#if OSL_DEBUG_LEVEL > 1
@@ -81,7 +81,7 @@ SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
SfxPoolItem::SfxPoolItem( const SfxPoolItem& rCpy )
: m_nRefCount(0) // don't copy that
, m_nWhich(rCpy.Which()) // call function because of ChkThis() (WTF does that mean?)
- , m_nKind( 0 )
+ , m_nKind( SFX_ITEMS_NONE )
{
#if OSL_DEBUG_LEVEL > 1
++nItemCount;