diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2014-12-16 18:04:05 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-12-16 20:42:30 +0000 |
commit | 38b8c1e8804c8556e71e1ec7c1f1350d75dc04bf (patch) | |
tree | f0f64824cbf66a6be471dd4a998c7f23df227309 /framework | |
parent | d41656754027da587298f7373770a62b7e7b3f98 (diff) |
fdo#39440 reduce scope of local variables
This addresses some cppcheck warnings.
Change-Id: I57f336c6ab3c418eac82397edeadecb4c1b168a7
Reviewed-on: https://gerrit.libreoffice.org/13495
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/classes/menumanager.cxx | 3 | ||||
-rw-r--r-- | framework/source/fwe/classes/bmkmenu.cxx | 3 | ||||
-rw-r--r-- | framework/source/fwe/xml/menudocumenthandler.cxx | 3 | ||||
-rw-r--r-- | framework/source/fwe/xml/statusbardocumenthandler.cxx | 3 | ||||
-rw-r--r-- | framework/source/fwe/xml/toolboxdocumenthandler.cxx | 3 | ||||
-rw-r--r-- | framework/source/layoutmanager/toolbarlayoutmanager.cxx | 17 | ||||
-rw-r--r-- | framework/source/uielement/menubarmanager.cxx | 5 | ||||
-rw-r--r-- | framework/source/uielement/toolbarmanager.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/toolbarsmenucontroller.cxx | 3 |
9 files changed, 20 insertions, 22 deletions
diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx index 0abb09306d2a..c09cc87a0006 100644 --- a/framework/source/classes/menumanager.cxx +++ b/framework/source/classes/menumanager.cxx @@ -507,11 +507,12 @@ void MenuManager::UpdateSpecialFileMenu( Menu* pMenu ) { SolarMutexGuard g; - int nRemoveItemCount = 0; int nItemCount = pMenu->GetItemCount(); if ( nItemCount > 0 ) { + int nRemoveItemCount = 0; + // remove all old picklist entries from menu sal_uInt16 nPos = pMenu->GetItemPos( START_ITEMID_PICKLIST ); for ( sal_uInt16 n = nPos; n < pMenu->GetItemCount(); ) diff --git a/framework/source/fwe/classes/bmkmenu.cxx b/framework/source/fwe/classes/bmkmenu.cxx index 550da2a9a6ca..bf1396b2c5dd 100644 --- a/framework/source/fwe/classes/bmkmenu.cxx +++ b/framework/source/fwe/classes/bmkmenu.cxx @@ -136,11 +136,12 @@ void BmkMenu::Initialize() InsertSeparator(); else { - bool bImageSet = false; sal_uInt16 nId = CreateMenuId(); if ( bShowMenuImages ) { + bool bImageSet = false; + if ( !aImageId.isEmpty() ) { Image aImage = GetImageFromURL( m_xFrame, aImageId, false ); diff --git a/framework/source/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx index 3d8945d2966a..58e03897d26c 100644 --- a/framework/source/fwe/xml/menudocumenthandler.cxx +++ b/framework/source/fwe/xml/menudocumenthandler.cxx @@ -184,10 +184,9 @@ throw( SAXException, RuntimeException, std::exception ) OUString ReadMenuDocumentHandlerBase::getErrorLineString() { - char buffer[32]; - if ( m_xLocator.is() ) { + char buffer[32]; snprintf( buffer, sizeof(buffer), "Line: %ld - ", static_cast<long>( m_xLocator->getLineNumber() )); return OUString::createFromAscii( buffer ); } diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx index a3bd46b246a5..ddc360c95009 100644 --- a/framework/source/fwe/xml/statusbardocumenthandler.cxx +++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx @@ -469,10 +469,9 @@ OUString OReadStatusBarDocumentHandler::getErrorLineString() { SolarMutexGuard g; - char buffer[32]; - if ( m_xLocator.is() ) { + char buffer[32]; snprintf( buffer, sizeof(buffer), "Line: %ld - ", static_cast<long>( m_xLocator->getLineNumber() )); return OUString::createFromAscii( buffer ); } diff --git a/framework/source/fwe/xml/toolboxdocumenthandler.cxx b/framework/source/fwe/xml/toolboxdocumenthandler.cxx index e6065a140470..15c0ad3af8b6 100644 --- a/framework/source/fwe/xml/toolboxdocumenthandler.cxx +++ b/framework/source/fwe/xml/toolboxdocumenthandler.cxx @@ -639,10 +639,9 @@ OUString OReadToolBoxDocumentHandler::getErrorLineString() { SolarMutexGuard g; - char buffer[32]; - if ( m_xLocator.is() ) { + char buffer[32]; snprintf( buffer, sizeof(buffer), "Line: %ld - ", static_cast<long>( m_xLocator->getLineNumber() )); return OUString::createFromAscii( buffer ); } diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 0811d5fea899..b044bad39c7e 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -482,8 +482,6 @@ bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL ) } implts_setToolbarCreation( false ); - bool bVisible( false ); - bool bFloating( false ); if ( xUIElement.is() ) { uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY ); @@ -503,6 +501,9 @@ bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL ) } } + bool bVisible = false; + bool bFloating = false; + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ SolarMutexClearableGuard aWriteLock; @@ -1752,11 +1753,10 @@ awt::Point ToolbarLayoutManager::implts_findNextCascadeFloatingPos() awt::Point aCurrPos( aStartPos ); awt::Rectangle aRect; - vcl::Window* pContainerWindow( 0 ); if ( xContainerWindow.is() ) { SolarMutexGuard aGuard; - pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); + vcl::Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); if ( pContainerWindow ) aStartPos = AWTPoint(pContainerWindow->OutputToScreenPixel(VCLPoint(aStartPos))); } @@ -2608,7 +2608,6 @@ void ToolbarLayoutManager::implts_calcDockingPosSize( aContainerWinSize = pContainerWindow->GetOutputSizePixel(); } - vcl::Window* pDockWindow( 0 ); vcl::Window* pDockingAreaWindow( 0 ); ToolBox* pToolBox( 0 ); uno::Reference< awt::XWindow > xWindow( rUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY ); @@ -2633,7 +2632,7 @@ void ToolbarLayoutManager::implts_calcDockingPosSize( { SolarMutexGuard aGuard; pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ); - pDockWindow = VCLUnoHelper::GetWindow( xWindow ); + vcl::Window* pDockWindow = VCLUnoHelper::GetWindow( xWindow ); if ( pDockWindow && pDockWindow->GetType() == WINDOW_TOOLBOX ) pToolBox = static_cast<ToolBox *>(pDockWindow); @@ -3068,11 +3067,10 @@ framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_d sal_Int32 nDockPosY( 0 ); vcl::Window* pDockingAreaWindow( 0 ); - vcl::Window* pContainerWindow( 0 ); { SolarMutexGuard aGuard; pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow ); - pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); + vcl::Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); nDockPosY = pDockingAreaWindow->ScreenToOutputPixel( pContainerWindow->OutputToScreenPixel( ::Point( 0, nPosY ))).Y(); } @@ -3263,7 +3261,6 @@ throw (uno::RuntimeException, std::exception) aReadGuard.clear(); vcl::Window* pContainerWindow( 0 ); - vcl::Window* pWindow( 0 ); ::Point aMousePos; { SolarMutexGuard aGuard; @@ -3289,7 +3286,7 @@ throw (uno::RuntimeException, std::exception) SolarMutexGuard aGuard; - pWindow = VCLUnoHelper::GetWindow( xWindow ); + vcl::Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX ) { ToolBox* pToolBox = static_cast<ToolBox *>(pWindow); diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 23e0c27e4e2e..4fe9415c48a1 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1620,8 +1620,6 @@ void MenuBarManager::FillMenu( OUString aLabel; OUString aHelpURL; OUString aModuleIdentifier( rModuleIdentifier ); - bool bShow(true); - bool bEnabled(true); sal_uInt16 nType = 0; Reference< XIndexAccess > xIndexContainer; Reference< XDispatchProvider > xDispatchProvider( rDispatchProvider ); @@ -1630,6 +1628,9 @@ void MenuBarManager::FillMenu( { if ( rItemContainer->getByIndex( n ) >>= aProp ) { + bool bShow = true; + bool bEnabled = true; + for ( int i = 0; i < aProp.getLength(); i++ ) { OUString aPropName = aProp[i].Name; diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index c9665323a1cc..ca8309b60366 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -1204,7 +1204,6 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine OUString aTooltip; sal_uInt16 nType( ::com::sun::star::ui::ItemType::DEFAULT ); sal_uInt16 nWidth( 0 ); - bool bIsVisible( true ); sal_uInt32 nStyle( 0 ); Reference< XIndexAccess > aMenuDesc; @@ -1212,6 +1211,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine { if ( rItemContainer->getByIndex( n ) >>= aProp ) { + bool bIsVisible( true ); for ( int i = 0; i < aProp.getLength(); i++ ) { if ( aProp[i].Name == ITEM_DESCRIPTOR_COMMANDURL ) diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index ebbb01c37d14..ac16ea6b251f 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -379,10 +379,11 @@ void ToolbarsMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& r OUString aUIName = pIter->second; bool bHideFromMenu( false ); bool bContextSensitive( false ); - bool bVisible( false ); if ( aUIName.isEmpty() && m_xPersistentWindowState.is() ) { + bool bVisible( false ); + try { Sequence< PropertyValue > aWindowState; |