From ea733ab5b632109d28bb8f1dc37116340b26229b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 10 Sep 2014 17:53:41 +0200 Subject: Turn SfxItemState into a C++11 scoped enumeration ...to gain further confidence in the claim "that none of the existing code tries to uses combinations of these enum values" (d92602c5b13d0a60439d86c5a033d124178726ca "more fixes for SfxItemState") Change-Id: I987922d945e8738e38adfde83b869adf3ff35b13 Reviewed-on: https://gerrit.libreoffice.org/11384 Reviewed-by: Stephan Bergmann Tested-by: Stephan Bergmann --- svl/source/items/itemprop.cxx | 16 +++++++-------- svl/source/items/itemset.cxx | 48 +++++++++++++++++++++---------------------- 2 files changed, 32 insertions(+), 32 deletions(-) (limited to 'svl') diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx index 9b1de9e2289d..53f948455687 100644 --- a/svl/source/items/itemprop.cxx +++ b/svl/source/items/itemprop.cxx @@ -185,10 +185,10 @@ void SfxItemPropertySet::getPropertyValue( const SfxItemPropertySimpleEntry& rEn // get the SfxPoolItem const SfxPoolItem* pItem = 0; SfxItemState eState = rSet.GetItemState( rEntry.nWID, true, &pItem ); - if(SFX_ITEM_SET != eState && SFX_WHICH_MAX > rEntry.nWID ) + if(SfxItemState::SET != eState && SFX_WHICH_MAX > rEntry.nWID ) pItem = &rSet.GetPool()->GetDefaultItem(rEntry.nWID); // return item values as uno::Any - if(eState >= SFX_ITEM_DEFAULT && pItem) + if(eState >= SfxItemState::DEFAULT && pItem) { pItem->QueryValue( rAny, rEntry.nMemberId ); } @@ -245,10 +245,10 @@ void SfxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry& rEn const SfxPoolItem* pItem = 0; boost::scoped_ptr pNewItem; SfxItemState eState = rSet.GetItemState( rEntry.nWID, true, &pItem ); - if(SFX_ITEM_SET != eState && SFX_WHICH_MAX > rEntry.nWID ) + if(SfxItemState::SET != eState && SFX_WHICH_MAX > rEntry.nWID ) pItem = &rSet.GetPool()->GetDefaultItem(rEntry.nWID); //maybe there's another way to find an Item - if(eState < SFX_ITEM_DEFAULT) + if(eState < SfxItemState::DEFAULT) { SfxItemSet aSet(*rSet.GetPool(), rEntry.nWID, rEntry.nWID); if(FillItem(aSet, rEntry.nWID, false)) @@ -296,9 +296,9 @@ PropertyState SfxItemPropertySet::getPropertyState(const SfxItemPropertySimpleEn // Get item state SfxItemState eState = rSet.GetItemState( nWhich, false ); // Return item value as UnoAny - if(eState == SFX_ITEM_DEFAULT) + if(eState == SfxItemState::DEFAULT) eRet = PropertyState_DEFAULT_VALUE; - else if(eState < SFX_ITEM_DEFAULT) + else if(eState < SfxItemState::DEFAULT) eRet = PropertyState_AMBIGUOUS_VALUE; return eRet; } @@ -319,9 +319,9 @@ PropertyState SfxItemPropertySet::getPropertyState(const OUString& rName, cons // Get item state SfxItemState eState = rSet.GetItemState(nWhich, false); // Return item value as UnoAny - if(eState == SFX_ITEM_DEFAULT) + if(eState == SfxItemState::DEFAULT) eRet = PropertyState_DEFAULT_VALUE; - else if(eState < SFX_ITEM_DEFAULT) + else if(eState < SfxItemState::DEFAULT) eRet = PropertyState_AMBIGUOUS_VALUE; return eRet; } diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 295c3f798d93..249082ce00a7 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -452,7 +452,7 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich, { // Find the range in which the Which is located const SfxItemSet* pAktSet = this; - SfxItemState eRet = SFX_ITEM_UNKNOWN; + SfxItemState eRet = SfxItemState::UNKNOWN; do { SfxItemArray ppFnd = pAktSet->_aItems; @@ -467,7 +467,7 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich, ppFnd += nWhich - *pPtr; if ( !*ppFnd ) { - eRet = SFX_ITEM_DEFAULT; + eRet = SfxItemState::DEFAULT; if( !bSrchInParent ) return eRet; // Not present break; // Keep searching in the parents! @@ -475,16 +475,16 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich, if ( (SfxPoolItem*) -1 == *ppFnd ) // Different ones are present - return SFX_ITEM_DONTCARE; + return SfxItemState::DONTCARE; if ( (*ppFnd)->Type() == TYPE(SfxVoidItem) ) - return SFX_ITEM_DISABLED; + return SfxItemState::DISABLED; if (ppItem) { *ppItem = *ppFnd; } - return SFX_ITEM_SET; + return SfxItemState::SET; } ppFnd += *(pPtr+1) - *pPtr + 1; pPtr += 2; @@ -496,7 +496,7 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich, bool SfxItemSet::HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem) const { - bool bRet = SFX_ITEM_SET == GetItemState(nWhich, true, ppItem); + bool bRet = SfxItemState::SET == GetItemState(nWhich, true, ppItem); if (!bRet && ppItem) *ppItem = NULL; return bRet; @@ -621,9 +621,9 @@ bool SfxItemSet::Put( const SfxItemSet& rSet, bool bInvalidAsDefault ) * Default (0 pointer) and Invalid (-1 pointer) Items are processed * according to their parameter 'eDontCareAs' and 'eDefaultAs': * - * SFX_ITEM_SET: Hard set to the default of the Pool - * SFX_ITEM_DEFAULT: Deleted (0 pointer) - * SFX_ITEM_DONTCARE: Invalid (-1 pointer) + * SfxItemState::SET: Hard set to the default of the Pool + * SfxItemState::DEFAULT: Deleted (0 pointer) + * SfxItemState::DONTCARE: Invalid (-1 pointer) * * NB: All other values for 'eDontCareAs' and 'eDefaultAs' are invalid */ @@ -647,15 +647,15 @@ void SfxItemSet::PutExtended // Item ist DontCare: switch ( eDontCareAs ) { - case SFX_ITEM_SET: + case SfxItemState::SET: Put( rSet.GetPool()->GetDefaultItem(nWhich), nWhich ); break; - case SFX_ITEM_DEFAULT: + case SfxItemState::DEFAULT: ClearItem( nWhich ); break; - case SFX_ITEM_DONTCARE: + case SfxItemState::DONTCARE: InvalidateItem( nWhich ); break; @@ -672,15 +672,15 @@ void SfxItemSet::PutExtended // Item is default: switch ( eDefaultAs ) { - case SFX_ITEM_SET: + case SfxItemState::SET: Put( rSet.GetPool()->GetDefaultItem(nWhich), nWhich ); break; - case SFX_ITEM_DEFAULT: + case SfxItemState::DEFAULT: ClearItem( nWhich ); break; - case SFX_ITEM_DONTCARE: + case SfxItemState::DONTCARE: InvalidateItem( nWhich ); break; @@ -701,7 +701,7 @@ void SfxItemSet::MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo ) { // special case: exactly one sal_uInt16 which is already included? SfxItemState eItemState = GetItemState(nFrom, false); - if ( nFrom == nTo && ( eItemState == SFX_ITEM_DEFAULT || eItemState == SFX_ITEM_SET ) ) + if ( nFrom == nTo && ( eItemState == SfxItemState::DEFAULT || eItemState == SfxItemState::SET ) ) return; // merge new range @@ -745,19 +745,19 @@ void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges ) { // direct move of pointer (not via pool) SfxItemState eState = GetItemState( nWID, false, aNewItems+n ); - if ( SFX_ITEM_SET == eState ) + if ( SfxItemState::SET == eState ) { // increment new item count and possibly increment ref count ++nNewCount; aNewItems[n]->AddRef(); } - else if ( SFX_ITEM_DISABLED == eState ) + else if ( SfxItemState::DISABLED == eState ) { // put "disabled" item ++nNewCount; aNewItems[n] = new SfxVoidItem(0); } - else if ( SFX_ITEM_DONTCARE == eState ) + else if ( SfxItemState::DONTCARE == eState ) { ++nNewCount; aNewItems[n] = (SfxPoolItem*)-1; @@ -845,7 +845,7 @@ bool SfxItemSet::Set while ( nWhich ) { const SfxPoolItem* pItem; - if( SFX_ITEM_SET == rSet.GetItemState( nWhich, true, &pItem ) ) + if( SfxItemState::SET == rSet.GetItemState( nWhich, true, &pItem ) ) bRet |= 0 != Put( *pItem, pItem->Which() ); nWhich = aIter.NextWhich(); } @@ -879,7 +879,7 @@ const SfxPoolItem* SfxItemSet::GetItem // Is the Item set or 'bDeep == true' available? const SfxPoolItem *pItem = 0; SfxItemState eState = GetItemState( nWhich, bSrchInParent, &pItem ); - if ( bSrchInParent && SFX_ITEM_DEFAULT == eState && + if ( bSrchInParent && SfxItemState::DEFAULT == eState && nWhich <= SFX_WHICH_MAX ) pItem = &_pPool->GetDefaultItem(nWhich); @@ -1042,7 +1042,7 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet ) sal_uInt16 nWhich = IsInvalidItem( pItem ) ? GetWhichByPos( aIter.GetCurPos() ) : pItem->Which(); - if( SFX_ITEM_UNKNOWN == rSet.GetItemState( nWhich, false ) ) + if( SfxItemState::UNKNOWN == rSet.GetItemState( nWhich, false ) ) ClearItem( nWhich ); // Delete if( aIter.IsAtEnd() ) break; @@ -1112,7 +1112,7 @@ void SfxItemSet::Differentiate( const SfxItemSet& rSet ) sal_uInt16 nWhich = IsInvalidItem( pItem ) ? GetWhichByPos( aIter.GetCurPos() ) : pItem->Which(); - if( SFX_ITEM_SET == rSet.GetItemState( nWhich, false ) ) + if( SfxItemState::SET == rSet.GetItemState( nWhich, false ) ) ClearItem( nWhich ); // Delete if( aIter.IsAtEnd() ) break; @@ -1603,7 +1603,7 @@ SfxItemSet *SfxItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const while ( nWhich ) { const SfxPoolItem* pItem; - if ( SFX_ITEM_SET == GetItemState( nWhich, false, &pItem ) ) + if ( SfxItemState::SET == GetItemState( nWhich, false, &pItem ) ) pNewSet->Put( *pItem, pItem->Which() ); nWhich = aIter.NextWhich(); } -- cgit