diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-01-27 14:50:50 +0100 |
---|---|---|
committer | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-01-27 15:58:28 +0000 |
commit | 70dee11c2e15e90fbd41bf331e67c1d28e094e35 (patch) | |
tree | 9bf3a9c17495788b9b1d7ef23da1b96799e81e6a | |
parent | ac33904d05ce40b5998b3f1b66a1454d049781be (diff) |
use a define for invalid SfxPoolItem
and use helper function IsInvalidItem() more
Change-Id: Ifd651a336a7bd4ef4f945219d765afb827465438
Reviewed-on: https://gerrit.libreoffice.org/33611
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Tested-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
-rw-r--r-- | cui/source/dialogs/srchxtra.cxx | 4 | ||||
-rw-r--r-- | include/svl/poolitem.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/control/bindings.cxx | 4 | ||||
-rw-r--r-- | svl/source/items/itemset.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 10 |
5 files changed, 24 insertions, 22 deletions
diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx index d6e0578ad0cc..23342dd3c3fc 100644 --- a/cui/source/dialogs/srchxtra.cxx +++ b/cui/source/dialogs/srchxtra.cxx @@ -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; diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index fa2fbd1bd026..54571a6a48f8 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -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 diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index f9a91c8ab582..c72f30303a3a 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -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 ); } } diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 9e44a8ba1889..a4ed73c52f33 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -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 ) { diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 53a439c698f9..66b44900fcfc 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -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); |