Kaydet (Commit) 8497efb4 authored tarafından Noel Grandin's avatar Noel Grandin

convert SfxPoolItem kind constants to an enum

Change-Id: I57de8c0cebfd60fdf70c23c72ecf1e47c69d7ecd
üst b78d8815
...@@ -89,7 +89,7 @@ protected: ...@@ -89,7 +89,7 @@ protected:
static inline void SetRefCount( SfxPoolItem& rItem, sal_uLong n ); static inline void SetRefCount( SfxPoolItem& rItem, sal_uLong n );
static inline void AddRef( const SfxPoolItem& rItem, sal_uLong n = 1 ); 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 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: public:
SfxItemPool( const SfxItemPool &rPool, SfxItemPool( const SfxItemPool &rPool,
...@@ -238,7 +238,7 @@ inline sal_uLong SfxItemPool::ReleaseRef( const SfxPoolItem& rItem, sal_uLong n ...@@ -238,7 +238,7 @@ inline sal_uLong SfxItemPool::ReleaseRef( const SfxPoolItem& rItem, sal_uLong n
return rItem.ReleaseRef(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 ); rItem.SetKind( nRef );
} }
......
...@@ -39,13 +39,16 @@ class IntlWrapper; ...@@ -39,13 +39,16 @@ class IntlWrapper;
namespace com { namespace sun { namespace star { namespace uno { class Any; } } } } namespace com { namespace sun { namespace star { namespace uno { class Any; } } } }
static const sal_uInt32 SFX_ITEMS_DIRECT= 0xffffffff; static const sal_uInt32 SFX_ITEMS_DIRECT = 0xffffffff;
static const sal_uInt32 SFX_ITEMS_NULL= 0xfffffff0; // instead StoreSurrogate static const sal_uInt32 SFX_ITEMS_NULL = 0xfffffff0; // instead StoreSurrogate
static const sal_uInt32 SFX_ITEMS_DEFAULT= 0xfffffffe; static const sal_uInt32 SFX_ITEMS_DEFAULT = 0xfffffffe;
#define SFX_ITEMS_POOLDEFAULT 0xffff enum SfxItemKind {
#define SFX_ITEMS_STATICDEFAULT 0xfffe SFX_ITEMS_NONE,
#define SFX_ITEMS_DELETEONIDLE 0xfffd SFX_ITEMS_DELETEONIDLE,
SFX_ITEMS_STATICDEFAULT,
SFX_ITEMS_POOLDEFAULT
};
#define SFX_ITEMS_OLD_MAXREF 0xffef #define SFX_ITEMS_OLD_MAXREF 0xffef
#define SFX_ITEMS_MAXREF 0xfffffffe #define SFX_ITEMS_MAXREF 0xfffffffe
...@@ -162,11 +165,11 @@ friend class SfxVoidItem; ...@@ -162,11 +165,11 @@ friend class SfxVoidItem;
mutable sal_uLong m_nRefCount; mutable sal_uLong m_nRefCount;
sal_uInt16 m_nWhich; sal_uInt16 m_nWhich;
sal_uInt16 m_nKind; SfxItemKind m_nKind;
private: private:
inline void SetRefCount( sal_uLong n ); inline void SetRefCount( sal_uLong n );
inline void SetKind( sal_uInt16 n ); inline void SetKind( SfxItemKind n );
public: public:
inline void AddRef( sal_uLong n = 1 ) const; inline void AddRef( sal_uLong n = 1 ) const;
private: private:
...@@ -206,7 +209,7 @@ public: ...@@ -206,7 +209,7 @@ public:
virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const = 0; virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const = 0;
sal_uLong GetRefCount() const { return m_nRefCount; } 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. /** Read in a Unicode string from a streamed byte string representation.
...@@ -259,10 +262,10 @@ private: ...@@ -259,10 +262,10 @@ private:
inline void SfxPoolItem::SetRefCount( sal_uLong n ) inline void SfxPoolItem::SetRefCount( sal_uLong n )
{ {
m_nRefCount = 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_nRefCount = SFX_ITEMS_SPECIAL;
m_nKind = n; m_nKind = n;
...@@ -297,7 +300,7 @@ inline bool IsStaticDefaultItem(const SfxPoolItem *pItem ) ...@@ -297,7 +300,7 @@ inline bool IsStaticDefaultItem(const SfxPoolItem *pItem )
inline bool IsDefaultItem( 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 ) inline bool IsPooledItem( const SfxPoolItem *pItem )
......
...@@ -42,6 +42,34 @@ const SfxItemPool* SfxItemPool::GetStoringPool() ...@@ -42,6 +42,34 @@ const SfxItemPool* SfxItemPool::GetStoringPool()
return pStoringPool_; 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 * The SfxItemPool is saved to the specified Stream (together with all its
* secondary Pools) using its Pool Defaults and pooled Items. * secondary Pools) using its Pool Defaults and pooled Items.
...@@ -191,7 +219,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const ...@@ -191,7 +219,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
aItemsRec.NewContent((sal_uInt16)j, 'X' ); aItemsRec.NewContent((sal_uInt16)j, 'X' );
if ( pItem->GetRefCount() == SFX_ITEMS_SPECIAL ) if ( pItem->GetRefCount() == SFX_ITEMS_SPECIAL )
rStream.WriteUInt16( (sal_uInt16) pItem->GetKind() ); rStream.WriteUInt16( convertSfxItemKindToUInt16(pItem->GetKind()) );
else else
{ {
rStream.WriteUInt16( (sal_uInt16) pItem->GetRefCount() ); rStream.WriteUInt16( (sal_uInt16) pItem->GetRefCount() );
...@@ -371,7 +399,7 @@ void SfxItemPool_Impl::readTheItems ( ...@@ -371,7 +399,7 @@ void SfxItemPool_Impl::readTheItems (
else else
{ {
if ( nRef > SFX_ITEMS_OLD_MAXREF ) if ( nRef > SFX_ITEMS_OLD_MAXREF )
SfxItemPool::SetKind(*pItem, nRef); SfxItemPool::SetKind(*pItem, convertUInt16ToSfxItemKind(nRef));
else else
SfxItemPool::AddRef(*pItem, nRef); SfxItemPool::AddRef(*pItem, nRef);
} }
...@@ -692,6 +720,7 @@ sal_uInt16 SfxItemPool::GetSize_Impl() const ...@@ -692,6 +720,7 @@ sal_uInt16 SfxItemPool::GetSize_Impl() const
return pImp->mnEnd - pImp->mnStart + 1; return pImp->mnEnd - pImp->mnStart + 1;
} }
SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
{ {
// For the Master the Header has already been loaded in Load() // For the Master the Header has already been loaded in Load()
...@@ -843,7 +872,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) ...@@ -843,7 +872,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
else else
{ {
if ( nRef > SFX_ITEMS_OLD_MAXREF ) if ( nRef > SFX_ITEMS_OLD_MAXREF )
pItem->SetKind( nRef ); pItem->SetKind( convertUInt16ToSfxItemKind(nRef) );
else else
AddRef(*pItem, nRef); AddRef(*pItem, nRef);
} }
......
...@@ -44,7 +44,7 @@ IMPL_PTRHINT(SfxPoolItemHint,SfxPoolItem) ...@@ -44,7 +44,7 @@ IMPL_PTRHINT(SfxPoolItemHint,SfxPoolItem)
SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich) SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
: m_nRefCount(0) : m_nRefCount(0)
, m_nWhich(nWhich) , m_nWhich(nWhich)
, m_nKind(0) , m_nKind(SFX_ITEMS_NONE)
{ {
DBG_ASSERT(nWhich <= SHRT_MAX, "invalid WhichId"); DBG_ASSERT(nWhich <= SHRT_MAX, "invalid WhichId");
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
...@@ -81,7 +81,7 @@ SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich) ...@@ -81,7 +81,7 @@ SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
SfxPoolItem::SfxPoolItem( const SfxPoolItem& rCpy ) SfxPoolItem::SfxPoolItem( const SfxPoolItem& rCpy )
: m_nRefCount(0) // don't copy that : m_nRefCount(0) // don't copy that
, m_nWhich(rCpy.Which()) // call function because of ChkThis() (WTF does that mean?) , 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 #if OSL_DEBUG_LEVEL > 1
++nItemCount; ++nItemCount;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment