Kaydet (Commit) ca8a4a7a authored tarafından Eike Rathke's avatar Eike Rathke

Eliminate dynamic_cast<const SfxVoidItem*>, use SfxPoolItem::IsVoidItem()

Change-Id: I09dafffd64dd107e802d016494d884f32363521a
üst f300a627
...@@ -62,7 +62,7 @@ void ScZoomSliderControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState ...@@ -62,7 +62,7 @@ void ScZoomSliderControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState
ScZoomSliderWnd* pBox = static_cast<ScZoomSliderWnd*>(rTbx.GetItemWindow( nId )); ScZoomSliderWnd* pBox = static_cast<ScZoomSliderWnd*>(rTbx.GetItemWindow( nId ));
OSL_ENSURE( pBox ,"Control not found!" ); OSL_ENSURE( pBox ,"Control not found!" );
if ( SfxItemState::DEFAULT != eState || dynamic_cast<const SfxVoidItem*>( pState) != nullptr ) if ( SfxItemState::DEFAULT != eState || pState->IsVoidItem() )
{ {
SvxZoomSliderItem aZoomSliderItem( 100 ); SvxZoomSliderItem aZoomSliderItem( 100 );
pBox->Disable(); pBox->Disable();
......
...@@ -76,7 +76,7 @@ SdTemplateControl::~SdTemplateControl() ...@@ -76,7 +76,7 @@ SdTemplateControl::~SdTemplateControl()
void SdTemplateControl::StateChanged( void SdTemplateControl::StateChanged(
sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState ) sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
{ {
if( eState != SfxItemState::DEFAULT || dynamic_cast< const SfxVoidItem *>( pState ) != nullptr ) if( eState != SfxItemState::DEFAULT || pState->IsVoidItem() )
GetStatusBar().SetItemText( GetId(), OUString() ); GetStatusBar().SetItemText( GetId(), OUString() );
else if ( dynamic_cast< const SfxStringItem *>( pState ) != nullptr ) else if ( dynamic_cast< const SfxStringItem *>( pState ) != nullptr )
{ {
......
...@@ -293,7 +293,7 @@ SfxItemState SfxControllerItem::GetItemState ...@@ -293,7 +293,7 @@ SfxItemState SfxControllerItem::GetItemState
? SfxItemState::DISABLED ? SfxItemState::DISABLED
: IsInvalidItem(pState) : IsInvalidItem(pState)
? SfxItemState::DONTCARE ? SfxItemState::DONTCARE
: dynamic_cast< const SfxVoidItem *>( pState ) != nullptr && !pState->Which() : pState->IsVoidItem() && !pState->Which()
? SfxItemState::UNKNOWN ? SfxItemState::UNKNOWN
: SfxItemState::DEFAULT; : SfxItemState::DEFAULT;
} }
......
...@@ -1882,7 +1882,7 @@ bool SfxDispatcher::FillState_(const SfxSlotServer& rSvr, SfxItemSet& rState, ...@@ -1882,7 +1882,7 @@ bool SfxDispatcher::FillState_(const SfxSlotServer& rSvr, SfxItemSet& rState,
pItem; pItem;
pItem = aIter.NextItem() ) pItem = aIter.NextItem() )
{ {
if ( !IsInvalidItem(pItem) && dynamic_cast< const SfxVoidItem *>( pItem ) == nullptr ) if ( !IsInvalidItem(pItem) && !pItem->IsVoidItem() )
{ {
sal_uInt16 nSlotId = rState.GetPool()->GetSlotId(pItem->Which()); sal_uInt16 nSlotId = rState.GetPool()->GetSlotId(pItem->Which());
SAL_INFO_IF( SAL_INFO_IF(
...@@ -2084,7 +2084,7 @@ SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSID, css::uno::Any& rAny ) ...@@ -2084,7 +2084,7 @@ SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSID, css::uno::Any& rAny )
else else
{ {
css::uno::Any aState; css::uno::Any aState;
if ( dynamic_cast< const SfxVoidItem *>( pItem ) == nullptr ) if ( !pItem->IsVoidItem() )
{ {
sal_uInt16 nSubId( 0 ); sal_uInt16 nSubId( 0 );
SfxItemPool& rPool = pShell->GetPool(); SfxItemPool& rPool = pShell->GetPool();
......
...@@ -746,7 +746,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, ...@@ -746,7 +746,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
{ {
if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem)) if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem))
bSuccess = pBoolItem->GetValue(); bSuccess = pBoolItem->GetValue();
else if ( dynamic_cast< const SfxVoidItem *>( pItem ) == nullptr ) else if ( !pItem->IsVoidItem() )
bSuccess = true; // all other types are true bSuccess = true; // all other types are true
} }
// else bSuccess = false look to line 664 it is false // else bSuccess = false look to line 664 it is false
...@@ -808,7 +808,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, ...@@ -808,7 +808,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
aEvent.State = css::frame::DispatchResultState::FAILURE; aEvent.State = css::frame::DispatchResultState::FAILURE;
aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch);
if ( bSuccess && pItem && dynamic_cast< const SfxVoidItem *>( pItem ) == nullptr ) if ( bSuccess && pItem && !pItem->IsVoidItem() )
{ {
sal_uInt16 nSubId( 0 ); sal_uInt16 nSubId( 0 );
if ( eMapUnit == MapUnit::MapTwip ) if ( eMapUnit == MapUnit::MapTwip )
...@@ -924,7 +924,7 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt ...@@ -924,7 +924,7 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
if (bNotify) if (bNotify)
{ {
css::uno::Any aState; css::uno::Any aState;
if ( ( eState >= SfxItemState::DEFAULT ) && pState && !IsInvalidItem( pState ) && dynamic_cast< const SfxVoidItem *>( pState ) == nullptr ) if ( ( eState >= SfxItemState::DEFAULT ) && pState && !IsInvalidItem( pState ) && !pState->IsVoidItem() )
{ {
// Retrieve metric from pool to have correct sub ID when calling QueryValue // Retrieve metric from pool to have correct sub ID when calling QueryValue
sal_uInt16 nSubId( 0 ); sal_uInt16 nSubId( 0 );
......
...@@ -610,7 +610,7 @@ bool SfxObjectShell::PrepareClose ...@@ -610,7 +610,7 @@ bool SfxObjectShell::PrepareClose
pPoolItem = pFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, ppArgs ); pPoolItem = pFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, ppArgs );
} }
if ( !pPoolItem || dynamic_cast< const SfxVoidItem *>( pPoolItem ) != nullptr || ( dynamic_cast< const SfxBoolItem *>( pPoolItem ) != nullptr && !static_cast<const SfxBoolItem*>( pPoolItem )->GetValue() ) ) if ( !pPoolItem || pPoolItem->IsVoidItem() || ( dynamic_cast< const SfxBoolItem *>( pPoolItem ) != nullptr && !static_cast<const SfxBoolItem*>( pPoolItem )->GetValue() ) )
return false; return false;
} }
else if ( RET_CANCEL == nRet ) else if ( RET_CANCEL == nRet )
......
...@@ -410,7 +410,7 @@ void SfxStatusBarControl::StateChanged ...@@ -410,7 +410,7 @@ void SfxStatusBarControl::StateChanged
pBar->SetItemText( nSID, pStr->GetValue() ); pBar->SetItemText( nSID, pStr->GetValue() );
else else
{ {
DBG_ASSERT( eState != SfxItemState::DEFAULT || dynamic_cast< const SfxVoidItem *>( pState ) != nullptr, DBG_ASSERT( eState != SfxItemState::DEFAULT || pState->IsVoidItem(),
"wrong SfxPoolItem subclass in SfxStatusBarControl" ); "wrong SfxPoolItem subclass in SfxStatusBarControl" );
pBar->SetItemText( nSID, OUString() ); pBar->SetItemText( nSID, OUString() );
} }
......
...@@ -374,7 +374,7 @@ SfxItemState SfxToolBoxControl::GetItemState( ...@@ -374,7 +374,7 @@ SfxItemState SfxToolBoxControl::GetItemState(
? SfxItemState::DISABLED ? SfxItemState::DISABLED
: IsInvalidItem(pState) : IsInvalidItem(pState)
? SfxItemState::DONTCARE ? SfxItemState::DONTCARE
: dynamic_cast< const SfxVoidItem *>( pState ) != nullptr && !pState->Which() : pState->IsVoidItem() && !pState->Which()
? SfxItemState::UNKNOWN ? SfxItemState::UNKNOWN
: SfxItemState::DEFAULT; : SfxItemState::DEFAULT;
} }
......
...@@ -917,7 +917,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const ...@@ -917,7 +917,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const
} }
#ifdef DBG_UTIL #ifdef DBG_UTIL
const SfxPoolItem *pItem = *ppFnd; const SfxPoolItem *pItem = *ppFnd;
if ( dynamic_cast<const SfxVoidItem *>(pItem) != nullptr || !pItem->Which() ) if ( pItem->IsVoidItem() || !pItem->Which() )
SAL_INFO("svl.items", "SFX_WARNING: Getting disabled Item"); SAL_INFO("svl.items", "SFX_WARNING: Getting disabled Item");
#endif #endif
return **ppFnd; return **ppFnd;
......
...@@ -168,7 +168,7 @@ SvxZoomSliderControl::~SvxZoomSliderControl() ...@@ -168,7 +168,7 @@ SvxZoomSliderControl::~SvxZoomSliderControl()
void SvxZoomSliderControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState ) void SvxZoomSliderControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
{ {
if ( (SfxItemState::DEFAULT != eState) || dynamic_cast<const SfxVoidItem*>( pState) != nullptr ) if ( (SfxItemState::DEFAULT != eState) || pState->IsVoidItem() )
{ {
GetStatusBar().SetItemText( GetId(), "" ); GetStatusBar().SetItemText( GetId(), "" );
mxImpl->mbValuesSet = false; mxImpl->mbValuesSet = false;
......
...@@ -920,7 +920,7 @@ void SdrItemBrowserControl::SetAttributes(const SfxItemSet* pSet, const SfxItemS ...@@ -920,7 +920,7 @@ void SdrItemBrowserControl::SetAttributes(const SfxItemSet* pSet, const SfxItemS
if (eState!=SfxItemState::DISABLED) { if (eState!=SfxItemState::DISABLED) {
const SfxPoolItem& rItem=pSet->Get(nWhich); const SfxPoolItem& rItem=pSet->Get(nWhich);
sal_uInt16 nIndent=0; sal_uInt16 nIndent=0;
if (dynamic_cast<const SfxVoidItem *>(&rItem) == nullptr && dynamic_cast<const SfxSetItem *>(&rItem) == nullptr if (!rItem.IsVoidItem() && dynamic_cast<const SfxSetItem *>(&rItem) == nullptr
&& (!IsItemIneffective(nWhich,pSet,nIndent) || bDontHideIneffectiveItems)) { && (!IsItemIneffective(nWhich,pSet,nIndent) || bDontHideIneffectiveItems)) {
OUString aCommentStr; OUString aCommentStr;
......
...@@ -68,7 +68,7 @@ void SwReadOnlyPopup::Check( sal_uInt16 nMID, sal_uInt16 nSID, SfxDispatcher &rD ...@@ -68,7 +68,7 @@ void SwReadOnlyPopup::Check( sal_uInt16 nMID, sal_uInt16 nSID, SfxDispatcher &rD
xMenu->EnableItem(nMID); xMenu->EnableItem(nMID);
if (_pItem) if (_pItem)
{ {
xMenu->CheckItem(nMID, dynamic_cast< const SfxVoidItem *>( _pItem.get() ) == nullptr && xMenu->CheckItem(nMID, !_pItem->IsVoidItem() &&
dynamic_cast< const SfxBoolItem *>( _pItem.get() ) != nullptr && dynamic_cast< const SfxBoolItem *>( _pItem.get() ) != nullptr &&
static_cast<SfxBoolItem*>(_pItem.get())->GetValue()); static_cast<SfxBoolItem*>(_pItem.get())->GetValue());
//remove full screen entry when not in full screen mode //remove full screen entry when not in full screen mode
......
...@@ -74,7 +74,7 @@ SwBookmarkControl::~SwBookmarkControl() ...@@ -74,7 +74,7 @@ SwBookmarkControl::~SwBookmarkControl()
void SwBookmarkControl::StateChanged( void SwBookmarkControl::StateChanged(
sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState ) sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
{ {
if( eState != SfxItemState::DEFAULT || dynamic_cast< const SfxVoidItem *>( pState ) != nullptr ) if( eState != SfxItemState::DEFAULT || pState->IsVoidItem() )
GetStatusBar().SetItemText( GetId(), OUString() ); GetStatusBar().SetItemText( GetId(), OUString() );
else if (const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>(pState)) else if (const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>(pState))
{ {
......
...@@ -60,7 +60,7 @@ SwViewLayoutControl::~SwViewLayoutControl() ...@@ -60,7 +60,7 @@ SwViewLayoutControl::~SwViewLayoutControl()
void SwViewLayoutControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState ) void SwViewLayoutControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
{ {
if ( SfxItemState::DEFAULT != eState || dynamic_cast< const SfxVoidItem *>( pState ) != nullptr ) if ( SfxItemState::DEFAULT != eState || pState->IsVoidItem() )
GetStatusBar().SetItemText( GetId(), OUString() ); GetStatusBar().SetItemText( GetId(), OUString() );
else else
{ {
......
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