diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2014-12-22 17:57:48 +0100 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2014-12-23 05:53:41 +0000 |
commit | ea644f0e90d0c9585e73bdec240908803a38d4a6 (patch) | |
tree | df140769eaf45d4205d4ac50147809597e3e6d73 /sfx2 | |
parent | a6c0583675b6fe4210ae8249728fe5d4df125f5c (diff) |
fdo#39440 reduce scope of local variables
This addresses some cppcheck warnings.
Change-Id: I404f121ee2e5020359a662f54ffe341f466cd1d5
Reviewed-on: https://gerrit.libreoffice.org/13608
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/newhelp.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/appl/shutdowniconw32.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/appl/workwin.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/control/dispatch.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/control/statcach.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/doc/doctemplates.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/doc/guisaveas.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/objcont.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 5 |
10 files changed, 22 insertions, 26 deletions
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index b629a09121ac..a2ae700b89b9 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -616,7 +616,6 @@ void IndexTabPage_Impl::InitializeIndex() if ( ( aAnySeq[0] >>= aKeywordList ) && ( aAnySeq[1] >>= aKeywordRefList ) && ( aAnySeq[2] >>= aAnchorRefList ) && ( aAnySeq[3] >>= aTitleRefList ) ) { - bool insert; sal_uInt16 nPos; int ndx,tmp; OUString aIndex, aTempString; @@ -634,7 +633,7 @@ void IndexTabPage_Impl::InitializeIndex() DBG_ASSERT( aRefList.getLength() == aAnchorList.getLength(),"reference list and title list of different length" ); - insert = ( ( ndx = aKeywordPair.indexOf( ';' ) ) == -1 ? sal_False : sal_True ); + const bool insert = ( ( ndx = aKeywordPair.indexOf( ';' ) ) == -1 ? sal_False : sal_True ); if ( insert ) { diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index e20eb0d011d1..40c6c2036fdc 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -238,7 +238,6 @@ static void deleteSystrayMenu( HMENU hMenu ) return; MENUITEMINFOW mi; - MYITEM *pMyItem; int pos=0; memset( &mi, 0, sizeof( mi ) ); mi.cbSize = sizeof( mi ); @@ -246,7 +245,7 @@ static void deleteSystrayMenu( HMENU hMenu ) while( GetMenuItemInfoW( hMenu, pos++, true, &mi ) ) { - pMyItem = (MYITEM*) mi.dwItemData; + MYITEM *pMyItem = (MYITEM*) mi.dwItemData; if( pMyItem ) { (pMyItem->text).clear(); diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index 6a9a71668540..01f827a232c3 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -1017,11 +1017,10 @@ void SfxWorkWindow::ReleaseChild_Impl( vcl::Window& rWindow ) SfxChild_Impl* SfxWorkWindow::FindChild_Impl( const vcl::Window& rWindow ) const { - SfxChild_Impl *pChild = 0; sal_uInt16 nCount = aChildren.size(); for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos ) { - pChild = aChildren[nPos]; + SfxChild_Impl *pChild = aChildren[nPos]; if ( pChild && pChild->pWin == &rWindow ) return pChild; } @@ -1759,11 +1758,10 @@ void SfxWorkWindow::ConfigChild_Impl(SfxChildIdentifier eChild, // windows may have been registered and released without an update until now Sort_Impl(); - SfxChild_Impl *pChild = 0; sal_uInt16 n; for ( n=0; n<aSortedList.size(); ++n ) { - pChild = aChildren[aSortedList[n]]; + SfxChild_Impl *pChild = aChildren[aSortedList[n]]; if ( pChild ) if ( pChild->pWin == pWin ) break; diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 4cf4e01d990e..b42f32aba37f 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -887,13 +887,12 @@ const SfxSlot* SfxDispatcher::GetSlot( const OUString& rCommand ) } } - const SfxSlot *pSlot=NULL; sal_uInt16 nFirstShell = 0; for ( sal_uInt16 i = nFirstShell; i < nTotCount; ++i ) { SfxShell *pObjShell = GetShell(i); SfxInterface *pIFace = pObjShell->GetInterface(); - pSlot = pIFace->GetSlot( rCommand ); + const SfxSlot *pSlot = pIFace->GetSlot( rCommand ); if ( pSlot ) return pSlot; } @@ -1262,7 +1261,6 @@ void SfxDispatcher::_Update_Impl( bool bUIActive, bool bIsMDIApp, bool bIsIPOwne SfxGetpApp(); SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl(); bool bIsActive = false; - bool bIsTaskActive = false; SfxDispatcher *pActDispat = pWorkWin->GetBindings().GetDispatcher_Impl(); SfxDispatcher *pDispat = this; while ( pActDispat && !bIsActive ) @@ -1401,6 +1399,8 @@ void SfxDispatcher::_Update_Impl( bool bUIActive, bool bIsMDIApp, bool bIsIPOwne if ( pTaskWin && ( bIsMDIApp || bIsIPOwner ) ) { + bool bIsTaskActive = false; + SfxDispatcher *pActDispatcher = pTaskWin->GetBindings().GetDispatcher_Impl(); SfxDispatcher *pDispatcher = this; while ( pActDispatcher && !bIsTaskActive ) diff --git a/sfx2/source/control/statcach.cxx b/sfx2/source/control/statcach.cxx index b74442221884..9a679e66853a 100644 --- a/sfx2/source/control/statcach.cxx +++ b/sfx2/source/control/statcach.cxx @@ -343,12 +343,12 @@ void SfxStateCache::SetState void SfxStateCache::SetVisibleState( bool bShow ) { - SfxItemState eState( SfxItemState::DEFAULT ); - const SfxPoolItem* pState( NULL ); - bool bDeleteItem( false ); - if ( bShow != bItemVisible ) { + SfxItemState eState( SfxItemState::DEFAULT ); + const SfxPoolItem* pState( NULL ); + bool bDeleteItem( false ); + bItemVisible = bShow; if ( bShow ) { diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index ea3ed0249991..7fa5f064ad4f 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -469,7 +469,6 @@ bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s assert(mnCurRegionId); // Only allowed in non root regions bool ret = true; - bool refresh = false; sal_uInt16 nSrcRegionId = mnCurRegionId-1; @@ -486,6 +485,8 @@ bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s if (pTarget && pSrc) { + bool refresh = false; + sal_uInt16 nTargetRegion = pTarget->mnRegionId; sal_uInt16 nTargetIdx = mpDocTemplates->GetCount(nTargetRegion); // Next Idx std::vector<sal_uInt16> aItemIds; // List of moved items ids (also prevents the invalidation of rItems iterators when we remove them as we go) diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index f76c7ad50571..8b795cf1700e 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -516,13 +516,12 @@ void SfxDocTplService_Impl::readFolderList() ResStringArray aShortNames( SfxResId( TEMPLATE_SHORT_NAMES_ARY ) ); ResStringArray aLongNames( SfxResId( TEMPLATE_LONG_NAMES_ARY ) ); - NamePair_Impl* pPair; sal_uInt16 nCount = (sal_uInt16)( std::min( aShortNames.Count(), aLongNames.Count() ) ); for ( sal_uInt16 i=0; i<nCount; i++ ) { - pPair = new NamePair_Impl; + NamePair_Impl* pPair = new NamePair_Impl; pPair->maShortName = aShortNames.GetString( i ); pPair->maLongName = aLongNames.GetString( i ); @@ -1584,14 +1583,14 @@ bool SfxDocTplService_Impl::removeGroup( const OUString& rGroupName ) try { - bool bHasNonRemovable = false; - bool bHasShared = false; - ResultSetInclude eInclude = INCLUDE_DOCUMENTS_ONLY; xResultSet = aGroup.createCursor( aProps, eInclude ); if ( xResultSet.is() ) { + bool bHasNonRemovable = false; + bool bHasShared = false; + uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY_THROW ); uno::Reference< XRow > xRow( xResultSet, UNO_QUERY_THROW ); diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 296a41bb99d3..4d51f8e9f6d0 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -802,9 +802,9 @@ sal_Int8 ModelData_Impl::CheckFilter( const OUString& aFilterName ) { uno::Reference< task::XInteractionHandler > xHandler; GetMediaDescr()[ OUString( "InteractionHandler" ) ] >>= xHandler; - bool bResult = false; if ( xHandler.is() ) { + bool bResult = false; try { task::ErrorCodeRequest aErrorCode; diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index de320ed56cf4..81edef6b545c 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -432,11 +432,12 @@ void SfxObjectShell::UpdateFromTemplate_Impl( ) { // check existence of template storage aTemplURL = aFoundName; - bool bLoad = false; // should the document checked against changes in the template ? if ( IsQueryLoadTemplate() ) { + bool bLoad = false; + // load document properties of template bool bOK = false; util::DateTime aTemplDate; diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 9a8c9e79452b..5d841a710a80 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -895,8 +895,8 @@ sal_uInt32 SfxObjectShell::HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDo if( xFilterCFG.is() ) { - bool bAbort = false; try { + bool bAbort = false; const SfxFilter* pFilter = pMedium->GetFilter(); Sequence < PropertyValue > aProps; Any aAny = xFilterCFG->getByName( pFilter->GetName() ); @@ -3158,10 +3158,9 @@ bool SfxObjectShell::SaveAsChildren( SfxMedium& rMedium ) if ( xStorage == GetStorage() ) return SaveChildren(); - bool bOasis = true; if ( pImp->mpObjectContainer ) { - bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 ); + bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 ); GetEmbeddedObjectContainer().StoreAsChildren(bOasis,SFX_CREATE_MODE_EMBEDDED == eCreateMode,xStorage); } |