diff options
author | Noel Grandin <noel@peralex.com> | 2014-09-10 14:20:18 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-09-10 17:54:35 +0200 |
commit | d92602c5b13d0a60439d86c5a033d124178726ca (patch) | |
tree | b8f352df0a81b4eb2371eff4e87aac21dadbaca3 /sfx2/source/toolbox | |
parent | d707d025b6c3773538abd2eedc6dc4c6d869aa86 (diff) |
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: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sfx2/source/toolbox')
-rw-r--r-- | sfx2/source/toolbox/tbxitem.cxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index 47348ec1e989..22a36a73c2ae 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -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() ) |