Kaydet (Commit) 70dee11c authored tarafından Jochen Nitschke's avatar Jochen Nitschke

use a define for invalid SfxPoolItem

and use helper function IsInvalidItem() more

Change-Id: Ifd651a336a7bd4ef4f945219d765afb827465438
Reviewed-on: https://gerrit.libreoffice.org/33611Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: 's avatarJochen Nitschke <j.nitschke+logerrit@ok.de>
Tested-by: 's avatarJochen Nitschke <j.nitschke+logerrit@ok.de>
üst ac33904d
......@@ -196,7 +196,7 @@ void SvxSearchAttributeDialog::dispose()
IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, Button*, void)
{
SearchAttrItem aInvalidItem;
aInvalidItem.pItem = reinterpret_cast<SfxPoolItem*>(-1);
aInvalidItem.pItem = INVALID_POOL_ITEM;
for ( sal_uLong i = 0; i < m_pAttrLB->GetEntryCount(); ++i )
{
......@@ -213,7 +213,7 @@ IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, Button*, void)
{
if( !IsInvalidItem( rItem.pItem ) )
delete rItem.pItem;
rItem.pItem = reinterpret_cast<SfxPoolItem*>(-1);
rItem.pItem = INVALID_POOL_ITEM;
}
else if( IsInvalidItem( rItem.pItem ) )
rItem.pItem = nullptr;
......
......@@ -108,6 +108,8 @@ enum class SfxItemState {
SET = 0x0030
};
#define INVALID_POOL_ITEM reinterpret_cast<SfxPoolItem*>(-1)
class SvXMLUnitConverter;
class SfxItemPool;
class SfxItemSet;
......@@ -227,7 +229,7 @@ inline bool IsPooledItem( const SfxPoolItem *pItem )
inline bool IsInvalidItem(const SfxPoolItem *pItem)
{
return pItem == reinterpret_cast<SfxPoolItem *>(-1);
return pItem == INVALID_POOL_ITEM;
}
class SVL_DLLPUBLIC SfxVoidItem final: public SfxPoolItem
......
......@@ -1357,7 +1357,7 @@ void SfxBindings::UpdateControllers_Impl
if ( SfxItemState::DONTCARE == eState )
{
// ambiguous
pCache->SetState( SfxItemState::DONTCARE, reinterpret_cast<SfxPoolItem *>(-1) );
pCache->SetState( SfxItemState::DONTCARE, INVALID_POOL_ITEM );
}
else if ( SfxItemState::DEFAULT == eState &&
SfxItemPool::IsSlot(rFound.nWhichId) )
......@@ -1427,7 +1427,7 @@ void SfxBindings::UpdateControllers_Impl
else
{
// ambiguous
pEnumCache->SetState( SfxItemState::DONTCARE, reinterpret_cast<SfxPoolItem *>(-1) );
pEnumCache->SetState( SfxItemState::DONTCARE, INVALID_POOL_ITEM );
}
}
......
......@@ -436,7 +436,7 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich,
break; // Keep searching in the parents!
}
if ( reinterpret_cast<SfxPoolItem*>(-1) == *ppFnd )
if ( IsInvalidItem(*ppFnd) )
// Different ones are present
return SfxItemState::DONTCARE;
......@@ -779,7 +779,7 @@ void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges )
else if ( SfxItemState::DONTCARE == eState )
{
++nNewCount;
aNewItems[n] = reinterpret_cast<SfxPoolItem*>(-1);
aNewItems[n] = INVALID_POOL_ITEM;
}
else
{
......@@ -908,7 +908,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const
ppFnd += nWhich - *pPtr;
if( *ppFnd )
{
if( reinterpret_cast<SfxPoolItem*>(-1) == *ppFnd ) {
if( IsInvalidItem(*ppFnd) ) {
//FIXME: The following code is duplicated further down
SAL_WARN_IF(!m_pPool, "svl.items", "no Pool, but status is ambiguous, with ID/pos " << nWhich);
//!((SfxAllItemSet *)this)->aDefault.SetWhich(nWhich);
......@@ -1192,12 +1192,12 @@ static void MergeItem_Impl( SfxItemPool *_pPool, sal_uInt16 &rCount,
{
if ( IsInvalidItem(pFnd2) )
// Decision table: default, dontcare, doesn't matter, doesn't matter
*ppFnd1 = reinterpret_cast<SfxPoolItem*>(-1);
*ppFnd1 = INVALID_POOL_ITEM;
else if ( pFnd2 && !bIgnoreDefaults &&
_pPool->GetDefaultItem(pFnd2->Which()) != *pFnd2 )
// Decision table: default, set, !=, sal_False
*ppFnd1 = reinterpret_cast<SfxPoolItem*>(-1);
*ppFnd1 = INVALID_POOL_ITEM;
else if ( pFnd2 && bIgnoreDefaults )
// Decision table: default, set, doesn't matter, sal_True
......@@ -1218,7 +1218,7 @@ static void MergeItem_Impl( SfxItemPool *_pPool, sal_uInt16 &rCount,
{
// Decision table: set, default, !=, sal_False
_pPool->Remove( **ppFnd1 );
*ppFnd1 = reinterpret_cast<SfxPoolItem*>(-1);
*ppFnd1 = INVALID_POOL_ITEM;
}
}
else if ( IsInvalidItem(pFnd2) )
......@@ -1230,7 +1230,7 @@ static void MergeItem_Impl( SfxItemPool *_pPool, sal_uInt16 &rCount,
// Decision table: set, dontcare, doesn't matter, sal_False
// or: set, dontcare, !=, sal_True
_pPool->Remove( **ppFnd1 );
*ppFnd1 = reinterpret_cast<SfxPoolItem*>(-1);
*ppFnd1 = INVALID_POOL_ITEM;
}
}
else
......@@ -1240,7 +1240,7 @@ static void MergeItem_Impl( SfxItemPool *_pPool, sal_uInt16 &rCount,
{
// Decision table: set, set, !=, doesn't matter
_pPool->Remove( **ppFnd1 );
*ppFnd1 = reinterpret_cast<SfxPoolItem*>(-1);
*ppFnd1 = INVALID_POOL_ITEM;
}
}
}
......@@ -1330,15 +1330,15 @@ void SfxItemSet::InvalidateItem( sal_uInt16 nWhich )
if( *ppFnd ) // Set for me
{
if( reinterpret_cast<SfxPoolItem*>(-1) != *ppFnd ) // Not yet dontcare!
if( !IsInvalidItem(*ppFnd) )
{
m_pPool->Remove( **ppFnd );
*ppFnd = reinterpret_cast<SfxPoolItem*>(-1);
*ppFnd = INVALID_POOL_ITEM;
}
}
else
{
*ppFnd = reinterpret_cast<SfxPoolItem*>(-1);
*ppFnd = INVALID_POOL_ITEM;
++m_nCount;
}
break;
......@@ -1825,7 +1825,7 @@ const SfxPoolItem* SfxAllItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhi
// Remember old Item
bool bIncrementCount = false;
const SfxPoolItem* pOld = *( m_pItems + nPos );
if ( reinterpret_cast< SfxPoolItem* >( -1 ) == pOld ) // state "dontcare"
if ( IsInvalidItem(pOld) ) // state "dontcare"
pOld = nullptr;
if ( !pOld )
{
......
......@@ -1908,7 +1908,7 @@ bool SwTextNode::SetAttr(
do
{
if ( pItem && (reinterpret_cast<SfxPoolItem*>(-1) != pItem))
if ( pItem && !IsInvalidItem(pItem) )
{
const sal_uInt16 nWhich = pItem->Which();
OSL_ENSURE( isCHRATR(nWhich) || isTXTATR(nWhich),
......@@ -2201,7 +2201,7 @@ bool SwTextNode::GetAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
if( nAttrStart > nStt )
{
rSet.InvalidateItem( nHintWhich );
pPrev->mpItem = reinterpret_cast<SfxPoolItem*>(-1);
pPrev->mpItem = INVALID_POOL_ITEM;
}
else
{
......@@ -2210,7 +2210,7 @@ bool SwTextNode::GetAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
}
}
}
else if( reinterpret_cast<SfxPoolItem*>(-1) != pPrev->mpItem )
else if( !IsInvalidItem(pPrev->mpItem) )
{
if( pPrev->mnEndPos == nAttrStart &&
*pPrev->mpItem == *pItem )
......@@ -2221,7 +2221,7 @@ bool SwTextNode::GetAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
else
{
rSet.InvalidateItem( nHintWhich );
pPrev->mpItem = reinterpret_cast<SfxPoolItem*>(-1);
pPrev->mpItem = INVALID_POOL_ITEM;
}
}
}
......@@ -2237,7 +2237,7 @@ bool SwTextNode::GetAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
for (size_t n = 0; n < coArrSz; ++n)
{
const SwPoolItemEndPair& rItemPair = (*pAttrArr)[ n ];
if( (nullptr != rItemPair.mpItem) && (reinterpret_cast<SfxPoolItem*>(-1) != rItemPair.mpItem) )
if( rItemPair.mpItem && !IsInvalidItem(rItemPair.mpItem) )
{
const sal_uInt16 nWh =
static_cast<sal_uInt16>(n + RES_CHRATR_BEGIN);
......
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