summaryrefslogtreecommitdiff
path: root/svtools/source/control/toolbarmenu.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-11-22 11:26:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-11-22 11:54:12 +0100
commit1ae61b0ac4187b2938647f3ca0289a070a5dc7d2 (patch)
tree9461c0532919f4fe61f3e0e3fa8556e954244fbd /svtools/source/control/toolbarmenu.cxx
parent04bb9549e0a0ee567f3bd48a7707286c5abd631a (diff)
loplugin:flatten in svtools
almost completely automatically rewritten, only had to tweak the indentation on a couple of lines. Change-Id: Ieec92e5b602d180d7ec556e3421ce3c835c1f646 Reviewed-on: https://gerrit.libreoffice.org/45072 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools/source/control/toolbarmenu.cxx')
-rw-r--r--svtools/source/control/toolbarmenu.cxx102
1 files changed, 51 insertions, 51 deletions
diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx
index 3a77a9f80225..12a651f49fa0 100644
--- a/svtools/source/control/toolbarmenu.cxx
+++ b/svtools/source/control/toolbarmenu.cxx
@@ -351,37 +351,37 @@ void ToolbarMenu_Impl::clearAccessibleSelection()
void ToolbarMenu_Impl::notifyHighlightedEntry()
{
- if( mxAccessible.is() && mxAccessible->HasAccessibleListeners() )
- {
- ToolbarMenuEntry* pEntry = implGetEntry( mnHighlightedEntry );
- if( pEntry && pEntry->mbEnabled && (pEntry->mnEntryId != TITLE_ID) )
- {
- Any aNew;
- Any aOld( mxOldSelection );
- if( pEntry->mpControl )
- {
- sal_Int32 nChildIndex = 0;
- // todo: if other controls than ValueSet are allowed, adapt this code
- ValueSet* pValueSet = dynamic_cast< ValueSet* >( pEntry->mpControl.get() );
- if( pValueSet )
- nChildIndex = static_cast< sal_Int32 >( pValueSet->GetItemPos( pValueSet->GetSelectItemId() ) );
+ if( !(mxAccessible.is() && mxAccessible->HasAccessibleListeners()) )
+ return;
- if( (nChildIndex >= pEntry->getAccessibleChildCount()) || (nChildIndex < 0) )
- return;
+ ToolbarMenuEntry* pEntry = implGetEntry( mnHighlightedEntry );
+ if( !(pEntry && pEntry->mbEnabled && (pEntry->mnEntryId != TITLE_ID)) )
+ return;
- aNew <<= getAccessibleChild( pEntry->mpControl, nChildIndex );
- }
- else
- {
- aNew <<= pEntry->GetAccessible();
- }
+ Any aNew;
+ Any aOld( mxOldSelection );
+ if( pEntry->mpControl )
+ {
+ sal_Int32 nChildIndex = 0;
+ // todo: if other controls than ValueSet are allowed, adapt this code
+ ValueSet* pValueSet = dynamic_cast< ValueSet* >( pEntry->mpControl.get() );
+ if( pValueSet )
+ nChildIndex = static_cast< sal_Int32 >( pValueSet->GetItemPos( pValueSet->GetSelectItemId() ) );
- fireAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOld, aNew );
- fireAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOld, aNew );
- fireAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), Any( AccessibleStateType::FOCUSED ) );
- aNew >>= mxOldSelection;
- }
+ if( (nChildIndex >= pEntry->getAccessibleChildCount()) || (nChildIndex < 0) )
+ return;
+
+ aNew <<= getAccessibleChild( pEntry->mpControl, nChildIndex );
+ }
+ else
+ {
+ aNew <<= pEntry->GetAccessible();
}
+
+ fireAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOld, aNew );
+ fireAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOld, aNew );
+ fireAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), Any( AccessibleStateType::FOCUSED ) );
+ aNew >>= mxOldSelection;
}
@@ -1029,32 +1029,32 @@ ToolbarMenuEntry* ToolbarMenu::implCursorUpDown( bool bUp, bool bHomeEnd )
void ToolbarMenu_Impl::implHighlightControl( sal_uInt16 nCode, Control* pControl )
{
ValueSet* pValueSet = dynamic_cast< ValueSet* >( pControl );
- if( pValueSet )
+ if( !pValueSet )
+ return;
+
+ const size_t nItemCount = pValueSet->GetItemCount();
+ size_t nItemPos = VALUESET_ITEM_NOTFOUND;
+ switch( nCode )
{
- const size_t nItemCount = pValueSet->GetItemCount();
- size_t nItemPos = VALUESET_ITEM_NOTFOUND;
- switch( nCode )
- {
- case KEY_UP:
- {
- const sal_uInt16 nColCount = pValueSet->GetColCount();
- const sal_uInt16 nLastLine = nItemCount / nColCount;
- nItemPos = std::min( static_cast<size_t>(((nLastLine-1) * nColCount) + mnLastColumn), nItemCount-1 );
- break;
- }
- case KEY_DOWN:
- nItemPos = std::min( static_cast<size_t>(mnLastColumn), nItemCount-1 );
- break;
- case KEY_END:
- nItemPos = nItemCount -1;
- break;
- case KEY_HOME:
- nItemPos = 0;
- break;
- }
- pValueSet->SelectItem( pValueSet->GetItemId( nItemPos ) );
- notifyHighlightedEntry();
+ case KEY_UP:
+ {
+ const sal_uInt16 nColCount = pValueSet->GetColCount();
+ const sal_uInt16 nLastLine = nItemCount / nColCount;
+ nItemPos = std::min( static_cast<size_t>(((nLastLine-1) * nColCount) + mnLastColumn), nItemCount-1 );
+ break;
+ }
+ case KEY_DOWN:
+ nItemPos = std::min( static_cast<size_t>(mnLastColumn), nItemCount-1 );
+ break;
+ case KEY_END:
+ nItemPos = nItemCount -1;
+ break;
+ case KEY_HOME:
+ nItemPos = 0;
+ break;
}
+ pValueSet->SelectItem( pValueSet->GetItemId( nItemPos ) );
+ notifyHighlightedEntry();
}