summaryrefslogtreecommitdiff
path: root/framework/source/uielement/controlmenucontroller.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-07 20:32:26 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-08 11:01:31 +0200
commitff25a4a6f4b9763b09abbbd6a711fa4d18f40ade (patch)
treeded29238e8fb782c20b429f6d5df6c40a3bb2604 /framework/source/uielement/controlmenucontroller.cxx
parent32343bcbb786168df62f85a57e30c620c3d3bdb4 (diff)
loplugin:flatten in framework
Change-Id: I2a74a7543b5edd853396efa31a3e2568e6607778 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91848 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework/source/uielement/controlmenucontroller.cxx')
-rw-r--r--framework/source/uielement/controlmenucontroller.cxx114
1 files changed, 57 insertions, 57 deletions
diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx
index 3ed5bc11aee2..9e6d490d3e33 100644
--- a/framework/source/uielement/controlmenucontroller.cxx
+++ b/framework/source/uielement/controlmenucontroller.cxx
@@ -237,37 +237,37 @@ void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Eve
nMenuId = m_xResPopupMenu->GetItemId(sIdent);
}
- if (pPopupMenu)
- {
- SolarMutexGuard aSolarMutexGuard;
+ if (!pPopupMenu)
+ return;
+
+ SolarMutexGuard aSolarMutexGuard;
- PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
+ PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
- if ( !Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) != MENU_ITEM_NOTFOUND )
- pVCLPopupMenu->RemoveItem( pVCLPopupMenu->GetItemPos( nMenuId ));
- else if ( Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) == MENU_ITEM_NOTFOUND )
+ if ( !Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) != MENU_ITEM_NOTFOUND )
+ pVCLPopupMenu->RemoveItem( pVCLPopupMenu->GetItemPos( nMenuId ));
+ else if ( Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) == MENU_ITEM_NOTFOUND )
+ {
+ sal_Int16 nSourcePos = m_xResPopupMenu->GetItemPos(nMenuId);
+ sal_Int16 nPrevInSource = nSourcePos;
+ sal_uInt16 nPrevInConversion = MENU_ITEM_NOTFOUND;
+ while (nPrevInSource>0)
{
- sal_Int16 nSourcePos = m_xResPopupMenu->GetItemPos(nMenuId);
- sal_Int16 nPrevInSource = nSourcePos;
- sal_uInt16 nPrevInConversion = MENU_ITEM_NOTFOUND;
- while (nPrevInSource>0)
- {
- sal_Int16 nPrevId = m_xResPopupMenu->GetItemId(--nPrevInSource);
+ sal_Int16 nPrevId = m_xResPopupMenu->GetItemId(--nPrevInSource);
- // do we have the source's predecessor in our conversion menu, too ?
- nPrevInConversion = pVCLPopupMenu->GetItemPos( nPrevId );
- if ( nPrevInConversion != MENU_ITEM_NOTFOUND )
- break;
- }
+ // do we have the source's predecessor in our conversion menu, too ?
+ nPrevInConversion = pVCLPopupMenu->GetItemPos( nPrevId );
+ if ( nPrevInConversion != MENU_ITEM_NOTFOUND )
+ break;
+ }
- if ( MENU_ITEM_NOTFOUND == nPrevInConversion )
- // none of the items which precede the nSID-slot in the source menu are present in our conversion menu
- nPrevInConversion = sal::static_int_cast< sal_uInt16 >(-1); // put the item at the first position
+ if ( MENU_ITEM_NOTFOUND == nPrevInConversion )
+ // none of the items which precede the nSID-slot in the source menu are present in our conversion menu
+ nPrevInConversion = sal::static_int_cast< sal_uInt16 >(-1); // put the item at the first position
- pVCLPopupMenu->InsertItem(nMenuId, m_xResPopupMenu->GetItemText(nMenuId), m_xResPopupMenu->GetItemBits(nMenuId), OString(), ++nPrevInConversion);
- pVCLPopupMenu->SetItemImage(nMenuId, m_xResPopupMenu->GetItemImage(nMenuId));
- pVCLPopupMenu->SetHelpId(nMenuId, m_xResPopupMenu->GetHelpId(nMenuId));
- }
+ pVCLPopupMenu->InsertItem(nMenuId, m_xResPopupMenu->GetItemText(nMenuId), m_xResPopupMenu->GetItemBits(nMenuId), OString(), ++nPrevInConversion);
+ pVCLPopupMenu->SetItemImage(nMenuId, m_xResPopupMenu->GetItemImage(nMenuId));
+ pVCLPopupMenu->SetHelpId(nMenuId, m_xResPopupMenu->GetHelpId(nMenuId));
}
}
@@ -276,25 +276,25 @@ void SAL_CALL ControlMenuController::itemActivated( const css::awt::MenuEvent& )
{
osl::MutexGuard aLock( m_aMutex );
- if ( m_xPopupMenu.is() )
- {
- SolarMutexGuard aSolarMutexGuard;
+ if ( !m_xPopupMenu.is() )
+ return;
- // Check if some modes have changed so we have to update our menu images
- const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- bool bShowMenuImages = rSettings.GetUseImagesInMenus();
+ SolarMutexGuard aSolarMutexGuard;
- if (bShowMenuImages != m_bShowMenuImages)
- {
- m_bShowMenuImages = bShowMenuImages;
+ // Check if some modes have changed so we have to update our menu images
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ bool bShowMenuImages = rSettings.GetUseImagesInMenus();
- VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu ));
- if ( pPopupMenu )
- {
- PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
- if (pVCLPopupMenu)
- updateImagesPopupMenu( pVCLPopupMenu );
- }
+ if (bShowMenuImages != m_bShowMenuImages)
+ {
+ m_bShowMenuImages = bShowMenuImages;
+
+ VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(comphelper::getUnoTunnelImplementation<VCLXMenu>( m_xPopupMenu ));
+ if ( pPopupMenu )
+ {
+ PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
+ if (pVCLPopupMenu)
+ updateImagesPopupMenu( pVCLPopupMenu );
}
}
}
@@ -316,25 +316,25 @@ void SAL_CALL ControlMenuController::updatePopupMenu()
throwIfDisposed();
- if ( m_xFrame.is() && m_xPopupMenu.is() )
+ if ( !(m_xFrame.is() && m_xPopupMenu.is()) )
+ return;
+
+ css::util::URL aTargetURL;
+ Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
+ fillPopupMenu( m_xPopupMenu );
+ m_aURLToDispatchMap.free();
+
+ for (const char* aCommand : aCommands)
{
- css::util::URL aTargetURL;
- Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
- fillPopupMenu( m_xPopupMenu );
- m_aURLToDispatchMap.free();
+ aTargetURL.Complete = OUString::createFromAscii( aCommand );
+ m_xURLTransformer->parseStrict( aTargetURL );
- for (const char* aCommand : aCommands)
+ Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
+ if ( xDispatch.is() )
{
- aTargetURL.Complete = OUString::createFromAscii( aCommand );
- m_xURLTransformer->parseStrict( aTargetURL );
-
- Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
- if ( xDispatch.is() )
- {
- xDispatch->addStatusListener( static_cast< XStatusListener* >(this), aTargetURL );
- xDispatch->removeStatusListener( static_cast< XStatusListener* >(this), aTargetURL );
- m_aURLToDispatchMap.emplace( aTargetURL.Complete, xDispatch );
- }
+ xDispatch->addStatusListener( static_cast< XStatusListener* >(this), aTargetURL );
+ xDispatch->removeStatusListener( static_cast< XStatusListener* >(this), aTargetURL );
+ m_aURLToDispatchMap.emplace( aTargetURL.Complete, xDispatch );
}
}
}