diff options
author | Noel <noelgrandin@gmail.com> | 2020-10-02 09:36:56 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-02 11:21:44 +0200 |
commit | eac4526f07bdf3cce70d84fb6e3d7896e7cae61b (patch) | |
tree | afea1fa35f749d1645a47cf0d8efb264fafd2932 /framework | |
parent | 4c5ffaf2ae8cd08a6d24bf674d203659e59f049f (diff) |
loplugin:reducevarscope in framework
Change-Id: I79237d68d815f9b46277a496a05b596f58b4028b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103813
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/dispatch/popupmenudispatcher.cxx | 3 | ||||
-rw-r--r-- | framework/source/fwe/classes/addonmenu.cxx | 2 | ||||
-rw-r--r-- | framework/source/fwe/classes/addonsoptions.cxx | 4 | ||||
-rw-r--r-- | framework/source/jobs/jobexecutor.cxx | 4 | ||||
-rw-r--r-- | framework/source/layoutmanager/toolbarlayoutmanager.cxx | 35 | ||||
-rw-r--r-- | framework/source/services/urltransformer.cxx | 6 | ||||
-rw-r--r-- | framework/source/uielement/menubarmanager.cxx | 5 | ||||
-rw-r--r-- | framework/source/uielement/menubarmerger.cxx | 3 | ||||
-rw-r--r-- | framework/source/uielement/statusbarmanager.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/subtoolbarcontroller.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/toolbarmanager.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/toolbarsmenucontroller.cxx | 3 |
12 files changed, 26 insertions, 45 deletions
diff --git a/framework/source/dispatch/popupmenudispatcher.cxx b/framework/source/dispatch/popupmenudispatcher.cxx index 264c74a4f034..991c8af1b555 100644 --- a/framework/source/dispatch/popupmenudispatcher.cxx +++ b/framework/source/dispatch/popupmenudispatcher.cxx @@ -119,7 +119,6 @@ SAL_CALL PopupMenuDispatcher::queryDispatch( try { // Just use the main part of the URL for popup menu controllers - sal_Int32 nQueryPart( 0 ); sal_Int32 nSchemePart( 0 ); OUString aBaseURL( "vnd.sun.star.popup:" ); OUString aURL( rURL.Complete ); @@ -128,7 +127,7 @@ SAL_CALL PopupMenuDispatcher::queryDispatch( if (( nSchemePart > 0 ) && ( aURL.getLength() > ( nSchemePart+1 ))) { - nQueryPart = aURL.indexOf( '?', nSchemePart ); + sal_Int32 nQueryPart = aURL.indexOf( '?', nSchemePart ); if ( nQueryPart > 0 ) aBaseURL += aURL.copy( nSchemePart+1, nQueryPart-(nSchemePart+1) ); else if ( nQueryPart == -1 ) diff --git a/framework/source/fwe/classes/addonmenu.cxx b/framework/source/fwe/classes/addonmenu.cxx index 86632c894be9..7e3103f17635 100644 --- a/framework/source/fwe/classes/addonmenu.cxx +++ b/framework/source/fwe/classes/addonmenu.cxx @@ -45,11 +45,11 @@ VclPtr<PopupMenu> AddonMenuManager::CreateAddonMenu( const Reference< XFrame >& { AddonsOptions aOptions; VclPtr<PopupMenu> pAddonMenu; - sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START; const Sequence< Sequence< PropertyValue > >& rAddonMenuEntries = aOptions.GetAddonsMenu(); if ( rAddonMenuEntries.hasElements() ) { + sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START; pAddonMenu = VclPtr<PopupMenu>::Create(); OUString aModuleIdentifier = vcl::CommandInfoProvider::GetModuleIdentifier( rFrame ); AddonMenuManager::BuildMenu( pAddonMenu, MENU_APPEND, nUniqueMenuId, rAddonMenuEntries, rFrame, aModuleIdentifier ); diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx index 1d1a89a55873..8d2aa243f702 100644 --- a/framework/source/fwe/classes/addonsoptions.cxx +++ b/framework/source/fwe/classes/addonsoptions.cxx @@ -1420,7 +1420,6 @@ void AddonsOptions_Impl::AppendPopupMenu( Sequence< PropertyValue >& rTargetPopu bool AddonsOptions_Impl::ReadToolBarItem( const OUString& aToolBarItemNodeName, Sequence< PropertyValue >& aToolBarItem ) { bool bResult = false; - OUString aTitle; OUString aURL; OUString aAddonToolBarItemTreeNode( aToolBarItemNodeName + m_aPathDelimiter ); @@ -1429,6 +1428,7 @@ bool AddonsOptions_Impl::ReadToolBarItem( const OUString& aToolBarItemNodeName, // A toolbar item must have a command URL if (( aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_URL ] >>= aURL ) && !aURL.isEmpty() ) { + OUString aTitle; if ( aURL == SEPARATOR_URL ) { // A separator toolbar item only needs a URL @@ -1473,7 +1473,6 @@ bool AddonsOptions_Impl::ReadToolBarItem( const OUString& aToolBarItemNodeName, bool AddonsOptions_Impl::ReadNotebookBarItem( const OUString& aNotebookBarItemNodeName, Sequence< PropertyValue >& aNotebookBarItem ) { bool bResult = false; - OUString aTitle; OUString aURL; OUString aAddonNotebookBarItemTreeNode( aNotebookBarItemNodeName + m_aPathDelimiter ); @@ -1482,6 +1481,7 @@ bool AddonsOptions_Impl::ReadNotebookBarItem( const OUString& aNotebookBarItemNo // A toolbar item must have a command URL if (( aNotebookBarItemNodePropValues[ OFFSET_NOTEBOOKBARITEM_URL ] >>= aURL ) && !aURL.isEmpty() ) { + OUString aTitle; if ( aURL == SEPARATOR_URL ) { // A separator toolbar item only needs a URL diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx index 7dd5f67d7de2..c90a8f56a1ed 100644 --- a/framework/source/jobs/jobexecutor.cxx +++ b/framework/source/jobs/jobexecutor.cxx @@ -241,8 +241,8 @@ void SAL_CALL JobExecutor::trigger( const OUString& sEvent ) void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent ) { - OUString EVENT_ON_DOCUMENT_OPENED("onDocumentOpened"); // Job UI event : OnNew or OnLoad - OUString EVENT_ON_DOCUMENT_ADDED("onDocumentAdded"); // Job API event : OnCreate or OnLoadFinished + static const OUStringLiteral EVENT_ON_DOCUMENT_OPENED(u"onDocumentOpened"); // Job UI event : OnNew or OnLoad + static const OUStringLiteral EVENT_ON_DOCUMENT_ADDED(u"onDocumentAdded"); // Job API event : OnCreate or OnLoadFinished OUString aModuleIdentifier; ::std::vector< JobData::TJob2DocEventBinding > lJobs; diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 17d2be8ca2ab..1b07f5a20e32 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -1475,7 +1475,6 @@ void ToolbarLayoutManager::implts_setElementData( UIElement& rElement, const uno else { bool bSetSize( false ); - awt::Point aDockPos; ::Point aPixelPos; ::Size aSize; @@ -1492,6 +1491,7 @@ void ToolbarLayoutManager::implts_setElementData( UIElement& rElement, const uno if ( isDefaultPos( rElement.m_aDockedData.m_aPos )) { + awt::Point aDockPos; implts_findNextDockingPos( rElement.m_aDockedData.m_nDockedArea, aSize, aDockPos, aPixelPos ); rElement.m_aDockedData.m_aPos = aDockPos; } @@ -2390,8 +2390,6 @@ void ToolbarLayoutManager::implts_calcWindowPosSizeOnSingleRowColumn( { sal_Int32 nDiff(0); sal_Int32 nRCSpace( rRowColumnWindowData.nSpace ); - sal_Int32 nTopDockingAreaSize(0); - sal_Int32 nBottomDockingAreaSize(0); sal_Int32 nContainerClientSize(0); if ( rRowColumnWindowData.aRowColumnWindows.empty() ) @@ -2404,8 +2402,8 @@ void ToolbarLayoutManager::implts_calcWindowPosSizeOnSingleRowColumn( } else { - nTopDockingAreaSize = implts_getTopBottomDockingAreaSizes().Width(); - nBottomDockingAreaSize = implts_getTopBottomDockingAreaSizes().Height(); + sal_Int32 nTopDockingAreaSize = implts_getTopBottomDockingAreaSizes().Width(); + sal_Int32 nBottomDockingAreaSize = implts_getTopBottomDockingAreaSizes().Height(); nContainerClientSize = ( rContainerSize.Height() - nTopDockingAreaSize - nBottomDockingAreaSize ); nDiff = nContainerClientSize - rRowColumnWindowData.nVarSize; } @@ -2608,7 +2606,6 @@ void ToolbarLayoutManager::implts_calcDockingPosSize( } vcl::Window* pDockingAreaWindow( nullptr ); - ToolBox* pToolBox( nullptr ); uno::Reference< awt::XWindow > xWindow( rUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY ); uno::Reference< awt::XWindow > xDockingAreaWindow; ::tools::Rectangle aTrackingRect( rTrackingRect ); @@ -2632,6 +2629,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize( SolarMutexGuard aGuard; pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ).get(); VclPtr<vcl::Window> pDockWindow = VCLUnoHelper::GetWindow( xWindow ); + ToolBox* pToolBox( nullptr ); if ( pDockWindow && pDockWindow->GetType() == WindowType::TOOLBOX ) pToolBox = static_cast<ToolBox *>(pDockWindow.get()); @@ -2966,8 +2964,8 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d const ::tools::Rectangle& rRowColRect, const Point& rMousePos ) { - const sal_Int32 nHorzVerticalRegionSize = 6; - const sal_Int32 nHorzVerticalMoveRegion = 4; + constexpr sal_Int32 nHorzVerticalRegionSize = 6; + constexpr sal_Int32 nHorzVerticalMoveRegion = 4; if ( rRowColRect.IsInside( rMousePos )) { @@ -3064,10 +3062,9 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d aReadGuard.clear(); sal_Int32 nDockPosY( 0 ); - vcl::Window* pDockingAreaWindow( nullptr ); { SolarMutexGuard aGuard; - pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ).get(); + vcl::Window* pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ).get(); VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); nDockPosY = pDockingAreaWindow->ScreenToOutputPixel( pContainerWindow->OutputToScreenPixel( ::Point( 0, nPosY ))).Y(); } @@ -3254,14 +3251,6 @@ void SAL_CALL ToolbarLayoutManager::startDocking( const awt::DockingEvent& e ) uno::Reference< awt::XWindow2 > xWindow( e.Source, uno::UNO_QUERY ); aReadGuard.clear(); - vcl::Window* pContainerWindow( nullptr ); - ::Point aMousePos; - { - SolarMutexGuard aGuard; - pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ).get(); - aMousePos = pContainerWindow->ScreenToOutputPixel( ::Point( e.MousePos.X, e.MousePos.Y )); - } - UIElement aUIElement = implts_findToolbar( e.Source ); if ( aUIElement.m_xUIElement.is() && xWindow.is() ) @@ -3296,8 +3285,8 @@ void SAL_CALL ToolbarLayoutManager::startDocking( const awt::DockingEvent& e ) awt::DockingData SAL_CALL ToolbarLayoutManager::docking( const awt::DockingEvent& e ) { - const sal_Int32 MAGNETIC_DISTANCE_UNDOCK = 25; - const sal_Int32 MAGNETIC_DISTANCE_DOCK = 20; + constexpr sal_Int32 MAGNETIC_DISTANCE_UNDOCK = 25; + constexpr sal_Int32 MAGNETIC_DISTANCE_DOCK = 20; SolarMutexClearableGuard aReadLock; awt::DockingData aDockingData; @@ -3310,7 +3299,6 @@ awt::DockingData SAL_CALL ToolbarLayoutManager::docking( const awt::DockingEvent uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow ); UIElement aUIDockingElement( m_aDockUIElement ); - DockingOperation eDockingOperation( DOCKOP_ON_COLROW ); bool bDockingInProgress( m_bDockingInProgress ); aReadLock.clear(); @@ -3323,9 +3311,9 @@ awt::DockingData SAL_CALL ToolbarLayoutManager::docking( const awt::DockingEvent { SolarMutexGuard aGuard; + DockingOperation eDockingOperation( DOCKOP_ON_COLROW ); ui::DockingArea eDockingArea( ui::DockingArea(-1) ); // none sal_Int32 nMagneticZone( aUIDockingElement.m_bFloating ? MAGNETIC_DISTANCE_DOCK : MAGNETIC_DISTANCE_UNDOCK ); - awt::Rectangle aNewTrackingRect; ::tools::Rectangle aTrackingRect( e.TrackingRectangle.X, e.TrackingRectangle.Y, ( e.TrackingRectangle.X + e.TrackingRectangle.Width ), ( e.TrackingRectangle.Y + e.TrackingRectangle.Height )); @@ -3405,9 +3393,8 @@ awt::DockingData SAL_CALL ToolbarLayoutManager::docking( const awt::DockingEvent implts_calcDockingPosSize( aUIDockingElement, eDockingOperation, aNewDockingRect, aMousePos ); ::Point aScreenPos = pContainerWindow->OutputToScreenPixel( aNewDockingRect.TopLeft() ); - aNewTrackingRect = awt::Rectangle( aScreenPos.X(), aScreenPos.Y(), + aDockingData.TrackingRectangle = awt::Rectangle( aScreenPos.X(), aScreenPos.Y(), aNewDockingRect.getWidth(), aNewDockingRect.getHeight() ); - aDockingData.TrackingRectangle = aNewTrackingRect; } else if (pToolBox) { diff --git a/framework/source/services/urltransformer.cxx b/framework/source/services/urltransformer.cxx index aa026f64504b..b5d319ef8716 100644 --- a/framework/source/services/urltransformer.cxx +++ b/framework/source/services/urltransformer.cxx @@ -117,10 +117,9 @@ sal_Bool SAL_CALL URLTransformer::parseStrict( css::util::URL& aURL ) } // Try to extract the protocol sal_Int32 nURLIndex = aURL.Complete.indexOf( ':' ); - OUString aProtocol; if ( nURLIndex > 1 ) { - aProtocol = aURL.Complete.copy( 0, nURLIndex+1 ); + OUString aProtocol = aURL.Complete.copy( 0, nURLIndex+1 ); // If INetURLObject knows this protocol let it parse if ( INetURLObject::CompareProtocolScheme( aProtocol ) != INetProtocol::NotValid ) @@ -187,10 +186,9 @@ sal_Bool SAL_CALL URLTransformer::parseSmart( css::util::URL& aURL, { // Try to extract the protocol sal_Int32 nIndex = aURL.Complete.indexOf( ':' ); - OUString aProtocol; if ( nIndex > 1 ) { - aProtocol = aURL.Complete.copy( 0, nIndex+1 ); + OUString aProtocol = aURL.Complete.copy( 0, nIndex+1 ); // If INetURLObject knows this protocol something is wrong as detected before => // give up and return false! diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 46e32ae1f2a2..27f5ae2931e2 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1495,16 +1495,15 @@ void MenuBarManager::GetPopupController( PopupControllerCache& rPopupController aPopupControllerEntry.m_xDispatchProvider = xDispatchProvider; // Just use the main part of the URL for popup menu controllers - sal_Int32 nQueryPart( 0 ); sal_Int32 nSchemePart( 0 ); - OUString aMainURL( "vnd.sun.star.popup:" ); OUString aMenuURL( menuItemHandler->aMenuItemURL ); nSchemePart = aMenuURL.indexOf( ':' ); if (( nSchemePart > 0 ) && ( aMenuURL.getLength() > ( nSchemePart+1 ))) { - nQueryPart = aMenuURL.indexOf( '?', nSchemePart ); + OUString aMainURL( "vnd.sun.star.popup:" ); + sal_Int32 nQueryPart = aMenuURL.indexOf( '?', nSchemePart ); if ( nQueryPart > 0 ) aMainURL += aMenuURL.copy( nSchemePart, nQueryPart-nSchemePart ); else if ( nQueryPart == -1 ) diff --git a/framework/source/uielement/menubarmerger.cxx b/framework/source/uielement/menubarmerger.cxx index 628f1d857ee1..526b4fb5fb81 100644 --- a/framework/source/uielement/menubarmerger.cxx +++ b/framework/source/uielement/menubarmerger.cxx @@ -350,13 +350,12 @@ bool MenuBarMerger::ProcessFallbackOperation( { const OUString aCmd( rReferencePath[nLevel] ); - sal_uInt16 nInsPos( MENU_APPEND ); VclPtr<PopupMenu> pPopupMenu = VclPtr<PopupMenu>::Create(); if ( bFirstLevel && ( aRefPathInfo.eResult == RP_MENUITEM_INSTEAD_OF_POPUPMENU_FOUND )) { // special case: menu item without popup - nInsPos = aRefPathInfo.nPos; + sal_uInt16 nInsPos = aRefPathInfo.nPos; sal_uInt16 nSetItemId = pCurrMenu->GetItemId( nInsPos ); pCurrMenu->SetItemCommand( nSetItemId, aCmd ); pCurrMenu->SetPopupMenu( nSetItemId, pPopupMenu ); diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx index f49716bc146e..6c417903b807 100644 --- a/framework/source/uielement/statusbarmanager.cxx +++ b/framework/source/uielement/statusbarmanager.cxx @@ -457,7 +457,7 @@ void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAcc } // Statusbar Merging - const sal_uInt16 STATUSBAR_ITEM_STARTID = 1000; + constexpr sal_uInt16 STATUSBAR_ITEM_STARTID = 1000; MergeStatusbarInstructionContainer aMergeInstructions = AddonsOptions().GetMergeStatusbarInstructions(); if ( !aMergeInstructions.empty() ) { diff --git a/framework/source/uielement/subtoolbarcontroller.cxx b/framework/source/uielement/subtoolbarcontroller.cxx index 3bbb2147f28b..6dcd8b67404a 100644 --- a/framework/source/uielement/subtoolbarcontroller.cxx +++ b/framework/source/uielement/subtoolbarcontroller.cxx @@ -364,12 +364,12 @@ void SubToolBarController::endPopupMode( const css::awt::EndPopupModeEvent& e ) if ( !(xSubToolBar.is() && xProp.is()) ) return; - OUString aPersistentString( "Persistent" ); try { VclPtr<vcl::Window> pTbxWindow = VCLUnoHelper::GetWindow( xSubToolBar ); if ( pTbxWindow && pTbxWindow->GetType() == WindowType::TOOLBOX ) { + OUString aPersistentString( "Persistent" ); css::uno::Any a = xProp->getPropertyValue( aPersistentString ); xProp->setPropertyValue( aPersistentString, css::uno::makeAny( false ) ); diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 7fa0393f9f0c..ea55656249ca 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -1075,7 +1075,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine // Support add-on toolbar merging here. Working directly on the toolbar object is much // simpler and faster. - const sal_uInt16 TOOLBAR_ITEM_STARTID = 1000; + constexpr sal_uInt16 TOOLBAR_ITEM_STARTID = 1000; MergeToolbarInstructionContainer aMergeInstructionContainer; diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index 351b9322f083..7cce1b37d29c 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -768,10 +768,9 @@ void SAL_CALL ToolbarsMenuController::initialize( const Sequence< Any >& aArgume Reference< XNameAccess > xPersistentWindowStateSupplier = css::ui::theWindowStateConfiguration::get( m_xContext ); // Retrieve persistent window state reference for our module - OUString aModuleIdentifier; try { - aModuleIdentifier = xModuleManager->identify( m_xFrame ); + OUString aModuleIdentifier = xModuleManager->identify( m_xFrame ); xPersistentWindowStateSupplier->getByName( aModuleIdentifier ) >>= m_xPersistentWindowState; Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier = |