Kaydet (Commit) d92602c5 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Stephan Bergmann

more fixes for SfxItemState

In commit 88a874fc "convert SfxItemState constants to a proper enum"
I made some mistakes in converting bitwise logic to boolean logic.

I fixed one of those places in commit 7ad83656 "fix bitwise->logic
conversion in SfxItemState commit"

This commit fixes the other places where I converted bitwise to normal
boolean logic. I also validated that none of the existing code tries to
uses combinations of these enum values.

This commit also introduces an exception-throwing check in the one place
where the enum is explicitly cast to make sure that no combinations
sneak in.

Change-Id: I545f7d17b76c4fd999078867caec314e83ffe165
Signed-off-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst d707d025
......@@ -153,7 +153,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs )
bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
m_pCbShowDescription->Check( bCheck );
if( aState != SFX_ITEM_DEFAULT && aState != SFX_ITEM_SET)
if( aState != SFX_ITEM_DEFAULT && aState != SFX_ITEM_SET )
m_pCbShowDescription->Hide();
}
......@@ -201,7 +201,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs )
bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
m_pCbTextOverlap->Check( bCheck );
if( aState != SFX_ITEM_DEFAULT )
if( aState != SFX_ITEM_DEFAULT && aState != SFX_ITEM_SET )
m_pCbTextOverlap->Hide();
}
......@@ -220,7 +220,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs )
bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
m_pCbTextBreak->Check( bCheck );
if( aState != SFX_ITEM_DEFAULT )
if( aState != SFX_ITEM_DEFAULT && aState != SFX_ITEM_SET )
{
m_pCbTextBreak->Hide();
if( ! m_pCbTextOverlap->IsVisible() )
......
......@@ -547,7 +547,13 @@ throw ( ::com::sun::star::uno::RuntimeException, std::exception )
{
ItemStatus aItemStatus;
rEvent.State >>= aItemStatus;
eState = (SfxItemState) aItemStatus.State;
SfxItemState tmpState = (SfxItemState) aItemStatus.State;
// make sure no-one tries to send us a combination of states
if (eState != SfxItemState::UNKNOWN && eState != SFX_ITEM_DISABLED &&
eState != SFX_ITEM_READONLY && eState != SFX_ITEM_DONTCARE &&
eState != SFX_ITEM_DEFAULT && eState != SFX_ITEM_SET)
throw ::com::sun::star::uno::RuntimeException("unknown status");
eState = tmpState;
pItem = new SfxVoidItem( nSlotId );
}
else if ( pType == cppu::UnoType< ::com::sun::star::frame::status::Visibility>::get() )
......@@ -1095,7 +1101,13 @@ throw ( ::com::sun::star::uno::RuntimeException, std::exception )
{
ItemStatus aItemStatus;
rEvent.State >>= aItemStatus;
eState = (SfxItemState) aItemStatus.State;
SfxItemState tmpState = (SfxItemState) aItemStatus.State;
// make sure no-one tries to send us a combination of states
if (eState != SfxItemState::UNKNOWN && eState != SFX_ITEM_DISABLED &&
eState != SFX_ITEM_READONLY && eState != SFX_ITEM_DONTCARE &&
eState != SFX_ITEM_DEFAULT && eState != SFX_ITEM_SET)
throw ::com::sun::star::uno::RuntimeException("unknown status");
eState = tmpState;
pItem = new SfxVoidItem( nSlotId );
}
else if ( pType == cppu::UnoType< ::com::sun::star::frame::status::Visibility>::get() )
......
......@@ -96,7 +96,7 @@ void FormatPaintBrushToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
void FormatPaintBrushToolBoxControl::StateChanged( sal_uInt16 nSID, SfxItemState eState,
const SfxPoolItem* pState )
{
if( eState != SFX_ITEM_SET )
if( eState != SFX_ITEM_DEFAULT && eState != SFX_ITEM_SET )
m_bPersistentCopy = false;
SfxToolBoxControl::StateChanged( nSID, eState, pState );
}
......
......@@ -4024,8 +4024,8 @@ static void lcl_PushNumruleState( SfxItemState &aNumRuleState, SwNumRuleItem &aN
}
}
static void lcl_PopNumruleState( int aNumRuleState, const SwNumRuleItem &aNumRuleItem,
int aListIdState, const SfxStringItem &aListIdItem,
static void lcl_PopNumruleState( SfxItemState aNumRuleState, const SwNumRuleItem &aNumRuleItem,
SfxItemState aListIdState, const SfxStringItem &aListIdItem,
SwTxtNode *pDestTxtNd, const SwPaM& rPam )
{
/* If only a part of one paragraph is copied
......
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