[Libreoffice-commits] core.git: vcl/source vcl/unx vcl/win

Michael Weghorn m.weghorn at posteo.de
Sun Jan 18 22:49:11 PST 2015


 vcl/source/window/menufloatingwindow.cxx |    6 ++----
 vcl/source/window/splitwin.cxx           |    6 ++----
 vcl/source/window/status.cxx             |    4 +---
 vcl/source/window/taskpanelist.cxx       |    5 +++--
 vcl/source/window/toolbox.cxx            |    6 +++---
 vcl/unx/generic/app/salinst.cxx          |    3 +--
 vcl/unx/generic/printer/ppdparser.cxx    |    8 +++-----
 vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx |    3 +--
 vcl/win/source/app/saldata.cxx           |    3 +--
 vcl/win/source/gdi/gdiimpl.cxx           |    3 +--
 10 files changed, 18 insertions(+), 29 deletions(-)

New commits:
commit f5f7a69628ad316298febe7b51234428a7896ff9
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Sat Jan 17 01:36:45 2015 +0100

    fdo#39440 vcl: reduce scope of local variables
    
    This addresses some cppcheck warnings.
    
    Change-Id: Ia3910e7f1b33d16866b7e606fd648f152f9fe67a
    Reviewed-on: https://gerrit.libreoffice.org/13971
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 3647960..e4b1124 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -70,11 +70,10 @@ void MenuFloatingWindow::doShutdown()
         if (!bKeyInput && pMenu && pMenu->pStartedFrom && !pMenu->pStartedFrom->IsMenuBar())
         {
             // #102461# remove highlight in parent
-            MenuItemData* pData;
             size_t i, nCount = pMenu->pStartedFrom->pItemList->size();
             for(i = 0; i < nCount; i++)
             {
-                pData = pMenu->pStartedFrom->pItemList->GetDataFromPos( i );
+                MenuItemData* pData = pMenu->pStartedFrom->pItemList->GetDataFromPos( i );
                 if( pData && ( pData->pSubMenu == pMenu ) )
                     break;
             }
@@ -672,11 +671,10 @@ void MenuFloatingWindow::ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTime
         if (pMenu->pStartedFrom && !pMenu->pStartedFrom->IsMenuBar())
         {
             // #102461# make sure parent entry is highlighted as well
-            MenuItemData* pData;
             size_t i, nCount = pMenu->pStartedFrom->pItemList->size();
             for(i = 0; i < nCount; i++)
             {
-                pData = pMenu->pStartedFrom->pItemList->GetDataFromPos( i );
+                MenuItemData* pData = pMenu->pStartedFrom->pItemList->GetDataFromPos( i );
                 if( pData && ( pData->pSubMenu == pMenu ) )
                     break;
             }
diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx
index ab313f9..3dd3e8c 100644
--- a/vcl/source/window/splitwin.cxx
+++ b/vcl/source/window/splitwin.cxx
@@ -416,7 +416,6 @@ static void ImplCalcSet( ImplSplitSet* pSet,
     sal_uInt16              nAbsItems;
     long                nCalcSize;
     long                nSizeDelta;
-    long                nCurSize;
     long                nSizeWinSize;
     long                nNewSizeWinSize;
     long                nTemp;
@@ -443,7 +442,7 @@ static void ImplCalcSet( ImplSplitSet* pSet,
     else
         nCalcSize = nSetWidth;
     nCalcSize -= (nVisItems-1)*pSet->mnSplitSize;
-    nCurSize   = 0;
+    long nCurSize   = 0;
     if ( pSet->mbCalcPix || (pSet->mnLastSize != nCalcSize) )
     {
         long nPercentFactor = 10;
@@ -2003,7 +2002,6 @@ void SplitWindow::ImplStartSplit( const MouseEvent& rMEvt )
         ImplSplitItem*  pSplitItem;
         long            nCurMaxSize;
         sal_uInt16          nTemp;
-        bool            bDown;
         bool            bPropSmaller;
 
         mnMouseModifier = rMEvt.GetModifier();
@@ -2028,7 +2026,7 @@ void SplitWindow::ImplStartSplit( const MouseEvent& rMEvt )
 
         if ( mpSplitSet->mpItems )
         {
-            bDown = true;
+            bool bDown = true;
             if ( (mpSplitSet == mpMainSet) && mbBottomRight )
                 bDown = false;
 
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 5751c92..bca642e23 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -315,11 +315,9 @@ Rectangle StatusBar::ImplGetItemRectPos( sal_uInt16 nPos ) const
 
 sal_uInt16 StatusBar::ImplGetFirstVisiblePos() const
 {
-    ImplStatusItem* pItem;
-
     for( size_t nPos = 0; nPos < mpItemList->size(); nPos++ )
     {
-        pItem = (*mpItemList)[ nPos ];
+        ImplStatusItem* pItem = (*mpItemList)[ nPos ];
         if ( pItem )
         {
             if ( pItem->mbVisible )
diff --git a/vcl/source/window/taskpanelist.cxx b/vcl/source/window/taskpanelist.cxx
index cc13f15..23b9648 100644
--- a/vcl/source/window/taskpanelist.cxx
+++ b/vcl/source/window/taskpanelist.cxx
@@ -162,12 +162,13 @@ bool TaskPaneList::HandleKeyEvent( KeyEvent aKeyEvent )
 
     // Since the design of Ctrl-Tab looks to be inconsistent ( non-modal dialogs are not reachable
     // and the shortcut conflicts with tab-control shortcut ), it is no more supported
-    bool bSplitterOnly = false;
-    bool bFocusInList = false;
     vcl::KeyCode aKeyCode = aKeyEvent.GetKeyCode();
     bool bForward = !aKeyCode.IsShift();
     if( aKeyCode.GetCode() == KEY_F6 && ! aKeyCode.IsMod2() ) // F6
     {
+        bool bSplitterOnly = false;
+        bool bFocusInList = false;
+
         bSplitterOnly = aKeyCode.IsMod1() && aKeyCode.IsShift();
 
         // is the focus in the list ?
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 62ac30c..ff83721 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1733,13 +1733,13 @@ bool ToolBox::ImplCalcItem()
         std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
         while ( it != mpData->m_aItems.end() )
         {
-            bool bImage;
-            bool bText;
-
             it->mbVisibleText = false;  // indicates if text will definitely be drawn, influences dropdown pos
 
             if ( it->meType == ToolBoxItemType::BUTTON )
             {
+                bool bImage;
+                bool bText;
+
                 // check if image and/or text exists
                 if ( !(it->maImage) )
                     bImage = false;
diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx
index 55c645e..aced86b 100644
--- a/vcl/unx/generic/app/salinst.cxx
+++ b/vcl/unx/generic/app/salinst.cxx
@@ -202,13 +202,12 @@ static void getServerDirectories( std::list< OString >& o_rFontPaths )
         if( pPipe )
         {
             char line[1024];
-            char* pSearch;
             while( fgets( line, sizeof(line), pPipe ) )
             {
                 int nLen = strlen( line );
                 if( line[nLen-1] == '\n' )
                     line[nLen-1] = 0;
-                pSearch = strstr( line, ": " );
+                char* pSearch = strstr( line, ": " );
                 if( pSearch )
                     aLines.push_back( pSearch+2 );
             }
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index 4ee3895..c2ec2a0 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -929,12 +929,11 @@ void PPDParser::parse( ::std::list< OString >& rLines )
         {
             //fdo#43049 very basic support for Custom entries, we ignore the
             //validation params and types
-            PPDKey* pKey = NULL;
             OUString aUniKey(OStringToOUString(aKey, RTL_TEXTENCODING_MS_1252));
             keyit = m_aKeys.find( aUniKey );
             if(keyit != m_aKeys.end())
             {
-                pKey = keyit->second;
+                PPDKey* pKey = keyit->second;
                 pKey->insertValue("Custom", eInvocation, true);
             }
             continue;
@@ -1362,14 +1361,13 @@ OUString PPDParser::matchPaper( int nWidth, int nHeight ) const
         return OUString();
 
     int nPDim = -1;
-    double PDWidth, PDHeight;
     double fSort = 2e36, fNewSort;
 
     for( int i = 0; i < m_pPaperDimensions->countValues(); i++ )
     {
         OUString aArea =  m_pPaperDimensions->getValue( i )->m_aValue;
-        PDWidth     = StringToDouble( GetCommandLineToken( 0, aArea ) );
-        PDHeight    = StringToDouble( GetCommandLineToken( 1, aArea ) );
+        double PDWidth     = StringToDouble( GetCommandLineToken( 0, aArea ) );
+        double PDHeight    = StringToDouble( GetCommandLineToken( 1, aArea ) );
         PDWidth     /= (double)nWidth;
         PDHeight    /= (double)nHeight;
         if( PDWidth >= 0.9      &&  PDWidth <= 1.1      &&
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index a9c42cf..7a613a7 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -232,12 +232,11 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(m_pFilterView), false);
     gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(m_pFilterView), true);
 
-    GtkTreeViewColumn *column;
     GtkCellRenderer *cell;
 
     for (i = 0; i < 2; ++i)
     {
-        column = gtk_tree_view_column_new ();
+        GtkTreeViewColumn *column = gtk_tree_view_column_new ();
         cell = gtk_cell_renderer_text_new ();
         gtk_tree_view_column_set_expand (column, true);
         gtk_tree_view_column_pack_start (column, cell, false);
diff --git a/vcl/win/source/app/saldata.cxx b/vcl/win/source/app/saldata.cxx
index f149a16..821790b 100644
--- a/vcl/win/source/app/saldata.cxx
+++ b/vcl/win/source/app/saldata.cxx
@@ -52,12 +52,11 @@ OUString ImplSalGetUniString(const sal_Char* pStr, sal_Int32 const nLen)
 int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 )
 {
     int         nRet;
-    wchar_t     c1;
     char       c2;
     do
     {
         // change to LowerCase if the char is between 'A' and 'Z'
-        c1 = *pStr1;
+        wchar_t c1 = *pStr1;
         c2 = *pStr2;
         if ( (c1 >= 65) && (c1 <= 90) )
             c1 += 32;
diff --git a/vcl/win/source/gdi/gdiimpl.cxx b/vcl/win/source/gdi/gdiimpl.cxx
index 9601643..16b7d4b 100644
--- a/vcl/win/source/gdi/gdiimpl.cxx
+++ b/vcl/win/source/gdi/gdiimpl.cxx
@@ -1743,12 +1743,11 @@ void WinSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pP
     // for NT, we can handover the array directly
    DBG_ASSERT( sizeof( POINT ) == sizeof( SalPoint ),
                 "WinSalGraphicsImpl::DrawPolyPolygon(): POINT != SalPoint" );
-    const SalPoint* pPolyAry;
     UINT            n = 0;
     for ( i = 0; i < (UINT)nPoly; i++ )
     {
         nPoints = pWinPointAry[i];
-        pPolyAry = pPtAry[i];
+        const SalPoint* pPolyAry = pPtAry[i];
         memcpy( pWinPointAryAry+n, pPolyAry, (nPoints-1)*sizeof(POINT) );
         pWinPointAryAry[n+nPoints-1] = pWinPointAryAry[n];
         n += nPoints;


More information about the Libreoffice-commits mailing list