From 1ae61b0ac4187b2938647f3ca0289a070a5dc7d2 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 22 Nov 2017 11:26:08 +0200 Subject: 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 Tested-by: Noel Grandin --- svtools/source/control/toolbarmenu.cxx | 102 ++++++++++++++++----------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'svtools/source/control/toolbarmenu.cxx') 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(((nLastLine-1) * nColCount) + mnLastColumn), nItemCount-1 ); - break; - } - case KEY_DOWN: - nItemPos = std::min( static_cast(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(((nLastLine-1) * nColCount) + mnLastColumn), nItemCount-1 ); + break; + } + case KEY_DOWN: + nItemPos = std::min( static_cast(mnLastColumn), nItemCount-1 ); + break; + case KEY_END: + nItemPos = nItemCount -1; + break; + case KEY_HOME: + nItemPos = 0; + break; } + pValueSet->SelectItem( pValueSet->GetItemId( nItemPos ) ); + notifyHighlightedEntry(); } -- cgit