svl: change SfxPoolItem ref-count to sal_uInt32

Fixes the inconsistency between potentially 64-bit sal_uLong and
the max-value macros that are ~2^32.

Change-Id: I895c674819cf4766cb2c7441f670bc1305362a74
This commit is contained in:
Michael Stahl
2016-10-28 21:45:06 +02:00
parent 0117a5d34e
commit 85c38f1cf4
3 changed files with 23 additions and 23 deletions

View File

@@ -79,9 +79,9 @@ public:
const sal_uInt16* GetFrozenIdRanges() const;
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 SetRefCount(SfxPoolItem& rItem, sal_uInt32 n);
static inline void AddRef(const SfxPoolItem& rItem, sal_uInt32 n = 1);
static inline sal_uInt32 ReleaseRef(const SfxPoolItem& rItem, sal_uInt32 n = 1);
static inline void SetKind( SfxPoolItem& rItem, SfxItemKind nRef );
public:
@@ -216,19 +216,19 @@ private:
};
// only the pool may manipulate the reference counts
inline void SfxItemPool::SetRefCount( SfxPoolItem& rItem, sal_uLong n )
inline void SfxItemPool::SetRefCount(SfxPoolItem& rItem, sal_uInt32 n)
{
rItem.SetRefCount(n);
}
// only the pool may manipulate the reference counts
inline void SfxItemPool::AddRef( const SfxPoolItem& rItem, sal_uLong n )
inline void SfxItemPool::AddRef(const SfxPoolItem& rItem, sal_uInt32 n)
{
rItem.AddRef(n);
}
// only the pool may manipulate the reference counts
inline sal_uLong SfxItemPool::ReleaseRef( const SfxPoolItem& rItem, sal_uLong n )
inline sal_uInt32 SfxItemPool::ReleaseRef(const SfxPoolItem& rItem, sal_uInt32 n)
{
return rItem.ReleaseRef(n);
}

View File

@@ -120,17 +120,17 @@ friend class SfxItemPoolCache;
friend class SfxItemSet;
friend class SfxVoidItem;
mutable sal_uLong m_nRefCount;
mutable sal_uInt32 m_nRefCount;
sal_uInt16 m_nWhich;
SfxItemKind m_nKind;
private:
inline void SetRefCount( sal_uLong n );
inline void SetRefCount(sal_uInt32 n);
inline void SetKind( SfxItemKind n );
public:
inline void AddRef( sal_uLong n = 1 ) const;
inline void AddRef(sal_uInt32 n = 1) const;
private:
inline sal_uLong ReleaseRef( sal_uLong n = 1 ) const;
inline sal_uInt32 ReleaseRef(sal_uInt32 n = 1) const;
protected:
explicit SfxPoolItem( sal_uInt16 nWhich = 0 );
@@ -170,7 +170,7 @@ public:
// clone and call SetWhich
SfxPoolItem* CloneSetWhich( sal_uInt16 nNewWhich ) const;
sal_uLong GetRefCount() const { return m_nRefCount; }
sal_uInt32 GetRefCount() const { return m_nRefCount; }
inline SfxItemKind GetKind() const { return m_nKind; }
virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
@@ -178,7 +178,7 @@ private:
SfxPoolItem& operator=( const SfxPoolItem& ) = delete;
};
inline void SfxPoolItem::SetRefCount( sal_uLong n )
inline void SfxPoolItem::SetRefCount(sal_uInt32 n)
{
m_nRefCount = n;
m_nKind = SfxItemKind::NONE;
@@ -190,14 +190,14 @@ inline void SfxPoolItem::SetKind( SfxItemKind n )
m_nKind = n;
}
inline void SfxPoolItem::AddRef( sal_uLong n ) const
inline void SfxPoolItem::AddRef(sal_uInt32 n) const
{
assert(m_nRefCount <= SFX_ITEMS_MAXREF && "AddRef with non-Pool-Item");
assert(n <= SFX_ITEMS_MAXREF - m_nRefCount && "AddRef: refcount overflow");
m_nRefCount += n;
}
inline sal_uLong SfxPoolItem::ReleaseRef( sal_uLong n ) const
inline sal_uInt32 SfxPoolItem::ReleaseRef(sal_uInt32 n) const
{
assert(m_nRefCount <= SFX_ITEMS_MAXREF && "ReleaseRef with non-Pool-Item");
assert(n <= m_nRefCount);

View File

@@ -610,7 +610,7 @@ const SfxPoolItem& ScDocumentPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWh
// Else Put must always happen, because it could be another Pool
const SfxPoolItem& rNew = SfxItemPool::Put( rItem, nWhich );
sal_uLong nRef = rNew.GetRefCount();
sal_uInt32 nRef = rNew.GetRefCount();
if (nRef == 1)
{
++mnCurrentMaxKey;
@@ -624,13 +624,13 @@ void ScDocumentPool::Remove( const SfxPoolItem& rItem )
{
if ( rItem.Which() == ATTR_PATTERN ) // Only Pattern is special
{
sal_uLong nRef = rItem.GetRefCount();
if ( nRef >= (sal_uLong) SC_MAX_POOLREF && nRef <= (sal_uLong) SFX_ITEMS_OLD_MAXREF )
sal_uInt32 nRef = rItem.GetRefCount();
if ( nRef >= (sal_uInt32) SC_MAX_POOLREF && nRef <= (sal_uInt32) SFX_ITEMS_OLD_MAXREF )
{
if ( nRef != (sal_uLong) SC_SAFE_POOLREF )
if ( nRef != (sal_uInt32) SC_SAFE_POOLREF )
{
OSL_FAIL("Who fiddles with my ref counts?");
SetRefCount( (SfxPoolItem&)rItem, (sal_uLong) SC_SAFE_POOLREF );
SetRefCount( (SfxPoolItem&)rItem, (sal_uInt32) SC_SAFE_POOLREF );
}
return; // Do not decrement
}
@@ -640,14 +640,14 @@ void ScDocumentPool::Remove( const SfxPoolItem& rItem )
void ScDocumentPool::CheckRef( const SfxPoolItem& rItem )
{
sal_uLong nRef = rItem.GetRefCount();
if ( nRef >= (sal_uLong) SC_MAX_POOLREF && nRef <= (sal_uLong) SFX_ITEMS_OLD_MAXREF )
sal_uInt32 nRef = rItem.GetRefCount();
if ( nRef >= (sal_uInt32) SC_MAX_POOLREF && nRef <= (sal_uInt32) SFX_ITEMS_OLD_MAXREF )
{
// At the Apply of the Cache we might increase by 2 (to MAX+1 or SAFE+2)
// We only decrease by 1 (in LoadCompleted)
OSL_ENSURE( nRef<=(sal_uLong)SC_MAX_POOLREF+1 || (nRef>=(sal_uLong)SC_SAFE_POOLREF-1 && nRef<=(sal_uLong)SC_SAFE_POOLREF+2),
OSL_ENSURE( nRef<=(sal_uInt32)SC_MAX_POOLREF+1 || (nRef>=(sal_uInt32)SC_SAFE_POOLREF-1 && nRef<=(sal_uInt32)SC_SAFE_POOLREF+2),
"ScDocumentPool::CheckRef" );
SetRefCount( (SfxPoolItem&)rItem, (sal_uLong) SC_SAFE_POOLREF );
SetRefCount( (SfxPoolItem&)rItem, (sal_uInt32) SC_SAFE_POOLREF );
}
}