[Libreoffice-commits] core.git: sdext/source sfx2/source shell/source starmath/source

Michael Weghorn m.weghorn at posteo.de
Mon Dec 22 21:54:05 PST 2014


 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |    3 +--
 sfx2/source/appl/newhelp.cxx                          |    3 +--
 sfx2/source/appl/shutdowniconw32.cxx                  |    3 +--
 sfx2/source/appl/workwin.cxx                          |    6 ++----
 sfx2/source/control/dispatch.cxx                      |    6 +++---
 sfx2/source/control/statcach.cxx                      |    8 ++++----
 sfx2/source/control/templatelocalview.cxx             |    3 ++-
 sfx2/source/doc/doctemplates.cxx                      |    9 ++++-----
 sfx2/source/doc/guisaveas.cxx                         |    2 +-
 sfx2/source/doc/objcont.cxx                           |    3 ++-
 sfx2/source/doc/objstor.cxx                           |    5 ++---
 shell/source/backends/gconfbe/gconfaccess.cxx         |    3 +--
 starmath/source/visitors.cxx                          |    2 +-
 13 files changed, 25 insertions(+), 31 deletions(-)

New commits:
commit ea644f0e90d0c9585e73bdec240908803a38d4a6
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Mon Dec 22 17:57:48 2014 +0100

    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 at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 129f2b9..4484e8f 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -149,11 +149,10 @@ bool ExtractJpegData(Stream* str, OutputBuffer& outBuf)
     int bytesToLen = -1;
     bool collectBytes = false;
     int startOfScan = 0;
-    int b2 = -1;
     int b1 = -1;
     for (; ; )
     {
-        b2 = b1;
+        const int b2 = b1;
         b1 = str->getChar();
 
         if (b1 == -1)
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index b629a09..a2ae700 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 e20eb0d..40c6c20 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 6a9a716..01f827a 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 4cf4e01..b42f32a 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 b744422..9a679e6 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 ea3ed02..7fa5f06 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 f76c7ad..8b795cf 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 296a41b..4d51f8e 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 de320ed..81edef6 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 9a8c9e7..5d841a7 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);
     }
 
diff --git a/shell/source/backends/gconfbe/gconfaccess.cxx b/shell/source/backends/gconfbe/gconfaccess.cxx
index 1b30545..bd419c9 100644
--- a/shell/source/backends/gconfbe/gconfaccess.cxx
+++ b/shell/source/backends/gconfbe/gconfaccess.cxx
@@ -820,10 +820,9 @@ std::size_t const nConfigurationValues =
 css::beans::Optional< css::uno::Any > getValue(ConfigurationValue const & data)
 {
     GConfClient* pClient = getGconfClient();
-    GConfValue* pGconfValue;
     if( ( data.nDependsOn == SETTINGS_LAST ) || isDependencySatisfied( pClient, data ) )
     {
-        pGconfValue = gconf_client_get( pClient, data.GconfItem, NULL );
+        GConfValue* pGconfValue = gconf_client_get( pClient, data.GconfItem, NULL );
 
         if( pGconfValue != NULL )
         {
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index e929837..40e3667 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -1636,8 +1636,8 @@ void SmCloningVisitor::CloneKids( SmStructureNode* pSource, SmStructureNode* pTa
     SmNodeArray aNodes( nSize );
 
     //Clone children
-    SmNode* pKid;
     for( sal_uInt16 i = 0; i < nSize; i++ ){
+        SmNode* pKid;
         if( NULL != ( pKid = pSource->GetSubNode( i ) ) )
             pKid->Accept( this );
         else


More information about the Libreoffice-commits mailing list