diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2015-01-17 01:36:45 +0100 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-01-19 06:48:42 +0000 |
commit | f5f7a69628ad316298febe7b51234428a7896ff9 (patch) | |
tree | 7a5fedc897db12840a3f560a8564bb05028c60a5 /vcl | |
parent | 5f01eb5d7a3927d31b7dd268562a59e3dacdd8e8 (diff) |
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@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/menufloatingwindow.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/splitwin.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/status.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/taskpanelist.cxx | 5 | ||||
-rw-r--r-- | vcl/source/window/toolbox.cxx | 6 | ||||
-rw-r--r-- | vcl/unx/generic/app/salinst.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 8 | ||||
-rw-r--r-- | vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx | 3 | ||||
-rw-r--r-- | vcl/win/source/app/saldata.cxx | 3 | ||||
-rw-r--r-- | vcl/win/source/gdi/gdiimpl.cxx | 3 |
10 files changed, 18 insertions, 29 deletions
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index 36479605fdd5..e4b1124af4da 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 ab313f9d6aa9..3dd3e8c62379 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 5751c9218aa3..bca642e23612 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 cc13f1573be0..23b96486273f 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 62ac30cea012..ff8372117b77 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 55c645e85aad..aced86b81ed8 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 4ee389592c6b..c2ec2a0db43f 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 a9c42cf90576..7a613a760b6e 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 f149a1629ad2..821790beb0e9 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 9601643f9518..16b7d4b1d576 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; |