summaryrefslogtreecommitdiff
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
parentb78d881520f2eb658180e2c90ffee3d30a80f0ae (diff)
convert SfxPoolItem kind constants to an enum
Change-Id: I57de8c0cebfd60fdf70c23c72ecf1e47c69d7ecd
-rw-r--r--include/svl/itempool.hxx4
-rw-r--r--include/svl/poolitem.hxx29
-rw-r--r--svl/source/items/poolio.cxx35
-rw-r--r--svl/source/items/poolitem.cxx4
4 files changed, 52 insertions, 20 deletions
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index 3fd8450c9de8..09c1305dd142 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -89,7 +89,7 @@ protected:
static inline void SetRefCount( SfxPoolItem& rItem, sal_uLong n );
static inline void AddRef( const SfxPoolItem& rItem, sal_uLong n = 1 );
static inline sal_uLong ReleaseRef( const SfxPoolItem& rItem, sal_uLong n = 1);
- static inline void SetKind( SfxPoolItem& rItem, sal_uInt16 nRef );
+ static inline void SetKind( SfxPoolItem& rItem, SfxItemKind nRef );
public:
SfxItemPool( const SfxItemPool &rPool,
@@ -238,7 +238,7 @@ inline sal_uLong SfxItemPool::ReleaseRef( const SfxPoolItem& rItem, sal_uLong n
return rItem.ReleaseRef(n);
}
-inline void SfxItemPool::SetKind( SfxPoolItem& rItem, sal_uInt16 nRef )
+inline void SfxItemPool::SetKind( SfxPoolItem& rItem, SfxItemKind nRef )
{
rItem.SetKind( nRef );
}
diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index 698fe6ea3854..ce916507b084 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -39,13 +39,16 @@ class IntlWrapper;
namespace com { namespace sun { namespace star { namespace uno { class Any; } } } }
-static const sal_uInt32 SFX_ITEMS_DIRECT= 0xffffffff;
-static const sal_uInt32 SFX_ITEMS_NULL= 0xfffffff0; // instead StoreSurrogate
-static const sal_uInt32 SFX_ITEMS_DEFAULT= 0xfffffffe;
-
-#define SFX_ITEMS_POOLDEFAULT 0xffff
-#define SFX_ITEMS_STATICDEFAULT 0xfffe
-#define SFX_ITEMS_DELETEONIDLE 0xfffd
+static const sal_uInt32 SFX_ITEMS_DIRECT = 0xffffffff;
+static const sal_uInt32 SFX_ITEMS_NULL = 0xfffffff0; // instead StoreSurrogate
+static const sal_uInt32 SFX_ITEMS_DEFAULT = 0xfffffffe;
+
+enum SfxItemKind {
+ SFX_ITEMS_NONE,
+ SFX_ITEMS_DELETEONIDLE,
+ SFX_ITEMS_STATICDEFAULT,
+ SFX_ITEMS_POOLDEFAULT
+};
#define SFX_ITEMS_OLD_MAXREF 0xffef
#define SFX_ITEMS_MAXREF 0xfffffffe
@@ -162,11 +165,11 @@ friend class SfxVoidItem;
mutable sal_uLong m_nRefCount;
sal_uInt16 m_nWhich;
- sal_uInt16 m_nKind;
+ SfxItemKind m_nKind;
private:
inline void SetRefCount( sal_uLong n );
- inline void SetKind( sal_uInt16 n );
+ inline void SetKind( SfxItemKind n );
public:
inline void AddRef( sal_uLong n = 1 ) const;
private:
@@ -206,7 +209,7 @@ public:
virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const = 0;
sal_uLong GetRefCount() const { return m_nRefCount; }
- inline sal_uInt16 GetKind() const { return m_nKind; }
+ inline SfxItemKind GetKind() const { return m_nKind; }
/** Read in a Unicode string from a streamed byte string representation.
@@ -259,10 +262,10 @@ private:
inline void SfxPoolItem::SetRefCount( sal_uLong n )
{
m_nRefCount = n;
- m_nKind = 0;
+ m_nKind = SFX_ITEMS_NONE;
}
-inline void SfxPoolItem::SetKind( sal_uInt16 n )
+inline void SfxPoolItem::SetKind( SfxItemKind n )
{
m_nRefCount = SFX_ITEMS_SPECIAL;
m_nKind = n;
@@ -297,7 +300,7 @@ inline bool IsStaticDefaultItem(const SfxPoolItem *pItem )
inline bool IsDefaultItem( const SfxPoolItem *pItem )
{
- return pItem && pItem->GetKind() >= SFX_ITEMS_STATICDEFAULT;
+ return pItem && (pItem->GetKind() == SFX_ITEMS_STATICDEFAULT || pItem->GetKind() == SFX_ITEMS_POOLDEFAULT);
}
inline bool IsPooledItem( const SfxPoolItem *pItem )
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;